# HG changeset patch # User Christian Hammond # Date 1069641327 0 # Node ID 994b2d782711e7bbd21b00ac5a6e8500389a915d # Parent 53e38b1ce00a6d156c14533266b27e76a8d30ee3 [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 diff -r 53e38b1ce00a -r 994b2d782711 src/gtkconv.c --- 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, "", GAIM_STOCK_INVITE }, + { N_("/Conversation/Send _File..."), NULL, menu_sendfile_cb, 0, + "", GAIM_STOCK_INVITE }, + { "/Conversation/sep2", NULL, NULL, 0, "" }, { 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 = diff -r 53e38b1ce00a -r 994b2d782711 src/gtkconv.h --- 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; diff -r 53e38b1ce00a -r 994b2d782711 src/prpl.c --- 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); + +} diff -r 53e38b1ce00a -r 994b2d782711 src/prpl.h --- 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 diff -r 53e38b1ce00a -r 994b2d782711 src/server.c --- 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;