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