Mercurial > pidgin
annotate src/blist.c @ 7327:258c19be6d84
[gaim-migrate @ 7913]
stop using this file
committer: Tailor Script <tailor@pidgin.im>
| author | Luke Schierer <lschiere@pidgin.im> |
|---|---|
| date | Sat, 25 Oct 2003 01:57:41 +0000 |
| parents | b8ce6e194cff |
| children | 53c86d59f20b |
| 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" |
| 7132 | 34 #include "xmlnode.h" |
| 5228 | 35 |
| 36 #define PATHSIZE 1024 | |
| 37 | |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
38 GaimBuddyList *gaimbuddylist = NULL; |
|
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
39 static GaimBlistUiOps *blist_ui_ops = NULL; |
| 5228 | 40 |
|
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
41 |
| 5228 | 42 /***************************************************************************** |
| 43 * Private Utility functions * | |
| 44 *****************************************************************************/ | |
| 45 static GaimBlistNode *gaim_blist_get_last_sibling(GaimBlistNode *node) | |
| 46 { | |
| 47 GaimBlistNode *n = node; | |
| 48 if (!n) | |
| 49 return NULL; | |
| 50 while (n->next) | |
| 51 n = n->next; | |
| 52 return n; | |
| 53 } | |
| 6695 | 54 |
| 5228 | 55 static GaimBlistNode *gaim_blist_get_last_child(GaimBlistNode *node) |
| 56 { | |
| 57 if (!node) | |
| 58 return NULL; | |
| 59 return gaim_blist_get_last_sibling(node->child); | |
| 60 } | |
| 61 | |
| 5247 | 62 struct _gaim_hbuddy { |
| 63 char *name; | |
|
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
64 GaimAccount *account; |
| 5758 | 65 GaimBlistNode *group; |
| 5247 | 66 }; |
| 67 | |
| 68 static guint _gaim_blist_hbuddy_hash (struct _gaim_hbuddy *hb) | |
| 69 { | |
| 70 return g_str_hash(hb->name); | |
| 71 } | |
| 72 | |
| 73 static guint _gaim_blist_hbuddy_equal (struct _gaim_hbuddy *hb1, struct _gaim_hbuddy *hb2) | |
| 74 { | |
| 5758 | 75 return ((!strcmp(hb1->name, hb2->name)) && hb1->account == hb2->account && hb1->group == hb2->group); |
| 5247 | 76 } |
| 77 | |
| 6742 | 78 static void _gaim_blist_hbuddy_free_key(struct _gaim_hbuddy *hb) |
| 79 { | |
| 80 g_free(hb->name); | |
| 81 g_free(hb); | |
| 82 } | |
| 83 | |
| 6006 | 84 static void blist_pref_cb(const char *name, GaimPrefType typ, gpointer value, gpointer data) |
| 85 { | |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
86 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
| 6695 | 87 GaimBlistNode *gnode, *cnode, *bnode; |
| 6012 | 88 |
| 89 if (!ops) | |
| 90 return; | |
| 91 | |
| 6695 | 92 for(gnode = gaimbuddylist->root; gnode; gnode = gnode->next) { |
| 93 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
| 6012 | 94 continue; |
| 6695 | 95 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
| 96 if(GAIM_BLIST_NODE_IS_CONTACT(cnode)) { | |
| 97 for(bnode = cnode->child; bnode; bnode = bnode->next) { | |
| 98 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
| 99 continue; | |
| 100 ops->update(gaimbuddylist, bnode); | |
| 101 } | |
| 102 } else if(GAIM_BLIST_NODE_IS_CHAT(cnode)) { | |
| 103 ops->update(gaimbuddylist, cnode); | |
| 104 } | |
| 6012 | 105 } |
| 106 } | |
| 6006 | 107 } |
| 108 | |
| 7312 | 109 GaimContact *gaim_buddy_get_contact(GaimBuddy *buddy) |
| 6843 | 110 { |
| 111 return (GaimContact*)((GaimBlistNode*)buddy)->parent; | |
| 112 } | |
| 113 | |
| 114 static void gaim_contact_compute_priority_buddy(GaimContact *contact) { | |
| 115 GaimBlistNode *bnode; | |
| 6870 | 116 contact->priority = NULL; |
| 6843 | 117 |
| 118 for(bnode = ((GaimBlistNode*)contact)->child; bnode; bnode = bnode->next) { | |
| 119 GaimBuddy *buddy; | |
| 120 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
| 121 continue; | |
| 122 buddy = (GaimBuddy*)bnode; | |
| 123 if(!gaim_account_is_connected(buddy->account)) | |
| 124 continue; | |
| 125 | |
| 126 if(!contact->priority) { | |
| 127 contact->priority = buddy; | |
| 128 } else if(GAIM_BUDDY_IS_ONLINE(buddy)) { | |
| 129 if(!GAIM_BUDDY_IS_ONLINE(contact->priority)) { | |
| 130 contact->priority = buddy; | |
| 131 } else if(!(buddy->uc & UC_UNAVAILABLE) && !buddy->idle && | |
| 132 (contact->priority->uc & UC_UNAVAILABLE || | |
| 133 contact->priority->idle)) { | |
| 134 contact->priority = buddy; | |
| 135 } else if(!buddy->idle && contact->priority->idle) { | |
| 136 contact->priority = buddy; | |
| 137 } else if(contact->priority->uc & UC_UNAVAILABLE && | |
| 138 contact->priority->idle && (!(buddy->uc & UC_UNAVAILABLE) || | |
| 139 !buddy->idle)) { | |
| 140 contact->priority = buddy; | |
| 141 } | |
| 142 } | |
| 143 } | |
| 144 } | |
| 145 | |
| 146 | |
| 5228 | 147 /***************************************************************************** |
| 148 * Public API functions * | |
| 149 *****************************************************************************/ | |
| 150 | |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
151 GaimBuddyList *gaim_blist_new() |
| 5228 | 152 { |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
153 GaimBuddyList *gbl = g_new0(GaimBuddyList, 1); |
| 5228 | 154 |
|
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7003
diff
changeset
|
155 gbl->ui_ops = gaim_blist_get_ui_ops(); |
| 5228 | 156 |
| 6742 | 157 gbl->buddies = g_hash_table_new_full((GHashFunc)_gaim_blist_hbuddy_hash, |
| 158 (GEqualFunc)_gaim_blist_hbuddy_equal, | |
| 159 (GDestroyNotify)_gaim_blist_hbuddy_free_key, NULL); | |
| 5247 | 160 |
| 5228 | 161 if (gbl->ui_ops != NULL && gbl->ui_ops->new_list != NULL) |
| 162 gbl->ui_ops->new_list(gbl); | |
| 163 | |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
164 gaim_prefs_connect_callback("/core/buddies/use_server_alias", |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
165 blist_pref_cb, NULL); |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
166 |
| 6006 | 167 |
| 5228 | 168 return gbl; |
| 169 } | |
| 170 | |
| 171 void | |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
172 gaim_set_blist(GaimBuddyList *list) |
| 5228 | 173 { |
| 174 gaimbuddylist = list; | |
| 175 } | |
| 176 | |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
177 GaimBuddyList * |
| 5228 | 178 gaim_get_blist(void) |
| 179 { | |
| 180 return gaimbuddylist; | |
| 181 } | |
| 182 | |
| 6695 | 183 void gaim_blist_show () |
| 5228 | 184 { |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
185 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
| 5228 | 186 if (ops) |
| 187 ops->show(gaimbuddylist); | |
| 188 } | |
| 189 | |
| 190 void gaim_blist_destroy() | |
| 191 { | |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
192 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
| 5228 | 193 if (ops) |
| 194 ops->destroy(gaimbuddylist); | |
| 195 } | |
| 196 | |
| 197 void gaim_blist_set_visible (gboolean show) | |
| 198 { | |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
199 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
| 5228 | 200 if (ops) |
| 201 ops->set_visible(gaimbuddylist, show); | |
| 202 } | |
| 203 | |
| 6695 | 204 void gaim_blist_update_buddy_status (GaimBuddy *buddy, int status) |
| 5228 | 205 { |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
206 GaimBlistUiOps *ops; |
|
5266
b3a03b86b09b
[gaim-migrate @ 5638]
Christian Hammond <chipx86@chipx86.com>
parents:
5259
diff
changeset
|
207 |
|
b3a03b86b09b
[gaim-migrate @ 5638]
Christian Hammond <chipx86@chipx86.com>
parents:
5259
diff
changeset
|
208 if (buddy->uc == status) |
|
b3a03b86b09b
[gaim-migrate @ 5638]
Christian Hammond <chipx86@chipx86.com>
parents:
5259
diff
changeset
|
209 return; |
|
b3a03b86b09b
[gaim-migrate @ 5638]
Christian Hammond <chipx86@chipx86.com>
parents:
5259
diff
changeset
|
210 |
|
b3a03b86b09b
[gaim-migrate @ 5638]
Christian Hammond <chipx86@chipx86.com>
parents:
5259
diff
changeset
|
211 ops = gaimbuddylist->ui_ops; |
| 5228 | 212 |
| 5305 | 213 if((status & UC_UNAVAILABLE) != (buddy->uc & UC_UNAVAILABLE)) { |
| 214 if(status & UC_UNAVAILABLE) | |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
215 gaim_signal_emit(gaim_blist_get_handle(), "buddy-away", buddy); |
| 5305 | 216 else |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
217 gaim_signal_emit(gaim_blist_get_handle(), "buddy-back", buddy); |
| 5305 | 218 } |
| 5228 | 219 |
| 5305 | 220 buddy->uc = status; |
| 6843 | 221 gaim_contact_compute_priority_buddy(gaim_buddy_get_contact(buddy)); |
| 5228 | 222 if (ops) |
| 223 ops->update(gaimbuddylist, (GaimBlistNode*)buddy); | |
| 224 } | |
| 225 | |
| 6695 | 226 static gboolean presence_update_timeout_cb(GaimBuddy *buddy) { |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
227 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
|
6640
314111e7b601
[gaim-migrate @ 7165]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
228 GaimConversation *conv; |
|
314111e7b601
[gaim-migrate @ 7165]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
229 |
|
314111e7b601
[gaim-migrate @ 7165]
Christian Hammond <chipx86@chipx86.com>
parents:
6564
diff
changeset
|
230 conv = gaim_find_conversation_with_account(buddy->name, buddy->account); |
| 5228 | 231 |
| 232 if(buddy->present == GAIM_BUDDY_SIGNING_ON) { | |
| 233 buddy->present = GAIM_BUDDY_ONLINE; | |
| 234 } else if(buddy->present == GAIM_BUDDY_SIGNING_OFF) { | |
| 235 buddy->present = GAIM_BUDDY_OFFLINE; | |
| 6860 | 236 ((GaimContact*)((GaimBlistNode*)buddy)->parent)->online--; |
| 237 if(((GaimContact*)((GaimBlistNode*)buddy)->parent)->online == 0) | |
| 238 ((GaimGroup *)((GaimBlistNode *)buddy)->parent->parent)->online--; | |
| 5228 | 239 } |
| 240 | |
| 241 buddy->timer = 0; | |
| 242 | |
| 243 if (ops) | |
| 244 ops->update(gaimbuddylist, (GaimBlistNode*)buddy); | |
| 245 | |
|
6392
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6378
diff
changeset
|
246 if (conv) { |
|
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6378
diff
changeset
|
247 if (buddy->present == GAIM_BUDDY_ONLINE) |
|
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6378
diff
changeset
|
248 gaim_conversation_update(conv, GAIM_CONV_ACCOUNT_ONLINE); |
|
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6378
diff
changeset
|
249 else if (buddy->present == GAIM_BUDDY_OFFLINE) |
|
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6378
diff
changeset
|
250 gaim_conversation_update(conv, GAIM_CONV_ACCOUNT_OFFLINE); |
|
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6378
diff
changeset
|
251 } |
|
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6378
diff
changeset
|
252 |
| 5228 | 253 return FALSE; |
| 254 } | |
| 255 | |
| 6695 | 256 void gaim_blist_update_buddy_presence(GaimBuddy *buddy, int presence) { |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
257 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
| 6961 | 258 gboolean do_something = FALSE; |
| 5228 | 259 |
| 260 if (!GAIM_BUDDY_IS_ONLINE(buddy) && presence) { | |
| 6901 | 261 int old_present = buddy->present; |
| 5228 | 262 buddy->present = GAIM_BUDDY_SIGNING_ON; |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
263 gaim_signal_emit(gaim_blist_get_handle(), "buddy-signed-on", buddy); |
| 6961 | 264 do_something = TRUE; |
| 6901 | 265 |
| 266 if(old_present != GAIM_BUDDY_SIGNING_OFF) { | |
| 267 ((GaimContact*)((GaimBlistNode*)buddy)->parent)->online++; | |
| 268 if(((GaimContact*)((GaimBlistNode*)buddy)->parent)->online == 1) | |
| 269 ((GaimGroup *)((GaimBlistNode *)buddy)->parent->parent)->online++; | |
| 270 } | |
| 5228 | 271 } else if(GAIM_BUDDY_IS_ONLINE(buddy) && !presence) { |
| 272 buddy->present = GAIM_BUDDY_SIGNING_OFF; | |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
273 gaim_signal_emit(gaim_blist_get_handle(), "buddy-signed-off", buddy); |
| 6961 | 274 do_something = TRUE; |
| 5228 | 275 } |
| 276 | |
| 6961 | 277 if(do_something) { |
| 5228 | 278 if(buddy->timer > 0) |
| 279 g_source_remove(buddy->timer); | |
| 280 buddy->timer = g_timeout_add(10000, (GSourceFunc)presence_update_timeout_cb, buddy); | |
| 6961 | 281 |
| 282 gaim_contact_compute_priority_buddy(gaim_buddy_get_contact(buddy)); | |
| 283 if (ops) | |
| 284 ops->update(gaimbuddylist, (GaimBlistNode*)buddy); | |
| 5228 | 285 } |
| 286 } | |
| 287 | |
| 288 | |
| 6695 | 289 void gaim_blist_update_buddy_idle (GaimBuddy *buddy, int idle) |
| 5228 | 290 { |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
291 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
| 6961 | 292 if(buddy->idle == idle) |
| 293 return; | |
| 294 | |
| 5228 | 295 buddy->idle = idle; |
| 6843 | 296 gaim_contact_compute_priority_buddy(gaim_buddy_get_contact(buddy)); |
| 5228 | 297 if (ops) |
| 298 ops->update(gaimbuddylist, (GaimBlistNode*)buddy); | |
| 299 } | |
| 6695 | 300 |
| 301 void gaim_blist_update_buddy_evil (GaimBuddy *buddy, int warning) | |
| 5228 | 302 { |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
303 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
| 6961 | 304 if(buddy->evil == warning) |
| 305 return; | |
| 306 | |
| 5228 | 307 buddy->evil = warning; |
| 308 if (ops) | |
| 309 ops->update(gaimbuddylist,(GaimBlistNode*)buddy); | |
| 310 } | |
| 6695 | 311 |
| 312 void gaim_blist_update_buddy_icon(GaimBuddy *buddy) { | |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
313 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
| 5228 | 314 if(ops) |
| 315 ops->update(gaimbuddylist, (GaimBlistNode*)buddy); | |
| 316 } | |
| 6695 | 317 |
| 318 void gaim_blist_rename_buddy (GaimBuddy *buddy, const char *name) | |
| 5228 | 319 { |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
320 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
| 5634 | 321 g_free(buddy->name); |
| 5228 | 322 buddy->name = g_strdup(name); |
| 323 if (ops) | |
| 324 ops->update(gaimbuddylist, (GaimBlistNode*)buddy); | |
| 325 } | |
| 5234 | 326 |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
327 void gaim_blist_alias_chat(GaimChat *chat, const char *alias) |
| 5234 | 328 { |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
329 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
| 5234 | 330 |
| 5237 | 331 g_free(chat->alias); |
| 5234 | 332 |
| 5237 | 333 if(alias && strlen(alias)) |
| 334 chat->alias = g_strdup(alias); | |
| 335 else | |
| 336 chat->alias = NULL; | |
| 337 | |
| 5234 | 338 if(ops) |
| 339 ops->update(gaimbuddylist, (GaimBlistNode*)chat); | |
| 340 } | |
| 341 | |
| 6695 | 342 void gaim_blist_alias_buddy (GaimBuddy *buddy, const char *alias) |
| 5228 | 343 { |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
344 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
|
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5634
diff
changeset
|
345 GaimConversation *conv; |
| 5228 | 346 |
| 347 g_free(buddy->alias); | |
| 348 | |
| 349 if(alias && strlen(alias)) | |
| 350 buddy->alias = g_strdup(alias); | |
| 351 else | |
| 352 buddy->alias = NULL; | |
| 353 | |
| 354 if (ops) | |
| 355 ops->update(gaimbuddylist, (GaimBlistNode*)buddy); | |
| 356 | |
| 357 conv = gaim_find_conversation_with_account(buddy->name, buddy->account); | |
| 358 | |
| 359 if (conv) | |
| 360 gaim_conversation_autoset_title(conv); | |
| 361 } | |
| 362 | |
| 6695 | 363 void gaim_blist_server_alias_buddy (GaimBuddy *buddy, const char *alias) |
| 6058 | 364 { |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
365 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
| 6058 | 366 GaimConversation *conv; |
| 367 | |
| 368 g_free(buddy->server_alias); | |
| 369 | |
| 370 if(alias && strlen(alias) && g_utf8_validate(alias, -1, NULL)) | |
| 371 buddy->server_alias = g_strdup(alias); | |
| 372 else | |
| 373 buddy->server_alias = NULL; | |
| 374 | |
| 375 if (ops) | |
| 376 ops->update(gaimbuddylist, (GaimBlistNode*)buddy); | |
| 377 | |
| 378 conv = gaim_find_conversation_with_account(buddy->name, buddy->account); | |
| 379 | |
| 380 if (conv) | |
| 381 gaim_conversation_autoset_title(conv); | |
| 382 } | |
| 383 | |
| 6695 | 384 void gaim_blist_rename_group(GaimGroup *group, const char *name) |
| 5228 | 385 { |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
386 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
| 6695 | 387 GaimGroup *dest_group; |
| 5346 | 388 GaimBlistNode *prev, *child, *next; |
| 389 GSList *accts; | |
| 390 | |
| 391 if(!name || !strlen(name) || !strcmp(name, group->name)) { | |
| 392 /* nothing to do here */ | |
| 393 return; | |
| 394 } else if((dest_group = gaim_find_group(name))) { | |
| 395 /* here we're merging two groups */ | |
| 396 prev = gaim_blist_get_last_child((GaimBlistNode*)dest_group); | |
| 397 child = ((GaimBlistNode*)group)->child; | |
| 398 | |
| 399 while(child) | |
| 400 { | |
| 401 next = child->next; | |
| 6695 | 402 if(GAIM_BLIST_NODE_IS_CONTACT(child)) { |
| 403 GaimBlistNode *bnode; | |
| 404 gaim_blist_add_contact((GaimContact *)child, dest_group, prev); | |
| 405 for(bnode = child->child; bnode; bnode = bnode->next) | |
| 406 gaim_blist_add_buddy((GaimBuddy*)bnode, (GaimContact*)child, | |
| 407 NULL, bnode->prev); | |
| 5346 | 408 prev = child; |
| 409 } else if(GAIM_BLIST_NODE_IS_CHAT(child)) { | |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
410 gaim_blist_add_chat((GaimChat *)child, dest_group, prev); |
| 5346 | 411 prev = child; |
| 412 } else { | |
| 413 gaim_debug(GAIM_DEBUG_ERROR, "blist", | |
| 414 "Unknown child type in group %s\n", group->name); | |
| 415 } | |
| 416 child = next; | |
| 417 } | |
| 418 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
|
419 GaimAccount *account = accts->data; |
| 5346 | 420 serv_rename_group(account->gc, group, name); |
| 421 } | |
| 422 gaim_blist_remove_group(group); | |
| 423 } else { | |
| 424 /* a simple rename */ | |
| 425 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
|
426 GaimAccount *account = accts->data; |
| 5346 | 427 serv_rename_group(account->gc, group, name); |
| 428 } | |
| 429 g_free(group->name); | |
| 430 group->name = g_strdup(name); | |
| 431 if (ops) | |
| 432 ops->update(gaimbuddylist, (GaimBlistNode*)group); | |
| 433 } | |
| 5228 | 434 } |
| 5234 | 435 |
| 7125 | 436 GaimChat *gaim_chat_new(GaimAccount *account, const char *alias, GHashTable *components) |
| 5234 | 437 { |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
438 GaimChat *chat; |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
439 GaimBlistUiOps *ops; |
| 5234 | 440 |
| 5237 | 441 if(!components) |
| 5234 | 442 return NULL; |
| 443 | |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
444 chat = g_new0(GaimChat, 1); |
| 5234 | 445 chat->account = account; |
| 5237 | 446 if(alias && strlen(alias)) |
| 447 chat->alias = g_strdup(alias); | |
| 5234 | 448 chat->components = components; |
| 5906 | 449 chat->settings = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 450 g_free, g_free); | |
| 5234 | 451 |
| 452 ((GaimBlistNode*)chat)->type = GAIM_BLIST_CHAT_NODE; | |
| 453 | |
|
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7003
diff
changeset
|
454 ops = gaim_blist_get_ui_ops(); |
| 5234 | 455 |
| 456 if (ops != NULL && ops->new_node != NULL) | |
| 457 ops->new_node((GaimBlistNode *)chat); | |
| 458 | |
| 459 return chat; | |
| 460 } | |
| 461 | |
| 7125 | 462 char *gaim_chat_get_display_name(GaimChat *chat) |
| 6034 | 463 { |
| 464 char *name; | |
| 465 | |
| 466 if(chat->alias){ | |
| 467 name = g_strdup(chat->alias); | |
| 468 } | |
| 469 else{ | |
| 470 GList *parts; | |
| 471 GaimPlugin *prpl; | |
| 472 GaimPluginProtocolInfo *prpl_info; | |
| 473 struct proto_chat_entry *pce; | |
| 474 | |
| 475 prpl = gaim_find_prpl(gaim_account_get_protocol(chat->account)); | |
| 476 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); | |
| 477 | |
| 478 parts = prpl_info->chat_info(chat->account->gc); | |
| 479 | |
| 480 pce = parts->data; | |
| 481 name = g_markup_escape_text(g_hash_table_lookup(chat->components, | |
| 482 pce->identifier), -1); | |
| 483 g_list_free(parts); | |
| 484 } | |
| 485 | |
| 486 return name; | |
| 487 } | |
| 488 | |
| 6695 | 489 GaimBuddy *gaim_buddy_new(GaimAccount *account, const char *screenname, const char *alias) |
| 5228 | 490 { |
| 6695 | 491 GaimBuddy *b; |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
492 GaimBlistUiOps *ops; |
| 5228 | 493 |
| 6695 | 494 b = g_new0(GaimBuddy, 1); |
| 5228 | 495 b->account = account; |
| 496 b->name = g_strdup(screenname); | |
| 497 b->alias = g_strdup(alias); | |
| 498 b->settings = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | |
| 499 ((GaimBlistNode*)b)->type = GAIM_BLIST_BUDDY_NODE; | |
| 500 | |
|
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7003
diff
changeset
|
501 ops = gaim_blist_get_ui_ops(); |
| 5228 | 502 |
| 503 if (ops != NULL && ops->new_node != NULL) | |
| 504 ops->new_node((GaimBlistNode *)b); | |
| 505 | |
| 506 return b; | |
| 507 } | |
| 5634 | 508 |
|
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
509 void |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
510 gaim_buddy_set_icon(GaimBuddy *buddy, GaimBuddyIcon *icon) |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
511 { |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
512 g_return_if_fail(buddy != NULL); |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
513 |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
514 if (buddy->icon == icon) |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
515 return; |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
516 |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
517 if (buddy->icon != NULL) |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
518 gaim_buddy_icon_unref(buddy->icon); |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
519 |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
520 buddy->icon = (icon == NULL ? NULL : gaim_buddy_icon_ref(icon)); |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
521 |
|
6886
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6885
diff
changeset
|
522 gaim_buddy_icon_cache(icon, buddy); |
|
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
523 |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
524 gaim_blist_update_buddy_icon(buddy); |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
525 } |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
526 |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
527 GaimBuddyIcon * |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
528 gaim_buddy_get_icon(const GaimBuddy *buddy) |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
529 { |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
530 g_return_val_if_fail(buddy != NULL, NULL); |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
531 |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
532 return buddy->icon; |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
533 } |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
534 |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
535 void gaim_blist_add_chat(GaimChat *chat, GaimGroup *group, GaimBlistNode *node) |
| 5234 | 536 { |
| 537 GaimBlistNode *n = node, *cnode = (GaimBlistNode*)chat; | |
| 6695 | 538 GaimGroup *g = group; |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
539 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
| 5234 | 540 gboolean save = FALSE; |
| 541 | |
| 6774 | 542 |
| 543 g_return_if_fail(chat != NULL); | |
| 544 g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT((GaimBlistNode*)chat)); | |
| 545 | |
| 5234 | 546 if (!n) { |
| 547 if (!g) { | |
| 548 g = gaim_group_new(_("Chats")); | |
| 5634 | 549 gaim_blist_add_group(g, |
| 550 gaim_blist_get_last_sibling(gaimbuddylist->root)); | |
| 5234 | 551 } |
| 552 } else { | |
| 6695 | 553 g = (GaimGroup*)n->parent; |
| 5234 | 554 } |
| 555 | |
| 556 /* if we're moving to overtop of ourselves, do nothing */ | |
| 557 if(cnode == n) | |
| 558 return; | |
| 559 | |
| 560 if (cnode->parent) { | |
| 561 /* This chat was already in the list and is | |
| 562 * being moved. | |
| 563 */ | |
| 6695 | 564 ((GaimGroup *)cnode->parent)->totalsize--; |
| 5855 | 565 if (gaim_account_is_connected(chat->account)) { |
| 6695 | 566 ((GaimGroup *)cnode->parent)->online--; |
| 567 ((GaimGroup *)cnode->parent)->currentsize--; | |
| 5287 | 568 } |
| 5234 | 569 if(cnode->next) |
| 570 cnode->next->prev = cnode->prev; | |
| 571 if(cnode->prev) | |
| 572 cnode->prev->next = cnode->next; | |
| 573 if(cnode->parent->child == cnode) | |
| 574 cnode->parent->child = cnode->next; | |
| 575 | |
| 576 ops->remove(gaimbuddylist, cnode); | |
| 577 | |
| 578 save = TRUE; | |
| 579 } | |
| 580 | |
| 581 if (n) { | |
| 582 if(n->next) | |
| 583 n->next->prev = cnode; | |
| 584 cnode->next = n->next; | |
| 585 cnode->prev = n; | |
| 586 cnode->parent = n->parent; | |
| 587 n->next = cnode; | |
| 6695 | 588 ((GaimGroup *)n->parent)->totalsize++; |
| 5855 | 589 if (gaim_account_is_connected(chat->account)) { |
| 6695 | 590 ((GaimGroup *)n->parent)->online++; |
| 591 ((GaimGroup *)n->parent)->currentsize++; | |
| 5287 | 592 } |
| 5234 | 593 } else { |
| 5634 | 594 if(((GaimBlistNode*)g)->child) |
| 595 ((GaimBlistNode*)g)->child->prev = cnode; | |
| 596 cnode->next = ((GaimBlistNode*)g)->child; | |
| 597 cnode->prev = NULL; | |
| 5234 | 598 ((GaimBlistNode*)g)->child = cnode; |
| 599 cnode->parent = (GaimBlistNode*)g; | |
| 5277 | 600 g->totalsize++; |
| 5855 | 601 if (gaim_account_is_connected(chat->account)) { |
| 5287 | 602 g->online++; |
| 5277 | 603 g->currentsize++; |
| 5287 | 604 } |
| 5234 | 605 } |
| 606 | |
| 607 if (ops) | |
| 608 ops->update(gaimbuddylist, (GaimBlistNode*)cnode); | |
| 609 if (save) | |
| 610 gaim_blist_save(); | |
| 611 } | |
| 612 | |
| 6695 | 613 void gaim_blist_add_buddy (GaimBuddy *buddy, GaimContact *contact, GaimGroup *group, GaimBlistNode *node) |
| 5228 | 614 { |
| 6695 | 615 GaimBlistNode *cnode, *bnode; |
| 616 GaimGroup *g; | |
| 617 GaimContact *c; | |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
618 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
| 6695 | 619 gboolean save = FALSE; |
| 5247 | 620 struct _gaim_hbuddy *hb; |
| 6695 | 621 |
| 622 g_return_if_fail(buddy != NULL); | |
| 6774 | 623 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY((GaimBlistNode*)buddy)); |
| 6695 | 624 |
| 625 bnode = (GaimBlistNode *)buddy; | |
| 5228 | 626 |
| 6695 | 627 /* if we're moving to overtop of ourselves, do nothing */ |
| 628 if(bnode == node || (!node && bnode->parent && | |
| 629 contact && bnode->parent == (GaimBlistNode*)contact | |
| 630 && bnode == bnode->parent->child)) | |
| 631 return; | |
| 632 | |
| 633 if(node && GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
| 634 c = (GaimContact*)node->parent; | |
| 635 g = (GaimGroup*)node->parent->parent; | |
| 636 } else if(contact) { | |
| 637 c = contact; | |
| 638 g = (GaimGroup*)((GaimBlistNode*)c)->parent; | |
| 639 } else { | |
| 640 if(group) { | |
| 641 g = group; | |
| 642 } else { | |
| 5228 | 643 g = gaim_group_new(_("Buddies")); |
| 5634 | 644 gaim_blist_add_group(g, |
| 645 gaim_blist_get_last_sibling(gaimbuddylist->root)); | |
| 5228 | 646 } |
| 6695 | 647 c = gaim_contact_new(); |
| 648 gaim_blist_add_contact(c, g, | |
| 649 gaim_blist_get_last_child((GaimBlistNode*)g)); | |
| 5228 | 650 } |
| 651 | |
| 6695 | 652 cnode = (GaimBlistNode *)c; |
| 5228 | 653 |
| 6695 | 654 if(bnode->parent) { |
| 655 if(GAIM_BUDDY_IS_ONLINE(buddy)) { | |
| 656 ((GaimContact*)bnode->parent)->online--; | |
| 657 if(((GaimContact*)bnode->parent)->online == 0) | |
| 658 ((GaimGroup*)bnode->parent->parent)->online--; | |
| 659 } | |
| 660 if(gaim_account_is_connected(buddy->account)) { | |
| 661 ((GaimContact*)bnode->parent)->currentsize--; | |
| 662 if(((GaimContact*)bnode->parent)->currentsize == 0) | |
| 663 ((GaimGroup*)bnode->parent->parent)->currentsize--; | |
| 664 } | |
| 665 ((GaimContact*)bnode->parent)->totalsize--; | |
| 666 /* the group totalsize will be taken care of by remove_contact below */ | |
| 667 | |
| 668 if(bnode->parent->parent != (GaimBlistNode*)g) | |
| 669 serv_move_buddy(buddy, (GaimGroup *)bnode->parent->parent, g); | |
| 5277 | 670 |
| 5228 | 671 if(bnode->next) |
| 672 bnode->next->prev = bnode->prev; | |
| 673 if(bnode->prev) | |
| 674 bnode->prev->next = bnode->next; | |
| 6794 | 675 if(bnode->parent->child == bnode) |
| 5228 | 676 bnode->parent->child = bnode->next; |
| 677 | |
| 678 ops->remove(gaimbuddylist, bnode); | |
| 679 | |
| 680 save = TRUE; | |
| 6742 | 681 |
| 682 if(bnode->parent->parent != (GaimBlistNode*)g) { | |
| 683 hb = g_new(struct _gaim_hbuddy, 1); | |
| 7261 | 684 hb->name = g_strdup(gaim_normalize(buddy->account, buddy->name)); |
| 6742 | 685 hb->account = buddy->account; |
| 686 hb->group = bnode->parent->parent; | |
| 6775 | 687 g_hash_table_remove(gaimbuddylist->buddies, hb); |
| 7162 | 688 g_free(hb->name); |
| 6742 | 689 g_free(hb); |
| 690 } | |
| 6794 | 691 |
| 7003 | 692 if(!bnode->parent->child) { |
| 6794 | 693 gaim_blist_remove_contact((GaimContact*)bnode->parent); |
| 7003 | 694 } else { |
| 695 gaim_contact_compute_priority_buddy((GaimContact*)bnode->parent); | |
| 696 ops->update(gaimbuddylist, bnode->parent); | |
| 697 } | |
| 5228 | 698 } |
| 699 | |
| 6695 | 700 if(node && GAIM_BLIST_NODE_IS_BUDDY(node)) { |
| 701 if(node->next) | |
| 702 node->next->prev = bnode; | |
| 703 bnode->next = node->next; | |
| 704 bnode->prev = node; | |
| 705 bnode->parent = node->parent; | |
| 706 node->next = bnode; | |
| 5228 | 707 } else { |
| 6695 | 708 if(cnode->child) |
| 709 cnode->child->prev = bnode; | |
| 710 bnode->prev = NULL; | |
| 711 bnode->next = cnode->child; | |
| 712 cnode->child = bnode; | |
| 713 bnode->parent = cnode; | |
| 5228 | 714 } |
| 715 | |
| 6695 | 716 if(GAIM_BUDDY_IS_ONLINE(buddy)) { |
| 717 ((GaimContact*)bnode->parent)->online++; | |
| 718 if(((GaimContact*)bnode->parent)->online == 1) | |
| 719 ((GaimGroup*)bnode->parent->parent)->online++; | |
| 720 } | |
| 721 if(gaim_account_is_connected(buddy->account)) { | |
| 722 ((GaimContact*)bnode->parent)->currentsize++; | |
| 723 if(((GaimContact*)bnode->parent)->currentsize == 1) | |
| 724 ((GaimGroup*)bnode->parent->parent)->currentsize++; | |
| 725 } | |
| 726 ((GaimContact*)bnode->parent)->totalsize++; | |
| 727 | |
| 728 | |
| 6742 | 729 hb = g_new(struct _gaim_hbuddy, 1); |
| 7261 | 730 hb->name = g_strdup(gaim_normalize(buddy->account, buddy->name)); |
| 5247 | 731 hb->account = buddy->account; |
| 6695 | 732 hb->group = ((GaimBlistNode*)buddy)->parent->parent; |
| 5247 | 733 |
| 6742 | 734 g_hash_table_replace(gaimbuddylist->buddies, hb, buddy); |
| 5247 | 735 |
| 6843 | 736 gaim_contact_compute_priority_buddy(gaim_buddy_get_contact(buddy)); |
| 5228 | 737 if (ops) |
| 738 ops->update(gaimbuddylist, (GaimBlistNode*)buddy); | |
| 739 if (save) | |
| 740 gaim_blist_save(); | |
| 741 } | |
| 742 | |
| 6695 | 743 GaimContact *gaim_contact_new() |
| 5228 | 744 { |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
745 GaimBlistUiOps *ops; |
| 6695 | 746 GaimContact *c = g_new0(GaimContact, 1); |
| 747 ((GaimBlistNode*)c)->type = GAIM_BLIST_CONTACT_NODE; | |
| 748 | |
| 749 c->totalsize = c->currentsize = c->online = 0; | |
| 750 | |
|
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7003
diff
changeset
|
751 ops = gaim_blist_get_ui_ops(); |
| 6695 | 752 if (ops != NULL && ops->new_node != NULL) |
| 753 ops->new_node((GaimBlistNode *)c); | |
| 754 | |
| 755 return c; | |
| 756 } | |
| 757 | |
| 6755 | 758 void gaim_contact_set_alias(GaimContact* contact, const char *alias) |
| 759 { | |
| 7245 | 760 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
| 761 | |
| 6755 | 762 g_return_if_fail(contact != NULL); |
| 763 | |
| 764 if(contact->alias) | |
| 765 g_free(contact->alias); | |
| 766 | |
| 7245 | 767 if(alias && *alias) |
| 768 contact->alias = g_strdup(alias); | |
| 769 else | |
| 770 contact->alias = NULL; | |
| 771 | |
| 772 if (ops) | |
| 773 ops->update(gaimbuddylist, (GaimBlistNode*)contact); | |
| 6755 | 774 } |
| 775 | |
| 776 const char *gaim_contact_get_alias(GaimContact* contact) | |
| 777 { | |
| 7312 | 778 if(!contact) |
| 779 return NULL; | |
| 780 | |
| 781 if(contact->alias) | |
| 782 return contact->alias; | |
| 783 | |
| 784 return gaim_get_buddy_alias(contact->priority); | |
| 6755 | 785 } |
| 786 | |
| 6695 | 787 GaimGroup *gaim_group_new(const char *name) |
| 788 { | |
| 789 GaimGroup *g = gaim_find_group(name); | |
| 5228 | 790 |
| 791 if (!g) { | |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
792 GaimBlistUiOps *ops; |
| 6695 | 793 g= g_new0(GaimGroup, 1); |
| 5228 | 794 g->name = g_strdup(name); |
| 5277 | 795 g->totalsize = 0; |
| 796 g->currentsize = 0; | |
| 797 g->online = 0; | |
| 5228 | 798 g->settings = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 799 g_free, g_free); | |
| 800 ((GaimBlistNode*)g)->type = GAIM_BLIST_GROUP_NODE; | |
| 801 | |
|
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7003
diff
changeset
|
802 ops = gaim_blist_get_ui_ops(); |
| 5228 | 803 |
| 804 if (ops != NULL && ops->new_node != NULL) | |
| 805 ops->new_node((GaimBlistNode *)g); | |
| 806 | |
| 807 } | |
| 808 return g; | |
| 809 } | |
| 810 | |
| 6695 | 811 void gaim_blist_add_contact(GaimContact *contact, GaimGroup *group, GaimBlistNode *node) |
| 812 { | |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
813 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
| 6695 | 814 GaimGroup *g; |
| 6742 | 815 GaimBlistNode *gnode, *cnode, *bnode; |
| 6695 | 816 gboolean save = FALSE; |
| 817 | |
| 6774 | 818 g_return_if_fail(contact != NULL); |
| 819 g_return_if_fail(GAIM_BLIST_NODE_IS_CONTACT((GaimBlistNode*)contact)); | |
| 6695 | 820 |
| 6975 | 821 if((GaimBlistNode*)contact == node) |
| 822 return; | |
| 823 | |
| 6695 | 824 if(node && (GAIM_BLIST_NODE_IS_CONTACT(node) || |
| 825 GAIM_BLIST_NODE_IS_CHAT(node))) | |
| 826 g = (GaimGroup*)node->parent; | |
| 827 else if(group) | |
| 828 g = group; | |
| 829 else { | |
| 830 g = gaim_group_new(_("Buddies")); | |
| 831 gaim_blist_add_group(g, | |
| 832 gaim_blist_get_last_sibling(gaimbuddylist->root)); | |
| 833 } | |
| 834 | |
| 835 gnode = (GaimBlistNode*)g; | |
| 836 cnode = (GaimBlistNode*)contact; | |
| 837 | |
| 838 if(cnode->parent) { | |
| 6731 | 839 if(cnode->parent->child == cnode) |
| 840 cnode->parent->child = cnode->next; | |
| 6695 | 841 if(cnode->prev) |
| 842 cnode->prev->next = cnode->next; | |
| 843 if(cnode->next) | |
| 844 cnode->next->prev = cnode->prev; | |
| 845 | |
| 846 | |
| 847 if(contact->online > 0) | |
| 848 ((GaimGroup*)cnode->parent)->online--; | |
| 849 if(contact->currentsize > 0) | |
| 850 ((GaimGroup*)cnode->parent)->currentsize--; | |
| 851 ((GaimGroup*)cnode->parent)->totalsize--; | |
| 852 | |
| 6731 | 853 ops->remove(gaimbuddylist, cnode); |
| 854 | |
| 6695 | 855 save = TRUE; |
| 6742 | 856 |
| 857 if(cnode->parent != gnode) { | |
| 858 for(bnode = cnode->child; bnode; bnode = bnode->next) { | |
| 859 GaimBuddy *b = (GaimBuddy*)bnode; | |
| 860 | |
| 861 struct _gaim_hbuddy *hb = g_new(struct _gaim_hbuddy, 1); | |
| 7261 | 862 hb->name = g_strdup(gaim_normalize(b->account, b->name)); |
| 6742 | 863 hb->account = b->account; |
| 864 hb->group = cnode->parent; | |
| 865 | |
| 6776 | 866 g_hash_table_remove(gaimbuddylist->buddies, hb); |
| 6742 | 867 |
| 868 hb->group = gnode; | |
| 869 g_hash_table_replace(gaimbuddylist->buddies, hb, b); | |
| 870 | |
| 871 if(b->account->gc) | |
| 872 serv_move_buddy(b, (GaimGroup*)cnode->parent, g); | |
| 873 } | |
| 874 } | |
| 6695 | 875 } |
| 876 | |
| 6775 | 877 |
| 6695 | 878 if(node && (GAIM_BLIST_NODE_IS_CONTACT(node) || |
| 879 GAIM_BLIST_NODE_IS_CHAT(node))) { | |
| 880 if(node->next) | |
| 881 node->next->prev = cnode; | |
| 882 cnode->next = node->next; | |
| 883 cnode->prev = node; | |
| 884 cnode->parent = node->parent; | |
| 885 node->next = cnode; | |
| 886 } else { | |
| 887 if(gnode->child) | |
| 888 gnode->child->prev = cnode; | |
| 889 cnode->prev = NULL; | |
| 890 cnode->next = gnode->child; | |
| 891 gnode->child = cnode; | |
| 892 cnode->parent = gnode; | |
| 893 } | |
| 894 | |
| 895 if(contact->online > 0) | |
| 896 g->online++; | |
| 897 if(contact->currentsize > 0) | |
| 898 g->currentsize++; | |
| 899 g->totalsize++; | |
| 900 | |
| 901 if(ops && cnode->child) | |
| 902 ops->update(gaimbuddylist, cnode); | |
| 6775 | 903 |
| 904 for(bnode = cnode->child; bnode; bnode = bnode->next) | |
| 905 ops->update(gaimbuddylist, bnode); | |
| 906 | |
| 6695 | 907 if (save) |
| 908 gaim_blist_save(); | |
| 909 } | |
| 910 | |
| 7246 | 911 void gaim_blist_merge_contact(GaimContact *source, GaimBlistNode *node) |
| 6965 | 912 { |
| 913 GaimBlistNode *sourcenode = (GaimBlistNode*)source; | |
| 7246 | 914 GaimBlistNode *targetnode; |
| 915 GaimBlistNode *prev, *cur, *next; | |
| 916 GaimContact *target; | |
| 917 | |
| 918 if(GAIM_BLIST_NODE_IS_CONTACT(node)) { | |
| 919 target = (GaimContact*)node; | |
| 920 prev = gaim_blist_get_last_child(node); | |
| 921 } else if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
| 922 target = (GaimContact*)node->parent; | |
| 923 prev = node; | |
| 924 } else { | |
| 6965 | 925 return; |
| 7246 | 926 } |
| 927 | |
| 928 if(source == target || !target) | |
| 929 return; | |
| 930 | |
| 931 targetnode = (GaimBlistNode*)target; | |
| 932 next = sourcenode->child; | |
| 933 | |
| 934 while(next) { | |
| 935 cur = next; | |
| 936 next = cur->next; | |
| 937 if(GAIM_BLIST_NODE_IS_BUDDY(cur)) { | |
| 938 gaim_blist_add_buddy((GaimBuddy*)cur, target, NULL, prev); | |
| 939 prev = cur; | |
| 940 } | |
| 6965 | 941 } |
| 942 } | |
| 943 | |
| 6695 | 944 void gaim_blist_add_group (GaimGroup *group, GaimBlistNode *node) |
| 5228 | 945 { |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
946 GaimBlistUiOps *ops; |
| 5228 | 947 GaimBlistNode *gnode = (GaimBlistNode*)group; |
| 948 gboolean save = FALSE; | |
| 949 | |
| 6774 | 950 g_return_if_fail(group != NULL); |
| 951 g_return_if_fail(GAIM_BLIST_NODE_IS_GROUP((GaimBlistNode*)group)); | |
| 952 | |
| 5228 | 953 if (!gaimbuddylist) |
| 954 gaimbuddylist = gaim_blist_new(); | |
| 955 ops = gaimbuddylist->ui_ops; | |
| 956 | |
| 957 if (!gaimbuddylist->root) { | |
| 958 gaimbuddylist->root = gnode; | |
| 959 return; | |
| 960 } | |
| 961 | |
| 962 /* if we're moving to overtop of ourselves, do nothing */ | |
| 963 if(gnode == node) | |
| 964 return; | |
| 965 | |
| 966 if (gaim_find_group(group->name)) { | |
| 967 /* This is just being moved */ | |
| 968 | |
| 969 ops->remove(gaimbuddylist, (GaimBlistNode*)group); | |
| 970 | |
| 971 if(gnode == gaimbuddylist->root) | |
| 972 gaimbuddylist->root = gnode->next; | |
| 973 if(gnode->prev) | |
| 974 gnode->prev->next = gnode->next; | |
| 975 if(gnode->next) | |
| 976 gnode->next->prev = gnode->prev; | |
| 977 | |
| 978 save = TRUE; | |
| 979 } | |
| 980 | |
| 6695 | 981 if (node && GAIM_BLIST_NODE_IS_GROUP(node)) { |
| 5634 | 982 gnode->next = node->next; |
| 983 gnode->prev = node; | |
| 984 if(node->next) | |
| 985 node->next->prev = gnode; | |
| 986 node->next = gnode; | |
| 987 } else { | |
| 6807 | 988 if(gaimbuddylist->root) |
| 989 gaimbuddylist->root->prev = gnode; | |
| 5634 | 990 gnode->next = gaimbuddylist->root; |
| 991 gnode->prev = NULL; | |
| 992 gaimbuddylist->root = gnode; | |
| 993 } | |
| 994 | |
| 5228 | 995 |
| 996 if (ops) { | |
| 997 ops->update(gaimbuddylist, gnode); | |
| 998 for(node = gnode->child; node; node = node->next) | |
| 999 ops->update(gaimbuddylist, node); | |
| 1000 } | |
| 1001 if (save) | |
| 1002 gaim_blist_save(); | |
| 1003 } | |
| 1004 | |
| 6695 | 1005 void gaim_blist_remove_contact(GaimContact* contact) |
| 5228 | 1006 { |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
1007 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
| 5228 | 1008 |
| 6695 | 1009 GaimBlistNode *gnode, *cnode = (GaimBlistNode*)contact; |
| 1010 | |
| 1011 gnode = cnode->parent; | |
| 1012 | |
| 1013 if(cnode->child) { | |
| 1014 while(cnode->child) { | |
| 1015 gaim_blist_remove_buddy((GaimBuddy*)cnode->child); | |
| 1016 } | |
| 1017 } else { | |
| 1018 if(ops) | |
| 1019 ops->remove(gaimbuddylist, cnode); | |
| 1020 | |
| 1021 if(gnode->child == cnode) | |
| 1022 gnode->child = cnode->next; | |
| 1023 if(cnode->prev) | |
| 1024 cnode->prev->next = cnode->next; | |
| 1025 if(cnode->next) | |
| 1026 cnode->next->prev = cnode->prev; | |
| 1027 | |
| 1028 g_free(contact); | |
| 1029 } | |
| 1030 } | |
| 1031 | |
| 6742 | 1032 void gaim_blist_remove_buddy (GaimBuddy *buddy) |
| 6695 | 1033 { |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
1034 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
| 6695 | 1035 |
| 1036 GaimBlistNode *cnode, *node = (GaimBlistNode*)buddy; | |
| 1037 GaimGroup *group; | |
| 6742 | 1038 struct _gaim_hbuddy hb; |
| 5228 | 1039 |
| 6695 | 1040 cnode = node->parent; |
| 1041 group = (GaimGroup *)cnode->parent; | |
| 5228 | 1042 |
| 6695 | 1043 if(GAIM_BUDDY_IS_ONLINE(buddy)) { |
| 1044 ((GaimContact*)cnode)->online--; | |
| 1045 if(((GaimContact*)cnode)->online == 0) | |
| 1046 group->online--; | |
| 1047 } | |
| 1048 if(gaim_account_is_connected(buddy->account)) { | |
| 1049 ((GaimContact*)cnode)->currentsize--; | |
| 1050 if(((GaimContact*)cnode)->currentsize == 0) | |
| 1051 group->currentsize--; | |
| 1052 } | |
| 1053 ((GaimContact*)cnode)->totalsize--; | |
| 1054 | |
| 5228 | 1055 if (node->prev) |
| 1056 node->prev->next = node->next; | |
| 1057 if (node->next) | |
| 1058 node->next->prev = node->prev; | |
| 6695 | 1059 if(cnode->child == node) { |
| 1060 cnode->child = node->next; | |
| 1061 } | |
| 5228 | 1062 |
| 6755 | 1063 |
| 7261 | 1064 hb.name = g_strdup(gaim_normalize(buddy->account, buddy->name)); |
| 5247 | 1065 hb.account = buddy->account; |
| 6695 | 1066 hb.group = ((GaimBlistNode*)buddy)->parent->parent; |
| 6742 | 1067 g_hash_table_remove(gaimbuddylist->buddies, &hb); |
| 7162 | 1068 g_free(hb.name); |
| 5247 | 1069 |
| 5292 | 1070 if(buddy->timer > 0) |
| 1071 g_source_remove(buddy->timer); | |
| 1072 | |
|
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
1073 if (buddy->icon != NULL) |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
1074 gaim_buddy_icon_unref(buddy->icon); |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
1075 |
| 5228 | 1076 ops->remove(gaimbuddylist, node); |
| 1077 g_hash_table_destroy(buddy->settings); | |
| 1078 g_free(buddy->name); | |
| 1079 g_free(buddy->alias); | |
| 1080 g_free(buddy); | |
| 6755 | 1081 |
| 1082 if(!cnode->child) | |
| 1083 gaim_blist_remove_contact((GaimContact*)cnode); | |
| 5228 | 1084 } |
| 1085 | |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
1086 void gaim_blist_remove_chat (GaimChat *chat) |
| 5234 | 1087 { |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
1088 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
| 5234 | 1089 |
| 1090 GaimBlistNode *gnode, *node = (GaimBlistNode*)chat; | |
| 6695 | 1091 GaimGroup *group; |
| 5234 | 1092 |
| 1093 gnode = node->parent; | |
| 6695 | 1094 group = (GaimGroup *)gnode; |
| 5234 | 1095 |
| 1096 if(gnode->child == node) | |
| 1097 gnode->child = node->next; | |
| 1098 if (node->prev) | |
| 1099 node->prev->next = node->next; | |
| 1100 if (node->next) | |
| 1101 node->next->prev = node->prev; | |
| 5277 | 1102 group->totalsize--; |
| 5855 | 1103 if (gaim_account_is_connected(chat->account)) { |
| 5277 | 1104 group->currentsize--; |
| 5394 | 1105 group->online--; |
| 1106 } | |
| 5234 | 1107 |
| 1108 ops->remove(gaimbuddylist, node); | |
| 1109 g_hash_table_destroy(chat->components); | |
| 1110 g_free(chat->alias); | |
| 1111 g_free(chat); | |
| 1112 } | |
| 1113 | |
| 6695 | 1114 void gaim_blist_remove_group (GaimGroup *group) |
| 5228 | 1115 { |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
1116 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
| 5228 | 1117 GaimBlistNode *node = (GaimBlistNode*)group; |
|
6885
66dd420d3d23
[gaim-migrate @ 7431]
Christian Hammond <chipx86@chipx86.com>
parents:
6872
diff
changeset
|
1118 GList *l; |
| 5228 | 1119 |
| 1120 if(node->child) { | |
| 1121 char *buf; | |
| 1122 int count = 0; | |
| 1123 GaimBlistNode *child = node->child; | |
| 1124 | |
| 1125 while(child) { | |
| 1126 count++; | |
| 1127 child = child->next; | |
| 1128 } | |
| 1129 | |
| 6308 | 1130 buf = g_strdup_printf(ngettext("%d buddy from group %s was not removed " |
| 1131 "because its account was not logged in." | |
| 1132 " This buddy and the group were not " | |
| 1133 "removed.\n", | |
| 1134 "%d buddies from group %s were not " | |
| 1135 "removed because their accounts were " | |
| 6336 | 1136 "not logged in. These buddies and " |
| 1137 "the group were not removed.\n", count), | |
| 6308 | 1138 count, group->name); |
|
5541
aee0ee458974
[gaim-migrate @ 5941]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1139 gaim_notify_error(NULL, NULL, _("Group not removed"), buf); |
| 5228 | 1140 g_free(buf); |
| 1141 return; | |
| 1142 } | |
| 1143 | |
| 1144 if(gaimbuddylist->root == node) | |
| 1145 gaimbuddylist->root = node->next; | |
| 1146 if (node->prev) | |
| 1147 node->prev->next = node->next; | |
| 1148 if (node->next) | |
| 1149 node->next->prev = node->prev; | |
| 1150 | |
|
6885
66dd420d3d23
[gaim-migrate @ 7431]
Christian Hammond <chipx86@chipx86.com>
parents:
6872
diff
changeset
|
1151 for (l = gaim_connections_get_all(); l != NULL; l = l->next) |
|
66dd420d3d23
[gaim-migrate @ 7431]
Christian Hammond <chipx86@chipx86.com>
parents:
6872
diff
changeset
|
1152 { |
|
66dd420d3d23
[gaim-migrate @ 7431]
Christian Hammond <chipx86@chipx86.com>
parents:
6872
diff
changeset
|
1153 GaimConnection *gc = (GaimConnection *)l->data; |
|
66dd420d3d23
[gaim-migrate @ 7431]
Christian Hammond <chipx86@chipx86.com>
parents:
6872
diff
changeset
|
1154 |
|
66dd420d3d23
[gaim-migrate @ 7431]
Christian Hammond <chipx86@chipx86.com>
parents:
6872
diff
changeset
|
1155 if (gaim_connection_get_state(gc) == GAIM_CONNECTED) |
|
66dd420d3d23
[gaim-migrate @ 7431]
Christian Hammond <chipx86@chipx86.com>
parents:
6872
diff
changeset
|
1156 serv_remove_group(gc, group->name); |
|
66dd420d3d23
[gaim-migrate @ 7431]
Christian Hammond <chipx86@chipx86.com>
parents:
6872
diff
changeset
|
1157 } |
|
66dd420d3d23
[gaim-migrate @ 7431]
Christian Hammond <chipx86@chipx86.com>
parents:
6872
diff
changeset
|
1158 |
| 5228 | 1159 ops->remove(gaimbuddylist, node); |
| 1160 g_free(group->name); | |
| 1161 g_free(group); | |
| 1162 } | |
| 1163 | |
| 6695 | 1164 GaimBuddy *gaim_contact_get_priority_buddy(GaimContact *contact) { |
| 6843 | 1165 return contact->priority; |
| 6695 | 1166 } |
| 1167 | |
| 1168 const char *gaim_get_buddy_alias_only(GaimBuddy *b) { | |
|
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1169 if(!b) |
|
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1170 return NULL; |
|
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1171 |
|
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1172 if(b->alias && b->alias[0]) { |
|
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1173 return b->alias; |
|
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1174 } |
|
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1175 else if (b->server_alias != NULL && |
|
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1176 gaim_prefs_get_bool("/core/buddies/use_server_alias")) { |
|
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1177 |
|
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1178 return b->server_alias; |
|
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1179 } |
|
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1180 |
|
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1181 return NULL; |
| 5228 | 1182 } |
| 1183 | |
| 6695 | 1184 const char * gaim_get_buddy_alias (GaimBuddy *buddy) |
| 5228 | 1185 { |
| 6755 | 1186 const char *ret; |
| 1187 | |
| 1188 if(!buddy) | |
| 1189 return _("Unknown"); | |
| 5228 | 1190 |
| 6755 | 1191 ret= gaim_get_buddy_alias_only(buddy); |
| 1192 | |
| 1193 return ret ? ret : buddy->name; | |
| 5228 | 1194 } |
| 1195 | |
| 7125 | 1196 const char *gaim_chat_get_name(GaimChat *chat) |
| 6744 | 1197 { |
| 1198 if(chat->alias && *chat->alias) { | |
| 1199 return chat->alias; | |
| 1200 } else { | |
| 1201 struct proto_chat_entry *pce; | |
| 1202 GList *parts, *tmp; | |
| 1203 char *ret; | |
| 1204 | |
| 1205 parts = GAIM_PLUGIN_PROTOCOL_INFO(chat->account->gc->prpl)->chat_info(chat->account->gc); | |
| 1206 pce = parts->data; | |
| 1207 ret = g_hash_table_lookup(chat->components, pce->identifier); | |
| 1208 for(tmp = parts; tmp; tmp = tmp->next) | |
| 1209 g_free(tmp->data); | |
| 1210 g_list_free(parts); | |
| 1211 | |
| 1212 return ret; | |
| 1213 } | |
| 1214 } | |
| 1215 | |
| 6695 | 1216 GaimBuddy *gaim_find_buddy(GaimAccount *account, const char *name) |
| 5228 | 1217 { |
| 6695 | 1218 GaimBuddy *buddy; |
| 5247 | 1219 struct _gaim_hbuddy hb; |
| 5758 | 1220 GaimBlistNode *group; |
| 5228 | 1221 |
| 1222 if (!gaimbuddylist) | |
| 1223 return NULL; | |
| 6245 | 1224 |
| 1225 if (!name) | |
|
5985
60d9cbfb6bf8
[gaim-migrate @ 6433]
Christian Hammond <chipx86@chipx86.com>
parents:
5947
diff
changeset
|
1226 return NULL; |
| 5228 | 1227 |
| 7261 | 1228 hb.name = g_strdup(gaim_normalize(account, name)); |
| 6245 | 1229 hb.account = account; |
| 5247 | 1230 |
| 6245 | 1231 for(group = gaimbuddylist->root; group; group = group->next) { |
| 5758 | 1232 hb.group = group; |
| 7162 | 1233 if ((buddy = g_hash_table_lookup(gaimbuddylist->buddies, &hb))) { |
| 1234 g_free(hb.name); | |
| 5758 | 1235 return buddy; |
| 7162 | 1236 } |
| 5758 | 1237 } |
| 6245 | 1238 |
| 7162 | 1239 g_free(hb.name); |
| 5758 | 1240 return NULL; |
| 5228 | 1241 } |
| 1242 | |
| 6872 | 1243 GaimBuddy *gaim_find_buddy_in_group(GaimAccount *account, const char *name, |
| 1244 GaimGroup *group) | |
| 1245 { | |
| 1246 struct _gaim_hbuddy hb; | |
| 7162 | 1247 GaimBuddy *ret; |
| 6872 | 1248 |
| 1249 if (!gaimbuddylist) | |
| 1250 return NULL; | |
| 1251 | |
| 1252 if (!name) | |
| 1253 return NULL; | |
| 1254 | |
| 7261 | 1255 hb.name = g_strdup(gaim_normalize(account, name)); |
| 6872 | 1256 hb.account = account; |
| 1257 hb.group = (GaimBlistNode*)group; | |
| 1258 | |
| 7162 | 1259 ret = g_hash_table_lookup(gaimbuddylist->buddies, &hb); |
| 1260 g_free(hb.name); | |
| 1261 return ret; | |
| 6872 | 1262 } |
| 1263 | |
| 6245 | 1264 GSList *gaim_find_buddies(GaimAccount *account, const char *name) |
| 1265 { | |
| 1266 struct buddy *buddy; | |
| 1267 struct _gaim_hbuddy hb; | |
| 1268 GaimBlistNode *group; | |
| 1269 GSList *ret = NULL; | |
| 1270 | |
| 1271 if (!gaimbuddylist) | |
| 1272 return NULL; | |
| 1273 | |
| 1274 if (!name) | |
| 1275 return NULL; | |
| 1276 | |
| 7261 | 1277 hb.name = g_strdup(gaim_normalize(account, name)); |
| 6245 | 1278 hb.account = account; |
| 1279 | |
| 1280 for(group = gaimbuddylist->root; group; group = group->next) { | |
| 1281 hb.group = group; | |
| 1282 if ((buddy = g_hash_table_lookup(gaimbuddylist->buddies, &hb)) != NULL) | |
| 1283 ret = g_slist_append(ret, buddy); | |
| 1284 } | |
| 1285 | |
| 7162 | 1286 g_free(hb.name); |
| 6245 | 1287 return ret; |
| 1288 } | |
| 1289 | |
| 6695 | 1290 GaimGroup *gaim_find_group(const char *name) |
| 5228 | 1291 { |
| 1292 GaimBlistNode *node; | |
| 1293 if (!gaimbuddylist) | |
| 1294 return NULL; | |
| 1295 node = gaimbuddylist->root; | |
| 1296 while(node) { | |
| 6695 | 1297 if (!strcmp(((GaimGroup *)node)->name, name)) |
| 1298 return (GaimGroup *)node; | |
| 5228 | 1299 node = node->next; |
| 1300 } | |
| 1301 return NULL; | |
| 1302 } | |
|
6456
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1303 |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
1304 GaimChat * |
|
6456
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1305 gaim_blist_find_chat(GaimAccount *account, const char *name) |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1306 { |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1307 char *chat_name; |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
1308 GaimChat *chat; |
|
6456
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1309 GaimPlugin *prpl; |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1310 GaimPluginProtocolInfo *prpl_info = NULL; |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1311 struct proto_chat_entry *pce; |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1312 GaimBlistNode *node, *group; |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1313 GList *parts; |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1314 |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1315 g_return_val_if_fail(gaim_get_blist() != NULL, NULL); |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1316 g_return_val_if_fail(name != NULL, NULL); |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1317 |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1318 for (group = gaimbuddylist->root; group != NULL; group = group->next) { |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1319 for (node = group->child; node != NULL; node = node->next) { |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1320 if (GAIM_BLIST_NODE_IS_CHAT(node)) { |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1321 |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
1322 chat = (GaimChat*)node; |
|
6456
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1323 |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1324 prpl = gaim_find_prpl(gaim_account_get_protocol(chat->account)); |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1325 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1326 |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1327 parts = prpl_info->chat_info( |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1328 gaim_account_get_connection(chat->account)); |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1329 |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1330 pce = parts->data; |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1331 chat_name = g_hash_table_lookup(chat->components, |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1332 pce->identifier); |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1333 |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1334 if (chat->account == account && |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1335 name != NULL && !strcmp(chat_name, name)) { |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1336 |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1337 return chat; |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1338 } |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1339 } |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1340 } |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1341 } |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1342 |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1343 return NULL; |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1344 } |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1345 |
| 6695 | 1346 GaimGroup * |
| 7125 | 1347 gaim_chat_get_group(GaimChat *chat) |
|
6456
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1348 { |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1349 g_return_val_if_fail(chat != NULL, NULL); |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1350 |
| 6695 | 1351 return (GaimGroup *)(((GaimBlistNode *)chat)->parent); |
|
6456
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1352 } |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1353 |
| 6695 | 1354 GaimGroup *gaim_find_buddys_group(GaimBuddy *buddy) |
| 5228 | 1355 { |
| 1356 if (!buddy) | |
| 1357 return NULL; | |
|
6706
854a435d2cc3
[gaim-migrate @ 7232]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1358 |
|
854a435d2cc3
[gaim-migrate @ 7232]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1359 if (((GaimBlistNode *)buddy)->parent == NULL) |
|
854a435d2cc3
[gaim-migrate @ 7232]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1360 return NULL; |
|
854a435d2cc3
[gaim-migrate @ 7232]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1361 |
| 6695 | 1362 return (GaimGroup *)(((GaimBlistNode*)buddy)->parent->parent); |
| 5228 | 1363 } |
| 1364 | |
| 6695 | 1365 GSList *gaim_group_get_accounts(GaimGroup *g) |
| 5228 | 1366 { |
| 1367 GSList *l = NULL; | |
| 6695 | 1368 GaimBlistNode *gnode, *cnode, *bnode; |
| 1369 | |
| 1370 gnode = (GaimBlistNode *)g; | |
| 5228 | 1371 |
| 6695 | 1372 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
| 1373 if (GAIM_BLIST_NODE_IS_CHAT(cnode)) { | |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
1374 if(!g_slist_find(l, ((GaimChat *)cnode)->account)) |
|
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
1375 l = g_slist_append(l, ((GaimChat *)cnode)->account); |
| 6695 | 1376 } else if(GAIM_BLIST_NODE_IS_CONTACT(cnode)) { |
| 1377 for(bnode = cnode->child; bnode; bnode = bnode->next) { | |
| 1378 if(GAIM_BLIST_NODE_IS_BUDDY(bnode)) { | |
| 1379 if(!g_slist_find(l, ((GaimBuddy *)bnode)->account)) | |
| 1380 l = g_slist_append(l, ((GaimBuddy *)bnode)->account); | |
| 1381 } | |
| 1382 } | |
| 1383 } | |
| 5228 | 1384 } |
| 6695 | 1385 |
| 5228 | 1386 return l; |
| 1387 } | |
| 1388 | |
|
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1389 void gaim_blist_add_account(GaimAccount *account) |
| 5234 | 1390 { |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
1391 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
| 6695 | 1392 GaimBlistNode *gnode, *cnode, *bnode; |
| 5234 | 1393 |
| 1394 if(!gaimbuddylist) | |
| 1395 return; | |
| 1396 | |
| 6695 | 1397 if(!ops) |
| 1398 return; | |
| 1399 | |
| 1400 for(gnode = gaimbuddylist->root; gnode; gnode = gnode->next) { | |
| 1401 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
| 5234 | 1402 continue; |
| 6695 | 1403 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
| 1404 if(GAIM_BLIST_NODE_IS_CONTACT(cnode)) { | |
| 6956 | 1405 gboolean recompute = FALSE; |
| 6695 | 1406 for(bnode = cnode->child; bnode; bnode = bnode->next) { |
| 1407 if(GAIM_BLIST_NODE_IS_BUDDY(bnode) && | |
| 1408 ((GaimBuddy*)bnode)->account == account) { | |
| 6956 | 1409 recompute = TRUE; |
| 6695 | 1410 ((GaimContact*)cnode)->currentsize++; |
| 1411 if(((GaimContact*)cnode)->currentsize == 1) | |
| 1412 ((GaimGroup*)gnode)->currentsize++; | |
| 1413 if(GAIM_BUDDY_IS_ONLINE((GaimBuddy*)bnode)) { | |
| 1414 ((GaimContact*)cnode)->online++; | |
| 1415 if(((GaimContact*)cnode)->online == 1) | |
| 1416 ((GaimGroup*)gnode)->online++; | |
| 1417 } | |
| 1418 ops->update(gaimbuddylist, bnode); | |
| 1419 } | |
| 1420 } | |
| 6956 | 1421 if(recompute) { |
| 1422 gaim_contact_compute_priority_buddy((GaimContact*)cnode); | |
| 1423 ops->update(gaimbuddylist, cnode); | |
| 1424 } | |
| 6695 | 1425 } else if(GAIM_BLIST_NODE_IS_CHAT(cnode) && |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
1426 ((GaimChat*)cnode)->account == account) { |
| 6901 | 1427 ((GaimGroup *)gnode)->online++; |
| 1428 ((GaimGroup *)gnode)->currentsize++; | |
| 1429 ops->update(gaimbuddylist, cnode); | |
| 5234 | 1430 } |
| 1431 } | |
| 6695 | 1432 ops->update(gaimbuddylist, gnode); |
| 5234 | 1433 } |
| 1434 } | |
| 1435 | |
|
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1436 void gaim_blist_remove_account(GaimAccount *account) |
| 5228 | 1437 { |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
1438 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
| 6695 | 1439 GaimBlistNode *gnode, *cnode, *bnode; |
| 5234 | 1440 |
| 5228 | 1441 if (!gaimbuddylist) |
| 1442 return; | |
| 5234 | 1443 |
| 6695 | 1444 for(gnode = gaimbuddylist->root; gnode; gnode = gnode->next) { |
| 1445 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
| 5234 | 1446 continue; |
| 6695 | 1447 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
| 1448 if(GAIM_BLIST_NODE_IS_CONTACT(cnode)) { | |
| 6957 | 1449 gboolean recompute = FALSE; |
| 6695 | 1450 for(bnode = cnode->child; bnode; bnode = bnode->next) { |
| 1451 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
| 1452 continue; | |
| 1453 if(account == ((GaimBuddy *)bnode)->account) { | |
| 6957 | 1454 recompute = TRUE; |
| 6695 | 1455 if(((GaimBuddy*)bnode)->present == GAIM_BUDDY_ONLINE || |
| 1456 ((GaimBuddy*)bnode)->present == GAIM_BUDDY_SIGNING_ON) { | |
| 1457 ((GaimContact*)cnode)->online--; | |
| 1458 if(((GaimContact*)cnode)->online == 0) | |
| 1459 ((GaimGroup*)gnode)->online--; | |
| 1460 } | |
| 1461 ((GaimContact*)cnode)->currentsize--; | |
| 1462 if(((GaimContact*)cnode)->currentsize == 0) | |
| 1463 ((GaimGroup*)gnode)->currentsize--; | |
| 1464 | |
| 1465 ((GaimBuddy*)bnode)->present = GAIM_BUDDY_OFFLINE; | |
| 1466 | |
| 6803 | 1467 ((GaimBuddy*)bnode)->uc = 0; |
| 1468 ((GaimBuddy*)bnode)->idle = 0; | |
| 1469 ((GaimBuddy*)bnode)->evil = 0; | |
| 1470 | |
| 6945 | 1471 |
| 6695 | 1472 if(ops) |
| 1473 ops->remove(gaimbuddylist, bnode); | |
| 1474 } | |
| 5234 | 1475 } |
| 6983 | 1476 if(recompute) { |
| 6959 | 1477 gaim_contact_compute_priority_buddy((GaimContact*)cnode); |
| 6983 | 1478 if(ops) |
| 1479 ops->update(gaimbuddylist, cnode); | |
| 1480 } | |
| 6695 | 1481 } else if(GAIM_BLIST_NODE_IS_CHAT(cnode) && |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
1482 ((GaimChat*)cnode)->account == account) { |
| 6695 | 1483 ((GaimGroup*)gnode)->currentsize--; |
| 1484 ((GaimGroup*)gnode)->online--; | |
| 1485 if(ops) | |
| 1486 ops->remove(gaimbuddylist, cnode); | |
| 5228 | 1487 } |
| 1488 } | |
| 1489 } | |
| 1490 } | |
| 1491 | |
|
7117
943085b0ff8b
[gaim-migrate @ 7684]
Christian Hammond <chipx86@chipx86.com>
parents:
7115
diff
changeset
|
1492 void gaim_blist_parse_toc_buddy_list(GaimAccount *account, char *config) |
| 5228 | 1493 { |
| 1494 char *c; | |
| 1495 char current[256]; | |
| 1496 GList *bud = NULL; | |
| 1497 | |
| 1498 | |
| 1499 if (config != NULL) { | |
| 1500 | |
| 1501 /* skip "CONFIG:" (if it exists) */ | |
| 1502 c = strncmp(config + 6 /* sizeof(struct sflap_hdr) */ , "CONFIG:", strlen("CONFIG:")) ? | |
| 1503 strtok(config, "\n") : | |
| 1504 strtok(config + 6 /* sizeof(struct sflap_hdr) */ + strlen("CONFIG:"), "\n"); | |
| 1505 do { | |
| 1506 if (c == NULL) | |
| 1507 break; | |
| 1508 if (*c == 'g') { | |
| 1509 char *utf8 = NULL; | |
|
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
1510 utf8 = gaim_utf8_try_convert(c + 2); |
| 5228 | 1511 if (utf8 == NULL) { |
| 1512 g_strlcpy(current, _("Invalid Groupname"), sizeof(current)); | |
| 1513 } else { | |
| 1514 g_strlcpy(current, utf8, sizeof(current)); | |
| 1515 g_free(utf8); | |
| 1516 } | |
| 1517 if (!gaim_find_group(current)) { | |
| 6695 | 1518 GaimGroup *g = gaim_group_new(current); |
| 5634 | 1519 gaim_blist_add_group(g, |
| 1520 gaim_blist_get_last_sibling(gaimbuddylist->root)); | |
| 5228 | 1521 } |
| 1522 } else if (*c == 'b') { /*&& !gaim_find_buddy(user, c + 2)) {*/ | |
| 1523 char nm[80], sw[388], *a, *utf8 = NULL; | |
| 1524 | |
| 1525 if ((a = strchr(c + 2, ':')) != NULL) { | |
| 1526 *a++ = '\0'; /* nul the : */ | |
| 1527 } | |
| 1528 | |
| 1529 g_strlcpy(nm, c + 2, sizeof(nm)); | |
| 1530 if (a) { | |
|
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
1531 utf8 = gaim_utf8_try_convert(a); |
| 5228 | 1532 if (utf8 == NULL) { |
| 1533 gaim_debug(GAIM_DEBUG_ERROR, "toc blist", | |
| 1534 "Failed to convert alias for " | |
| 1535 "'%s' to UTF-8\n", nm); | |
| 1536 } | |
| 1537 } | |
| 1538 if (utf8 == NULL) { | |
| 1539 sw[0] = '\0'; | |
| 1540 } else { | |
| 1541 /* This can leave a partial sequence at the end, | |
| 1542 * but who cares? */ | |
| 1543 g_strlcpy(sw, utf8, sizeof(sw)); | |
| 1544 g_free(utf8); | |
| 1545 } | |
| 1546 | |
| 1547 if (!gaim_find_buddy(account, nm)) { | |
| 6695 | 1548 GaimBuddy *b = gaim_buddy_new(account, nm, sw); |
| 1549 GaimGroup *g = gaim_find_group(current); | |
| 1550 gaim_blist_add_buddy(b, NULL, g, | |
| 5634 | 1551 gaim_blist_get_last_child((GaimBlistNode*)g)); |
| 5228 | 1552 bud = g_list_append(bud, g_strdup(nm)); |
| 1553 } | |
| 1554 } else if (*c == 'p') { | |
|
6378
01289157fc37
[gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1555 gaim_privacy_permit_add(account, c + 2, TRUE); |
| 5228 | 1556 } else if (*c == 'd') { |
|
6378
01289157fc37
[gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1557 gaim_privacy_deny_add(account, c + 2, TRUE); |
| 5228 | 1558 } else if (!strncmp("toc", c, 3)) { |
|
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1559 sscanf(c + strlen(c) - 1, "%d", &account->perm_deny); |
| 5228 | 1560 gaim_debug(GAIM_DEBUG_MISC, "toc blist", |
|
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1561 "permdeny: %d\n", account->perm_deny); |
|
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1562 if (account->perm_deny == 0) |
|
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1563 account->perm_deny = 1; |
| 5228 | 1564 } else if (*c == 'm') { |
|
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1565 sscanf(c + 2, "%d", &account->perm_deny); |
| 5228 | 1566 gaim_debug(GAIM_DEBUG_MISC, "toc blist", |
|
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1567 "permdeny: %d\n", account->perm_deny); |
|
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1568 if (account->perm_deny == 0) |
|
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1569 account->perm_deny = 1; |
| 5228 | 1570 } |
| 1571 } while ((c = strtok(NULL, "\n"))); | |
| 1572 | |
| 1573 if(account->gc) { | |
| 1574 if(bud) { | |
| 1575 GList *node = bud; | |
| 1576 serv_add_buddies(account->gc, bud); | |
| 1577 while(node) { | |
| 1578 g_free(node->data); | |
| 1579 node = node->next; | |
| 1580 } | |
| 1581 } | |
| 1582 serv_set_permit_deny(account->gc); | |
| 1583 } | |
| 1584 g_list_free(bud); | |
| 1585 } | |
| 1586 } | |
| 1587 | |
| 1588 #if 0 | |
| 1589 /* translate an AIM 3 buddylist (*.lst) to a Gaim buddylist */ | |
| 1590 static GString *translate_lst(FILE *src_fp) | |
| 1591 { | |
| 1592 char line[BUF_LEN], *line2; | |
| 1593 char *name; | |
| 1594 int i; | |
| 1595 | |
| 1596 GString *dest = g_string_new("m 1\n"); | |
| 1597 | |
| 1598 while (fgets(line, BUF_LEN, src_fp)) { | |
| 1599 line2 = g_strchug(line); | |
| 1600 if (strstr(line2, "group") == line2) { | |
| 1601 name = strpbrk(line2, " \t\n\r\f") + 1; | |
| 1602 dest = g_string_append(dest, "g "); | |
| 1603 for (i = 0; i < strcspn(name, "\n\r"); i++) | |
| 1604 if (name[i] != '\"') | |
| 1605 dest = g_string_append_c(dest, name[i]); | |
| 1606 dest = g_string_append_c(dest, '\n'); | |
| 1607 } | |
| 1608 if (strstr(line2, "buddy") == line2) { | |
| 1609 name = strpbrk(line2, " \t\n\r\f") + 1; | |
| 1610 dest = g_string_append(dest, "b "); | |
| 1611 for (i = 0; i < strcspn(name, "\n\r"); i++) | |
| 1612 if (name[i] != '\"') | |
| 1613 dest = g_string_append_c(dest, name[i]); | |
| 1614 dest = g_string_append_c(dest, '\n'); | |
| 1615 } | |
| 1616 } | |
| 1617 | |
| 1618 return dest; | |
| 1619 } | |
| 1620 | |
| 1621 | |
| 1622 /* translate an AIM 4 buddylist (*.blt) to Gaim format */ | |
| 1623 static GString *translate_blt(FILE *src_fp) | |
| 1624 { | |
| 1625 int i; | |
| 1626 char line[BUF_LEN]; | |
| 1627 char *buddy; | |
| 1628 | |
| 1629 GString *dest = g_string_new("m 1\n"); | |
| 1630 | |
| 1631 while (strstr(fgets(line, BUF_LEN, src_fp), "Buddy") == NULL); | |
| 1632 while (strstr(fgets(line, BUF_LEN, src_fp), "list") == NULL); | |
| 1633 | |
| 1634 while (1) { | |
| 1635 fgets(line, BUF_LEN, src_fp); g_strchomp(line); | |
| 1636 if (strchr(line, '}') != NULL) | |
| 1637 break; | |
| 1638 | |
| 1639 if (strchr(line, '{') != NULL) { | |
| 1640 /* Syntax starting with "<group> {" */ | |
| 1641 | |
| 1642 dest = g_string_append(dest, "g "); | |
| 1643 buddy = g_strchug(strtok(line, "{")); | |
| 1644 for (i = 0; i < strlen(buddy); i++) | |
| 1645 if (buddy[i] != '\"') | |
| 1646 dest = g_string_append_c(dest, buddy[i]); | |
| 1647 dest = g_string_append_c(dest, '\n'); | |
| 1648 while (strchr(fgets(line, BUF_LEN, src_fp), '}') == NULL) { | |
| 1649 gboolean pounce = FALSE; | |
| 1650 char *e; | |
| 1651 g_strchomp(line); | |
| 1652 buddy = g_strchug(line); | |
| 1653 gaim_debug(GAIM_DEBUG_MISC, "AIM 4 blt import", | |
| 1654 "buddy: \"%s\"\n", buddy); | |
| 1655 dest = g_string_append(dest, "b "); | |
| 1656 if (strchr(buddy, '{') != NULL) { | |
| 1657 /* buddy pounce, etc */ | |
| 1658 char *pos = strchr(buddy, '{') - 1; | |
| 1659 *pos = 0; | |
| 1660 pounce = TRUE; | |
| 1661 } | |
| 1662 if ((e = strchr(buddy, '\"')) != NULL) { | |
| 1663 *e = '\0'; | |
| 1664 buddy++; | |
| 1665 } | |
| 1666 dest = g_string_append(dest, buddy); | |
| 1667 dest = g_string_append_c(dest, '\n'); | |
| 1668 if (pounce) | |
| 1669 do | |
| 1670 fgets(line, BUF_LEN, src_fp); | |
| 1671 while (!strchr(line, '}')); | |
| 1672 } | |
| 1673 } else { | |
| 1674 | |
| 1675 /* Syntax "group buddy buddy ..." */ | |
| 1676 buddy = g_strchug(strtok(line, " \n")); | |
| 1677 dest = g_string_append(dest, "g "); | |
| 1678 if (strchr(buddy, '\"') != NULL) { | |
| 1679 dest = g_string_append(dest, &buddy[1]); | |
| 1680 dest = g_string_append_c(dest, ' '); | |
| 1681 buddy = g_strchug(strtok(NULL, " \n")); | |
| 1682 while (strchr(buddy, '\"') == NULL) { | |
| 1683 dest = g_string_append(dest, buddy); | |
| 1684 dest = g_string_append_c(dest, ' '); | |
| 1685 buddy = g_strchug(strtok(NULL, " \n")); | |
| 1686 } | |
| 1687 buddy[strlen(buddy) - 1] = '\0'; | |
| 1688 dest = g_string_append(dest, buddy); | |
| 1689 } else { | |
| 1690 dest = g_string_append(dest, buddy); | |
| 1691 } | |
| 1692 dest = g_string_append_c(dest, '\n'); | |
| 1693 while ((buddy = g_strchug(strtok(NULL, " \n"))) != NULL) { | |
| 1694 dest = g_string_append(dest, "b "); | |
| 1695 if (strchr(buddy, '\"') != NULL) { | |
| 1696 dest = g_string_append(dest, &buddy[1]); | |
| 1697 dest = g_string_append_c(dest, ' '); | |
| 1698 buddy = g_strchug(strtok(NULL, " \n")); | |
| 1699 while (strchr(buddy, '\"') == NULL) { | |
| 1700 dest = g_string_append(dest, buddy); | |
| 1701 dest = g_string_append_c(dest, ' '); | |
| 1702 buddy = g_strchug(strtok(NULL, " \n")); | |
| 1703 } | |
| 1704 buddy[strlen(buddy) - 1] = '\0'; | |
| 1705 dest = g_string_append(dest, buddy); | |
| 1706 } else { | |
| 1707 dest = g_string_append(dest, buddy); | |
| 1708 } | |
| 1709 dest = g_string_append_c(dest, '\n'); | |
| 1710 } | |
| 1711 } | |
| 1712 } | |
| 1713 | |
| 1714 return dest; | |
| 1715 } | |
| 1716 | |
| 1717 static GString *translate_gnomeicu(FILE *src_fp) | |
| 1718 { | |
| 1719 char line[BUF_LEN]; | |
| 1720 GString *dest = g_string_new("m 1\ng Buddies\n"); | |
| 1721 | |
| 1722 while (strstr(fgets(line, BUF_LEN, src_fp), "NewContacts") == NULL); | |
| 1723 | |
| 1724 while (fgets(line, BUF_LEN, src_fp)) { | |
| 1725 char *eq; | |
| 1726 g_strchomp(line); | |
| 1727 if (line[0] == '\n' || line[0] == '[') | |
| 1728 break; | |
| 1729 eq = strchr(line, '='); | |
| 1730 if (!eq) | |
| 1731 break; | |
| 1732 *eq = ':'; | |
| 1733 eq = strchr(eq, ','); | |
| 1734 if (eq) | |
| 1735 *eq = '\0'; | |
| 1736 dest = g_string_append(dest, "b "); | |
| 1737 dest = g_string_append(dest, line); | |
| 1738 dest = g_string_append_c(dest, '\n'); | |
| 1739 } | |
| 1740 | |
| 1741 return dest; | |
| 1742 } | |
| 1743 #endif | |
| 1744 | |
| 1745 static gchar *get_screenname_filename(const char *name) | |
| 1746 { | |
| 1747 gchar **split; | |
| 1748 gchar *good; | |
| 1749 gchar *ret; | |
| 1750 | |
| 1751 split = g_strsplit(name, G_DIR_SEPARATOR_S, -1); | |
| 1752 good = g_strjoinv(NULL, split); | |
| 1753 g_strfreev(split); | |
| 1754 | |
| 1755 ret = g_utf8_strup(good, -1); | |
| 1756 | |
| 1757 g_free(good); | |
| 1758 | |
| 1759 return ret; | |
| 1760 } | |
| 1761 | |
| 1762 static gboolean gaim_blist_read(const char *filename); | |
| 1763 | |
| 1764 | |
|
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1765 static void do_import(GaimAccount *account, const char *filename) |
| 5228 | 1766 { |
| 1767 GString *buf = NULL; | |
| 1768 char first[64]; | |
| 1769 char path[PATHSIZE]; | |
| 1770 int len; | |
| 1771 FILE *f; | |
| 1772 struct stat st; | |
| 1773 | |
| 1774 if (filename) { | |
| 1775 g_snprintf(path, sizeof(path), "%s", filename); | |
| 1776 } else { | |
| 1777 char *g_screenname = get_screenname_filename(account->username); | |
|
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1778 const char *username; |
| 5228 | 1779 char *file = gaim_user_dir(); |
|
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1780 GaimProtocol prpl_num; |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1781 int protocol; |
| 6695 | 1782 |
|
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1783 prpl_num = gaim_account_get_protocol(account); |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1784 |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1785 protocol = prpl_num; |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1786 |
|
6450
e7b87c8e8c0a
[gaim-migrate @ 6959]
Christian Hammond <chipx86@chipx86.com>
parents:
6392
diff
changeset
|
1787 /* TODO Somehow move this checking into prpls */ |
|
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1788 if (prpl_num == GAIM_PROTO_OSCAR) { |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1789 if ((username = gaim_account_get_username(account)) != NULL) { |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1790 protocol = (isalpha(*username) |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1791 ? GAIM_PROTO_TOC : GAIM_PROTO_ICQ); |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1792 } |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1793 } |
| 5228 | 1794 |
| 1795 if (file != (char *)NULL) { | |
| 5435 | 1796 snprintf(path, PATHSIZE, "%s" G_DIR_SEPARATOR_S "%s.%d.blist", file, g_screenname, protocol); |
| 5228 | 1797 g_free(g_screenname); |
| 1798 } else { | |
| 1799 g_free(g_screenname); | |
| 1800 return; | |
| 1801 } | |
| 1802 } | |
| 1803 | |
| 1804 if (stat(path, &st)) { | |
| 1805 gaim_debug(GAIM_DEBUG_ERROR, "blist import", "Unable to stat %s.\n", | |
| 1806 path); | |
| 1807 return; | |
| 1808 } | |
| 1809 | |
| 1810 if (!(f = fopen(path, "r"))) { | |
| 1811 gaim_debug(GAIM_DEBUG_ERROR, "blist import", "Unable to open %s.\n", | |
| 1812 path); | |
| 1813 return; | |
| 1814 } | |
| 1815 | |
| 1816 fgets(first, 64, f); | |
| 1817 | |
| 1818 if ((first[0] == '\n') || (first[0] == '\r' && first[1] == '\n')) | |
| 1819 fgets(first, 64, f); | |
| 1820 | |
| 1821 #if 0 | |
| 1822 if (!g_strncasecmp(first, "<xml", strlen("<xml"))) { | |
| 1823 /* new gaim XML buddy list */ | |
| 1824 gaim_blist_read(path); | |
| 1825 | |
| 1826 /* We really don't need to bother doing stuf like translating AIM 3 buddy lists anymore */ | |
| 1827 | |
| 1828 } else if (!g_strncasecmp(first, "Config {", strlen("Config {"))) { | |
| 1829 /* AIM 4 buddy list */ | |
| 1830 gaim_debug(GAIM_DEBUG_MISC, "blist import", "aim 4\n"); | |
| 1831 rewind(f); | |
| 1832 buf = translate_blt(f); | |
| 1833 } else if (strstr(first, "group") != NULL) { | |
| 1834 /* AIM 3 buddy list */ | |
| 1835 gaim_debug(GAIM_DEBUG_MISC, "blist import", "aim 3\n"); | |
| 1836 rewind(f); | |
| 1837 buf = translate_lst(f); | |
| 1838 } else if (!g_strncasecmp(first, "[User]", strlen("[User]"))) { | |
| 1839 /* GnomeICU (hopefully) */ | |
| 1840 gaim_debug(GAIM_DEBUG_MISC, "blist import", "gnomeicu\n"); | |
| 1841 rewind(f); | |
| 1842 buf = translate_gnomeicu(f); | |
| 1843 | |
| 1844 } else | |
| 1845 #endif | |
| 1846 if (first[0] == 'm') { | |
| 1847 /* Gaim buddy list - no translation */ | |
| 1848 char buf2[BUF_LONG * 2]; | |
| 1849 buf = g_string_new(""); | |
| 1850 rewind(f); | |
| 1851 while (1) { | |
| 1852 len = fread(buf2, 1, BUF_LONG * 2 - 1, f); | |
| 1853 if (len <= 0) | |
| 1854 break; | |
| 1855 buf2[len] = '\0'; | |
| 1856 buf = g_string_append(buf, buf2); | |
| 1857 if (len != BUF_LONG * 2 - 1) | |
| 1858 break; | |
| 1859 } | |
| 1860 } | |
| 1861 | |
| 1862 fclose(f); | |
| 1863 | |
| 1864 if (buf) { | |
| 1865 buf = g_string_prepend(buf, "toc_set_config {"); | |
| 1866 buf = g_string_append(buf, "}\n"); | |
|
7117
943085b0ff8b
[gaim-migrate @ 7684]
Christian Hammond <chipx86@chipx86.com>
parents:
7115
diff
changeset
|
1867 gaim_blist_parse_toc_buddy_list(account, buf->str); |
| 5228 | 1868 g_string_free(buf, TRUE); |
| 1869 } | |
| 1870 } | |
| 1871 | |
| 6695 | 1872 gboolean gaim_group_on_account(GaimGroup *g, GaimAccount *account) { |
| 1873 GaimBlistNode *cnode, *bnode; | |
| 1874 for(cnode = ((GaimBlistNode *)g)->child; cnode; cnode = cnode->next) { | |
| 1875 if(GAIM_BLIST_NODE_IS_CONTACT(cnode)) { | |
| 1876 for(bnode = cnode->child; bnode; bnode = bnode->next) { | |
| 1877 if(GAIM_BLIST_NODE_IS_BUDDY(bnode)) { | |
| 1878 GaimBuddy *buddy = (GaimBuddy *)bnode; | |
| 1879 if((!account && gaim_account_is_connected(buddy->account)) | |
| 1880 || buddy->account == account) | |
| 1881 return TRUE; | |
| 1882 } | |
| 1883 } | |
| 1884 } else if(GAIM_BLIST_NODE_IS_CHAT(cnode)) { | |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
1885 GaimChat *chat = (GaimChat *)cnode; |
| 6695 | 1886 if((!account && gaim_account_is_connected(chat->account)) |
| 1887 || chat->account == account) | |
| 1888 return TRUE; | |
| 1889 } | |
| 5228 | 1890 } |
| 1891 return FALSE; | |
| 1892 } | |
| 1893 | |
| 1894 static gboolean blist_safe_to_write = FALSE; | |
| 1895 | |
| 7132 | 1896 static void parse_setting(GaimBlistNode *node, xmlnode *setting) |
| 1897 { | |
| 1898 const char *name = xmlnode_get_attrib(setting, "name"); | |
| 1899 char *value = xmlnode_get_data(setting); | |
| 1900 | |
| 1901 /* XXX: replace with generic settings stuff */ | |
| 1902 if(GAIM_BLIST_NODE_IS_GROUP(node)) | |
| 1903 gaim_group_set_setting((GaimGroup*)node, name, value); | |
| 1904 else if(GAIM_BLIST_NODE_IS_CHAT(node)) | |
| 1905 gaim_chat_set_setting((GaimChat*)node, name, value); | |
| 1906 else if(GAIM_BLIST_NODE_IS_BUDDY(node)) | |
| 1907 gaim_buddy_set_setting((GaimBuddy*)node, name, value); | |
| 1908 | |
| 1909 g_free(value); | |
| 1910 } | |
| 1911 | |
| 1912 static void parse_buddy(GaimGroup *group, GaimContact *contact, xmlnode *bnode) | |
| 1913 { | |
| 1914 GaimAccount *account; | |
| 1915 GaimBuddy *buddy; | |
| 1916 char *name = NULL, *alias = NULL; | |
| 7153 | 1917 const char *acct_name, *proto, *protocol; |
| 7132 | 1918 xmlnode *x; |
| 1919 | |
| 1920 acct_name = xmlnode_get_attrib(bnode, "account"); | |
| 7153 | 1921 protocol = xmlnode_get_attrib(bnode, "protocol"); |
| 1922 proto = xmlnode_get_attrib(bnode, "proto"); | |
| 1923 | |
| 1924 if(!acct_name || (!proto && !protocol)) | |
| 7132 | 1925 return; |
| 1926 | |
| 7153 | 1927 account = gaim_accounts_find(acct_name, proto ? proto : protocol); |
| 7132 | 1928 |
| 1929 if(!account) | |
| 1930 return; | |
| 1931 | |
| 1932 if((x = xmlnode_get_child(bnode, "name"))) | |
| 1933 name = xmlnode_get_data(x); | |
| 1934 | |
| 1935 if(!name) | |
| 1936 return; | |
| 1937 | |
| 1938 if((x = xmlnode_get_child(bnode, "alias"))) | |
| 1939 alias = xmlnode_get_data(x); | |
| 1940 | |
| 1941 buddy = gaim_buddy_new(account, name, alias); | |
| 1942 gaim_blist_add_buddy(buddy, contact, group, | |
| 1943 gaim_blist_get_last_child((GaimBlistNode*)contact)); | |
| 1944 | |
| 1945 for(x = bnode->child; x; x = x->next) { | |
| 1946 if(x->type != NODE_TYPE_TAG || strcmp(x->name, "setting")) | |
| 1947 continue; | |
| 1948 parse_setting((GaimBlistNode*)buddy, x); | |
| 1949 } | |
| 1950 | |
| 1951 g_free(name); | |
| 1952 if(alias) | |
| 1953 g_free(alias); | |
| 1954 } | |
| 1955 | |
| 1956 static void parse_contact(GaimGroup *group, xmlnode *cnode) | |
| 1957 { | |
| 1958 GaimContact *contact = gaim_contact_new(); | |
| 1959 xmlnode *x; | |
| 7245 | 1960 const char *alias; |
| 7132 | 1961 |
| 1962 gaim_blist_add_contact(contact, group, | |
| 1963 gaim_blist_get_last_child((GaimBlistNode*)group)); | |
| 1964 | |
| 7245 | 1965 if((alias = xmlnode_get_attrib(cnode, "alias"))) { |
| 7132 | 1966 gaim_contact_set_alias(contact, alias); |
| 1967 } | |
| 1968 | |
| 1969 for(x = cnode->child; x; x = x->next) { | |
| 1970 if(x->type != NODE_TYPE_TAG) | |
| 1971 continue; | |
| 1972 if(!strcmp(x->name, "buddy")) | |
| 1973 parse_buddy(group, contact, x); | |
| 1974 else if(strcmp(x->name, "setting")) | |
| 1975 parse_setting((GaimBlistNode*)contact, x); | |
| 5228 | 1976 } |
| 1977 } | |
| 1978 | |
| 7132 | 1979 static void parse_chat(GaimGroup *group, xmlnode *cnode) |
| 1980 { | |
| 1981 GaimChat *chat; | |
| 1982 GaimAccount *account; | |
| 7153 | 1983 const char *acct_name, *proto, *protocol; |
| 7132 | 1984 xmlnode *x; |
| 1985 char *alias = NULL; | |
| 1986 GHashTable *components; | |
| 1987 | |
| 1988 acct_name = xmlnode_get_attrib(cnode, "account"); | |
| 7153 | 1989 protocol = xmlnode_get_attrib(cnode, "protocol"); |
| 1990 proto = xmlnode_get_attrib(cnode, "proto"); | |
| 1991 | |
| 1992 if(!acct_name || (!proto && !protocol)) | |
| 7132 | 1993 return; |
| 1994 | |
| 7153 | 1995 account = gaim_accounts_find(acct_name, proto ? proto : protocol); |
| 7132 | 1996 |
| 1997 if(!account) | |
| 1998 return; | |
| 1999 | |
| 2000 if((x = xmlnode_get_child(cnode, "alias"))) | |
| 2001 alias = xmlnode_get_data(x); | |
| 2002 | |
| 2003 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | |
| 2004 | |
| 2005 for(x = cnode->child; x; x = x->next) { | |
| 2006 const char *name; | |
| 2007 char *value; | |
| 2008 if(x->type != NODE_TYPE_TAG || strcmp(x->name, "component")) | |
| 2009 continue; | |
| 2010 | |
| 2011 name = xmlnode_get_attrib(x, "name"); | |
| 2012 value = xmlnode_get_data(x); | |
| 2013 g_hash_table_replace(components, g_strdup(name), value); | |
| 2014 } | |
| 2015 | |
| 2016 chat = gaim_chat_new(account, alias, components); | |
| 7151 | 2017 gaim_blist_add_chat(chat, group, |
| 2018 gaim_blist_get_last_child((GaimBlistNode*)group)); | |
| 7132 | 2019 |
| 2020 for(x = cnode->child; x; x = x->next) { | |
| 2021 if(x->type != NODE_TYPE_TAG || strcmp(x->name, "setting")) | |
| 2022 continue; | |
| 2023 parse_setting((GaimBlistNode*)chat, x); | |
| 2024 } | |
| 2025 | |
| 2026 if(alias) | |
| 2027 g_free(alias); | |
| 2028 } | |
| 2029 | |
| 2030 | |
| 2031 static void parse_group(xmlnode *groupnode) | |
| 2032 { | |
| 2033 const char *name = xmlnode_get_attrib(groupnode, "name"); | |
| 2034 GaimGroup *group; | |
| 2035 xmlnode *cnode; | |
| 2036 | |
| 2037 if(!name) | |
| 2038 name = _("Buddies"); | |
| 2039 | |
| 2040 group = gaim_group_new(name); | |
| 2041 gaim_blist_add_group(group, | |
| 2042 gaim_blist_get_last_sibling(gaimbuddylist->root)); | |
| 2043 | |
| 2044 for(cnode = groupnode->child; cnode; cnode = cnode->next) { | |
| 2045 if(cnode->type != NODE_TYPE_TAG) | |
| 2046 continue; | |
| 2047 if(!strcmp(cnode->name, "setting")) | |
| 2048 parse_setting((GaimBlistNode*)group, cnode); | |
| 2049 else if(!strcmp(cnode->name, "contact") || | |
| 2050 !strcmp(cnode->name, "person")) | |
| 2051 parse_contact(group, cnode); | |
| 2052 else if(!strcmp(cnode->name, "chat")) | |
| 2053 parse_chat(group, cnode); | |
| 5228 | 2054 } |
| 2055 } | |
| 2056 | |
| 2057 static gboolean gaim_blist_read(const char *filename) { | |
| 7132 | 2058 GError *error; |
| 5228 | 2059 gchar *contents = NULL; |
| 2060 gsize length; | |
| 7132 | 2061 xmlnode *gaim, *blist, *privacy; |
| 5228 | 2062 |
| 2063 gaim_debug(GAIM_DEBUG_INFO, "blist import", | |
| 2064 "Reading %s\n", filename); | |
| 2065 if(!g_file_get_contents(filename, &contents, &length, &error)) { | |
| 2066 gaim_debug(GAIM_DEBUG_ERROR, "blist import", | |
| 2067 "Error reading blist: %s\n", error->message); | |
| 2068 g_error_free(error); | |
| 2069 return FALSE; | |
| 2070 } | |
| 2071 | |
| 7132 | 2072 gaim = xmlnode_from_str(contents, length); |
| 2073 g_free(contents); | |
| 2074 | |
| 2075 if(!gaim) { | |
| 2076 gaim_debug(GAIM_DEBUG_ERROR, "blist import", "Error parsing %s\n", | |
| 2077 filename); | |
| 5228 | 2078 return FALSE; |
| 2079 } | |
| 2080 | |
| 7132 | 2081 blist = xmlnode_get_child(gaim, "blist"); |
| 2082 if(blist) { | |
| 2083 xmlnode *groupnode; | |
| 2084 for(groupnode = blist->child; groupnode; groupnode = groupnode->next) { | |
| 2085 if(groupnode->type != NODE_TYPE_TAG || | |
| 2086 strcmp(groupnode->name, "group")) | |
| 2087 continue; | |
| 2088 | |
| 2089 parse_group(groupnode); | |
| 2090 } | |
| 5228 | 2091 } |
| 2092 | |
| 7132 | 2093 privacy = xmlnode_get_child(gaim, "privacy"); |
| 2094 if(privacy) { | |
| 2095 xmlnode *anode; | |
| 2096 for(anode = privacy->child; anode; anode = anode->next) { | |
| 2097 xmlnode *x; | |
| 2098 GaimAccount *account; | |
| 7153 | 2099 const char *acct_name, *proto, *mode, *protocol; |
| 7132 | 2100 |
| 2101 acct_name = xmlnode_get_attrib(anode, "name"); | |
| 7153 | 2102 protocol = xmlnode_get_attrib(anode, "protocol"); |
| 2103 proto = xmlnode_get_attrib(anode, "proto"); | |
| 7132 | 2104 mode = xmlnode_get_attrib(anode, "mode"); |
| 2105 | |
| 7153 | 2106 if(!acct_name || (!proto && !protocol) || !mode) |
| 7132 | 2107 continue; |
| 2108 | |
| 7153 | 2109 account = gaim_accounts_find(acct_name, proto ? proto : protocol); |
| 7132 | 2110 |
| 2111 if(!account) | |
| 2112 continue; | |
| 2113 | |
| 2114 account->perm_deny = atoi(mode); | |
| 2115 | |
| 2116 for(x = anode->child; x; x = x->next) { | |
| 2117 char *name; | |
| 2118 if(x->type != NODE_TYPE_TAG) | |
| 2119 continue; | |
| 2120 | |
| 2121 if(!strcmp(x->name, "permit")) { | |
| 2122 name = xmlnode_get_data(x); | |
| 2123 gaim_privacy_permit_add(account, name, TRUE); | |
| 2124 g_free(name); | |
| 2125 } else if(!strcmp(x->name, "block")) { | |
| 2126 name = xmlnode_get_data(x); | |
| 2127 gaim_privacy_deny_add(account, name, TRUE); | |
| 2128 g_free(name); | |
| 2129 } | |
| 2130 } | |
| 2131 } | |
| 2132 } | |
| 5228 | 2133 |
| 2134 gaim_debug(GAIM_DEBUG_INFO, "blist import", "Finished reading %s\n", | |
| 2135 filename); | |
| 2136 | |
| 2137 return TRUE; | |
| 2138 } | |
| 2139 | |
| 2140 void gaim_blist_load() { | |
|
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
2141 GList *accts; |
| 5228 | 2142 char *user_dir = gaim_user_dir(); |
| 2143 char *filename; | |
| 2144 char *msg; | |
| 2145 | |
| 2146 blist_safe_to_write = TRUE; | |
| 2147 | |
| 2148 if(!user_dir) | |
| 2149 return; | |
| 2150 | |
| 2151 filename = g_build_filename(user_dir, "blist.xml", NULL); | |
| 2152 | |
| 2153 if(g_file_test(filename, G_FILE_TEST_EXISTS)) { | |
| 2154 if(!gaim_blist_read(filename)) { | |
| 2155 msg = g_strdup_printf(_("An error was encountered parsing your " | |
| 2156 "buddy list. It has not been loaded.")); | |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2157 gaim_notify_error(NULL, NULL, _("Buddy List Error"), msg); |
| 5228 | 2158 g_free(msg); |
| 2159 } | |
|
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
2160 } else if(g_list_length(gaim_accounts_get_all())) { |
| 5228 | 2161 /* 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
|
2162 for(accts = gaim_accounts_get_all(); accts; accts = accts->next) { |
| 5228 | 2163 do_import(accts->data, NULL); |
| 2164 } | |
| 2165 gaim_blist_save(); | |
| 2166 } | |
| 2167 | |
| 2168 g_free(filename); | |
| 2169 } | |
| 2170 | |
|
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2171 void |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2172 gaim_blist_request_add_buddy(GaimAccount *account, const char *username, |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2173 const char *group, const char *alias) |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2174 { |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
2175 GaimBlistUiOps *ui_ops; |
|
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2176 |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2177 ui_ops = gaim_blist_get_ui_ops(); |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2178 |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2179 if (ui_ops != NULL && ui_ops->request_add_buddy != NULL) |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2180 ui_ops->request_add_buddy(account, username, group, alias); |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2181 } |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2182 |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2183 void |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2184 gaim_blist_request_add_chat(GaimAccount *account, GaimGroup *group) |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2185 { |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
2186 GaimBlistUiOps *ui_ops; |
|
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2187 |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2188 ui_ops = gaim_blist_get_ui_ops(); |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2189 |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2190 if (ui_ops != NULL && ui_ops->request_add_chat != NULL) |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2191 ui_ops->request_add_chat(account, group); |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2192 } |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2193 |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2194 void |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2195 gaim_blist_request_add_group(void) |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2196 { |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
2197 GaimBlistUiOps *ui_ops; |
|
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2198 |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2199 ui_ops = gaim_blist_get_ui_ops(); |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2200 |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2201 if (ui_ops != NULL && ui_ops->request_add_group != NULL) |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2202 ui_ops->request_add_group(); |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2203 } |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2204 |
| 5228 | 2205 static void blist_print_group_settings(gpointer key, gpointer data, |
| 2206 gpointer user_data) { | |
| 2207 char *key_val; | |
| 2208 char *data_val; | |
| 2209 FILE *file = user_data; | |
| 2210 | |
| 2211 if(!key || !data) | |
| 2212 return; | |
| 2213 | |
| 2214 key_val = g_markup_escape_text(key, -1); | |
| 2215 data_val = g_markup_escape_text(data, -1); | |
| 2216 | |
| 2217 fprintf(file, "\t\t\t<setting name=\"%s\">%s</setting>\n", key_val, | |
| 2218 data_val); | |
| 2219 g_free(key_val); | |
| 2220 g_free(data_val); | |
| 2221 } | |
| 2222 | |
| 2223 static void blist_print_buddy_settings(gpointer key, gpointer data, | |
| 2224 gpointer user_data) { | |
| 2225 char *key_val; | |
| 2226 char *data_val; | |
| 2227 FILE *file = user_data; | |
| 2228 | |
| 2229 if(!key || !data) | |
| 2230 return; | |
| 2231 | |
| 2232 key_val = g_markup_escape_text(key, -1); | |
| 2233 data_val = g_markup_escape_text(data, -1); | |
| 2234 | |
| 2235 fprintf(file, "\t\t\t\t\t<setting name=\"%s\">%s</setting>\n", key_val, | |
| 2236 data_val); | |
| 2237 g_free(key_val); | |
| 2238 g_free(data_val); | |
| 2239 } | |
| 2240 | |
| 6695 | 2241 static void blist_print_cnode_settings(gpointer key, gpointer data, |
| 2242 gpointer user_data) { | |
| 2243 char *key_val; | |
| 2244 char *data_val; | |
| 2245 FILE *file = user_data; | |
| 2246 | |
| 2247 if(!key || !data) | |
| 2248 return; | |
| 2249 | |
| 2250 key_val = g_markup_escape_text(key, -1); | |
| 2251 data_val = g_markup_escape_text(data, -1); | |
| 2252 | |
| 2253 fprintf(file, "\t\t\t\t<setting name=\"%s\">%s</setting>\n", key_val, | |
| 2254 data_val); | |
| 2255 g_free(key_val); | |
| 2256 g_free(data_val); | |
| 2257 } | |
| 2258 | |
| 5234 | 2259 static void blist_print_chat_components(gpointer key, gpointer data, |
| 2260 gpointer user_data) { | |
| 2261 char *key_val; | |
| 2262 char *data_val; | |
| 2263 FILE *file = user_data; | |
| 2264 | |
| 2265 if(!key || !data) | |
| 2266 return; | |
| 2267 | |
| 2268 key_val = g_markup_escape_text(key, -1); | |
| 2269 data_val = g_markup_escape_text(data, -1); | |
| 2270 | |
| 2271 fprintf(file, "\t\t\t\t<component name=\"%s\">%s</component>\n", key_val, | |
| 2272 data_val); | |
| 2273 g_free(key_val); | |
| 2274 g_free(data_val); | |
| 2275 } | |
| 2276 | |
| 6695 | 2277 static void print_buddy(FILE *file, GaimBuddy *buddy) { |
| 2278 char *bud_name = g_markup_escape_text(buddy->name, -1); | |
| 2279 char *bud_alias = NULL; | |
| 2280 char *acct_name = g_markup_escape_text(buddy->account->username, -1); | |
| 7153 | 2281 int proto_num = gaim_account_get_protocol(buddy->account); |
| 6695 | 2282 if(buddy->alias) |
| 2283 bud_alias= g_markup_escape_text(buddy->alias, -1); | |
| 7153 | 2284 fprintf(file, "\t\t\t\t<buddy account=\"%s\" proto=\"%s\"", acct_name, |
| 2285 gaim_account_get_protocol_id(buddy->account)); | |
| 2286 if(proto_num != -1) | |
| 2287 fprintf(file, " protocol=\"%d\"", proto_num); | |
| 2288 fprintf(file, ">\n"); | |
| 2289 | |
| 6695 | 2290 fprintf(file, "\t\t\t\t\t<name>%s</name>\n", bud_name); |
| 2291 if(bud_alias) { | |
| 2292 fprintf(file, "\t\t\t\t\t<alias>%s</alias>\n", bud_alias); | |
| 2293 } | |
| 2294 g_hash_table_foreach(buddy->settings, blist_print_buddy_settings, file); | |
| 2295 fprintf(file, "\t\t\t\t</buddy>\n"); | |
| 2296 g_free(bud_name); | |
| 2297 g_free(bud_alias); | |
| 2298 g_free(acct_name); | |
| 2299 } | |
| 2300 | |
|
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
2301 static void gaim_blist_write(FILE *file, GaimAccount *exp_acct) { |
|
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
2302 GList *accounts; |
|
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
2303 GSList *buds; |
| 6695 | 2304 GaimBlistNode *gnode, *cnode, *bnode; |
| 5228 | 2305 fprintf(file, "<?xml version='1.0' encoding='UTF-8' ?>\n"); |
| 2306 fprintf(file, "<gaim version=\"1\">\n"); | |
| 2307 fprintf(file, "\t<blist>\n"); | |
| 2308 | |
| 2309 for(gnode = gaimbuddylist->root; gnode; gnode = gnode->next) { | |
| 6695 | 2310 GaimGroup *group; |
| 2311 | |
| 5228 | 2312 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
| 2313 continue; | |
| 6695 | 2314 |
| 2315 group = (GaimGroup *)gnode; | |
| 5228 | 2316 if(!exp_acct || gaim_group_on_account(group, exp_acct)) { |
| 2317 char *group_name = g_markup_escape_text(group->name, -1); | |
| 2318 fprintf(file, "\t\t<group name=\"%s\">\n", group_name); | |
| 2319 g_hash_table_foreach(group->settings, blist_print_group_settings, file); | |
| 6695 | 2320 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
| 2321 if(GAIM_BLIST_NODE_IS_CONTACT(cnode)) { | |
| 6755 | 2322 GaimContact *contact = (GaimContact*)cnode; |
| 2323 fprintf(file, "\t\t\t<contact"); | |
| 2324 if(contact->alias) { | |
| 2325 char *alias = g_markup_escape_text(contact->alias, -1); | |
| 2326 fprintf(file, " alias=\"%s\"", alias); | |
| 2327 g_free(alias); | |
| 2328 } | |
| 2329 fprintf(file, ">\n"); | |
| 6695 | 2330 |
| 2331 for(bnode = cnode->child; bnode; bnode = bnode->next) { | |
| 2332 if(GAIM_BLIST_NODE_IS_BUDDY(bnode)) { | |
| 2333 GaimBuddy *buddy = (GaimBuddy *)bnode; | |
| 2334 if(!exp_acct || buddy->account == exp_acct) { | |
| 2335 print_buddy(file, buddy); | |
| 2336 } | |
| 5234 | 2337 } |
| 5228 | 2338 } |
| 6695 | 2339 |
| 2340 fprintf(file, "\t\t\t</contact>\n"); | |
| 2341 } else if(GAIM_BLIST_NODE_IS_CHAT(cnode)) { | |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
2342 GaimChat *chat = (GaimChat *)cnode; |
| 5234 | 2343 if(!exp_acct || chat->account == exp_acct) { |
| 2344 char *acct_name = g_markup_escape_text(chat->account->username, -1); | |
| 7153 | 2345 int proto_num = gaim_account_get_protocol(chat->account); |
| 2346 fprintf(file, "\t\t\t<chat proto=\"%s\" account=\"%s\"", | |
| 7133 | 2347 gaim_account_get_protocol_id(chat->account), |
|
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
2348 acct_name); |
| 7153 | 2349 if(proto_num != -1) |
| 2350 fprintf(file, " protocol=\"%d\"", proto_num); | |
| 2351 fprintf(file, ">\n"); | |
| 2352 | |
| 5237 | 2353 if(chat->alias) { |
| 2354 char *chat_alias = g_markup_escape_text(chat->alias, -1); | |
| 2355 fprintf(file, "\t\t\t\t<alias>%s</alias>\n", chat_alias); | |
| 2356 g_free(chat_alias); | |
| 2357 } | |
| 5234 | 2358 g_hash_table_foreach(chat->components, |
| 2359 blist_print_chat_components, file); | |
| 5906 | 2360 g_hash_table_foreach(chat->settings, |
| 6695 | 2361 blist_print_cnode_settings, file); |
| 5234 | 2362 fprintf(file, "\t\t\t</chat>\n"); |
| 5237 | 2363 g_free(acct_name); |
| 5234 | 2364 } |
| 5228 | 2365 } |
| 2366 } | |
| 2367 fprintf(file, "\t\t</group>\n"); | |
| 2368 g_free(group_name); | |
| 2369 } | |
| 2370 } | |
| 2371 | |
| 2372 fprintf(file, "\t</blist>\n"); | |
| 2373 fprintf(file, "\t<privacy>\n"); | |
| 2374 | |
|
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
2375 for(accounts = gaim_accounts_get_all(); |
|
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
2376 accounts != NULL; |
|
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
2377 accounts = accounts->next) { |
|
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
2378 |
|
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
2379 GaimAccount *account = accounts->data; |
| 5228 | 2380 char *acct_name = g_markup_escape_text(account->username, -1); |
| 7153 | 2381 int proto_num = gaim_account_get_protocol(account); |
| 5228 | 2382 if(!exp_acct || account == exp_acct) { |
| 7153 | 2383 fprintf(file, "\t\t<account proto=\"%s\" name=\"%s\" " |
| 2384 "mode=\"%d\"", gaim_account_get_protocol_id(account), | |
|
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
2385 acct_name, account->perm_deny); |
| 7153 | 2386 if(proto_num != -1) |
| 2387 fprintf(file, " protocol=\"%d\"", proto_num); | |
| 2388 fprintf(file, ">\n"); | |
| 2389 | |
| 5228 | 2390 for(buds = account->permit; buds; buds = buds->next) { |
| 2391 char *bud_name = g_markup_escape_text(buds->data, -1); | |
| 2392 fprintf(file, "\t\t\t<permit>%s</permit>\n", bud_name); | |
| 2393 g_free(bud_name); | |
| 2394 } | |
| 2395 for(buds = account->deny; buds; buds = buds->next) { | |
| 2396 char *bud_name = g_markup_escape_text(buds->data, -1); | |
| 2397 fprintf(file, "\t\t\t<block>%s</block>\n", bud_name); | |
| 2398 g_free(bud_name); | |
| 2399 } | |
| 2400 fprintf(file, "\t\t</account>\n"); | |
| 2401 } | |
| 2402 g_free(acct_name); | |
| 2403 } | |
| 2404 | |
| 2405 fprintf(file, "\t</privacy>\n"); | |
| 2406 fprintf(file, "</gaim>\n"); | |
| 2407 } | |
| 2408 | |
| 2409 void gaim_blist_save() { | |
| 2410 FILE *file; | |
| 2411 char *user_dir = gaim_user_dir(); | |
| 2412 char *filename; | |
| 2413 char *filename_real; | |
| 2414 | |
| 2415 if(!user_dir) | |
| 2416 return; | |
| 2417 if(!blist_safe_to_write) { | |
| 2418 gaim_debug(GAIM_DEBUG_WARNING, "blist save", | |
| 2419 "AHH!! Tried to write the blist before we read it!\n"); | |
| 2420 return; | |
| 2421 } | |
| 2422 | |
| 2423 file = fopen(user_dir, "r"); | |
| 2424 if(!file) | |
| 2425 mkdir(user_dir, S_IRUSR | S_IWUSR | S_IXUSR); | |
| 2426 else | |
| 2427 fclose(file); | |
| 2428 | |
| 2429 filename = g_build_filename(user_dir, "blist.xml.save", NULL); | |
| 2430 | |
| 2431 if((file = fopen(filename, "w"))) { | |
| 2432 gaim_blist_write(file, NULL); | |
| 2433 fclose(file); | |
| 2434 chmod(filename, S_IRUSR | S_IWUSR); | |
| 2435 } else { | |
| 2436 gaim_debug(GAIM_DEBUG_ERROR, "blist save", "Unable to write %s\n", | |
| 2437 filename); | |
| 2438 } | |
| 2439 | |
| 2440 filename_real = g_build_filename(user_dir, "blist.xml", NULL); | |
| 2441 | |
| 2442 if(rename(filename, filename_real) < 0) | |
| 2443 gaim_debug(GAIM_DEBUG_ERROR, "blist save", | |
| 2444 "Error renaming %s to %s\n", filename, filename_real); | |
| 2445 | |
| 2446 | |
| 2447 g_free(filename); | |
| 2448 g_free(filename_real); | |
| 2449 } | |
| 2450 | |
| 6695 | 2451 void gaim_group_set_setting(GaimGroup *g, const char *key, |
| 5228 | 2452 const char *value) { |
| 2453 if(!g) | |
| 2454 return; | |
| 2455 g_hash_table_replace(g->settings, g_strdup(key), g_strdup(value)); | |
| 2456 } | |
| 2457 | |
| 7125 | 2458 const char *gaim_group_get_setting(GaimGroup *g, const char *key) { |
| 5228 | 2459 if(!g) |
| 2460 return NULL; | |
| 7125 | 2461 return g_hash_table_lookup(g->settings, key); |
| 5228 | 2462 } |
| 2463 | |
| 7125 | 2464 void gaim_chat_set_setting(GaimChat *c, const char *key, |
| 5906 | 2465 const char *value) |
| 2466 { | |
| 2467 if(!c) | |
| 2468 return; | |
| 2469 g_hash_table_replace(c->settings, g_strdup(key), g_strdup(value)); | |
| 2470 } | |
| 2471 | |
| 7125 | 2472 const char *gaim_chat_get_setting(GaimChat *c, const char *key) |
| 5906 | 2473 { |
| 2474 if(!c) | |
| 2475 return NULL; | |
| 7125 | 2476 return g_hash_table_lookup(c->settings, key); |
| 5906 | 2477 } |
| 2478 | |
| 6695 | 2479 void gaim_buddy_set_setting(GaimBuddy *b, const char *key, |
| 5228 | 2480 const char *value) { |
| 2481 if(!b) | |
| 2482 return; | |
| 2483 g_hash_table_replace(b->settings, g_strdup(key), g_strdup(value)); | |
| 2484 } | |
| 2485 | |
| 7125 | 2486 const char *gaim_buddy_get_setting(GaimBuddy *b, const char *key) { |
| 5228 | 2487 if(!b) |
| 2488 return NULL; | |
| 7125 | 2489 return g_hash_table_lookup(b->settings, key); |
| 5228 | 2490 } |
| 2491 | |
| 6695 | 2492 int gaim_blist_get_group_size(GaimGroup *group, gboolean offline) { |
| 5228 | 2493 if(!group) |
| 2494 return 0; | |
| 2495 | |
| 5277 | 2496 return offline ? group->totalsize : group->currentsize; |
| 5228 | 2497 } |
| 2498 | |
| 6695 | 2499 int gaim_blist_get_group_online_count(GaimGroup *group) { |
| 5228 | 2500 if(!group) |
| 2501 return 0; | |
| 2502 | |
| 5277 | 2503 return group->online; |
| 5228 | 2504 } |
| 2505 | |
|
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7003
diff
changeset
|
2506 void |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
2507 gaim_blist_set_ui_ops(GaimBlistUiOps *ops) |
|
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7003
diff
changeset
|
2508 { |
|
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7003
diff
changeset
|
2509 blist_ui_ops = ops; |
|
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7003
diff
changeset
|
2510 } |
|
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7003
diff
changeset
|
2511 |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
2512 GaimBlistUiOps * |
|
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7003
diff
changeset
|
2513 gaim_blist_get_ui_ops(void) |
|
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7003
diff
changeset
|
2514 { |
|
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7003
diff
changeset
|
2515 return blist_ui_ops; |
|
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7003
diff
changeset
|
2516 } |
|
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7003
diff
changeset
|
2517 |
|
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7003
diff
changeset
|
2518 |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2519 void * |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2520 gaim_blist_get_handle(void) |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2521 { |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2522 static int handle; |
| 5228 | 2523 |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2524 return &handle; |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2525 } |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2526 |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2527 void |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2528 gaim_blist_init(void) |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2529 { |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2530 void *handle = gaim_blist_get_handle(); |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2531 |
|
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2532 gaim_signal_register(handle, "buddy-away", |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2533 gaim_marshal_VOID__POINTER, NULL, 1, |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2534 gaim_value_new(GAIM_TYPE_SUBTYPE, |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2535 GAIM_SUBTYPE_BLIST_BUDDY)); |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2536 |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2537 gaim_signal_register(handle, "buddy-back", |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2538 gaim_marshal_VOID__POINTER, NULL, 1, |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2539 gaim_value_new(GAIM_TYPE_SUBTYPE, |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2540 GAIM_SUBTYPE_BLIST_BUDDY)); |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2541 |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2542 gaim_signal_register(handle, "buddy-idle", |
|
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2543 gaim_marshal_VOID__POINTER, NULL, 1, |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2544 gaim_value_new(GAIM_TYPE_SUBTYPE, |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2545 GAIM_SUBTYPE_BLIST_BUDDY)); |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2546 gaim_signal_register(handle, "buddy-unidle", |
|
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2547 gaim_marshal_VOID__POINTER, NULL, 1, |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2548 gaim_value_new(GAIM_TYPE_SUBTYPE, |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2549 GAIM_SUBTYPE_BLIST_BUDDY)); |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2550 |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2551 gaim_signal_register(handle, "buddy-signed-on", |
|
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2552 gaim_marshal_VOID__POINTER, NULL, 1, |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2553 gaim_value_new(GAIM_TYPE_SUBTYPE, |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2554 GAIM_SUBTYPE_BLIST_BUDDY)); |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2555 |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2556 gaim_signal_register(handle, "buddy-signed-off", |
|
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2557 gaim_marshal_VOID__POINTER, NULL, 1, |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2558 gaim_value_new(GAIM_TYPE_SUBTYPE, |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2559 GAIM_SUBTYPE_BLIST_BUDDY)); |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2560 |
|
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2561 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
|
2562 } |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2563 |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2564 void |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2565 gaim_blist_uninit(void) |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2566 { |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2567 gaim_signals_unregister_by_instance(gaim_blist_get_handle()); |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2568 } |
