Mercurial > pidgin.yaz
changeset 12291:5bc3d67ceb24
[gaim-migrate @ 14595]
Adam Wendt <adam@ipwebdev.com> gives us the playing-sound-event signal, now
plugins can stop sound events, or play their own.
committer: Tailor Script <tailor@pidgin.im>
author | Etan Reisner <pidgin@unreliablesource.net> |
---|---|
date | Fri, 02 Dec 2005 06:43:00 +0000 |
parents | f17958be25ab |
children | b0582839cd6c |
files | COPYRIGHT doc/Makefile.am doc/gtkaccount-signals.dox doc/gtkblist-signals.dox doc/gtkconv-signals.dox doc/gtkimhtml-signals.dox plugins/signals-test.c src/signals.c src/signals.h src/sound.c src/sound.h |
diffstat | 11 files changed, 92 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/COPYRIGHT Fri Dec 02 03:13:51 2005 +0000 +++ b/COPYRIGHT Fri Dec 02 06:43:00 2005 +0000 @@ -253,6 +253,7 @@ Nathan Walp Eric Warmenhoven Andrew Wellington +Adam Wendt Dave West Daniel Westermann-Clark Andrew Whewell
--- a/doc/Makefile.am Fri Dec 02 03:13:51 2005 +0000 +++ b/doc/Makefile.am Fri Dec 02 06:43:00 2005 +0000 @@ -22,5 +22,6 @@ notify-signals.dox \ plugin-ids.dox \ plugin-signals.dox \ + sound-signals.dox \ the_penguin.txt \ xfer-signals.dox
--- a/doc/gtkaccount-signals.dox Fri Dec 02 03:13:51 2005 +0000 +++ b/doc/gtkaccount-signals.dox Fri Dec 02 06:43:00 2005 +0000 @@ -15,3 +15,4 @@ @param account The account that has been modified. @endsignaldef */ +// vim: syntax=c tw=75 et
--- a/doc/gtkblist-signals.dox Fri Dec 02 03:13:51 2005 +0000 +++ b/doc/gtkblist-signals.dox Fri Dec 02 06:43:00 2005 +0000 @@ -50,3 +50,4 @@ @param text A pointer to the text that will be displayed. @endsignaldef */ +// vim: syntax=c tw=75 et
--- a/doc/gtkconv-signals.dox Fri Dec 02 03:13:51 2005 +0000 +++ b/doc/gtkconv-signals.dox Fri Dec 02 06:43:00 2005 +0000 @@ -16,3 +16,4 @@ @param destination The window where the conversation will be moved to. @endsignaldef */ +// vim: syntax=c tw=75 et
--- a/doc/gtkimhtml-signals.dox Fri Dec 02 03:13:51 2005 +0000 +++ b/doc/gtkimhtml-signals.dox Fri Dec 02 06:43:00 2005 +0000 @@ -57,3 +57,4 @@ @param data User defined data. @endsignaldef */ +// vim: syntax=c tw=75 et
--- a/plugins/signals-test.c Fri Dec 02 03:13:51 2005 +0000 +++ b/plugins/signals-test.c Fri Dec 02 06:43:00 2005 +0000 @@ -32,6 +32,7 @@ #include "signals.h" #include "version.h" #include "status.h" +#include "sound.h" /************************************************************************** * Account subsystem signal callbacks @@ -548,18 +549,30 @@ } /************************************************************************** + * Sound signal callbacks + **************************************************************************/ +static int +sound_playing_event_cb(GaimSoundEventID event, const GaimAccount *account) { + gaim_debug_misc("signals test", "sound playing event: %d for account: %s\n", + event, gaim_account_get_username(account)); + + return 0; +} + +/************************************************************************** * Plugin stuff **************************************************************************/ static gboolean plugin_load(GaimPlugin *plugin) { - void *core_handle = gaim_get_core(); - void *blist_handle = gaim_blist_get_handle(); - void *conn_handle = gaim_connections_get_handle(); - void *conv_handle = gaim_conversations_get_handle(); + void *core_handle = gaim_get_core(); + void *blist_handle = gaim_blist_get_handle(); + void *conn_handle = gaim_connections_get_handle(); + void *conv_handle = gaim_conversations_get_handle(); void *accounts_handle = gaim_accounts_get_handle(); - void *ciphers_handle = gaim_ciphers_get_handle(); - void *ft_handle = gaim_xfers_get_handle(); + void *ciphers_handle = gaim_ciphers_get_handle(); + void *ft_handle = gaim_xfers_get_handle(); + void *sound_handle = gaim_sounds_get_handle(); /* Accounts subsystem signals */ gaim_signal_connect(accounts_handle, "account-connecting", @@ -679,7 +692,7 @@ gaim_signal_connect(core_handle, "quitting", plugin, GAIM_CALLBACK(quitting_cb), NULL); - /* file transfer signals */ + /* 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", @@ -697,6 +710,10 @@ gaim_signal_connect(ft_handle, "file-send-complete", plugin, GAIM_CALLBACK(ft_send_complete_cb), NULL); + /* Sound signals */ + gaim_signal_connect(sound_handle, "playing-sound-event", plugin, + GAIM_CALLBACK(sound_playing_event_cb), NULL); + return TRUE; }
--- a/src/signals.c Fri Dec 02 03:13:51 2005 +0000 +++ b/src/signals.c Fri Dec 02 06:43:00 2005 +0000 @@ -931,3 +931,17 @@ if (return_val != NULL) *return_val = GINT_TO_POINTER(ret_val); } + +void +gaim_marshal_BOOLEAN__INT_POINTER(GaimCallback cb, va_list args, void *data, + void **return_val) +{ + gboolean ret_val; + gint arg1 = va_arg(args, gint); + void *arg2 = va_arg(args, void *); + + ret_val = ((gboolean (*)(gint, void *, void *))cb)(arg1, arg2, data); + + if (return_val != NULL) + *return_val = GINT_TO_POINTER(ret_val); +}
--- a/src/signals.h Fri Dec 02 03:13:51 2005 +0000 +++ b/src/signals.h Fri Dec 02 06:43:00 2005 +0000 @@ -324,6 +324,9 @@ void gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER_POINTER( GaimCallback cb, va_list args, void *data, void **return_val); +void gaim_marshal_BOOLEAN__INT_POINTER( + GaimCallback cb, va_list args, void *data, void **return_val); + /*@}*/ #ifdef __cplusplus
--- a/src/sound.c Fri Dec 02 03:13:51 2005 +0000 +++ b/src/sound.c Fri Dec 02 06:43:00 2005 +0000 @@ -49,15 +49,27 @@ { GaimStatus *status; - if ((account != NULL) && (!gaim_prefs_get_bool("/core/sound/while_away"))) + if ((account != NULL) && + (!gaim_prefs_get_bool("/core/sound/while_away"))) { status = gaim_account_get_active_status(account); - if (gaim_status_is_online(status) && !gaim_status_is_available(status)) + if (gaim_status_is_online(status) && + !gaim_status_is_available(status)) return; } - if(sound_ui_ops && sound_ui_ops->play_event) - sound_ui_ops->play_event(event); + if(sound_ui_ops && sound_ui_ops->play_event) { + int plugin_return; + + plugin_return = GPOINTER_TO_INT(gaim_signal_emit_return_1( + gaim_sounds_get_handle(), "playing-sound-event", + event, account)); + + if (plugin_return) + return; + else + sound_ui_ops->play_event(event); + } } void @@ -81,6 +93,18 @@ void gaim_sound_init() { + void *handle = gaim_sounds_get_handle(); + + /********************************************************************** + * Register signals + **********************************************************************/ + + gaim_signal_register(handle, "playing-sound-event", + gaim_marshal_BOOLEAN__INT_POINTER, + gaim_value_new(GAIM_TYPE_BOOLEAN), 2, + gaim_value_new(GAIM_TYPE_INT), + gaim_value_new(GAIM_TYPE_POINTER)); + gaim_prefs_add_none("/core/sound"); gaim_prefs_add_bool("/core/sound/while_away", FALSE); @@ -91,4 +115,14 @@ { if(sound_ui_ops && sound_ui_ops->uninit) sound_ui_ops->uninit(); + + gaim_signals_unregister_by_instance(gaim_sounds_get_handle()); } + +void * +gaim_sounds_get_handle() +{ + static int handle; + + return &handle; +}
--- a/src/sound.h Fri Dec 02 03:13:51 2005 +0000 +++ b/src/sound.h Fri Dec 02 06:43:00 2005 +0000 @@ -117,6 +117,13 @@ */ void gaim_sound_uninit(void); +/** + * Returns the sound subsystem handle. + * + * @return The sound subsystem handle. + */ +void *gaim_sounds_get_handle(void); + /*@}*/ #ifdef __cplusplus