Mercurial > pidgin
comparison src/sound.c @ 5545:7a64114641c3
[gaim-migrate @ 5946]
I've been rewriting the prefs to move from gaimrc to prefs.xml. This will
NOT compile! I don't want to see complaints about this, as it's CVS, and
you should only be using it if you can put up with things like this. Also,
don't ask how long it'll take until it compiles again. It may be several
days. This is a big migration. Even when it works, it may not run right.
However, it's made a lot of progress, and I plan to actively work on it
today and tomorrow.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Thu, 29 May 2003 19:10:24 +0000 |
parents | ad445074d239 |
children | 9cd94a5bec8e |
comparison
equal
deleted
inserted
replaced
5544:0028381fa874 | 5545:7a64114641c3 |
---|---|
48 #endif /* USE_NAS_AUDIO */ | 48 #endif /* USE_NAS_AUDIO */ |
49 | 49 |
50 #include "gaim.h" | 50 #include "gaim.h" |
51 #include "sound.h" | 51 #include "sound.h" |
52 #include "notify.h" | 52 #include "notify.h" |
53 #include "prefs.h" | |
53 | 54 |
54 #ifdef _WIN32 | 55 #ifdef _WIN32 |
55 #include "win32dep.h" | 56 #include "win32dep.h" |
56 #endif | 57 #endif |
57 | 58 |
58 struct gaim_sound_event { | 59 struct gaim_sound_event { |
59 char *label; | 60 char *label; |
60 guint opt; | 61 char *pref; |
61 char *def; | 62 char *def; |
62 }; | 63 }; |
63 | 64 |
64 #ifdef USE_AO | 65 #ifdef USE_AO |
65 static gboolean ao_initialized=FALSE; | 66 static gboolean ao_initialized=FALSE; |
74 /* description, option bit, default sound file * | 75 /* description, option bit, default sound file * |
75 * set the option bit to 0 to have it not display in prefs * | 76 * set the option bit to 0 to have it not display in prefs * |
76 * the order here has to match the defines in gaim.h. * | 77 * the order here has to match the defines in gaim.h. * |
77 * -Robot101 */ | 78 * -Robot101 */ |
78 static struct gaim_sound_event sounds[GAIM_NUM_SOUNDS] = { | 79 static struct gaim_sound_event sounds[GAIM_NUM_SOUNDS] = { |
79 {N_("Buddy logs in"), OPT_SOUND_LOGIN, "arrive.wav"}, | 80 {N_("Buddy logs in"), "/gaim/gtk/sound/login", "arrive.wav"}, |
80 {N_("Buddy logs out"), OPT_SOUND_LOGOUT, "leave.wav"}, | 81 {N_("Buddy logs out"), "/gaim/gtk/sound/logout", "leave.wav"}, |
81 {N_("Message received"), OPT_SOUND_RECV, "receive.wav"}, | 82 {N_("Message received"), "/gaim/gtk/sound/message_recv", "receive.wav"}, |
82 {N_("Message received begins conversation"), OPT_SOUND_FIRST_RCV, "receive.wav"}, | 83 {N_("Message received begins conversation"), "/gaim/gtk/sound/first_message_recv", "receive.wav"}, |
83 {N_("Message sent"), OPT_SOUND_SEND, "send.wav"}, | 84 {N_("Message sent"), "/gaim/gtk/sound/send_im", "send.wav"}, |
84 {N_("Person enters chat"), OPT_SOUND_CHAT_JOIN, "arrive.wav"}, | 85 {N_("Person enters chat"), "/gaim/gtk/sound/join_chat", "arrive.wav"}, |
85 {N_("Person leaves chat"), OPT_SOUND_CHAT_PART, "leave.wav"}, | 86 {N_("Person leaves chat"), "/gaim/gtk/sound/left_chat", "leave.wav"}, |
86 {N_("You talk in chat"), OPT_SOUND_CHAT_YOU_SAY, "send.wav"}, | 87 {N_("You talk in chat"), "/gaim/gtk/sound/send_chat_msg", "send.wav"}, |
87 {N_("Others talk in chat"), OPT_SOUND_CHAT_SAY, "receive.wav"}, | 88 {N_("Others talk in chat"), "/gaim/gtk/sound/chat_msg_recv", "receive.wav"}, |
88 /* this isn't a terminator, it's the buddy pounce default sound event ;-) */ | 89 /* this isn't a terminator, it's the buddy pounce default sound event ;-) */ |
89 {NULL, 0, "redalert.wav"}, | 90 {NULL, 0, "redalert.wav"}, |
90 {N_("Someone says your name in chat"), OPT_SOUND_CHAT_NICK, "redalert.wav"} | 91 {N_("Someone says your name in chat"), "/gaim/gtk/sound/nick_said", "redalert.wav"} |
91 }; | 92 }; |
92 | 93 |
93 static char *sound_file[GAIM_NUM_SOUNDS]; | 94 static char *sound_file[GAIM_NUM_SOUNDS]; |
94 | 95 |
95 | 96 |
107 | 108 |
108 void gaim_sound_change_output_method() { | 109 void gaim_sound_change_output_method() { |
109 #ifdef USE_AO | 110 #ifdef USE_AO |
110 ao_driver = -1; | 111 ao_driver = -1; |
111 | 112 |
112 if ((sound_options & OPT_SOUND_ESD) || (sound_options & OPT_SOUND_ARTS) || | 113 if (gaim_prefs_get_bool("/core/sound/use_esd") || |
113 (sound_options & OPT_SOUND_NORMAL)) { | 114 gaim_prefs_get_bool("/core/sound/use_arts") || |
115 gaim_prefs_get_bool("/core/sound/use_sys_default")) { | |
116 | |
114 check_ao_init(); | 117 check_ao_init(); |
115 if (ao_driver == -1 && (sound_options & OPT_SOUND_ESD)) { | 118 |
119 if (ao_driver == -1 && gaim_prefs_get_bool("/core/sound/use_esd")) | |
116 ao_driver = ao_driver_id("esd"); | 120 ao_driver = ao_driver_id("esd"); |
117 } | 121 |
118 if(ao_driver == -1 && (sound_options & OPT_SOUND_ARTS)) { | 122 if (ao_driver == -1 && gaim_prefs_get_bool("/core/sound/use_arts")) |
119 ao_driver = ao_driver_id("arts"); | 123 ao_driver = ao_driver_id("arts"); |
120 } | 124 |
121 if (ao_driver == -1) { | 125 if (ao_driver == -1) |
122 ao_driver = ao_default_driver_id(); | 126 ao_driver = ao_default_driver_id(); |
123 } | 127 } |
124 } | 128 |
125 if(ao_driver != -1) { | 129 if(ao_driver != -1) { |
126 ao_info *info = ao_driver_info(ao_driver); | 130 ao_info *info = ao_driver_info(ao_driver); |
127 gaim_debug(GAIM_DEBUG_INFO, "sound", | 131 gaim_debug(GAIM_DEBUG_INFO, "sound", |
128 "Sound output driver loaded: %s\n", info->name); | 132 "Sound output driver loaded: %s\n", info->name); |
129 } | 133 } |
130 #endif /* USE_AO */ | 134 #endif /* USE_AO */ |
131 #ifdef USE_NAS | 135 #ifdef USE_NAS |
132 if((sound_options & OPT_SOUND_NAS)) | 136 if (gaim_prefs_get_bool("/core/sound/use_nas")) |
133 gaim_debug(GAIM_DEBUG_INFO, "sound", | 137 gaim_debug(GAIM_DEBUG_INFO, "sound", |
134 "Sound output driver loaded: NAS output\n"); | 138 "Sound output driver loaded: NAS output\n"); |
135 #endif /* USE_NAS */ | 139 #endif /* USE_NAS */ |
136 } | 140 } |
137 | 141 |
170 #endif | 174 #endif |
171 | 175 |
172 if (mute_sounds) | 176 if (mute_sounds) |
173 return; | 177 return; |
174 | 178 |
175 if (awaymessage && !(sound_options & OPT_SOUND_WHEN_AWAY)) | 179 if (awaymessage && !gaim_prefs_get_bool("/core/sound/while_away")) |
176 return; /* check here in case a buddy pounce plays a file while away */ | 180 return; /* check here in case a buddy pounce plays a file while away */ |
177 | 181 |
178 if (sound_options & OPT_SOUND_BEEP) { | 182 if (gaim_prefs_get_bool("/core/sound/use_beep")) { |
179 gdk_beep(); | 183 gdk_beep(); |
180 return; | 184 return; |
181 } | 185 } |
182 | 186 |
183 if (!g_file_test(filename, G_FILE_TEST_EXISTS)) { | 187 if (!g_file_test(filename, G_FILE_TEST_EXISTS)) { |
186 g_free(tmp); | 190 g_free(tmp); |
187 return; | 191 return; |
188 } | 192 } |
189 | 193 |
190 #ifndef _WIN32 | 194 #ifndef _WIN32 |
191 if ((sound_options & OPT_SOUND_CMD)) { | 195 if (gaim_prefs_get_bool("/core/sound/use_custom")) { |
196 const char *sound_cmd; | |
192 char *command; | 197 char *command; |
193 GError *error = NULL; | 198 GError *error = NULL; |
194 | 199 |
195 if(!sound_cmd) { | 200 sound_cmd = gaim_prefs_get_string("/core/sound/command"); |
201 | |
202 if (!sound_cmd || *sound_cmd == '\0') { | |
196 gaim_notify_error(NULL, NULL, | 203 gaim_notify_error(NULL, NULL, |
197 _("Unable to play sound because the " | 204 _("Unable to play sound because the " |
198 "'Command' sound method has been chosen, " | 205 "'Command' sound method has been chosen, " |
199 "but no command has been set."), NULL); | 206 "but no command has been set."), NULL); |
200 return; | 207 return; |
216 pid = fork(); | 223 pid = fork(); |
217 if (pid < 0) | 224 if (pid < 0) |
218 return; | 225 return; |
219 else if (pid == 0) { | 226 else if (pid == 0) { |
220 #ifdef USE_NAS_AUDIO | 227 #ifdef USE_NAS_AUDIO |
221 if ((sound_options & OPT_SOUND_NAS)) { | 228 if (gaim_prefs_get_bool("/core/sound/use_nas")) { |
222 if (play_file_nas(filename)) | 229 if (play_file_nas(filename)) |
223 _exit(0); | 230 _exit(0); |
224 } | 231 } |
225 #endif /* USE_NAS_AUDIO */ | 232 #endif /* USE_NAS_AUDIO */ |
226 | 233 |
299 "got request for unknown sound: %d\n", event); | 306 "got request for unknown sound: %d\n", event); |
300 return; | 307 return; |
301 } | 308 } |
302 | 309 |
303 /* check NULL for sounds that don't have an option, ie buddy pounce */ | 310 /* check NULL for sounds that don't have an option, ie buddy pounce */ |
304 if ((sound_options & sounds[event].opt) || (sounds[event].opt == 0)) { | 311 if (sounds[event].pref == NULL || gaim_prefs_get_bool(sounds[event].pref)) { |
305 if (sound_file[event]) { | 312 if (sound_file[event]) { |
306 gaim_sound_play_file(sound_file[event]); | 313 gaim_sound_play_file(sound_file[event]); |
307 } else { | 314 } else { |
308 gchar *filename = NULL; | 315 gchar *filename = NULL; |
309 | 316 |
347 return NULL; | 354 return NULL; |
348 | 355 |
349 return sound_file[event]; | 356 return sound_file[event]; |
350 } | 357 } |
351 | 358 |
352 guint gaim_sound_get_event_option(GaimSoundEventID event) | 359 const char *gaim_sound_get_event_option(GaimSoundEventID event) |
353 { | 360 { |
354 if(event >= GAIM_NUM_SOUNDS) | 361 if(event >= GAIM_NUM_SOUNDS) |
355 return 0; | 362 return 0; |
356 | 363 |
357 return sounds[event].opt; | 364 return sounds[event].pref; |
358 } | 365 } |
359 | 366 |
360 char *gaim_sound_get_event_label(GaimSoundEventID event) | 367 char *gaim_sound_get_event_label(GaimSoundEventID event) |
361 { | 368 { |
362 if(event >= GAIM_NUM_SOUNDS) | 369 if(event >= GAIM_NUM_SOUNDS) |