Exemple #1
0
static void
finch_sound_play_event(PurpleSoundEventID event)
{
	char *enable_pref;
	char *file_pref;
	if ((event == PURPLE_SOUND_BUDDY_ARRIVE) && mute_login_sounds)
		return;

	if (event >= PURPLE_NUM_SOUNDS ||
			event >= G_N_ELEMENTS(sounds)) {
		purple_debug_error("sound", "got request for unknown sound: %d\n", event);
		return;
	}

	enable_pref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/enabled/%s",
			finch_sound_get_active_profile(),
			sounds[event].pref);
	file_pref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/file/%s", finch_sound_get_active_profile(), sounds[event].pref);

	/* check NULL for sounds that don't have an option, ie buddy pounce */
	if (purple_prefs_get_bool(enable_pref)) {
		char *filename = g_strdup(purple_prefs_get_path(file_pref));
		if (!filename || !strlen(filename)) {
			g_free(filename);
			/* XXX Consider creating a constant for "sounds/purple" to be shared with Pidgin */
			filename = g_build_filename(DATADIR, "sounds", "purple", sounds[event].def, NULL);
		}

		purple_sound_play_file(filename, NULL);
		g_free(filename);
	}

	g_free(enable_pref);
	g_free(file_pref);
}
Exemple #2
0
static void
pidgin_sound_play_event(PurpleSoundEventID event)
{
	char *enable_pref;
	char *file_pref;
	const char *theme_name;
	PurpleSoundTheme *theme;

	if ((event == PURPLE_SOUND_BUDDY_ARRIVE) && mute_login_sounds)
		return;

	if (event >= PURPLE_NUM_SOUNDS) {
		purple_debug_error("sound", "got request for unknown sound: %d\n", event);
		return;
	}

	enable_pref = g_strdup_printf(PIDGIN_PREFS_ROOT "/sound/enabled/%s",
			sounds[event].pref);
	file_pref = g_strdup_printf(PIDGIN_PREFS_ROOT "/sound/file/%s", sounds[event].pref);

	/* check NULL for sounds that don't have an option, ie buddy pounce */
	if (purple_prefs_get_bool(enable_pref)) {
		char *filename = g_strdup(purple_prefs_get_path(file_pref));
		theme_name = purple_prefs_get_string(PIDGIN_PREFS_ROOT "/sound/theme");

		if (theme_name && *theme_name && (!filename || !*filename)) {
			/* Use theme */
			g_free(filename);

			theme = PURPLE_SOUND_THEME(purple_theme_manager_find_theme(theme_name, "sound"));
			filename = purple_sound_theme_get_file_full(theme, sounds[event].pref);

			if(!g_file_test(filename, G_FILE_TEST_IS_REGULAR)){ /* Use Default sound in this case */
				purple_debug_error("sound", "The file: (%s) %s\n from theme: %s, was not found or wasn't readable\n",
							sounds[event].pref, filename, theme_name);
				g_free(filename);
				filename = NULL;
			}
		}

		if (!filename || !strlen(filename)) {			    /* Use Default sounds */
			g_free(filename);

			/* XXX Consider creating a constant for "sounds/purple" to be shared with Finch */
			filename = g_build_filename(DATADIR, "sounds", "purple", sounds[event].def, NULL);
		}

		purple_sound_play_file(filename, NULL);

		g_free(filename);
	}

	g_free(enable_pref);
	g_free(file_pref);
}