Mercurial > pidgin.yaz
comparison src/savedstatuses.c @ 10423:3232e1a33899
[gaim-migrate @ 11675]
Set version numbers for all our xml files
Use xmlnode for writing accounts.xml
Add 2 conveniencey helper functions to xmlnode
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 26 Dec 2004 18:38:22 +0000 |
parents | 854c972ea863 |
children | 108151be77a3 |
comparison
equal
deleted
inserted
replaced
10422:e0cf2f3f9929 | 10423:3232e1a33899 |
---|---|
62 GaimAccount *account; | 62 GaimAccount *account; |
63 const GaimStatusType *type; | 63 const GaimStatusType *type; |
64 char *message; | 64 char *message; |
65 }; | 65 }; |
66 | 66 |
67 static GList *saved_statuses = NULL; | 67 static GList *saved_statuses = NULL; |
68 gboolean have_read_saved_statuses = FALSE; | 68 static guint statuses_save_timer = 0; |
69 static guint statuses_save_timer = 0; | 69 static gboolean statuses_loaded = FALSE; |
70 | 70 |
71 /************************************************************************** | 71 /************************************************************************** |
72 * Helper functions | 72 * Helper functions |
73 **************************************************************************/ | 73 **************************************************************************/ |
74 | 74 |
163 { | 163 { |
164 xmlnode *node, *child; | 164 xmlnode *node, *child; |
165 GList *cur; | 165 GList *cur; |
166 | 166 |
167 node = xmlnode_new("statuses"); | 167 node = xmlnode_new("statuses"); |
168 xmlnode_set_attrib(node, "version", "1"); | 168 xmlnode_set_attrib(node, "version", "1.0"); |
169 | 169 |
170 for (cur = saved_statuses; cur != NULL; cur = cur->next) | 170 for (cur = saved_statuses; cur != NULL; cur = cur->next) |
171 { | 171 { |
172 child = status_to_xmlnode(cur->data); | 172 child = status_to_xmlnode(cur->data); |
173 xmlnode_insert_child(node, child); | 173 xmlnode_insert_child(node, child); |
177 } | 177 } |
178 | 178 |
179 static void | 179 static void |
180 sync_statuses(void) | 180 sync_statuses(void) |
181 { | 181 { |
182 xmlnode *statuses; | 182 xmlnode *node; |
183 char *data; | 183 char *data; |
184 | 184 |
185 if (!have_read_saved_statuses) { | 185 if (!statuses_loaded) { |
186 gaim_debug_error("status", "Attempted to save statuses before they " | 186 gaim_debug_error("status", "Attempted to save statuses before they " |
187 "were read!\n"); | 187 "were read!\n"); |
188 return; | 188 return; |
189 } | 189 } |
190 | 190 |
191 statuses = statuses_to_xmlnode(); | 191 node = statuses_to_xmlnode(); |
192 data = xmlnode_to_formatted_str(statuses, NULL); | 192 data = xmlnode_to_formatted_str(node, NULL); |
193 gaim_util_write_data_to_file("status.xml", data, -1); | 193 gaim_util_write_data_to_file("status.xml", data, -1); |
194 g_free(data); | 194 g_free(data); |
195 xmlnode_free(statuses); | 195 xmlnode_free(node); |
196 } | 196 } |
197 | 197 |
198 static gboolean | 198 static gboolean |
199 save_callback(gpointer data) | 199 save_callback(gpointer data) |
200 { | 200 { |
414 gchar *filename; | 414 gchar *filename; |
415 gchar *msg; | 415 gchar *msg; |
416 | 416 |
417 g_return_if_fail(user_dir != NULL); | 417 g_return_if_fail(user_dir != NULL); |
418 | 418 |
419 have_read_saved_statuses = TRUE; | 419 statuses_loaded = TRUE; |
420 | 420 |
421 filename = g_build_filename(user_dir, "status.xml", NULL); | 421 filename = g_build_filename(user_dir, "status.xml", NULL); |
422 | 422 |
423 if (g_file_test(filename, G_FILE_TEST_EXISTS)) | 423 if (g_file_test(filename, G_FILE_TEST_EXISTS)) |
424 { | 424 { |