Mercurial > pidgin
comparison libpurple/sound-theme-loader.c @ 27590:a08e84032814
merge of '2348ff22f0ff3453774b8b25b36238465580c609'
and 'e76f11543c2a4aa05bdf584f087cbe3439029661'
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Sun, 12 Jul 2009 05:43:38 +0000 |
parents | 9ad4b5200f24 |
children | f7be1e356a23 |
comparison
equal
deleted
inserted
replaced
27104:048bcf41deef | 27590:a08e84032814 |
---|---|
23 #include "internal.h" | 23 #include "internal.h" |
24 #include "sound-theme-loader.h" | 24 #include "sound-theme-loader.h" |
25 #include "sound-theme.h" | 25 #include "sound-theme.h" |
26 #include "util.h" | 26 #include "util.h" |
27 #include "xmlnode.h" | 27 #include "xmlnode.h" |
28 #include "debug.h" | |
28 | 29 |
29 /***************************************************************************** | 30 /***************************************************************************** |
30 * Sound Theme Builder | 31 * Sound Theme Builder |
31 *****************************************************************************/ | 32 *****************************************************************************/ |
32 | 33 |
33 static PurpleTheme * | 34 static PurpleTheme * |
34 purple_sound_loader_build(const gchar *dir) | 35 purple_sound_loader_build(const gchar *dir) |
35 { | 36 { |
36 xmlnode *root_node = NULL, *sub_node; | 37 xmlnode *root_node = NULL, *sub_node; |
37 gchar *filename_full, *data; | 38 gchar *filename_full, *data = NULL; |
38 PurpleSoundTheme *theme = NULL; | 39 PurpleSoundTheme *theme = NULL; |
40 const gchar *name; | |
39 | 41 |
40 /* Find the theme file */ | 42 /* Find the theme file */ |
41 g_return_val_if_fail(dir != NULL, NULL); | 43 g_return_val_if_fail(dir != NULL, NULL); |
42 filename_full = g_build_filename(dir, "theme.xml", NULL); | 44 filename_full = g_build_filename(dir, "theme.xml", NULL); |
43 | 45 |
44 if (g_file_test(filename_full, G_FILE_TEST_IS_REGULAR)) | 46 if (g_file_test(filename_full, G_FILE_TEST_IS_REGULAR)) |
45 root_node = xmlnode_from_file(dir, "theme.xml", "sound themes", "sound-theme-loader"); | 47 root_node = xmlnode_from_file(dir, "theme.xml", "sound themes", "sound-theme-loader"); |
46 | 48 |
47 g_free(filename_full); | 49 g_free(filename_full); |
48 g_return_val_if_fail(root_node != NULL, NULL); | 50 if (root_node == NULL) |
51 return NULL; | |
49 | 52 |
50 /* Parse the tree */ | 53 name = xmlnode_get_attrib(root_node, "name"); |
51 sub_node = xmlnode_get_child(root_node, "description"); | |
52 data = xmlnode_get_data(sub_node); | |
53 | 54 |
54 if (xmlnode_get_attrib(root_node, "name") != NULL) { | 55 if (name && purple_strequal(xmlnode_get_attrib(root_node, "type"), "sound")) { |
55 theme = g_object_new(PURPLE_TYPE_SOUND_THEME, | 56 /* Parse the tree */ |
56 "type", "sound", | 57 sub_node = xmlnode_get_child(root_node, "description"); |
57 "name", xmlnode_get_attrib(root_node, "name"), | 58 data = xmlnode_get_data(sub_node); |
58 "author", xmlnode_get_attrib(root_node, "author"), | |
59 "image", xmlnode_get_attrib(root_node, "image"), | |
60 "directory", dir, | |
61 "description", data, NULL); | |
62 | 59 |
63 sub_node = xmlnode_get_child(root_node, "event"); | 60 if (xmlnode_get_attrib(root_node, "name") != NULL) { |
61 theme = g_object_new(PURPLE_TYPE_SOUND_THEME, | |
62 "type", "sound", | |
63 "name", name, | |
64 "author", xmlnode_get_attrib(root_node, "author"), | |
65 "image", xmlnode_get_attrib(root_node, "image"), | |
66 "directory", dir, | |
67 "description", data, NULL); | |
64 | 68 |
65 while (sub_node) { | 69 sub_node = xmlnode_get_child(root_node, "event"); |
66 purple_sound_theme_set_file(theme, | 70 |
67 xmlnode_get_attrib(sub_node, "name"), | 71 while (sub_node) { |
68 xmlnode_get_attrib(sub_node, "file")); | 72 purple_sound_theme_set_file(theme, |
69 sub_node = xmlnode_get_next_twin(sub_node); | 73 xmlnode_get_attrib(sub_node, "name"), |
74 xmlnode_get_attrib(sub_node, "file")); | |
75 sub_node = xmlnode_get_next_twin(sub_node); | |
76 } | |
70 } | 77 } |
71 } | 78 } else purple_debug_warning("sound-theme-loader", "Missing attribute or problem with the root element\n"); |
72 | 79 |
73 xmlnode_free(root_node); | 80 xmlnode_free(root_node); |
74 g_free(data); | 81 g_free(data); |
75 return PURPLE_THEME(theme); | 82 return PURPLE_THEME(theme); |
76 } | 83 } |