changeset 7619:994b2d782711

[gaim-migrate @ 8243] Juan Pablo Mendoza made file sending a little more generic, UI-wise, and added drag-and-drop file sending, as well as a Send File in the conversation menu. Congrats Juan on the $400 bounty. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Mon, 24 Nov 2003 02:35:27 +0000
parents 53e38b1ce00a
children 4f41c4aa9913
files src/gtkconv.c src/gtkconv.h src/prpl.c src/prpl.h src/server.c
diffstat 5 files changed, 95 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkconv.c	Mon Nov 24 02:28:42 2003 +0000
+++ b/src/gtkconv.c	Mon Nov 24 02:35:27 2003 +0000
@@ -881,6 +881,20 @@
 }
 
 static void
+menu_sendfile_cb(gpointer data, guint action, GtkWidget *widget)
+{
+	GaimConvWindow *win = (GaimConvWindow *)data;
+	GaimConversation *conv;
+	GaimConnection *gc;
+
+	conv = gaim_conv_window_get_active_conversation(win);
+
+	gc = gaim_conversation_get_gc(conv);
+
+	gaim_prpl_ask_send_file (gc, gaim_conversation_get_name (conv));
+}
+
+static void
 menu_warn_cb(gpointer data, guint action, GtkWidget *widget)
 {
 	GaimConvWindow *win = (GaimConvWindow *)data;
@@ -2079,6 +2093,15 @@
 		prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
 	}
 
+
+	if (gaim_prpl_has_send_file (gc, gaim_conversation_get_name(conv))) {
+		gtk_widget_show(gtkwin->menu.sendfile);
+		gtk_widget_set_sensitive(gtkwin->menu.sendfile, TRUE);
+	} else {
+		gtk_widget_hide(gtkwin->menu.sendfile);
+		gtk_widget_set_sensitive(gtkwin->menu.sendfile, FALSE);
+	}
+
 	/* Update the menubar */
 	if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) {
 		gtk_widget_show(gtkwin->menu.view_log);
@@ -2937,6 +2960,9 @@
 	{ N_("/Conversation/In_vite..."), NULL, menu_invite_cb, 0,
 	  "<StockItem>", GAIM_STOCK_INVITE },
 
+	{ N_("/Conversation/Send _File..."), NULL, menu_sendfile_cb, 0,
+	  "<StockItem>", GAIM_STOCK_INVITE },
+
 	{ "/Conversation/sep2", NULL, NULL, 0, "<Separator>" },
 
 	{ N_("/Conversation/Insert _URL..."), NULL, menu_insert_link_cb, 0,
@@ -3025,6 +3051,10 @@
 		gtk_item_factory_get_widget(gtkwin->menu.item_factory,
 									N_("/Conversation/Invite..."));
 
+	gtkwin->menu.sendfile =
+		gtk_item_factory_get_widget(gtkwin->menu.item_factory,
+									N_("/Conversation/Send File..."));
+
 	/* --- */
 
 	gtkwin->menu.insert_link =
--- a/src/gtkconv.h	Mon Nov 24 02:28:42 2003 +0000
+++ b/src/gtkconv.h	Mon Nov 24 02:35:27 2003 +0000
@@ -55,6 +55,7 @@
 		GtkWidget *alias;
 		GtkWidget *get_info;
 		GtkWidget *invite;
+		GtkWidget *sendfile;
 
 		GtkWidget *warn;
 		GtkWidget *block;
--- a/src/prpl.c	Mon Nov 24 02:28:42 2003 +0000
+++ b/src/prpl.c	Mon Nov 24 02:35:27 2003 +0000
@@ -96,3 +96,31 @@
 
 	return NULL;
 }
+
+void gaim_prpl_ask_send_file (GaimConnection *gc, char *name)
+{
+	GaimPluginProtocolInfo *prpl_info = NULL;
+ 
+        if (gc != NULL && gc->prpl != NULL)
+                prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
+
+	if (prpl_info->has_send_file == NULL || prpl_info->send_file == NULL)
+		return FALSE;	
+
+	prpl_info->ask_send_file(gc, name);
+}
+
+
+gboolean gaim_prpl_has_send_file (GaimConnection *gc, char *name)
+{
+	GaimPluginProtocolInfo *prpl_info = NULL;
+ 
+        if (gc != NULL && gc->prpl != NULL)
+                prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
+
+	if (prpl_info->has_send_file == NULL || prpl_info->send_file == NULL)
+		return FALSE;
+
+	return prpl_info->has_send_file(gc, name);
+	
+}
--- a/src/prpl.h	Mon Nov 24 02:28:42 2003 +0000
+++ b/src/prpl.h	Mon Nov 24 02:35:27 2003 +0000
@@ -313,6 +313,12 @@
 	void (*remove_group)(GaimConnection *gc, const char *group);
 
 	char *(*get_cb_real_name)(GaimConnection *gc, int id, const char *who);
+
+	void (*ask_send_file)(GaimConnection *gc, const char *who);
+
+	void (*send_file)(GaimConnection *gc, const char *who, const char *file);
+
+	gboolean (*has_send_file)(GaimConnection *gc, const char *who);
 };
 
 #define GAIM_IS_PROTOCOL_PLUGIN(plugin) \
@@ -351,6 +357,23 @@
  */
 GaimPlugin *gaim_find_prpl(GaimProtocol type);
 
+/**
+ * Ask the user to select a file to send to a user
+ *
+ * @param gc The Gaim Connection to send the file trough;
+ * @param name The screen name of the one we are sending the file;
+ */
+void gaim_prpl_ask_send_file (GaimConnection *gc, char *name);
+
+/**
+ * Checks if a given user supports file sends
+ *
+ * @param gc The Gaim Connection to send the file trough;
+ * @param name The screen name of the one we are sending the file;
+ * @return TRUE if we can send files to this user, FALSE otherwise.
+ */
+gboolean gaim_prpl_has_send_file (GaimConnection *gc, char *name);
+
 #ifdef __cplusplus
 }
 #endif
--- a/src/server.c	Mon Nov 24 02:28:42 2003 +0000
+++ b/src/server.c	Mon Nov 24 02:35:27 2003 +0000
@@ -291,6 +291,19 @@
 	return val;
 }
 
+void serv_send_file(GaimConnection *gc, const char *name, const char *file)
+{
+	GaimPluginProtocolInfo *prpl_info = NULL;
+
+	if (gc != NULL && gc->prpl != NULL)
+		prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
+
+	if (prpl_info->send_file == NULL || file == NULL || name ==  NULL)
+		return;
+
+	prpl_info->send_file(gc, name, file);
+}
+
 void serv_get_info(GaimConnection *g, const char *name)
 {
 	GaimPluginProtocolInfo *prpl_info = NULL;