Mercurial > pidgin
changeset 21061:1d92b85ef5d9
gg: Properly display your status in the buddylist.
author | Bartoz Oler <bartosz@pidgin.im> |
---|---|
date | Sun, 04 Nov 2007 22:17:45 +0000 |
parents | 647b841ea945 |
children | 7be910c7cff7 |
files | libpurple/protocols/gg/gg-utils.c libpurple/protocols/gg/gg-utils.h libpurple/protocols/gg/gg.c |
diffstat | 3 files changed, 50 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/gg/gg-utils.c Fri Nov 02 06:59:04 2007 +0000 +++ b/libpurple/protocols/gg/gg-utils.c Sun Nov 04 22:17:45 2007 +0000 @@ -112,5 +112,36 @@ } /* }}} */ +void ggp_status_fake_to_self(PurpleAccount *account) +{ + PurplePresence *presence; + PurpleStatus *status; + const char *status_id; + const char *msg; + + if (! purple_find_buddy(account, purple_account_get_username(account))) + return; + + presence = purple_account_get_presence(account); + status = purple_presence_get_active_status(presence); + msg = purple_status_get_attr_string(status, "message"); + if (msg && !*msg) + msg = NULL; + + status_id = purple_status_get_id(status); + if (strcmp(status_id, "invisible") == 0) { + status_id = "offline"; + } + + if (msg) { + if (strlen(msg) > GG_STATUS_DESCR_MAXSIZE) { + msg = purple_markup_slice(msg, 0, GG_STATUS_DESCR_MAXSIZE); + } + } + purple_prpl_got_user_status(account, purple_account_get_username(account), + status_id, + msg ? "message" : NULL, msg, NULL); +} + /* vim: set ts=8 sts=0 sw=8 noet: */
--- a/libpurple/protocols/gg/gg-utils.h Fri Nov 02 06:59:04 2007 +0000 +++ b/libpurple/protocols/gg/gg-utils.h Sun Nov 04 22:17:45 2007 +0000 @@ -92,6 +92,15 @@ char * ggp_buddy_get_name(PurpleConnection *gc, const uin_t uin); +/** + * Manages the display of account's status in the buddylist. + * + * @param account Current account. + */ +void +ggp_status_fake_to_self(PurpleAccount *account); + + #endif /* _PURPLE_GG_UTILS_H */ /* vim: set ts=8 sts=0 sw=8 noet: */
--- a/libpurple/protocols/gg/gg.c Fri Nov 02 06:59:04 2007 +0000 +++ b/libpurple/protocols/gg/gg.c Sun Nov 04 22:17:45 2007 +0000 @@ -828,6 +828,7 @@ { GGPInfo *info = gc->proto_data; PurpleRequestField *field; + /* TODO: sel may be null. */ GList *sel; field = purple_request_fields_get_field(fields, "name"); @@ -1868,15 +1869,24 @@ gg_change_status_descr(info->session, new_status_descr, new_msg); g_free(new_msg); } + + ggp_status_fake_to_self(account); + } /* }}} */ /* static void ggp_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) {{{ */ static void ggp_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) { + PurpleAccount *account; GGPInfo *info = gc->proto_data; gg_add_notify(info->session, ggp_str_to_uin(buddy->name)); + + account = purple_connection_get_account(gc); + if (strcmp(purple_account_get_username(account), buddy->name) == 0) { + ggp_status_fake_to_self(account); + } } /* }}} */