public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: Bastien Nocera <hadess@hadess.net>
To: BlueZ development <bluez-devel@lists.sourceforge.net>
Subject: Re: [Bluez-devel] [PATCH] Send DefaultAdapterChanged more often
Date: Fri, 01 Feb 2008 12:33:16 +0000	[thread overview]
Message-ID: <1201869196.2389.321.camel@cookie.hadess.net> (raw)
In-Reply-To: <1201866163.2389.311.camel@cookie.hadess.net>

[-- Attachment #1: Type: text/plain, Size: 536 bytes --]


On Fri, 2008-02-01 at 11:42 +0000, Bastien Nocera wrote:
> Before the patch, we only used to send the DefaultAdapter changed from
> one adapter to another, never when there wasn't a new default adapter.
> 
> This allows us to remove bad tricks from client.c as well.
> 
> Both patches attached. The bluez-gnome patch includes the changes from
> the client.c cleanup thread.
> 
> Try plugging/unplugging your adapters after the patching, and the
> treeview will magically change its contents.

Updated patch with documentation changes.

[-- Attachment #2: bluez-utils-more-default-adapter-signal-2.patch --]
[-- Type: text/x-patch, Size: 2352 bytes --]

Index: dbus-api.txt
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/dbus-api.txt,v
retrieving revision 1.136
diff -u -p -r1.136 dbus-api.txt
--- dbus-api.txt	1 Feb 2008 12:22:09 -0000	1.136
+++ dbus-api.txt	1 Feb 2008 12:32:46 -0000
@@ -224,7 +224,8 @@ Signals		void AdapterAdded(string path)
 
 		void DefaultAdapterChanged(string path)
 
-			Parameter is object path of the new default adapter.
+			Parameter is object path of the new default adapter,
+			or an empty string if there is no available adapters.
 
 		void ServiceAdded(string path)
 
Index: dbus-hci.c
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/dbus-hci.c,v
retrieving revision 1.35
diff -u -p -r1.35 dbus-hci.c
--- dbus-hci.c	28 Jan 2008 10:38:40 -0000	1.35
+++ dbus-hci.c	1 Feb 2008 12:32:47 -0000
@@ -532,7 +532,7 @@ int hcid_dbus_unregister_device(uint16_t
 
 	ret = unregister_adapter_path(path);
 
-	if (ret == 0 && get_default_adapter() == id) {
+	if (ret == 0 && (get_default_adapter() == id || get_default_adapter() < 0)) {
 		int new_default = hci_get_route(NULL);
 		set_default_adapter(new_default);
 		if (new_default >= 0) {
@@ -543,6 +543,13 @@ int hcid_dbus_unregister_device(uint16_t
 							"DefaultAdapterChanged",
 							DBUS_TYPE_STRING, &pptr,
 							DBUS_TYPE_INVALID);
+		} else {
+			*path = '\0';
+			dbus_connection_emit_signal(connection, BASE_PATH,
+							MANAGER_INTERFACE,
+							"DefaultAdapterChanged",
+							DBUS_TYPE_STRING, &pptr,
+							DBUS_TYPE_INVALID);
 		}
 	}
 
@@ -551,7 +558,7 @@ int hcid_dbus_unregister_device(uint16_t
 
 int hcid_dbus_start_device(uint16_t id)
 {
-	char path[MAX_PATH_LENGTH];
+	char path[MAX_PATH_LENGTH], *pptr;
 	struct hci_dev_info di;
 	struct adapter* adapter;
 	struct hci_conn_list_req *cl = NULL;
@@ -633,10 +640,17 @@ int hcid_dbus_start_device(uint16_t id)
 					DBUS_TYPE_STRING, &mode,
 					DBUS_TYPE_INVALID);
 
-failed:
-	if (ret == 0 && get_default_adapter() < 0)
+	if (get_default_adapter() < 0) {
 		set_default_adapter(id);
+		pptr = path;
+		dbus_connection_emit_signal(connection, BASE_PATH,
+					    MANAGER_INTERFACE,
+					    "DefaultAdapterChanged",
+					    DBUS_TYPE_STRING, &pptr,
+					    DBUS_TYPE_INVALID);
+	}
 
+failed:
 	if (dd >= 0)
 		hci_close_dev(dd);
 

[-- Attachment #3: Type: text/plain, Size: 228 bytes --]

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

[-- Attachment #4: Type: text/plain, Size: 164 bytes --]

_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

  reply	other threads:[~2008-02-01 12:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-01 11:42 [Bluez-devel] [PATCH] Send DefaultAdapterChanged more often Bastien Nocera
2008-02-01 12:33 ` Bastien Nocera [this message]
2008-02-01 12:40   ` Marcel Holtmann
2008-02-01 12:44 ` Marcel Holtmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1201869196.2389.321.camel@cookie.hadess.net \
    --to=hadess@hadess.net \
    --cc=bluez-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox