After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 546571 - [bluetooth] Use last used device by default
[bluetooth] Use last used device by default
Status: RESOLVED FIXED
Product: nautilus-sendto
Classification: Applications
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: nautilus-sendto-maint
nautilus-sendto-maint
Depends on:
Blocks:
 
 
Reported: 2008-08-06 12:19 UTC by Baptiste Mille-Mathias
Modified: 2008-12-18 14:19 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
First draft (2.80 KB, patch)
2008-10-27 21:24 UTC, Baptiste Mille-Mathias
needs-work Details | Review
2nd version (2.90 KB, patch)
2008-11-02 17:16 UTC, Baptiste Mille-Mathias
needs-work Details | Review
Fixed all things described in last comment (2.87 KB, patch)
2008-12-18 13:38 UTC, Baptiste Mille-Mathias
accepted-commit_now Details | Review

Description Baptiste Mille-Mathias 2008-08-06 12:19:25 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.
Comment 1 Bastien Nocera 2008-08-11 18:59:54 UTC
Bug 511324 would need to remember more than just the last item though, and implementing one shouldn't stop us from implementing the other...
Comment 2 Baptiste Mille-Mathias 2008-10-27 21:24:08 UTC
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 3 Bastien Nocera 2008-10-28 00:56:14 UTC
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);
Comment 4 Baptiste Mille-Mathias 2008-11-02 17:16:55 UTC
Created attachment 121823 [details] [review]
2nd version
Comment 5 Baptiste Mille-Mathias 2008-12-03 10:07:36 UTC
Hello Bastien,

Could you review the patch I attached :)

Thanks
Comment 6 Bastien Nocera 2008-12-03 11:16:50 UTC
+	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);
Comment 7 Baptiste Mille-Mathias 2008-12-18 13:38:45 UTC
Created attachment 124922 [details] [review]
Fixed all things described in last comment

No warning at compile with the patch.
Comment 8 Bastien Nocera 2008-12-18 13:41:18 UTC
Looks good. Please commit.
Comment 9 Baptiste Mille-Mathias 2008-12-18 14:19:57 UTC
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.