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 597039 - Update of the plugin to use Pidgin dbus API
Update of the plugin to use Pidgin dbus API
Status: RESOLVED FIXED
Product: nautilus-sendto
Classification: Applications
Component: pidgin
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: Pascal Terjan
nautilus-sendto-maint
Depends on:
Blocks:
 
 
Reported: 2009-10-01 20:00 UTC by Pascal Terjan
Modified: 2009-10-02 00:09 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Switch to dbus (14.73 KB, patch)
2009-10-01 20:00 UTC, Pascal Terjan
needs-work Details | Review
Switch to dbus, second try (27.60 KB, patch)
2009-10-01 22:24 UTC, Pascal Terjan
committed Details | Review

Description Pascal Terjan 2009-10-01 20:00:53 UTC
Created attachment 144536 [details] [review]
Switch to dbus

Here is a patch to use pidgin d-bus API instead of a plugin inside pidgin

The only user visible changes should be:
- Buddy icons are used instead of protocol icons (I should fallback to protocol
icons when people have no buddy icon however)
- I fixed a crash when some people (like a certain bmm which was the first I
tried on) have too long account name, which was already there

I had another version which (in my opinion) improvements to the user interface
and simpler code, but it needs more work to be really nice so I'll keep it for
later.

With this patch the pidgin_plugin/ dir can be removed but I did not to keep the
patch shorter
Comment 1 Bastien Nocera 2009-10-01 20:17:34 UTC
Comment on attachment 144536 [details] [review]
Switch to dbus

<snip>
>+			gtk_tree_store_set (store, iter,
>+					    0, icon,
>+					    1, alias_e->str, 
>+					    2, dat->alias,
>+					    -1);
> 		}
> 		g_string_free(alias_e, TRUE);
> 	}
>@@ -207,7 +294,7 @@ get_contacts_widget (NstPlugin *plugin)
> 
> 	iter = g_malloc (sizeof(GtkTreeIter));
> 	iter2 = g_malloc (sizeof(GtkTreeIter));
>-	store = gtk_tree_store_new (2, GDK_TYPE_PIXBUF, G_TYPE_STRING);
>+	store = gtk_tree_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);

Could you change the magic numbers by an enum?

enum {
   COL_ICON,
   COL_ALIAS,
   COL_WHATEVER,
   NUM_COLS
};

<snip>
>-static gboolean
>-send_files (NstPlugin *plugin,
>-	    GtkWidget *contact_widget,
>+static
>+gboolean send_file(int account, const char *who, const char *filename)

Can the code not send groups of files, as opposed to a single file?

<snip>
>+	for(file_iter = file_list; file_iter != NULL; 
>+	    file_iter = g_list_next(file_iter)) {
>+		error= NULL;
>+		file_path = g_filename_from_uri(file_iter->data, NULL, &error);

Don't do that, you'd lose the ability to send files located on remote network shares.

Do something like:
GFile *file;
file = g_file_new_for_uri (file_iter->data);
path = g_file_get_path (file);
g_object_unref (file);
/* check if file is null and print a warning */

>+		if(error != NULL) {
>+			g_warning("[Pidgin] %d Unable to convert URI `%s' to absolute file path",
>+				  error->code, (gchar *)file_iter->data);
>+			g_error_free(error);
>+			continue;
>+		}

Rest looks fine.

If the functionality is at least as good as it used to be, then it's fine to work on other bugs incrementally.
Comment 2 Pascal Terjan 2009-10-01 20:50:35 UTC
(In reply to comment #1)
> Could you change the magic numbers by an enum?
> 
> enum {
>    COL_ICON,
>    COL_ALIAS,
>    COL_WHATEVER,
>    NUM_COLS
> };
> 
yes (I did in my other version :) )

> <snip>
> >-static gboolean
> >-send_files (NstPlugin *plugin,
> >-	    GtkWidget *contact_widget,
> >+static
> >+gboolean send_file(int account, const char *who, const char *filename)
> 
> Can the code not send groups of files, as opposed to a single file?

yes, I still have send_files later in the code 

> <snip>
> >+	for(file_iter = file_list; file_iter != NULL; 
> >+	    file_iter = g_list_next(file_iter)) {
> >+		error= NULL;
> >+		file_path = g_filename_from_uri(file_iter->data, NULL, &error);
> 
> Don't do that, you'd lose the ability to send files located on remote network
> shares.

I think original code had the same issue :)
 
> Do something like:
> GFile *file;
> file = g_file_new_for_uri (file_iter->data);
> path = g_file_get_path (file);
> g_object_unref (file);
> /* check if file is null and print a warning */

OK
Comment 3 Bastien Nocera 2009-10-01 20:53:26 UTC
(In reply to comment #2)
> > <snip>
> > >-static gboolean
> > >-send_files (NstPlugin *plugin,
> > >-	    GtkWidget *contact_widget,
> > >+static
> > >+gboolean send_file(int account, const char *who, const char *filename)
> > 
> > Can the code not send groups of files, as opposed to a single file?
> 
> yes, I still have send_files later in the code 

I meant, isn't there a Pidgin API to send multiple files at once, rather than sending them one-by-one?
Comment 4 Pascal Terjan 2009-10-01 21:01:49 UTC
No they have a "transfer" object with a filename field
Comment 5 Bastien Nocera 2009-10-01 21:04:34 UTC
OK, would be fine with the other changes mentioned above then, thanks.
Comment 6 Pascal Terjan 2009-10-01 22:24:15 UTC
Created attachment 144550 [details] [review]
Switch to dbus, second try

OK, here is the full patch
Comment 7 Bastien Nocera 2009-10-01 22:44:55 UTC
Looks fine to me. Out of curiosity, why did the previous patch's tree store have 3 columns when this one only has 2?
Comment 8 Pascal Terjan 2009-10-01 23:02:39 UTC
Because I had fixed the crash in a stupid way, the model used to contain manually ellipsized alias which did not allow to identify the contact, so I added the full one.

I only thought afterwards of only storing it, and setting the ellipsize operation on the renderer...
Comment 9 Bastien Nocera 2009-10-02 00:09:25 UTC
There's 2 other bugs related to Pidgin in nautilus-sendto, would be nice if you could look into those, thanks!