Mercurial > pidgin
diff src/sound.c @ 10322:2a132b73a6e6
[gaim-migrate @ 11529]
I shuffled around lots of sound code and made the buddy-signon/signoff
sounds work again. And I did it by making sound.c connec to the
buddy-signon signal.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 05 Dec 2004 23:19:16 +0000 |
parents | bdec08a8fc5b |
children | 11d30825c1bb |
line wrap: on
line diff
--- a/src/sound.c Sun Dec 05 21:25:44 2004 +0000 +++ b/src/sound.c Sun Dec 05 23:19:16 2004 +0000 @@ -22,38 +22,14 @@ */ #include "internal.h" +#include "blist.h" +#include "prefs.h" #include "sound.h" -#include "prefs.h" static GaimSoundUiOps *sound_ui_ops = NULL; -void gaim_sound_set_ui_ops(GaimSoundUiOps *ops) -{ - if(sound_ui_ops && sound_ui_ops->shutdown) - sound_ui_ops->shutdown(); - sound_ui_ops = ops; - if(sound_ui_ops && sound_ui_ops->init) - sound_ui_ops->init(); -} - -GaimSoundUiOps *gaim_sound_get_ui_ops(void) -{ - return sound_ui_ops; -} - -void gaim_sound_init() -{ - gaim_prefs_add_none("/core/sound"); - gaim_prefs_add_bool("/core/sound/while_away", FALSE); -} - -void gaim_sound_shutdown() -{ - if(sound_ui_ops && sound_ui_ops->shutdown) - sound_ui_ops->shutdown(); -} - -void gaim_sound_play_file(const char *filename) +void +gaim_sound_play_file(const char *filename) { /* FIXME */ #if 0 @@ -65,7 +41,8 @@ sound_ui_ops->play_file(filename); } -void gaim_sound_play_event(GaimSoundEventID event) +void +gaim_sound_play_event(GaimSoundEventID event) { /* FIXME */ #if 0 @@ -76,3 +53,60 @@ if(sound_ui_ops && sound_ui_ops->play_event) sound_ui_ops->play_event(event); } + +static void +sound_triggered_cb(GaimBuddy *buddy, GaimSoundEventID event) +{ + gaim_sound_play_event(event); +} + +void +gaim_sound_set_ui_ops(GaimSoundUiOps *ops) +{ + if(sound_ui_ops && sound_ui_ops->uninit) + sound_ui_ops->uninit(); + + sound_ui_ops = ops; + + if(sound_ui_ops && sound_ui_ops->init) + sound_ui_ops->init(); +} + +GaimSoundUiOps * +gaim_sound_get_ui_ops(void) +{ + return sound_ui_ops; +} + +void * +gaim_sound_get_handle() { + static int handle; + + return &handle; +} + +void +gaim_sound_init() +{ + void *handle = gaim_sound_get_handle(); + void *blist_handle = gaim_blist_get_handle(); + + gaim_prefs_add_none("/core/sound"); + gaim_prefs_add_bool("/core/sound/while_away", FALSE); + + gaim_signal_connect(blist_handle, "buddy-signed-on", + handle, GAIM_CALLBACK(sound_triggered_cb), + GINT_TO_POINTER(GAIM_SOUND_BUDDY_ARRIVE)); + gaim_signal_connect(blist_handle, "buddy-signed-off", + handle, GAIM_CALLBACK(sound_triggered_cb), + GINT_TO_POINTER(GAIM_SOUND_BUDDY_LEAVE)); +} + +void +gaim_sound_uninit() +{ + gaim_signals_disconnect_by_handle(gaim_sound_get_handle()); + + if(sound_ui_ops && sound_ui_ops->uninit) + sound_ui_ops->uninit(); +}