# HG changeset patch # User Richard Laager # Date 1139635470 0 # Node ID d0f7f698b6de59d5d84ad48cb87321de0f16e8ff # Parent c01aa6ea494700bd9ea3d586db10906b3002ac15 [gaim-migrate @ 15583] SF Patch #1428591 from Sadrul "This is a new signal, emitted when request for a file-transfer comes in. I have written a trivial plugin (which I plan on adding under plugin_pack in a couple of days) that uses this signal to auto-accept file-transfers. I have tested the plugin to auto-accept or auto-reject file-transfer requests." I also noticed that the file transfer signals weren't using a subtype for GaimXfer pointers, so I added one. committer: Tailor Script diff -r c01aa6ea4947 -r d0f7f698b6de doc/xfer-signals.dox --- a/doc/xfer-signals.dox Sat Feb 11 05:18:48 2006 +0000 +++ b/doc/xfer-signals.dox Sat Feb 11 05:24:30 2006 +0000 @@ -5,6 +5,7 @@ @signal file-recv-start @signal file-recv-cancel @signal file-recv-complete + @signal file-recv-request @signal file-send-accept @signal file-send-start @signal file-send-cancel @@ -53,6 +54,20 @@ @param data User data @endsignaldef + @signaldef file-recv-request + @signalproto +void (*file_recv_request)(GaimXfer *xfer, gpointer data); + @endsignalproto + @signaldesc + Emitted before the user is prompted for an incoming file-transfer. + Plugins can intercept the signal to auto-accept/auto-reject the + requests. To auto-accept the file transfer, use + gaim_xfer_request_accepted(). To auto-reject, set the status of the + xfer to GAIM_XFER_STATUS_CANCEL_LOCAL. + @param xfer The file transfer + @param data User data + @endsignaldef + @signaldef file-send-accept @signalproto void (*file_send_accept)(GaimXfer *xfer, gpointer data); diff -r c01aa6ea4947 -r d0f7f698b6de plugins/ChangeLog.API --- a/plugins/ChangeLog.API Sat Feb 11 05:18:48 2006 +0000 +++ b/plugins/ChangeLog.API Sat Feb 11 05:24:30 2006 +0000 @@ -306,6 +306,7 @@ * "file-recv-start" * "file-recv-cancel" * "file-recv-complete" + * "file-recv-request" * "file-send-accept" * "file-send-start" * "file-send-cancel" diff -r c01aa6ea4947 -r d0f7f698b6de plugins/perl/perl-common.c --- a/plugins/perl/perl-common.c Sat Feb 11 05:18:48 2006 +0000 +++ b/plugins/perl/perl-common.c Sat Feb 11 05:24:30 2006 +0000 @@ -444,6 +444,9 @@ case GAIM_SUBTYPE_LOG: stash = "Gaim::Log"; break; + case GAIM_SUBTYPE_XFER: + stash = "Gaim::Xfer"; + break; default: stash = "Gaim"; /* ? */ diff -r c01aa6ea4947 -r d0f7f698b6de plugins/tcl/tcl_signals.c --- a/plugins/tcl/tcl_signals.c Sat Feb 11 05:18:48 2006 +0000 +++ b/plugins/tcl/tcl_signals.c Sat Feb 11 05:24:30 2006 +0000 @@ -259,6 +259,7 @@ case GAIM_SUBTYPE_CONNECTION: case GAIM_SUBTYPE_CONVERSATION: case GAIM_SUBTYPE_PLUGIN: + case GAIM_SUBTYPE_XFER: /* pointers again */ if (gaim_value_is_outgoing(handler->argtypes[i])) { vals[i] = va_arg(args, void **); diff -r c01aa6ea4947 -r d0f7f698b6de src/ft.c --- a/src/ft.c Sat Feb 11 05:18:48 2006 +0000 +++ b/src/ft.c Sat Feb 11 05:24:30 2006 +0000 @@ -219,7 +219,7 @@ gaim_xfer_request_accepted(xfer, filename); } else { - gaim_xfer_show_file_error(xfer, filename); + gaim_xfer_show_file_error(xfer, filename); gaim_xfer_request_denied(xfer); } } @@ -305,8 +305,8 @@ size = gaim_xfer_get_size(xfer); size_buf = gaim_str_size_to_units(size); buf = g_strdup_printf(_("%s wants to send you %s (%s)"), - buddy ? gaim_buddy_get_alias(buddy) : xfer->who, - gaim_xfer_get_filename(xfer), size_buf); + buddy ? gaim_buddy_get_alias(buddy) : xfer->who, + gaim_xfer_get_filename(xfer), size_buf); g_free(size_buf); } else @@ -353,13 +353,13 @@ GaimBuddy *buddy = gaim_find_buddy(xfer->account, xfer->who); buf = g_strdup_printf(_("Accept file transfer request from %s?"), - buddy ? gaim_buddy_get_alias(buddy) : xfer->who); + buddy ? gaim_buddy_get_alias(buddy) : xfer->who); if (gaim_xfer_get_remote_ip(xfer) && - gaim_xfer_get_remote_port(xfer)) + gaim_xfer_get_remote_port(xfer)) buf2 = g_strdup_printf(_("A file is available for download from:\n" "Remote host: %s\nRemote port: %d"), - gaim_xfer_get_remote_ip(xfer), - gaim_xfer_get_remote_port(xfer)); + gaim_xfer_get_remote_ip(xfer), + gaim_xfer_get_remote_port(xfer)); gaim_request_accept_cancel(xfer, NULL, buf, buf2, GAIM_DEFAULT_ACTION_NONE, xfer, G_CALLBACK(ask_accept_ok), @@ -376,20 +376,35 @@ gaim_xfer_ref(xfer); - if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { - if (gaim_xfer_get_filename(xfer) || - gaim_xfer_get_status(xfer) == GAIM_XFER_STATUS_ACCEPTED) { + if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) + { + gaim_signal_emit(gaim_xfers_get_handle(), "file-recv-request", xfer); + if (gaim_xfer_get_status(xfer) == GAIM_XFER_STATUS_CANCEL_LOCAL) + { + /* The file-transfer was cancelled by a plugin */ + gaim_xfer_cancel_local(xfer); + } + else if (gaim_xfer_get_filename(xfer) || + gaim_xfer_get_status(xfer) == GAIM_XFER_STATUS_ACCEPTED) + { gchar* message = NULL; message = g_strdup_printf(_("%s is offering to send file %s"), xfer->who, gaim_xfer_get_filename(xfer)); gaim_xfer_conversation_write(xfer, message, FALSE); g_free(message); - gaim_xfer_ask_recv(xfer); - } else { + /* Ask for a filename to save to if it's not already given by a plugin */ + if (xfer->local_filename == NULL) + gaim_xfer_ask_recv(xfer); + } + else + { gaim_xfer_ask_accept(xfer); } - } else + } + else + { gaim_xfer_choose_file(xfer); + } } void @@ -1168,35 +1183,39 @@ gaim_signal_register(handle, "file-recv-accept", gaim_marshal_VOID__POINTER, NULL, 1, - gaim_value_new(GAIM_TYPE_POINTER)); + gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_XFER)); gaim_signal_register(handle, "file-send-accept", gaim_marshal_VOID__POINTER, NULL, 1, - gaim_value_new(GAIM_TYPE_POINTER)); + gaim_value_new(GAIM_TYPE_POINTER, GAIM_SUBTYPE_XFER)); gaim_signal_register(handle, "file-recv-start", gaim_marshal_VOID__POINTER, NULL, 1, - gaim_value_new(GAIM_TYPE_POINTER)); + gaim_value_new(GAIM_TYPE_POINTER, GAIM_SUBTYPE_XFER)); gaim_signal_register(handle, "file-send-start", gaim_marshal_VOID__POINTER, NULL, 1, - gaim_value_new(GAIM_TYPE_POINTER)); + gaim_value_new(GAIM_TYPE_POINTER, GAIM_SUBTYPE_XFER)); gaim_signal_register(handle, "file-send-cancel", gaim_marshal_VOID__POINTER, NULL, 1, - gaim_value_new(GAIM_TYPE_POINTER)); + gaim_value_new(GAIM_TYPE_POINTER, GAIM_SUBTYPE_XFER)); gaim_signal_register(handle, "file-recv-cancel", gaim_marshal_VOID__POINTER, NULL, 1, - gaim_value_new(GAIM_TYPE_POINTER)); + gaim_value_new(GAIM_TYPE_POINTER, GAIM_SUBTYPE_XFER)); gaim_signal_register(handle, "file-send-complete", gaim_marshal_VOID__POINTER, NULL, 1, - gaim_value_new(GAIM_TYPE_POINTER)); + gaim_value_new(GAIM_TYPE_POINTER, GAIM_SUBTYPE_XFER)); gaim_signal_register(handle, "file-recv-complete", gaim_marshal_VOID__POINTER, NULL, 1, - gaim_value_new(GAIM_TYPE_POINTER)); + gaim_value_new(GAIM_TYPE_POINTER, GAIM_SUBTYPE_XFER)); + gaim_signal_register(handle, "file-recv-request", + gaim_marshal_VOID__POINTER, + NULL, 1, + gaim_value_new(GAIM_TYPE_POINTER, GAIM_SUBTYPE_XFER)); } void diff -r c01aa6ea4947 -r d0f7f698b6de src/value.h --- a/src/value.h Sat Feb 11 05:18:48 2006 +0000 +++ b/src/value.h Sat Feb 11 05:24:30 2006 +0000 @@ -71,7 +71,8 @@ GAIM_SUBTYPE_BLIST_NODE, GAIM_SUBTYPE_CIPHER, GAIM_SUBTYPE_STATUS, - GAIM_SUBTYPE_LOG + GAIM_SUBTYPE_LOG, + GAIM_SUBTYPE_XFER } GaimSubType; /**