Mercurial > pidgin.yaz
changeset 25464:0e93bbb7f5ca
Woo boy this function is a little crazy. I shuffled some things around:
1. We now call aim_srv_setextrainfo() after aim_locate_setprofile() This
fixes the bug where, if you set an available message, then set an
away message, then change your state to available but leave the same
away message up, the AIM servers would use your old available message.
I'm not really sure why it happens... maybe some sort of race condition
in how the server parses our requests. In any case, this fixes it, and
it's what the official clients seem to do (or AIM Lite at least)
2. Combine the code for stripping HTML and truncating the available
message. It was happening in two places before (one for available
messages and another for ICQ away messages)
3. Put our away message in the field we've been calling an "available"
message. This seems to be what the official clients do. Or AIM Lite
at least. I'm not sure if there will be other side effects.
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 05 Mar 2009 23:54:50 +0000 |
parents | cef8479194c0 |
children | 9ea3474065dc 7e020fbe2cdb 439f07ce4c8a 7ace7bf0bfad c4fd9222dda1 |
files | libpurple/protocols/oscar/oscar.c |
diffstat | 1 files changed, 52 insertions(+), 65 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/oscar/oscar.c Thu Mar 05 23:33:22 2009 +0000 +++ b/libpurple/protocols/oscar/oscar.c Thu Mar 05 23:54:50 2009 +0000 @@ -4738,16 +4738,17 @@ PurpleStatusType *status_type; PurpleStatusPrimitive primitive; - char *htmlinfo; char *info_encoding = NULL; char *info = NULL; gsize infolen = 0; - const char *htmlaway; char *away_encoding = NULL; char *away = NULL; gsize awaylen = 0; + char *status_text = NULL; + const char *itmsurl = NULL; + status_type = purple_status_get_type(status); primitive = purple_status_type_get_primitive(status_type); @@ -4765,7 +4766,7 @@ } else if (rawinfo != NULL) { - htmlinfo = purple_strdup_withhtml(rawinfo); + char *htmlinfo = purple_strdup_withhtml(rawinfo); info = purple_prpl_oscar_convert_to_infotext(htmlinfo, &infolen, &info_encoding); g_free(htmlinfo); @@ -4782,16 +4783,54 @@ } } - if (!setstatus) + if (setstatus) { - /* Do nothing! */ - } - else if (primitive == PURPLE_STATUS_AVAILABLE || primitive == PURPLE_STATUS_INVISIBLE) - { - const char *status_html, *itmsurl; - char *status_text = NULL; + const char *status_html; status_html = purple_status_get_attr_string(status, "message"); + + if (primitive == PURPLE_STATUS_AVAILABLE || primitive == PURPLE_STATUS_INVISIBLE) + { + /* This is needed for us to un-set any previous away message. */ + away = g_strdup(""); + } + else + { + gchar *linkified; + + /* We do this for icq too so that they work for old third party clients */ + linkified = purple_markup_linkify(status_html); + away = purple_prpl_oscar_convert_to_infotext(linkified, &awaylen, &away_encoding); + g_free(linkified); + + if (awaylen > od->rights.maxawaymsglen) + { + gchar *errstr; + + errstr = g_strdup_printf(dngettext(PACKAGE, "The maximum away message length of %d byte " + "has been exceeded. It has been truncated for you.", + "The maximum away message length of %d bytes " + "has been exceeded. It has been truncated for you.", + od->rights.maxawaymsglen), od->rights.maxawaymsglen); + purple_notify_warning(gc, NULL, _("Away message too long."), errstr); + g_free(errstr); + } + } + } + + aim_locate_setprofile(od, + info_encoding, info, MIN(infolen, od->rights.maxsiglen), + away_encoding, away, MIN(awaylen, od->rights.maxawaymsglen)); + g_free(info); + g_free(away); + + if (setstatus) + { + const char *status_html; + + status_html = purple_status_get_attr_string(status, "message"); + if (od->icq && (status_html == NULL || status_html[0] == '\0')) + status_html = purple_status_type_get_name(status_type); if (status_html != NULL) { status_text = purple_markup_strip_html(status_html); @@ -4802,65 +4841,13 @@ strcpy(tmp, "..."); } } + itmsurl = purple_status_get_attr_string(status, "itmsurl"); + /* TODO: Combine these two calls! */ aim_srv_setextrainfo(od, FALSE, 0, TRUE, status_text, itmsurl); - g_free(status_text); - - /* This is needed for us to un-set any previous away message. */ - away = g_strdup(""); - } - else - { - gchar *linkified; - - htmlaway = purple_status_get_attr_string(status, "message"); - if ((htmlaway == NULL) || (*htmlaway == '\0')) - htmlaway = purple_status_type_get_name(status_type); - - /* ICQ 6.x seems to use an available message for all statuses so set one */ - if (od->icq) - { - char *status_text; - - status_text = purple_markup_strip_html(htmlaway); - - /* If the status_text is longer than 251 characters then truncate it */ - if (strlen(status_text) > MAXAVAILMSGLEN) - { - char *tmp = g_utf8_find_prev_char(status_text, &status_text[MAXAVAILMSGLEN - 2]); - strcpy(tmp, "..."); - } - aim_srv_setextrainfo(od, FALSE, 0, TRUE, status_text, NULL); - g_free(status_text); - } - - /* Set a proper away message for icq too so that they work for old third party clients */ - linkified = purple_markup_linkify(htmlaway); - away = purple_prpl_oscar_convert_to_infotext(linkified, &awaylen, &away_encoding); - g_free(linkified); - - if (awaylen > od->rights.maxawaymsglen) - { - gchar *errstr; - - errstr = g_strdup_printf(dngettext(PACKAGE, "The maximum away message length of %d byte " - "has been exceeded. It has been truncated for you.", - "The maximum away message length of %d bytes " - "has been exceeded. It has been truncated for you.", - od->rights.maxawaymsglen), od->rights.maxawaymsglen); - purple_notify_warning(gc, NULL, _("Away message too long."), errstr); - g_free(errstr); - } - } - - if (setstatus) oscar_set_extendedstatus(gc); - - aim_locate_setprofile(od, info_encoding, info, MIN(infolen, od->rights.maxsiglen), - away_encoding, away, MIN(awaylen, od->rights.maxawaymsglen)); - g_free(info); - g_free(away); + } } static void