Send DefaultAdapterChanged more often
PATCH 1/1 Send DefaultAdapterChanged more often
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.
Cheers
Index: dbus-hci.c
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/dbus-hci.c,v
retrieving revision 1.35
dbus-hci.c +18 -4
@@ -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_tint 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);
Index: bluetooth-device-selection.c
===================================================================
RCS file: /cvsroot/bluez/gnome/common/bluetooth-device-selection.c,v retrieving revision 1.11
bluetooth-device-selection.c +49 -6
99 lines not on this page · raw message
Index: client.c
===================================================================
RCS file: /cvsroot/bluez/gnome/common/client.c,v
retrieving revision 1.37
client.c +67 -13
139 lines not on this page · raw message
Index: test-client.c
===================================================================
RCS file: /cvsroot/bluez/gnome/common/test-client.c,v retrieving revision 1.11
test-client.c +13 -0
@@ -41,6 +41,17 @@ static void delete_callback(GtkWidget *wgtk_main_quit (); } +static void default_adapter_changed (GObject *gobject, +GParamSpec *arg1, +gpointer user_data) +{ +char *adapter; + +g_object_get (gobject,"default-adapter" , &adapter,NULL ); +g_message ("default adapter changed: %s" , adapter); +g_free (adapter); +} +static void create_window (void ) {GtkWidget *window;
@@ -135,6 +146,8 @@ static void create_window(void)g_signal_connect (G_OBJECT (window),"delete-event" ,G_CALLBACK (delete_callback),NULL ); +g_signal_connect (G_OBJECT (client),"notify::default-adapter" , +G_CALLBACK (default_adapter_changed), client);gtk_widget_show_all (window); }
-------------------------------------------------------------------------
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/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
Quoted 10 lines · Bastien Nocera
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.cas well.Both patches attached. The bluez-gnome patch includes the changes from the
client.ccleanup thread.Try plugging/unplugging your adapters after the patching, and the treeview will magically change its contents.
Updated patch with documentation changes.
Index: dbus-api.txt
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/dbus-api.txt,v retrieving revision 1.136
dbus-api.txt +2 -1
@@ -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
dbus-hci.c +18 -4
@@ -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_tint 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);
-------------------------------------------------------------------------
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/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
Marcel Holtmann
maintainerHi Bastien,
Quoted 5 lines
Quoted 5 lines
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.cas well.
Quoted 7 lines
Quoted 5 lines
Both patches attached. The bluez-gnome patch includes the changes from the
client.ccleanup thread.Try plugging/unplugging your adapters after the patching, and the treeview will magically change its contents.
Updated patch with documentation changes.
patch has been applied. Thanks.
Regards
Marcel
-------------------------------------------------------------------------
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/
_______________________________________________
Bluez-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
Marcel Holtmann
maintainerHi Bastien,
Quoted 5 lines
Both patches attached. The bluez-gnome patch includes the changes from the
client.ccleanup thread.Try plugging/unplugging your adapters after the patching, and the treeview will magically change its contents.
patch has been applied. Thanks.
Regards
Marcel
-------------------------------------------------------------------------
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/
_______________________________________________
Bluez-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel