Merged in release-2.x.y (pull request #701) release-2.x.y

Sun, 07 Jun 2020 07:09:30 +0000

author
Gary Kramlich <grim@reaperworld.com>
date
Sun, 07 Jun 2020 07:09:30 +0000
branch
release-2.x.y
changeset 40430
5f9ec468c680
parent 40425
7d42fa9bad3a (current diff)
parent 40429
3d50e9e9e84d (diff)
child 40431
3ff906f65fe2

Merged in release-2.x.y (pull request #701)

Add chat_send_file() facility to PRPL.

Approved-by: Elliott Sales de Andrade
Approved-by: Gary Kramlich

--- a/libpurple/ft.c	Sat Jun 06 04:57:21 2020 -0500
+++ b/libpurple/ft.c	Sun Jun 07 07:09:30 2020 +0000
@@ -289,7 +289,7 @@
 
 	thumbnail_data = purple_xfer_get_thumbnail(xfer, &size);
 
-	conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, xfer->who,
+	conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, xfer->who,
 											   purple_xfer_get_account(xfer));
 
 	if (conv == NULL)
@@ -898,7 +898,7 @@
 		else
 			msg = g_strdup(_("File transfer complete"));
 
-		conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, xfer->who,
+		conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, xfer->who,
 		                                             purple_xfer_get_account(xfer));
 
 		if (conv != NULL)
--- a/libpurple/protocols/bonjour/bonjour.c	Sat Jun 06 04:57:21 2020 -0500
+++ b/libpurple/protocols/bonjour/bonjour.c	Sun Jun 07 07:09:30 2020 +0000
@@ -537,7 +537,9 @@
 	NULL,                                                    /* get_public_alias */
 	NULL,                                                    /* add_buddy_with_invite */
 	NULL,                                                    /* add_buddies_with_invite */
-	NULL                                                     /* get_cb_alias */
+	NULL,                                                    /* get_cb_alias */
+	NULL,                                                    /* chat_can_receive_file */
+	NULL,                                                    /* chat_send_file */
 };
 
 static PurplePluginInfo info =
--- a/libpurple/protocols/gg/gg.c	Sat Jun 06 04:57:21 2020 -0500
+++ b/libpurple/protocols/gg/gg.c	Sun Jun 07 07:09:30 2020 +0000
@@ -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	Sat Jun 06 04:57:21 2020 -0500
+++ b/libpurple/protocols/irc/irc.c	Sun Jun 07 07:09:30 2020 +0000
@@ -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	Sat Jun 06 04:57:21 2020 -0500
+++ b/libpurple/protocols/jabber/libxmpp.c	Sun Jun 07 07:09:30 2020 +0000
@@ -132,7 +132,9 @@
 	NULL, /* get_public_alias */
 	NULL, /* add_buddy_with_invite */
 	NULL, /* add_buddies_with_invite */
-	NULL  /* get_cb_alias */
+	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	Sat Jun 06 04:57:21 2020 -0500
+++ b/libpurple/protocols/novell/novell.c	Sun Jun 07 07:09:30 2020 +0000
@@ -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	Sat Jun 06 04:57:21 2020 -0500
+++ b/libpurple/protocols/null/nullprpl.c	Sun Jun 07 07:09:30 2020 +0000
@@ -1124,7 +1124,9 @@
   NULL,                                /* get_public_alias */
   NULL,                                /* add_buddy_with_invite */
   NULL,                                /* add_buddies_with_invite */
-  NULL                                 /* get_cb_alias */
+  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	Sat Jun 06 04:57:21 2020 -0500
+++ b/libpurple/protocols/oscar/libaim.c	Sun Jun 07 07:09:30 2020 +0000
@@ -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	Sat Jun 06 04:57:21 2020 -0500
+++ b/libpurple/protocols/oscar/libicq.c	Sun Jun 07 07:09:30 2020 +0000
@@ -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	Sat Jun 06 04:57:21 2020 -0500
+++ b/libpurple/protocols/sametime/sametime.c	Sun Jun 07 07:09:30 2020 +0000
@@ -5156,7 +5156,9 @@
   NULL,
   NULL,
   NULL,
-  NULL
+  NULL, /* get_cb_alias */
+  NULL, /* chat_can_receive_file */
+  NULL, /* chat_send_file */
 };
 
 
--- a/libpurple/protocols/silc/silc.c	Sat Jun 06 04:57:21 2020 -0500
+++ b/libpurple/protocols/silc/silc.c	Sun Jun 07 07:09:30 2020 +0000
@@ -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	Sat Jun 06 04:57:21 2020 -0500
+++ b/libpurple/protocols/silc10/silc.c	Sun Jun 07 07:09:30 2020 +0000
@@ -1848,7 +1848,9 @@
 	NULL,                       /* get_public_alias */
 	NULL,                       /* add_buddy_with_invite */
 	NULL,                       /* add_buddies_with_invite */
-	NULL                        /* get_cb_alias */
+	NULL,                       /* get_cb_alias */
+	NULL,                       /* chat_can_receive_file */
+	NULL,                       /* chat_send_file */
 };
 
 static PurplePluginInfo info =
--- a/libpurple/protocols/simple/simple.c	Sat Jun 06 04:57:21 2020 -0500
+++ b/libpurple/protocols/simple/simple.c	Sun Jun 07 07:09:30 2020 +0000
@@ -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	Sat Jun 06 04:57:21 2020 -0500
+++ b/libpurple/protocols/zephyr/zephyr.c	Sun Jun 07 07:09:30 2020 +0000
@@ -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	Sat Jun 06 04:57:21 2020 -0500
+++ b/libpurple/prpl.h	Sun Jun 07 07:09:30 2020 +0000
@@ -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	Sat Jun 06 04:57:21 2020 -0500
+++ b/libpurple/server.c	Sun Jun 07 07:09:30 2020 +0000
@@ -982,13 +982,30 @@
 	PurplePlugin *prpl;
 	PurplePluginProtocolInfo *prpl_info;
 
-	if (gc) {
-		prpl = purple_connection_get_prpl(gc);
-		prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
+	g_return_if_fail(gc != NULL);
 
-		if (prpl_info->send_file &&
-				(!prpl_info->can_receive_file
-						|| prpl_info->can_receive_file(gc, who)))
-			prpl_info->send_file(gc, who, file);
+	prpl = purple_connection_get_prpl(gc);
+	prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
+
+	if (prpl_info->send_file && (!prpl_info->can_receive_file
+				     || prpl_info->can_receive_file(gc, who))) {
+		prpl_info->send_file(gc, who, file);
 	}
 }
+
+void serv_chat_send_file(PurpleConnection *gc, int id, const char *file)
+{
+	PurplePlugin *prpl;
+	PurplePluginProtocolInfo *prpl_info;
+
+	g_return_if_fail(gc != NULL);
+
+	prpl = purple_connection_get_prpl(gc);
+	prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
+
+	if (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, id))) {
+		prpl_info->chat_send_file(gc, id, file);
+	}
+}
--- a/libpurple/server.h	Sat Jun 06 04:57:21 2020 -0500
+++ b/libpurple/server.h	Sun Jun 07 07:09:30 2020 +0000
@@ -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	Sat Jun 06 04:57:21 2020 -0500
+++ b/pidgin/gtkconv.c	Sun Jun 07 07:09:30 2020 +0000
@@ -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));

mercurial