# HG changeset patch # User Gary Kramlich # Date 1124225067 0 # Node ID 920a37a4c1be952cc87142b5d1cf629ac7a8ca24 # Parent 65658ff2deb8d1dbbebfc4f3a6dc23f8228ef10e [gaim-migrate @ 13478] Patch from Sadrul Habib Chowdhury, with a bit of hacking from me, to add file transfer signals committer: Tailor Script diff -r 65658ff2deb8 -r 920a37a4c1be doc/Makefile.am --- a/doc/Makefile.am Tue Aug 16 19:15:28 2005 +0000 +++ b/doc/Makefile.am Tue Aug 16 20:44:27 2005 +0000 @@ -19,4 +19,5 @@ gtkimhtml-signals.dox \ plugin-ids.dox \ gaim.1.in \ - gaim-remote.1.in + gaim-remote.1.in \ + xfer-signals.dox diff -r 65658ff2deb8 -r 920a37a4c1be doc/xfer-signals.dox --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/xfer-signals.dox Tue Aug 16 20:44:27 2005 +0000 @@ -0,0 +1,97 @@ +/** @page xfer-signals File Transfer Signals + + @signals + @signal file-recv-accept + @signal file-recv-start + @signal file-recv-cancel + @signal file-recv-complete + @signal file-send-accept + @signal file-send-start + @signal file-send-cancel + @signal file-send-complete + @endsignals + +
+ + @signaldef file-recv-accept + @signalproto +void (*file_recv_accept)(GaimXfer *xfer, gpointer data); + @endsignalproto + @signaldesc + Emitted when an incoming file transfer has been accepted. + @param xfer The file transfer + @param data User data + @endsignaldef + + @signaldef file-recv-start + @signalproto +void (*file_recv_start)(GaimXfer *xfer, gpointer data); + @endsignalproto + @signaldesc + Emitted when an incoming file transfer has been started. + @param xfer The file transfer + @param data User data + @endsignaldef + + @signaldef file-recv-cancel + @signalproto +void (*file_recv_cancel)(GaimXfer *xfer, gpointer data); + @endsignalproto + @signaldesc + Emitted when an incoming file transfer has been canceled. + @param xfer The file transfer + @param data User data + @endsignaldef + + @signaldef file-recv-complete + @signalproto +void (*file_recv_complete)(GaimXfer *xfer, gpointer data); + @endsignalproto + @signaldesc + Emitted when an incoming file transfer has been completed. + @param xfer The file transfer + @param data User data + @endsignaldef + + @signaldef file-send-accept + @signalproto +void (*file_send_accept)(GaimXfer *xfer, gpointer data); + @endsignalproto + @signaldesc + Emitted when an outgoing file transfer has been accepted. + @param xfer The file transfer + @param data User data + @endsignaldef + + @signaldef file-send-start + @signalproto +void (*file_send_start)(GaimXfer *xfer, gpointer data); + @endsignalproto + @signaldesc + Emitted when an outgoing file transfer has started. + @param xfer The file transfer + @param data User data + @endsignaldef + + @signaldef file-send-cancel + @signalproto +void (*file_send_cancel)(GaimXfer *xfer, gpointer data); + @endsignalproto + @signaldesc + Emitted when an outgoing file transfer has been canceled. + @param xfer The file transfer + @param data User data + @endsignaldef + + @signaldef file-send-complete + @signalproto +void (*file_send_complete)(GaimXfer *xfer, gpointer data); + @endsignalproto + @signaldesc + Emitted when an outgoing file transfer has been completed. + @param xfer The file transfer + @param data User data + @endsignaldef + + */ +// vim: syntax=c tw=75 et diff -r 65658ff2deb8 -r 920a37a4c1be plugins/signals-test.c --- a/plugins/signals-test.c Tue Aug 16 19:15:28 2005 +0000 +++ b/plugins/signals-test.c Tue Aug 16 20:44:27 2005 +0000 @@ -28,6 +28,7 @@ #include "conversation.h" #include "core.h" #include "debug.h" +#include "ft.h" #include "signals.h" #include "version.h" @@ -477,6 +478,49 @@ } /************************************************************************** + * File transfer signal callbacks + **************************************************************************/ +static void +ft_recv_accept_cb(GaimXfer *xfer, gpointer data) { + gaim_debug_misc("signals test", "file receive accepted\n"); +} + +static void +ft_send_accept_cb(GaimXfer *xfer, gpointer data) { + gaim_debug_misc("signals test", "file send accepted\n"); +} + +static void +ft_recv_start_cb(GaimXfer *xfer, gpointer data) { + gaim_debug_misc("signals test", "file receive started\n"); +} + +static void +ft_send_start_cb(GaimXfer *xfer, gpointer data) { + gaim_debug_misc("signals test", "file send started\n"); +} + +static void +ft_recv_cancel_cb(GaimXfer *xfer, gpointer data) { + gaim_debug_misc("signals test", "file receive canceled\n"); +} + +static void +ft_send_cancel_cb(GaimXfer *xfer, gpointer data) { + gaim_debug_misc("signals test", "file send canceled\n"); +} + +static void +ft_recv_complete_cb(GaimXfer *xfer, gpointer data) { + gaim_debug_misc("signals test", "file receive completed\n"); +} + +static void +ft_send_complete_cb(GaimXfer *xfer, gpointer data) { + gaim_debug_misc("signals test", "file send completed\n"); +} + +/************************************************************************** * Plugin stuff **************************************************************************/ static gboolean @@ -489,6 +533,7 @@ void *accounts_handle = gaim_accounts_get_handle(); void *ciphers_handle = gaim_ciphers_get_handle(); void *buddy_icons_handle = gaim_buddy_icons_get_handle(); + void *ft_handle = gaim_xfers_get_handle(); /* Accounts subsystem signals */ gaim_signal_connect(accounts_handle, "account-connecting", @@ -608,6 +653,24 @@ gaim_signal_connect(core_handle, "quitting", plugin, GAIM_CALLBACK(quitting_cb), NULL); + /* file transfer signals */ + gaim_signal_connect(ft_handle, "file-recv-accept", + plugin, GAIM_CALLBACK(ft_recv_accept_cb), NULL); + gaim_signal_connect(ft_handle, "file-recv-start", + plugin, GAIM_CALLBACK(ft_recv_start_cb), NULL); + gaim_signal_connect(ft_handle, "file-recv-cancel", + plugin, GAIM_CALLBACK(ft_recv_cancel_cb), NULL); + gaim_signal_connect(ft_handle, "file-recv-complete", + plugin, GAIM_CALLBACK(ft_recv_complete_cb), NULL); + gaim_signal_connect(ft_handle, "file-send-accept", + plugin, GAIM_CALLBACK(ft_send_accept_cb), NULL); + gaim_signal_connect(ft_handle, "file-send-start", + plugin, GAIM_CALLBACK(ft_send_start_cb), NULL); + gaim_signal_connect(ft_handle, "file-send-cancel", + plugin, GAIM_CALLBACK(ft_send_cancel_cb), NULL); + gaim_signal_connect(ft_handle, "file-send-complete", + plugin, GAIM_CALLBACK(ft_send_complete_cb), NULL); + return TRUE; } diff -r 65658ff2deb8 -r 920a37a4c1be src/core.c --- a/src/core.c Tue Aug 16 19:15:28 2005 +0000 +++ b/src/core.c Tue Aug 16 20:44:27 2005 +0000 @@ -28,6 +28,7 @@ #include "conversation.h" #include "core.h" #include "debug.h" +#include "ft.h" #include "network.h" #include "plugin.h" #include "pounce.h" @@ -120,6 +121,7 @@ gaim_proxy_init(); gaim_sound_init(); gaim_ssl_init(); + gaim_xfers_init(); if (ops != NULL && ops->ui_init != NULL) ops->ui_init(); @@ -154,6 +156,7 @@ gaim_status_uninit(); gaim_prefs_uninit(); gaim_sound_uninit(); + gaim_xfers_uninit(); gaim_debug_info("main", "Unloading all plugins\n"); gaim_plugins_destroy_all(); diff -r 65658ff2deb8 -r 920a37a4c1be src/ft.c --- a/src/ft.c Tue Aug 16 19:15:28 2005 +0000 +++ b/src/ft.c Tue Aug 16 20:44:27 2005 +0000 @@ -110,6 +110,44 @@ { g_return_if_fail(xfer != NULL); + if(xfer->type == GAIM_XFER_SEND) { + switch(status) { + case GAIM_XFER_STATUS_ACCEPTED: + gaim_signal_emit(gaim_xfers_get_handle(), "file-send-accept", xfer); + break; + case GAIM_XFER_STATUS_STARTED: + gaim_signal_emit(gaim_xfers_get_handle(), "file-send-start", xfer); + break; + case GAIM_XFER_STATUS_DONE: + gaim_signal_emit(gaim_xfers_get_handle(), "file-send-complete", xfer); + break; + case GAIM_XFER_STATUS_CANCEL_LOCAL: + case GAIM_XFER_STATUS_CANCEL_REMOTE: + gaim_signal_emit(gaim_xfers_get_handle(), "file-send-cancel", xfer); + break; + default: + break; + } + } else if(xfer->type == GAIM_XFER_RECEIVE) { + switch(status) { + case GAIM_XFER_STATUS_ACCEPTED: + gaim_signal_emit(gaim_xfers_get_handle(), "file-recv-accept", xfer); + break; + case GAIM_XFER_STATUS_STARTED: + gaim_signal_emit(gaim_xfers_get_handle(), "file-recv-start", xfer); + break; + case GAIM_XFER_STATUS_DONE: + gaim_signal_emit(gaim_xfers_get_handle(), "file-recv-complete", xfer); + break; + case GAIM_XFER_STATUS_CANCEL_LOCAL: + case GAIM_XFER_STATUS_CANCEL_REMOTE: + gaim_signal_emit(gaim_xfers_get_handle(), "file-recv-cancel", xfer); + break; + default: + break; + } + } + xfer->status = status; } @@ -1103,15 +1141,63 @@ /************************************************************************** * File Transfer Subsystem API **************************************************************************/ +void * +gaim_xfers_get_handle(void) { + static int handle = 0; + + return &handle; +} void -gaim_xfers_set_ui_ops(GaimXferUiOps *ops) -{ +gaim_xfers_init(void) { + void *handle = gaim_xfers_get_handle(); + + /* register signals */ + gaim_signal_register(handle, "file-recv-accept", + gaim_marshal_VOID__POINTER, + NULL, 1, + gaim_value_new(GAIM_TYPE_POINTER)); + gaim_signal_register(handle, "file-send-accept", + gaim_marshal_VOID__POINTER, + NULL, 1, + gaim_value_new(GAIM_TYPE_POINTER)); + gaim_signal_register(handle, "file-recv-start", + gaim_marshal_VOID__POINTER, + NULL, 1, + gaim_value_new(GAIM_TYPE_POINTER)); + gaim_signal_register(handle, "file-send-start", + gaim_marshal_VOID__POINTER, + NULL, 1, + gaim_value_new(GAIM_TYPE_POINTER)); + gaim_signal_register(handle, "file-send-cancel", + gaim_marshal_VOID__POINTER, + NULL, 1, + gaim_value_new(GAIM_TYPE_POINTER)); + gaim_signal_register(handle, "file-recv-cancel", + gaim_marshal_VOID__POINTER, + NULL, 1, + gaim_value_new(GAIM_TYPE_POINTER)); + gaim_signal_register(handle, "file-send-complete", + gaim_marshal_VOID__POINTER, + NULL, 1, + gaim_value_new(GAIM_TYPE_POINTER)); + gaim_signal_register(handle, "file-recv-complete", + gaim_marshal_VOID__POINTER, + NULL, 1, + gaim_value_new(GAIM_TYPE_POINTER)); +} + +void +gaim_xfers_uninit(void) { + gaim_signals_disconnect_by_handle(gaim_xfers_get_handle()); +} + +void +gaim_xfers_set_ui_ops(GaimXferUiOps *ops) { xfer_ui_ops = ops; } GaimXferUiOps * -gaim_xfers_get_ui_ops(void) -{ +gaim_xfers_get_ui_ops(void) { return xfer_ui_ops; } diff -r 65658ff2deb8 -r 920a37a4c1be src/ft.h --- a/src/ft.h Tue Aug 16 19:15:28 2005 +0000 +++ b/src/ft.h Tue Aug 16 20:44:27 2005 +0000 @@ -558,6 +558,23 @@ /*@{*/ /** + * Returns the handle to the file transfer subsystem + * + * @return The handle + */ +void *gaim_xfers_get_handle(void); + +/** + * Initializes the file transfer subsystem + */ +void gaim_xfers_init(void); + +/** + * Uninitializes the file transfer subsystem + */ +void gaim_xfers_uninit(void); + +/** * Sets the UI operations structure to be used in all gaim file transfers. * * @param ops The UI operations structure.