Mercurial > pidgin
comparison 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 |
comparison
equal
deleted
inserted
replaced
10321:782c1b564906 | 10322:2a132b73a6e6 |
---|---|
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 * | 21 * |
22 */ | 22 */ |
23 #include "internal.h" | 23 #include "internal.h" |
24 | 24 |
25 #include "blist.h" | |
26 #include "prefs.h" | |
25 #include "sound.h" | 27 #include "sound.h" |
26 #include "prefs.h" | |
27 | 28 |
28 static GaimSoundUiOps *sound_ui_ops = NULL; | 29 static GaimSoundUiOps *sound_ui_ops = NULL; |
29 | 30 |
30 void gaim_sound_set_ui_ops(GaimSoundUiOps *ops) | 31 void |
31 { | 32 gaim_sound_play_file(const char *filename) |
32 if(sound_ui_ops && sound_ui_ops->shutdown) | |
33 sound_ui_ops->shutdown(); | |
34 sound_ui_ops = ops; | |
35 if(sound_ui_ops && sound_ui_ops->init) | |
36 sound_ui_ops->init(); | |
37 } | |
38 | |
39 GaimSoundUiOps *gaim_sound_get_ui_ops(void) | |
40 { | |
41 return sound_ui_ops; | |
42 } | |
43 | |
44 void gaim_sound_init() | |
45 { | |
46 gaim_prefs_add_none("/core/sound"); | |
47 gaim_prefs_add_bool("/core/sound/while_away", FALSE); | |
48 } | |
49 | |
50 void gaim_sound_shutdown() | |
51 { | |
52 if(sound_ui_ops && sound_ui_ops->shutdown) | |
53 sound_ui_ops->shutdown(); | |
54 } | |
55 | |
56 void gaim_sound_play_file(const char *filename) | |
57 { | 33 { |
58 /* FIXME */ | 34 /* FIXME */ |
59 #if 0 | 35 #if 0 |
60 if(awaymessage && !gaim_prefs_get_bool("/core/sound/while_away")) | 36 if(awaymessage && !gaim_prefs_get_bool("/core/sound/while_away")) |
61 return; | 37 return; |
63 | 39 |
64 if(sound_ui_ops && sound_ui_ops->play_file) | 40 if(sound_ui_ops && sound_ui_ops->play_file) |
65 sound_ui_ops->play_file(filename); | 41 sound_ui_ops->play_file(filename); |
66 } | 42 } |
67 | 43 |
68 void gaim_sound_play_event(GaimSoundEventID event) | 44 void |
45 gaim_sound_play_event(GaimSoundEventID event) | |
69 { | 46 { |
70 /* FIXME */ | 47 /* FIXME */ |
71 #if 0 | 48 #if 0 |
72 if(awaymessage && !gaim_prefs_get_bool("/core/sound/while_away")) | 49 if(awaymessage && !gaim_prefs_get_bool("/core/sound/while_away")) |
73 return; | 50 return; |
74 #endif | 51 #endif |
75 | 52 |
76 if(sound_ui_ops && sound_ui_ops->play_event) | 53 if(sound_ui_ops && sound_ui_ops->play_event) |
77 sound_ui_ops->play_event(event); | 54 sound_ui_ops->play_event(event); |
78 } | 55 } |
56 | |
57 static void | |
58 sound_triggered_cb(GaimBuddy *buddy, GaimSoundEventID event) | |
59 { | |
60 gaim_sound_play_event(event); | |
61 } | |
62 | |
63 void | |
64 gaim_sound_set_ui_ops(GaimSoundUiOps *ops) | |
65 { | |
66 if(sound_ui_ops && sound_ui_ops->uninit) | |
67 sound_ui_ops->uninit(); | |
68 | |
69 sound_ui_ops = ops; | |
70 | |
71 if(sound_ui_ops && sound_ui_ops->init) | |
72 sound_ui_ops->init(); | |
73 } | |
74 | |
75 GaimSoundUiOps * | |
76 gaim_sound_get_ui_ops(void) | |
77 { | |
78 return sound_ui_ops; | |
79 } | |
80 | |
81 void * | |
82 gaim_sound_get_handle() { | |
83 static int handle; | |
84 | |
85 return &handle; | |
86 } | |
87 | |
88 void | |
89 gaim_sound_init() | |
90 { | |
91 void *handle = gaim_sound_get_handle(); | |
92 void *blist_handle = gaim_blist_get_handle(); | |
93 | |
94 gaim_prefs_add_none("/core/sound"); | |
95 gaim_prefs_add_bool("/core/sound/while_away", FALSE); | |
96 | |
97 gaim_signal_connect(blist_handle, "buddy-signed-on", | |
98 handle, GAIM_CALLBACK(sound_triggered_cb), | |
99 GINT_TO_POINTER(GAIM_SOUND_BUDDY_ARRIVE)); | |
100 gaim_signal_connect(blist_handle, "buddy-signed-off", | |
101 handle, GAIM_CALLBACK(sound_triggered_cb), | |
102 GINT_TO_POINTER(GAIM_SOUND_BUDDY_LEAVE)); | |
103 } | |
104 | |
105 void | |
106 gaim_sound_uninit() | |
107 { | |
108 gaim_signals_disconnect_by_handle(gaim_sound_get_handle()); | |
109 | |
110 if(sound_ui_ops && sound_ui_ops->uninit) | |
111 sound_ui_ops->uninit(); | |
112 } |