summaryrefslogtreecommitdiff
path: root/libpurple/protocols/oscar/userinfo.c
diff options
context:
space:
mode:
Diffstat (limited to 'libpurple/protocols/oscar/userinfo.c')
-rw-r--r--libpurple/protocols/oscar/userinfo.c69
1 files changed, 31 insertions, 38 deletions
diff --git a/libpurple/protocols/oscar/userinfo.c b/libpurple/protocols/oscar/userinfo.c
index 5762977ad6..58653e6eb9 100644
--- a/libpurple/protocols/oscar/userinfo.c
+++ b/libpurple/protocols/oscar/userinfo.c
@@ -173,17 +173,17 @@ oscar_user_info_convert_and_add_hyperlink(PurpleAccount *account, OscarData *od,
* @param user_info A PurpleNotifyUserInfo object to which status information will be added
* @param b The PurpleBuddy whose status is desired. This or the aim_userinfo_t (or both) must be passed to oscar_user_info_append_status().
* @param userinfo The aim_userinfo_t of the buddy whose status is desired. This or the PurpleBuddy (or both) must be passed to oscar_user_info_append_status().
- * @param strip_html_tags If strip_html_tags is TRUE, tags embedded in the status message will be stripped, returning a non-formatted string. The string will still be HTML escaped.
+ * @param use_html_status If TRUE, prefer HTML-formatted away message over plaintext available message.
*/
void
-oscar_user_info_append_status(PurpleConnection *gc, PurpleNotifyUserInfo *user_info, PurpleBuddy *b, aim_userinfo_t *userinfo, gboolean strip_html_tags)
+oscar_user_info_append_status(PurpleConnection *gc, PurpleNotifyUserInfo *user_info, PurpleBuddy *b, aim_userinfo_t *userinfo, gboolean use_html_status)
{
PurpleAccount *account = purple_connection_get_account(gc);
OscarData *od;
PurplePresence *presence = NULL;
PurpleStatus *status = NULL;
gchar *message = NULL, *itmsurl = NULL, *tmp;
- gboolean is_away;
+ gboolean escaping_needed = TRUE;
od = purple_connection_get_protocol_data(gc);
@@ -205,9 +205,10 @@ oscar_user_info_append_status(PurpleConnection *gc, PurpleNotifyUserInfo *user_i
the "message" attribute of the status contains only the plaintext
message. */
if (userinfo) {
- if ((userinfo->flags & AIM_FLAG_AWAY) && userinfo->away_len > 0 && userinfo->away != NULL && userinfo->away_encoding != NULL) {
+ if ((userinfo->flags & AIM_FLAG_AWAY) && use_html_status && userinfo->away_len > 0 && userinfo->away != NULL && userinfo->away_encoding != NULL) {
/* Away message */
message = oscar_encoding_to_utf8(userinfo->away_encoding, userinfo->away, userinfo->away_len);
+ escaping_needed = FALSE;
} else {
/*
* Available message or non-HTML away message (because that's
@@ -227,44 +228,26 @@ oscar_user_info_append_status(PurpleConnection *gc, PurpleNotifyUserInfo *user_i
itmsurl = g_strdup(purple_status_get_attr_string(status, "itmsurl"));
}
- is_away = ((status && !purple_status_is_available(status)) ||
- (userinfo && (userinfo->flags & AIM_FLAG_AWAY)));
-
- if (strip_html_tags) {
- /* Away messages are HTML, but available messages were originally plain text.
- * We therefore need to strip away messages but not available messages if we're asked to remove HTML tags.
- */
- /*
- * It seems like the above comment no longer applies. All messages need
- * to be escaped.
- */
- if (message) {
- gchar *tmp2;
- tmp = purple_markup_strip_html(message);
- g_free(message);
- tmp2 = g_markup_escape_text(tmp, -1);
- g_free(tmp);
- message = tmp2;
- }
-
- } else {
- if (itmsurl) {
- tmp = g_strdup_printf("<a href=\"%s\">%s</a>",
- itmsurl, message);
+ if (message) {
+ tmp = oscar_util_format_string(message, purple_account_get_username(account));
+ g_free(message);
+ message = tmp;
+ if (escaping_needed) {
+ tmp = purple_markup_escape_text(message, -1);
g_free(message);
message = tmp;
}
}
- g_free(itmsurl);
- if (message) {
- tmp = oscar_util_format_string(message, purple_account_get_username(account));
+ if (use_html_status && itmsurl) {
+ tmp = g_strdup_printf("<a href=\"%s\">%s</a>", itmsurl, message);
g_free(message);
message = tmp;
}
if (b) {
if (purple_presence_is_online(presence)) {
+ gboolean is_away = ((status && !purple_status_is_available(status)) || (userinfo && (userinfo->flags & AIM_FLAG_AWAY)));
if (oscar_util_valid_name_icq(purple_buddy_get_name(b)) || is_away || !message || !(*message)) {
/* Append the status name for online ICQ statuses, away AIM statuses, and for all buddies with no message.
* If the status name and the message are the same, only show one. */
@@ -299,12 +282,22 @@ oscar_user_info_append_status(PurpleConnection *gc, PurpleNotifyUserInfo *user_i
if (presence) {
const char *mood;
- const char *description;
+ const char *comment;
+ char *description;
status = purple_presence_get_status(presence, "mood");
- mood = purple_status_get_attr_string(status, PURPLE_MOOD_NAME);
- description = icq_get_custom_icon_description(mood);
- if (description && *description)
- purple_notify_user_info_add_pair(user_info, _("Mood"), _(description));
+ mood = icq_get_custom_icon_description(purple_status_get_attr_string(status, PURPLE_MOOD_NAME));
+ if (mood) {
+ comment = purple_status_get_attr_string(status, PURPLE_MOOD_COMMENT);
+ if (comment) {
+ char *escaped_comment = purple_markup_escape_text(comment, -1);
+ description = g_strdup_printf("%s (%s)", _(mood), escaped_comment);
+ g_free(escaped_comment);
+ } else {
+ description = g_strdup(_(mood));
+ }
+ purple_notify_user_info_add_pair(user_info, _("Mood"), description);
+ g_free(description);
+ }
}
purple_notify_user_info_add_pair(user_info, _("Status"), message);
@@ -458,7 +451,7 @@ oscar_user_info_display_icq(OscarData *od, struct aim_icq_info *info)
}
oscar_user_info_convert_and_add_hyperlink(account, od, user_info, _("Personal Web Page"), info->email, "");
if (buddy != NULL)
- oscar_user_info_append_status(gc, user_info, buddy, /* aim_userinfo_t */ NULL, /* strip_html_tags */ FALSE);
+ oscar_user_info_append_status(gc, user_info, buddy, /* aim_userinfo_t */ NULL, /* use_html_status */ TRUE);
oscar_user_info_convert_and_add(account, od, user_info, _("Additional Information"), info->info);
purple_notify_user_info_add_section_break(user_info);
@@ -504,7 +497,7 @@ oscar_user_info_display_aim(OscarData *od, aim_userinfo_t *userinfo)
PurpleNotifyUserInfo *user_info = purple_notify_user_info_new();
gchar *tmp = NULL, *info_utf8 = NULL, *base_profile_url = NULL;
- oscar_user_info_append_status(gc, user_info, /* PurpleBuddy */ NULL, userinfo, /* strip_html_tags */ FALSE);
+ oscar_user_info_append_status(gc, user_info, /* PurpleBuddy */ NULL, userinfo, /* use_html_status */ TRUE);
if ((userinfo->present & AIM_USERINFO_PRESENT_IDLE) && userinfo->idletime != 0) {
tmp = purple_str_seconds_to_string(userinfo->idletime*60);