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