Mercurial > pidgin.yaz
changeset 15524:84b3ab83df35
Use the status API to handle mobileness, and convert AIM to use it. This makes mobile buddies prioritze lower in Perons, and ensures the UI is notified of changes in mobileness. Other protocols to follow.
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Sun, 04 Feb 2007 02:31:04 +0000 |
parents | ccbdf500f13a |
children | 2193394fd427 cb0750152bf6 |
files | libpurple/protocols/oscar/oscar.c libpurple/prpl.c libpurple/prpl.h libpurple/status.c pidgin/gtkblist.c |
diffstat | 5 files changed, 75 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/oscar/oscar.c Sat Feb 03 23:32:43 2007 +0000 +++ b/libpurple/protocols/oscar/oscar.c Sun Feb 04 02:31:04 2007 +0000 @@ -58,6 +58,7 @@ #define OSCAR_STATUS_ID_OCCUPIED "occupied" #define OSCAR_STATUS_ID_FREE4CHAT "free4chat" #define OSCAR_STATUS_ID_CUSTOM "custom" +#define OSCAR_STATUS_ID_MOBILE "mobile" #define AIMHASHDATA "http://gaim.sourceforge.net/aim_data.php3" @@ -1767,6 +1768,13 @@ info->status, info->status_len); } + if (info->flags & AIM_FLAG_WIRELESS || info->capabilities & OSCAR_CAPABILITY_HIPTOP) + { + gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_MOBILE, NULL); + } else { + gaim_prpl_got_user_status_deactive(account, info->sn, OSCAR_STATUS_ID_MOBILE); + } + if (have_status_message) { gaim_prpl_got_user_status(account, info->sn, status_id, @@ -1881,7 +1889,7 @@ va_end(ap); gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_OFFLINE, NULL); - + gaim_prpl_got_user_status_deactive(account, info->sn, OSCAR_STATUS_ID_MOBILE); g_hash_table_remove(od->buddyinfo, gaim_normalize(gc->account, info->sn)); return 1; @@ -5431,10 +5439,6 @@ if (userinfo != NULL ) { if (userinfo->flags & AIM_FLAG_ADMINISTRATOR) return "admin"; - if (userinfo->flags & AIM_FLAG_WIRELESS) - return "mobile"; - if (userinfo->capabilities & OSCAR_CAPABILITY_HIPTOP) - return "mobile"; if (userinfo->flags & AIM_FLAG_ACTIVEBUDDY) return "bot"; if (userinfo->flags & AIM_FLAG_AOL) @@ -5718,6 +5722,9 @@ NULL, TRUE, TRUE, FALSE); status_types = g_list_prepend(status_types, type); + type = gaim_status_type_new_full(GAIM_STATUS_MOBILE, OSCAR_STATUS_ID_MOBILE, NULL, FALSE, FALSE, TRUE); + status_types = g_list_prepend(status_types, type); + /* ICQ-specific status types */ type = gaim_status_type_new_with_attrs(GAIM_STATUS_UNAVAILABLE, OSCAR_STATUS_ID_OCCUPIED,
--- a/libpurple/prpl.c Sat Feb 03 23:32:43 2007 +0000 +++ b/libpurple/prpl.c Sun Feb 04 02:31:04 2007 +0000 @@ -162,6 +162,31 @@ serv_got_typing_stopped(gaim_account_get_connection(account), name); } +void gaim_prpl_got_user_status_deactive(GaimAccount *account, const char *name, + const char *status_id) +{ + GSList *list; + GaimBuddy *buddy; + GaimPresence *presence; + GaimStatus *status; + GaimStatus *old_status; + va_list args; + + 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) || gaim_account_is_connecting(account)); + + if ((buddy = gaim_find_buddy(account, name)) == NULL) + return; + + presence = gaim_buddy_get_presence(buddy); + status = gaim_presence_get_status(presence, status_id); + + g_return_if_fail(status != NULL); + gaim_status_set_active(status, FALSE); +} + static void do_prpl_change_account_status(GaimAccount *account, GaimStatus *old_status, GaimStatus *new_status)
--- a/libpurple/prpl.h Sat Feb 03 23:32:43 2007 +0000 +++ b/libpurple/prpl.h Sun Feb 04 02:31:04 2007 +0000 @@ -388,7 +388,7 @@ time_t login_time); /** - * Notifies Gaim that a user's status has changed. + * Notifies Gaim that a user's status has been activated. * * This is meant to be called from protocol plugins. * @@ -400,6 +400,19 @@ */ void gaim_prpl_got_user_status(GaimAccount *account, const char *name, const char *status_id, ...); + +/** + * Notifies libpurple that a user's status has been deactivated + * + * This is meant to be called from protocol plugins. + * + * @param account The account the user is on. + * @param name The screen name of the user. + * @param status_id The status ID. + */ +void gaim_prpl_got_user_status_deactive(GaimAccount *account, const char *name, + const char *status_id); + /** * Informs the server that an account's status changed. *
--- a/libpurple/status.c Sat Feb 03 23:32:43 2007 +0000 +++ b/libpurple/status.c Sun Feb 04 02:31:04 2007 +0000 @@ -1549,18 +1549,20 @@ gaim_presence_is_status_primitive_active(const GaimPresence *presence, GaimStatusPrimitive primitive) { - GaimStatus *status; - GaimStatusType *status_type; + GList *l; g_return_val_if_fail(presence != NULL, FALSE); g_return_val_if_fail(primitive != GAIM_STATUS_UNSET, FALSE); - status = gaim_presence_get_active_status(presence); - status_type = gaim_status_get_type(status); + for (l = gaim_presence_get_statuses(presence); + l != NULL; l = l->next) { + GaimStatus *temp_status = l->data; + GaimStatusType *type = gaim_status_get_type(temp_status); - if (gaim_status_type_get_primitive(status_type) == primitive) - return TRUE; - + if (gaim_status_type_get_primitive(type) == primitive && + gaim_status_is_active(temp_status)) + return TRUE; + } return FALSE; }
--- a/pidgin/gtkblist.c Sat Feb 03 23:32:43 2007 +0000 +++ b/pidgin/gtkblist.c Sun Feb 04 02:31:04 2007 +0000 @@ -2977,6 +2977,10 @@ const char *name = NULL; char *filename, *path; GdkPixbuf *ret; + GaimPresence *p; + + + if(GAIM_BLIST_NODE_IS_CONTACT(node)) { if(!gtknode->contact_expanded) { buddy = gaim_contact_get_priority_buddy((GaimContact*)node); @@ -2995,7 +2999,17 @@ if (!gaim_privacy_check(buddy->account, gaim_buddy_get_name(buddy))) { path = g_build_filename(DATADIR, "pixmaps", "pidgin", "emblems", "16", "blocked.png", NULL); - return gdk_pixbuf_new_from_file(path, NULL); + ret = gdk_pixbuf_new_from_file(path, NULL); + g_free(path); + return ret; + } + + p = gaim_buddy_get_presence(buddy); + if (gaim_presence_is_status_primitive_active(p, GAIM_STATUS_MOBILE)) { + path = g_build_filename(DATADIR, "pixmaps", "pidgin", "emblems", "16", "mobile.png", NULL); + ret = gdk_pixbuf_new_from_file(path, NULL); + g_free(path); + return ret; } prpl = gaim_find_prpl(gaim_account_get_protocol_id(buddy->account));