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