GNOME Bugzilla – Bug 546571
[bluetooth] Use last used device by default
Last modified: 2008-12-18 14:19:57 UTC
Some people requires to put as default device the latest device used in previous sending. Perhaps this could be linked to the bug http://bugzilla.gnome.org/show_bug.cgi?id=511324 and use the same gconf key. I set a dependency on this bug, feel free to remove it if this is not a good idea.
Bug 511324 would need to remember more than just the last item though, and implementing one shouldn't stop us from implementing the other...
Created attachment 121477 [details] [review] First draft First version, slighly tested on my side, but of course need review :) Certainly the gconf key should have a different name (and a different type to store something like timestamp of last usage) to be used also with bug #511324. cheers
Comment on attachment 121477 [details] [review] First draft >Index: src/plugins/bluetooth.c <snip> > static void >+add_last_used_device_to_list (GtkListStore *store) >+{ >+ char *bdaddr; >+ char *name; >+ >+ GConfClient *GConfClient; >+ >+ GConfClient = gconf_client_get_default (); >+ bdaddr = gconf_client_get_string (GConfClient, LAST_OBEX_DEVICE, NULL); >+ g_object_unref(GConfClient); >+ >+ if (bdaddr != NULL) { You also need to check for bdaddr != '\0', and don't forget to free it. <snip> >@@ -325,6 +391,8 @@ > ret = g_spawn_async (NULL, (gchar **) argv->pdata, > NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, &err); > g_ptr_array_free (argv, TRUE); >+ >+ save_last_used_obex_device (bdaddr); Only save the last device if sending actually worked. > if (ret == FALSE) { > g_warning ("Couldn't send files via bluetooth: %s", err->message);
Created attachment 121823 [details] [review] 2nd version
Hello Bastien, Could you review the patch I attached :) Thanks
+ if (bdaddr != NULL || bdaddr != '\0') { That should be &&, not ||, and the second part very certainly produces a warning... + GConfClient *GConfClient; don't use type names as variable names Finally, the indentation is busted, you're using 8 spaces tabs after the first braces, but 4 spaces whenever a level deeper: + if (bdaddr != NULL || bdaddr != '\0') { + name = get_device_name_from_address (bdaddr); should be: + if (bdaddr != NULL || bdaddr != '\0') { + name = get_device_name_from_address (bdaddr);
Created attachment 124922 [details] [review] Fixed all things described in last comment No warning at compile with the patch.
Looks good. Please commit.
tx Bastien for your help. This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.