Mercurial > pidgin
changeset 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 | 0810288958ad |
children | a4ceacb1816d |
files | plugins/perl/common/BuddyList_Buddy.xs src/account.c src/blist.c src/blist.h src/cmds.h src/connection.c src/prpl.c src/server.c src/status.c |
diffstat | 9 files changed, 73 insertions(+), 88 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/perl/common/BuddyList_Buddy.xs Sun Sep 19 21:14:28 2004 +0000 +++ b/plugins/perl/common/BuddyList_Buddy.xs Sun Sep 19 21:19:55 2004 +0000 @@ -14,13 +14,6 @@ RETVAL void -update_presence(buddy, presence) - Gaim::BuddyList::Buddy buddy - int presence -CODE: - gaim_blist_update_buddy_presence(buddy, presence); - -void rename(buddy, new_name) Gaim::BuddyList::Buddy buddy const char *new_name
--- a/src/account.c Sun Sep 19 21:14:28 2004 +0000 +++ b/src/account.c Sun Sep 19 21:19:55 2004 +0000 @@ -152,14 +152,16 @@ account->presence = gaim_presence_new_for_account(account); prpl = gaim_find_prpl(gaim_account_get_protocol_id(account)); - + if (prpl == NULL) return account; - + prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); if ( prpl_info != NULL && prpl_info->status_types != NULL ) gaim_account_set_status_types(account, prpl_info->status_types(account)); + gaim_presence_set_status_active(account->presence, "offline", TRUE); + return account; }
--- a/src/blist.c Sun Sep 19 21:14:28 2004 +0000 +++ b/src/blist.c Sun Sep 19 21:19:55 2004 +0000 @@ -241,32 +241,6 @@ ops->set_visible(gaimbuddylist, show); } -void gaim_blist_update_buddy_status(GaimBuddy *buddy, int status) -{ -#if 0 - GaimBlistUiOps *ops = gaimbuddylist->ui_ops; - int old_status; - - g_return_if_fail(buddy != NULL); - - old_status = buddy->uc; - if (old_status != status) { - buddy->uc = status; - gaim_contact_compute_priority_buddy(gaim_buddy_get_contact(buddy)); - - if ((status & UC_UNAVAILABLE) != (old_status & UC_UNAVAILABLE)) { - if (status & UC_UNAVAILABLE) - gaim_signal_emit(gaim_blist_get_handle(), "buddy-away", buddy); - else - gaim_signal_emit(gaim_blist_get_handle(), "buddy-back", buddy); - } - } - - if (ops && ops->update) - ops->update(gaimbuddylist, (GaimBlistNode*)buddy); -#endif -} - static gboolean presence_update_timeout_cb(GaimBuddy *buddy) { GaimBlistUiOps *ops = gaimbuddylist->ui_ops; @@ -299,35 +273,58 @@ return FALSE; } -void gaim_blist_update_buddy_presence(GaimBuddy *buddy, gboolean online) +void +gaim_blist_update_buddy_status(GaimBuddy *buddy, GaimStatus *old_status) { GaimBlistUiOps *ops = gaimbuddylist->ui_ops; + GaimPresence *presence; + GaimStatus *status; gboolean did_something = FALSE; g_return_if_fail(buddy != NULL); - if (!GAIM_BUDDY_IS_ONLINE(buddy) && online) { + presence = gaim_buddy_get_presence(buddy); + status = gaim_presence_get_active_status(presence); + + gaim_debug_info("blist", "Updating buddy status\n"); + + if (gaim_status_is_online(status) && + !gaim_status_is_online(old_status)) { int old_present = buddy->present; - buddy->present = GAIM_BUDDY_SIGNING_ON; + gaim_signal_emit(gaim_blist_get_handle(), "buddy-signed-on", buddy); - did_something = TRUE; - if (old_present != GAIM_BUDDY_SIGNING_OFF) { ((GaimContact*)((GaimBlistNode*)buddy)->parent)->online++; if (((GaimContact*)((GaimBlistNode*)buddy)->parent)->online == 1) ((GaimGroup *)((GaimBlistNode *)buddy)->parent->parent)->online++; } - } else if (GAIM_BUDDY_IS_ONLINE(buddy) && !online) { + if (buddy->timer > 0) + gaim_timeout_remove(buddy->timer); + buddy->timer = gaim_timeout_add(10000, (GSourceFunc)presence_update_timeout_cb, buddy); + did_something = TRUE; + + } else if (!gaim_status_is_online(status) && + gaim_status_is_online(old_status)) { buddy->present = GAIM_BUDDY_SIGNING_OFF; gaim_signal_emit(gaim_blist_get_handle(), "buddy-signed-off", buddy); + if (buddy->timer > 0) + gaim_timeout_remove(buddy->timer); + buddy->timer = gaim_timeout_add(10000, (GSourceFunc)presence_update_timeout_cb, buddy); did_something = TRUE; + + } else if (gaim_status_is_available(status) && + !gaim_status_is_available(old_status)) { + gaim_signal_emit(gaim_blist_get_handle(), "buddy-back", buddy); + did_something = TRUE; + + } else if (!gaim_status_is_available(status) && + gaim_status_is_available(old_status)) { + gaim_signal_emit(gaim_blist_get_handle(), "buddy-away", buddy); + did_something = TRUE; + } if (did_something) { - if (buddy->timer > 0) - gaim_timeout_remove(buddy->timer); - buddy->timer = gaim_timeout_add(10000, (GSourceFunc)presence_update_timeout_cb, buddy); - gaim_contact_compute_priority_buddy(gaim_buddy_get_contact(buddy)); if (ops && ops->update) ops->update(gaimbuddylist, (GaimBlistNode *)buddy); @@ -607,6 +604,8 @@ buddy->alias = g_strdup(alias); buddy->presence = gaim_presence_new_for_buddy(buddy); + gaim_presence_set_status_active(buddy->presence, "offline", TRUE); + gaim_blist_node_initialize_settings((GaimBlistNode *)buddy); ((GaimBlistNode *)buddy)->type = GAIM_BLIST_BUDDY_NODE;
--- a/src/blist.h Sun Sep 19 21:14:28 2004 +0000 +++ b/src/blist.h Sun Sep 19 21:19:55 2004 +0000 @@ -251,21 +251,10 @@ /** * Updates a buddy's status. * - * This needs to not take an int. - * - * @param buddy The buddy whose status has changed - * @param status The new status in cryptic prpl-understood code + * @param buddy The buddy whose status has changed. + * @param old_status The status from which we are changing. */ -void gaim_blist_update_buddy_status(GaimBuddy *buddy, int status); - - -/** - * Updates a buddy's presence. - * - * @param buddy The buddy whose presence has changed - * @param online If the buddy is now online - */ -void gaim_blist_update_buddy_presence(GaimBuddy *buddy, gboolean online); +void gaim_blist_update_buddy_status(GaimBuddy *buddy, GaimStatus *old_status); /** * Updates a buddy's signon time.
--- a/src/cmds.h Sun Sep 19 21:14:28 2004 +0000 +++ b/src/cmds.h Sun Sep 19 21:19:55 2004 +0000 @@ -120,7 +120,7 @@ * before the command name. * @param data User defined data to pass to the GaimCmdFunc * @return A GaimCmdId. This is only used for calling gaim_cmd_unregister. - * Returns @c NULL on failure. + * Returns 0 on failure. */ GaimCmdId gaim_cmd_register(const gchar *cmd, const gchar *args, GaimCmdPriority p, GaimCmdFlag f, const gchar *prpl_id, GaimCmdFunc func, const gchar *helpstr, void *data);
--- a/src/connection.c Sun Sep 19 21:14:28 2004 +0000 +++ b/src/connection.c Sun Sep 19 21:19:55 2004 +0000 @@ -213,6 +213,7 @@ { GaimAccount *account; GList *wins; + GaimPresence *presence = NULL; g_return_if_fail(gc != NULL); @@ -242,6 +243,9 @@ OPT_LOG_BUDDY_SIGNON | OPT_LOG_MY_SIGNON); */ gaim_signal_emit(gaim_connections_get_handle(), "signed-off", gc); + presence = gaim_account_get_presence(account); + if (gaim_presence_is_online(presence) == TRUE) + gaim_presence_set_status_active(presence, "offline", TRUE); /* * XXX This is a hack! Remove this and replace it with a better event @@ -313,7 +317,11 @@ GaimBlistNode *gnode,*cnode,*bnode; GList *wins; GList *add_buds = NULL; - GaimAccount *account = gaim_connection_get_account(gc); + GaimAccount *account; + GaimPresence *presence; + + account = gaim_connection_get_account(gc); + presence = gaim_account_get_presence(account); /* Set the time the account came online */ time(&gc->login_time); @@ -349,20 +357,9 @@ gaim_signal_emit(gaim_connections_get_handle(), "signed-on", gc); -#if 0 - /* away option given? */ - if (opt_away) { - away_on_login(opt_away_arg); - /* don't do it again */ - opt_away = 0; - } else if (awaymessage) { - serv_set_away(gc, GAIM_AWAY_CUSTOM, awaymessage->message); - } - if (opt_away_arg != NULL) { - g_free(opt_away_arg); - opt_away_arg = NULL; - } -#endif + /* XXX - STATUS - Need to handle away at login here. */ + if (gaim_presence_is_online(presence) == FALSE) + gaim_presence_set_status_active(presence, "online", TRUE); /* let the prpl know what buddies we pulled out of the local list */ for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) {
--- a/src/prpl.c Sun Sep 19 21:14:28 2004 +0000 +++ b/src/prpl.c Sun Sep 19 21:19:55 2004 +0000 @@ -270,13 +270,15 @@ GaimBuddy *buddy; GaimPresence *presence; GaimStatus *status; + GaimStatus *old_status; g_return_if_fail(account != NULL); g_return_if_fail(name != NULL); g_return_if_fail(status_id != NULL); g_return_if_fail(gaim_account_is_connected(account)); - if ((buddy = gaim_find_buddy(account, name)) == NULL) + buddy = gaim_find_buddy(account, name); + if (buddy == NULL) return; presence = gaim_buddy_get_presence(buddy); @@ -300,10 +302,9 @@ va_end(args); } + old_status = gaim_presence_get_active_status(presence); gaim_presence_set_status_active(presence, status_id, TRUE); - - gaim_blist_update_buddy_presence(buddy, GAIM_BUDDY_IS_ONLINE(buddy)); - gaim_contact_compute_priority_buddy(gaim_buddy_get_contact(buddy)); + gaim_blist_update_buddy_status(buddy, old_status); } void
--- a/src/server.c Sun Sep 19 21:14:28 2004 +0000 +++ b/src/server.c Sun Sep 19 21:19:55 2004 +0000 @@ -941,12 +941,9 @@ * is set */ auto_reply_pref = gaim_prefs_get_string("/core/away/auto_reply"); - status = gaim_presence_get_active_status(presence); - away_msg = gaim_value_get_string( - gaim_status_get_attr_value(status, "message")); - + if (!(gc->flags & GAIM_CONNECTION_AUTO_RESP) || - away_msg == NULL || *away_msg == '\0' || + gaim_presence_is_available(presence) || !strcmp(auto_reply_pref, "never") || (!gaim_presence_is_idle(presence) && !strcmp(auto_reply_pref, "awayidle"))) { @@ -973,6 +970,13 @@ } lar->sent = t; + status = gaim_presence_get_active_status(presence); + if (status == NULL) + return; + + away_msg = gaim_value_get_string( + gaim_status_get_attr_value(status, "message")); + /* apply default fonts and colors */ tmpmsg = stylize(away_msg, MSG_LEN);
--- a/src/status.c Sun Sep 19 21:14:28 2004 +0000 +++ b/src/status.c Sun Sep 19 21:19:55 2004 +0000 @@ -621,7 +621,7 @@ if (!active && !gaim_status_type_is_independent(status_type)) { - gaim_debug(GAIM_DEBUG_ERROR, "status", + gaim_debug_error("status", "Cannot deactivate an exclusive status (%s).\n", gaim_status_type_get_id(status_type)); return; @@ -1099,13 +1099,13 @@ return; } - if (presence->active_status != NULL) - gaim_status_set_active(presence->active_status, FALSE); + } else if (presence->active_status != NULL) { + gaim_status_set_active(presence->active_status, FALSE); - presence->active_status = status; } gaim_status_set_active(status, active); + presence->active_status = status; } void