annotate src/blist.c @ 6473:2311f3761ed2

[gaim-migrate @ 6982] We shouldn't notify people that we're converting the buddy list, since it doesn't really take long, and we don't do that for preferences, accounts, or pounces. However, I've only #if 0'd it out, so if somebody feels this is *really* important, we can easily put it back. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Fri, 15 Aug 2003 03:59:00 +0000
parents ccfdf9f2cdd1
children 70d5122bc3ff
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1 /*
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2 * gaim
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
3 *
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
4 * Copyright (C) 2003, Sean Egan <sean.egan@binghamton.edu>
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
5 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
6 *
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
10 * (at your option) any later version.
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
11 *
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 * GNU General Public License for more details.
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 *
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
20 *
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
21 */
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5855
diff changeset
22 #include "internal.h"
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
23 #include "blist.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5855
diff changeset
24 #include "conversation.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5855
diff changeset
25 #include "debug.h"
6034
5a0060191a77 [gaim-migrate @ 6484]
Luke Schierer <lschiere@pidgin.im>
parents: 6012
diff changeset
26 #include "multi.h"
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5435
diff changeset
27 #include "notify.h"
5545
7a64114641c3 [gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents: 5541
diff changeset
28 #include "prefs.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5855
diff changeset
29 #include "privacy.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5855
diff changeset
30 #include "prpl.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5855
diff changeset
31 #include "server.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5855
diff changeset
32 #include "util.h"
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
33
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
34 #define PATHSIZE 1024
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
35
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
36 struct gaim_buddy_list *gaimbuddylist = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
37 static struct gaim_blist_ui_ops *blist_ui_ops = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
38
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
39 /*****************************************************************************
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
40 * Private Utility functions *
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
41 *****************************************************************************/
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
42 static GaimBlistNode *gaim_blist_get_last_sibling(GaimBlistNode *node)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
43 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
44 GaimBlistNode *n = node;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
45 if (!n)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
46 return NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
47 while (n->next)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
48 n = n->next;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
49 return n;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
50 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
51 static GaimBlistNode *gaim_blist_get_last_child(GaimBlistNode *node)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
52 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
53 if (!node)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
54 return NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
55 return gaim_blist_get_last_sibling(node->child);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
56 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
57
5247
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
58 struct _gaim_hbuddy {
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
59 char *name;
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
60 GaimAccount *account;
5758
666b04f93c55 [gaim-migrate @ 6183]
Sean Egan <seanegan@gmail.com>
parents: 5676
diff changeset
61 GaimBlistNode *group;
5247
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
62 };
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
63
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
64 static guint _gaim_blist_hbuddy_hash (struct _gaim_hbuddy *hb)
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
65 {
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
66 return g_str_hash(hb->name);
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
67 }
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
68
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
69 static guint _gaim_blist_hbuddy_equal (struct _gaim_hbuddy *hb1, struct _gaim_hbuddy *hb2)
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
70 {
5758
666b04f93c55 [gaim-migrate @ 6183]
Sean Egan <seanegan@gmail.com>
parents: 5676
diff changeset
71 return ((!strcmp(hb1->name, hb2->name)) && hb1->account == hb2->account && hb1->group == hb2->group);
5247
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
72 }
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
73
6006
0aeb4fd0fc65 [gaim-migrate @ 6454]
Mark Doliner <mark@kingant.net>
parents: 5985
diff changeset
74 static void blist_pref_cb(const char *name, GaimPrefType typ, gpointer value, gpointer data)
0aeb4fd0fc65 [gaim-migrate @ 6454]
Mark Doliner <mark@kingant.net>
parents: 5985
diff changeset
75 {
6012
4c16227f7cd9 [gaim-migrate @ 6460]
Mark Doliner <mark@kingant.net>
parents: 6006
diff changeset
76 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
4c16227f7cd9 [gaim-migrate @ 6460]
Mark Doliner <mark@kingant.net>
parents: 6006
diff changeset
77 GaimBlistNode *group, *buddy;
4c16227f7cd9 [gaim-migrate @ 6460]
Mark Doliner <mark@kingant.net>
parents: 6006
diff changeset
78
4c16227f7cd9 [gaim-migrate @ 6460]
Mark Doliner <mark@kingant.net>
parents: 6006
diff changeset
79 if (!ops)
4c16227f7cd9 [gaim-migrate @ 6460]
Mark Doliner <mark@kingant.net>
parents: 6006
diff changeset
80 return;
4c16227f7cd9 [gaim-migrate @ 6460]
Mark Doliner <mark@kingant.net>
parents: 6006
diff changeset
81
4c16227f7cd9 [gaim-migrate @ 6460]
Mark Doliner <mark@kingant.net>
parents: 6006
diff changeset
82 for(group = gaimbuddylist->root; group; group = group->next) {
4c16227f7cd9 [gaim-migrate @ 6460]
Mark Doliner <mark@kingant.net>
parents: 6006
diff changeset
83 if(!GAIM_BLIST_NODE_IS_GROUP(group))
4c16227f7cd9 [gaim-migrate @ 6460]
Mark Doliner <mark@kingant.net>
parents: 6006
diff changeset
84 continue;
4c16227f7cd9 [gaim-migrate @ 6460]
Mark Doliner <mark@kingant.net>
parents: 6006
diff changeset
85 for(buddy = group->child; buddy; buddy = buddy->next) {
4c16227f7cd9 [gaim-migrate @ 6460]
Mark Doliner <mark@kingant.net>
parents: 6006
diff changeset
86 if(!GAIM_BLIST_NODE_IS_BUDDY(buddy))
4c16227f7cd9 [gaim-migrate @ 6460]
Mark Doliner <mark@kingant.net>
parents: 6006
diff changeset
87 continue;
4c16227f7cd9 [gaim-migrate @ 6460]
Mark Doliner <mark@kingant.net>
parents: 6006
diff changeset
88 ops->update(gaimbuddylist, buddy);
4c16227f7cd9 [gaim-migrate @ 6460]
Mark Doliner <mark@kingant.net>
parents: 6006
diff changeset
89 }
4c16227f7cd9 [gaim-migrate @ 6460]
Mark Doliner <mark@kingant.net>
parents: 6006
diff changeset
90 }
6006
0aeb4fd0fc65 [gaim-migrate @ 6454]
Mark Doliner <mark@kingant.net>
parents: 5985
diff changeset
91 }
0aeb4fd0fc65 [gaim-migrate @ 6454]
Mark Doliner <mark@kingant.net>
parents: 5985
diff changeset
92
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
93 /*****************************************************************************
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
94 * Public API functions *
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
95 *****************************************************************************/
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
96
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
97 struct gaim_buddy_list *gaim_blist_new()
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
98 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
99 struct gaim_buddy_list *gbl = g_new0(struct gaim_buddy_list, 1);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
100
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
101 gbl->ui_ops = gaim_get_blist_ui_ops();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
102
5247
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
103 gbl->buddies = g_hash_table_new ((GHashFunc)_gaim_blist_hbuddy_hash,
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
104 (GEqualFunc)_gaim_blist_hbuddy_equal);
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
105
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
106 if (gbl->ui_ops != NULL && gbl->ui_ops->new_list != NULL)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
107 gbl->ui_ops->new_list(gbl);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
108
6006
0aeb4fd0fc65 [gaim-migrate @ 6454]
Mark Doliner <mark@kingant.net>
parents: 5985
diff changeset
109 gaim_prefs_connect_callback("/core/buddies/use_server_alias", blist_pref_cb, NULL);
0aeb4fd0fc65 [gaim-migrate @ 6454]
Mark Doliner <mark@kingant.net>
parents: 5985
diff changeset
110
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
111 return gbl;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
112 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
113
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
114 void
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
115 gaim_set_blist(struct gaim_buddy_list *list)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
116 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
117 gaimbuddylist = list;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
118 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
119
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
120 struct gaim_buddy_list *
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
121 gaim_get_blist(void)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
122 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
123 return gaimbuddylist;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
124 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
125
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
126 void gaim_blist_show ()
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
127 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
128 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
129 if (ops)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
130 ops->show(gaimbuddylist);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
131 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
132
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
133 void gaim_blist_destroy()
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
134 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
135 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
136 if (ops)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
137 ops->destroy(gaimbuddylist);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
138 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
139
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
140 void gaim_blist_set_visible (gboolean show)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
141 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
142 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
143 if (ops)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
144 ops->set_visible(gaimbuddylist, show);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
145 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
146
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
147 void gaim_blist_update_buddy_status (struct buddy *buddy, int status)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
148 {
5266
b3a03b86b09b [gaim-migrate @ 5638]
Christian Hammond <chipx86@chipx86.com>
parents: 5259
diff changeset
149 struct gaim_blist_ui_ops *ops;
b3a03b86b09b [gaim-migrate @ 5638]
Christian Hammond <chipx86@chipx86.com>
parents: 5259
diff changeset
150
b3a03b86b09b [gaim-migrate @ 5638]
Christian Hammond <chipx86@chipx86.com>
parents: 5259
diff changeset
151 if (buddy->uc == status)
b3a03b86b09b [gaim-migrate @ 5638]
Christian Hammond <chipx86@chipx86.com>
parents: 5259
diff changeset
152 return;
b3a03b86b09b [gaim-migrate @ 5638]
Christian Hammond <chipx86@chipx86.com>
parents: 5259
diff changeset
153
b3a03b86b09b [gaim-migrate @ 5638]
Christian Hammond <chipx86@chipx86.com>
parents: 5259
diff changeset
154 ops = gaimbuddylist->ui_ops;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
155
5305
d2732160850b [gaim-migrate @ 5677]
Luke Schierer <lschiere@pidgin.im>
parents: 5292
diff changeset
156 if((status & UC_UNAVAILABLE) != (buddy->uc & UC_UNAVAILABLE)) {
d2732160850b [gaim-migrate @ 5677]
Luke Schierer <lschiere@pidgin.im>
parents: 5292
diff changeset
157 if(status & UC_UNAVAILABLE)
d2732160850b [gaim-migrate @ 5677]
Luke Schierer <lschiere@pidgin.im>
parents: 5292
diff changeset
158 gaim_event_broadcast(event_buddy_away, buddy->account->gc, buddy->name);
d2732160850b [gaim-migrate @ 5677]
Luke Schierer <lschiere@pidgin.im>
parents: 5292
diff changeset
159 else
d2732160850b [gaim-migrate @ 5677]
Luke Schierer <lschiere@pidgin.im>
parents: 5292
diff changeset
160 gaim_event_broadcast(event_buddy_back, buddy->account->gc, buddy->name);
d2732160850b [gaim-migrate @ 5677]
Luke Schierer <lschiere@pidgin.im>
parents: 5292
diff changeset
161 }
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
162
5305
d2732160850b [gaim-migrate @ 5677]
Luke Schierer <lschiere@pidgin.im>
parents: 5292
diff changeset
163 buddy->uc = status;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
164 if (ops)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
165 ops->update(gaimbuddylist, (GaimBlistNode*)buddy);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
166 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
167
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
168 static gboolean presence_update_timeout_cb(struct buddy *buddy) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
169 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
6392
e9974608b319 [gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents: 6378
diff changeset
170 GaimConversation *conv = gaim_find_conversation(buddy->name);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
171
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
172 if(buddy->present == GAIM_BUDDY_SIGNING_ON) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
173 buddy->present = GAIM_BUDDY_ONLINE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
174 } else if(buddy->present == GAIM_BUDDY_SIGNING_OFF) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
175 buddy->present = GAIM_BUDDY_OFFLINE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
176 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
177
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
178 buddy->timer = 0;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
179
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
180 if (ops)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
181 ops->update(gaimbuddylist, (GaimBlistNode*)buddy);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
182
6392
e9974608b319 [gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents: 6378
diff changeset
183 if (conv) {
e9974608b319 [gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents: 6378
diff changeset
184 if (buddy->present == GAIM_BUDDY_ONLINE)
e9974608b319 [gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents: 6378
diff changeset
185 gaim_conversation_update(conv, GAIM_CONV_ACCOUNT_ONLINE);
e9974608b319 [gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents: 6378
diff changeset
186 else if (buddy->present == GAIM_BUDDY_OFFLINE)
e9974608b319 [gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents: 6378
diff changeset
187 gaim_conversation_update(conv, GAIM_CONV_ACCOUNT_OFFLINE);
e9974608b319 [gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents: 6378
diff changeset
188 }
e9974608b319 [gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents: 6378
diff changeset
189
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
190 return FALSE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
191 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
192
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
193 void gaim_blist_update_buddy_presence(struct buddy *buddy, int presence) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
194 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
195 gboolean do_timer = FALSE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
196
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
197 if (!GAIM_BUDDY_IS_ONLINE(buddy) && presence) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
198 buddy->present = GAIM_BUDDY_SIGNING_ON;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
199 gaim_event_broadcast(event_buddy_signon, buddy->account->gc, buddy->name);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
200 do_timer = TRUE;
5277
d7771fe33cbd [gaim-migrate @ 5649]
Luke Schierer <lschiere@pidgin.im>
parents: 5266
diff changeset
201 ((struct group *)((GaimBlistNode *)buddy)->parent)->online++;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
202 } else if(GAIM_BUDDY_IS_ONLINE(buddy) && !presence) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
203 buddy->present = GAIM_BUDDY_SIGNING_OFF;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
204 gaim_event_broadcast(event_buddy_signoff, buddy->account->gc, buddy->name);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
205 do_timer = TRUE;
5394
08a90a9e28e4 [gaim-migrate @ 5770]
Nathan Walp <nwalp@pidgin.im>
parents: 5392
diff changeset
206 ((struct group *)((GaimBlistNode *)buddy)->parent)->online--;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
207 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
208
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
209 if(do_timer) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
210 if(buddy->timer > 0)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
211 g_source_remove(buddy->timer);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
212 buddy->timer = g_timeout_add(10000, (GSourceFunc)presence_update_timeout_cb, buddy);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
213 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
214
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
215 if (ops)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
216 ops->update(gaimbuddylist, (GaimBlistNode*)buddy);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
217 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
218
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
219
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
220 void gaim_blist_update_buddy_idle (struct buddy *buddy, int idle)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
221 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
222 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
223 buddy->idle = idle;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
224 if (ops)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
225 ops->update(gaimbuddylist, (GaimBlistNode*)buddy);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
226 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
227 void gaim_blist_update_buddy_evil (struct buddy *buddy, int warning)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
228 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
229 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
230 buddy->evil = warning;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
231 if (ops)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
232 ops->update(gaimbuddylist,(GaimBlistNode*)buddy);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
233 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
234 void gaim_blist_update_buddy_icon(struct buddy *buddy) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
235 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
236 if(ops)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
237 ops->update(gaimbuddylist, (GaimBlistNode*)buddy);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
238 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
239 void gaim_blist_rename_buddy (struct buddy *buddy, const char *name)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
240 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
241 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
5634
5946be17f9ec [gaim-migrate @ 6041]
Nathan Walp <nwalp@pidgin.im>
parents: 5580
diff changeset
242 g_free(buddy->name);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
243 buddy->name = g_strdup(name);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
244 if (ops)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
245 ops->update(gaimbuddylist, (GaimBlistNode*)buddy);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
246 }
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
247
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
248 void gaim_blist_alias_chat(struct chat *chat, const char *alias)
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
249 {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
250 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
251
5237
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
252 g_free(chat->alias);
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
253
5237
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
254 if(alias && strlen(alias))
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
255 chat->alias = g_strdup(alias);
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
256 else
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
257 chat->alias = NULL;
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
258
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
259 if(ops)
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
260 ops->update(gaimbuddylist, (GaimBlistNode*)chat);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
261 }
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
262
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
263 void gaim_blist_alias_buddy (struct buddy *buddy, const char *alias)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
264 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
265 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
5676
dae79aefac8d [gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents: 5634
diff changeset
266 GaimConversation *conv;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
267
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
268 g_free(buddy->alias);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
269
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
270 if(alias && strlen(alias))
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
271 buddy->alias = g_strdup(alias);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
272 else
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
273 buddy->alias = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
274
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
275 if (ops)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
276 ops->update(gaimbuddylist, (GaimBlistNode*)buddy);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
277
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
278 conv = gaim_find_conversation_with_account(buddy->name, buddy->account);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
279
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
280 if (conv)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
281 gaim_conversation_autoset_title(conv);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
282 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
283
6058
d5f4ae4f9a02 [gaim-migrate @ 6508]
Mark Doliner <mark@kingant.net>
parents: 6036
diff changeset
284 void gaim_blist_server_alias_buddy (struct buddy *buddy, const char *alias)
d5f4ae4f9a02 [gaim-migrate @ 6508]
Mark Doliner <mark@kingant.net>
parents: 6036
diff changeset
285 {
d5f4ae4f9a02 [gaim-migrate @ 6508]
Mark Doliner <mark@kingant.net>
parents: 6036
diff changeset
286 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
d5f4ae4f9a02 [gaim-migrate @ 6508]
Mark Doliner <mark@kingant.net>
parents: 6036
diff changeset
287 GaimConversation *conv;
d5f4ae4f9a02 [gaim-migrate @ 6508]
Mark Doliner <mark@kingant.net>
parents: 6036
diff changeset
288
d5f4ae4f9a02 [gaim-migrate @ 6508]
Mark Doliner <mark@kingant.net>
parents: 6036
diff changeset
289 g_free(buddy->server_alias);
d5f4ae4f9a02 [gaim-migrate @ 6508]
Mark Doliner <mark@kingant.net>
parents: 6036
diff changeset
290
d5f4ae4f9a02 [gaim-migrate @ 6508]
Mark Doliner <mark@kingant.net>
parents: 6036
diff changeset
291 if(alias && strlen(alias) && g_utf8_validate(alias, -1, NULL))
d5f4ae4f9a02 [gaim-migrate @ 6508]
Mark Doliner <mark@kingant.net>
parents: 6036
diff changeset
292 buddy->server_alias = g_strdup(alias);
d5f4ae4f9a02 [gaim-migrate @ 6508]
Mark Doliner <mark@kingant.net>
parents: 6036
diff changeset
293 else
d5f4ae4f9a02 [gaim-migrate @ 6508]
Mark Doliner <mark@kingant.net>
parents: 6036
diff changeset
294 buddy->server_alias = NULL;
d5f4ae4f9a02 [gaim-migrate @ 6508]
Mark Doliner <mark@kingant.net>
parents: 6036
diff changeset
295
d5f4ae4f9a02 [gaim-migrate @ 6508]
Mark Doliner <mark@kingant.net>
parents: 6036
diff changeset
296 if (ops)
d5f4ae4f9a02 [gaim-migrate @ 6508]
Mark Doliner <mark@kingant.net>
parents: 6036
diff changeset
297 ops->update(gaimbuddylist, (GaimBlistNode*)buddy);
d5f4ae4f9a02 [gaim-migrate @ 6508]
Mark Doliner <mark@kingant.net>
parents: 6036
diff changeset
298
d5f4ae4f9a02 [gaim-migrate @ 6508]
Mark Doliner <mark@kingant.net>
parents: 6036
diff changeset
299 conv = gaim_find_conversation_with_account(buddy->name, buddy->account);
d5f4ae4f9a02 [gaim-migrate @ 6508]
Mark Doliner <mark@kingant.net>
parents: 6036
diff changeset
300
d5f4ae4f9a02 [gaim-migrate @ 6508]
Mark Doliner <mark@kingant.net>
parents: 6036
diff changeset
301 if (conv)
d5f4ae4f9a02 [gaim-migrate @ 6508]
Mark Doliner <mark@kingant.net>
parents: 6036
diff changeset
302 gaim_conversation_autoset_title(conv);
d5f4ae4f9a02 [gaim-migrate @ 6508]
Mark Doliner <mark@kingant.net>
parents: 6036
diff changeset
303 }
d5f4ae4f9a02 [gaim-migrate @ 6508]
Mark Doliner <mark@kingant.net>
parents: 6036
diff changeset
304
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
305 void gaim_blist_rename_group(struct group *group, const char *name)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
306 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
307 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
5346
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
308 struct group *dest_group;
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
309 GaimBlistNode *prev, *child, *next;
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
310 GSList *accts;
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
311
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
312 if(!name || !strlen(name) || !strcmp(name, group->name)) {
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
313 /* nothing to do here */
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
314 return;
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
315 } else if((dest_group = gaim_find_group(name))) {
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
316 /* here we're merging two groups */
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
317 prev = gaim_blist_get_last_child((GaimBlistNode*)dest_group);
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
318 child = ((GaimBlistNode*)group)->child;
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
319
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
320 while(child)
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
321 {
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
322 next = child->next;
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
323 if(GAIM_BLIST_NODE_IS_BUDDY(child)) {
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
324 gaim_blist_add_buddy((struct buddy *)child, dest_group, prev);
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
325 prev = child;
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
326 } else if(GAIM_BLIST_NODE_IS_CHAT(child)) {
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
327 gaim_blist_add_chat((struct chat *)child, dest_group, prev);
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
328 prev = child;
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
329 } else {
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
330 gaim_debug(GAIM_DEBUG_ERROR, "blist",
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
331 "Unknown child type in group %s\n", group->name);
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
332 }
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
333 child = next;
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
334 }
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
335 for (accts = gaim_group_get_accounts(group); accts; accts = g_slist_remove(accts, accts->data)) {
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
336 GaimAccount *account = accts->data;
5346
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
337 serv_rename_group(account->gc, group, name);
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
338 }
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
339 gaim_blist_remove_group(group);
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
340 } else {
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
341 /* a simple rename */
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
342 for (accts = gaim_group_get_accounts(group); accts; accts = g_slist_remove(accts, accts->data)) {
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
343 GaimAccount *account = accts->data;
5346
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
344 serv_rename_group(account->gc, group, name);
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
345 }
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
346 g_free(group->name);
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
347 group->name = g_strdup(name);
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
348 if (ops)
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
349 ops->update(gaimbuddylist, (GaimBlistNode*)group);
c1e7c3f72128 [gaim-migrate @ 5722]
Nathan Walp <nwalp@pidgin.im>
parents: 5313
diff changeset
350 }
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
351 }
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
352
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
353 struct chat *gaim_chat_new(GaimAccount *account, const char *alias, GHashTable *components)
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
354 {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
355 struct chat *chat;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
356 struct gaim_blist_ui_ops *ops;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
357
5237
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
358 if(!components)
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
359 return NULL;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
360
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
361 chat = g_new0(struct chat, 1);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
362 chat->account = account;
5237
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
363 if(alias && strlen(alias))
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
364 chat->alias = g_strdup(alias);
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
365 chat->components = components;
5906
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5874
diff changeset
366 chat->settings = g_hash_table_new_full(g_str_hash, g_str_equal,
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5874
diff changeset
367 g_free, g_free);
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
368
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
369 ((GaimBlistNode*)chat)->type = GAIM_BLIST_CHAT_NODE;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
370
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
371 ops = gaim_get_blist_ui_ops();
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
372
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
373 if (ops != NULL && ops->new_node != NULL)
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
374 ops->new_node((GaimBlistNode *)chat);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
375
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
376 return chat;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
377 }
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
378
6036
547ba881bc7e [gaim-migrate @ 6486]
Mark Doliner <mark@kingant.net>
parents: 6034
diff changeset
379 char *gaim_chat_get_display_name(struct chat *chat)
6034
5a0060191a77 [gaim-migrate @ 6484]
Luke Schierer <lschiere@pidgin.im>
parents: 6012
diff changeset
380 {
5a0060191a77 [gaim-migrate @ 6484]
Luke Schierer <lschiere@pidgin.im>
parents: 6012
diff changeset
381 char *name;
5a0060191a77 [gaim-migrate @ 6484]
Luke Schierer <lschiere@pidgin.im>
parents: 6012
diff changeset
382
5a0060191a77 [gaim-migrate @ 6484]
Luke Schierer <lschiere@pidgin.im>
parents: 6012
diff changeset
383 if(chat->alias){
5a0060191a77 [gaim-migrate @ 6484]
Luke Schierer <lschiere@pidgin.im>
parents: 6012
diff changeset
384 name = g_strdup(chat->alias);
5a0060191a77 [gaim-migrate @ 6484]
Luke Schierer <lschiere@pidgin.im>
parents: 6012
diff changeset
385 }
5a0060191a77 [gaim-migrate @ 6484]
Luke Schierer <lschiere@pidgin.im>
parents: 6012
diff changeset
386 else{
5a0060191a77 [gaim-migrate @ 6484]
Luke Schierer <lschiere@pidgin.im>
parents: 6012
diff changeset
387 GList *parts;
5a0060191a77 [gaim-migrate @ 6484]
Luke Schierer <lschiere@pidgin.im>
parents: 6012
diff changeset
388 GaimPlugin *prpl;
5a0060191a77 [gaim-migrate @ 6484]
Luke Schierer <lschiere@pidgin.im>
parents: 6012
diff changeset
389 GaimPluginProtocolInfo *prpl_info;
5a0060191a77 [gaim-migrate @ 6484]
Luke Schierer <lschiere@pidgin.im>
parents: 6012
diff changeset
390 struct proto_chat_entry *pce;
5a0060191a77 [gaim-migrate @ 6484]
Luke Schierer <lschiere@pidgin.im>
parents: 6012
diff changeset
391
5a0060191a77 [gaim-migrate @ 6484]
Luke Schierer <lschiere@pidgin.im>
parents: 6012
diff changeset
392 prpl = gaim_find_prpl(gaim_account_get_protocol(chat->account));
5a0060191a77 [gaim-migrate @ 6484]
Luke Schierer <lschiere@pidgin.im>
parents: 6012
diff changeset
393 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl);
5a0060191a77 [gaim-migrate @ 6484]
Luke Schierer <lschiere@pidgin.im>
parents: 6012
diff changeset
394
5a0060191a77 [gaim-migrate @ 6484]
Luke Schierer <lschiere@pidgin.im>
parents: 6012
diff changeset
395 parts = prpl_info->chat_info(chat->account->gc);
5a0060191a77 [gaim-migrate @ 6484]
Luke Schierer <lschiere@pidgin.im>
parents: 6012
diff changeset
396
5a0060191a77 [gaim-migrate @ 6484]
Luke Schierer <lschiere@pidgin.im>
parents: 6012
diff changeset
397 pce = parts->data;
5a0060191a77 [gaim-migrate @ 6484]
Luke Schierer <lschiere@pidgin.im>
parents: 6012
diff changeset
398 name = g_markup_escape_text(g_hash_table_lookup(chat->components,
5a0060191a77 [gaim-migrate @ 6484]
Luke Schierer <lschiere@pidgin.im>
parents: 6012
diff changeset
399 pce->identifier), -1);
5a0060191a77 [gaim-migrate @ 6484]
Luke Schierer <lschiere@pidgin.im>
parents: 6012
diff changeset
400 g_list_free(parts);
5a0060191a77 [gaim-migrate @ 6484]
Luke Schierer <lschiere@pidgin.im>
parents: 6012
diff changeset
401 }
5a0060191a77 [gaim-migrate @ 6484]
Luke Schierer <lschiere@pidgin.im>
parents: 6012
diff changeset
402
5a0060191a77 [gaim-migrate @ 6484]
Luke Schierer <lschiere@pidgin.im>
parents: 6012
diff changeset
403 return name;
5a0060191a77 [gaim-migrate @ 6484]
Luke Schierer <lschiere@pidgin.im>
parents: 6012
diff changeset
404 }
5a0060191a77 [gaim-migrate @ 6484]
Luke Schierer <lschiere@pidgin.im>
parents: 6012
diff changeset
405
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
406 struct buddy *gaim_buddy_new(GaimAccount *account, const char *screenname, const char *alias)
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
407 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
408 struct buddy *b;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
409 struct gaim_blist_ui_ops *ops;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
410
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
411 b = g_new0(struct buddy, 1);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
412 b->account = account;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
413 b->name = g_strdup(screenname);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
414 b->alias = g_strdup(alias);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
415 b->settings = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
416 ((GaimBlistNode*)b)->type = GAIM_BLIST_BUDDY_NODE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
417
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
418 ops = gaim_get_blist_ui_ops();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
419
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
420 if (ops != NULL && ops->new_node != NULL)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
421 ops->new_node((GaimBlistNode *)b);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
422
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
423 return b;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
424 }
5634
5946be17f9ec [gaim-migrate @ 6041]
Nathan Walp <nwalp@pidgin.im>
parents: 5580
diff changeset
425
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
426 void gaim_blist_add_chat(struct chat *chat, struct group *group, GaimBlistNode *node)
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
427 {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
428 GaimBlistNode *n = node, *cnode = (GaimBlistNode*)chat;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
429 struct group *g = group;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
430 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
431 gboolean save = FALSE;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
432
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
433 if (!n) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
434 if (!g) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
435 g = gaim_group_new(_("Chats"));
5634
5946be17f9ec [gaim-migrate @ 6041]
Nathan Walp <nwalp@pidgin.im>
parents: 5580
diff changeset
436 gaim_blist_add_group(g,
5946be17f9ec [gaim-migrate @ 6041]
Nathan Walp <nwalp@pidgin.im>
parents: 5580
diff changeset
437 gaim_blist_get_last_sibling(gaimbuddylist->root));
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
438 }
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
439 } else {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
440 g = (struct group*)n->parent;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
441 }
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
442
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
443 /* if we're moving to overtop of ourselves, do nothing */
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
444 if(cnode == n)
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
445 return;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
446
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
447 if (cnode->parent) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
448 /* This chat was already in the list and is
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
449 * being moved.
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
450 */
5277
d7771fe33cbd [gaim-migrate @ 5649]
Luke Schierer <lschiere@pidgin.im>
parents: 5266
diff changeset
451 ((struct group *)cnode->parent)->totalsize--;
5855
082982a4acbd [gaim-migrate @ 6286]
Nathan Walp <nwalp@pidgin.im>
parents: 5776
diff changeset
452 if (gaim_account_is_connected(chat->account)) {
5287
abd6d3abbe37 [gaim-migrate @ 5659]
Nathan Walp <nwalp@pidgin.im>
parents: 5278
diff changeset
453 ((struct group *)cnode->parent)->online--;
5277
d7771fe33cbd [gaim-migrate @ 5649]
Luke Schierer <lschiere@pidgin.im>
parents: 5266
diff changeset
454 ((struct group *)cnode->parent)->currentsize--;
5287
abd6d3abbe37 [gaim-migrate @ 5659]
Nathan Walp <nwalp@pidgin.im>
parents: 5278
diff changeset
455 }
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
456 if(cnode->next)
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
457 cnode->next->prev = cnode->prev;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
458 if(cnode->prev)
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
459 cnode->prev->next = cnode->next;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
460 if(cnode->parent->child == cnode)
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
461 cnode->parent->child = cnode->next;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
462
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
463 ops->remove(gaimbuddylist, cnode);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
464
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
465 save = TRUE;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
466 }
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
467
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
468 if (n) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
469 if(n->next)
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
470 n->next->prev = cnode;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
471 cnode->next = n->next;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
472 cnode->prev = n;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
473 cnode->parent = n->parent;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
474 n->next = cnode;
5277
d7771fe33cbd [gaim-migrate @ 5649]
Luke Schierer <lschiere@pidgin.im>
parents: 5266
diff changeset
475 ((struct group *)n->parent)->totalsize++;
5855
082982a4acbd [gaim-migrate @ 6286]
Nathan Walp <nwalp@pidgin.im>
parents: 5776
diff changeset
476 if (gaim_account_is_connected(chat->account)) {
5287
abd6d3abbe37 [gaim-migrate @ 5659]
Nathan Walp <nwalp@pidgin.im>
parents: 5278
diff changeset
477 ((struct group *)n->parent)->online++;
5277
d7771fe33cbd [gaim-migrate @ 5649]
Luke Schierer <lschiere@pidgin.im>
parents: 5266
diff changeset
478 ((struct group *)n->parent)->currentsize++;
5287
abd6d3abbe37 [gaim-migrate @ 5659]
Nathan Walp <nwalp@pidgin.im>
parents: 5278
diff changeset
479 }
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
480 } else {
5634
5946be17f9ec [gaim-migrate @ 6041]
Nathan Walp <nwalp@pidgin.im>
parents: 5580
diff changeset
481 if(((GaimBlistNode*)g)->child)
5946be17f9ec [gaim-migrate @ 6041]
Nathan Walp <nwalp@pidgin.im>
parents: 5580
diff changeset
482 ((GaimBlistNode*)g)->child->prev = cnode;
5946be17f9ec [gaim-migrate @ 6041]
Nathan Walp <nwalp@pidgin.im>
parents: 5580
diff changeset
483 cnode->next = ((GaimBlistNode*)g)->child;
5946be17f9ec [gaim-migrate @ 6041]
Nathan Walp <nwalp@pidgin.im>
parents: 5580
diff changeset
484 cnode->prev = NULL;
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
485 ((GaimBlistNode*)g)->child = cnode;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
486 cnode->parent = (GaimBlistNode*)g;
5277
d7771fe33cbd [gaim-migrate @ 5649]
Luke Schierer <lschiere@pidgin.im>
parents: 5266
diff changeset
487 g->totalsize++;
5855
082982a4acbd [gaim-migrate @ 6286]
Nathan Walp <nwalp@pidgin.im>
parents: 5776
diff changeset
488 if (gaim_account_is_connected(chat->account)) {
5287
abd6d3abbe37 [gaim-migrate @ 5659]
Nathan Walp <nwalp@pidgin.im>
parents: 5278
diff changeset
489 g->online++;
5277
d7771fe33cbd [gaim-migrate @ 5649]
Luke Schierer <lschiere@pidgin.im>
parents: 5266
diff changeset
490 g->currentsize++;
5287
abd6d3abbe37 [gaim-migrate @ 5659]
Nathan Walp <nwalp@pidgin.im>
parents: 5278
diff changeset
491 }
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
492 }
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
493
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
494 if (ops)
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
495 ops->update(gaimbuddylist, (GaimBlistNode*)cnode);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
496 if (save)
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
497 gaim_blist_save();
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
498 }
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
499
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
500 void gaim_blist_add_buddy (struct buddy *buddy, struct group *group, GaimBlistNode *node)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
501 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
502 GaimBlistNode *n = node, *bnode = (GaimBlistNode*)buddy;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
503 struct group *g = group;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
504 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
5247
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
505 struct _gaim_hbuddy *hb;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
506 gboolean save = FALSE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
507
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
508 if (!n) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
509 if (!g) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
510 g = gaim_group_new(_("Buddies"));
5634
5946be17f9ec [gaim-migrate @ 6041]
Nathan Walp <nwalp@pidgin.im>
parents: 5580
diff changeset
511 gaim_blist_add_group(g,
5946be17f9ec [gaim-migrate @ 6041]
Nathan Walp <nwalp@pidgin.im>
parents: 5580
diff changeset
512 gaim_blist_get_last_sibling(gaimbuddylist->root));
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
513 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
514 } else {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
515 g = (struct group*)n->parent;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
516 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
517
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
518 /* if we're moving to overtop of ourselves, do nothing */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
519 if(bnode == n)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
520 return;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
521
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
522 if (bnode->parent) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
523 /* This buddy was already in the list and is
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
524 * being moved.
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
525 */
5394
08a90a9e28e4 [gaim-migrate @ 5770]
Nathan Walp <nwalp@pidgin.im>
parents: 5392
diff changeset
526 ((struct group *)bnode->parent)->totalsize--;
5855
082982a4acbd [gaim-migrate @ 6286]
Nathan Walp <nwalp@pidgin.im>
parents: 5776
diff changeset
527 if (gaim_account_is_connected(buddy->account))
5277
d7771fe33cbd [gaim-migrate @ 5649]
Luke Schierer <lschiere@pidgin.im>
parents: 5266
diff changeset
528 ((struct group *)bnode->parent)->currentsize--;
5394
08a90a9e28e4 [gaim-migrate @ 5770]
Nathan Walp <nwalp@pidgin.im>
parents: 5392
diff changeset
529 if (GAIM_BUDDY_IS_ONLINE(buddy))
5313
8d118c2b03c9 [gaim-migrate @ 5685]
Nathan Walp <nwalp@pidgin.im>
parents: 5305
diff changeset
530 ((struct group *)bnode->parent)->online--;
5277
d7771fe33cbd [gaim-migrate @ 5649]
Luke Schierer <lschiere@pidgin.im>
parents: 5266
diff changeset
531
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
532 if(bnode->next)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
533 bnode->next->prev = bnode->prev;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
534 if(bnode->prev)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
535 bnode->prev->next = bnode->next;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
536 if(bnode->parent->child == bnode)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
537 bnode->parent->child = bnode->next;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
538
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
539 ops->remove(gaimbuddylist, bnode);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
540
5277
d7771fe33cbd [gaim-migrate @ 5649]
Luke Schierer <lschiere@pidgin.im>
parents: 5266
diff changeset
541 if (bnode->parent != ((GaimBlistNode*)g)) {
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
542 serv_move_buddy(buddy, (struct group*)bnode->parent, g);
5277
d7771fe33cbd [gaim-migrate @ 5649]
Luke Schierer <lschiere@pidgin.im>
parents: 5266
diff changeset
543 }
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
544 save = TRUE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
545 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
546
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
547 if (n) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
548 if(n->next)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
549 n->next->prev = (GaimBlistNode*)buddy;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
550 ((GaimBlistNode*)buddy)->next = n->next;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
551 ((GaimBlistNode*)buddy)->prev = n;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
552 ((GaimBlistNode*)buddy)->parent = n->parent;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
553 n->next = (GaimBlistNode*)buddy;
5277
d7771fe33cbd [gaim-migrate @ 5649]
Luke Schierer <lschiere@pidgin.im>
parents: 5266
diff changeset
554 ((struct group *)n->parent)->totalsize++;
5855
082982a4acbd [gaim-migrate @ 6286]
Nathan Walp <nwalp@pidgin.im>
parents: 5776
diff changeset
555 if (gaim_account_is_connected(buddy->account))
5277
d7771fe33cbd [gaim-migrate @ 5649]
Luke Schierer <lschiere@pidgin.im>
parents: 5266
diff changeset
556 ((struct group *)n->parent)->currentsize++;
5394
08a90a9e28e4 [gaim-migrate @ 5770]
Nathan Walp <nwalp@pidgin.im>
parents: 5392
diff changeset
557 if (GAIM_BUDDY_IS_ONLINE(buddy))
5313
8d118c2b03c9 [gaim-migrate @ 5685]
Nathan Walp <nwalp@pidgin.im>
parents: 5305
diff changeset
558 ((struct group *)n->parent)->online++;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
559 } else {
5634
5946be17f9ec [gaim-migrate @ 6041]
Nathan Walp <nwalp@pidgin.im>
parents: 5580
diff changeset
560 if(((GaimBlistNode*)g)->child)
5946be17f9ec [gaim-migrate @ 6041]
Nathan Walp <nwalp@pidgin.im>
parents: 5580
diff changeset
561 ((GaimBlistNode*)g)->child->prev = (GaimBlistNode*)buddy;
5946be17f9ec [gaim-migrate @ 6041]
Nathan Walp <nwalp@pidgin.im>
parents: 5580
diff changeset
562 ((GaimBlistNode*)buddy)->prev = NULL;
5946be17f9ec [gaim-migrate @ 6041]
Nathan Walp <nwalp@pidgin.im>
parents: 5580
diff changeset
563 ((GaimBlistNode*)buddy)->next = ((GaimBlistNode*)g)->child;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
564 ((GaimBlistNode*)g)->child = (GaimBlistNode*)buddy;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
565 ((GaimBlistNode*)buddy)->parent = (GaimBlistNode*)g;
5277
d7771fe33cbd [gaim-migrate @ 5649]
Luke Schierer <lschiere@pidgin.im>
parents: 5266
diff changeset
566 g->totalsize++;
5855
082982a4acbd [gaim-migrate @ 6286]
Nathan Walp <nwalp@pidgin.im>
parents: 5776
diff changeset
567 if (gaim_account_is_connected(buddy->account))
5277
d7771fe33cbd [gaim-migrate @ 5649]
Luke Schierer <lschiere@pidgin.im>
parents: 5266
diff changeset
568 g->currentsize++;
5394
08a90a9e28e4 [gaim-migrate @ 5770]
Nathan Walp <nwalp@pidgin.im>
parents: 5392
diff changeset
569 if (GAIM_BUDDY_IS_ONLINE(buddy))
5313
8d118c2b03c9 [gaim-migrate @ 5685]
Nathan Walp <nwalp@pidgin.im>
parents: 5305
diff changeset
570 g->online++;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
571 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
572
5247
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
573 hb = g_malloc(sizeof(struct _gaim_hbuddy));
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
574 hb->name = g_strdup(normalize(buddy->name));
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
575 hb->account = buddy->account;
5758
666b04f93c55 [gaim-migrate @ 6183]
Sean Egan <seanegan@gmail.com>
parents: 5676
diff changeset
576 hb->group = ((GaimBlistNode*)buddy)->parent;
5247
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
577
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
578 if (g_hash_table_lookup(gaimbuddylist->buddies, (gpointer)hb)) {
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
579 /* This guy already exists */
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
580 g_free(hb->name);
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
581 g_free(hb);
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
582 } else {
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
583 g_hash_table_insert(gaimbuddylist->buddies, (gpointer)hb, (gpointer)buddy);
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
584 }
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
585
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
586 if (ops)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
587 ops->update(gaimbuddylist, (GaimBlistNode*)buddy);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
588 if (save)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
589 gaim_blist_save();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
590 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
591
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
592 struct group *gaim_group_new(const char *name)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
593 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
594 struct group *g = gaim_find_group(name);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
595
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
596 if (!g) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
597 struct gaim_blist_ui_ops *ops;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
598 g= g_new0(struct group, 1);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
599 g->name = g_strdup(name);
5277
d7771fe33cbd [gaim-migrate @ 5649]
Luke Schierer <lschiere@pidgin.im>
parents: 5266
diff changeset
600 g->totalsize = 0;
d7771fe33cbd [gaim-migrate @ 5649]
Luke Schierer <lschiere@pidgin.im>
parents: 5266
diff changeset
601 g->currentsize = 0;
d7771fe33cbd [gaim-migrate @ 5649]
Luke Schierer <lschiere@pidgin.im>
parents: 5266
diff changeset
602 g->online = 0;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
603 g->settings = g_hash_table_new_full(g_str_hash, g_str_equal,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
604 g_free, g_free);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
605 ((GaimBlistNode*)g)->type = GAIM_BLIST_GROUP_NODE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
606
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
607 ops = gaim_get_blist_ui_ops();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
608
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
609 if (ops != NULL && ops->new_node != NULL)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
610 ops->new_node((GaimBlistNode *)g);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
611
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
612 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
613 return g;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
614 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
615
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
616 void gaim_blist_add_group (struct group *group, GaimBlistNode *node)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
617 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
618 struct gaim_blist_ui_ops *ops;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
619 GaimBlistNode *gnode = (GaimBlistNode*)group;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
620 gboolean save = FALSE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
621
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
622 if (!gaimbuddylist)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
623 gaimbuddylist = gaim_blist_new();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
624 ops = gaimbuddylist->ui_ops;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
625
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
626 if (!gaimbuddylist->root) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
627 gaimbuddylist->root = gnode;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
628 return;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
629 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
630
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
631 /* if we're moving to overtop of ourselves, do nothing */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
632 if(gnode == node)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
633 return;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
634
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
635 if (gaim_find_group(group->name)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
636 /* This is just being moved */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
637
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
638 ops->remove(gaimbuddylist, (GaimBlistNode*)group);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
639
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
640 if(gnode == gaimbuddylist->root)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
641 gaimbuddylist->root = gnode->next;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
642 if(gnode->prev)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
643 gnode->prev->next = gnode->next;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
644 if(gnode->next)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
645 gnode->next->prev = gnode->prev;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
646
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
647 save = TRUE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
648 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
649
5634
5946be17f9ec [gaim-migrate @ 6041]
Nathan Walp <nwalp@pidgin.im>
parents: 5580
diff changeset
650 if (node) {
5946be17f9ec [gaim-migrate @ 6041]
Nathan Walp <nwalp@pidgin.im>
parents: 5580
diff changeset
651 gnode->next = node->next;
5946be17f9ec [gaim-migrate @ 6041]
Nathan Walp <nwalp@pidgin.im>
parents: 5580
diff changeset
652 gnode->prev = node;
5946be17f9ec [gaim-migrate @ 6041]
Nathan Walp <nwalp@pidgin.im>
parents: 5580
diff changeset
653 if(node->next)
5946be17f9ec [gaim-migrate @ 6041]
Nathan Walp <nwalp@pidgin.im>
parents: 5580
diff changeset
654 node->next->prev = gnode;
5946be17f9ec [gaim-migrate @ 6041]
Nathan Walp <nwalp@pidgin.im>
parents: 5580
diff changeset
655 node->next = gnode;
5946be17f9ec [gaim-migrate @ 6041]
Nathan Walp <nwalp@pidgin.im>
parents: 5580
diff changeset
656 } else {
5946be17f9ec [gaim-migrate @ 6041]
Nathan Walp <nwalp@pidgin.im>
parents: 5580
diff changeset
657 gaimbuddylist->root->prev = gnode;
5946be17f9ec [gaim-migrate @ 6041]
Nathan Walp <nwalp@pidgin.im>
parents: 5580
diff changeset
658 gnode->next = gaimbuddylist->root;
5946be17f9ec [gaim-migrate @ 6041]
Nathan Walp <nwalp@pidgin.im>
parents: 5580
diff changeset
659 gnode->prev = NULL;
5946be17f9ec [gaim-migrate @ 6041]
Nathan Walp <nwalp@pidgin.im>
parents: 5580
diff changeset
660 gaimbuddylist->root = gnode;
5946be17f9ec [gaim-migrate @ 6041]
Nathan Walp <nwalp@pidgin.im>
parents: 5580
diff changeset
661 }
5946be17f9ec [gaim-migrate @ 6041]
Nathan Walp <nwalp@pidgin.im>
parents: 5580
diff changeset
662
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
663
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
664 if (ops) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
665 ops->update(gaimbuddylist, gnode);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
666 for(node = gnode->child; node; node = node->next)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
667 ops->update(gaimbuddylist, node);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
668 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
669 if (save)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
670 gaim_blist_save();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
671 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
672
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
673 void gaim_blist_remove_buddy (struct buddy *buddy)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
674 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
675 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
676
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
677 GaimBlistNode *gnode, *node = (GaimBlistNode*)buddy;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
678 struct group *group;
5247
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
679 struct _gaim_hbuddy hb, *key;
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
680 struct buddy *val;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
681
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
682 gnode = node->parent;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
683 group = (struct group *)gnode;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
684
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
685 if(gnode->child == node)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
686 gnode->child = node->next;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
687 if (node->prev)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
688 node->prev->next = node->next;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
689 if (node->next)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
690 node->next->prev = node->prev;
5394
08a90a9e28e4 [gaim-migrate @ 5770]
Nathan Walp <nwalp@pidgin.im>
parents: 5392
diff changeset
691 group->totalsize--;
5855
082982a4acbd [gaim-migrate @ 6286]
Nathan Walp <nwalp@pidgin.im>
parents: 5776
diff changeset
692 if (gaim_account_is_connected(buddy->account))
5277
d7771fe33cbd [gaim-migrate @ 5649]
Luke Schierer <lschiere@pidgin.im>
parents: 5266
diff changeset
693 group->currentsize--;
5394
08a90a9e28e4 [gaim-migrate @ 5770]
Nathan Walp <nwalp@pidgin.im>
parents: 5392
diff changeset
694 if (GAIM_BUDDY_IS_ONLINE(buddy))
08a90a9e28e4 [gaim-migrate @ 5770]
Nathan Walp <nwalp@pidgin.im>
parents: 5392
diff changeset
695 group->online--;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
696
5247
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
697 hb.name = normalize(buddy->name);
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
698 hb.account = buddy->account;
5758
666b04f93c55 [gaim-migrate @ 6183]
Sean Egan <seanegan@gmail.com>
parents: 5676
diff changeset
699 hb.group = ((GaimBlistNode*)buddy)->parent;
5247
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
700 if (g_hash_table_lookup_extended(gaimbuddylist->buddies, &hb, (gpointer *)&key, (gpointer *)&val)) {
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
701 g_hash_table_remove(gaimbuddylist->buddies, &hb);
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
702 g_free(key->name);
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
703 g_free(key);
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
704 }
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
705
5292
436c83d60be0 [gaim-migrate @ 5664]
Nathan Walp <nwalp@pidgin.im>
parents: 5287
diff changeset
706 if(buddy->timer > 0)
436c83d60be0 [gaim-migrate @ 5664]
Nathan Walp <nwalp@pidgin.im>
parents: 5287
diff changeset
707 g_source_remove(buddy->timer);
436c83d60be0 [gaim-migrate @ 5664]
Nathan Walp <nwalp@pidgin.im>
parents: 5287
diff changeset
708
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
709 ops->remove(gaimbuddylist, node);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
710 g_hash_table_destroy(buddy->settings);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
711 g_free(buddy->name);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
712 g_free(buddy->alias);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
713 g_free(buddy);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
714 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
715
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
716 void gaim_blist_remove_chat (struct chat *chat)
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
717 {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
718 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
719
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
720 GaimBlistNode *gnode, *node = (GaimBlistNode*)chat;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
721 struct group *group;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
722
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
723 gnode = node->parent;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
724 group = (struct group *)gnode;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
725
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
726 if(gnode->child == node)
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
727 gnode->child = node->next;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
728 if (node->prev)
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
729 node->prev->next = node->next;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
730 if (node->next)
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
731 node->next->prev = node->prev;
5277
d7771fe33cbd [gaim-migrate @ 5649]
Luke Schierer <lschiere@pidgin.im>
parents: 5266
diff changeset
732 group->totalsize--;
5855
082982a4acbd [gaim-migrate @ 6286]
Nathan Walp <nwalp@pidgin.im>
parents: 5776
diff changeset
733 if (gaim_account_is_connected(chat->account)) {
5277
d7771fe33cbd [gaim-migrate @ 5649]
Luke Schierer <lschiere@pidgin.im>
parents: 5266
diff changeset
734 group->currentsize--;
5394
08a90a9e28e4 [gaim-migrate @ 5770]
Nathan Walp <nwalp@pidgin.im>
parents: 5392
diff changeset
735 group->online--;
08a90a9e28e4 [gaim-migrate @ 5770]
Nathan Walp <nwalp@pidgin.im>
parents: 5392
diff changeset
736 }
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
737
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
738 ops->remove(gaimbuddylist, node);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
739 g_hash_table_destroy(chat->components);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
740 g_free(chat->alias);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
741 g_free(chat);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
742 }
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
743
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
744 void gaim_blist_remove_group (struct group *group)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
745 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
746 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
747 GaimBlistNode *node = (GaimBlistNode*)group;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
748
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
749 if(node->child) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
750 char *buf;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
751 int count = 0;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
752 GaimBlistNode *child = node->child;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
753
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
754 while(child) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
755 count++;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
756 child = child->next;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
757 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
758
6308
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 6307
diff changeset
759 buf = g_strdup_printf(ngettext("%d buddy from group %s was not removed "
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 6307
diff changeset
760 "because its account was not logged in."
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 6307
diff changeset
761 " This buddy and the group were not "
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 6307
diff changeset
762 "removed.\n",
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 6307
diff changeset
763 "%d buddies from group %s were not "
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 6307
diff changeset
764 "removed because their accounts were "
6336
aeb8c2119a58 [gaim-migrate @ 6835]
Mark Doliner <mark@kingant.net>
parents: 6322
diff changeset
765 "not logged in. These buddies and "
aeb8c2119a58 [gaim-migrate @ 6835]
Mark Doliner <mark@kingant.net>
parents: 6322
diff changeset
766 "the group were not removed.\n", count),
6308
a21cf07cd8e1 [gaim-migrate @ 6807]
Mark Doliner <mark@kingant.net>
parents: 6307
diff changeset
767 count, group->name);
5541
aee0ee458974 [gaim-migrate @ 5941]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
768 gaim_notify_error(NULL, NULL, _("Group not removed"), buf);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
769 g_free(buf);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
770 return;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
771 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
772
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
773 if(gaimbuddylist->root == node)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
774 gaimbuddylist->root = node->next;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
775 if (node->prev)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
776 node->prev->next = node->next;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
777 if (node->next)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
778 node->next->prev = node->prev;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
779
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
780 ops->remove(gaimbuddylist, node);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
781 g_free(group->name);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
782 g_free(group);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
783 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
784
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
785 char *gaim_get_buddy_alias_only(struct buddy *b) {
5545
7a64114641c3 [gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents: 5541
diff changeset
786 if(!b)
7a64114641c3 [gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents: 5541
diff changeset
787 return NULL;
7a64114641c3 [gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents: 5541
diff changeset
788
7a64114641c3 [gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents: 5541
diff changeset
789 if(b->alias && b->alias[0]) {
7a64114641c3 [gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents: 5541
diff changeset
790 return b->alias;
7a64114641c3 [gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents: 5541
diff changeset
791 }
7a64114641c3 [gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents: 5541
diff changeset
792 else if (b->server_alias != NULL &&
7a64114641c3 [gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents: 5541
diff changeset
793 gaim_prefs_get_bool("/core/buddies/use_server_alias")) {
7a64114641c3 [gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents: 5541
diff changeset
794
7a64114641c3 [gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents: 5541
diff changeset
795 return b->server_alias;
7a64114641c3 [gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents: 5541
diff changeset
796 }
7a64114641c3 [gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents: 5541
diff changeset
797
7a64114641c3 [gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents: 5541
diff changeset
798 return NULL;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
799 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
800
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
801 char * gaim_get_buddy_alias (struct buddy *buddy)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
802 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
803 char *ret = gaim_get_buddy_alias_only(buddy);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
804
6036
547ba881bc7e [gaim-migrate @ 6486]
Mark Doliner <mark@kingant.net>
parents: 6034
diff changeset
805 if(!ret)
547ba881bc7e [gaim-migrate @ 6486]
Mark Doliner <mark@kingant.net>
parents: 6034
diff changeset
806 return buddy ? buddy->name : _("Unknown");
547ba881bc7e [gaim-migrate @ 6486]
Mark Doliner <mark@kingant.net>
parents: 6034
diff changeset
807
547ba881bc7e [gaim-migrate @ 6486]
Mark Doliner <mark@kingant.net>
parents: 6034
diff changeset
808 return ret;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
809 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
810
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
811 struct buddy *gaim_find_buddy(GaimAccount *account, const char *name)
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
812 {
6245
9083f92e0d58 [gaim-migrate @ 6739]
Nathan Walp <nwalp@pidgin.im>
parents: 6116
diff changeset
813 struct buddy *buddy;
5247
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
814 struct _gaim_hbuddy hb;
5758
666b04f93c55 [gaim-migrate @ 6183]
Sean Egan <seanegan@gmail.com>
parents: 5676
diff changeset
815 GaimBlistNode *group;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
816
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
817 if (!gaimbuddylist)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
818 return NULL;
6245
9083f92e0d58 [gaim-migrate @ 6739]
Nathan Walp <nwalp@pidgin.im>
parents: 6116
diff changeset
819
9083f92e0d58 [gaim-migrate @ 6739]
Nathan Walp <nwalp@pidgin.im>
parents: 6116
diff changeset
820 if (!name)
5985
60d9cbfb6bf8 [gaim-migrate @ 6433]
Christian Hammond <chipx86@chipx86.com>
parents: 5947
diff changeset
821 return NULL;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
822
6245
9083f92e0d58 [gaim-migrate @ 6739]
Nathan Walp <nwalp@pidgin.im>
parents: 6116
diff changeset
823 hb.name = normalize(name);
9083f92e0d58 [gaim-migrate @ 6739]
Nathan Walp <nwalp@pidgin.im>
parents: 6116
diff changeset
824 hb.account = account;
5247
60983a46700e [gaim-migrate @ 5618]
Luke Schierer <lschiere@pidgin.im>
parents: 5237
diff changeset
825
6245
9083f92e0d58 [gaim-migrate @ 6739]
Nathan Walp <nwalp@pidgin.im>
parents: 6116
diff changeset
826 for(group = gaimbuddylist->root; group; group = group->next) {
5758
666b04f93c55 [gaim-migrate @ 6183]
Sean Egan <seanegan@gmail.com>
parents: 5676
diff changeset
827 hb.group = group;
5776
147f4c25af15 [gaim-migrate @ 6201]
Nathan Walp <nwalp@pidgin.im>
parents: 5758
diff changeset
828 if ((buddy = g_hash_table_lookup(gaimbuddylist->buddies, &hb)) != NULL)
5758
666b04f93c55 [gaim-migrate @ 6183]
Sean Egan <seanegan@gmail.com>
parents: 5676
diff changeset
829 return buddy;
666b04f93c55 [gaim-migrate @ 6183]
Sean Egan <seanegan@gmail.com>
parents: 5676
diff changeset
830 }
6245
9083f92e0d58 [gaim-migrate @ 6739]
Nathan Walp <nwalp@pidgin.im>
parents: 6116
diff changeset
831
5758
666b04f93c55 [gaim-migrate @ 6183]
Sean Egan <seanegan@gmail.com>
parents: 5676
diff changeset
832 return NULL;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
833 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
834
6245
9083f92e0d58 [gaim-migrate @ 6739]
Nathan Walp <nwalp@pidgin.im>
parents: 6116
diff changeset
835 GSList *gaim_find_buddies(GaimAccount *account, const char *name)
9083f92e0d58 [gaim-migrate @ 6739]
Nathan Walp <nwalp@pidgin.im>
parents: 6116
diff changeset
836 {
9083f92e0d58 [gaim-migrate @ 6739]
Nathan Walp <nwalp@pidgin.im>
parents: 6116
diff changeset
837 struct buddy *buddy;
9083f92e0d58 [gaim-migrate @ 6739]
Nathan Walp <nwalp@pidgin.im>
parents: 6116
diff changeset
838 struct _gaim_hbuddy hb;
9083f92e0d58 [gaim-migrate @ 6739]
Nathan Walp <nwalp@pidgin.im>
parents: 6116
diff changeset
839 GaimBlistNode *group;
9083f92e0d58 [gaim-migrate @ 6739]
Nathan Walp <nwalp@pidgin.im>
parents: 6116
diff changeset
840 GSList *ret = NULL;
9083f92e0d58 [gaim-migrate @ 6739]
Nathan Walp <nwalp@pidgin.im>
parents: 6116
diff changeset
841
9083f92e0d58 [gaim-migrate @ 6739]
Nathan Walp <nwalp@pidgin.im>
parents: 6116
diff changeset
842 if (!gaimbuddylist)
9083f92e0d58 [gaim-migrate @ 6739]
Nathan Walp <nwalp@pidgin.im>
parents: 6116
diff changeset
843 return NULL;
9083f92e0d58 [gaim-migrate @ 6739]
Nathan Walp <nwalp@pidgin.im>
parents: 6116
diff changeset
844
9083f92e0d58 [gaim-migrate @ 6739]
Nathan Walp <nwalp@pidgin.im>
parents: 6116
diff changeset
845 if (!name)
9083f92e0d58 [gaim-migrate @ 6739]
Nathan Walp <nwalp@pidgin.im>
parents: 6116
diff changeset
846 return NULL;
9083f92e0d58 [gaim-migrate @ 6739]
Nathan Walp <nwalp@pidgin.im>
parents: 6116
diff changeset
847
9083f92e0d58 [gaim-migrate @ 6739]
Nathan Walp <nwalp@pidgin.im>
parents: 6116
diff changeset
848 hb.name = normalize(name);
9083f92e0d58 [gaim-migrate @ 6739]
Nathan Walp <nwalp@pidgin.im>
parents: 6116
diff changeset
849 hb.account = account;
9083f92e0d58 [gaim-migrate @ 6739]
Nathan Walp <nwalp@pidgin.im>
parents: 6116
diff changeset
850
9083f92e0d58 [gaim-migrate @ 6739]
Nathan Walp <nwalp@pidgin.im>
parents: 6116
diff changeset
851 for(group = gaimbuddylist->root; group; group = group->next) {
9083f92e0d58 [gaim-migrate @ 6739]
Nathan Walp <nwalp@pidgin.im>
parents: 6116
diff changeset
852 hb.group = group;
9083f92e0d58 [gaim-migrate @ 6739]
Nathan Walp <nwalp@pidgin.im>
parents: 6116
diff changeset
853 if ((buddy = g_hash_table_lookup(gaimbuddylist->buddies, &hb)) != NULL)
9083f92e0d58 [gaim-migrate @ 6739]
Nathan Walp <nwalp@pidgin.im>
parents: 6116
diff changeset
854 ret = g_slist_append(ret, buddy);
9083f92e0d58 [gaim-migrate @ 6739]
Nathan Walp <nwalp@pidgin.im>
parents: 6116
diff changeset
855 }
9083f92e0d58 [gaim-migrate @ 6739]
Nathan Walp <nwalp@pidgin.im>
parents: 6116
diff changeset
856
9083f92e0d58 [gaim-migrate @ 6739]
Nathan Walp <nwalp@pidgin.im>
parents: 6116
diff changeset
857 return ret;
9083f92e0d58 [gaim-migrate @ 6739]
Nathan Walp <nwalp@pidgin.im>
parents: 6116
diff changeset
858 }
9083f92e0d58 [gaim-migrate @ 6739]
Nathan Walp <nwalp@pidgin.im>
parents: 6116
diff changeset
859
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
860 struct group *gaim_find_group(const char *name)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
861 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
862 GaimBlistNode *node;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
863 if (!gaimbuddylist)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
864 return NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
865 node = gaimbuddylist->root;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
866 while(node) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
867 if (!strcmp(((struct group*)node)->name, name))
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
868 return (struct group*)node;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
869 node = node->next;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
870 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
871 return NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
872 }
6456
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
873
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
874 struct chat *
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
875 gaim_blist_find_chat(GaimAccount *account, const char *name)
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
876 {
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
877 char *chat_name;
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
878 struct chat *chat;
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
879 GaimPlugin *prpl;
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
880 GaimPluginProtocolInfo *prpl_info = NULL;
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
881 struct proto_chat_entry *pce;
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
882 GaimBlistNode *node, *group;
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
883 GList *parts;
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
884
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
885 g_return_val_if_fail(gaim_get_blist() != NULL, NULL);
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
886 g_return_val_if_fail(name != NULL, NULL);
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
887
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
888 for (group = gaimbuddylist->root; group != NULL; group = group->next) {
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
889 for (node = group->child; node != NULL; node = node->next) {
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
890 if (GAIM_BLIST_NODE_IS_CHAT(node)) {
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
891
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
892 chat = (struct chat *)node;
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
893
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
894 prpl = gaim_find_prpl(gaim_account_get_protocol(chat->account));
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
895 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl);
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
896
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
897 parts = prpl_info->chat_info(
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
898 gaim_account_get_connection(chat->account));
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
899
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
900 pce = parts->data;
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
901 chat_name = g_hash_table_lookup(chat->components,
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
902 pce->identifier);
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
903
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
904 if (chat->account == account &&
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
905 name != NULL && !strcmp(chat_name, name)) {
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
906
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
907 return chat;
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
908 }
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
909 }
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
910 }
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
911 }
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
912
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
913 return NULL;
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
914 }
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
915
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
916 struct group *
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
917 gaim_blist_chat_get_group(struct chat *chat)
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
918 {
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
919 g_return_val_if_fail(chat != NULL, NULL);
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
920
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
921 return (struct group *)(((GaimBlistNode *)chat)->parent);
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
922 }
ccfdf9f2cdd1 [gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents: 6450
diff changeset
923
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
924 struct group *gaim_find_buddys_group(struct buddy *buddy)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
925 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
926 if (!buddy)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
927 return NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
928 return (struct group*)(((GaimBlistNode*)buddy)->parent);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
929 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
930
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
931 GSList *gaim_group_get_accounts(struct group *g)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
932 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
933 GSList *l = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
934 GaimBlistNode *child = ((GaimBlistNode *)g)->child;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
935
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
936 while (child) {
6322
dd2be7cd66df [gaim-migrate @ 6821]
Mark Doliner <mark@kingant.net>
parents: 6308
diff changeset
937 GaimAccount *account = NULL;
dd2be7cd66df [gaim-migrate @ 6821]
Mark Doliner <mark@kingant.net>
parents: 6308
diff changeset
938 if (GAIM_BLIST_NODE_IS_BUDDY(child))
dd2be7cd66df [gaim-migrate @ 6821]
Mark Doliner <mark@kingant.net>
parents: 6308
diff changeset
939 account = ((struct buddy *)child)->account;
dd2be7cd66df [gaim-migrate @ 6821]
Mark Doliner <mark@kingant.net>
parents: 6308
diff changeset
940 else if (GAIM_BLIST_NODE_IS_CHAT(child))
dd2be7cd66df [gaim-migrate @ 6821]
Mark Doliner <mark@kingant.net>
parents: 6308
diff changeset
941 account = ((struct chat *)child)->account;
dd2be7cd66df [gaim-migrate @ 6821]
Mark Doliner <mark@kingant.net>
parents: 6308
diff changeset
942 if (!g_slist_find(l, account))
dd2be7cd66df [gaim-migrate @ 6821]
Mark Doliner <mark@kingant.net>
parents: 6308
diff changeset
943 l = g_slist_append(l, account);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
944 child = child->next;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
945 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
946 return l;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
947 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
948
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
949 void gaim_blist_add_account(GaimAccount *account)
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
950 {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
951 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
952 GaimBlistNode *group, *buddy;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
953
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
954 if(!gaimbuddylist)
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
955 return;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
956
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
957 for(group = gaimbuddylist->root; group; group = group->next) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
958 if(!GAIM_BLIST_NODE_IS_GROUP(group))
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
959 continue;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
960 for(buddy = group->child; buddy; buddy = buddy->next) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
961 if(GAIM_BLIST_NODE_IS_BUDDY(buddy)) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
962 if (account == ((struct buddy*)buddy)->account) {
5277
d7771fe33cbd [gaim-migrate @ 5649]
Luke Schierer <lschiere@pidgin.im>
parents: 5266
diff changeset
963 ((struct group *)group)->currentsize++;
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
964 if(ops)
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
965 ops->update(gaimbuddylist, buddy);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
966 }
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
967 } else if(GAIM_BLIST_NODE_IS_CHAT(buddy)) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
968 if (account == ((struct chat*)buddy)->account) {
5287
abd6d3abbe37 [gaim-migrate @ 5659]
Nathan Walp <nwalp@pidgin.im>
parents: 5278
diff changeset
969 ((struct group *)group)->online++;
5277
d7771fe33cbd [gaim-migrate @ 5649]
Luke Schierer <lschiere@pidgin.im>
parents: 5266
diff changeset
970 ((struct group *)group)->currentsize++;
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
971 if(ops)
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
972 ops->update(gaimbuddylist, buddy);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
973 }
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
974 }
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
975 }
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
976 }
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
977 }
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
978
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
979 void gaim_blist_remove_account(GaimAccount *account)
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
980 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
981 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
982 GaimBlistNode *group, *buddy;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
983
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
984 if (!gaimbuddylist)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
985 return;
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
986
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
987 for(group = gaimbuddylist->root; group; group = group->next) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
988 if(!GAIM_BLIST_NODE_IS_GROUP(group))
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
989 continue;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
990 for(buddy = group->child; buddy; buddy = buddy->next) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
991 if(GAIM_BLIST_NODE_IS_BUDDY(buddy)) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
992 if (account == ((struct buddy*)buddy)->account) {
5394
08a90a9e28e4 [gaim-migrate @ 5770]
Nathan Walp <nwalp@pidgin.im>
parents: 5392
diff changeset
993 if (GAIM_BUDDY_IS_ONLINE((struct buddy*)buddy))
5277
d7771fe33cbd [gaim-migrate @ 5649]
Luke Schierer <lschiere@pidgin.im>
parents: 5266
diff changeset
994 ((struct group *)group)->online--;
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
995 ((struct buddy*)buddy)->present = GAIM_BUDDY_OFFLINE;
5394
08a90a9e28e4 [gaim-migrate @ 5770]
Nathan Walp <nwalp@pidgin.im>
parents: 5392
diff changeset
996 ((struct group *)group)->currentsize--;
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
997 if(ops)
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
998 ops->remove(gaimbuddylist, buddy);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
999 }
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1000 } else if(GAIM_BLIST_NODE_IS_CHAT(buddy)) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1001 if (account == ((struct chat*)buddy)->account) {
5277
d7771fe33cbd [gaim-migrate @ 5649]
Luke Schierer <lschiere@pidgin.im>
parents: 5266
diff changeset
1002 ((struct group *)group)->online--;
d7771fe33cbd [gaim-migrate @ 5649]
Luke Schierer <lschiere@pidgin.im>
parents: 5266
diff changeset
1003 ((struct group *)group)->currentsize--;
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1004 if(ops)
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1005 ops->remove(gaimbuddylist, buddy);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1006 }
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1007 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1008 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1009 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1010 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1011
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
1012 void parse_toc_buddy_list(GaimAccount *account, char *config)
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1013 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1014 char *c;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1015 char current[256];
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1016 GList *bud = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1017
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1018
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1019 if (config != NULL) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1020
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1021 /* skip "CONFIG:" (if it exists) */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1022 c = strncmp(config + 6 /* sizeof(struct sflap_hdr) */ , "CONFIG:", strlen("CONFIG:")) ?
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1023 strtok(config, "\n") :
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1024 strtok(config + 6 /* sizeof(struct sflap_hdr) */ + strlen("CONFIG:"), "\n");
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1025 do {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1026 if (c == NULL)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1027 break;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1028 if (*c == 'g') {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1029 char *utf8 = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1030 utf8 = gaim_try_conv_to_utf8(c + 2);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1031 if (utf8 == NULL) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1032 g_strlcpy(current, _("Invalid Groupname"), sizeof(current));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1033 } else {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1034 g_strlcpy(current, utf8, sizeof(current));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1035 g_free(utf8);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1036 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1037 if (!gaim_find_group(current)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1038 struct group *g = gaim_group_new(current);
5634
5946be17f9ec [gaim-migrate @ 6041]
Nathan Walp <nwalp@pidgin.im>
parents: 5580
diff changeset
1039 gaim_blist_add_group(g,
5946be17f9ec [gaim-migrate @ 6041]
Nathan Walp <nwalp@pidgin.im>
parents: 5580
diff changeset
1040 gaim_blist_get_last_sibling(gaimbuddylist->root));
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1041 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1042 } else if (*c == 'b') { /*&& !gaim_find_buddy(user, c + 2)) {*/
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1043 char nm[80], sw[388], *a, *utf8 = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1044
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1045 if ((a = strchr(c + 2, ':')) != NULL) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1046 *a++ = '\0'; /* nul the : */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1047 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1048
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1049 g_strlcpy(nm, c + 2, sizeof(nm));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1050 if (a) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1051 utf8 = gaim_try_conv_to_utf8(a);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1052 if (utf8 == NULL) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1053 gaim_debug(GAIM_DEBUG_ERROR, "toc blist",
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1054 "Failed to convert alias for "
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1055 "'%s' to UTF-8\n", nm);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1056 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1057 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1058 if (utf8 == NULL) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1059 sw[0] = '\0';
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1060 } else {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1061 /* This can leave a partial sequence at the end,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1062 * but who cares? */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1063 g_strlcpy(sw, utf8, sizeof(sw));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1064 g_free(utf8);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1065 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1066
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1067 if (!gaim_find_buddy(account, nm)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1068 struct buddy *b = gaim_buddy_new(account, nm, sw);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1069 struct group *g = gaim_find_group(current);
5634
5946be17f9ec [gaim-migrate @ 6041]
Nathan Walp <nwalp@pidgin.im>
parents: 5580
diff changeset
1070 gaim_blist_add_buddy(b, g,
5946be17f9ec [gaim-migrate @ 6041]
Nathan Walp <nwalp@pidgin.im>
parents: 5580
diff changeset
1071 gaim_blist_get_last_child((GaimBlistNode*)g));
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1072 bud = g_list_append(bud, g_strdup(nm));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1073 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1074 } else if (*c == 'p') {
6378
01289157fc37 [gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
1075 gaim_privacy_permit_add(account, c + 2, TRUE);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1076 } else if (*c == 'd') {
6378
01289157fc37 [gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
1077 gaim_privacy_deny_add(account, c + 2, TRUE);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1078 } else if (!strncmp("toc", c, 3)) {
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
1079 sscanf(c + strlen(c) - 1, "%d", &account->perm_deny);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1080 gaim_debug(GAIM_DEBUG_MISC, "toc blist",
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
1081 "permdeny: %d\n", account->perm_deny);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
1082 if (account->perm_deny == 0)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
1083 account->perm_deny = 1;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1084 } else if (*c == 'm') {
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
1085 sscanf(c + 2, "%d", &account->perm_deny);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1086 gaim_debug(GAIM_DEBUG_MISC, "toc blist",
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
1087 "permdeny: %d\n", account->perm_deny);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
1088 if (account->perm_deny == 0)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
1089 account->perm_deny = 1;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1090 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1091 } while ((c = strtok(NULL, "\n")));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1092
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1093 if(account->gc) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1094 if(bud) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1095 GList *node = bud;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1096 serv_add_buddies(account->gc, bud);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1097 while(node) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1098 g_free(node->data);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1099 node = node->next;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1100 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1101 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1102 serv_set_permit_deny(account->gc);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1103 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1104 g_list_free(bud);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1105 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1106 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1107
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1108 #if 0
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1109 /* translate an AIM 3 buddylist (*.lst) to a Gaim buddylist */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1110 static GString *translate_lst(FILE *src_fp)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1111 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1112 char line[BUF_LEN], *line2;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1113 char *name;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1114 int i;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1115
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1116 GString *dest = g_string_new("m 1\n");
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1117
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1118 while (fgets(line, BUF_LEN, src_fp)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1119 line2 = g_strchug(line);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1120 if (strstr(line2, "group") == line2) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1121 name = strpbrk(line2, " \t\n\r\f") + 1;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1122 dest = g_string_append(dest, "g ");
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1123 for (i = 0; i < strcspn(name, "\n\r"); i++)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1124 if (name[i] != '\"')
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1125 dest = g_string_append_c(dest, name[i]);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1126 dest = g_string_append_c(dest, '\n');
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1127 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1128 if (strstr(line2, "buddy") == line2) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1129 name = strpbrk(line2, " \t\n\r\f") + 1;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1130 dest = g_string_append(dest, "b ");
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1131 for (i = 0; i < strcspn(name, "\n\r"); i++)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1132 if (name[i] != '\"')
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1133 dest = g_string_append_c(dest, name[i]);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1134 dest = g_string_append_c(dest, '\n');
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1135 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1136 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1137
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1138 return dest;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1139 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1140
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1141
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1142 /* translate an AIM 4 buddylist (*.blt) to Gaim format */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1143 static GString *translate_blt(FILE *src_fp)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1144 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1145 int i;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1146 char line[BUF_LEN];
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1147 char *buddy;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1148
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1149 GString *dest = g_string_new("m 1\n");
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1150
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1151 while (strstr(fgets(line, BUF_LEN, src_fp), "Buddy") == NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1152 while (strstr(fgets(line, BUF_LEN, src_fp), "list") == NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1153
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1154 while (1) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1155 fgets(line, BUF_LEN, src_fp); g_strchomp(line);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1156 if (strchr(line, '}') != NULL)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1157 break;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1158
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1159 if (strchr(line, '{') != NULL) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1160 /* Syntax starting with "<group> {" */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1161
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1162 dest = g_string_append(dest, "g ");
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1163 buddy = g_strchug(strtok(line, "{"));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1164 for (i = 0; i < strlen(buddy); i++)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1165 if (buddy[i] != '\"')
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1166 dest = g_string_append_c(dest, buddy[i]);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1167 dest = g_string_append_c(dest, '\n');
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1168 while (strchr(fgets(line, BUF_LEN, src_fp), '}') == NULL) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1169 gboolean pounce = FALSE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1170 char *e;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1171 g_strchomp(line);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1172 buddy = g_strchug(line);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1173 gaim_debug(GAIM_DEBUG_MISC, "AIM 4 blt import",
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1174 "buddy: \"%s\"\n", buddy);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1175 dest = g_string_append(dest, "b ");
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1176 if (strchr(buddy, '{') != NULL) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1177 /* buddy pounce, etc */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1178 char *pos = strchr(buddy, '{') - 1;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1179 *pos = 0;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1180 pounce = TRUE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1181 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1182 if ((e = strchr(buddy, '\"')) != NULL) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1183 *e = '\0';
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1184 buddy++;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1185 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1186 dest = g_string_append(dest, buddy);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1187 dest = g_string_append_c(dest, '\n');
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1188 if (pounce)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1189 do
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1190 fgets(line, BUF_LEN, src_fp);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1191 while (!strchr(line, '}'));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1192 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1193 } else {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1194
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1195 /* Syntax "group buddy buddy ..." */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1196 buddy = g_strchug(strtok(line, " \n"));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1197 dest = g_string_append(dest, "g ");
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1198 if (strchr(buddy, '\"') != NULL) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1199 dest = g_string_append(dest, &buddy[1]);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1200 dest = g_string_append_c(dest, ' ');
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1201 buddy = g_strchug(strtok(NULL, " \n"));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1202 while (strchr(buddy, '\"') == NULL) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1203 dest = g_string_append(dest, buddy);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1204 dest = g_string_append_c(dest, ' ');
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1205 buddy = g_strchug(strtok(NULL, " \n"));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1206 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1207 buddy[strlen(buddy) - 1] = '\0';
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1208 dest = g_string_append(dest, buddy);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1209 } else {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1210 dest = g_string_append(dest, buddy);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1211 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1212 dest = g_string_append_c(dest, '\n');
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1213 while ((buddy = g_strchug(strtok(NULL, " \n"))) != NULL) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1214 dest = g_string_append(dest, "b ");
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1215 if (strchr(buddy, '\"') != NULL) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1216 dest = g_string_append(dest, &buddy[1]);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1217 dest = g_string_append_c(dest, ' ');
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1218 buddy = g_strchug(strtok(NULL, " \n"));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1219 while (strchr(buddy, '\"') == NULL) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1220 dest = g_string_append(dest, buddy);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1221 dest = g_string_append_c(dest, ' ');
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1222 buddy = g_strchug(strtok(NULL, " \n"));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1223 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1224 buddy[strlen(buddy) - 1] = '\0';
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1225 dest = g_string_append(dest, buddy);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1226 } else {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1227 dest = g_string_append(dest, buddy);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1228 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1229 dest = g_string_append_c(dest, '\n');
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1230 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1231 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1232 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1233
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1234 return dest;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1235 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1236
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1237 static GString *translate_gnomeicu(FILE *src_fp)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1238 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1239 char line[BUF_LEN];
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1240 GString *dest = g_string_new("m 1\ng Buddies\n");
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1241
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1242 while (strstr(fgets(line, BUF_LEN, src_fp), "NewContacts") == NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1243
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1244 while (fgets(line, BUF_LEN, src_fp)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1245 char *eq;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1246 g_strchomp(line);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1247 if (line[0] == '\n' || line[0] == '[')
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1248 break;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1249 eq = strchr(line, '=');
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1250 if (!eq)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1251 break;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1252 *eq = ':';
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1253 eq = strchr(eq, ',');
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1254 if (eq)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1255 *eq = '\0';
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1256 dest = g_string_append(dest, "b ");
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1257 dest = g_string_append(dest, line);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1258 dest = g_string_append_c(dest, '\n');
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1259 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1260
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1261 return dest;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1262 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1263 #endif
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1264
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1265 static gchar *get_screenname_filename(const char *name)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1266 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1267 gchar **split;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1268 gchar *good;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1269 gchar *ret;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1270
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1271 split = g_strsplit(name, G_DIR_SEPARATOR_S, -1);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1272 good = g_strjoinv(NULL, split);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1273 g_strfreev(split);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1274
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1275 ret = g_utf8_strup(good, -1);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1276
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1277 g_free(good);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1278
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1279 return ret;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1280 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1281
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1282 static gboolean gaim_blist_read(const char *filename);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1283
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1284
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
1285 static void do_import(GaimAccount *account, const char *filename)
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1286 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1287 GString *buf = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1288 char first[64];
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1289 char path[PATHSIZE];
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1290 int len;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1291 FILE *f;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1292 struct stat st;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1293
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1294 if (filename) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1295 g_snprintf(path, sizeof(path), "%s", filename);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1296 } else {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1297 char *g_screenname = get_screenname_filename(account->username);
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
1298 const char *username;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1299 char *file = gaim_user_dir();
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
1300 GaimProtocol prpl_num;
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
1301 int protocol;
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
1302
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
1303 prpl_num = gaim_account_get_protocol(account);
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
1304
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
1305 protocol = prpl_num;
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
1306
6450
e7b87c8e8c0a [gaim-migrate @ 6959]
Christian Hammond <chipx86@chipx86.com>
parents: 6392
diff changeset
1307 /* TODO Somehow move this checking into prpls */
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
1308 if (prpl_num == GAIM_PROTO_OSCAR) {
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
1309 if ((username = gaim_account_get_username(account)) != NULL) {
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
1310 protocol = (isalpha(*username)
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
1311 ? GAIM_PROTO_TOC : GAIM_PROTO_ICQ);
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
1312 }
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
1313 }
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1314
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1315 if (file != (char *)NULL) {
5435
a2f26666de42 [gaim-migrate @ 5817]
Mark Doliner <mark@kingant.net>
parents: 5394
diff changeset
1316 snprintf(path, PATHSIZE, "%s" G_DIR_SEPARATOR_S "%s.%d.blist", file, g_screenname, protocol);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1317 g_free(g_screenname);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1318 } else {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1319 g_free(g_screenname);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1320 return;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1321 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1322 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1323
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1324 if (stat(path, &st)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1325 gaim_debug(GAIM_DEBUG_ERROR, "blist import", "Unable to stat %s.\n",
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1326 path);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1327 return;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1328 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1329
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1330 if (!(f = fopen(path, "r"))) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1331 gaim_debug(GAIM_DEBUG_ERROR, "blist import", "Unable to open %s.\n",
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1332 path);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1333 return;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1334 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1335
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1336 fgets(first, 64, f);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1337
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1338 if ((first[0] == '\n') || (first[0] == '\r' && first[1] == '\n'))
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1339 fgets(first, 64, f);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1340
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1341 #if 0
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1342 if (!g_strncasecmp(first, "<xml", strlen("<xml"))) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1343 /* new gaim XML buddy list */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1344 gaim_blist_read(path);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1345
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1346 /* We really don't need to bother doing stuf like translating AIM 3 buddy lists anymore */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1347
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1348 } else if (!g_strncasecmp(first, "Config {", strlen("Config {"))) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1349 /* AIM 4 buddy list */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1350 gaim_debug(GAIM_DEBUG_MISC, "blist import", "aim 4\n");
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1351 rewind(f);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1352 buf = translate_blt(f);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1353 } else if (strstr(first, "group") != NULL) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1354 /* AIM 3 buddy list */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1355 gaim_debug(GAIM_DEBUG_MISC, "blist import", "aim 3\n");
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1356 rewind(f);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1357 buf = translate_lst(f);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1358 } else if (!g_strncasecmp(first, "[User]", strlen("[User]"))) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1359 /* GnomeICU (hopefully) */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1360 gaim_debug(GAIM_DEBUG_MISC, "blist import", "gnomeicu\n");
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1361 rewind(f);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1362 buf = translate_gnomeicu(f);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1363
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1364 } else
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1365 #endif
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1366 if (first[0] == 'm') {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1367 /* Gaim buddy list - no translation */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1368 char buf2[BUF_LONG * 2];
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1369 buf = g_string_new("");
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1370 rewind(f);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1371 while (1) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1372 len = fread(buf2, 1, BUF_LONG * 2 - 1, f);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1373 if (len <= 0)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1374 break;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1375 buf2[len] = '\0';
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1376 buf = g_string_append(buf, buf2);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1377 if (len != BUF_LONG * 2 - 1)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1378 break;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1379 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1380 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1381
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1382 fclose(f);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1383
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1384 if (buf) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1385 buf = g_string_prepend(buf, "toc_set_config {");
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1386 buf = g_string_append(buf, "}\n");
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1387 parse_toc_buddy_list(account, buf->str);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1388 g_string_free(buf, TRUE);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1389 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1390 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1391
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
1392 gboolean gaim_group_on_account(struct group *g, GaimAccount *account) {
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1393 GaimBlistNode *bnode;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1394 for(bnode = g->node.child; bnode; bnode = bnode->next) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1395 struct buddy *b = (struct buddy *)bnode;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1396 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode))
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1397 continue;
5855
082982a4acbd [gaim-migrate @ 6286]
Nathan Walp <nwalp@pidgin.im>
parents: 5776
diff changeset
1398 if((!account && gaim_account_is_connected(b->account))
082982a4acbd [gaim-migrate @ 6286]
Nathan Walp <nwalp@pidgin.im>
parents: 5776
diff changeset
1399 || b->account == account)
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1400 return TRUE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1401 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1402 return FALSE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1403 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1404
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1405 static gboolean blist_safe_to_write = FALSE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1406
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1407 static char *blist_parser_group_name = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1408 static char *blist_parser_person_name = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1409 static char *blist_parser_account_name = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1410 static int blist_parser_account_protocol = 0;
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1411 static char *blist_parser_chat_alias = NULL;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1412 static char *blist_parser_component_name = NULL;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1413 static char *blist_parser_component_value = NULL;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1414 static char *blist_parser_buddy_name = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1415 static char *blist_parser_buddy_alias = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1416 static char *blist_parser_setting_name = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1417 static char *blist_parser_setting_value = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1418 static GHashTable *blist_parser_buddy_settings = NULL;
5906
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5874
diff changeset
1419 static GHashTable *blist_parser_chat_settings = NULL;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1420 static GHashTable *blist_parser_group_settings = NULL;
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1421 static GHashTable *blist_parser_chat_components = NULL;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1422 static int blist_parser_privacy_mode = 0;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1423 static GList *tag_stack = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1424 enum {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1425 BLIST_TAG_GAIM,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1426 BLIST_TAG_BLIST,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1427 BLIST_TAG_GROUP,
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1428 BLIST_TAG_CHAT,
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1429 BLIST_TAG_COMPONENT,
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1430 BLIST_TAG_PERSON,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1431 BLIST_TAG_BUDDY,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1432 BLIST_TAG_NAME,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1433 BLIST_TAG_ALIAS,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1434 BLIST_TAG_SETTING,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1435 BLIST_TAG_PRIVACY,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1436 BLIST_TAG_ACCOUNT,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1437 BLIST_TAG_PERMIT,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1438 BLIST_TAG_BLOCK,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1439 BLIST_TAG_IGNORE
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1440 };
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1441 static gboolean blist_parser_error_occurred = FALSE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1442
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1443 static void blist_start_element_handler (GMarkupParseContext *context,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1444 const gchar *element_name,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1445 const gchar **attribute_names,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1446 const gchar **attribute_values,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1447 gpointer user_data,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1448 GError **error) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1449 int i;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1450
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1451 if(!strcmp(element_name, "gaim")) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1452 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_GAIM));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1453 } else if(!strcmp(element_name, "blist")) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1454 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_BLIST));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1455 } else if(!strcmp(element_name, "group")) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1456 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_GROUP));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1457 for(i=0; attribute_names[i]; i++) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1458 if(!strcmp(attribute_names[i], "name")) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1459 g_free(blist_parser_group_name);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1460 blist_parser_group_name = g_strdup(attribute_values[i]);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1461 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1462 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1463 if(blist_parser_group_name) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1464 struct group *g = gaim_group_new(blist_parser_group_name);
5634
5946be17f9ec [gaim-migrate @ 6041]
Nathan Walp <nwalp@pidgin.im>
parents: 5580
diff changeset
1465 gaim_blist_add_group(g,
5946be17f9ec [gaim-migrate @ 6041]
Nathan Walp <nwalp@pidgin.im>
parents: 5580
diff changeset
1466 gaim_blist_get_last_sibling(gaimbuddylist->root));
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1467 }
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1468 } else if(!strcmp(element_name, "chat")) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1469 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_CHAT));
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1470 for(i=0; attribute_names[i]; i++) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1471 if(!strcmp(attribute_names[i], "account")) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1472 g_free(blist_parser_account_name);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1473 blist_parser_account_name = g_strdup(attribute_values[i]);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1474 } else if(!strcmp(attribute_names[i], "protocol")) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1475 blist_parser_account_protocol = atoi(attribute_values[i]);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1476 }
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1477 }
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1478 } else if(!strcmp(element_name, "person")) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1479 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_PERSON));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1480 for(i=0; attribute_names[i]; i++) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1481 if(!strcmp(attribute_names[i], "name")) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1482 g_free(blist_parser_person_name);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1483 blist_parser_person_name = g_strdup(attribute_values[i]);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1484 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1485 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1486 } else if(!strcmp(element_name, "buddy")) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1487 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_BUDDY));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1488 for(i=0; attribute_names[i]; i++) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1489 if(!strcmp(attribute_names[i], "account")) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1490 g_free(blist_parser_account_name);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1491 blist_parser_account_name = g_strdup(attribute_values[i]);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1492 } else if(!strcmp(attribute_names[i], "protocol")) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1493 blist_parser_account_protocol = atoi(attribute_values[i]);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1494 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1495 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1496 } else if(!strcmp(element_name, "name")) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1497 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_NAME));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1498 } else if(!strcmp(element_name, "alias")) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1499 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_ALIAS));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1500 } else if(!strcmp(element_name, "setting")) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1501 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_SETTING));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1502 for(i=0; attribute_names[i]; i++) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1503 if(!strcmp(attribute_names[i], "name")) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1504 g_free(blist_parser_setting_name);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1505 blist_parser_setting_name = g_strdup(attribute_values[i]);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1506 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1507 }
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1508 } else if(!strcmp(element_name, "component")) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1509 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_COMPONENT));
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1510 for(i=0; attribute_names[i]; i++) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1511 if(!strcmp(attribute_names[i], "name")) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1512 g_free(blist_parser_component_name);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1513 blist_parser_component_name = g_strdup(attribute_values[i]);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1514 }
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1515 }
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1516
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1517 } else if(!strcmp(element_name, "privacy")) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1518 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_PRIVACY));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1519 } else if(!strcmp(element_name, "account")) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1520 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_ACCOUNT));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1521 for(i=0; attribute_names[i]; i++) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1522 if(!strcmp(attribute_names[i], "protocol"))
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1523 blist_parser_account_protocol = atoi(attribute_values[i]);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1524 else if(!strcmp(attribute_names[i], "mode"))
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1525 blist_parser_privacy_mode = atoi(attribute_values[i]);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1526 else if(!strcmp(attribute_names[i], "name")) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1527 g_free(blist_parser_account_name);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1528 blist_parser_account_name = g_strdup(attribute_values[i]);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1529 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1530 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1531 } else if(!strcmp(element_name, "permit")) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1532 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_PERMIT));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1533 } else if(!strcmp(element_name, "block")) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1534 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_BLOCK));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1535 } else if(!strcmp(element_name, "ignore")) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1536 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_IGNORE));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1537 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1538 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1539
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1540 static void blist_end_element_handler(GMarkupParseContext *context,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1541 const gchar *element_name, gpointer user_data, GError **error) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1542 if(!strcmp(element_name, "gaim")) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1543 tag_stack = g_list_delete_link(tag_stack, tag_stack);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1544 } else if(!strcmp(element_name, "blist")) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1545 tag_stack = g_list_delete_link(tag_stack, tag_stack);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1546 } else if(!strcmp(element_name, "group")) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1547 if(blist_parser_group_settings) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1548 struct group *g = gaim_find_group(blist_parser_group_name);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1549 g_hash_table_destroy(g->settings);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1550 g->settings = blist_parser_group_settings;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1551 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1552 tag_stack = g_list_delete_link(tag_stack, tag_stack);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1553 blist_parser_group_settings = NULL;
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1554 } else if(!strcmp(element_name, "chat")) {
5874
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1555 GaimAccount *account = gaim_accounts_find(blist_parser_account_name,
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1556 blist_parser_account_protocol);
5237
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
1557 if(account) {
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1558 struct chat *chat = gaim_chat_new(account, blist_parser_chat_alias, blist_parser_chat_components);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1559 struct group *g = gaim_find_group(blist_parser_group_name);
5634
5946be17f9ec [gaim-migrate @ 6041]
Nathan Walp <nwalp@pidgin.im>
parents: 5580
diff changeset
1560 gaim_blist_add_chat(chat,g,
5946be17f9ec [gaim-migrate @ 6041]
Nathan Walp <nwalp@pidgin.im>
parents: 5580
diff changeset
1561 gaim_blist_get_last_child((GaimBlistNode*)g));
5906
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5874
diff changeset
1562 if(blist_parser_chat_settings) {
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5874
diff changeset
1563 g_hash_table_destroy(chat->settings);
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5874
diff changeset
1564 chat->settings = blist_parser_chat_settings;
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5874
diff changeset
1565 }
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1566 }
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1567 g_free(blist_parser_chat_alias);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1568 blist_parser_chat_alias = NULL;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1569 g_free(blist_parser_account_name);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1570 blist_parser_account_name = NULL;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1571 blist_parser_chat_components = NULL;
5906
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5874
diff changeset
1572 blist_parser_chat_settings = NULL;
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1573 tag_stack = g_list_delete_link(tag_stack, tag_stack);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1574 } else if(!strcmp(element_name, "person")) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1575 g_free(blist_parser_person_name);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1576 blist_parser_person_name = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1577 tag_stack = g_list_delete_link(tag_stack, tag_stack);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1578 } else if(!strcmp(element_name, "buddy")) {
5874
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1579 GaimAccount *account = gaim_accounts_find(blist_parser_account_name,
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1580 blist_parser_account_protocol);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1581 if(account) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1582 struct buddy *b = gaim_buddy_new(account, blist_parser_buddy_name, blist_parser_buddy_alias);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1583 struct group *g = gaim_find_group(blist_parser_group_name);
5634
5946be17f9ec [gaim-migrate @ 6041]
Nathan Walp <nwalp@pidgin.im>
parents: 5580
diff changeset
1584 gaim_blist_add_buddy(b,g,
5946be17f9ec [gaim-migrate @ 6041]
Nathan Walp <nwalp@pidgin.im>
parents: 5580
diff changeset
1585 gaim_blist_get_last_child((GaimBlistNode*)g));
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1586 if(blist_parser_buddy_settings) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1587 g_hash_table_destroy(b->settings);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1588 b->settings = blist_parser_buddy_settings;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1589 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1590 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1591 g_free(blist_parser_buddy_name);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1592 blist_parser_buddy_name = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1593 g_free(blist_parser_buddy_alias);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1594 blist_parser_buddy_alias = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1595 g_free(blist_parser_account_name);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1596 blist_parser_account_name = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1597 blist_parser_buddy_settings = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1598 tag_stack = g_list_delete_link(tag_stack, tag_stack);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1599 } else if(!strcmp(element_name, "name")) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1600 tag_stack = g_list_delete_link(tag_stack, tag_stack);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1601 } else if(!strcmp(element_name, "alias")) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1602 tag_stack = g_list_delete_link(tag_stack, tag_stack);
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1603 } else if(!strcmp(element_name, "component")) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1604 if(!blist_parser_chat_components)
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1605 blist_parser_chat_components = g_hash_table_new_full(g_str_hash,
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1606 g_str_equal, g_free, g_free);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1607 if(blist_parser_component_name && blist_parser_component_value) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1608 g_hash_table_replace(blist_parser_chat_components,
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1609 g_strdup(blist_parser_component_name),
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1610 g_strdup(blist_parser_component_value));
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1611 }
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1612 g_free(blist_parser_component_name);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1613 g_free(blist_parser_component_value);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1614 blist_parser_component_name = NULL;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1615 blist_parser_component_value = NULL;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1616 tag_stack = g_list_delete_link(tag_stack, tag_stack);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1617 } else if(!strcmp(element_name, "setting")) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1618 if(GPOINTER_TO_INT(tag_stack->next->data) == BLIST_TAG_BUDDY) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1619 if(!blist_parser_buddy_settings)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1620 blist_parser_buddy_settings = g_hash_table_new_full(g_str_hash,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1621 g_str_equal, g_free, g_free);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1622 if(blist_parser_setting_name && blist_parser_setting_value) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1623 g_hash_table_replace(blist_parser_buddy_settings,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1624 g_strdup(blist_parser_setting_name),
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1625 g_strdup(blist_parser_setting_value));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1626 }
5906
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5874
diff changeset
1627 } else if(GPOINTER_TO_INT(tag_stack->next->data) == BLIST_TAG_CHAT) {
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5874
diff changeset
1628 if(!blist_parser_chat_settings)
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5874
diff changeset
1629 blist_parser_chat_settings = g_hash_table_new_full(g_str_hash,
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5874
diff changeset
1630 g_str_equal, g_free, g_free);
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5874
diff changeset
1631 if(blist_parser_setting_name && blist_parser_setting_value) {
6307
55588b222901 [gaim-migrate @ 6806]
Mark Doliner <mark@kingant.net>
parents: 6245
diff changeset
1632 g_hash_table_replace(blist_parser_chat_settings,
5906
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5874
diff changeset
1633 g_strdup(blist_parser_setting_name),
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5874
diff changeset
1634 g_strdup(blist_parser_setting_value));
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5874
diff changeset
1635 }
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1636 } else if(GPOINTER_TO_INT(tag_stack->next->data) == BLIST_TAG_GROUP) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1637 if(!blist_parser_group_settings)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1638 blist_parser_group_settings = g_hash_table_new_full(g_str_hash,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1639 g_str_equal, g_free, g_free);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1640 if(blist_parser_setting_name && blist_parser_setting_value) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1641 g_hash_table_replace(blist_parser_group_settings,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1642 g_strdup(blist_parser_setting_name),
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1643 g_strdup(blist_parser_setting_value));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1644 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1645 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1646 g_free(blist_parser_setting_name);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1647 g_free(blist_parser_setting_value);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1648 blist_parser_setting_name = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1649 blist_parser_setting_value = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1650 tag_stack = g_list_delete_link(tag_stack, tag_stack);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1651 } else if(!strcmp(element_name, "privacy")) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1652 tag_stack = g_list_delete_link(tag_stack, tag_stack);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1653 } else if(!strcmp(element_name, "account")) {
5874
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1654 GaimAccount *account = gaim_accounts_find(blist_parser_account_name,
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1655 blist_parser_account_protocol);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1656 if(account) {
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
1657 account->perm_deny = blist_parser_privacy_mode;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1658 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1659 g_free(blist_parser_account_name);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1660 blist_parser_account_name = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1661 tag_stack = g_list_delete_link(tag_stack, tag_stack);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1662 } else if(!strcmp(element_name, "permit")) {
5874
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1663 GaimAccount *account = gaim_accounts_find(blist_parser_account_name,
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1664 blist_parser_account_protocol);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1665 if(account) {
6378
01289157fc37 [gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
1666 gaim_privacy_permit_add(account, blist_parser_buddy_name, TRUE);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1667 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1668 g_free(blist_parser_buddy_name);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1669 blist_parser_buddy_name = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1670 tag_stack = g_list_delete_link(tag_stack, tag_stack);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1671 } else if(!strcmp(element_name, "block")) {
5874
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1672 GaimAccount *account = gaim_accounts_find(blist_parser_account_name,
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1673 blist_parser_account_protocol);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1674 if(account) {
6378
01289157fc37 [gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
1675 gaim_privacy_deny_add(account, blist_parser_buddy_name, TRUE);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1676 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1677 g_free(blist_parser_buddy_name);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1678 blist_parser_buddy_name = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1679 tag_stack = g_list_delete_link(tag_stack, tag_stack);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1680 } else if(!strcmp(element_name, "ignore")) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1681 /* we'll apparently do something with this later */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1682 tag_stack = g_list_delete_link(tag_stack, tag_stack);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1683 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1684 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1685
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1686 static void blist_text_handler(GMarkupParseContext *context, const gchar *text,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1687 gsize text_len, gpointer user_data, GError **error) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1688 switch(GPOINTER_TO_INT(tag_stack->data)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1689 case BLIST_TAG_NAME:
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1690 blist_parser_buddy_name = g_strndup(text, text_len);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1691 break;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1692 case BLIST_TAG_ALIAS:
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1693 if(tag_stack->next &&
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1694 GPOINTER_TO_INT(tag_stack->next->data) == BLIST_TAG_BUDDY)
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1695 blist_parser_buddy_alias = g_strndup(text, text_len);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1696 else if(tag_stack->next &&
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1697 GPOINTER_TO_INT(tag_stack->next->data) == BLIST_TAG_CHAT)
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1698 blist_parser_chat_alias = g_strndup(text, text_len);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1699 break;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1700 case BLIST_TAG_PERMIT:
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1701 case BLIST_TAG_BLOCK:
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1702 case BLIST_TAG_IGNORE:
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1703 blist_parser_buddy_name = g_strndup(text, text_len);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1704 break;
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1705 case BLIST_TAG_COMPONENT:
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1706 blist_parser_component_value = g_strndup(text, text_len);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1707 break;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1708 case BLIST_TAG_SETTING:
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1709 blist_parser_setting_value = g_strndup(text, text_len);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1710 break;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1711 default:
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1712 break;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1713 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1714 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1715
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1716 static void blist_error_handler(GMarkupParseContext *context, GError *error,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1717 gpointer user_data) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1718 blist_parser_error_occurred = TRUE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1719 gaim_debug(GAIM_DEBUG_ERROR, "blist import",
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1720 "Error parsing blist.xml: %s\n", error->message);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1721 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1722
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1723 static GMarkupParser blist_parser = {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1724 blist_start_element_handler,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1725 blist_end_element_handler,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1726 blist_text_handler,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1727 NULL,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1728 blist_error_handler
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1729 };
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1730
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1731 static gboolean gaim_blist_read(const char *filename) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1732 gchar *contents = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1733 gsize length;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1734 GMarkupParseContext *context;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1735 GError *error = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1736
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1737 gaim_debug(GAIM_DEBUG_INFO, "blist import",
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1738 "Reading %s\n", filename);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1739 if(!g_file_get_contents(filename, &contents, &length, &error)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1740 gaim_debug(GAIM_DEBUG_ERROR, "blist import",
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1741 "Error reading blist: %s\n", error->message);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1742 g_error_free(error);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1743 return FALSE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1744 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1745
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1746 context = g_markup_parse_context_new(&blist_parser, 0, NULL, NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1747
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1748 if(!g_markup_parse_context_parse(context, contents, length, NULL)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1749 g_markup_parse_context_free(context);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1750 g_free(contents);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1751 return FALSE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1752 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1753
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1754 if(!g_markup_parse_context_end_parse(context, NULL)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1755 gaim_debug(GAIM_DEBUG_ERROR, "blist import",
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1756 "Error parsing %s\n", filename);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1757 g_markup_parse_context_free(context);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1758 g_free(contents);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1759 return FALSE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1760 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1761
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1762 g_markup_parse_context_free(context);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1763 g_free(contents);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1764
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1765 if(blist_parser_error_occurred)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1766 return FALSE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1767
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1768 gaim_debug(GAIM_DEBUG_INFO, "blist import", "Finished reading %s\n",
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1769 filename);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1770
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1771 return TRUE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1772 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1773
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1774 void gaim_blist_load() {
5580
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
1775 GList *accts;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1776 char *user_dir = gaim_user_dir();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1777 char *filename;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1778 char *msg;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1779
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1780 blist_safe_to_write = TRUE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1781
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1782 if(!user_dir)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1783 return;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1784
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1785 filename = g_build_filename(user_dir, "blist.xml", NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1786
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1787 if(g_file_test(filename, G_FILE_TEST_EXISTS)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1788 if(!gaim_blist_read(filename)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1789 msg = g_strdup_printf(_("An error was encountered parsing your "
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1790 "buddy list. It has not been loaded."));
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5435
diff changeset
1791 gaim_notify_error(NULL, NULL, _("Buddy List Error"), msg);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1792 g_free(msg);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1793 }
5580
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
1794 } else if(g_list_length(gaim_accounts_get_all())) {
5947
ac4dd1d0ee39 [gaim-migrate @ 6388]
Christian Hammond <chipx86@chipx86.com>
parents: 5943
diff changeset
1795 GMainContext *ctx;
ac4dd1d0ee39 [gaim-migrate @ 6388]
Christian Hammond <chipx86@chipx86.com>
parents: 5943
diff changeset
1796
6473
2311f3761ed2 [gaim-migrate @ 6982]
Christian Hammond <chipx86@chipx86.com>
parents: 6456
diff changeset
1797 #if 0
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1798 /* rob wants to inform the user that their buddy lists are
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1799 * being converted */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1800 msg = g_strdup_printf(_("Gaim is converting your old buddy lists "
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1801 "to a new format, which will now be located at %s"),
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1802 filename);
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5435
diff changeset
1803 gaim_notify_info(NULL, NULL, _("Converting Buddy List"), msg);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1804 g_free(msg);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1805
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1806 /* now, let gtk actually display the dialog before we start anything */
5947
ac4dd1d0ee39 [gaim-migrate @ 6388]
Christian Hammond <chipx86@chipx86.com>
parents: 5943
diff changeset
1807 ctx = g_main_context_default();
ac4dd1d0ee39 [gaim-migrate @ 6388]
Christian Hammond <chipx86@chipx86.com>
parents: 5943
diff changeset
1808
ac4dd1d0ee39 [gaim-migrate @ 6388]
Christian Hammond <chipx86@chipx86.com>
parents: 5943
diff changeset
1809 while(g_main_context_pending(ctx))
ac4dd1d0ee39 [gaim-migrate @ 6388]
Christian Hammond <chipx86@chipx86.com>
parents: 5943
diff changeset
1810 g_main_context_iteration(ctx, FALSE);
6473
2311f3761ed2 [gaim-migrate @ 6982]
Christian Hammond <chipx86@chipx86.com>
parents: 6456
diff changeset
1811 #endif
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1812
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1813 /* read in the old lists, then save to the new format */
5580
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
1814 for(accts = gaim_accounts_get_all(); accts; accts = accts->next) {
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1815 do_import(accts->data, NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1816 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1817 gaim_blist_save();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1818 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1819
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1820 g_free(filename);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1821 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1822
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1823 static void blist_print_group_settings(gpointer key, gpointer data,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1824 gpointer user_data) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1825 char *key_val;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1826 char *data_val;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1827 FILE *file = user_data;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1828
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1829 if(!key || !data)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1830 return;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1831
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1832 key_val = g_markup_escape_text(key, -1);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1833 data_val = g_markup_escape_text(data, -1);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1834
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1835 fprintf(file, "\t\t\t<setting name=\"%s\">%s</setting>\n", key_val,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1836 data_val);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1837 g_free(key_val);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1838 g_free(data_val);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1839 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1840
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1841 static void blist_print_buddy_settings(gpointer key, gpointer data,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1842 gpointer user_data) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1843 char *key_val;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1844 char *data_val;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1845 FILE *file = user_data;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1846
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1847 if(!key || !data)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1848 return;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1849
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1850 key_val = g_markup_escape_text(key, -1);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1851 data_val = g_markup_escape_text(data, -1);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1852
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1853 fprintf(file, "\t\t\t\t\t<setting name=\"%s\">%s</setting>\n", key_val,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1854 data_val);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1855 g_free(key_val);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1856 g_free(data_val);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1857 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1858
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1859 static void blist_print_chat_components(gpointer key, gpointer data,
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1860 gpointer user_data) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1861 char *key_val;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1862 char *data_val;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1863 FILE *file = user_data;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1864
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1865 if(!key || !data)
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1866 return;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1867
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1868 key_val = g_markup_escape_text(key, -1);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1869 data_val = g_markup_escape_text(data, -1);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1870
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1871 fprintf(file, "\t\t\t\t<component name=\"%s\">%s</component>\n", key_val,
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1872 data_val);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1873 g_free(key_val);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1874 g_free(data_val);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1875 }
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1876
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
1877 static void gaim_blist_write(FILE *file, GaimAccount *exp_acct) {
5580
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
1878 GList *accounts;
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
1879 GSList *buds;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1880 GaimBlistNode *gnode,*bnode;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1881 struct group *group;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1882 struct buddy *bud;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1883 fprintf(file, "<?xml version='1.0' encoding='UTF-8' ?>\n");
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1884 fprintf(file, "<gaim version=\"1\">\n");
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1885 fprintf(file, "\t<blist>\n");
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1886
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1887 for(gnode = gaimbuddylist->root; gnode; gnode = gnode->next) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1888 if(!GAIM_BLIST_NODE_IS_GROUP(gnode))
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1889 continue;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1890 group = (struct group *)gnode;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1891 if(!exp_acct || gaim_group_on_account(group, exp_acct)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1892 char *group_name = g_markup_escape_text(group->name, -1);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1893 fprintf(file, "\t\t<group name=\"%s\">\n", group_name);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1894 g_hash_table_foreach(group->settings, blist_print_group_settings, file);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1895 for(bnode = gnode->child; bnode; bnode = bnode->next) {
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1896 if(GAIM_BLIST_NODE_IS_BUDDY(bnode)) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1897 bud = (struct buddy *)bnode;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1898 if(!exp_acct || bud->account == exp_acct) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1899 char *bud_name = g_markup_escape_text(bud->name, -1);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1900 char *bud_alias = NULL;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1901 char *acct_name = g_markup_escape_text(bud->account->username, -1);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1902 if(bud->alias)
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1903 bud_alias= g_markup_escape_text(bud->alias, -1);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1904 fprintf(file, "\t\t\t<person name=\"%s\">\n",
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1905 bud_alias ? bud_alias : bud_name);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1906 fprintf(file, "\t\t\t\t<buddy protocol=\"%d\" "
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
1907 "account=\"%s\">\n",
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
1908 gaim_account_get_protocol(bud->account),
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1909 acct_name);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1910 fprintf(file, "\t\t\t\t\t<name>%s</name>\n", bud_name);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1911 if(bud_alias) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1912 fprintf(file, "\t\t\t\t\t<alias>%s</alias>\n",
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1913 bud_alias);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1914 }
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1915 g_hash_table_foreach(bud->settings,
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1916 blist_print_buddy_settings, file);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1917 fprintf(file, "\t\t\t\t</buddy>\n");
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1918 fprintf(file, "\t\t\t</person>\n");
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1919 g_free(bud_name);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1920 g_free(bud_alias);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1921 g_free(acct_name);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1922 }
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1923 } else if(GAIM_BLIST_NODE_IS_CHAT(bnode)) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1924 struct chat *chat = (struct chat *)bnode;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1925 if(!exp_acct || chat->account == exp_acct) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1926 char *acct_name = g_markup_escape_text(chat->account->username, -1);
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
1927 fprintf(file, "\t\t\t<chat protocol=\"%d\" account=\"%s\">\n",
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
1928 gaim_account_get_protocol(chat->account),
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
1929 acct_name);
5237
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
1930 if(chat->alias) {
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
1931 char *chat_alias = g_markup_escape_text(chat->alias, -1);
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
1932 fprintf(file, "\t\t\t\t<alias>%s</alias>\n", chat_alias);
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
1933 g_free(chat_alias);
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
1934 }
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1935 g_hash_table_foreach(chat->components,
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1936 blist_print_chat_components, file);
5906
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5874
diff changeset
1937 /* works for chats too, I don't feel like renaming */
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5874
diff changeset
1938 g_hash_table_foreach(chat->settings,
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5874
diff changeset
1939 blist_print_buddy_settings, file);
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1940 fprintf(file, "\t\t\t</chat>\n");
5237
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
1941 g_free(acct_name);
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1942 }
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1943 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1944 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1945 fprintf(file, "\t\t</group>\n");
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1946 g_free(group_name);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1947 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1948 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1949
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1950 fprintf(file, "\t</blist>\n");
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1951 fprintf(file, "\t<privacy>\n");
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1952
5580
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
1953 for(accounts = gaim_accounts_get_all();
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
1954 accounts != NULL;
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
1955 accounts = accounts->next) {
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
1956
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
1957 GaimAccount *account = accounts->data;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1958 char *acct_name = g_markup_escape_text(account->username, -1);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1959 if(!exp_acct || account == exp_acct) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1960 fprintf(file, "\t\t<account protocol=\"%d\" name=\"%s\" "
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
1961 "mode=\"%d\">\n", gaim_account_get_protocol(account),
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
1962 acct_name, account->perm_deny);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1963 for(buds = account->permit; buds; buds = buds->next) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1964 char *bud_name = g_markup_escape_text(buds->data, -1);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1965 fprintf(file, "\t\t\t<permit>%s</permit>\n", bud_name);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1966 g_free(bud_name);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1967 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1968 for(buds = account->deny; buds; buds = buds->next) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1969 char *bud_name = g_markup_escape_text(buds->data, -1);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1970 fprintf(file, "\t\t\t<block>%s</block>\n", bud_name);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1971 g_free(bud_name);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1972 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1973 fprintf(file, "\t\t</account>\n");
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1974 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1975 g_free(acct_name);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1976 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1977
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1978 fprintf(file, "\t</privacy>\n");
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1979 fprintf(file, "</gaim>\n");
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1980 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1981
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1982 void gaim_blist_save() {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1983 FILE *file;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1984 char *user_dir = gaim_user_dir();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1985 char *filename;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1986 char *filename_real;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1987
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1988 if(!user_dir)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1989 return;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1990 if(!blist_safe_to_write) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1991 gaim_debug(GAIM_DEBUG_WARNING, "blist save",
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1992 "AHH!! Tried to write the blist before we read it!\n");
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1993 return;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1994 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1995
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1996 file = fopen(user_dir, "r");
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1997 if(!file)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1998 mkdir(user_dir, S_IRUSR | S_IWUSR | S_IXUSR);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1999 else
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2000 fclose(file);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2001
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2002 filename = g_build_filename(user_dir, "blist.xml.save", NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2003
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2004 if((file = fopen(filename, "w"))) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2005 gaim_blist_write(file, NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2006 fclose(file);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2007 chmod(filename, S_IRUSR | S_IWUSR);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2008 } else {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2009 gaim_debug(GAIM_DEBUG_ERROR, "blist save", "Unable to write %s\n",
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2010 filename);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2011 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2012
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2013 filename_real = g_build_filename(user_dir, "blist.xml", NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2014
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2015 if(rename(filename, filename_real) < 0)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2016 gaim_debug(GAIM_DEBUG_ERROR, "blist save",
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2017 "Error renaming %s to %s\n", filename, filename_real);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2018
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2019
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2020 g_free(filename);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2021 g_free(filename_real);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2022 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2023
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2024 void gaim_group_set_setting(struct group *g, const char *key,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2025 const char *value) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2026 if(!g)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2027 return;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2028 g_hash_table_replace(g->settings, g_strdup(key), g_strdup(value));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2029 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2030
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2031 char *gaim_group_get_setting(struct group *g, const char *key) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2032 if(!g)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2033 return NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2034 return g_strdup(g_hash_table_lookup(g->settings, key));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2035 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2036
5906
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5874
diff changeset
2037 void gaim_chat_set_setting(struct chat *c, const char *key,
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5874
diff changeset
2038 const char *value)
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5874
diff changeset
2039 {
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5874
diff changeset
2040 if(!c)
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5874
diff changeset
2041 return;
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5874
diff changeset
2042 g_hash_table_replace(c->settings, g_strdup(key), g_strdup(value));
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5874
diff changeset
2043 }
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5874
diff changeset
2044
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5874
diff changeset
2045 char *gaim_chat_get_setting(struct chat *c, const char *key)
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5874
diff changeset
2046 {
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5874
diff changeset
2047 if(!c)
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5874
diff changeset
2048 return NULL;
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5874
diff changeset
2049 return g_strdup(g_hash_table_lookup(c->settings, key));
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5874
diff changeset
2050 }
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5874
diff changeset
2051
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2052 void gaim_buddy_set_setting(struct buddy *b, const char *key,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2053 const char *value) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2054 if(!b)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2055 return;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2056 g_hash_table_replace(b->settings, g_strdup(key), g_strdup(value));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2057 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2058
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2059 char *gaim_buddy_get_setting(struct buddy *b, const char *key) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2060 if(!b)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2061 return NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2062 return g_strdup(g_hash_table_lookup(b->settings, key));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2063 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2064
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2065 void gaim_set_blist_ui_ops(struct gaim_blist_ui_ops *ops)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2066 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2067 blist_ui_ops = ops;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2068 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2069
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2070 struct gaim_blist_ui_ops *
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2071 gaim_get_blist_ui_ops(void)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2072 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2073 return blist_ui_ops;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2074 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2075
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2076 int gaim_blist_get_group_size(struct group *group, gboolean offline) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2077 if(!group)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2078 return 0;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2079
5277
d7771fe33cbd [gaim-migrate @ 5649]
Luke Schierer <lschiere@pidgin.im>
parents: 5266
diff changeset
2080 return offline ? group->totalsize : group->currentsize;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2081 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2082
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2083 int gaim_blist_get_group_online_count(struct group *group) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2084 if(!group)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2085 return 0;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2086
5277
d7771fe33cbd [gaim-migrate @ 5649]
Luke Schierer <lschiere@pidgin.im>
parents: 5266
diff changeset
2087 return group->online;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2088 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2089
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2090