Mercurial > pidgin.yaz
comparison libpurple/sound.c @ 15823:32c366eeeb99
sed -ie 's/gaim/purple/g'
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Mon, 19 Mar 2007 07:01:17 +0000 |
parents | 5fe8042783c1 |
children | 4999bbc52881 |
comparison
equal
deleted
inserted
replaced
15822:84b0f9b23ede | 15823:32c366eeeb99 |
---|---|
1 /* | 1 /* |
2 * gaim | 2 * purple |
3 * | 3 * |
4 * Gaim is the legal property of its developers, whose names are too numerous | 4 * Purple is the legal property of its developers, whose names are too numerous |
5 * to list here. Please refer to the COPYRIGHT file distributed with this | 5 * to list here. Please refer to the COPYRIGHT file distributed with this |
6 * source distribution. | 6 * source distribution. |
7 * | 7 * |
8 * This program is free software; you can redistribute it and/or modify | 8 * This program is free software; you can redistribute it and/or modify |
9 * it under the terms of the GNU General Public License as published by | 9 * it under the terms of the GNU General Public License as published by |
24 | 24 |
25 #include "blist.h" | 25 #include "blist.h" |
26 #include "prefs.h" | 26 #include "prefs.h" |
27 #include "sound.h" | 27 #include "sound.h" |
28 | 28 |
29 static GaimSoundUiOps *sound_ui_ops = NULL; | 29 static PurpleSoundUiOps *sound_ui_ops = NULL; |
30 | 30 |
31 #define STATUS_AVAILABLE 1 | 31 #define STATUS_AVAILABLE 1 |
32 #define STATUS_AWAY 2 | 32 #define STATUS_AWAY 2 |
33 | 33 |
34 static gboolean | 34 static gboolean |
35 gaim_sound_play_required(const GaimAccount *account) | 35 purple_sound_play_required(const PurpleAccount *account) |
36 { | 36 { |
37 gint pref_status = gaim_prefs_get_int("/core/sound/while_status"); | 37 gint pref_status = purple_prefs_get_int("/core/sound/while_status"); |
38 | 38 |
39 if (pref_status == 3) | 39 if (pref_status == 3) |
40 { | 40 { |
41 /* Play sounds: Always */ | 41 /* Play sounds: Always */ |
42 return TRUE; | 42 return TRUE; |
43 } | 43 } |
44 | 44 |
45 if (account != NULL) | 45 if (account != NULL) |
46 { | 46 { |
47 GaimStatus *status = gaim_account_get_active_status(account); | 47 PurpleStatus *status = purple_account_get_active_status(account); |
48 | 48 |
49 if (gaim_status_is_online(status)) | 49 if (purple_status_is_online(status)) |
50 { | 50 { |
51 gboolean available = gaim_status_is_available(status); | 51 gboolean available = purple_status_is_available(status); |
52 return (( available && pref_status == STATUS_AVAILABLE) || | 52 return (( available && pref_status == STATUS_AVAILABLE) || |
53 (!available && pref_status == STATUS_AWAY)); | 53 (!available && pref_status == STATUS_AWAY)); |
54 } | 54 } |
55 } | 55 } |
56 | 56 |
57 /* We get here a couple of ways. Either the request has been OK'ed | 57 /* We get here a couple of ways. Either the request has been OK'ed |
58 * by gaim_sound_play_event() and we're here because the UI has | 58 * by purple_sound_play_event() and we're here because the UI has |
59 * called gaim_sound_play_file(), or we're here for something | 59 * called purple_sound_play_file(), or we're here for something |
60 * not related to an account (like testing a sound). */ | 60 * not related to an account (like testing a sound). */ |
61 return TRUE; | 61 return TRUE; |
62 } | 62 } |
63 | 63 |
64 void | 64 void |
65 gaim_sound_play_file(const char *filename, const GaimAccount *account) | 65 purple_sound_play_file(const char *filename, const PurpleAccount *account) |
66 { | 66 { |
67 if (!gaim_sound_play_required(account)) | 67 if (!purple_sound_play_required(account)) |
68 return; | 68 return; |
69 | 69 |
70 if(sound_ui_ops && sound_ui_ops->play_file) | 70 if(sound_ui_ops && sound_ui_ops->play_file) |
71 sound_ui_ops->play_file(filename); | 71 sound_ui_ops->play_file(filename); |
72 } | 72 } |
73 | 73 |
74 void | 74 void |
75 gaim_sound_play_event(GaimSoundEventID event, const GaimAccount *account) | 75 purple_sound_play_event(PurpleSoundEventID event, const PurpleAccount *account) |
76 { | 76 { |
77 if (!gaim_sound_play_required(account)) | 77 if (!purple_sound_play_required(account)) |
78 return; | 78 return; |
79 | 79 |
80 if(sound_ui_ops && sound_ui_ops->play_event) { | 80 if(sound_ui_ops && sound_ui_ops->play_event) { |
81 int plugin_return; | 81 int plugin_return; |
82 | 82 |
83 plugin_return = GPOINTER_TO_INT(gaim_signal_emit_return_1( | 83 plugin_return = GPOINTER_TO_INT(purple_signal_emit_return_1( |
84 gaim_sounds_get_handle(), "playing-sound-event", | 84 purple_sounds_get_handle(), "playing-sound-event", |
85 event, account)); | 85 event, account)); |
86 | 86 |
87 if (plugin_return) | 87 if (plugin_return) |
88 return; | 88 return; |
89 else | 89 else |
90 sound_ui_ops->play_event(event); | 90 sound_ui_ops->play_event(event); |
91 } | 91 } |
92 } | 92 } |
93 | 93 |
94 void | 94 void |
95 gaim_sound_set_ui_ops(GaimSoundUiOps *ops) | 95 purple_sound_set_ui_ops(PurpleSoundUiOps *ops) |
96 { | 96 { |
97 if(sound_ui_ops && sound_ui_ops->uninit) | 97 if(sound_ui_ops && sound_ui_ops->uninit) |
98 sound_ui_ops->uninit(); | 98 sound_ui_ops->uninit(); |
99 | 99 |
100 sound_ui_ops = ops; | 100 sound_ui_ops = ops; |
101 | 101 |
102 if(sound_ui_ops && sound_ui_ops->init) | 102 if(sound_ui_ops && sound_ui_ops->init) |
103 sound_ui_ops->init(); | 103 sound_ui_ops->init(); |
104 } | 104 } |
105 | 105 |
106 GaimSoundUiOps * | 106 PurpleSoundUiOps * |
107 gaim_sound_get_ui_ops(void) | 107 purple_sound_get_ui_ops(void) |
108 { | 108 { |
109 return sound_ui_ops; | 109 return sound_ui_ops; |
110 } | 110 } |
111 | 111 |
112 void | 112 void |
113 gaim_sound_init() | 113 purple_sound_init() |
114 { | 114 { |
115 void *handle = gaim_sounds_get_handle(); | 115 void *handle = purple_sounds_get_handle(); |
116 | 116 |
117 /********************************************************************** | 117 /********************************************************************** |
118 * Register signals | 118 * Register signals |
119 **********************************************************************/ | 119 **********************************************************************/ |
120 | 120 |
121 gaim_signal_register(handle, "playing-sound-event", | 121 purple_signal_register(handle, "playing-sound-event", |
122 gaim_marshal_BOOLEAN__INT_POINTER, | 122 purple_marshal_BOOLEAN__INT_POINTER, |
123 gaim_value_new(GAIM_TYPE_BOOLEAN), 2, | 123 purple_value_new(PURPLE_TYPE_BOOLEAN), 2, |
124 gaim_value_new(GAIM_TYPE_INT), | 124 purple_value_new(PURPLE_TYPE_INT), |
125 gaim_value_new(GAIM_TYPE_SUBTYPE, | 125 purple_value_new(PURPLE_TYPE_SUBTYPE, |
126 GAIM_SUBTYPE_ACCOUNT)); | 126 PURPLE_SUBTYPE_ACCOUNT)); |
127 | 127 |
128 gaim_prefs_add_none("/core/sound"); | 128 purple_prefs_add_none("/core/sound"); |
129 gaim_prefs_add_int("/core/sound/while_status", STATUS_AVAILABLE); | 129 purple_prefs_add_int("/core/sound/while_status", STATUS_AVAILABLE); |
130 } | 130 } |
131 | 131 |
132 void | 132 void |
133 gaim_sound_uninit() | 133 purple_sound_uninit() |
134 { | 134 { |
135 if(sound_ui_ops && sound_ui_ops->uninit) | 135 if(sound_ui_ops && sound_ui_ops->uninit) |
136 sound_ui_ops->uninit(); | 136 sound_ui_ops->uninit(); |
137 | 137 |
138 gaim_signals_unregister_by_instance(gaim_sounds_get_handle()); | 138 purple_signals_unregister_by_instance(purple_sounds_get_handle()); |
139 } | 139 } |
140 | 140 |
141 void * | 141 void * |
142 gaim_sounds_get_handle() | 142 purple_sounds_get_handle() |
143 { | 143 { |
144 static int handle; | 144 static int handle; |
145 | 145 |
146 return &handle; | 146 return &handle; |
147 } | 147 } |