Fix an incorrect call to soup_message_set_request.
[pidgin-git.git] / libpurple / sound-theme.c
blob9d44f9c6d0474c11601453cb9f9b8a0bb398fded
1 /*
2 * Sound Themes for libpurple
4 * Pidgin 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
6 * source distribution.
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
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
23 #include "internal.h"
24 #include "sound-theme.h"
26 /******************************************************************************
27 * Structs
28 *****************************************************************************/
30 /**
31 * PurpleSoundTheme:
33 * A purple sound theme.
34 * This is an object for Purple to represent a sound theme.
36 struct _PurpleSoundTheme
38 /*< private >*/
39 PurpleTheme parent;
42 typedef struct {
43 /* used to store filenames of diffrent sounds */
44 GHashTable *sound_files;
45 } PurpleSoundThemePrivate;
47 /******************************************************************************
48 * Globals
49 *****************************************************************************/
51 G_DEFINE_TYPE_WITH_PRIVATE(PurpleSoundTheme, purple_sound_theme,
52 PURPLE_TYPE_THEME);
54 /******************************************************************************
55 * Enums
56 *****************************************************************************/
58 /******************************************************************************
59 * GObject Stuff
60 *****************************************************************************/
62 static void
63 purple_sound_theme_init(PurpleSoundTheme *theme)
65 PurpleSoundThemePrivate *priv;
67 priv = purple_sound_theme_get_instance_private(theme);
69 priv->sound_files = g_hash_table_new_full(g_str_hash,
70 g_str_equal, g_free, g_free);
73 static void
74 purple_sound_theme_finalize(GObject *obj)
76 PurpleSoundThemePrivate *priv;
78 priv = purple_sound_theme_get_instance_private(PURPLE_SOUND_THEME(obj));
80 g_hash_table_destroy(priv->sound_files);
82 G_OBJECT_CLASS(purple_sound_theme_parent_class)->finalize(obj);
85 static void
86 purple_sound_theme_class_init(PurpleSoundThemeClass *klass)
88 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
90 obj_class->finalize = purple_sound_theme_finalize;
93 /*****************************************************************************
94 * Public API functions
95 *****************************************************************************/
97 const gchar *
98 purple_sound_theme_get_file(PurpleSoundTheme *theme,
99 const gchar *event)
101 PurpleSoundThemePrivate *priv;
103 g_return_val_if_fail(PURPLE_IS_SOUND_THEME(theme), NULL);
105 priv = purple_sound_theme_get_instance_private(theme);
107 return g_hash_table_lookup(priv->sound_files, event);
110 gchar *
111 purple_sound_theme_get_file_full(PurpleSoundTheme *theme,
112 const gchar *event)
114 const gchar *filename;
116 g_return_val_if_fail(PURPLE_IS_SOUND_THEME(theme), NULL);
118 filename = purple_sound_theme_get_file(theme, event);
120 g_return_val_if_fail(filename, NULL);
122 return g_build_filename(purple_theme_get_dir(PURPLE_THEME(theme)), filename, NULL);
125 void
126 purple_sound_theme_set_file(PurpleSoundTheme *theme,
127 const gchar *event,
128 const gchar *filename)
130 PurpleSoundThemePrivate *priv;
131 g_return_if_fail(PURPLE_IS_SOUND_THEME(theme));
133 priv = purple_sound_theme_get_instance_private(theme);
135 if (filename != NULL)
136 g_hash_table_replace(priv->sound_files,
137 g_strdup(event), g_strdup(filename));
138 else
139 g_hash_table_remove(priv->sound_files, event);