Mercurial > pidgin
annotate src/blist.c @ 7246:cb6bf374c7ee
[gaim-migrate @ 7823]
1. fix 822297 (add/remove button in conv window not changing)
2. make dragging a contact into an expanded contact put the dragged one
where you wanted it
committer: Tailor Script <tailor@pidgin.im>
| author | Nathan Walp <nwalp@pidgin.im> |
|---|---|
| date | Mon, 13 Oct 2003 03:48:36 +0000 |
| parents | 747b9e00ef60 |
| children | 1930e3d00ecd |
| 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 { | |
| 7245 | 760 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
| 761 | |
| 6755 | 762 g_return_if_fail(contact != NULL); |
| 763 | |
| 764 if(contact->alias) | |
| 765 g_free(contact->alias); | |
| 766 | |
| 7245 | 767 if(alias && *alias) |
| 768 contact->alias = g_strdup(alias); | |
| 769 else | |
| 770 contact->alias = NULL; | |
| 771 | |
| 772 if (ops) | |
| 773 ops->update(gaimbuddylist, (GaimBlistNode*)contact); | |
| 6755 | 774 } |
| 775 | |
| 776 const char *gaim_contact_get_alias(GaimContact* contact) | |
| 777 { | |
| 778 return contact ? contact->alias : NULL; | |
| 779 } | |
| 780 | |
| 6695 | 781 GaimGroup *gaim_group_new(const char *name) |
| 782 { | |
| 783 GaimGroup *g = gaim_find_group(name); | |
| 5228 | 784 |
| 785 if (!g) { | |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
786 GaimBlistUiOps *ops; |
| 6695 | 787 g= g_new0(GaimGroup, 1); |
| 5228 | 788 g->name = g_strdup(name); |
| 5277 | 789 g->totalsize = 0; |
| 790 g->currentsize = 0; | |
| 791 g->online = 0; | |
| 5228 | 792 g->settings = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 793 g_free, g_free); | |
| 794 ((GaimBlistNode*)g)->type = GAIM_BLIST_GROUP_NODE; | |
| 795 | |
|
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7003
diff
changeset
|
796 ops = gaim_blist_get_ui_ops(); |
| 5228 | 797 |
| 798 if (ops != NULL && ops->new_node != NULL) | |
| 799 ops->new_node((GaimBlistNode *)g); | |
| 800 | |
| 801 } | |
| 802 return g; | |
| 803 } | |
| 804 | |
| 6695 | 805 void gaim_blist_add_contact(GaimContact *contact, GaimGroup *group, GaimBlistNode *node) |
| 806 { | |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
807 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
| 6695 | 808 GaimGroup *g; |
| 6742 | 809 GaimBlistNode *gnode, *cnode, *bnode; |
| 6695 | 810 gboolean save = FALSE; |
| 811 | |
| 6774 | 812 g_return_if_fail(contact != NULL); |
| 813 g_return_if_fail(GAIM_BLIST_NODE_IS_CONTACT((GaimBlistNode*)contact)); | |
| 6695 | 814 |
| 6975 | 815 if((GaimBlistNode*)contact == node) |
| 816 return; | |
| 817 | |
| 6695 | 818 if(node && (GAIM_BLIST_NODE_IS_CONTACT(node) || |
| 819 GAIM_BLIST_NODE_IS_CHAT(node))) | |
| 820 g = (GaimGroup*)node->parent; | |
| 821 else if(group) | |
| 822 g = group; | |
| 823 else { | |
| 824 g = gaim_group_new(_("Buddies")); | |
| 825 gaim_blist_add_group(g, | |
| 826 gaim_blist_get_last_sibling(gaimbuddylist->root)); | |
| 827 } | |
| 828 | |
| 829 gnode = (GaimBlistNode*)g; | |
| 830 cnode = (GaimBlistNode*)contact; | |
| 831 | |
| 832 if(cnode->parent) { | |
| 6731 | 833 if(cnode->parent->child == cnode) |
| 834 cnode->parent->child = cnode->next; | |
| 6695 | 835 if(cnode->prev) |
| 836 cnode->prev->next = cnode->next; | |
| 837 if(cnode->next) | |
| 838 cnode->next->prev = cnode->prev; | |
| 839 | |
| 840 | |
| 841 if(contact->online > 0) | |
| 842 ((GaimGroup*)cnode->parent)->online--; | |
| 843 if(contact->currentsize > 0) | |
| 844 ((GaimGroup*)cnode->parent)->currentsize--; | |
| 845 ((GaimGroup*)cnode->parent)->totalsize--; | |
| 846 | |
| 6731 | 847 ops->remove(gaimbuddylist, cnode); |
| 848 | |
| 6695 | 849 save = TRUE; |
| 6742 | 850 |
| 851 if(cnode->parent != gnode) { | |
| 852 for(bnode = cnode->child; bnode; bnode = bnode->next) { | |
| 853 GaimBuddy *b = (GaimBuddy*)bnode; | |
| 854 | |
| 855 struct _gaim_hbuddy *hb = g_new(struct _gaim_hbuddy, 1); | |
|
7107
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
856 hb->name = g_strdup(gaim_normalize(b->name)); |
| 6742 | 857 hb->account = b->account; |
| 858 hb->group = cnode->parent; | |
| 859 | |
| 6776 | 860 g_hash_table_remove(gaimbuddylist->buddies, hb); |
| 6742 | 861 |
| 862 hb->group = gnode; | |
| 863 g_hash_table_replace(gaimbuddylist->buddies, hb, b); | |
| 864 | |
| 865 if(b->account->gc) | |
| 866 serv_move_buddy(b, (GaimGroup*)cnode->parent, g); | |
| 867 } | |
| 868 } | |
| 6695 | 869 } |
| 870 | |
| 6775 | 871 |
| 6695 | 872 if(node && (GAIM_BLIST_NODE_IS_CONTACT(node) || |
| 873 GAIM_BLIST_NODE_IS_CHAT(node))) { | |
| 874 if(node->next) | |
| 875 node->next->prev = cnode; | |
| 876 cnode->next = node->next; | |
| 877 cnode->prev = node; | |
| 878 cnode->parent = node->parent; | |
| 879 node->next = cnode; | |
| 880 } else { | |
| 881 if(gnode->child) | |
| 882 gnode->child->prev = cnode; | |
| 883 cnode->prev = NULL; | |
| 884 cnode->next = gnode->child; | |
| 885 gnode->child = cnode; | |
| 886 cnode->parent = gnode; | |
| 887 } | |
| 888 | |
| 889 if(contact->online > 0) | |
| 890 g->online++; | |
| 891 if(contact->currentsize > 0) | |
| 892 g->currentsize++; | |
| 893 g->totalsize++; | |
| 894 | |
| 895 if(ops && cnode->child) | |
| 896 ops->update(gaimbuddylist, cnode); | |
| 6775 | 897 |
| 898 for(bnode = cnode->child; bnode; bnode = bnode->next) | |
| 899 ops->update(gaimbuddylist, bnode); | |
| 900 | |
| 6695 | 901 if (save) |
| 902 gaim_blist_save(); | |
| 903 } | |
| 904 | |
| 7246 | 905 void gaim_blist_merge_contact(GaimContact *source, GaimBlistNode *node) |
| 6965 | 906 { |
| 907 GaimBlistNode *sourcenode = (GaimBlistNode*)source; | |
| 7246 | 908 GaimBlistNode *targetnode; |
| 909 GaimBlistNode *prev, *cur, *next; | |
| 910 GaimContact *target; | |
| 911 | |
| 912 if(GAIM_BLIST_NODE_IS_CONTACT(node)) { | |
| 913 target = (GaimContact*)node; | |
| 914 prev = gaim_blist_get_last_child(node); | |
| 915 } else if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
| 916 target = (GaimContact*)node->parent; | |
| 917 prev = node; | |
| 918 } else { | |
| 6965 | 919 return; |
| 7246 | 920 } |
| 921 | |
| 922 if(source == target || !target) | |
| 923 return; | |
| 924 | |
| 925 targetnode = (GaimBlistNode*)target; | |
| 926 next = sourcenode->child; | |
| 927 | |
| 928 while(next) { | |
| 929 cur = next; | |
| 930 next = cur->next; | |
| 931 if(GAIM_BLIST_NODE_IS_BUDDY(cur)) { | |
| 932 gaim_blist_add_buddy((GaimBuddy*)cur, target, NULL, prev); | |
| 933 prev = cur; | |
| 934 } | |
| 6965 | 935 } |
| 936 } | |
| 937 | |
| 6695 | 938 void gaim_blist_add_group (GaimGroup *group, GaimBlistNode *node) |
| 5228 | 939 { |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
940 GaimBlistUiOps *ops; |
| 5228 | 941 GaimBlistNode *gnode = (GaimBlistNode*)group; |
| 942 gboolean save = FALSE; | |
| 943 | |
| 6774 | 944 g_return_if_fail(group != NULL); |
| 945 g_return_if_fail(GAIM_BLIST_NODE_IS_GROUP((GaimBlistNode*)group)); | |
| 946 | |
| 5228 | 947 if (!gaimbuddylist) |
| 948 gaimbuddylist = gaim_blist_new(); | |
| 949 ops = gaimbuddylist->ui_ops; | |
| 950 | |
| 951 if (!gaimbuddylist->root) { | |
| 952 gaimbuddylist->root = gnode; | |
| 953 return; | |
| 954 } | |
| 955 | |
| 956 /* if we're moving to overtop of ourselves, do nothing */ | |
| 957 if(gnode == node) | |
| 958 return; | |
| 959 | |
| 960 if (gaim_find_group(group->name)) { | |
| 961 /* This is just being moved */ | |
| 962 | |
| 963 ops->remove(gaimbuddylist, (GaimBlistNode*)group); | |
| 964 | |
| 965 if(gnode == gaimbuddylist->root) | |
| 966 gaimbuddylist->root = gnode->next; | |
| 967 if(gnode->prev) | |
| 968 gnode->prev->next = gnode->next; | |
| 969 if(gnode->next) | |
| 970 gnode->next->prev = gnode->prev; | |
| 971 | |
| 972 save = TRUE; | |
| 973 } | |
| 974 | |
| 6695 | 975 if (node && GAIM_BLIST_NODE_IS_GROUP(node)) { |
| 5634 | 976 gnode->next = node->next; |
| 977 gnode->prev = node; | |
| 978 if(node->next) | |
| 979 node->next->prev = gnode; | |
| 980 node->next = gnode; | |
| 981 } else { | |
| 6807 | 982 if(gaimbuddylist->root) |
| 983 gaimbuddylist->root->prev = gnode; | |
| 5634 | 984 gnode->next = gaimbuddylist->root; |
| 985 gnode->prev = NULL; | |
| 986 gaimbuddylist->root = gnode; | |
| 987 } | |
| 988 | |
| 5228 | 989 |
| 990 if (ops) { | |
| 991 ops->update(gaimbuddylist, gnode); | |
| 992 for(node = gnode->child; node; node = node->next) | |
| 993 ops->update(gaimbuddylist, node); | |
| 994 } | |
| 995 if (save) | |
| 996 gaim_blist_save(); | |
| 997 } | |
| 998 | |
| 6695 | 999 void gaim_blist_remove_contact(GaimContact* contact) |
| 5228 | 1000 { |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
1001 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
| 5228 | 1002 |
| 6695 | 1003 GaimBlistNode *gnode, *cnode = (GaimBlistNode*)contact; |
| 1004 | |
| 1005 gnode = cnode->parent; | |
| 1006 | |
| 1007 if(cnode->child) { | |
| 1008 while(cnode->child) { | |
| 1009 gaim_blist_remove_buddy((GaimBuddy*)cnode->child); | |
| 1010 } | |
| 1011 } else { | |
| 1012 if(ops) | |
| 1013 ops->remove(gaimbuddylist, cnode); | |
| 1014 | |
| 1015 if(gnode->child == cnode) | |
| 1016 gnode->child = cnode->next; | |
| 1017 if(cnode->prev) | |
| 1018 cnode->prev->next = cnode->next; | |
| 1019 if(cnode->next) | |
| 1020 cnode->next->prev = cnode->prev; | |
| 1021 | |
| 1022 g_free(contact); | |
| 1023 } | |
| 1024 } | |
| 1025 | |
| 6742 | 1026 void gaim_blist_remove_buddy (GaimBuddy *buddy) |
| 6695 | 1027 { |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
1028 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
| 6695 | 1029 |
| 1030 GaimBlistNode *cnode, *node = (GaimBlistNode*)buddy; | |
| 1031 GaimGroup *group; | |
| 6742 | 1032 struct _gaim_hbuddy hb; |
| 5228 | 1033 |
| 6695 | 1034 cnode = node->parent; |
| 1035 group = (GaimGroup *)cnode->parent; | |
| 5228 | 1036 |
| 6695 | 1037 if(GAIM_BUDDY_IS_ONLINE(buddy)) { |
| 1038 ((GaimContact*)cnode)->online--; | |
| 1039 if(((GaimContact*)cnode)->online == 0) | |
| 1040 group->online--; | |
| 1041 } | |
| 1042 if(gaim_account_is_connected(buddy->account)) { | |
| 1043 ((GaimContact*)cnode)->currentsize--; | |
| 1044 if(((GaimContact*)cnode)->currentsize == 0) | |
| 1045 group->currentsize--; | |
| 1046 } | |
| 1047 ((GaimContact*)cnode)->totalsize--; | |
| 1048 | |
| 5228 | 1049 if (node->prev) |
| 1050 node->prev->next = node->next; | |
| 1051 if (node->next) | |
| 1052 node->next->prev = node->prev; | |
| 6695 | 1053 if(cnode->child == node) { |
| 1054 cnode->child = node->next; | |
| 1055 } | |
| 5228 | 1056 |
| 6755 | 1057 |
| 7162 | 1058 hb.name = g_strdup(gaim_normalize(buddy->name)); |
| 5247 | 1059 hb.account = buddy->account; |
| 6695 | 1060 hb.group = ((GaimBlistNode*)buddy)->parent->parent; |
| 6742 | 1061 g_hash_table_remove(gaimbuddylist->buddies, &hb); |
| 7162 | 1062 g_free(hb.name); |
| 5247 | 1063 |
| 5292 | 1064 if(buddy->timer > 0) |
| 1065 g_source_remove(buddy->timer); | |
| 1066 | |
|
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
1067 if (buddy->icon != NULL) |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
1068 gaim_buddy_icon_unref(buddy->icon); |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6843
diff
changeset
|
1069 |
| 5228 | 1070 ops->remove(gaimbuddylist, node); |
| 1071 g_hash_table_destroy(buddy->settings); | |
| 1072 g_free(buddy->name); | |
| 1073 g_free(buddy->alias); | |
| 1074 g_free(buddy); | |
| 6755 | 1075 |
| 1076 if(!cnode->child) | |
| 1077 gaim_blist_remove_contact((GaimContact*)cnode); | |
| 5228 | 1078 } |
| 1079 | |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
1080 void gaim_blist_remove_chat (GaimChat *chat) |
| 5234 | 1081 { |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
1082 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
| 5234 | 1083 |
| 1084 GaimBlistNode *gnode, *node = (GaimBlistNode*)chat; | |
| 6695 | 1085 GaimGroup *group; |
| 5234 | 1086 |
| 1087 gnode = node->parent; | |
| 6695 | 1088 group = (GaimGroup *)gnode; |
| 5234 | 1089 |
| 1090 if(gnode->child == node) | |
| 1091 gnode->child = node->next; | |
| 1092 if (node->prev) | |
| 1093 node->prev->next = node->next; | |
| 1094 if (node->next) | |
| 1095 node->next->prev = node->prev; | |
| 5277 | 1096 group->totalsize--; |
| 5855 | 1097 if (gaim_account_is_connected(chat->account)) { |
| 5277 | 1098 group->currentsize--; |
| 5394 | 1099 group->online--; |
| 1100 } | |
| 5234 | 1101 |
| 1102 ops->remove(gaimbuddylist, node); | |
| 1103 g_hash_table_destroy(chat->components); | |
| 1104 g_free(chat->alias); | |
| 1105 g_free(chat); | |
| 1106 } | |
| 1107 | |
| 6695 | 1108 void gaim_blist_remove_group (GaimGroup *group) |
| 5228 | 1109 { |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
1110 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
| 5228 | 1111 GaimBlistNode *node = (GaimBlistNode*)group; |
|
6885
66dd420d3d23
[gaim-migrate @ 7431]
Christian Hammond <chipx86@chipx86.com>
parents:
6872
diff
changeset
|
1112 GList *l; |
| 5228 | 1113 |
| 1114 if(node->child) { | |
| 1115 char *buf; | |
| 1116 int count = 0; | |
| 1117 GaimBlistNode *child = node->child; | |
| 1118 | |
| 1119 while(child) { | |
| 1120 count++; | |
| 1121 child = child->next; | |
| 1122 } | |
| 1123 | |
| 6308 | 1124 buf = g_strdup_printf(ngettext("%d buddy from group %s was not removed " |
| 1125 "because its account was not logged in." | |
| 1126 " This buddy and the group were not " | |
| 1127 "removed.\n", | |
| 1128 "%d buddies from group %s were not " | |
| 1129 "removed because their accounts were " | |
| 6336 | 1130 "not logged in. These buddies and " |
| 1131 "the group were not removed.\n", count), | |
| 6308 | 1132 count, group->name); |
|
5541
aee0ee458974
[gaim-migrate @ 5941]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1133 gaim_notify_error(NULL, NULL, _("Group not removed"), buf); |
| 5228 | 1134 g_free(buf); |
| 1135 return; | |
| 1136 } | |
| 1137 | |
| 1138 if(gaimbuddylist->root == node) | |
| 1139 gaimbuddylist->root = node->next; | |
| 1140 if (node->prev) | |
| 1141 node->prev->next = node->next; | |
| 1142 if (node->next) | |
| 1143 node->next->prev = node->prev; | |
| 1144 | |
|
6885
66dd420d3d23
[gaim-migrate @ 7431]
Christian Hammond <chipx86@chipx86.com>
parents:
6872
diff
changeset
|
1145 for (l = gaim_connections_get_all(); l != NULL; l = l->next) |
|
66dd420d3d23
[gaim-migrate @ 7431]
Christian Hammond <chipx86@chipx86.com>
parents:
6872
diff
changeset
|
1146 { |
|
66dd420d3d23
[gaim-migrate @ 7431]
Christian Hammond <chipx86@chipx86.com>
parents:
6872
diff
changeset
|
1147 GaimConnection *gc = (GaimConnection *)l->data; |
|
66dd420d3d23
[gaim-migrate @ 7431]
Christian Hammond <chipx86@chipx86.com>
parents:
6872
diff
changeset
|
1148 |
|
66dd420d3d23
[gaim-migrate @ 7431]
Christian Hammond <chipx86@chipx86.com>
parents:
6872
diff
changeset
|
1149 if (gaim_connection_get_state(gc) == GAIM_CONNECTED) |
|
66dd420d3d23
[gaim-migrate @ 7431]
Christian Hammond <chipx86@chipx86.com>
parents:
6872
diff
changeset
|
1150 serv_remove_group(gc, group->name); |
|
66dd420d3d23
[gaim-migrate @ 7431]
Christian Hammond <chipx86@chipx86.com>
parents:
6872
diff
changeset
|
1151 } |
|
66dd420d3d23
[gaim-migrate @ 7431]
Christian Hammond <chipx86@chipx86.com>
parents:
6872
diff
changeset
|
1152 |
| 5228 | 1153 ops->remove(gaimbuddylist, node); |
| 1154 g_free(group->name); | |
| 1155 g_free(group); | |
| 1156 } | |
| 1157 | |
| 6695 | 1158 GaimBuddy *gaim_contact_get_priority_buddy(GaimContact *contact) { |
| 6843 | 1159 return contact->priority; |
| 6695 | 1160 } |
| 1161 | |
| 1162 const char *gaim_get_buddy_alias_only(GaimBuddy *b) { | |
|
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1163 if(!b) |
|
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1164 return NULL; |
|
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1165 |
|
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1166 if(b->alias && b->alias[0]) { |
|
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1167 return b->alias; |
|
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1168 } |
|
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1169 else if (b->server_alias != NULL && |
|
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1170 gaim_prefs_get_bool("/core/buddies/use_server_alias")) { |
|
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1171 |
|
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1172 return b->server_alias; |
|
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1173 } |
|
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1174 |
|
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5541
diff
changeset
|
1175 return NULL; |
| 5228 | 1176 } |
| 1177 | |
| 6695 | 1178 const char * gaim_get_buddy_alias (GaimBuddy *buddy) |
| 5228 | 1179 { |
| 6755 | 1180 const char *ret; |
| 1181 | |
| 1182 if(!buddy) | |
| 1183 return _("Unknown"); | |
| 5228 | 1184 |
| 6755 | 1185 ret= gaim_get_buddy_alias_only(buddy); |
| 1186 | |
| 1187 return ret ? ret : buddy->name; | |
| 5228 | 1188 } |
| 1189 | |
| 7125 | 1190 const char *gaim_chat_get_name(GaimChat *chat) |
| 6744 | 1191 { |
| 1192 if(chat->alias && *chat->alias) { | |
| 1193 return chat->alias; | |
| 1194 } else { | |
| 1195 struct proto_chat_entry *pce; | |
| 1196 GList *parts, *tmp; | |
| 1197 char *ret; | |
| 1198 | |
| 1199 parts = GAIM_PLUGIN_PROTOCOL_INFO(chat->account->gc->prpl)->chat_info(chat->account->gc); | |
| 1200 pce = parts->data; | |
| 1201 ret = g_hash_table_lookup(chat->components, pce->identifier); | |
| 1202 for(tmp = parts; tmp; tmp = tmp->next) | |
| 1203 g_free(tmp->data); | |
| 1204 g_list_free(parts); | |
| 1205 | |
| 1206 return ret; | |
| 1207 } | |
| 1208 } | |
| 1209 | |
| 6695 | 1210 GaimBuddy *gaim_find_buddy(GaimAccount *account, const char *name) |
| 5228 | 1211 { |
| 6695 | 1212 GaimBuddy *buddy; |
| 5247 | 1213 struct _gaim_hbuddy hb; |
| 5758 | 1214 GaimBlistNode *group; |
| 5228 | 1215 |
| 1216 if (!gaimbuddylist) | |
| 1217 return NULL; | |
| 6245 | 1218 |
| 1219 if (!name) | |
|
5985
60d9cbfb6bf8
[gaim-migrate @ 6433]
Christian Hammond <chipx86@chipx86.com>
parents:
5947
diff
changeset
|
1220 return NULL; |
| 5228 | 1221 |
| 7162 | 1222 hb.name = g_strdup(gaim_normalize(name)); |
| 6245 | 1223 hb.account = account; |
| 5247 | 1224 |
| 6245 | 1225 for(group = gaimbuddylist->root; group; group = group->next) { |
| 5758 | 1226 hb.group = group; |
| 7162 | 1227 if ((buddy = g_hash_table_lookup(gaimbuddylist->buddies, &hb))) { |
| 1228 g_free(hb.name); | |
| 5758 | 1229 return buddy; |
| 7162 | 1230 } |
| 5758 | 1231 } |
| 6245 | 1232 |
| 7162 | 1233 g_free(hb.name); |
| 5758 | 1234 return NULL; |
| 5228 | 1235 } |
| 1236 | |
| 6872 | 1237 GaimBuddy *gaim_find_buddy_in_group(GaimAccount *account, const char *name, |
| 1238 GaimGroup *group) | |
| 1239 { | |
| 1240 struct _gaim_hbuddy hb; | |
| 7162 | 1241 GaimBuddy *ret; |
| 6872 | 1242 |
| 1243 if (!gaimbuddylist) | |
| 1244 return NULL; | |
| 1245 | |
| 1246 if (!name) | |
| 1247 return NULL; | |
| 1248 | |
| 7162 | 1249 hb.name = g_strdup(gaim_normalize(name)); |
| 6872 | 1250 hb.account = account; |
| 1251 hb.group = (GaimBlistNode*)group; | |
| 1252 | |
| 7162 | 1253 ret = g_hash_table_lookup(gaimbuddylist->buddies, &hb); |
| 1254 g_free(hb.name); | |
| 1255 return ret; | |
| 6872 | 1256 } |
| 1257 | |
| 6245 | 1258 GSList *gaim_find_buddies(GaimAccount *account, const char *name) |
| 1259 { | |
| 1260 struct buddy *buddy; | |
| 1261 struct _gaim_hbuddy hb; | |
| 1262 GaimBlistNode *group; | |
| 1263 GSList *ret = NULL; | |
| 1264 | |
| 1265 if (!gaimbuddylist) | |
| 1266 return NULL; | |
| 1267 | |
| 1268 if (!name) | |
| 1269 return NULL; | |
| 1270 | |
| 7162 | 1271 hb.name = g_strdup(gaim_normalize(name)); |
| 6245 | 1272 hb.account = account; |
| 1273 | |
| 1274 for(group = gaimbuddylist->root; group; group = group->next) { | |
| 1275 hb.group = group; | |
| 1276 if ((buddy = g_hash_table_lookup(gaimbuddylist->buddies, &hb)) != NULL) | |
| 1277 ret = g_slist_append(ret, buddy); | |
| 1278 } | |
| 1279 | |
| 7162 | 1280 g_free(hb.name); |
| 6245 | 1281 return ret; |
| 1282 } | |
| 1283 | |
| 6695 | 1284 GaimGroup *gaim_find_group(const char *name) |
| 5228 | 1285 { |
| 1286 GaimBlistNode *node; | |
| 1287 if (!gaimbuddylist) | |
| 1288 return NULL; | |
| 1289 node = gaimbuddylist->root; | |
| 1290 while(node) { | |
| 6695 | 1291 if (!strcmp(((GaimGroup *)node)->name, name)) |
| 1292 return (GaimGroup *)node; | |
| 5228 | 1293 node = node->next; |
| 1294 } | |
| 1295 return NULL; | |
| 1296 } | |
|
6456
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1297 |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
1298 GaimChat * |
|
6456
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1299 gaim_blist_find_chat(GaimAccount *account, const char *name) |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1300 { |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1301 char *chat_name; |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
1302 GaimChat *chat; |
|
6456
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1303 GaimPlugin *prpl; |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1304 GaimPluginProtocolInfo *prpl_info = NULL; |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1305 struct proto_chat_entry *pce; |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1306 GaimBlistNode *node, *group; |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1307 GList *parts; |
|
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 g_return_val_if_fail(gaim_get_blist() != NULL, NULL); |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1310 g_return_val_if_fail(name != NULL, NULL); |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1311 |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1312 for (group = gaimbuddylist->root; group != NULL; group = group->next) { |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1313 for (node = group->child; node != NULL; node = node->next) { |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1314 if (GAIM_BLIST_NODE_IS_CHAT(node)) { |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1315 |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
1316 chat = (GaimChat*)node; |
|
6456
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 prpl = gaim_find_prpl(gaim_account_get_protocol(chat->account)); |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1319 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); |
|
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 parts = prpl_info->chat_info( |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1322 gaim_account_get_connection(chat->account)); |
|
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 pce = parts->data; |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1325 chat_name = g_hash_table_lookup(chat->components, |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1326 pce->identifier); |
|
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 if (chat->account == account && |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1329 name != NULL && !strcmp(chat_name, name)) { |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1330 |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1331 return chat; |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1332 } |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1333 } |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1334 } |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1335 } |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1336 |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1337 return NULL; |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1338 } |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1339 |
| 6695 | 1340 GaimGroup * |
| 7125 | 1341 gaim_chat_get_group(GaimChat *chat) |
|
6456
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1342 { |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1343 g_return_val_if_fail(chat != NULL, NULL); |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1344 |
| 6695 | 1345 return (GaimGroup *)(((GaimBlistNode *)chat)->parent); |
|
6456
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1346 } |
|
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6450
diff
changeset
|
1347 |
| 6695 | 1348 GaimGroup *gaim_find_buddys_group(GaimBuddy *buddy) |
| 5228 | 1349 { |
| 1350 if (!buddy) | |
| 1351 return NULL; | |
|
6706
854a435d2cc3
[gaim-migrate @ 7232]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1352 |
|
854a435d2cc3
[gaim-migrate @ 7232]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1353 if (((GaimBlistNode *)buddy)->parent == NULL) |
|
854a435d2cc3
[gaim-migrate @ 7232]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1354 return NULL; |
|
854a435d2cc3
[gaim-migrate @ 7232]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1355 |
| 6695 | 1356 return (GaimGroup *)(((GaimBlistNode*)buddy)->parent->parent); |
| 5228 | 1357 } |
| 1358 | |
| 6695 | 1359 GSList *gaim_group_get_accounts(GaimGroup *g) |
| 5228 | 1360 { |
| 1361 GSList *l = NULL; | |
| 6695 | 1362 GaimBlistNode *gnode, *cnode, *bnode; |
| 1363 | |
| 1364 gnode = (GaimBlistNode *)g; | |
| 5228 | 1365 |
| 6695 | 1366 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
| 1367 if (GAIM_BLIST_NODE_IS_CHAT(cnode)) { | |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
1368 if(!g_slist_find(l, ((GaimChat *)cnode)->account)) |
|
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
1369 l = g_slist_append(l, ((GaimChat *)cnode)->account); |
| 6695 | 1370 } else if(GAIM_BLIST_NODE_IS_CONTACT(cnode)) { |
| 1371 for(bnode = cnode->child; bnode; bnode = bnode->next) { | |
| 1372 if(GAIM_BLIST_NODE_IS_BUDDY(bnode)) { | |
| 1373 if(!g_slist_find(l, ((GaimBuddy *)bnode)->account)) | |
| 1374 l = g_slist_append(l, ((GaimBuddy *)bnode)->account); | |
| 1375 } | |
| 1376 } | |
| 1377 } | |
| 5228 | 1378 } |
| 6695 | 1379 |
| 5228 | 1380 return l; |
| 1381 } | |
| 1382 | |
|
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1383 void gaim_blist_add_account(GaimAccount *account) |
| 5234 | 1384 { |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
1385 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
| 6695 | 1386 GaimBlistNode *gnode, *cnode, *bnode; |
| 5234 | 1387 |
| 1388 if(!gaimbuddylist) | |
| 1389 return; | |
| 1390 | |
| 6695 | 1391 if(!ops) |
| 1392 return; | |
| 1393 | |
| 1394 for(gnode = gaimbuddylist->root; gnode; gnode = gnode->next) { | |
| 1395 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
| 5234 | 1396 continue; |
| 6695 | 1397 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
| 1398 if(GAIM_BLIST_NODE_IS_CONTACT(cnode)) { | |
| 6956 | 1399 gboolean recompute = FALSE; |
| 6695 | 1400 for(bnode = cnode->child; bnode; bnode = bnode->next) { |
| 1401 if(GAIM_BLIST_NODE_IS_BUDDY(bnode) && | |
| 1402 ((GaimBuddy*)bnode)->account == account) { | |
| 6956 | 1403 recompute = TRUE; |
| 6695 | 1404 ((GaimContact*)cnode)->currentsize++; |
| 1405 if(((GaimContact*)cnode)->currentsize == 1) | |
| 1406 ((GaimGroup*)gnode)->currentsize++; | |
| 1407 if(GAIM_BUDDY_IS_ONLINE((GaimBuddy*)bnode)) { | |
| 1408 ((GaimContact*)cnode)->online++; | |
| 1409 if(((GaimContact*)cnode)->online == 1) | |
| 1410 ((GaimGroup*)gnode)->online++; | |
| 1411 } | |
| 1412 ops->update(gaimbuddylist, bnode); | |
| 1413 } | |
| 1414 } | |
| 6956 | 1415 if(recompute) { |
| 1416 gaim_contact_compute_priority_buddy((GaimContact*)cnode); | |
| 1417 ops->update(gaimbuddylist, cnode); | |
| 1418 } | |
| 6695 | 1419 } else if(GAIM_BLIST_NODE_IS_CHAT(cnode) && |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
1420 ((GaimChat*)cnode)->account == account) { |
| 6901 | 1421 ((GaimGroup *)gnode)->online++; |
| 1422 ((GaimGroup *)gnode)->currentsize++; | |
| 1423 ops->update(gaimbuddylist, cnode); | |
| 5234 | 1424 } |
| 1425 } | |
| 6695 | 1426 ops->update(gaimbuddylist, gnode); |
| 5234 | 1427 } |
| 1428 } | |
| 1429 | |
|
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1430 void gaim_blist_remove_account(GaimAccount *account) |
| 5228 | 1431 { |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
1432 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
| 6695 | 1433 GaimBlistNode *gnode, *cnode, *bnode; |
| 5234 | 1434 |
| 5228 | 1435 if (!gaimbuddylist) |
| 1436 return; | |
| 5234 | 1437 |
| 6695 | 1438 for(gnode = gaimbuddylist->root; gnode; gnode = gnode->next) { |
| 1439 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
| 5234 | 1440 continue; |
| 6695 | 1441 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
| 1442 if(GAIM_BLIST_NODE_IS_CONTACT(cnode)) { | |
| 6957 | 1443 gboolean recompute = FALSE; |
| 6695 | 1444 for(bnode = cnode->child; bnode; bnode = bnode->next) { |
| 1445 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
| 1446 continue; | |
| 1447 if(account == ((GaimBuddy *)bnode)->account) { | |
| 6957 | 1448 recompute = TRUE; |
| 6695 | 1449 if(((GaimBuddy*)bnode)->present == GAIM_BUDDY_ONLINE || |
| 1450 ((GaimBuddy*)bnode)->present == GAIM_BUDDY_SIGNING_ON) { | |
| 1451 ((GaimContact*)cnode)->online--; | |
| 1452 if(((GaimContact*)cnode)->online == 0) | |
| 1453 ((GaimGroup*)gnode)->online--; | |
| 1454 } | |
| 1455 ((GaimContact*)cnode)->currentsize--; | |
| 1456 if(((GaimContact*)cnode)->currentsize == 0) | |
| 1457 ((GaimGroup*)gnode)->currentsize--; | |
| 1458 | |
| 1459 ((GaimBuddy*)bnode)->present = GAIM_BUDDY_OFFLINE; | |
| 1460 | |
| 6803 | 1461 ((GaimBuddy*)bnode)->uc = 0; |
| 1462 ((GaimBuddy*)bnode)->idle = 0; | |
| 1463 ((GaimBuddy*)bnode)->evil = 0; | |
| 1464 | |
| 6945 | 1465 |
| 6695 | 1466 if(ops) |
| 1467 ops->remove(gaimbuddylist, bnode); | |
| 1468 } | |
| 5234 | 1469 } |
| 6983 | 1470 if(recompute) { |
| 6959 | 1471 gaim_contact_compute_priority_buddy((GaimContact*)cnode); |
| 6983 | 1472 if(ops) |
| 1473 ops->update(gaimbuddylist, cnode); | |
| 1474 } | |
| 6695 | 1475 } else if(GAIM_BLIST_NODE_IS_CHAT(cnode) && |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
1476 ((GaimChat*)cnode)->account == account) { |
| 6695 | 1477 ((GaimGroup*)gnode)->currentsize--; |
| 1478 ((GaimGroup*)gnode)->online--; | |
| 1479 if(ops) | |
| 1480 ops->remove(gaimbuddylist, cnode); | |
| 5228 | 1481 } |
| 1482 } | |
| 1483 } | |
| 1484 } | |
| 1485 | |
|
7117
943085b0ff8b
[gaim-migrate @ 7684]
Christian Hammond <chipx86@chipx86.com>
parents:
7115
diff
changeset
|
1486 void gaim_blist_parse_toc_buddy_list(GaimAccount *account, char *config) |
| 5228 | 1487 { |
| 1488 char *c; | |
| 1489 char current[256]; | |
| 1490 GList *bud = NULL; | |
| 1491 | |
| 1492 | |
| 1493 if (config != NULL) { | |
| 1494 | |
| 1495 /* skip "CONFIG:" (if it exists) */ | |
| 1496 c = strncmp(config + 6 /* sizeof(struct sflap_hdr) */ , "CONFIG:", strlen("CONFIG:")) ? | |
| 1497 strtok(config, "\n") : | |
| 1498 strtok(config + 6 /* sizeof(struct sflap_hdr) */ + strlen("CONFIG:"), "\n"); | |
| 1499 do { | |
| 1500 if (c == NULL) | |
| 1501 break; | |
| 1502 if (*c == 'g') { | |
| 1503 char *utf8 = NULL; | |
|
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
1504 utf8 = gaim_utf8_try_convert(c + 2); |
| 5228 | 1505 if (utf8 == NULL) { |
| 1506 g_strlcpy(current, _("Invalid Groupname"), sizeof(current)); | |
| 1507 } else { | |
| 1508 g_strlcpy(current, utf8, sizeof(current)); | |
| 1509 g_free(utf8); | |
| 1510 } | |
| 1511 if (!gaim_find_group(current)) { | |
| 6695 | 1512 GaimGroup *g = gaim_group_new(current); |
| 5634 | 1513 gaim_blist_add_group(g, |
| 1514 gaim_blist_get_last_sibling(gaimbuddylist->root)); | |
| 5228 | 1515 } |
| 1516 } else if (*c == 'b') { /*&& !gaim_find_buddy(user, c + 2)) {*/ | |
| 1517 char nm[80], sw[388], *a, *utf8 = NULL; | |
| 1518 | |
| 1519 if ((a = strchr(c + 2, ':')) != NULL) { | |
| 1520 *a++ = '\0'; /* nul the : */ | |
| 1521 } | |
| 1522 | |
| 1523 g_strlcpy(nm, c + 2, sizeof(nm)); | |
| 1524 if (a) { | |
|
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
1525 utf8 = gaim_utf8_try_convert(a); |
| 5228 | 1526 if (utf8 == NULL) { |
| 1527 gaim_debug(GAIM_DEBUG_ERROR, "toc blist", | |
| 1528 "Failed to convert alias for " | |
| 1529 "'%s' to UTF-8\n", nm); | |
| 1530 } | |
| 1531 } | |
| 1532 if (utf8 == NULL) { | |
| 1533 sw[0] = '\0'; | |
| 1534 } else { | |
| 1535 /* This can leave a partial sequence at the end, | |
| 1536 * but who cares? */ | |
| 1537 g_strlcpy(sw, utf8, sizeof(sw)); | |
| 1538 g_free(utf8); | |
| 1539 } | |
| 1540 | |
| 1541 if (!gaim_find_buddy(account, nm)) { | |
| 6695 | 1542 GaimBuddy *b = gaim_buddy_new(account, nm, sw); |
| 1543 GaimGroup *g = gaim_find_group(current); | |
| 1544 gaim_blist_add_buddy(b, NULL, g, | |
| 5634 | 1545 gaim_blist_get_last_child((GaimBlistNode*)g)); |
| 5228 | 1546 bud = g_list_append(bud, g_strdup(nm)); |
| 1547 } | |
| 1548 } else if (*c == 'p') { | |
|
6378
01289157fc37
[gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1549 gaim_privacy_permit_add(account, c + 2, TRUE); |
| 5228 | 1550 } else if (*c == 'd') { |
|
6378
01289157fc37
[gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1551 gaim_privacy_deny_add(account, c + 2, TRUE); |
| 5228 | 1552 } else if (!strncmp("toc", c, 3)) { |
|
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1553 sscanf(c + strlen(c) - 1, "%d", &account->perm_deny); |
| 5228 | 1554 gaim_debug(GAIM_DEBUG_MISC, "toc blist", |
|
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1555 "permdeny: %d\n", account->perm_deny); |
|
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1556 if (account->perm_deny == 0) |
|
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1557 account->perm_deny = 1; |
| 5228 | 1558 } else if (*c == 'm') { |
|
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1559 sscanf(c + 2, "%d", &account->perm_deny); |
| 5228 | 1560 gaim_debug(GAIM_DEBUG_MISC, "toc blist", |
|
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1561 "permdeny: %d\n", account->perm_deny); |
|
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1562 if (account->perm_deny == 0) |
|
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1563 account->perm_deny = 1; |
| 5228 | 1564 } |
| 1565 } while ((c = strtok(NULL, "\n"))); | |
| 1566 | |
| 1567 if(account->gc) { | |
| 1568 if(bud) { | |
| 1569 GList *node = bud; | |
| 1570 serv_add_buddies(account->gc, bud); | |
| 1571 while(node) { | |
| 1572 g_free(node->data); | |
| 1573 node = node->next; | |
| 1574 } | |
| 1575 } | |
| 1576 serv_set_permit_deny(account->gc); | |
| 1577 } | |
| 1578 g_list_free(bud); | |
| 1579 } | |
| 1580 } | |
| 1581 | |
| 1582 #if 0 | |
| 1583 /* translate an AIM 3 buddylist (*.lst) to a Gaim buddylist */ | |
| 1584 static GString *translate_lst(FILE *src_fp) | |
| 1585 { | |
| 1586 char line[BUF_LEN], *line2; | |
| 1587 char *name; | |
| 1588 int i; | |
| 1589 | |
| 1590 GString *dest = g_string_new("m 1\n"); | |
| 1591 | |
| 1592 while (fgets(line, BUF_LEN, src_fp)) { | |
| 1593 line2 = g_strchug(line); | |
| 1594 if (strstr(line2, "group") == line2) { | |
| 1595 name = strpbrk(line2, " \t\n\r\f") + 1; | |
| 1596 dest = g_string_append(dest, "g "); | |
| 1597 for (i = 0; i < strcspn(name, "\n\r"); i++) | |
| 1598 if (name[i] != '\"') | |
| 1599 dest = g_string_append_c(dest, name[i]); | |
| 1600 dest = g_string_append_c(dest, '\n'); | |
| 1601 } | |
| 1602 if (strstr(line2, "buddy") == line2) { | |
| 1603 name = strpbrk(line2, " \t\n\r\f") + 1; | |
| 1604 dest = g_string_append(dest, "b "); | |
| 1605 for (i = 0; i < strcspn(name, "\n\r"); i++) | |
| 1606 if (name[i] != '\"') | |
| 1607 dest = g_string_append_c(dest, name[i]); | |
| 1608 dest = g_string_append_c(dest, '\n'); | |
| 1609 } | |
| 1610 } | |
| 1611 | |
| 1612 return dest; | |
| 1613 } | |
| 1614 | |
| 1615 | |
| 1616 /* translate an AIM 4 buddylist (*.blt) to Gaim format */ | |
| 1617 static GString *translate_blt(FILE *src_fp) | |
| 1618 { | |
| 1619 int i; | |
| 1620 char line[BUF_LEN]; | |
| 1621 char *buddy; | |
| 1622 | |
| 1623 GString *dest = g_string_new("m 1\n"); | |
| 1624 | |
| 1625 while (strstr(fgets(line, BUF_LEN, src_fp), "Buddy") == NULL); | |
| 1626 while (strstr(fgets(line, BUF_LEN, src_fp), "list") == NULL); | |
| 1627 | |
| 1628 while (1) { | |
| 1629 fgets(line, BUF_LEN, src_fp); g_strchomp(line); | |
| 1630 if (strchr(line, '}') != NULL) | |
| 1631 break; | |
| 1632 | |
| 1633 if (strchr(line, '{') != NULL) { | |
| 1634 /* Syntax starting with "<group> {" */ | |
| 1635 | |
| 1636 dest = g_string_append(dest, "g "); | |
| 1637 buddy = g_strchug(strtok(line, "{")); | |
| 1638 for (i = 0; i < strlen(buddy); i++) | |
| 1639 if (buddy[i] != '\"') | |
| 1640 dest = g_string_append_c(dest, buddy[i]); | |
| 1641 dest = g_string_append_c(dest, '\n'); | |
| 1642 while (strchr(fgets(line, BUF_LEN, src_fp), '}') == NULL) { | |
| 1643 gboolean pounce = FALSE; | |
| 1644 char *e; | |
| 1645 g_strchomp(line); | |
| 1646 buddy = g_strchug(line); | |
| 1647 gaim_debug(GAIM_DEBUG_MISC, "AIM 4 blt import", | |
| 1648 "buddy: \"%s\"\n", buddy); | |
| 1649 dest = g_string_append(dest, "b "); | |
| 1650 if (strchr(buddy, '{') != NULL) { | |
| 1651 /* buddy pounce, etc */ | |
| 1652 char *pos = strchr(buddy, '{') - 1; | |
| 1653 *pos = 0; | |
| 1654 pounce = TRUE; | |
| 1655 } | |
| 1656 if ((e = strchr(buddy, '\"')) != NULL) { | |
| 1657 *e = '\0'; | |
| 1658 buddy++; | |
| 1659 } | |
| 1660 dest = g_string_append(dest, buddy); | |
| 1661 dest = g_string_append_c(dest, '\n'); | |
| 1662 if (pounce) | |
| 1663 do | |
| 1664 fgets(line, BUF_LEN, src_fp); | |
| 1665 while (!strchr(line, '}')); | |
| 1666 } | |
| 1667 } else { | |
| 1668 | |
| 1669 /* Syntax "group buddy buddy ..." */ | |
| 1670 buddy = g_strchug(strtok(line, " \n")); | |
| 1671 dest = g_string_append(dest, "g "); | |
| 1672 if (strchr(buddy, '\"') != NULL) { | |
| 1673 dest = g_string_append(dest, &buddy[1]); | |
| 1674 dest = g_string_append_c(dest, ' '); | |
| 1675 buddy = g_strchug(strtok(NULL, " \n")); | |
| 1676 while (strchr(buddy, '\"') == NULL) { | |
| 1677 dest = g_string_append(dest, buddy); | |
| 1678 dest = g_string_append_c(dest, ' '); | |
| 1679 buddy = g_strchug(strtok(NULL, " \n")); | |
| 1680 } | |
| 1681 buddy[strlen(buddy) - 1] = '\0'; | |
| 1682 dest = g_string_append(dest, buddy); | |
| 1683 } else { | |
| 1684 dest = g_string_append(dest, buddy); | |
| 1685 } | |
| 1686 dest = g_string_append_c(dest, '\n'); | |
| 1687 while ((buddy = g_strchug(strtok(NULL, " \n"))) != NULL) { | |
| 1688 dest = g_string_append(dest, "b "); | |
| 1689 if (strchr(buddy, '\"') != NULL) { | |
| 1690 dest = g_string_append(dest, &buddy[1]); | |
| 1691 dest = g_string_append_c(dest, ' '); | |
| 1692 buddy = g_strchug(strtok(NULL, " \n")); | |
| 1693 while (strchr(buddy, '\"') == NULL) { | |
| 1694 dest = g_string_append(dest, buddy); | |
| 1695 dest = g_string_append_c(dest, ' '); | |
| 1696 buddy = g_strchug(strtok(NULL, " \n")); | |
| 1697 } | |
| 1698 buddy[strlen(buddy) - 1] = '\0'; | |
| 1699 dest = g_string_append(dest, buddy); | |
| 1700 } else { | |
| 1701 dest = g_string_append(dest, buddy); | |
| 1702 } | |
| 1703 dest = g_string_append_c(dest, '\n'); | |
| 1704 } | |
| 1705 } | |
| 1706 } | |
| 1707 | |
| 1708 return dest; | |
| 1709 } | |
| 1710 | |
| 1711 static GString *translate_gnomeicu(FILE *src_fp) | |
| 1712 { | |
| 1713 char line[BUF_LEN]; | |
| 1714 GString *dest = g_string_new("m 1\ng Buddies\n"); | |
| 1715 | |
| 1716 while (strstr(fgets(line, BUF_LEN, src_fp), "NewContacts") == NULL); | |
| 1717 | |
| 1718 while (fgets(line, BUF_LEN, src_fp)) { | |
| 1719 char *eq; | |
| 1720 g_strchomp(line); | |
| 1721 if (line[0] == '\n' || line[0] == '[') | |
| 1722 break; | |
| 1723 eq = strchr(line, '='); | |
| 1724 if (!eq) | |
| 1725 break; | |
| 1726 *eq = ':'; | |
| 1727 eq = strchr(eq, ','); | |
| 1728 if (eq) | |
| 1729 *eq = '\0'; | |
| 1730 dest = g_string_append(dest, "b "); | |
| 1731 dest = g_string_append(dest, line); | |
| 1732 dest = g_string_append_c(dest, '\n'); | |
| 1733 } | |
| 1734 | |
| 1735 return dest; | |
| 1736 } | |
| 1737 #endif | |
| 1738 | |
| 1739 static gchar *get_screenname_filename(const char *name) | |
| 1740 { | |
| 1741 gchar **split; | |
| 1742 gchar *good; | |
| 1743 gchar *ret; | |
| 1744 | |
| 1745 split = g_strsplit(name, G_DIR_SEPARATOR_S, -1); | |
| 1746 good = g_strjoinv(NULL, split); | |
| 1747 g_strfreev(split); | |
| 1748 | |
| 1749 ret = g_utf8_strup(good, -1); | |
| 1750 | |
| 1751 g_free(good); | |
| 1752 | |
| 1753 return ret; | |
| 1754 } | |
| 1755 | |
| 1756 static gboolean gaim_blist_read(const char *filename); | |
| 1757 | |
| 1758 | |
|
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
1759 static void do_import(GaimAccount *account, const char *filename) |
| 5228 | 1760 { |
| 1761 GString *buf = NULL; | |
| 1762 char first[64]; | |
| 1763 char path[PATHSIZE]; | |
| 1764 int len; | |
| 1765 FILE *f; | |
| 1766 struct stat st; | |
| 1767 | |
| 1768 if (filename) { | |
| 1769 g_snprintf(path, sizeof(path), "%s", filename); | |
| 1770 } else { | |
| 1771 char *g_screenname = get_screenname_filename(account->username); | |
|
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1772 const char *username; |
| 5228 | 1773 char *file = gaim_user_dir(); |
|
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1774 GaimProtocol prpl_num; |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1775 int protocol; |
| 6695 | 1776 |
|
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1777 prpl_num = gaim_account_get_protocol(account); |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1778 |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1779 protocol = prpl_num; |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1780 |
|
6450
e7b87c8e8c0a
[gaim-migrate @ 6959]
Christian Hammond <chipx86@chipx86.com>
parents:
6392
diff
changeset
|
1781 /* TODO Somehow move this checking into prpls */ |
|
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1782 if (prpl_num == GAIM_PROTO_OSCAR) { |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1783 if ((username = gaim_account_get_username(account)) != NULL) { |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1784 protocol = (isalpha(*username) |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1785 ? GAIM_PROTO_TOC : GAIM_PROTO_ICQ); |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1786 } |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1787 } |
| 5228 | 1788 |
| 1789 if (file != (char *)NULL) { | |
| 5435 | 1790 snprintf(path, PATHSIZE, "%s" G_DIR_SEPARATOR_S "%s.%d.blist", file, g_screenname, protocol); |
| 5228 | 1791 g_free(g_screenname); |
| 1792 } else { | |
| 1793 g_free(g_screenname); | |
| 1794 return; | |
| 1795 } | |
| 1796 } | |
| 1797 | |
| 1798 if (stat(path, &st)) { | |
| 1799 gaim_debug(GAIM_DEBUG_ERROR, "blist import", "Unable to stat %s.\n", | |
| 1800 path); | |
| 1801 return; | |
| 1802 } | |
| 1803 | |
| 1804 if (!(f = fopen(path, "r"))) { | |
| 1805 gaim_debug(GAIM_DEBUG_ERROR, "blist import", "Unable to open %s.\n", | |
| 1806 path); | |
| 1807 return; | |
| 1808 } | |
| 1809 | |
| 1810 fgets(first, 64, f); | |
| 1811 | |
| 1812 if ((first[0] == '\n') || (first[0] == '\r' && first[1] == '\n')) | |
| 1813 fgets(first, 64, f); | |
| 1814 | |
| 1815 #if 0 | |
| 1816 if (!g_strncasecmp(first, "<xml", strlen("<xml"))) { | |
| 1817 /* new gaim XML buddy list */ | |
| 1818 gaim_blist_read(path); | |
| 1819 | |
| 1820 /* We really don't need to bother doing stuf like translating AIM 3 buddy lists anymore */ | |
| 1821 | |
| 1822 } else if (!g_strncasecmp(first, "Config {", strlen("Config {"))) { | |
| 1823 /* AIM 4 buddy list */ | |
| 1824 gaim_debug(GAIM_DEBUG_MISC, "blist import", "aim 4\n"); | |
| 1825 rewind(f); | |
| 1826 buf = translate_blt(f); | |
| 1827 } else if (strstr(first, "group") != NULL) { | |
| 1828 /* AIM 3 buddy list */ | |
| 1829 gaim_debug(GAIM_DEBUG_MISC, "blist import", "aim 3\n"); | |
| 1830 rewind(f); | |
| 1831 buf = translate_lst(f); | |
| 1832 } else if (!g_strncasecmp(first, "[User]", strlen("[User]"))) { | |
| 1833 /* GnomeICU (hopefully) */ | |
| 1834 gaim_debug(GAIM_DEBUG_MISC, "blist import", "gnomeicu\n"); | |
| 1835 rewind(f); | |
| 1836 buf = translate_gnomeicu(f); | |
| 1837 | |
| 1838 } else | |
| 1839 #endif | |
| 1840 if (first[0] == 'm') { | |
| 1841 /* Gaim buddy list - no translation */ | |
| 1842 char buf2[BUF_LONG * 2]; | |
| 1843 buf = g_string_new(""); | |
| 1844 rewind(f); | |
| 1845 while (1) { | |
| 1846 len = fread(buf2, 1, BUF_LONG * 2 - 1, f); | |
| 1847 if (len <= 0) | |
| 1848 break; | |
| 1849 buf2[len] = '\0'; | |
| 1850 buf = g_string_append(buf, buf2); | |
| 1851 if (len != BUF_LONG * 2 - 1) | |
| 1852 break; | |
| 1853 } | |
| 1854 } | |
| 1855 | |
| 1856 fclose(f); | |
| 1857 | |
| 1858 if (buf) { | |
| 1859 buf = g_string_prepend(buf, "toc_set_config {"); | |
| 1860 buf = g_string_append(buf, "}\n"); | |
|
7117
943085b0ff8b
[gaim-migrate @ 7684]
Christian Hammond <chipx86@chipx86.com>
parents:
7115
diff
changeset
|
1861 gaim_blist_parse_toc_buddy_list(account, buf->str); |
| 5228 | 1862 g_string_free(buf, TRUE); |
| 1863 } | |
| 1864 } | |
| 1865 | |
| 6695 | 1866 gboolean gaim_group_on_account(GaimGroup *g, GaimAccount *account) { |
| 1867 GaimBlistNode *cnode, *bnode; | |
| 1868 for(cnode = ((GaimBlistNode *)g)->child; cnode; cnode = cnode->next) { | |
| 1869 if(GAIM_BLIST_NODE_IS_CONTACT(cnode)) { | |
| 1870 for(bnode = cnode->child; bnode; bnode = bnode->next) { | |
| 1871 if(GAIM_BLIST_NODE_IS_BUDDY(bnode)) { | |
| 1872 GaimBuddy *buddy = (GaimBuddy *)bnode; | |
| 1873 if((!account && gaim_account_is_connected(buddy->account)) | |
| 1874 || buddy->account == account) | |
| 1875 return TRUE; | |
| 1876 } | |
| 1877 } | |
| 1878 } else if(GAIM_BLIST_NODE_IS_CHAT(cnode)) { | |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
1879 GaimChat *chat = (GaimChat *)cnode; |
| 6695 | 1880 if((!account && gaim_account_is_connected(chat->account)) |
| 1881 || chat->account == account) | |
| 1882 return TRUE; | |
| 1883 } | |
| 5228 | 1884 } |
| 1885 return FALSE; | |
| 1886 } | |
| 1887 | |
| 1888 static gboolean blist_safe_to_write = FALSE; | |
| 1889 | |
| 7132 | 1890 static void parse_setting(GaimBlistNode *node, xmlnode *setting) |
| 1891 { | |
| 1892 const char *name = xmlnode_get_attrib(setting, "name"); | |
| 1893 char *value = xmlnode_get_data(setting); | |
| 1894 | |
| 1895 /* XXX: replace with generic settings stuff */ | |
| 1896 if(GAIM_BLIST_NODE_IS_GROUP(node)) | |
| 1897 gaim_group_set_setting((GaimGroup*)node, name, value); | |
| 1898 else if(GAIM_BLIST_NODE_IS_CHAT(node)) | |
| 1899 gaim_chat_set_setting((GaimChat*)node, name, value); | |
| 1900 else if(GAIM_BLIST_NODE_IS_BUDDY(node)) | |
| 1901 gaim_buddy_set_setting((GaimBuddy*)node, name, value); | |
| 1902 | |
| 1903 g_free(value); | |
| 1904 } | |
| 1905 | |
| 1906 static void parse_buddy(GaimGroup *group, GaimContact *contact, xmlnode *bnode) | |
| 1907 { | |
| 1908 GaimAccount *account; | |
| 1909 GaimBuddy *buddy; | |
| 1910 char *name = NULL, *alias = NULL; | |
| 7153 | 1911 const char *acct_name, *proto, *protocol; |
| 7132 | 1912 xmlnode *x; |
| 1913 | |
| 1914 acct_name = xmlnode_get_attrib(bnode, "account"); | |
| 7153 | 1915 protocol = xmlnode_get_attrib(bnode, "protocol"); |
| 1916 proto = xmlnode_get_attrib(bnode, "proto"); | |
| 1917 | |
| 1918 if(!acct_name || (!proto && !protocol)) | |
| 7132 | 1919 return; |
| 1920 | |
| 7153 | 1921 account = gaim_accounts_find(acct_name, proto ? proto : protocol); |
| 7132 | 1922 |
| 1923 if(!account) | |
| 1924 return; | |
| 1925 | |
| 1926 if((x = xmlnode_get_child(bnode, "name"))) | |
| 1927 name = xmlnode_get_data(x); | |
| 1928 | |
| 1929 if(!name) | |
| 1930 return; | |
| 1931 | |
| 1932 if((x = xmlnode_get_child(bnode, "alias"))) | |
| 1933 alias = xmlnode_get_data(x); | |
| 1934 | |
| 1935 buddy = gaim_buddy_new(account, name, alias); | |
| 1936 gaim_blist_add_buddy(buddy, contact, group, | |
| 1937 gaim_blist_get_last_child((GaimBlistNode*)contact)); | |
| 1938 | |
| 1939 for(x = bnode->child; x; x = x->next) { | |
| 1940 if(x->type != NODE_TYPE_TAG || strcmp(x->name, "setting")) | |
| 1941 continue; | |
| 1942 parse_setting((GaimBlistNode*)buddy, x); | |
| 1943 } | |
| 1944 | |
| 1945 g_free(name); | |
| 1946 if(alias) | |
| 1947 g_free(alias); | |
| 1948 } | |
| 1949 | |
| 1950 static void parse_contact(GaimGroup *group, xmlnode *cnode) | |
| 1951 { | |
| 1952 GaimContact *contact = gaim_contact_new(); | |
| 1953 xmlnode *x; | |
| 7245 | 1954 const char *alias; |
| 7132 | 1955 |
| 1956 gaim_blist_add_contact(contact, group, | |
| 1957 gaim_blist_get_last_child((GaimBlistNode*)group)); | |
| 1958 | |
| 7245 | 1959 if((alias = xmlnode_get_attrib(cnode, "alias"))) { |
| 7132 | 1960 gaim_contact_set_alias(contact, alias); |
| 1961 } | |
| 1962 | |
| 1963 for(x = cnode->child; x; x = x->next) { | |
| 1964 if(x->type != NODE_TYPE_TAG) | |
| 1965 continue; | |
| 1966 if(!strcmp(x->name, "buddy")) | |
| 1967 parse_buddy(group, contact, x); | |
| 1968 else if(strcmp(x->name, "setting")) | |
| 1969 parse_setting((GaimBlistNode*)contact, x); | |
| 5228 | 1970 } |
| 1971 } | |
| 1972 | |
| 7132 | 1973 static void parse_chat(GaimGroup *group, xmlnode *cnode) |
| 1974 { | |
| 1975 GaimChat *chat; | |
| 1976 GaimAccount *account; | |
| 7153 | 1977 const char *acct_name, *proto, *protocol; |
| 7132 | 1978 xmlnode *x; |
| 1979 char *alias = NULL; | |
| 1980 GHashTable *components; | |
| 1981 | |
| 1982 acct_name = xmlnode_get_attrib(cnode, "account"); | |
| 7153 | 1983 protocol = xmlnode_get_attrib(cnode, "protocol"); |
| 1984 proto = xmlnode_get_attrib(cnode, "proto"); | |
| 1985 | |
| 1986 if(!acct_name || (!proto && !protocol)) | |
| 7132 | 1987 return; |
| 1988 | |
| 7153 | 1989 account = gaim_accounts_find(acct_name, proto ? proto : protocol); |
| 7132 | 1990 |
| 1991 if(!account) | |
| 1992 return; | |
| 1993 | |
| 1994 if((x = xmlnode_get_child(cnode, "alias"))) | |
| 1995 alias = xmlnode_get_data(x); | |
| 1996 | |
| 1997 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | |
| 1998 | |
| 1999 for(x = cnode->child; x; x = x->next) { | |
| 2000 const char *name; | |
| 2001 char *value; | |
| 2002 if(x->type != NODE_TYPE_TAG || strcmp(x->name, "component")) | |
| 2003 continue; | |
| 2004 | |
| 2005 name = xmlnode_get_attrib(x, "name"); | |
| 2006 value = xmlnode_get_data(x); | |
| 2007 g_hash_table_replace(components, g_strdup(name), value); | |
| 2008 } | |
| 2009 | |
| 2010 chat = gaim_chat_new(account, alias, components); | |
| 7151 | 2011 gaim_blist_add_chat(chat, group, |
| 2012 gaim_blist_get_last_child((GaimBlistNode*)group)); | |
| 7132 | 2013 |
| 2014 for(x = cnode->child; x; x = x->next) { | |
| 2015 if(x->type != NODE_TYPE_TAG || strcmp(x->name, "setting")) | |
| 2016 continue; | |
| 2017 parse_setting((GaimBlistNode*)chat, x); | |
| 2018 } | |
| 2019 | |
| 2020 if(alias) | |
| 2021 g_free(alias); | |
| 2022 } | |
| 2023 | |
| 2024 | |
| 2025 static void parse_group(xmlnode *groupnode) | |
| 2026 { | |
| 2027 const char *name = xmlnode_get_attrib(groupnode, "name"); | |
| 2028 GaimGroup *group; | |
| 2029 xmlnode *cnode; | |
| 2030 | |
| 2031 if(!name) | |
| 2032 name = _("Buddies"); | |
| 2033 | |
| 2034 group = gaim_group_new(name); | |
| 2035 gaim_blist_add_group(group, | |
| 2036 gaim_blist_get_last_sibling(gaimbuddylist->root)); | |
| 2037 | |
| 2038 for(cnode = groupnode->child; cnode; cnode = cnode->next) { | |
| 2039 if(cnode->type != NODE_TYPE_TAG) | |
| 2040 continue; | |
| 2041 if(!strcmp(cnode->name, "setting")) | |
| 2042 parse_setting((GaimBlistNode*)group, cnode); | |
| 2043 else if(!strcmp(cnode->name, "contact") || | |
| 2044 !strcmp(cnode->name, "person")) | |
| 2045 parse_contact(group, cnode); | |
| 2046 else if(!strcmp(cnode->name, "chat")) | |
| 2047 parse_chat(group, cnode); | |
| 5228 | 2048 } |
| 2049 } | |
| 2050 | |
| 2051 static gboolean gaim_blist_read(const char *filename) { | |
| 7132 | 2052 GError *error; |
| 5228 | 2053 gchar *contents = NULL; |
| 2054 gsize length; | |
| 7132 | 2055 xmlnode *gaim, *blist, *privacy; |
| 5228 | 2056 |
| 2057 gaim_debug(GAIM_DEBUG_INFO, "blist import", | |
| 2058 "Reading %s\n", filename); | |
| 2059 if(!g_file_get_contents(filename, &contents, &length, &error)) { | |
| 2060 gaim_debug(GAIM_DEBUG_ERROR, "blist import", | |
| 2061 "Error reading blist: %s\n", error->message); | |
| 2062 g_error_free(error); | |
| 2063 return FALSE; | |
| 2064 } | |
| 2065 | |
| 7132 | 2066 gaim = xmlnode_from_str(contents, length); |
| 2067 g_free(contents); | |
| 2068 | |
| 2069 if(!gaim) { | |
| 2070 gaim_debug(GAIM_DEBUG_ERROR, "blist import", "Error parsing %s\n", | |
| 2071 filename); | |
| 5228 | 2072 return FALSE; |
| 2073 } | |
| 2074 | |
| 7132 | 2075 blist = xmlnode_get_child(gaim, "blist"); |
| 2076 if(blist) { | |
| 2077 xmlnode *groupnode; | |
| 2078 for(groupnode = blist->child; groupnode; groupnode = groupnode->next) { | |
| 2079 if(groupnode->type != NODE_TYPE_TAG || | |
| 2080 strcmp(groupnode->name, "group")) | |
| 2081 continue; | |
| 2082 | |
| 2083 parse_group(groupnode); | |
| 2084 } | |
| 5228 | 2085 } |
| 2086 | |
| 7132 | 2087 privacy = xmlnode_get_child(gaim, "privacy"); |
| 2088 if(privacy) { | |
| 2089 xmlnode *anode; | |
| 2090 for(anode = privacy->child; anode; anode = anode->next) { | |
| 2091 xmlnode *x; | |
| 2092 GaimAccount *account; | |
| 7153 | 2093 const char *acct_name, *proto, *mode, *protocol; |
| 7132 | 2094 |
| 2095 acct_name = xmlnode_get_attrib(anode, "name"); | |
| 7153 | 2096 protocol = xmlnode_get_attrib(anode, "protocol"); |
| 2097 proto = xmlnode_get_attrib(anode, "proto"); | |
| 7132 | 2098 mode = xmlnode_get_attrib(anode, "mode"); |
| 2099 | |
| 7153 | 2100 if(!acct_name || (!proto && !protocol) || !mode) |
| 7132 | 2101 continue; |
| 2102 | |
| 7153 | 2103 account = gaim_accounts_find(acct_name, proto ? proto : protocol); |
| 7132 | 2104 |
| 2105 if(!account) | |
| 2106 continue; | |
| 2107 | |
| 2108 account->perm_deny = atoi(mode); | |
| 2109 | |
| 2110 for(x = anode->child; x; x = x->next) { | |
| 2111 char *name; | |
| 2112 if(x->type != NODE_TYPE_TAG) | |
| 2113 continue; | |
| 2114 | |
| 2115 if(!strcmp(x->name, "permit")) { | |
| 2116 name = xmlnode_get_data(x); | |
| 2117 gaim_privacy_permit_add(account, name, TRUE); | |
| 2118 g_free(name); | |
| 2119 } else if(!strcmp(x->name, "block")) { | |
| 2120 name = xmlnode_get_data(x); | |
| 2121 gaim_privacy_deny_add(account, name, TRUE); | |
| 2122 g_free(name); | |
| 2123 } | |
| 2124 } | |
| 2125 } | |
| 2126 } | |
| 5228 | 2127 |
| 2128 gaim_debug(GAIM_DEBUG_INFO, "blist import", "Finished reading %s\n", | |
| 2129 filename); | |
| 2130 | |
| 2131 return TRUE; | |
| 2132 } | |
| 2133 | |
| 2134 void gaim_blist_load() { | |
|
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
2135 GList *accts; |
| 5228 | 2136 char *user_dir = gaim_user_dir(); |
| 2137 char *filename; | |
| 2138 char *msg; | |
| 2139 | |
| 2140 blist_safe_to_write = TRUE; | |
| 2141 | |
| 2142 if(!user_dir) | |
| 2143 return; | |
| 2144 | |
| 2145 filename = g_build_filename(user_dir, "blist.xml", NULL); | |
| 2146 | |
| 2147 if(g_file_test(filename, G_FILE_TEST_EXISTS)) { | |
| 2148 if(!gaim_blist_read(filename)) { | |
| 2149 msg = g_strdup_printf(_("An error was encountered parsing your " | |
| 2150 "buddy list. It has not been loaded.")); | |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2151 gaim_notify_error(NULL, NULL, _("Buddy List Error"), msg); |
| 5228 | 2152 g_free(msg); |
| 2153 } | |
|
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
2154 } else if(g_list_length(gaim_accounts_get_all())) { |
| 5228 | 2155 /* 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
|
2156 for(accts = gaim_accounts_get_all(); accts; accts = accts->next) { |
| 5228 | 2157 do_import(accts->data, NULL); |
| 2158 } | |
| 2159 gaim_blist_save(); | |
| 2160 } | |
| 2161 | |
| 2162 g_free(filename); | |
| 2163 } | |
| 2164 | |
|
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2165 void |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2166 gaim_blist_request_add_buddy(GaimAccount *account, const char *username, |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2167 const char *group, const char *alias) |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2168 { |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
2169 GaimBlistUiOps *ui_ops; |
|
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2170 |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2171 ui_ops = gaim_blist_get_ui_ops(); |
|
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 if (ui_ops != NULL && ui_ops->request_add_buddy != NULL) |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2174 ui_ops->request_add_buddy(account, username, group, alias); |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2175 } |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2176 |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2177 void |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2178 gaim_blist_request_add_chat(GaimAccount *account, GaimGroup *group) |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2179 { |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
2180 GaimBlistUiOps *ui_ops; |
|
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2181 |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2182 ui_ops = gaim_blist_get_ui_ops(); |
|
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 if (ui_ops != NULL && ui_ops->request_add_chat != NULL) |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2185 ui_ops->request_add_chat(account, group); |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2186 } |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2187 |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2188 void |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2189 gaim_blist_request_add_group(void) |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2190 { |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
2191 GaimBlistUiOps *ui_ops; |
|
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2192 |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2193 ui_ops = gaim_blist_get_ui_ops(); |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2194 |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2195 if (ui_ops != NULL && ui_ops->request_add_group != NULL) |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2196 ui_ops->request_add_group(); |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2197 } |
|
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
2198 |
| 5228 | 2199 static void blist_print_group_settings(gpointer key, gpointer data, |
| 2200 gpointer user_data) { | |
| 2201 char *key_val; | |
| 2202 char *data_val; | |
| 2203 FILE *file = user_data; | |
| 2204 | |
| 2205 if(!key || !data) | |
| 2206 return; | |
| 2207 | |
| 2208 key_val = g_markup_escape_text(key, -1); | |
| 2209 data_val = g_markup_escape_text(data, -1); | |
| 2210 | |
| 2211 fprintf(file, "\t\t\t<setting name=\"%s\">%s</setting>\n", key_val, | |
| 2212 data_val); | |
| 2213 g_free(key_val); | |
| 2214 g_free(data_val); | |
| 2215 } | |
| 2216 | |
| 2217 static void blist_print_buddy_settings(gpointer key, gpointer data, | |
| 2218 gpointer user_data) { | |
| 2219 char *key_val; | |
| 2220 char *data_val; | |
| 2221 FILE *file = user_data; | |
| 2222 | |
| 2223 if(!key || !data) | |
| 2224 return; | |
| 2225 | |
| 2226 key_val = g_markup_escape_text(key, -1); | |
| 2227 data_val = g_markup_escape_text(data, -1); | |
| 2228 | |
| 2229 fprintf(file, "\t\t\t\t\t<setting name=\"%s\">%s</setting>\n", key_val, | |
| 2230 data_val); | |
| 2231 g_free(key_val); | |
| 2232 g_free(data_val); | |
| 2233 } | |
| 2234 | |
| 6695 | 2235 static void blist_print_cnode_settings(gpointer key, gpointer data, |
| 2236 gpointer user_data) { | |
| 2237 char *key_val; | |
| 2238 char *data_val; | |
| 2239 FILE *file = user_data; | |
| 2240 | |
| 2241 if(!key || !data) | |
| 2242 return; | |
| 2243 | |
| 2244 key_val = g_markup_escape_text(key, -1); | |
| 2245 data_val = g_markup_escape_text(data, -1); | |
| 2246 | |
| 2247 fprintf(file, "\t\t\t\t<setting name=\"%s\">%s</setting>\n", key_val, | |
| 2248 data_val); | |
| 2249 g_free(key_val); | |
| 2250 g_free(data_val); | |
| 2251 } | |
| 2252 | |
| 5234 | 2253 static void blist_print_chat_components(gpointer key, gpointer data, |
| 2254 gpointer user_data) { | |
| 2255 char *key_val; | |
| 2256 char *data_val; | |
| 2257 FILE *file = user_data; | |
| 2258 | |
| 2259 if(!key || !data) | |
| 2260 return; | |
| 2261 | |
| 2262 key_val = g_markup_escape_text(key, -1); | |
| 2263 data_val = g_markup_escape_text(data, -1); | |
| 2264 | |
| 2265 fprintf(file, "\t\t\t\t<component name=\"%s\">%s</component>\n", key_val, | |
| 2266 data_val); | |
| 2267 g_free(key_val); | |
| 2268 g_free(data_val); | |
| 2269 } | |
| 2270 | |
| 6695 | 2271 static void print_buddy(FILE *file, GaimBuddy *buddy) { |
| 2272 char *bud_name = g_markup_escape_text(buddy->name, -1); | |
| 2273 char *bud_alias = NULL; | |
| 2274 char *acct_name = g_markup_escape_text(buddy->account->username, -1); | |
| 7153 | 2275 int proto_num = gaim_account_get_protocol(buddy->account); |
| 6695 | 2276 if(buddy->alias) |
| 2277 bud_alias= g_markup_escape_text(buddy->alias, -1); | |
| 7153 | 2278 fprintf(file, "\t\t\t\t<buddy account=\"%s\" proto=\"%s\"", acct_name, |
| 2279 gaim_account_get_protocol_id(buddy->account)); | |
| 2280 if(proto_num != -1) | |
| 2281 fprintf(file, " protocol=\"%d\"", proto_num); | |
| 2282 fprintf(file, ">\n"); | |
| 2283 | |
| 6695 | 2284 fprintf(file, "\t\t\t\t\t<name>%s</name>\n", bud_name); |
| 2285 if(bud_alias) { | |
| 2286 fprintf(file, "\t\t\t\t\t<alias>%s</alias>\n", bud_alias); | |
| 2287 } | |
| 2288 g_hash_table_foreach(buddy->settings, blist_print_buddy_settings, file); | |
| 2289 fprintf(file, "\t\t\t\t</buddy>\n"); | |
| 2290 g_free(bud_name); | |
| 2291 g_free(bud_alias); | |
| 2292 g_free(acct_name); | |
| 2293 } | |
| 2294 | |
|
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
2295 static void gaim_blist_write(FILE *file, GaimAccount *exp_acct) { |
|
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
2296 GList *accounts; |
|
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
2297 GSList *buds; |
| 6695 | 2298 GaimBlistNode *gnode, *cnode, *bnode; |
| 5228 | 2299 fprintf(file, "<?xml version='1.0' encoding='UTF-8' ?>\n"); |
| 2300 fprintf(file, "<gaim version=\"1\">\n"); | |
| 2301 fprintf(file, "\t<blist>\n"); | |
| 2302 | |
| 2303 for(gnode = gaimbuddylist->root; gnode; gnode = gnode->next) { | |
| 6695 | 2304 GaimGroup *group; |
| 2305 | |
| 5228 | 2306 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
| 2307 continue; | |
| 6695 | 2308 |
| 2309 group = (GaimGroup *)gnode; | |
| 5228 | 2310 if(!exp_acct || gaim_group_on_account(group, exp_acct)) { |
| 2311 char *group_name = g_markup_escape_text(group->name, -1); | |
| 2312 fprintf(file, "\t\t<group name=\"%s\">\n", group_name); | |
| 2313 g_hash_table_foreach(group->settings, blist_print_group_settings, file); | |
| 6695 | 2314 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
| 2315 if(GAIM_BLIST_NODE_IS_CONTACT(cnode)) { | |
| 6755 | 2316 GaimContact *contact = (GaimContact*)cnode; |
| 2317 fprintf(file, "\t\t\t<contact"); | |
| 2318 if(contact->alias) { | |
| 2319 char *alias = g_markup_escape_text(contact->alias, -1); | |
| 2320 fprintf(file, " alias=\"%s\"", alias); | |
| 2321 g_free(alias); | |
| 2322 } | |
| 2323 fprintf(file, ">\n"); | |
| 6695 | 2324 |
| 2325 for(bnode = cnode->child; bnode; bnode = bnode->next) { | |
| 2326 if(GAIM_BLIST_NODE_IS_BUDDY(bnode)) { | |
| 2327 GaimBuddy *buddy = (GaimBuddy *)bnode; | |
| 2328 if(!exp_acct || buddy->account == exp_acct) { | |
| 2329 print_buddy(file, buddy); | |
| 2330 } | |
| 5234 | 2331 } |
| 5228 | 2332 } |
| 6695 | 2333 |
| 2334 fprintf(file, "\t\t\t</contact>\n"); | |
| 2335 } else if(GAIM_BLIST_NODE_IS_CHAT(cnode)) { | |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
2336 GaimChat *chat = (GaimChat *)cnode; |
| 5234 | 2337 if(!exp_acct || chat->account == exp_acct) { |
| 2338 char *acct_name = g_markup_escape_text(chat->account->username, -1); | |
| 7153 | 2339 int proto_num = gaim_account_get_protocol(chat->account); |
| 2340 fprintf(file, "\t\t\t<chat proto=\"%s\" account=\"%s\"", | |
| 7133 | 2341 gaim_account_get_protocol_id(chat->account), |
|
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
2342 acct_name); |
| 7153 | 2343 if(proto_num != -1) |
| 2344 fprintf(file, " protocol=\"%d\"", proto_num); | |
| 2345 fprintf(file, ">\n"); | |
| 2346 | |
| 5237 | 2347 if(chat->alias) { |
| 2348 char *chat_alias = g_markup_escape_text(chat->alias, -1); | |
| 2349 fprintf(file, "\t\t\t\t<alias>%s</alias>\n", chat_alias); | |
| 2350 g_free(chat_alias); | |
| 2351 } | |
| 5234 | 2352 g_hash_table_foreach(chat->components, |
| 2353 blist_print_chat_components, file); | |
| 5906 | 2354 g_hash_table_foreach(chat->settings, |
| 6695 | 2355 blist_print_cnode_settings, file); |
| 5234 | 2356 fprintf(file, "\t\t\t</chat>\n"); |
| 5237 | 2357 g_free(acct_name); |
| 5234 | 2358 } |
| 5228 | 2359 } |
| 2360 } | |
| 2361 fprintf(file, "\t\t</group>\n"); | |
| 2362 g_free(group_name); | |
| 2363 } | |
| 2364 } | |
| 2365 | |
| 2366 fprintf(file, "\t</blist>\n"); | |
| 2367 fprintf(file, "\t<privacy>\n"); | |
| 2368 | |
|
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
2369 for(accounts = gaim_accounts_get_all(); |
|
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
2370 accounts != NULL; |
|
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
2371 accounts = accounts->next) { |
|
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
2372 |
|
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
2373 GaimAccount *account = accounts->data; |
| 5228 | 2374 char *acct_name = g_markup_escape_text(account->username, -1); |
| 7153 | 2375 int proto_num = gaim_account_get_protocol(account); |
| 5228 | 2376 if(!exp_acct || account == exp_acct) { |
| 7153 | 2377 fprintf(file, "\t\t<account proto=\"%s\" name=\"%s\" " |
| 2378 "mode=\"%d\"", gaim_account_get_protocol_id(account), | |
|
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
2379 acct_name, account->perm_deny); |
| 7153 | 2380 if(proto_num != -1) |
| 2381 fprintf(file, " protocol=\"%d\"", proto_num); | |
| 2382 fprintf(file, ">\n"); | |
| 2383 | |
| 5228 | 2384 for(buds = account->permit; buds; buds = buds->next) { |
| 2385 char *bud_name = g_markup_escape_text(buds->data, -1); | |
| 2386 fprintf(file, "\t\t\t<permit>%s</permit>\n", bud_name); | |
| 2387 g_free(bud_name); | |
| 2388 } | |
| 2389 for(buds = account->deny; buds; buds = buds->next) { | |
| 2390 char *bud_name = g_markup_escape_text(buds->data, -1); | |
| 2391 fprintf(file, "\t\t\t<block>%s</block>\n", bud_name); | |
| 2392 g_free(bud_name); | |
| 2393 } | |
| 2394 fprintf(file, "\t\t</account>\n"); | |
| 2395 } | |
| 2396 g_free(acct_name); | |
| 2397 } | |
| 2398 | |
| 2399 fprintf(file, "\t</privacy>\n"); | |
| 2400 fprintf(file, "</gaim>\n"); | |
| 2401 } | |
| 2402 | |
| 2403 void gaim_blist_save() { | |
| 2404 FILE *file; | |
| 2405 char *user_dir = gaim_user_dir(); | |
| 2406 char *filename; | |
| 2407 char *filename_real; | |
| 2408 | |
| 2409 if(!user_dir) | |
| 2410 return; | |
| 2411 if(!blist_safe_to_write) { | |
| 2412 gaim_debug(GAIM_DEBUG_WARNING, "blist save", | |
| 2413 "AHH!! Tried to write the blist before we read it!\n"); | |
| 2414 return; | |
| 2415 } | |
| 2416 | |
| 2417 file = fopen(user_dir, "r"); | |
| 2418 if(!file) | |
| 2419 mkdir(user_dir, S_IRUSR | S_IWUSR | S_IXUSR); | |
| 2420 else | |
| 2421 fclose(file); | |
| 2422 | |
| 2423 filename = g_build_filename(user_dir, "blist.xml.save", NULL); | |
| 2424 | |
| 2425 if((file = fopen(filename, "w"))) { | |
| 2426 gaim_blist_write(file, NULL); | |
| 2427 fclose(file); | |
| 2428 chmod(filename, S_IRUSR | S_IWUSR); | |
| 2429 } else { | |
| 2430 gaim_debug(GAIM_DEBUG_ERROR, "blist save", "Unable to write %s\n", | |
| 2431 filename); | |
| 2432 } | |
| 2433 | |
| 2434 filename_real = g_build_filename(user_dir, "blist.xml", NULL); | |
| 2435 | |
| 2436 if(rename(filename, filename_real) < 0) | |
| 2437 gaim_debug(GAIM_DEBUG_ERROR, "blist save", | |
| 2438 "Error renaming %s to %s\n", filename, filename_real); | |
| 2439 | |
| 2440 | |
| 2441 g_free(filename); | |
| 2442 g_free(filename_real); | |
| 2443 } | |
| 2444 | |
| 6695 | 2445 void gaim_group_set_setting(GaimGroup *g, const char *key, |
| 5228 | 2446 const char *value) { |
| 2447 if(!g) | |
| 2448 return; | |
| 2449 g_hash_table_replace(g->settings, g_strdup(key), g_strdup(value)); | |
| 2450 } | |
| 2451 | |
| 7125 | 2452 const char *gaim_group_get_setting(GaimGroup *g, const char *key) { |
| 5228 | 2453 if(!g) |
| 2454 return NULL; | |
| 7125 | 2455 return g_hash_table_lookup(g->settings, key); |
| 5228 | 2456 } |
| 2457 | |
| 7125 | 2458 void gaim_chat_set_setting(GaimChat *c, const char *key, |
| 5906 | 2459 const char *value) |
| 2460 { | |
| 2461 if(!c) | |
| 2462 return; | |
| 2463 g_hash_table_replace(c->settings, g_strdup(key), g_strdup(value)); | |
| 2464 } | |
| 2465 | |
| 7125 | 2466 const char *gaim_chat_get_setting(GaimChat *c, const char *key) |
| 5906 | 2467 { |
| 2468 if(!c) | |
| 2469 return NULL; | |
| 7125 | 2470 return g_hash_table_lookup(c->settings, key); |
| 5906 | 2471 } |
| 2472 | |
| 6695 | 2473 void gaim_buddy_set_setting(GaimBuddy *b, const char *key, |
| 5228 | 2474 const char *value) { |
| 2475 if(!b) | |
| 2476 return; | |
| 2477 g_hash_table_replace(b->settings, g_strdup(key), g_strdup(value)); | |
| 2478 } | |
| 2479 | |
| 7125 | 2480 const char *gaim_buddy_get_setting(GaimBuddy *b, const char *key) { |
| 5228 | 2481 if(!b) |
| 2482 return NULL; | |
| 7125 | 2483 return g_hash_table_lookup(b->settings, key); |
| 5228 | 2484 } |
| 2485 | |
| 6695 | 2486 int gaim_blist_get_group_size(GaimGroup *group, gboolean offline) { |
| 5228 | 2487 if(!group) |
| 2488 return 0; | |
| 2489 | |
| 5277 | 2490 return offline ? group->totalsize : group->currentsize; |
| 5228 | 2491 } |
| 2492 | |
| 6695 | 2493 int gaim_blist_get_group_online_count(GaimGroup *group) { |
| 5228 | 2494 if(!group) |
| 2495 return 0; | |
| 2496 | |
| 5277 | 2497 return group->online; |
| 5228 | 2498 } |
| 2499 | |
|
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7003
diff
changeset
|
2500 void |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
2501 gaim_blist_set_ui_ops(GaimBlistUiOps *ops) |
|
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7003
diff
changeset
|
2502 { |
|
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7003
diff
changeset
|
2503 blist_ui_ops = ops; |
|
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7003
diff
changeset
|
2504 } |
|
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7003
diff
changeset
|
2505 |
|
7098
770233dad86c
[gaim-migrate @ 7663]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
2506 GaimBlistUiOps * |
|
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7003
diff
changeset
|
2507 gaim_blist_get_ui_ops(void) |
|
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7003
diff
changeset
|
2508 { |
|
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7003
diff
changeset
|
2509 return blist_ui_ops; |
|
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7003
diff
changeset
|
2510 } |
|
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7003
diff
changeset
|
2511 |
|
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7003
diff
changeset
|
2512 |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2513 void * |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2514 gaim_blist_get_handle(void) |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2515 { |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2516 static int handle; |
| 5228 | 2517 |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2518 return &handle; |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2519 } |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2520 |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2521 void |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2522 gaim_blist_init(void) |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2523 { |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2524 void *handle = gaim_blist_get_handle(); |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2525 |
|
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2526 gaim_signal_register(handle, "buddy-away", |
|
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)); |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2530 |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2531 gaim_signal_register(handle, "buddy-back", |
|
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)); |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2535 |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2536 gaim_signal_register(handle, "buddy-idle", |
|
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 gaim_signal_register(handle, "buddy-unidle", |
|
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2541 gaim_marshal_VOID__POINTER, NULL, 1, |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2542 gaim_value_new(GAIM_TYPE_SUBTYPE, |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2543 GAIM_SUBTYPE_BLIST_BUDDY)); |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2544 |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2545 gaim_signal_register(handle, "buddy-signed-on", |
|
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2546 gaim_marshal_VOID__POINTER, NULL, 1, |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2547 gaim_value_new(GAIM_TYPE_SUBTYPE, |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2548 GAIM_SUBTYPE_BLIST_BUDDY)); |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2549 |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2550 gaim_signal_register(handle, "buddy-signed-off", |
|
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2551 gaim_marshal_VOID__POINTER, NULL, 1, |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2552 gaim_value_new(GAIM_TYPE_SUBTYPE, |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2553 GAIM_SUBTYPE_BLIST_BUDDY)); |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2554 |
|
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6506
diff
changeset
|
2555 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
|
2556 } |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2557 |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2558 void |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2559 gaim_blist_uninit(void) |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2560 { |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2561 gaim_signals_unregister_by_instance(gaim_blist_get_handle()); |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6473
diff
changeset
|
2562 } |
