Mercurial > pidgin
comparison finch/gntsound.c @ 30404:8e9b04071e79
propagate from branch 'im.pidgin.pidgin' (head 9166d0ffe82472b17cee09aabbef61d8ec6e3e44)
to branch 'im.pidgin.soc.2010.icq-tlc' (head 4c9bb4231e46e234d01e6dc64bf4be49fb12c27c)
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 12 Aug 2010 15:30:11 +0000 |
parents | 9bd9ef37354f |
children | a8cc50c2279f |
comparison
equal
deleted
inserted
replaced
30403:a4d7d154d00d | 30404:8e9b04071e79 |
---|---|
102 {PURPLE_SOUND_CHAT_JOIN, N_("Person enters chat"), "join_chat", "login.wav", NULL}, | 102 {PURPLE_SOUND_CHAT_JOIN, N_("Person enters chat"), "join_chat", "login.wav", NULL}, |
103 {PURPLE_SOUND_CHAT_LEAVE, N_("Person leaves chat"), "left_chat", "logout.wav", NULL}, | 103 {PURPLE_SOUND_CHAT_LEAVE, N_("Person leaves chat"), "left_chat", "logout.wav", NULL}, |
104 {PURPLE_SOUND_CHAT_YOU_SAY, N_("You talk in chat"), "send_chat_msg", "send.wav", NULL}, | 104 {PURPLE_SOUND_CHAT_YOU_SAY, N_("You talk in chat"), "send_chat_msg", "send.wav", NULL}, |
105 {PURPLE_SOUND_CHAT_SAY, N_("Others talk in chat"), "chat_msg_recv", "receive.wav", NULL}, | 105 {PURPLE_SOUND_CHAT_SAY, N_("Others talk in chat"), "chat_msg_recv", "receive.wav", NULL}, |
106 {PURPLE_SOUND_POUNCE_DEFAULT, NULL, "pounce_default", "alert.wav", NULL}, | 106 {PURPLE_SOUND_POUNCE_DEFAULT, NULL, "pounce_default", "alert.wav", NULL}, |
107 {PURPLE_SOUND_CHAT_NICK, N_("Someone says your username in chat"), "nick_said", "alert.wav", NULL} | 107 {PURPLE_SOUND_CHAT_NICK, N_("Someone says your username in chat"), "nick_said", "alert.wav", NULL}, |
108 {PURPLE_SOUND_GOT_ATTENTION, N_("Attention received"), "got_attention", "alert.wav", NULL} | |
108 }; | 109 }; |
109 | 110 |
110 const char * | 111 const char * |
111 finch_sound_get_active_profile() | 112 finch_sound_get_active_profile() |
112 { | 113 { |
271 play_conv_event(conv, PURPLE_SOUND_CHAT_NICK); | 272 play_conv_event(conv, PURPLE_SOUND_CHAT_NICK); |
272 else | 273 else |
273 play_conv_event(conv, event); | 274 play_conv_event(conv, event); |
274 } | 275 } |
275 | 276 |
277 static void | |
278 got_attention_cb(PurpleAccount *account, const char *who, | |
279 PurpleConversation *conv, guint type, PurpleSoundEventID event) | |
280 { | |
281 play_conv_event(conv, event); | |
282 } | |
283 | |
284 | |
276 /* | 285 /* |
277 * We mute sounds for the 10 seconds after you log in so that | 286 * We mute sounds for the 10 seconds after you log in so that |
278 * you don't get flooded with sounds when the blist shows all | 287 * you don't get flooded with sounds when the blist shows all |
279 * your buddies logging in. | 288 * your buddies logging in. |
280 */ | 289 */ |
298 | 307 |
299 /* This gets called when the active profile changes */ | 308 /* This gets called when the active profile changes */ |
300 static void | 309 static void |
301 initialize_profile(const char *name, PurplePrefType type, gconstpointer val, gpointer null) | 310 initialize_profile(const char *name, PurplePrefType type, gconstpointer val, gpointer null) |
302 { | 311 { |
312 FinchSoundEvent *event; | |
303 if (purple_prefs_exists(make_pref(""))) | 313 if (purple_prefs_exists(make_pref(""))) |
304 return; | 314 return; |
305 | 315 |
306 purple_prefs_add_none(make_pref("")); | 316 purple_prefs_add_none(make_pref("")); |
307 purple_prefs_add_none(make_pref("/enabled")); | 317 purple_prefs_add_none(make_pref("/enabled")); |
308 purple_prefs_add_none(make_pref("/file")); | 318 purple_prefs_add_none(make_pref("/file")); |
309 purple_prefs_add_bool(make_pref("/enabled/login"), FALSE); | 319 |
310 purple_prefs_add_path(make_pref("/file/login"), ""); | 320 for (event = sounds; event - sounds < PURPLE_NUM_SOUNDS; event++) { |
311 purple_prefs_add_bool(make_pref("/enabled/logout"), FALSE); | 321 char pref[512]; |
312 purple_prefs_add_path(make_pref("/file/logout"), ""); | 322 g_snprintf(pref, sizeof(pref), "/enabled/%s", event->pref); |
313 purple_prefs_add_bool(make_pref("/enabled/im_recv"), FALSE); | 323 purple_prefs_add_bool(make_pref(pref), FALSE); |
314 purple_prefs_add_path(make_pref("/file/im_recv"), ""); | 324 g_snprintf(pref, sizeof(pref), "/file/%s", event->pref); |
315 purple_prefs_add_bool(make_pref("/enabled/first_im_recv"), FALSE); | 325 purple_prefs_add_path(make_pref(pref), ""); |
316 purple_prefs_add_path(make_pref("/file/first_im_recv"), ""); | 326 } |
317 purple_prefs_add_bool(make_pref("/enabled/send_im"), FALSE); | 327 |
318 purple_prefs_add_path(make_pref("/file/send_im"), ""); | |
319 purple_prefs_add_bool(make_pref("/enabled/join_chat"), FALSE); | |
320 purple_prefs_add_path(make_pref("/file/join_chat"), ""); | |
321 purple_prefs_add_bool(make_pref("/enabled/left_chat"), FALSE); | |
322 purple_prefs_add_path(make_pref("/file/left_chat"), ""); | |
323 purple_prefs_add_bool(make_pref("/enabled/send_chat_msg"), FALSE); | |
324 purple_prefs_add_path(make_pref("/file/send_chat_msg"), ""); | |
325 purple_prefs_add_bool(make_pref("/enabled/chat_msg_recv"), FALSE); | |
326 purple_prefs_add_path(make_pref("/file/chat_msg_recv"), ""); | |
327 purple_prefs_add_bool(make_pref("/enabled/nick_said"), FALSE); | |
328 purple_prefs_add_path(make_pref("/file/nick_said"), ""); | |
329 purple_prefs_add_bool(make_pref("/enabled/pounce_default"), FALSE); | |
330 purple_prefs_add_path(make_pref("/file/pounce_default"), ""); | |
331 purple_prefs_add_bool(make_pref("/conv_focus"), FALSE); | 328 purple_prefs_add_bool(make_pref("/conv_focus"), FALSE); |
332 purple_prefs_add_bool(make_pref("/mute"), FALSE); | 329 purple_prefs_add_bool(make_pref("/mute"), FALSE); |
333 purple_prefs_add_path(make_pref("/command"), ""); | 330 purple_prefs_add_path(make_pref("/command"), ""); |
334 purple_prefs_add_string(make_pref("/method"), "automatic"); | 331 purple_prefs_add_string(make_pref("/method"), "automatic"); |
335 purple_prefs_add_int(make_pref("/volume"), 50); | 332 purple_prefs_add_int(make_pref("/volume"), 50); |
333 } | |
334 | |
335 static void | |
336 update_profiles(void) | |
337 { | |
338 GList *list = finch_sound_get_profiles(); | |
339 for (; list; list = g_list_delete_link(list, list)) { | |
340 char pname[512]; | |
341 | |
342 /* got_attention was added in libpurple 2.7.0 */ | |
343 g_snprintf(pname, sizeof(pname), FINCH_PREFS_ROOT "/sound/profiles/%s%s", | |
344 (char *)list->data, "/enabled/got_attention"); | |
345 purple_prefs_add_bool(pname, FALSE); | |
346 g_snprintf(pname, sizeof(pname), FINCH_PREFS_ROOT "/sound/profiles/%s%s", | |
347 (char *)list->data, "/file/got_attention"); | |
348 purple_prefs_add_path(pname, ""); | |
349 | |
350 g_free(list->data); | |
351 } | |
336 } | 352 } |
337 | 353 |
338 static void | 354 static void |
339 finch_sound_init(void) | 355 finch_sound_init(void) |
340 { | 356 { |
354 purple_prefs_add_none(FINCH_PREFS_ROOT "/sound/profiles"); | 370 purple_prefs_add_none(FINCH_PREFS_ROOT "/sound/profiles"); |
355 | 371 |
356 purple_prefs_connect_callback(gnt_sound_handle, FINCH_PREFS_ROOT "/sound/actprofile", initialize_profile, NULL); | 372 purple_prefs_connect_callback(gnt_sound_handle, FINCH_PREFS_ROOT "/sound/actprofile", initialize_profile, NULL); |
357 purple_prefs_trigger_callback(FINCH_PREFS_ROOT "/sound/actprofile"); | 373 purple_prefs_trigger_callback(FINCH_PREFS_ROOT "/sound/actprofile"); |
358 | 374 |
359 | 375 |
360 #ifdef USE_GSTREAMER | 376 #ifdef USE_GSTREAMER |
361 purple_debug_info("sound", "Initializing sound output drivers.\n"); | 377 purple_debug_info("sound", "Initializing sound output drivers.\n"); |
362 #if (GST_VERSION_MAJOR > 0 || \ | 378 #if (GST_VERSION_MAJOR > 0 || \ |
363 (GST_VERSION_MAJOR == 0 && GST_VERSION_MINOR > 10) || \ | 379 (GST_VERSION_MAJOR == 0 && GST_VERSION_MINOR > 10) || \ |
364 (GST_VERSION_MAJOR == 0 && GST_VERSION_MINOR == 10 && GST_VERSION_MICRO >= 10)) | 380 (GST_VERSION_MAJOR == 0 && GST_VERSION_MINOR == 10 && GST_VERSION_MICRO >= 10)) |
397 gnt_sound_handle, PURPLE_CALLBACK(chat_msg_sent_cb), | 413 gnt_sound_handle, PURPLE_CALLBACK(chat_msg_sent_cb), |
398 GINT_TO_POINTER(PURPLE_SOUND_CHAT_YOU_SAY)); | 414 GINT_TO_POINTER(PURPLE_SOUND_CHAT_YOU_SAY)); |
399 purple_signal_connect(conv_handle, "received-chat-msg", | 415 purple_signal_connect(conv_handle, "received-chat-msg", |
400 gnt_sound_handle, PURPLE_CALLBACK(chat_msg_received_cb), | 416 gnt_sound_handle, PURPLE_CALLBACK(chat_msg_received_cb), |
401 GINT_TO_POINTER(PURPLE_SOUND_CHAT_SAY)); | 417 GINT_TO_POINTER(PURPLE_SOUND_CHAT_SAY)); |
418 purple_signal_connect(conv_handle, "got-attention", | |
419 gnt_sound_handle, PURPLE_CALLBACK(got_attention_cb), | |
420 GINT_TO_POINTER(PURPLE_SOUND_GOT_ATTENTION)); | |
421 | |
422 update_profiles(); | |
402 } | 423 } |
403 | 424 |
404 static void | 425 static void |
405 finch_sound_uninit(void) | 426 finch_sound_uninit(void) |
406 { | 427 { |
575 char *enable_pref; | 596 char *enable_pref; |
576 char *file_pref; | 597 char *file_pref; |
577 if ((event == PURPLE_SOUND_BUDDY_ARRIVE) && mute_login_sounds) | 598 if ((event == PURPLE_SOUND_BUDDY_ARRIVE) && mute_login_sounds) |
578 return; | 599 return; |
579 | 600 |
580 if (event >= PURPLE_NUM_SOUNDS) { | 601 if (event >= PURPLE_NUM_SOUNDS || |
602 event >= G_N_ELEMENTS(sounds)) { | |
581 purple_debug_error("sound", "got request for unknown sound: %d\n", event); | 603 purple_debug_error("sound", "got request for unknown sound: %d\n", event); |
582 return; | 604 return; |
583 } | 605 } |
584 | 606 |
585 enable_pref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/enabled/%s", | 607 enable_pref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/enabled/%s", |