Mercurial > pidgin.yaz
changeset 11281:920a37a4c1be
[gaim-migrate @ 13478]
Patch from Sadrul Habib Chowdhury, with a bit of hacking from me, to add file transfer signals
committer: Tailor Script <tailor@pidgin.im>
author | Gary Kramlich <grim@reaperworld.com> |
---|---|
date | Tue, 16 Aug 2005 20:44:27 +0000 |
parents | 65658ff2deb8 |
children | 1c2232d6ae15 |
files | doc/Makefile.am doc/xfer-signals.dox plugins/signals-test.c src/core.c src/ft.c src/ft.h |
diffstat | 6 files changed, 272 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- /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 + + <hr> + + @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
--- 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; }
--- 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();
--- 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; }
--- 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.