Mercurial > pidgin.yaz
changeset 9466:d27156c9c876
[gaim-migrate @ 10291]
(21:36:44) datallah: anyway... i added "Send File" to the prpl core
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Wed, 07 Jul 2004 01:49:39 +0000 |
parents | 8a4797a608ae |
children | b6971539f7af |
files | src/gtkblist.c src/protocols/irc/dcc_send.c src/protocols/irc/irc.c src/protocols/irc/irc.h src/protocols/jabber/buddy.c src/protocols/jabber/jabber.c src/protocols/jabber/si.c src/protocols/jabber/si.h src/protocols/msn/msn.c src/protocols/oscar/oscar.c src/protocols/silc/buddy.c src/protocols/silc/ft.c src/protocols/silc/silc.c src/protocols/silc/silcgaim.h src/protocols/yahoo/yahoo.c src/protocols/yahoo/yahoo_filexfer.c src/protocols/yahoo/yahoo_filexfer.h src/prpl.h src/server.c src/server.h |
diffstat | 20 files changed, 107 insertions(+), 167 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gtkblist.c Wed Jul 07 01:35:27 2004 +0000 +++ b/src/gtkblist.c Wed Jul 07 01:49:39 2004 +0000 @@ -528,6 +528,11 @@ } } +static void gtk_blist_menu_send_file_cb(GtkWidget *w, GaimBuddy *b) +{ + serv_send_file(b->account->gc, b->name, NULL); +} + static void gtk_blist_menu_autojoin_cb(GtkWidget *w, GaimChat *chat) { gaim_blist_node_set_bool((GaimBlistNode*)chat, "gtk-autojoin", @@ -1130,6 +1135,13 @@ } gaim_new_item_from_stock(menu, _("I_M"), GAIM_STOCK_IM, G_CALLBACK(gtk_blist_menu_im_cb), b, 0, 0, NULL); + if (prpl_info && prpl_info->send_file) { + if (!prpl_info->can_receive_file + || prpl_info->can_receive_file(b->account->gc, b->name)) { + gaim_new_item_from_stock(menu, _("_Send File"), GAIM_STOCK_FILE_TRANSFER, + G_CALLBACK(gtk_blist_menu_send_file_cb), b, 0, 0, NULL); + } + } gaim_new_item_from_stock(menu, _("Add Buddy _Pounce"), NULL, G_CALLBACK(gtk_blist_menu_bp_cb), b, 0, 0, NULL); gaim_new_item_from_stock(menu, _("View _Log"), NULL,
--- a/src/protocols/irc/dcc_send.c Wed Jul 07 01:35:27 2004 +0000 +++ b/src/protocols/irc/dcc_send.c Wed Jul 07 01:49:39 2004 +0000 @@ -299,12 +299,12 @@ * buddy menu * It sets up the GaimXfer struct and tells Gaim to go ahead */ -void irc_dccsend_send_ask(GaimConnection *gc, const char *dst) { +void irc_dccsend_send_file(GaimConnection *gc, const char *who, const char *file) { GaimXfer *xfer; struct irc_xfer_send_data *xd; /* Build the file transfer handle */ - xfer = gaim_xfer_new(gaim_connection_get_account(gc), GAIM_XFER_SEND, dst); + xfer = gaim_xfer_new(gaim_connection_get_account(gc), GAIM_XFER_SEND, who); xd = g_new0(struct irc_xfer_send_data, 1); @@ -318,5 +318,8 @@ gaim_xfer_set_request_denied_fnc(xfer, irc_dccsend_send_destroy); gaim_xfer_set_cancel_send_fnc(xfer, irc_dccsend_send_destroy); /* Now perform the request */ - gaim_xfer_request(xfer); + if (file) + gaim_xfer_request_accepted(xfer, file); + else + gaim_xfer_request(xfer); }
--- a/src/protocols/irc/irc.c Wed Jul 07 01:35:27 2004 +0000 +++ b/src/protocols/irc/irc.c Wed Jul 07 01:49:39 2004 +0000 @@ -150,34 +150,15 @@ return list; } - -static void irc_dccsend_send_ask_menu(GaimBlistNode *node, gpointer data) -{ - GaimBuddy *buddy; - GaimConnection *gc; - - g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); - - buddy = (GaimBuddy *) node; - gc =gaim_account_get_connection(buddy->account); - - irc_dccsend_send_ask(gc, buddy->name); -} - - +#if 0 static GList *irc_blist_node_menu(GaimBlistNode *node) { GList *m = NULL; GaimBlistNodeAction *act; - if(GAIM_BLIST_NODE_IS_BUDDY(node)) { - act = gaim_blist_node_action_new(_("Send File"), - irc_dccsend_send_ask_menu, NULL); - m = g_list_append(m, act); - } - return m; } +#endif static GList *irc_chat_join_info(GaimConnection *gc) { @@ -582,7 +563,7 @@ NULL, NULL, irc_away_states, - irc_blist_node_menu, + NULL, /*irc_blist_node_menu, */ irc_chat_join_info, irc_login, irc_close, @@ -626,7 +607,9 @@ NULL, irc_roomlist_get_list, irc_roomlist_cancel, - NULL + NULL, + NULL, + irc_dccsend_send_file };
--- a/src/protocols/irc/irc.h Wed Jul 07 01:35:27 2004 +0000 +++ b/src/protocols/irc/irc.h Wed Jul 07 01:49:39 2004 +0000 @@ -155,6 +155,6 @@ int irc_cmd_wallops(struct irc_conn *irc, const char *cmd, const char *target, const char **args); int irc_cmd_whois(struct irc_conn *irc, const char *cmd, const char *target, const char **args); -void irc_dccsend_send_ask(GaimConnection *gc, const char *dst); +void irc_dccsend_send_file(GaimConnection *gc, const char *who, const char *file); void irc_dccsend_recv(struct irc_conn *irc, const char *from, const char *msg); #endif /* _GAIM_IRC_H */
--- a/src/protocols/jabber/buddy.c Wed Jul 07 01:35:27 2004 +0000 +++ b/src/protocols/jabber/buddy.c Wed Jul 07 01:49:39 2004 +0000 @@ -32,7 +32,6 @@ #include "jabber.h" #include "iq.h" #include "presence.h" -#include "si.h" void jabber_buddy_free(JabberBuddy *jb) @@ -926,10 +925,6 @@ if(!jb) return m; - act = gaim_blist_node_action_new(_("Send File"), - jabber_si_xfer_ask_send, NULL); - m = g_list_append(m, act); - /* XXX: fix the NOT ME below */ if(js->protocol_version == JABBER_PROTO_0_9 /* && NOT ME */) {
--- a/src/protocols/jabber/jabber.c Wed Jul 07 01:35:27 2004 +0000 +++ b/src/protocols/jabber/jabber.c Wed Jul 07 01:49:39 2004 +0000 @@ -44,6 +44,7 @@ #include "presence.h" #include "jabber.h" #include "roster.h" +#include "si.h" #include "xdata.h" #define JABBER_CONNECT_STEPS (js->gsc ? 8 : 5) @@ -1515,7 +1516,9 @@ jabber_find_blist_chat, jabber_roomlist_get_list, jabber_roomlist_cancel, - NULL + NULL, + NULL, + jabber_si_xfer_send }; static GaimPluginInfo info =
--- a/src/protocols/jabber/si.c Wed Jul 07 01:35:27 2004 +0000 +++ b/src/protocols/jabber/si.c Wed Jul 07 01:49:39 2004 +0000 @@ -644,25 +644,19 @@ } } -void jabber_si_xfer_ask_send(GaimBlistNode *node, gpointer data) +void jabber_si_xfer_send(GaimConnection *gc, const char *who, const char *file) { - GaimBuddy *buddy; - GaimConnection *gc; JabberStream *js; GaimXfer *xfer; JabberSIXfer *jsx; - g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); - - buddy = (GaimBuddy *) node; - gc = gaim_account_get_connection(buddy->account); js = gc->proto_data; - if(!gaim_find_buddy(gc->account, buddy->name) || !jabber_buddy_find(js, buddy->name, FALSE)) + if(!gaim_find_buddy(gc->account, who) || !jabber_buddy_find(js, who, FALSE)) return; - xfer = gaim_xfer_new(buddy->account, GAIM_XFER_SEND, buddy->name); + xfer = gaim_xfer_new(gc->account, GAIM_XFER_SEND, who); xfer->data = jsx = g_new0(JabberSIXfer, 1); jsx->js = js; @@ -673,7 +667,10 @@ js->file_transfers = g_list_append(js->file_transfers, xfer); - gaim_xfer_request(xfer); + if (file) + gaim_xfer_request_accepted(xfer, file); + else + gaim_xfer_request(xfer); } void jabber_si_parse(JabberStream *js, xmlnode *packet)
--- a/src/protocols/jabber/si.h Wed Jul 07 01:35:27 2004 +0000 +++ b/src/protocols/jabber/si.h Wed Jul 07 01:49:39 2004 +0000 @@ -28,6 +28,6 @@ void jabber_bytestreams_parse(JabberStream *js, xmlnode *packet); void jabber_si_parse(JabberStream *js, xmlnode *packet); -void jabber_si_xfer_ask_send(GaimBlistNode *node, gpointer data); +void jabber_si_xfer_send(GaimConnection *gc, const char *who, const char *file); #endif /* _GAIM_JABBER_SI_H_ */
--- a/src/protocols/msn/msn.c Wed Jul 07 01:35:27 2004 +0000 +++ b/src/protocols/msn/msn.c Wed Jul 07 01:49:39 2004 +0000 @@ -354,30 +354,26 @@ } static void -show_send_file_cb(GaimBlistNode *node, gpointer ignored) +msn_send_file(GaimConnection *gc, const char *who, const char *file) { - GaimBuddy *buddy; - GaimConnection *gc; MsnSession *session; MsnSlpLink *slplink; GaimXfer *xfer; - g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); - - buddy = (GaimBuddy *) node; - - gc = gaim_account_get_connection(buddy->account); session = gc->proto_data; - xfer = gaim_xfer_new(buddy->account, GAIM_XFER_SEND, buddy->name); + xfer = gaim_xfer_new(gc->account, GAIM_XFER_SEND, who); - slplink = msn_session_get_slplink(session, buddy->name); + slplink = msn_session_get_slplink(session, who); xfer->data = slplink; gaim_xfer_set_init_fnc(xfer, t_msn_xfer_init); - gaim_xfer_request(xfer); + if (file) + gaim_xfer_request_accepted(xfer, file); + else + gaim_xfer_request(xfer); } static void @@ -541,11 +537,6 @@ initiate_chat_cb, NULL); m = g_list_append(m, act); - act = gaim_blist_node_action_new(_("Send File"), - show_send_file_cb, NULL); - - m = g_list_append(m, act); - act = gaim_blist_node_action_new(_("Update Buddy Icon"), update_buddy_icon_cb, NULL); @@ -1703,7 +1694,9 @@ NULL, NULL, NULL, - NULL + NULL, + NULL, + msn_send_file }; static GaimPluginInfo info =
--- a/src/protocols/oscar/oscar.c Wed Jul 07 01:35:27 2004 +0000 +++ b/src/protocols/oscar/oscar.c Wed Jul 07 01:49:39 2004 +0000 @@ -1922,30 +1922,37 @@ } } -static void oscar_ask_sendfile(GaimBlistNode *node, gpointer data) { - - GaimBuddy *buddy; - GaimConnection *gc; +static gboolean oscar_can_receive_file(GaimConnection *gc, const char *who) { + gboolean can_receive = FALSE; + OscarData *od = gc->proto_data; + + if (!od->icq) { + aim_userinfo_t *userinfo; + userinfo = aim_locate_finduserinfo(od->sess, who); + if (userinfo && userinfo->capabilities & AIM_CAPS_SENDFILE) + can_receive = TRUE; + } + + return can_receive; +} + +static void oscar_send_file(GaimConnection *gc, const char *who, const char *file) { OscarData *od; GaimXfer *xfer; struct aim_oft_info *oft_info; const char *ip; - g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); - - buddy = (GaimBuddy *) node; - gc = gaim_account_get_connection(buddy->account); od = (OscarData *)gc->proto_data; /* You want to send a file to someone else, you're so generous */ /* Build the file transfer handle */ - xfer = gaim_xfer_new(buddy->account, GAIM_XFER_SEND, buddy->name); + xfer = gaim_xfer_new(gc->account, GAIM_XFER_SEND, who); /* Create the oscar-specific data */ ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); - oft_info = aim_oft_createinfo(od->sess, NULL, buddy->name, ip, 0, 0, 0, NULL); + oft_info = aim_oft_createinfo(od->sess, NULL, who, ip, 0, 0, 0, NULL); xfer->data = oft_info; /* Setup our I/O op functions */ @@ -1959,7 +1966,10 @@ od->file_transfers = g_slist_append(od->file_transfers, xfer); /* Now perform the request */ - gaim_xfer_request(xfer); + if (file) + gaim_xfer_request_accepted(xfer, file); + else + gaim_xfer_request(xfer); } static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) { @@ -6770,13 +6780,12 @@ oscar_ask_direct_im, NULL); m = g_list_append(m, act); } - +#if 0 if (userinfo->capabilities & AIM_CAPS_SENDFILE) { act = gaim_blist_node_action_new(_("Send File"), oscar_ask_sendfile, NULL); m = g_list_append(m, act); } -#if 0 if (userinfo->capabilities & AIM_CAPS_GETFILE) { act = gaim_blist_node_action_new(_("Get File"), oscar_ask_getfile, NULL); @@ -7210,7 +7219,9 @@ NULL, NULL, NULL, - NULL + NULL, + oscar_can_receive_file, + oscar_send_file }; static GaimPluginInfo info =
--- a/src/protocols/silc/buddy.c Wed Jul 07 01:35:27 2004 +0000 +++ b/src/protocols/silc/buddy.c Wed Jul 07 01:49:39 2004 +0000 @@ -1570,20 +1570,6 @@ b->name, "Killed by operator", NULL); } -static void -silcgaim_buddy_send_file(GaimBlistNode *node, gpointer data) -{ - GaimBuddy *b; - GaimConnection *gc; - - g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); - - b = (GaimBuddy *) node; - gc = gaim_account_get_connection(b->account); - - silcgaim_ftp_send_file(gc, b->name); -} - GList *silcgaim_buddy_menu(GaimBuddy *buddy) { @@ -1626,10 +1612,6 @@ m = g_list_append(m, act); } - act = gaim_blist_node_action_new(_("Send File..."), - silcgaim_buddy_send_file, NULL); - m = g_list_append(m, act); - if (conn && conn->local_entry->mode & SILC_UMODE_ROUTER_OPERATOR) { act = gaim_blist_node_action_new(_("Kill User"), silcgaim_buddy_kill, NULL);
--- a/src/protocols/silc/ft.c Wed Jul 07 01:35:27 2004 +0000 +++ b/src/protocols/silc/ft.c Wed Jul 07 01:49:39 2004 +0000 @@ -345,11 +345,11 @@ return; } - silcgaim_ftp_send_file(client->application, (const char *)context); + silcgaim_ftp_send_file(client->application, (const char *)context, NULL); silc_free(context); } -void silcgaim_ftp_send_file(GaimConnection *gc, const char *name) +void silcgaim_ftp_send_file(GaimConnection *gc, const char *name, const char *file) { SilcGaim sg = gc->proto_data; SilcClient client = sg->client; @@ -400,7 +400,10 @@ xfer->xfer->data = xfer; /* Choose file to send */ - gaim_xfer_request(xfer->xfer); + if (file) + gaim_xfer_request_accepted(xfer->xfer, file); + else + gaim_xfer_request(xfer->xfer); silc_free(clients); silc_free(nickname);
--- a/src/protocols/silc/silc.c Wed Jul 07 01:35:27 2004 +0000 +++ b/src/protocols/silc/silc.c Wed Jul 07 01:49:39 2004 +0000 @@ -1436,7 +1436,9 @@ NULL, silcgaim_roomlist_get_list, silcgaim_roomlist_cancel, - NULL + NULL, + NULL, + silcgaim_ftp_send_file }; static GaimPluginInfo info =
--- a/src/protocols/silc/silcgaim.h Wed Jul 07 01:35:27 2004 +0000 +++ b/src/protocols/silc/silcgaim.h Wed Jul 07 01:49:39 2004 +0000 @@ -98,7 +98,7 @@ char *silcgaim_tooltip_text(GaimBuddy *b); char *silcgaim_status_text(GaimBuddy *b); gboolean silcgaim_ip_is_private(const char *ip); -void silcgaim_ftp_send_file(GaimConnection *gc, const char *name); +void silcgaim_ftp_send_file(GaimConnection *gc, const char *name, const char *file); void silcgaim_ftp_request(SilcClient client, SilcClientConnection conn, SilcClientEntry client_entry, SilcUInt32 session_id, const char *hostname, SilcUInt16 port);
--- a/src/protocols/yahoo/yahoo.c Wed Jul 07 01:35:27 2004 +0000 +++ b/src/protocols/yahoo/yahoo.c Wed Jul 07 01:49:39 2004 +0000 @@ -2666,20 +2666,6 @@ } -static void yahoo_ask_send_file_menu(GaimBlistNode *node, gpointer data) -{ - GaimBuddy *buddy; - GaimConnection *gc; - - g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); - - buddy = (GaimBuddy *) node; - gc = gaim_account_get_connection(buddy->account); - - yahoo_ask_send_file(gc, buddy->name); -} - - static GList *yahoo_buddy_menu(GaimBuddy *buddy) { GList *m = NULL; @@ -2713,11 +2699,6 @@ yahoo_initiate_conference, NULL); m = g_list_append(m, act); - /* FIXME: remove this when the ui does it for us. */ - act = gaim_blist_node_action_new(_("Send File"), - yahoo_ask_send_file_menu, NULL); - m = g_list_append(m, act); - if (yahoo_friend_get_game(f)) { const char *game = yahoo_friend_get_game(f); char *room; @@ -3232,13 +3213,6 @@ g_free(gpo); } -#if 0 -static gboolean yahoo_has_send_file(GaimConnection *gc, const char *who) -{ - return TRUE; -} -#endif - static GaimPlugin *my_protocol = NULL; static GaimPluginProtocolInfo prpl_info = @@ -3293,16 +3267,13 @@ yahoo_set_buddy_icon, NULL, /* void (*remove_group)(GaimConnection *gc, const char *group);*/ NULL, /* char *(*get_cb_real_name)(GaimConnection *gc, int id, const char *who); */ -#if 0 - yahoo_ask_send_file, - yahoo_send_file, - yahoo_has_send_file, -#endif NULL, NULL, yahoo_roomlist_get_list, yahoo_roomlist_cancel, - yahoo_roomlist_expand_category + yahoo_roomlist_expand_category, + NULL, + yahoo_send_file }; static GaimPluginInfo info =
--- a/src/protocols/yahoo/yahoo_filexfer.c Wed Jul 07 01:35:27 2004 +0000 +++ b/src/protocols/yahoo/yahoo_filexfer.c Wed Jul 07 01:49:39 2004 +0000 @@ -455,38 +455,12 @@ gaim_xfer_request(xfer); } -void yahoo_ask_send_file(GaimConnection *gc, const char *who) -{ - GaimXfer *xfer; - struct yahoo_xfer_data *xfer_data; - - xfer_data = g_new0(struct yahoo_xfer_data, 1); - xfer_data->gc = gc; - - - /* Build the file transfer handle. */ - xfer = gaim_xfer_new(gc->account, GAIM_XFER_SEND, who); - xfer->data = xfer_data; - - /* Setup our I/O op functions */ - gaim_xfer_set_init_fnc(xfer, yahoo_xfer_init); - gaim_xfer_set_start_fnc(xfer, yahoo_xfer_start); - gaim_xfer_set_end_fnc(xfer, yahoo_xfer_end); - gaim_xfer_set_cancel_send_fnc(xfer, yahoo_xfer_cancel_send); - gaim_xfer_set_cancel_recv_fnc(xfer, yahoo_xfer_cancel_recv); - gaim_xfer_set_read_fnc(xfer, yahoo_xfer_read); - gaim_xfer_set_write_fnc(xfer, yahoo_xfer_write); - - /* Now perform the request */ - gaim_xfer_request(xfer); -} - void yahoo_send_file(GaimConnection *gc, const char *who, const char *file) { GaimXfer *xfer; struct yahoo_xfer_data *xfer_data; - if (!who || !file) + if (!who) return; xfer_data = g_new0(struct yahoo_xfer_data, 1); @@ -507,5 +481,8 @@ gaim_xfer_set_write_fnc(xfer, yahoo_xfer_write); /* Now perform the request */ - gaim_xfer_request_accepted(xfer, file); + if (file) + gaim_xfer_request_accepted(xfer, file); + else + gaim_xfer_request(xfer); }
--- a/src/protocols/yahoo/yahoo_filexfer.h Wed Jul 07 01:35:27 2004 +0000 +++ b/src/protocols/yahoo/yahoo_filexfer.h Wed Jul 07 01:49:39 2004 +0000 @@ -30,14 +30,6 @@ * * @param gc The GaimConnection handle. * @param who Who are we sending it to? - * @param file What file? + * @param file What file? If NULL, user will choose after this call. */ void yahoo_send_file(GaimConnection *gc, const char *who, const char *file); - -/** - * Sends a file, that the user chooses after this call. - * - * @param gc The GaimConnection. - * @param who Who are we going to send a file to? - */ -void yahoo_ask_send_file(GaimConnection *gc, const char *who);
--- a/src/prpl.h Wed Jul 07 01:35:27 2004 +0000 +++ b/src/prpl.h Wed Jul 07 01:49:39 2004 +0000 @@ -286,6 +286,10 @@ struct _GaimRoomlist *(*roomlist_get_list)(GaimConnection *gc); void (*roomlist_cancel)(struct _GaimRoomlist *list); void (*roomlist_expand_category)(struct _GaimRoomlist *list, struct _GaimRoomlistRoom *category); + + /* file transfer callbacks */ + gboolean (*can_receive_file)(GaimConnection *, const char *who); + void (*send_file)(GaimConnection *, const char *who, const char *filename); }; #define GAIM_IS_PROTOCOL_PLUGIN(plugin) \
--- a/src/server.c Wed Jul 07 01:35:27 2004 +0000 +++ b/src/server.c Wed Jul 07 01:49:39 2004 +0000 @@ -1588,3 +1588,14 @@ g_free(buf); g_free(buffy); } + +void serv_send_file(GaimConnection *gc, const char *who, const char *file) +{ + GaimPluginProtocolInfo *prpl_info = NULL; + + if (gc != NULL && gc->prpl != NULL) + prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); + + if (prpl_info && prpl_info->send_file) + prpl_info->send_file(gc, who, file); +}
--- a/src/server.h Wed Jul 07 01:35:27 2004 +0000 +++ b/src/server.h Wed Jul 07 01:49:39 2004 +0000 @@ -95,6 +95,7 @@ void serv_got_chat_left(GaimConnection *g, int id); void serv_got_chat_in(GaimConnection *g, int id, const char *who, int whisper, const char *message, time_t mtime); +void serv_send_file(GaimConnection *gc, const char *who, const char *file); #ifdef __cplusplus }