Mercurial > pidgin.yaz
comparison src/blist.c @ 10052:eaec201b2688
[gaim-migrate @ 11013]
More rockin status stuff from Dave West!
Things are beginning to shape up quite well.
Dave, again, sorry it took me a week to get to this. Girl waits for no man.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 19 Sep 2004 21:19:55 +0000 |
parents | e6e68b9db19b |
children | 9fdbfe832fac |
comparison
equal
deleted
inserted
replaced
10051:0810288958ad | 10052:eaec201b2688 |
---|---|
239 | 239 |
240 if (ops && ops->set_visible) | 240 if (ops && ops->set_visible) |
241 ops->set_visible(gaimbuddylist, show); | 241 ops->set_visible(gaimbuddylist, show); |
242 } | 242 } |
243 | 243 |
244 void gaim_blist_update_buddy_status(GaimBuddy *buddy, int status) | |
245 { | |
246 #if 0 | |
247 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; | |
248 int old_status; | |
249 | |
250 g_return_if_fail(buddy != NULL); | |
251 | |
252 old_status = buddy->uc; | |
253 if (old_status != status) { | |
254 buddy->uc = status; | |
255 gaim_contact_compute_priority_buddy(gaim_buddy_get_contact(buddy)); | |
256 | |
257 if ((status & UC_UNAVAILABLE) != (old_status & UC_UNAVAILABLE)) { | |
258 if (status & UC_UNAVAILABLE) | |
259 gaim_signal_emit(gaim_blist_get_handle(), "buddy-away", buddy); | |
260 else | |
261 gaim_signal_emit(gaim_blist_get_handle(), "buddy-back", buddy); | |
262 } | |
263 } | |
264 | |
265 if (ops && ops->update) | |
266 ops->update(gaimbuddylist, (GaimBlistNode*)buddy); | |
267 #endif | |
268 } | |
269 | |
270 static gboolean presence_update_timeout_cb(GaimBuddy *buddy) | 244 static gboolean presence_update_timeout_cb(GaimBuddy *buddy) |
271 { | 245 { |
272 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; | 246 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
273 GaimConversation *conv; | 247 GaimConversation *conv; |
274 | 248 |
297 } | 271 } |
298 | 272 |
299 return FALSE; | 273 return FALSE; |
300 } | 274 } |
301 | 275 |
302 void gaim_blist_update_buddy_presence(GaimBuddy *buddy, gboolean online) | 276 void |
277 gaim_blist_update_buddy_status(GaimBuddy *buddy, GaimStatus *old_status) | |
303 { | 278 { |
304 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; | 279 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
280 GaimPresence *presence; | |
281 GaimStatus *status; | |
305 gboolean did_something = FALSE; | 282 gboolean did_something = FALSE; |
306 | 283 |
307 g_return_if_fail(buddy != NULL); | 284 g_return_if_fail(buddy != NULL); |
308 | 285 |
309 if (!GAIM_BUDDY_IS_ONLINE(buddy) && online) { | 286 presence = gaim_buddy_get_presence(buddy); |
287 status = gaim_presence_get_active_status(presence); | |
288 | |
289 gaim_debug_info("blist", "Updating buddy status\n"); | |
290 | |
291 if (gaim_status_is_online(status) && | |
292 !gaim_status_is_online(old_status)) { | |
310 int old_present = buddy->present; | 293 int old_present = buddy->present; |
311 buddy->present = GAIM_BUDDY_SIGNING_ON; | 294 |
312 gaim_signal_emit(gaim_blist_get_handle(), "buddy-signed-on", buddy); | 295 gaim_signal_emit(gaim_blist_get_handle(), "buddy-signed-on", buddy); |
313 did_something = TRUE; | |
314 | |
315 if (old_present != GAIM_BUDDY_SIGNING_OFF) { | 296 if (old_present != GAIM_BUDDY_SIGNING_OFF) { |
316 ((GaimContact*)((GaimBlistNode*)buddy)->parent)->online++; | 297 ((GaimContact*)((GaimBlistNode*)buddy)->parent)->online++; |
317 if (((GaimContact*)((GaimBlistNode*)buddy)->parent)->online == 1) | 298 if (((GaimContact*)((GaimBlistNode*)buddy)->parent)->online == 1) |
318 ((GaimGroup *)((GaimBlistNode *)buddy)->parent->parent)->online++; | 299 ((GaimGroup *)((GaimBlistNode *)buddy)->parent->parent)->online++; |
319 } | 300 } |
320 } else if (GAIM_BUDDY_IS_ONLINE(buddy) && !online) { | |
321 buddy->present = GAIM_BUDDY_SIGNING_OFF; | |
322 gaim_signal_emit(gaim_blist_get_handle(), "buddy-signed-off", buddy); | |
323 did_something = TRUE; | |
324 } | |
325 | |
326 if (did_something) { | |
327 if (buddy->timer > 0) | 301 if (buddy->timer > 0) |
328 gaim_timeout_remove(buddy->timer); | 302 gaim_timeout_remove(buddy->timer); |
329 buddy->timer = gaim_timeout_add(10000, (GSourceFunc)presence_update_timeout_cb, buddy); | 303 buddy->timer = gaim_timeout_add(10000, (GSourceFunc)presence_update_timeout_cb, buddy); |
330 | 304 did_something = TRUE; |
305 | |
306 } else if (!gaim_status_is_online(status) && | |
307 gaim_status_is_online(old_status)) { | |
308 buddy->present = GAIM_BUDDY_SIGNING_OFF; | |
309 gaim_signal_emit(gaim_blist_get_handle(), "buddy-signed-off", buddy); | |
310 if (buddy->timer > 0) | |
311 gaim_timeout_remove(buddy->timer); | |
312 buddy->timer = gaim_timeout_add(10000, (GSourceFunc)presence_update_timeout_cb, buddy); | |
313 did_something = TRUE; | |
314 | |
315 } else if (gaim_status_is_available(status) && | |
316 !gaim_status_is_available(old_status)) { | |
317 gaim_signal_emit(gaim_blist_get_handle(), "buddy-back", buddy); | |
318 did_something = TRUE; | |
319 | |
320 } else if (!gaim_status_is_available(status) && | |
321 gaim_status_is_available(old_status)) { | |
322 gaim_signal_emit(gaim_blist_get_handle(), "buddy-away", buddy); | |
323 did_something = TRUE; | |
324 | |
325 } | |
326 | |
327 if (did_something) { | |
331 gaim_contact_compute_priority_buddy(gaim_buddy_get_contact(buddy)); | 328 gaim_contact_compute_priority_buddy(gaim_buddy_get_contact(buddy)); |
332 if (ops && ops->update) | 329 if (ops && ops->update) |
333 ops->update(gaimbuddylist, (GaimBlistNode *)buddy); | 330 ops->update(gaimbuddylist, (GaimBlistNode *)buddy); |
334 } | 331 } |
335 } | 332 } |
604 buddy = g_new0(GaimBuddy, 1); | 601 buddy = g_new0(GaimBuddy, 1); |
605 buddy->account = account; | 602 buddy->account = account; |
606 buddy->name = g_strdup(screenname); | 603 buddy->name = g_strdup(screenname); |
607 buddy->alias = g_strdup(alias); | 604 buddy->alias = g_strdup(alias); |
608 buddy->presence = gaim_presence_new_for_buddy(buddy); | 605 buddy->presence = gaim_presence_new_for_buddy(buddy); |
606 | |
607 gaim_presence_set_status_active(buddy->presence, "offline", TRUE); | |
609 | 608 |
610 gaim_blist_node_initialize_settings((GaimBlistNode *)buddy); | 609 gaim_blist_node_initialize_settings((GaimBlistNode *)buddy); |
611 ((GaimBlistNode *)buddy)->type = GAIM_BLIST_BUDDY_NODE; | 610 ((GaimBlistNode *)buddy)->type = GAIM_BLIST_BUDDY_NODE; |
612 | 611 |
613 if (ops && ops->new_node) | 612 if (ops && ops->new_node) |