pidgin/pidgin

Add chat_send_file() facility
release-2.x.y
2020-05-20, David Woodhouse
93bf0203f935
Parents 159344ba2a49
Children 2097f91763f1
Add chat_send_file() facility
--- a/libpurple/protocols/bonjour/bonjour.c Wed May 20 11:33:10 2020 +0100
+++ b/libpurple/protocols/bonjour/bonjour.c Wed May 20 11:33:58 2020 +0100
@@ -538,6 +538,8 @@
NULL, /* add_buddy_with_invite */
NULL, /* add_buddies_with_invite */
NULL, /* get_cb_alias */
+ NULL, /* chat_can_receive_file */
+ NULL, /* chat_send_file */
};
static PurplePluginInfo info =
--- a/libpurple/protocols/gg/gg.c Wed May 20 11:33:10 2020 +0100
+++ b/libpurple/protocols/gg/gg.c Wed May 20 11:33:58 2020 +0100
@@ -2329,6 +2329,8 @@
NULL, /* add_buddy_with_invite */
NULL, /* add_buddies_with_invite */
NULL, /* get_cb_alias */
+ NULL, /* chat_can_receive_file */
+ NULL, /* chat_send_file */
};
static PurplePluginInfo info = {
--- a/libpurple/protocols/irc/irc.c Wed May 20 11:33:10 2020 +0100
+++ b/libpurple/protocols/irc/irc.c Wed May 20 11:33:58 2020 +0100
@@ -1010,6 +1010,8 @@
NULL, /* add_buddy_with_invite */
NULL, /* add_buddies_with_invite */
NULL, /* get_cb_alias */
+ NULL, /* chat_can_receive_file */
+ NULL, /* chat_send_file */
};
static gboolean load_plugin (PurplePlugin *plugin) {
--- a/libpurple/protocols/jabber/libxmpp.c Wed May 20 11:33:10 2020 +0100
+++ b/libpurple/protocols/jabber/libxmpp.c Wed May 20 11:33:58 2020 +0100
@@ -133,6 +133,8 @@
NULL, /* add_buddy_with_invite */
NULL, /* add_buddies_with_invite */
NULL, /* get_cb_alias */
+ NULL, /* chat_can_receive_file */
+ NULL, /* chat_send_file */
};
static gboolean load_plugin(PurplePlugin *plugin)
--- a/libpurple/protocols/novell/novell.c Wed May 20 11:33:10 2020 +0100
+++ b/libpurple/protocols/novell/novell.c Wed May 20 11:33:58 2020 +0100
@@ -3527,6 +3527,8 @@
NULL, /* add_buddy_with_invite */
NULL, /* add_buddies_with_invite */
NULL, /* get_cb_alias */
+ NULL, /* chat_can_receive_file */
+ NULL, /* chat_send_file */
};
static PurplePluginInfo info = {
--- a/libpurple/protocols/null/nullprpl.c Wed May 20 11:33:10 2020 +0100
+++ b/libpurple/protocols/null/nullprpl.c Wed May 20 11:33:58 2020 +0100
@@ -1125,6 +1125,8 @@
NULL, /* add_buddy_with_invite */
NULL, /* add_buddies_with_invite */
NULL, /* get_cb_alias */
+ NULL, /* chat_can_receive_file */
+ NULL, /* chat_send_file */
};
static void nullprpl_init(PurplePlugin *plugin)
--- a/libpurple/protocols/oscar/libaim.c Wed May 20 11:33:10 2020 +0100
+++ b/libpurple/protocols/oscar/libaim.c Wed May 20 11:33:58 2020 +0100
@@ -104,6 +104,8 @@
oscar_add_buddy, /* add_buddy_with_invite */
NULL, /* add_buddies_with_invite */
NULL, /* get_cb_alias */
+ NULL, /* chat_can_receive_file */
+ NULL, /* chat_send_file */
};
static PurplePluginInfo info =
--- a/libpurple/protocols/oscar/libicq.c Wed May 20 11:33:10 2020 +0100
+++ b/libpurple/protocols/oscar/libicq.c Wed May 20 11:33:58 2020 +0100
@@ -114,6 +114,8 @@
oscar_add_buddy, /* add_buddy_with_invite */
NULL, /* add_buddies_with_invite */
NULL, /* get_cb_alias */
+ NULL, /* chat_can_receive_file */
+ NULL, /* chat_send_file */
};
static PurplePluginInfo info =
--- a/libpurple/protocols/sametime/sametime.c Wed May 20 11:33:10 2020 +0100
+++ b/libpurple/protocols/sametime/sametime.c Wed May 20 11:33:58 2020 +0100
@@ -5157,6 +5157,8 @@
NULL,
NULL,
NULL, /* get_cb_alias */
+ NULL, /* chat_can_receive_file */
+ NULL, /* chat_send_file */
};
--- a/libpurple/protocols/silc/silc.c Wed May 20 11:33:10 2020 +0100
+++ b/libpurple/protocols/silc/silc.c Wed May 20 11:33:58 2020 +0100
@@ -2126,6 +2126,8 @@
NULL, /* add_buddy_with_invite */
NULL, /* add_buddies_with_invite */
NULL, /* get_cb_alias */
+ NULL, /* chat_can_receive_file */
+ NULL, /* chat_send_file */
};
static PurplePluginInfo info =
--- a/libpurple/protocols/silc10/silc.c Wed May 20 11:33:10 2020 +0100
+++ b/libpurple/protocols/silc10/silc.c Wed May 20 11:33:58 2020 +0100
@@ -1849,6 +1849,8 @@
NULL, /* add_buddy_with_invite */
NULL, /* add_buddies_with_invite */
NULL, /* get_cb_alias */
+ NULL, /* chat_can_receive_file */
+ NULL, /* chat_send_file */
};
static PurplePluginInfo info =
--- a/libpurple/protocols/simple/simple.c Wed May 20 11:33:10 2020 +0100
+++ b/libpurple/protocols/simple/simple.c Wed May 20 11:33:58 2020 +0100
@@ -2121,6 +2121,8 @@
NULL, /* add_buddy_with_invite */
NULL, /* add_buddies_with_invite */
NULL, /* get_cb_alias */
+ NULL, /* chat_can_receive_file */
+ NULL, /* chat_send_file */
};
--- a/libpurple/protocols/zephyr/zephyr.c Wed May 20 11:33:10 2020 +0100
+++ b/libpurple/protocols/zephyr/zephyr.c Wed May 20 11:33:58 2020 +0100
@@ -2928,6 +2928,8 @@
NULL, /* add_buddy_with_invite */
NULL, /* add_buddies_with_invite */
NULL, /* get_cb_alias */
+ NULL, /* chat_can_receive_file */
+ NULL, /* chat_send_file */
};
static PurplePluginInfo info = {
--- a/libpurple/prpl.h Wed May 20 11:33:10 2020 +0100
+++ b/libpurple/prpl.h Wed May 20 11:33:58 2020 +0100
@@ -666,6 +666,31 @@
* @since 2.14.0
*/
char *(*get_cb_alias)(PurpleConnection *gc, int id, const char *who);
+
+
+ /**
+ * Determine whether a chat can receive a file
+ *
+ * @param gc the connection on which the room is.
+ * @param id the ID of the chat room.
+ * @return whether it is OK to use chat_send_file() to send a
+ * file to this chat.
+ *
+ * @since 2.14.0
+ */
+ gboolean (*chat_can_receive_file)(PurpleConnection *, int id);
+
+ /**
+ * Send a file to a chat room
+ *
+ * @param gc the connection on which the room is.
+ * @param id the ID of the chat room.
+ * @param filename the file to be sent.
+ *
+ * @since 2.14.0
+ */
+ void (*chat_send_file)(PurpleConnection *, int id, const char *filename);
+
};
#define PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl, member) \
--- a/libpurple/server.c Wed May 20 11:33:10 2020 +0100
+++ b/libpurple/server.c Wed May 20 11:33:58 2020 +0100
@@ -992,3 +992,19 @@
prpl_info->send_file(gc, who, file);
}
}
+
+void serv_chat_send_file(PurpleConnection *gc, int id, const char *file)
+{
+ PurplePlugin *prpl;
+ PurplePluginProtocolInfo *prpl_info;
+
+ if (gc) {
+ prpl = purple_connection_get_prpl(gc);
+ prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
+
+ if (prpl_info->chat_send_file &&
+ (!prpl_info->chat_can_receive_file
+ || prpl_info->chat_can_receive_file(gc, id)))
+ prpl_info->chat_send_file(gc, id, file);
+ }
+}
--- a/libpurple/server.h Wed May 20 11:33:10 2020 +0100
+++ b/libpurple/server.h Wed May 20 11:33:58 2020 +0100
@@ -210,6 +210,7 @@
void serv_got_chat_in(PurpleConnection *g, int id, const char *who,
PurpleMessageFlags flags, const char *message, time_t mtime);
void serv_send_file(PurpleConnection *gc, const char *who, const char *file);
+void serv_chat_send_file(PurpleConnection *gc, int id, const char *file);
#ifdef __cplusplus
}
--- a/pidgin/gtkconv.c Wed May 20 11:33:10 2020 +0100
+++ b/pidgin/gtkconv.c Wed May 20 11:33:58 2020 +0100
@@ -1145,8 +1145,9 @@
if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) {
serv_send_file(purple_conversation_get_gc(conv), purple_conversation_get_name(conv), NULL);
- }
-
+ } else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) {
+ serv_chat_send_file(purple_conversation_get_gc(conv), purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv)), NULL);
+ }
}
static void
@@ -6564,7 +6565,7 @@
/* Deal with menu items */
gtk_widget_show(win->menu.view_log);
- gtk_widget_hide(win->menu.send_file);
+ gtk_widget_show(win->menu.send_file);
gtk_widget_hide(g_object_get_data(G_OBJECT(win->window), "get_attention"));
gtk_widget_hide(win->menu.add_pounce);
gtk_widget_hide(win->menu.get_info);
@@ -6652,6 +6653,10 @@
{
gtk_widget_set_sensitive(win->menu.add, (prpl_info->join_chat != NULL));
gtk_widget_set_sensitive(win->menu.remove, (prpl_info->join_chat != NULL));
+ gtk_widget_set_sensitive(win->menu.send_file,
+ (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, chat_send_file) &&
+ (!PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, chat_can_receive_file) ||
+ prpl_info->chat_can_receive_file(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv))))));
gtk_widget_set_sensitive(win->menu.alias,
(account != NULL) &&
(purple_blist_find_chat(account, purple_conversation_get_name(conv)) != NULL));