Mercurial > pidgin
comparison src/list.c @ 4491:3196d9044a45
[gaim-migrate @ 4766]
aim_user is dead. long live gaim_account.
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Fri, 31 Jan 2003 13:03:47 +0000 |
parents | a46c57f2d58b |
children | 71e8b8e62a54 |
comparison
equal
deleted
inserted
replaced
4490:70b892694e0b | 4491:3196d9044a45 |
---|---|
41 | 41 |
42 #define PATHSIZE 1024 | 42 #define PATHSIZE 1024 |
43 | 43 |
44 void remove_buddy(struct buddy *rem_b) | 44 void remove_buddy(struct buddy *rem_b) |
45 { | 45 { |
46 if(rem_b->user->gc) { | 46 if(rem_b->account->gc) { |
47 struct group *rem_g = find_group_by_buddy(rem_b); | 47 struct group *rem_g = find_group_by_buddy(rem_b); |
48 | 48 |
49 ui_remove_buddy(rem_b); | 49 ui_remove_buddy(rem_b); |
50 | 50 |
51 rem_g->members = g_slist_remove(rem_g->members, rem_b); | 51 rem_g->members = g_slist_remove(rem_g->members, rem_b); |
54 | 54 |
55 g_free(rem_b); | 55 g_free(rem_b); |
56 } else { | 56 } else { |
57 char *buf = g_strdup_printf(_("%s was not removed from your buddy " | 57 char *buf = g_strdup_printf(_("%s was not removed from your buddy " |
58 "list, because your account (%s) is not logged in."), | 58 "list, because your account (%s) is not logged in."), |
59 rem_b->name, rem_b->user->username); | 59 rem_b->name, rem_b->account->username); |
60 do_error_dialog(_("Buddy Not Removed"), buf, GAIM_ERROR); | 60 do_error_dialog(_("Buddy Not Removed"), buf, GAIM_ERROR); |
61 g_free(buf); | 61 g_free(buf); |
62 } | 62 } |
63 } | 63 } |
64 | 64 |
65 void remove_group(struct group *rem_g) | 65 void remove_group(struct group *rem_g) |
66 { | 66 { |
67 GSList *users; | 67 GSList *accounts; |
68 | 68 |
69 for(users = aim_users; users; users = users->next) { | 69 for(accounts = gaim_accounts; accounts; accounts = accounts->next) { |
70 struct aim_user *user = users->data; | 70 struct gaim_account *account = accounts->data; |
71 if(user->gc) { | 71 if(account->gc) { |
72 GList *tmp = NULL; | 72 GList *tmp = NULL; |
73 GSList *buds = rem_g->members; | 73 GSList *buds = rem_g->members; |
74 | 74 |
75 while (buds) { | 75 while (buds) { |
76 struct buddy *delb = (struct buddy *)buds->data; | 76 struct buddy *delb = (struct buddy *)buds->data; |
77 buds = buds->next; | 77 buds = buds->next; |
78 | 78 |
79 if(delb->user == user) { | 79 if(delb->account == account) { |
80 tmp = g_list_append(tmp, g_strdup(delb->name)); | 80 tmp = g_list_append(tmp, g_strdup(delb->name)); |
81 remove_buddy(delb); /* this should take care of removing | 81 remove_buddy(delb); /* this should take care of removing |
82 the group_show if necessary */ | 82 the group_show if necessary */ |
83 } | 83 } |
84 } | 84 } |
85 | 85 |
86 if(tmp) | 86 if(tmp) |
87 serv_remove_buddies(user->gc, tmp, rem_g->name); | 87 serv_remove_buddies(account->gc, tmp, rem_g->name); |
88 | 88 |
89 while (tmp) { | 89 while (tmp) { |
90 g_free(tmp->data); | 90 g_free(tmp->data); |
91 tmp = g_list_remove(tmp, tmp->data); | 91 tmp = g_list_remove(tmp, tmp->data); |
92 } | 92 } |
112 | 112 |
113 /* don't flush buddy list to cache in order to be consistent with remove_buddy, | 113 /* don't flush buddy list to cache in order to be consistent with remove_buddy, |
114 * mostly. remove_group is only called from one place, so we'll let it handle it. */ | 114 * mostly. remove_group is only called from one place, so we'll let it handle it. */ |
115 } | 115 } |
116 | 116 |
117 struct buddy *add_buddy(struct aim_user *user, const char *group, const char *buddy, const char *show) | 117 struct buddy *add_buddy(struct gaim_account *account, const char *group, const char *buddy, const char *show) |
118 { | 118 { |
119 struct buddy *b; | 119 struct buddy *b; |
120 struct group *g; | 120 struct group *g; |
121 const char *good; | 121 const char *good; |
122 | 122 |
123 if ((b = find_buddy(user, buddy)) != NULL) | 123 if ((b = find_buddy(account, buddy)) != NULL) |
124 return b; | 124 return b; |
125 | 125 |
126 g = find_group(group); | 126 g = find_group(group); |
127 | 127 |
128 if (g == NULL) | 128 if (g == NULL) |
131 b = (struct buddy *)g_new0(struct buddy, 1); | 131 b = (struct buddy *)g_new0(struct buddy, 1); |
132 | 132 |
133 if (!b) | 133 if (!b) |
134 return NULL; | 134 return NULL; |
135 | 135 |
136 b->user = user; | 136 b->account = account; |
137 b->present = 0; | 137 b->present = 0; |
138 | 138 |
139 b->settings = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | 139 b->settings = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); |
140 | 140 |
141 good = buddy; | 141 good = buddy; |
149 g->members = g_slist_append(g->members, b); | 149 g->members = g_slist_append(g->members, b); |
150 | 150 |
151 b->idle = 0; | 151 b->idle = 0; |
152 b->caps = 0; | 152 b->caps = 0; |
153 | 153 |
154 ui_add_buddy(user->gc, g, b); | 154 ui_add_buddy(account->gc, g, b); |
155 | 155 |
156 return b; | 156 return b; |
157 } | 157 } |
158 | 158 |
159 struct group *add_group(const char *group) | 159 struct group *add_group(const char *group) |
205 grp = grp->next; | 205 grp = grp->next; |
206 } | 206 } |
207 return NULL; | 207 return NULL; |
208 } | 208 } |
209 | 209 |
210 struct buddy *find_buddy(struct aim_user *user, const char *who) | 210 struct buddy *find_buddy(struct gaim_account *account, const char *who) |
211 { | 211 { |
212 struct group *g; | 212 struct group *g; |
213 struct buddy *b; | 213 struct buddy *b; |
214 GSList *grp; | 214 GSList *grp; |
215 GSList *mem; | 215 GSList *mem; |
226 /* | 226 /* |
227 norm = (b->user->gc && b->user->gc->prpl->normalize) ? b->user->gc->prpl->normalize : normalize; | 227 norm = (b->user->gc && b->user->gc->prpl->normalize) ? b->user->gc->prpl->normalize : normalize; |
228 */ | 228 */ |
229 norm = normalize; | 229 norm = normalize; |
230 whoname = g_strdup(norm(who)); | 230 whoname = g_strdup(norm(who)); |
231 if ((b->user == user || !user) && !strcmp(norm(b->name), whoname)) { | 231 if ((b->account == account || !account) && !strcmp(norm(b->name), whoname)) { |
232 g_free(whoname); | 232 g_free(whoname); |
233 return b; | 233 return b; |
234 } | 234 } |
235 g_free(whoname); | 235 g_free(whoname); |
236 mem = mem->next; | 236 mem = mem->next; |
238 grp = g_slist_next(grp); | 238 grp = g_slist_next(grp); |
239 } | 239 } |
240 return NULL; | 240 return NULL; |
241 } | 241 } |
242 | 242 |
243 void parse_toc_buddy_list(struct aim_user *user, char *config) | 243 void parse_toc_buddy_list(struct gaim_account *account, char *config) |
244 { | 244 { |
245 char *c; | 245 char *c; |
246 char current[256]; | 246 char current[256]; |
247 GList *bud = NULL; | 247 GList *bud = NULL; |
248 | 248 |
283 } | 283 } |
284 } | 284 } |
285 if (utf8 == NULL) { | 285 if (utf8 == NULL) { |
286 sw[0] = '\0'; | 286 sw[0] = '\0'; |
287 } else { | 287 } else { |
288 /* This can leave a partial sequence at the end, | 288 /* This can leave a partial sequence at the end, |
289 * but who cares? */ | 289 * but who cares? */ |
290 g_strlcpy(sw, utf8, sizeof(sw)); | 290 g_strlcpy(sw, utf8, sizeof(sw)); |
291 g_free(utf8); | 291 g_free(utf8); |
292 } | 292 } |
293 | 293 |
294 if (!find_buddy(user, nm)) { | 294 if (!find_buddy(account, nm)) { |
295 add_buddy(user, current, nm, sw); | 295 add_buddy(account, current, nm, sw); |
296 bud = g_list_append(bud, nm); | 296 bud = g_list_append(bud, nm); |
297 } | 297 } |
298 } else if (*c == 'p') { | 298 } else if (*c == 'p') { |
299 gaim_privacy_permit_add(user, c + 2); | 299 gaim_privacy_permit_add(account, c + 2); |
300 } else if (*c == 'd') { | 300 } else if (*c == 'd') { |
301 gaim_privacy_deny_add(user, c + 2); | 301 gaim_privacy_deny_add(account, c + 2); |
302 } else if (!strncmp("toc", c, 3)) { | 302 } else if (!strncmp("toc", c, 3)) { |
303 sscanf(c + strlen(c) - 1, "%d", &user->permdeny); | 303 sscanf(c + strlen(c) - 1, "%d", &account->permdeny); |
304 debug_printf("permdeny: %d\n", user->permdeny); | 304 debug_printf("permdeny: %d\n", account->permdeny); |
305 if (user->permdeny == 0) | 305 if (account->permdeny == 0) |
306 user->permdeny = 1; | 306 account->permdeny = 1; |
307 } else if (*c == 'm') { | 307 } else if (*c == 'm') { |
308 sscanf(c + 2, "%d", &user->permdeny); | 308 sscanf(c + 2, "%d", &account->permdeny); |
309 debug_printf("permdeny: %d\n", user->permdeny); | 309 debug_printf("permdeny: %d\n", account->permdeny); |
310 if (user->permdeny == 0) | 310 if (account->permdeny == 0) |
311 user->permdeny = 1; | 311 account->permdeny = 1; |
312 } | 312 } |
313 } while ((c = strtok(NULL, "\n"))); | 313 } while ((c = strtok(NULL, "\n"))); |
314 | 314 |
315 if(user->gc) { | 315 if(account->gc) { |
316 if(bud) | 316 if(bud) |
317 serv_add_buddies(user->gc, bud); | 317 serv_add_buddies(account->gc, bud); |
318 serv_set_permit_deny(user->gc); | 318 serv_set_permit_deny(account->gc); |
319 } | 319 } |
320 g_list_free(bud); | 320 g_list_free(bud); |
321 } | 321 } |
322 } | 322 } |
323 | 323 |
324 void toc_build_config(struct aim_user *user, char *s, int len, gboolean show) | 324 void toc_build_config(struct gaim_account *account, char *s, int len, gboolean show) |
325 { | 325 { |
326 GSList *grp = groups; | 326 GSList *grp = groups; |
327 GSList *mem; | 327 GSList *mem; |
328 struct group *g; | 328 struct group *g; |
329 struct buddy *b; | 329 struct buddy *b; |
330 GSList *plist = user->permit; | 330 GSList *plist = account->permit; |
331 GSList *dlist = user->deny; | 331 GSList *dlist = account->deny; |
332 | 332 |
333 int pos = 0; | 333 int pos = 0; |
334 | 334 |
335 if (!user->permdeny) | 335 if (!account->permdeny) |
336 user->permdeny = 1; | 336 account->permdeny = 1; |
337 | 337 |
338 pos += g_snprintf(&s[pos], len - pos, "m %d\n", user->permdeny); | 338 pos += g_snprintf(&s[pos], len - pos, "m %d\n", account->permdeny); |
339 while (len > pos && grp) { | 339 while (len > pos && grp) { |
340 g = (struct group *)grp->data; | 340 g = (struct group *)grp->data; |
341 if(gaim_group_on_account(g, user)) { | 341 if(gaim_group_on_account(g, account)) { |
342 pos += g_snprintf(&s[pos], len - pos, "g %s\n", g->name); | 342 pos += g_snprintf(&s[pos], len - pos, "g %s\n", g->name); |
343 mem = g->members; | 343 mem = g->members; |
344 while (len > pos && mem) { | 344 while (len > pos && mem) { |
345 b = (struct buddy *)mem->data; | 345 b = (struct buddy *)mem->data; |
346 if(b->user == user) { | 346 if(b->account == account) { |
347 pos += g_snprintf(&s[pos], len - pos, "b %s%s%s\n", b->name, | 347 pos += g_snprintf(&s[pos], len - pos, "b %s%s%s\n", b->name, |
348 (show && b->alias[0]) ? ":" : "", | 348 (show && b->alias[0]) ? ":" : "", |
349 (show && b->alias[0]) ? b->alias : ""); | 349 (show && b->alias[0]) ? b->alias : ""); |
350 } | 350 } |
351 mem = mem->next; | 351 mem = mem->next; |
533 return good; | 533 return good; |
534 } | 534 } |
535 | 535 |
536 static gboolean gaim_blist_read(const char *filename); | 536 static gboolean gaim_blist_read(const char *filename); |
537 | 537 |
538 void do_import(struct aim_user *user, const char *filename) | 538 void do_import(struct gaim_account *account, const char *filename) |
539 { | 539 { |
540 GString *buf = NULL; | 540 GString *buf = NULL; |
541 char first[64]; | 541 char first[64]; |
542 char path[PATHSIZE]; | 542 char path[PATHSIZE]; |
543 int len; | 543 int len; |
545 struct stat st; | 545 struct stat st; |
546 | 546 |
547 if (filename) { | 547 if (filename) { |
548 g_snprintf(path, sizeof(path), "%s", filename); | 548 g_snprintf(path, sizeof(path), "%s", filename); |
549 } else { | 549 } else { |
550 char *g_screenname = get_screenname_filename(user->username); | 550 char *g_screenname = get_screenname_filename(account->username); |
551 char *file = gaim_user_dir(); | 551 char *file = gaim_user_dir(); |
552 int protocol = (user->protocol == PROTO_OSCAR) ? (isalpha(user->username[0]) ? PROTO_TOC : PROTO_ICQ): user->protocol; | 552 int protocol = (account->protocol == PROTO_OSCAR) ? (isalpha(account->username[0]) ? PROTO_TOC : PROTO_ICQ): account->protocol; |
553 | 553 |
554 if (file != (char *)NULL) { | 554 if (file != (char *)NULL) { |
555 sprintf(path, "%s" G_DIR_SEPARATOR_S "%s.%d.blist", file, g_screenname, protocol); | 555 sprintf(path, "%s" G_DIR_SEPARATOR_S "%s.%d.blist", file, g_screenname, protocol); |
556 g_free(g_screenname); | 556 g_free(g_screenname); |
557 } else { | 557 } else { |
612 fclose(f); | 612 fclose(f); |
613 | 613 |
614 if (buf) { | 614 if (buf) { |
615 buf = g_string_prepend(buf, "toc_set_config {"); | 615 buf = g_string_prepend(buf, "toc_set_config {"); |
616 buf = g_string_append(buf, "}\n"); | 616 buf = g_string_append(buf, "}\n"); |
617 parse_toc_buddy_list(user, buf->str); | 617 parse_toc_buddy_list(account, buf->str); |
618 g_string_free(buf, TRUE); | 618 g_string_free(buf, TRUE); |
619 } | 619 } |
620 } | 620 } |
621 | 621 |
622 static gboolean is_blocked(struct buddy *b) | 622 static gboolean is_blocked(struct buddy *b) |
623 { | 623 { |
624 struct aim_user *user = b->user; | 624 struct gaim_account *account = b->account; |
625 | 625 |
626 if (user->permdeny == PERMIT_ALL) | 626 if (account->permdeny == PERMIT_ALL) |
627 return FALSE; | 627 return FALSE; |
628 | 628 |
629 if (user->permdeny == PERMIT_NONE) { | 629 if (account->permdeny == PERMIT_NONE) { |
630 if (user->gc && g_strcasecmp(b->name, user->gc->username)) | 630 if (account->gc && g_strcasecmp(b->name, account->gc->username)) |
631 return TRUE; | 631 return TRUE; |
632 else | 632 else |
633 return FALSE; | 633 return FALSE; |
634 } | 634 } |
635 | 635 |
636 if (user->permdeny == PERMIT_SOME) { | 636 if (account->permdeny == PERMIT_SOME) { |
637 char *x = g_strdup(normalize(b->name)); | 637 char *x = g_strdup(normalize(b->name)); |
638 GSList *s = user->permit; | 638 GSList *s = account->permit; |
639 while (s) { | 639 while (s) { |
640 if (!g_strcasecmp(x, normalize(s->data))) | 640 if (!g_strcasecmp(x, normalize(s->data))) |
641 break; | 641 break; |
642 s = s->next; | 642 s = s->next; |
643 } | 643 } |
645 if (s) | 645 if (s) |
646 return FALSE; | 646 return FALSE; |
647 return TRUE; | 647 return TRUE; |
648 } | 648 } |
649 | 649 |
650 if (user->permdeny == DENY_SOME) { | 650 if (account->permdeny == DENY_SOME) { |
651 char *x = g_strdup(normalize(b->name)); | 651 char *x = g_strdup(normalize(b->name)); |
652 GSList *s = user->deny; | 652 GSList *s = account->deny; |
653 while (s) { | 653 while (s) { |
654 if (!g_strcasecmp(x, normalize(s->data))) | 654 if (!g_strcasecmp(x, normalize(s->data))) |
655 break; | 655 break; |
656 s = s->next; | 656 s = s->next; |
657 } | 657 } |
700 GSList *gaim_group_get_accounts(struct group *g) { | 700 GSList *gaim_group_get_accounts(struct group *g) { |
701 GSList *buds = g->members; | 701 GSList *buds = g->members; |
702 GSList *ret = NULL; | 702 GSList *ret = NULL; |
703 while(buds) { | 703 while(buds) { |
704 struct buddy *b = buds->data; | 704 struct buddy *b = buds->data; |
705 if(!g_slist_find(ret, b->user)) | 705 if(!g_slist_find(ret, b->account)) |
706 ret = g_slist_append(ret, b->user); | 706 ret = g_slist_append(ret, b->account); |
707 buds = buds->next; | 707 buds = buds->next; |
708 } | 708 } |
709 return ret; | 709 return ret; |
710 } | 710 } |
711 | 711 |
712 gboolean gaim_group_on_account(struct group *g, struct aim_user *user) { | 712 gboolean gaim_group_on_account(struct group *g, struct gaim_account *account) { |
713 GSList *buds = g->members; | 713 GSList *buds = g->members; |
714 while(buds) { | 714 while(buds) { |
715 struct buddy *b = buds->data; | 715 struct buddy *b = buds->data; |
716 if((!user && b->user->gc) || b->user == user) | 716 if((!account && b->account->gc) || b->account == account) |
717 return TRUE; | 717 return TRUE; |
718 buds = buds->next; | 718 buds = buds->next; |
719 } | 719 } |
720 return FALSE; | 720 return FALSE; |
721 } | 721 } |
834 } else if(!strcmp(element_name, "person")) { | 834 } else if(!strcmp(element_name, "person")) { |
835 blist_parser_current_tag = BLIST_TAG_GROUP; | 835 blist_parser_current_tag = BLIST_TAG_GROUP; |
836 g_free(blist_parser_person_name); | 836 g_free(blist_parser_person_name); |
837 blist_parser_person_name = NULL; | 837 blist_parser_person_name = NULL; |
838 } else if(!strcmp(element_name, "buddy")) { | 838 } else if(!strcmp(element_name, "buddy")) { |
839 struct aim_user *user = find_user(blist_parser_account_name, | 839 struct gaim_account *account = gaim_account_find(blist_parser_account_name, |
840 blist_parser_account_protocol); | 840 blist_parser_account_protocol); |
841 if(user) { | 841 if(account) { |
842 struct buddy *b = add_buddy(user, blist_parser_group_name, | 842 struct buddy *b = add_buddy(account, blist_parser_group_name, |
843 blist_parser_buddy_name, blist_parser_buddy_alias); | 843 blist_parser_buddy_name, blist_parser_buddy_alias); |
844 if(blist_parser_buddy_settings) { | 844 if(blist_parser_buddy_settings) { |
845 g_hash_table_destroy(b->settings); | 845 g_hash_table_destroy(b->settings); |
846 b->settings = blist_parser_buddy_settings; | 846 b->settings = blist_parser_buddy_settings; |
847 } | 847 } |
871 g_free(blist_parser_setting_value); | 871 g_free(blist_parser_setting_value); |
872 blist_parser_current_tag = BLIST_TAG_BUDDY; | 872 blist_parser_current_tag = BLIST_TAG_BUDDY; |
873 } else if(!strcmp(element_name, "privacy")) { | 873 } else if(!strcmp(element_name, "privacy")) { |
874 blist_parser_current_tag = BLIST_TAG_GAIM; | 874 blist_parser_current_tag = BLIST_TAG_GAIM; |
875 } else if(!strcmp(element_name, "account")) { | 875 } else if(!strcmp(element_name, "account")) { |
876 struct aim_user *user = find_user(blist_parser_account_name, | 876 struct gaim_account *account = gaim_account_find(blist_parser_account_name, |
877 blist_parser_account_protocol); | 877 blist_parser_account_protocol); |
878 if(user) { | 878 if(account) { |
879 user->permdeny = blist_parser_privacy_mode; | 879 account->permdeny = blist_parser_privacy_mode; |
880 } | 880 } |
881 blist_parser_current_tag = BLIST_TAG_PRIVACY; | 881 blist_parser_current_tag = BLIST_TAG_PRIVACY; |
882 g_free(blist_parser_account_name); | 882 g_free(blist_parser_account_name); |
883 blist_parser_account_name = NULL; | 883 blist_parser_account_name = NULL; |
884 } else if(!strcmp(element_name, "permit")) { | 884 } else if(!strcmp(element_name, "permit")) { |
885 struct aim_user *user = find_user(blist_parser_account_name, | 885 struct gaim_account *account = gaim_account_find(blist_parser_account_name, |
886 blist_parser_account_protocol); | 886 blist_parser_account_protocol); |
887 if(user) { | 887 if(account) { |
888 gaim_privacy_permit_add(user, blist_parser_buddy_name); | 888 gaim_privacy_permit_add(account, blist_parser_buddy_name); |
889 } | 889 } |
890 blist_parser_current_tag = BLIST_TAG_ACCOUNT; | 890 blist_parser_current_tag = BLIST_TAG_ACCOUNT; |
891 g_free(blist_parser_buddy_name); | 891 g_free(blist_parser_buddy_name); |
892 blist_parser_buddy_name = NULL; | 892 blist_parser_buddy_name = NULL; |
893 } else if(!strcmp(element_name, "block")) { | 893 } else if(!strcmp(element_name, "block")) { |
894 struct aim_user *user = find_user(blist_parser_account_name, | 894 struct gaim_account *account = gaim_account_find(blist_parser_account_name, |
895 blist_parser_account_protocol); | 895 blist_parser_account_protocol); |
896 if(user) { | 896 if(account) { |
897 gaim_privacy_deny_add(user, blist_parser_buddy_name); | 897 gaim_privacy_deny_add(account, blist_parser_buddy_name); |
898 } | 898 } |
899 blist_parser_current_tag = BLIST_TAG_ACCOUNT; | 899 blist_parser_current_tag = BLIST_TAG_ACCOUNT; |
900 g_free(blist_parser_buddy_name); | 900 g_free(blist_parser_buddy_name); |
901 blist_parser_buddy_name = NULL; | 901 blist_parser_buddy_name = NULL; |
902 } else if(!strcmp(element_name, "ignore")) { | 902 } else if(!strcmp(element_name, "ignore")) { |
992 msg = g_strdup_printf(_("An error was encountered parsing your " | 992 msg = g_strdup_printf(_("An error was encountered parsing your " |
993 "buddy list. It has not been loaded.")); | 993 "buddy list. It has not been loaded.")); |
994 do_error_dialog(_("Buddy List Error"), msg, GAIM_ERROR); | 994 do_error_dialog(_("Buddy List Error"), msg, GAIM_ERROR); |
995 g_free(msg); | 995 g_free(msg); |
996 } | 996 } |
997 } else if(g_slist_length(aim_users)) { | 997 } else if(g_slist_length(gaim_accounts)) { |
998 /* rob wants to inform the user that their buddy lists are | 998 /* rob wants to inform the user that their buddy lists are |
999 * being converted */ | 999 * being converted */ |
1000 msg = g_strdup_printf(_("Gaim is converting your old buddy lists " | 1000 msg = g_strdup_printf(_("Gaim is converting your old buddy lists " |
1001 "to a new format, which will now be located at %s"), | 1001 "to a new format, which will now be located at %s"), |
1002 filename); | 1002 filename); |
1006 /* now, let gtk actually display the dialog before we start anything */ | 1006 /* now, let gtk actually display the dialog before we start anything */ |
1007 while(gtk_events_pending()) | 1007 while(gtk_events_pending()) |
1008 gtk_main_iteration(); | 1008 gtk_main_iteration(); |
1009 | 1009 |
1010 /* read in the old lists, then save to the new format */ | 1010 /* read in the old lists, then save to the new format */ |
1011 for(accts = aim_users; accts; accts = accts->next) { | 1011 for(accts = gaim_accounts; accts; accts = accts->next) { |
1012 do_import(accts->data, NULL); | 1012 do_import(accts->data, NULL); |
1013 } | 1013 } |
1014 gaim_blist_save(); | 1014 gaim_blist_save(); |
1015 } | 1015 } |
1016 | 1016 |
1026 data_val); | 1026 data_val); |
1027 g_free(key_val); | 1027 g_free(key_val); |
1028 g_free(data_val); | 1028 g_free(data_val); |
1029 } | 1029 } |
1030 | 1030 |
1031 static void gaim_blist_write(FILE *file, struct aim_user *user) { | 1031 static void gaim_blist_write(FILE *file, struct gaim_account *exp_acct) { |
1032 GSList *grps, *buds, *users; | 1032 GSList *grps, *buds, *accounts; |
1033 fprintf(file, "<?xml version='1.0' encoding='UTF-8' ?>\n"); | 1033 fprintf(file, "<?xml version='1.0' encoding='UTF-8' ?>\n"); |
1034 fprintf(file, "<gaim version=\"1\">\n"); | 1034 fprintf(file, "<gaim version=\"1\">\n"); |
1035 fprintf(file, "\t<blist>\n"); | 1035 fprintf(file, "\t<blist>\n"); |
1036 | 1036 |
1037 for(grps = groups; grps; grps = grps->next) { | 1037 for(grps = groups; grps; grps = grps->next) { |
1038 struct group *g = grps->data; | 1038 struct group *g = grps->data; |
1039 if(!user || gaim_group_on_account(g, user)) { | 1039 if(!exp_acct || gaim_group_on_account(g, exp_acct)) { |
1040 char *group_name = g_markup_escape_text(g->name, -1); | 1040 char *group_name = g_markup_escape_text(g->name, -1); |
1041 fprintf(file, "\t\t<group name=\"%s\">\n", group_name); | 1041 fprintf(file, "\t\t<group name=\"%s\">\n", group_name); |
1042 for(buds = g->members; buds; buds = buds->next) { | 1042 for(buds = g->members; buds; buds = buds->next) { |
1043 struct buddy *b = buds->data; | 1043 struct buddy *b = buds->data; |
1044 if(!user || b->user == user) { | 1044 if(!exp_acct || b->account == exp_acct) { |
1045 char *bud_name = g_markup_escape_text(b->name, -1); | 1045 char *bud_name = g_markup_escape_text(b->name, -1); |
1046 char *bud_alias = NULL; | 1046 char *bud_alias = NULL; |
1047 char *acct_name = g_markup_escape_text(b->user->username, -1); | 1047 char *acct_name = g_markup_escape_text(b->account->username, -1); |
1048 if(b->alias[0]) | 1048 if(b->alias[0]) |
1049 bud_alias= g_markup_escape_text(b->alias, -1); | 1049 bud_alias= g_markup_escape_text(b->alias, -1); |
1050 fprintf(file, "\t\t\t<person name=\"%s\">\n", | 1050 fprintf(file, "\t\t\t<person name=\"%s\">\n", |
1051 bud_alias ? bud_alias : bud_name); | 1051 bud_alias ? bud_alias : bud_name); |
1052 fprintf(file, "\t\t\t\t<buddy protocol=\"%d\" " | 1052 fprintf(file, "\t\t\t\t<buddy protocol=\"%d\" " |
1053 "account=\"%s\">\n", b->user->protocol, | 1053 "account=\"%s\">\n", b->account->protocol, |
1054 acct_name); | 1054 acct_name); |
1055 fprintf(file, "\t\t\t\t\t<name>%s</name>\n", bud_name); | 1055 fprintf(file, "\t\t\t\t\t<name>%s</name>\n", bud_name); |
1056 if(bud_alias) { | 1056 if(bud_alias) { |
1057 fprintf(file, "\t\t\t\t\t<alias>%s</alias>\n", | 1057 fprintf(file, "\t\t\t\t\t<alias>%s</alias>\n", |
1058 bud_alias); | 1058 bud_alias); |
1072 } | 1072 } |
1073 | 1073 |
1074 fprintf(file, "\t</blist>\n"); | 1074 fprintf(file, "\t</blist>\n"); |
1075 fprintf(file, "\t<privacy>\n"); | 1075 fprintf(file, "\t<privacy>\n"); |
1076 | 1076 |
1077 for(users = aim_users; users; users = users->next) { | 1077 for(accounts = gaim_accounts; accounts; accounts = accounts->next) { |
1078 struct aim_user *usr = users->data; | 1078 struct gaim_account *account = accounts->data; |
1079 char *acct_name = g_markup_escape_text(usr->username, -1); | 1079 char *acct_name = g_markup_escape_text(account->username, -1); |
1080 if(!user || usr == user) { | 1080 if(!exp_acct || account == exp_acct) { |
1081 fprintf(file, "\t\t<account protocol=\"%d\" name=\"%s\" " | 1081 fprintf(file, "\t\t<account protocol=\"%d\" name=\"%s\" " |
1082 "mode=\"%d\">\n", usr->protocol, acct_name, usr->permdeny); | 1082 "mode=\"%d\">\n", account->protocol, acct_name, account->permdeny); |
1083 for(buds = usr->permit; buds; buds = buds->next) { | 1083 for(buds = account->permit; buds; buds = buds->next) { |
1084 char *bud_name = g_markup_escape_text(buds->data, -1); | 1084 char *bud_name = g_markup_escape_text(buds->data, -1); |
1085 fprintf(file, "\t\t\t<permit>%s</permit>\n", bud_name); | 1085 fprintf(file, "\t\t\t<permit>%s</permit>\n", bud_name); |
1086 g_free(bud_name); | 1086 g_free(bud_name); |
1087 } | 1087 } |
1088 for(buds = usr->deny; buds; buds = buds->next) { | 1088 for(buds = account->deny; buds; buds = buds->next) { |
1089 char *bud_name = g_markup_escape_text(buds->data, -1); | 1089 char *bud_name = g_markup_escape_text(buds->data, -1); |
1090 fprintf(file, "\t\t\t<block>%s</block>\n", bud_name); | 1090 fprintf(file, "\t\t\t<block>%s</block>\n", bud_name); |
1091 g_free(bud_name); | 1091 g_free(bud_name); |
1092 } | 1092 } |
1093 fprintf(file, "\t\t</account>\n"); | 1093 fprintf(file, "\t\t</account>\n"); |
1094 } | 1094 } |
1095 g_free(acct_name); | |
1095 } | 1096 } |
1096 | 1097 |
1097 fprintf(file, "\t</privacy>\n"); | 1098 fprintf(file, "\t</privacy>\n"); |
1098 fprintf(file, "</gaim>\n"); | 1099 fprintf(file, "</gaim>\n"); |
1099 } | 1100 } |
1123 } | 1124 } |
1124 | 1125 |
1125 g_free(filename); | 1126 g_free(filename); |
1126 } | 1127 } |
1127 | 1128 |
1128 gboolean gaim_privacy_permit_add(struct aim_user *user, const char *who) { | 1129 gboolean gaim_privacy_permit_add(struct gaim_account *account, const char *who) { |
1129 GSList *d = user->permit; | 1130 GSList *d = account->permit; |
1130 char *n = g_strdup(normalize(who)); | 1131 char *n = g_strdup(normalize(who)); |
1131 while(d) { | 1132 while(d) { |
1132 if(!g_strcasecmp(n, normalize(d->data))) | 1133 if(!g_strcasecmp(n, normalize(d->data))) |
1133 break; | 1134 break; |
1134 d = d->next; | 1135 d = d->next; |
1135 } | 1136 } |
1136 g_free(n); | 1137 g_free(n); |
1137 if(!d) { | 1138 if(!d) { |
1138 user->permit = g_slist_append(user->permit, g_strdup(who)); | 1139 account->permit = g_slist_append(account->permit, g_strdup(who)); |
1139 return TRUE; | 1140 return TRUE; |
1140 } | 1141 } |
1141 | 1142 |
1142 return FALSE; | 1143 return FALSE; |
1143 } | 1144 } |
1144 | 1145 |
1145 gboolean gaim_privacy_permit_remove(struct aim_user *user, const char *who) { | 1146 gboolean gaim_privacy_permit_remove(struct gaim_account *account, const char *who) { |
1146 GSList *d = user->permit; | 1147 GSList *d = account->permit; |
1147 char *n = g_strdup(normalize(who)); | 1148 char *n = g_strdup(normalize(who)); |
1148 while(d) { | 1149 while(d) { |
1149 if(!g_strcasecmp(n, normalize(d->data))) | 1150 if(!g_strcasecmp(n, normalize(d->data))) |
1150 break; | 1151 break; |
1151 d = d->next; | 1152 d = d->next; |
1152 } | 1153 } |
1153 g_free(n); | 1154 g_free(n); |
1154 if(d) { | 1155 if(d) { |
1155 user->permit = g_slist_remove(user->permit, d->data); | 1156 account->permit = g_slist_remove(account->permit, d->data); |
1156 g_free(d->data); | 1157 g_free(d->data); |
1157 return TRUE; | 1158 return TRUE; |
1158 } | 1159 } |
1159 return FALSE; | 1160 return FALSE; |
1160 } | 1161 } |
1161 | 1162 |
1162 gboolean gaim_privacy_deny_add(struct aim_user *user, const char *who) { | 1163 gboolean gaim_privacy_deny_add(struct gaim_account *account, const char *who) { |
1163 GSList *d = user->deny; | 1164 GSList *d = account->deny; |
1164 char *n = g_strdup(normalize(who)); | 1165 char *n = g_strdup(normalize(who)); |
1165 while(d) { | 1166 while(d) { |
1166 if(!g_strcasecmp(n, normalize(d->data))) | 1167 if(!g_strcasecmp(n, normalize(d->data))) |
1167 break; | 1168 break; |
1168 d = d->next; | 1169 d = d->next; |
1169 } | 1170 } |
1170 g_free(n); | 1171 g_free(n); |
1171 if(!d) { | 1172 if(!d) { |
1172 user->deny = g_slist_append(user->deny, g_strdup(who)); | 1173 account->deny = g_slist_append(account->deny, g_strdup(who)); |
1173 return TRUE; | 1174 return TRUE; |
1174 } | 1175 } |
1175 | 1176 |
1176 return FALSE; | 1177 return FALSE; |
1177 } | 1178 } |
1178 | 1179 |
1179 gboolean gaim_privacy_deny_remove(struct aim_user *user, const char *who) { | 1180 gboolean gaim_privacy_deny_remove(struct gaim_account *account, const char *who) { |
1180 GSList *d = user->deny; | 1181 GSList *d = account->deny; |
1181 char *n = g_strdup(normalize(who)); | 1182 char *n = g_strdup(normalize(who)); |
1182 while(d) { | 1183 while(d) { |
1183 if(!g_strcasecmp(n, normalize(d->data))) | 1184 if(!g_strcasecmp(n, normalize(d->data))) |
1184 break; | 1185 break; |
1185 d = d->next; | 1186 d = d->next; |
1186 } | 1187 } |
1187 g_free(n); | 1188 g_free(n); |
1188 if(d) { | 1189 if(d) { |
1189 user->deny = g_slist_remove(user->deny, d->data); | 1190 account->deny = g_slist_remove(account->deny, d->data); |
1190 g_free(d->data); | 1191 g_free(d->data); |
1191 return TRUE; | 1192 return TRUE; |
1192 } | 1193 } |
1193 return FALSE; | 1194 return FALSE; |
1194 } | 1195 } |