comparison libpurple/smiley.c @ 29693:7925bb7f2aa7

propagate from branch 'im.pidgin.pidgin' (head 92e101e3698042e7600729bc09dec9e28f81de8f) to branch 'im.pidgin.cpw.attention_ui' (head 563c35d20efcc234a74567ebb88c059d10ce1e09)
author Marcus Lundblad <ml@update.uu.se>
date Mon, 24 Aug 2009 19:23:56 +0000
parents 54efb427b91a
children
comparison
equal deleted inserted replaced
29692:fb99a0067812 29693:7925bb7f2aa7
78 78
79 /****************************************************************************** 79 /******************************************************************************
80 * XML descriptor file layout * 80 * XML descriptor file layout *
81 ****************************************************************************** 81 ******************************************************************************
82 * 82 *
83 * Althought we are creating the profile XML structure here, now we 83 * Although we are creating the profile XML structure here, now we
84 * won't handle it. 84 * won't handle it.
85 * So, we just add one profile named "default" that has no associated 85 * So, we just add one profile named "default" that has no associated
86 * account elements, and have only the smiley_set that will contain 86 * account elements, and have only the smiley_set that will contain
87 * all existent custom smiley. 87 * all existent custom smiley.
88 * 88 *
161 child_node = smiley_to_xmlnode(value); 161 child_node = smiley_to_xmlnode(value);
162 xmlnode_insert_child((xmlnode*)user_data, child_node); 162 xmlnode_insert_child((xmlnode*)user_data, child_node);
163 } 163 }
164 164
165 static xmlnode * 165 static xmlnode *
166 smileys_to_xmlnode() 166 smileys_to_xmlnode(void)
167 { 167 {
168 xmlnode *root_node, *profile_node, *smileyset_node; 168 xmlnode *root_node, *profile_node, *smileyset_node;
169 169
170 root_node = xmlnode_new(XML_ROOT_TAG); 170 root_node = xmlnode_new(XML_ROOT_TAG);
171 xmlnode_set_attrib(root_node, "version", "1.0"); 171 xmlnode_set_attrib(root_node, "version", "1.0");
172 172
173 /* See the top comment's above to understand why initial tag elements 173 /* See the top comments above to understand why initial tag elements
174 * are not being considered by now. */ 174 * are not being considered by now. */
175 profile_node = xmlnode_new(XML_PROFILE_TAG); 175 profile_node = xmlnode_new(XML_PROFILE_TAG);
176 if (profile_node) { 176 if (profile_node) {
177 xmlnode_set_attrib(profile_node, XML_PROFILE_NAME_ATTRIB_TAG, "Default"); 177 xmlnode_set_attrib(profile_node, XML_PROFILE_NAME_ATTRIB_TAG, "Default");
178 xmlnode_insert_child(root_node, profile_node); 178 xmlnode_insert_child(root_node, profile_node);
186 186
187 return root_node; 187 return root_node;
188 } 188 }
189 189
190 static void 190 static void
191 sync_smileys() 191 sync_smileys(void)
192 { 192 {
193 xmlnode *root_node; 193 xmlnode *root_node;
194 char *data; 194 char *data;
195 195
196 if (!smileys_loaded) { 196 if (!smileys_loaded) {
214 save_timer = 0; 214 save_timer = 0;
215 return FALSE; 215 return FALSE;
216 } 216 }
217 217
218 static void 218 static void
219 purple_smileys_save() 219 purple_smileys_save(void)
220 { 220 {
221 if (save_timer == 0) 221 if (save_timer == 0)
222 save_timer = purple_timeout_add_seconds(5, save_smileys_cb, NULL); 222 save_timer = purple_timeout_add_seconds(5, save_smileys_cb, NULL);
223 } 223 }
224 224
246 246
247 return smiley; 247 return smiley;
248 } 248 }
249 249
250 static void 250 static void
251 purple_smileys_load() 251 purple_smileys_load(void)
252 { 252 {
253 xmlnode *root_node, *profile_node; 253 xmlnode *root_node, *profile_node;
254 xmlnode *smileyset_node = NULL; 254 xmlnode *smileyset_node = NULL;
255 xmlnode *smiley_node; 255 xmlnode *smiley_node;
256 256
260 _(SMILEYS_LOG_ID)); 260 _(SMILEYS_LOG_ID));
261 261
262 if (root_node == NULL) 262 if (root_node == NULL)
263 return; 263 return;
264 264
265 /* See the top comment's above to understand why initial tag elements 265 /* See the top comments above to understand why initial tag elements
266 * are not being considered by now. */ 266 * are not being considered by now. */
267 profile_node = xmlnode_get_child(root_node, XML_PROFILE_TAG); 267 profile_node = xmlnode_get_child(root_node, XML_PROFILE_TAG);
268 if (profile_node) 268 if (profile_node)
269 smileyset_node = xmlnode_get_child(profile_node, XML_SMILEY_SET_TAG); 269 smileyset_node = xmlnode_get_child(profile_node, XML_SMILEY_SET_TAG);
270 270
454 454
455 return type; 455 return type;
456 } 456 }
457 457
458 /********************************************************************* 458 /*********************************************************************
459 * Other Stuff * 459 * Other Stuff *
460 *********************************************************************/ 460 *********************************************************************/
461 461
462 static char *get_file_full_path(const char *filename) 462 static char *get_file_full_path(const char *filename)
463 { 463 {
464 char *path; 464 char *path;
874 { 874 {
875 return smileys_dir; 875 return smileys_dir;
876 } 876 }
877 877
878 void 878 void
879 purple_smileys_init() 879 purple_smileys_init(void)
880 { 880 {
881 smiley_shortcut_index = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); 881 smiley_shortcut_index = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
882 smiley_checksum_index = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); 882 smiley_checksum_index = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
883 883
884 smileys_dir = g_build_filename(purple_user_dir(), SMILEYS_DEFAULT_FOLDER, NULL); 884 smileys_dir = g_build_filename(purple_user_dir(), SMILEYS_DEFAULT_FOLDER, NULL);
885 885
886 purple_smileys_load(); 886 purple_smileys_load();
887 } 887 }
888 888
889 void 889 void
890 purple_smileys_uninit() 890 purple_smileys_uninit(void)
891 { 891 {
892 if (save_timer != 0) { 892 if (save_timer != 0) {
893 purple_timeout_remove(save_timer); 893 purple_timeout_remove(save_timer);
894 save_timer = 0; 894 save_timer = 0;
895 sync_smileys(); 895 sync_smileys();