comparison src/blist.c @ 10704:a4ae4fb7f939

[gaim-migrate @ 12288] Make the blist.xml saving schedule function public and call it whenever privacy settings are changed. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sun, 20 Mar 2005 01:42:53 +0000
parents 54ac161a876e
children 00e3dc1a0206
comparison
equal deleted inserted replaced
10703:a7486f12e56f 10704:a4ae4fb7f939
353 gaim_blist_sync(); 353 gaim_blist_sync();
354 save_timer = 0; 354 save_timer = 0;
355 return FALSE; 355 return FALSE;
356 } 356 }
357 357
358 static void 358 void
359 schedule_blist_save() 359 gaim_blist_schedule_save()
360 { 360 {
361 if (save_timer == 0) 361 if (save_timer == 0)
362 save_timer = gaim_timeout_add(5000, save_cb, NULL); 362 save_timer = gaim_timeout_add(5000, save_cb, NULL);
363 } 363 }
364 364
833 g_hash_table_replace(gaimbuddylist->buddies, hb, buddy); 833 g_hash_table_replace(gaimbuddylist->buddies, hb, buddy);
834 834
835 g_free(buddy->name); 835 g_free(buddy->name);
836 buddy->name = g_strdup(name); 836 buddy->name = g_strdup(name);
837 837
838 schedule_blist_save(); 838 gaim_blist_schedule_save();
839 839
840 if (ops && ops->update) 840 if (ops && ops->update)
841 ops->update(gaimbuddylist, (GaimBlistNode *)buddy); 841 ops->update(gaimbuddylist, (GaimBlistNode *)buddy);
842 } 842 }
843 843
851 if ((alias != NULL) && (*alias != '\0')) 851 if ((alias != NULL) && (*alias != '\0'))
852 chat->alias = g_strdup(alias); 852 chat->alias = g_strdup(alias);
853 else 853 else
854 chat->alias = NULL; 854 chat->alias = NULL;
855 855
856 schedule_blist_save(); 856 gaim_blist_schedule_save();
857 857
858 if (ops && ops->update) 858 if (ops && ops->update)
859 ops->update(gaimbuddylist, (GaimBlistNode *)chat); 859 ops->update(gaimbuddylist, (GaimBlistNode *)chat);
860 } 860 }
861 861
870 if ((alias != NULL) && (*alias != '\0')) 870 if ((alias != NULL) && (*alias != '\0'))
871 buddy->alias = g_strdup(alias); 871 buddy->alias = g_strdup(alias);
872 else 872 else
873 buddy->alias = NULL; 873 buddy->alias = NULL;
874 874
875 schedule_blist_save(); 875 gaim_blist_schedule_save();
876 876
877 if (ops && ops->update) 877 if (ops && ops->update)
878 ops->update(gaimbuddylist, (GaimBlistNode *)buddy); 878 ops->update(gaimbuddylist, (GaimBlistNode *)buddy);
879 879
880 conv = gaim_find_conversation_with_account(GAIM_CONV_IM, buddy->name, 880 conv = gaim_find_conversation_with_account(GAIM_CONV_IM, buddy->name,
894 if ((alias != NULL) && (*alias != '\0') && g_utf8_validate(alias, -1, NULL)) 894 if ((alias != NULL) && (*alias != '\0') && g_utf8_validate(alias, -1, NULL))
895 buddy->server_alias = g_strdup(alias); 895 buddy->server_alias = g_strdup(alias);
896 else 896 else
897 buddy->server_alias = NULL; 897 buddy->server_alias = NULL;
898 898
899 schedule_blist_save(); 899 gaim_blist_schedule_save();
900 900
901 if (ops && ops->update) 901 if (ops && ops->update)
902 ops->update(gaimbuddylist, (GaimBlistNode *)buddy); 902 ops->update(gaimbuddylist, (GaimBlistNode *)buddy);
903 903
904 conv = gaim_find_conversation_with_account(GAIM_CONV_IM, buddy->name, 904 conv = gaim_find_conversation_with_account(GAIM_CONV_IM, buddy->name,
978 source->name = g_strdup(new_name); 978 source->name = g_strdup(new_name);
979 979
980 } 980 }
981 981
982 /* Save our changes */ 982 /* Save our changes */
983 schedule_blist_save(); 983 gaim_blist_schedule_save();
984 984
985 /* Update the UI */ 985 /* Update the UI */
986 if (ops && ops->update) 986 if (ops && ops->update)
987 ops->update(gaimbuddylist, (GaimBlistNode*)source); 987 ops->update(gaimbuddylist, (GaimBlistNode*)source);
988 988
1088 if (buddy->icon) 1088 if (buddy->icon)
1089 gaim_buddy_icon_cache(icon, buddy); 1089 gaim_buddy_icon_cache(icon, buddy);
1090 else 1090 else
1091 gaim_blist_node_remove_setting((GaimBlistNode *)buddy, "buddy_icon"); 1091 gaim_blist_node_remove_setting((GaimBlistNode *)buddy, "buddy_icon");
1092 1092
1093 schedule_blist_save(); 1093 gaim_blist_schedule_save();
1094 1094
1095 gaim_blist_update_buddy_icon(buddy); 1095 gaim_blist_update_buddy_icon(buddy);
1096 } 1096 }
1097 1097
1098 GaimAccount * 1098 GaimAccount *
1157 if (cnode->parent->child == cnode) 1157 if (cnode->parent->child == cnode)
1158 cnode->parent->child = cnode->next; 1158 cnode->parent->child = cnode->next;
1159 1159
1160 ops->remove(gaimbuddylist, cnode); 1160 ops->remove(gaimbuddylist, cnode);
1161 1161
1162 schedule_blist_save(); 1162 gaim_blist_schedule_save();
1163 } 1163 }
1164 1164
1165 if (node != NULL) { 1165 if (node != NULL) {
1166 if (node->next) 1166 if (node->next)
1167 node->next->prev = cnode; 1167 node->next->prev = cnode;
1186 group->online++; 1186 group->online++;
1187 group->currentsize++; 1187 group->currentsize++;
1188 } 1188 }
1189 } 1189 }
1190 1190
1191 schedule_blist_save(); 1191 gaim_blist_schedule_save();
1192 1192
1193 if (ops && ops->update) 1193 if (ops && ops->update)
1194 ops->update(gaimbuddylist, (GaimBlistNode *)cnode); 1194 ops->update(gaimbuddylist, (GaimBlistNode *)cnode);
1195 } 1195 }
1196 1196
1258 if (bnode->parent->child == bnode) 1258 if (bnode->parent->child == bnode)
1259 bnode->parent->child = bnode->next; 1259 bnode->parent->child = bnode->next;
1260 1260
1261 ops->remove(gaimbuddylist, bnode); 1261 ops->remove(gaimbuddylist, bnode);
1262 1262
1263 schedule_blist_save(); 1263 gaim_blist_schedule_save();
1264 1264
1265 if (bnode->parent->parent != (GaimBlistNode*)g) { 1265 if (bnode->parent->parent != (GaimBlistNode*)g) {
1266 hb = g_new(struct _gaim_hbuddy, 1); 1266 hb = g_new(struct _gaim_hbuddy, 1);
1267 hb->name = g_strdup(gaim_normalize(buddy->account, buddy->name)); 1267 hb->name = g_strdup(gaim_normalize(buddy->account, buddy->name));
1268 hb->account = buddy->account; 1268 hb->account = buddy->account;
1315 1315
1316 g_hash_table_replace(gaimbuddylist->buddies, hb, buddy); 1316 g_hash_table_replace(gaimbuddylist->buddies, hb, buddy);
1317 1317
1318 gaim_contact_invalidate_priority_buddy(gaim_buddy_get_contact(buddy)); 1318 gaim_contact_invalidate_priority_buddy(gaim_buddy_get_contact(buddy));
1319 1319
1320 schedule_blist_save(); 1320 gaim_blist_schedule_save();
1321 1321
1322 if (ops && ops->update) 1322 if (ops && ops->update)
1323 ops->update(gaimbuddylist, (GaimBlistNode*)buddy); 1323 ops->update(gaimbuddylist, (GaimBlistNode*)buddy);
1324 } 1324 }
1325 1325
1352 if ((alias != NULL) && (*alias != '\0')) 1352 if ((alias != NULL) && (*alias != '\0'))
1353 contact->alias = g_strdup(alias); 1353 contact->alias = g_strdup(alias);
1354 else 1354 else
1355 contact->alias = NULL; 1355 contact->alias = NULL;
1356 1356
1357 schedule_blist_save(); 1357 gaim_blist_schedule_save();
1358 1358
1359 if (ops && ops->update) 1359 if (ops && ops->update)
1360 ops->update(gaimbuddylist, (GaimBlistNode*)contact); 1360 ops->update(gaimbuddylist, (GaimBlistNode*)contact);
1361 } 1361 }
1362 1362
1502 ((GaimGroup*)cnode->parent)->currentsize--; 1502 ((GaimGroup*)cnode->parent)->currentsize--;
1503 ((GaimGroup*)cnode->parent)->totalsize--; 1503 ((GaimGroup*)cnode->parent)->totalsize--;
1504 1504
1505 ops->remove(gaimbuddylist, cnode); 1505 ops->remove(gaimbuddylist, cnode);
1506 1506
1507 schedule_blist_save(); 1507 gaim_blist_schedule_save();
1508 } 1508 }
1509 1509
1510 if (node && (GAIM_BLIST_NODE_IS_CONTACT(node) || 1510 if (node && (GAIM_BLIST_NODE_IS_CONTACT(node) ||
1511 GAIM_BLIST_NODE_IS_CHAT(node))) { 1511 GAIM_BLIST_NODE_IS_CHAT(node))) {
1512 if (node->next) 1512 if (node->next)
1528 g->online++; 1528 g->online++;
1529 if (contact->currentsize > 0) 1529 if (contact->currentsize > 0)
1530 g->currentsize++; 1530 g->currentsize++;
1531 g->totalsize++; 1531 g->totalsize++;
1532 1532
1533 schedule_blist_save(); 1533 gaim_blist_schedule_save();
1534 1534
1535 if (ops && cnode->child) 1535 if (ops && cnode->child)
1536 ops->update(gaimbuddylist, cnode); 1536 ops->update(gaimbuddylist, cnode);
1537 1537
1538 for (bnode = cnode->child; bnode; bnode = bnode->next) 1538 for (bnode = cnode->child; bnode; bnode = bnode->next)
1619 gnode->next = gaimbuddylist->root; 1619 gnode->next = gaimbuddylist->root;
1620 gnode->prev = NULL; 1620 gnode->prev = NULL;
1621 gaimbuddylist->root = gnode; 1621 gaimbuddylist->root = gnode;
1622 } 1622 }
1623 1623
1624 schedule_blist_save(); 1624 gaim_blist_schedule_save();
1625 1625
1626 if (ops && ops->update) { 1626 if (ops && ops->update) {
1627 ops->update(gaimbuddylist, gnode); 1627 ops->update(gaimbuddylist, gnode);
1628 for (node = gnode->child; node; node = node->next) 1628 for (node = gnode->child; node; node = node->next)
1629 ops->update(gaimbuddylist, node); 1629 ops->update(gaimbuddylist, node);
1662 if (node->prev) 1662 if (node->prev)
1663 node->prev->next = node->next; 1663 node->prev->next = node->next;
1664 if (node->next) 1664 if (node->next)
1665 node->next->prev = node->prev; 1665 node->next->prev = node->prev;
1666 1666
1667 schedule_blist_save(); 1667 gaim_blist_schedule_save();
1668 1668
1669 /* Update the UI */ 1669 /* Update the UI */
1670 if (ops && ops->remove) 1670 if (ops && ops->remove)
1671 ops->remove(gaimbuddylist, node); 1671 ops->remove(gaimbuddylist, node);
1672 1672
1711 if (contact->currentsize == 0) 1711 if (contact->currentsize == 0)
1712 group->currentsize--; 1712 group->currentsize--;
1713 } 1713 }
1714 contact->totalsize--; 1714 contact->totalsize--;
1715 1715
1716 schedule_blist_save(); 1716 gaim_blist_schedule_save();
1717 1717
1718 /* Re-sort the contact */ 1718 /* Re-sort the contact */
1719 if (contact->priority == buddy) { 1719 if (contact->priority == buddy) {
1720 gaim_contact_invalidate_priority_buddy(contact); 1720 gaim_contact_invalidate_priority_buddy(contact);
1721 if (ops && ops->update) 1721 if (ops && ops->update)
1776 group->online--; 1776 group->online--;
1777 group->currentsize--; 1777 group->currentsize--;
1778 } 1778 }
1779 group->totalsize--; 1779 group->totalsize--;
1780 1780
1781 schedule_blist_save(); 1781 gaim_blist_schedule_save();
1782 1782
1783 /* Update the UI */ 1783 /* Update the UI */
1784 if (ops && ops->remove) 1784 if (ops && ops->remove)
1785 ops->remove(gaimbuddylist, node); 1785 ops->remove(gaimbuddylist, node);
1786 1786
1830 if (node->prev) 1830 if (node->prev)
1831 node->prev->next = node->next; 1831 node->prev->next = node->next;
1832 if (node->next) 1832 if (node->next)
1833 node->next->prev = node->prev; 1833 node->next->prev = node->prev;
1834 1834
1835 schedule_blist_save(); 1835 gaim_blist_schedule_save();
1836 1836
1837 /* Update the UI */ 1837 /* Update the UI */
1838 if (ops && ops->remove) 1838 if (ops && ops->remove)
1839 ops->remove(gaimbuddylist, node); 1839 ops->remove(gaimbuddylist, node);
1840 1840
2331 g_return_if_fail(node->settings != NULL); 2331 g_return_if_fail(node->settings != NULL);
2332 g_return_if_fail(key != NULL); 2332 g_return_if_fail(key != NULL);
2333 2333
2334 g_hash_table_remove(node->settings, key); 2334 g_hash_table_remove(node->settings, key);
2335 2335
2336 schedule_blist_save(); 2336 gaim_blist_schedule_save();
2337 } 2337 }
2338 2338
2339 void 2339 void
2340 gaim_blist_node_set_flags(GaimBlistNode *node, GaimBlistNodeFlags flags) 2340 gaim_blist_node_set_flags(GaimBlistNode *node, GaimBlistNodeFlags flags)
2341 { 2341 {
2364 value = gaim_value_new(GAIM_TYPE_BOOLEAN); 2364 value = gaim_value_new(GAIM_TYPE_BOOLEAN);
2365 gaim_value_set_boolean(value, data); 2365 gaim_value_set_boolean(value, data);
2366 2366
2367 g_hash_table_replace(node->settings, g_strdup(key), value); 2367 g_hash_table_replace(node->settings, g_strdup(key), value);
2368 2368
2369 schedule_blist_save(); 2369 gaim_blist_schedule_save();
2370 } 2370 }
2371 2371
2372 gboolean 2372 gboolean
2373 gaim_blist_node_get_bool(GaimBlistNode* node, const char *key) 2373 gaim_blist_node_get_bool(GaimBlistNode* node, const char *key)
2374 { 2374 {
2400 value = gaim_value_new(GAIM_TYPE_INT); 2400 value = gaim_value_new(GAIM_TYPE_INT);
2401 gaim_value_set_int(value, data); 2401 gaim_value_set_int(value, data);
2402 2402
2403 g_hash_table_replace(node->settings, g_strdup(key), value); 2403 g_hash_table_replace(node->settings, g_strdup(key), value);
2404 2404
2405 schedule_blist_save(); 2405 gaim_blist_schedule_save();
2406 } 2406 }
2407 2407
2408 int 2408 int
2409 gaim_blist_node_get_int(GaimBlistNode* node, const char *key) 2409 gaim_blist_node_get_int(GaimBlistNode* node, const char *key)
2410 { 2410 {
2436 value = gaim_value_new(GAIM_TYPE_STRING); 2436 value = gaim_value_new(GAIM_TYPE_STRING);
2437 gaim_value_set_string(value, data); 2437 gaim_value_set_string(value, data);
2438 2438
2439 g_hash_table_replace(node->settings, g_strdup(key), value); 2439 g_hash_table_replace(node->settings, g_strdup(key), value);
2440 2440
2441 schedule_blist_save(); 2441 gaim_blist_schedule_save();
2442 } 2442 }
2443 2443
2444 const char * 2444 const char *
2445 gaim_blist_node_get_string(GaimBlistNode* node, const char *key) 2445 gaim_blist_node_get_string(GaimBlistNode* node, const char *key)
2446 { 2446 {