cpw.ivan: 28df58e3: A follow-up commit to e4e0a8019c2a8da23c...
ivan.komarov at soc.pidgin.im
ivan.komarov at soc.pidgin.im
Fri Sep 24 11:26:59 EDT 2010
----------------------------------------------------------------------
Revision: 28df58e33e7d8d23e766f0e95629ecfb374776b2
Parent: e4e0a8019c2a8da23c47db0095c8485f18ba6caa
Author: ivan.komarov at soc.pidgin.im
Date: 09/24/10 11:22:40
Branch: im.pidgin.cpw.ivan
URL: http://d.pidgin.im/viewmtn/revision/info/28df58e33e7d8d23e766f0e95629ecfb374776b2
Changelog:
A follow-up commit to e4e0a8019c2a8da23c47db0095c8485f18ba6caa.
I misunderstood how purple_prpl_got_user_status() worked and screwed things
up a little. We should call it EVERY time we get a new status, like the
original code did.
Also, there was an error in the original code which I fixed. info->status
or info->itmsurl being NULL doesn't imply we should unset these attributes.
It means the values for these attributes simply weren't in the packet
and we should keep them from the previous status.
Changes against parent e4e0a8019c2a8da23c47db0095c8485f18ba6caa
patched libpurple/protocols/oscar/oscar.c
-------------- next part --------------
============================================================
--- libpurple/protocols/oscar/oscar.c 1a9dec6716433c8ab250bc0a0223d874916538a1
+++ libpurple/protocols/oscar/oscar.c 7f3f9725ad923ea66d341217a0ef4a7de1b15432
@@ -1292,6 +1292,8 @@ static int purple_parse_oncoming(OscarDa
{
PurpleConnection *gc;
PurpleAccount *account;
+ PurpleBuddy *buddy = NULL;
+ PurpleStatus *previous_status = NULL;
struct buddyinfo *bi;
time_t time_idle = 0, signon = 0;
int type = 0;
@@ -1312,6 +1314,11 @@ static int purple_parse_oncoming(OscarDa
g_return_val_if_fail(info != NULL, 1);
g_return_val_if_fail(info->bn != NULL, 1);
+ buddy = purple_find_buddy(account, info->bn);
+ if (buddy) {
+ previous_status = purple_presence_get_active_status(purple_buddy_get_presence(buddy));
+ }
+
/*
* If this is an AIM buddy and their name has formatting, set their
* server alias.
@@ -1381,14 +1388,26 @@ static int purple_parse_oncoming(OscarDa
purple_prpl_got_user_status_deactive(account, info->bn, OSCAR_STATUS_ID_MOBILE);
}
+ /* Empty status means we should unset the status message. NULL status means we should keep it from the previous active status.
+ * Same goes for itmsurl (which is available only for the "available" status).
+ */
if (info->status != NULL) {
- message = oscar_encoding_to_utf8(info->status_encoding, info->status, info->status_len);
- purple_prpl_got_user_status(account, info->bn, status_id, "message", message, NULL);
+ message = (info->status_len > 0) ? oscar_encoding_to_utf8(info->status_encoding, info->status, info->status_len) : NULL;
+ } else if (previous_status != NULL) {
+ message = g_strdup(purple_status_get_attr_string(previous_status, "message"));
}
- if (info->itmsurl != NULL) {
- itmsurl = oscar_encoding_to_utf8(info->itmsurl_encoding, info->itmsurl, info->itmsurl_len);
- purple_prpl_got_user_status(account, info->bn, status_id, "itmsurl", itmsurl, NULL);
+ if (strcmp(status_id, OSCAR_STATUS_ID_AVAILABLE) == 0) {
+ if (info->itmsurl != NULL) {
+ itmsurl = (info->itmsurl_len > 0) ? oscar_encoding_to_utf8(info->itmsurl_encoding, info->itmsurl, info->itmsurl_len) : NULL;
+ } else if (previous_status != NULL) {
+ itmsurl = g_strdup(purple_status_get_attr_string(previous_status, "itmsurl"));
+ }
+ purple_debug_info("oscar", "Activating status '%s' for buddy %s, message = '%s'\n", status_id, info->bn, message);
+ purple_prpl_got_user_status(account, info->bn, status_id, "message", message, "itmsurl", itmsurl, NULL);
+ } else {
+ purple_debug_info("oscar", "Activating status '%s' for buddy %s, message = '%s', itmsurl = '%s'\n", status_id, info->bn, message, itmsurl);
+ purple_prpl_got_user_status(account, info->bn, status_id, "message", message, NULL);
}
g_free(message);
More information about the Commits
mailing list