--- a/pidgin/gtkutils.c Sat Jan 16 10:01:23 2016 -0500
+++ b/pidgin/gtkutils.c Mon Jan 18 23:24:26 2016 -0800
@@ -1446,13 +1446,123 @@
+pidgin_dnd_file_send_image(PurpleAccount *account, const gchar *who, + PurpleConnection *gc = purple_account_get_connection(account); + PurpleProtocol *protocol = NULL; + _DndData *data = g_malloc(sizeof(_DndData)); + gboolean ft = FALSE, im = FALSE; + data->who = g_strdup(who); + data->filename = g_strdup(filename); + data->account = account; + protocol = purple_connection_get_protocol(gc); + if (!(purple_connection_get_flags(gc) & PURPLE_CONNECTION_FLAG_NO_IMAGES)) + if (protocol && PURPLE_PROTOCOL_IMPLEMENTS(protocol, XFER_IFACE, can_receive)) + ft = purple_protocol_xfer_iface_can_receive(protocol, gc, who); + else if (protocol && PURPLE_PROTOCOL_IMPLEMENTS(protocol, XFER_IFACE, send)) + purple_request_choice(NULL, NULL, + _("You have dragged an image"), + _("You can send this image as a file " + "transfer, embed it into this message, " + "or use it as the buddy icon for this user."), + (gpointer)DND_FILE_TRANSFER, _("OK"), + (GCallback)dnd_image_ok_callback, _("Cancel"), + (GCallback)dnd_image_cancel_callback, + purple_request_cpar_from_account(account), data, + _("Set as buddy icon"), DND_BUDDY_ICON, + _("Send image file"), DND_FILE_TRANSFER, + _("Insert in message"), DND_IM_IMAGE, + } else if (!(im || ft)) { + purple_request_yes_no(NULL, NULL, _("You have dragged an image"), + _("Would you like to set it as the buddy icon for this user?"), + PURPLE_DEFAULT_ACTION_NONE, + purple_request_cpar_from_account(account), + data, (GCallback)dnd_set_icon_ok_cb, (GCallback)dnd_set_icon_cancel_cb); + purple_request_choice(NULL, NULL, + _("You have dragged an image"), + (ft ? _("You can send this image as a file transfer, or use it as the buddy icon for this user.") : + _("You can insert this image into this message, or use it as the buddy icon for this user")), + GINT_TO_POINTER(ft ? DND_FILE_TRANSFER : DND_IM_IMAGE), + _("OK"), (GCallback)dnd_image_ok_callback, + _("Cancel"), (GCallback)dnd_image_cancel_callback, + purple_request_cpar_from_account(account), + _("Set as buddy icon"), DND_BUDDY_ICON, + (ft ? _("Send image file") : _("Insert in message")), (ft ? DND_FILE_TRANSFER : DND_IM_IMAGE), +pidgin_dnd_file_send_desktop(PurpleAccount *account, const gchar *who, + PurpleDesktopItem *item) + PurpleDesktopItemType dtype; + const char *itemname = NULL; + const char * const *langs; + langs = g_get_language_names(); + g_snprintf(key, sizeof(key), "Name[%s]", langs[0]); + itemname = purple_desktop_item_get_string(item, key); + itemname = purple_desktop_item_get_string(item, "Name"); + dtype = purple_desktop_item_get_entry_type(item); + PurpleConversation *conv; + PidginConversation *gtkconv; + case PURPLE_DESKTOP_ITEM_TYPE_LINK: + conv = PURPLE_CONVERSATION(purple_im_conversation_new(account, who)); + gtkconv = PIDGIN_CONVERSATION(conv); + pidgin_webview_insert_link(PIDGIN_WEBVIEW(gtkconv->entry), + purple_desktop_item_get_string(item, "URL"), + /* I don't know if we really want to do anything here. Most of + * the desktop item types are crap like "MIME Type" (I have no + * clue how that would be a desktop item) and "Comment"... + * nothing we can really send. The only logical one is + * "Application," but do we really want to send a binary and + * nothing else? Probably not. I'll just give an error and + /* The original patch sent the icon used by the launcher. That's probably wrong */ + purple_notify_error(NULL, NULL, _("Cannot send launcher"), + _("You dragged a desktop launcher. Most " + "likely you wanted to send the target " + "of this launcher instead of this " + "launcher itself."), NULL); pidgin_dnd_file_manage(GtkSelectionData *sd, PurpleAccount *account, const char *who)
GList *files = purple_uri_list_extract_filenames((const gchar *) gtk_selection_data_get_data(sd));
PurpleConnection *gc = purple_account_get_connection(account);
- PurpleProtocol *protocol = NULL;
@@ -1493,119 +1603,20 @@
/* Are we dealing with an image? */
pb = pidgin_pixbuf_new_from_file(filename);
- _DndData *data = g_malloc(sizeof(_DndData));
- gboolean ft = FALSE, im = FALSE;
- data->who = g_strdup(who);
- data->filename = g_strdup(filename);
- data->account = account;
- protocol = purple_connection_get_protocol(gc);
- if (!(purple_connection_get_flags(gc) & PURPLE_CONNECTION_FLAG_NO_IMAGES))
- if (protocol && PURPLE_PROTOCOL_IMPLEMENTS(protocol, XFER_IFACE, can_receive))
- ft = purple_protocol_xfer_iface_can_receive(protocol, gc, who);
- else if (protocol && PURPLE_PROTOCOL_IMPLEMENTS(protocol, XFER_IFACE, send))
- purple_request_choice(NULL, NULL,
- _("You have dragged an image"),
- _("You can send this image as a file "
- "transfer, embed it into this message, "
- "or use it as the buddy icon for this user."),
- (gpointer)DND_FILE_TRANSFER, _("OK"),
- (GCallback)dnd_image_ok_callback, _("Cancel"),
- (GCallback)dnd_image_cancel_callback,
- purple_request_cpar_from_account(account), data,
- _("Set as buddy icon"), DND_BUDDY_ICON,
- _("Send image file"), DND_FILE_TRANSFER,
- _("Insert in message"), DND_IM_IMAGE,
- } else if (!(im || ft))
- purple_request_yes_no(NULL, NULL, _("You have dragged an image"),
- _("Would you like to set it as the buddy icon for this user?"),
- PURPLE_DEFAULT_ACTION_NONE,
- purple_request_cpar_from_account(account),
- data, (GCallback)dnd_set_icon_ok_cb, (GCallback)dnd_set_icon_cancel_cb);
- purple_request_choice(NULL, NULL,
- _("You have dragged an image"),
- (ft ? _("You can send this image as a file transfer, or use it as the buddy icon for this user.") :
- _("You can insert this image into this message, or use it as the buddy icon for this user")),
- GINT_TO_POINTER(ft ? DND_FILE_TRANSFER : DND_IM_IMAGE),
- _("OK"), (GCallback)dnd_image_ok_callback,
- _("Cancel"), (GCallback)dnd_image_cancel_callback,
- purple_request_cpar_from_account(account),
- _("Set as buddy icon"), DND_BUDDY_ICON,
- (ft ? _("Send image file") : _("Insert in message")), (ft ? DND_FILE_TRANSFER : DND_IM_IMAGE),
+ pidgin_dnd_file_send_image(account, who, filename); g_object_unref(G_OBJECT(pb));
- files = g_list_delete_link(files, files);
/* Are we trying to send a .desktop file? */
else if (purple_str_has_suffix(basename, ".desktop") && (item = purple_desktop_item_new_from_file(filename))) {
- PurpleDesktopItemType dtype;
- const char *itemname = NULL;
- const char * const *langs;
- langs = g_get_language_names();
- g_snprintf(key, sizeof(key), "Name[%s]", langs[0]);
- itemname = purple_desktop_item_get_string(item, key);
- itemname = purple_desktop_item_get_string(item, "Name");
- dtype = purple_desktop_item_get_entry_type(item);
- PurpleConversation *conv;
- PidginConversation *gtkconv;
- case PURPLE_DESKTOP_ITEM_TYPE_LINK:
- conv = PURPLE_CONVERSATION(purple_im_conversation_new(account, who));
- gtkconv = PIDGIN_CONVERSATION(conv);
- pidgin_webview_insert_link(PIDGIN_WEBVIEW(gtkconv->entry),
- purple_desktop_item_get_string(item, "URL"),
- /* I don't know if we really want to do anything here. Most of
- * the desktop item types are crap like "MIME Type" (I have no
- * clue how that would be a desktop item) and "Comment"...
- * nothing we can really send. The only logical one is
- * "Application," but do we really want to send a binary and
- * nothing else? Probably not. I'll just give an error and
- /* The original patch sent the icon used by the launcher. That's probably wrong */
- purple_notify_error(NULL, NULL, _("Cannot send launcher"),
- _("You dragged a desktop launcher. Most "
- "likely you wanted to send the target "
- "of this launcher instead of this "
- "launcher itself."), NULL);
+ pidgin_dnd_file_send_desktop(account, who, item); purple_desktop_item_unref(item);
- files = g_list_delete_link(files, files);