Mercurial > pidgin.yaz
changeset 27847:0b36e6eb2439
propagate from branch 'im.pidgin.pidgin' (head fa58d38b47ddd3adf4314e997ff052d610af4d09)
to branch 'im.pidgin.pidgin.yaz' (head 6cc097c351098e07ab4efcce0ffa5cb202f111d6)
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Tue, 03 Jun 2008 05:23:38 +0000 |
parents | 9f91d6e0983c (current diff) b87ce62751a2 (diff) |
children | d201287d3a0e |
files | libpurple/protocols/jabber/jabber.c libpurple/protocols/oscar/oscar.c |
diffstat | 6 files changed, 134 insertions(+), 75 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/plugins/ssl/ssl-gnutls.c Mon Jun 02 06:58:38 2008 +0000 +++ b/libpurple/plugins/ssl/ssl-gnutls.c Tue Jun 03 05:23:38 2008 +0000 @@ -54,8 +54,8 @@ If there are strange bugs, perhaps look here (yes, I am a hypocrite) */ gnutls_global_set_mem_functions( - (gnutls_alloc_function) g_malloc0, /* malloc */ - (gnutls_alloc_function) g_malloc0, /* secure malloc */ + (gnutls_alloc_function) g_malloc, /* malloc */ + (gnutls_alloc_function) g_malloc, /* secure malloc */ NULL, /* mem_is_secure */ (gnutls_realloc_function) g_realloc, /* realloc */ (gnutls_free_function) g_free /* free */
--- a/libpurple/privacy.c Mon Jun 02 06:58:38 2008 +0000 +++ b/libpurple/privacy.c Tue Jun 03 05:23:38 2008 +0000 @@ -241,6 +241,7 @@ gboolean restore) { GSList *list; + PurplePrivacyType type = account->perm_deny; switch (account->perm_deny) { case PURPLE_PRIVACY_ALLOW_ALL: @@ -254,10 +255,12 @@ case PURPLE_PRIVACY_DENY_ALL: if (!restore) { /* Empty the allow-list. */ + const char *norm = purple_normalize(account, who); for (list = account->permit; list != NULL;) { - char *who = list->data; + char *person = list->data; list = list->next; - purple_privacy_permit_remove(account, who, local); + if (strcmp(norm, person) != 0) + purple_privacy_permit_remove(account, person, local); } } purple_privacy_permit_add(account, who, local); @@ -273,6 +276,10 @@ default: g_return_if_reached(); } + + /* Notify the server if the privacy setting was changed */ + if (type != account->perm_deny && purple_account_is_connected(account)) + serv_set_permit_deny(purple_account_get_connection(account)); } /* @@ -286,15 +293,18 @@ gboolean restore) { GSList *list; + PurplePrivacyType type = account->perm_deny; switch (account->perm_deny) { case PURPLE_PRIVACY_ALLOW_ALL: if (!restore) { /* Empty the deny-list. */ + const char *norm = purple_normalize(account, who); for (list = account->deny; list != NULL; ) { char *person = list->data; list = list->next; - purple_privacy_deny_remove(account, person, local); + if (strcmp(norm, person) != 0) + purple_privacy_deny_remove(account, person, local); } } purple_privacy_deny_add(account, who, local); @@ -318,6 +328,10 @@ default: g_return_if_reached(); } + + /* Notify the server if the privacy setting was changed */ + if (type != account->perm_deny && purple_account_is_connected(account)) + serv_set_permit_deny(purple_account_get_connection(account)); } gboolean
--- a/libpurple/protocols/jabber/jabber.c Mon Jun 02 06:58:38 2008 +0000 +++ b/libpurple/protocols/jabber/jabber.c Tue Jun 03 05:23:38 2008 +0000 @@ -1506,8 +1506,7 @@ if (full) { PurpleStatus *status; - PurpleValue *value; - + if(jb->subscription & JABBER_SUB_FROM) { if(jb->subscription & JABBER_SUB_TO) sub = _("Both"); @@ -1523,17 +1522,17 @@ else sub = _("None"); } - + purple_notify_user_info_add_pair(user_info, _("Subscription"), sub); - + status = purple_presence_get_active_status(presence); - value = purple_status_get_attr_value(status, "mood"); - if (value && purple_value_get_type(value) == PURPLE_TYPE_STRING && (mood = purple_value_get_string(value))) { - - value = purple_status_get_attr_value(status, "moodtext"); - if(value && purple_value_get_type(value) == PURPLE_TYPE_STRING) { - char *moodplustext = g_strdup_printf("%s (%s)",mood,purple_value_get_string(value)); - + mood = purple_status_get_attr_string(status, "mood"); + if(mood != NULL) { + const char *moodtext; + moodtext = purple_status_get_attr_string(status, "moodtext"); + if(moodtext != NULL) { + char *moodplustext = g_strdup_printf("%s (%s)", mood, moodtext); + purple_notify_user_info_add_pair(user_info, _("Mood"), moodplustext); g_free(moodplustext); } else
--- a/libpurple/protocols/oscar/oscar.c Mon Jun 02 06:58:38 2008 +0000 +++ b/libpurple/protocols/oscar/oscar.c Tue Jun 03 05:23:38 2008 +0000 @@ -781,7 +781,7 @@ const char *name, const char *value) { gchar *utf8; - + if (value && value[0] && (utf8 = oscar_utf8_try_convert(account, value))) { purple_notify_user_info_add_pair(user_info, name, utf8); g_free(utf8); @@ -793,20 +793,32 @@ const char *name, const char *value) { gchar *utf8; - + if (value && value[0] && (utf8 = oscar_utf8_try_convert(account, value))) { purple_notify_user_info_add_pair(user_info, name, utf8); g_free(utf8); } } -static void oscar_user_info_append_status(PurpleConnection *gc, PurpleNotifyUserInfo *user_info, PurpleBuddy *b, aim_userinfo_t *userinfo) +/** + * @brief Append the status information to a user_info struct + * + * The returned information is HTML-ready, appropriately escaped, as all information in a user_info struct should be HTML. + * + * @param gc The PurpleConnection + * @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. + */ +static void oscar_user_info_append_status(PurpleConnection *gc, PurpleNotifyUserInfo *user_info, PurpleBuddy *b, aim_userinfo_t *userinfo, gboolean strip_html_tags) { PurpleAccount *account = purple_connection_get_account(gc); OscarData *od; PurplePresence *presence = NULL; PurpleStatus *status = NULL; gchar *message = NULL, *itmsurl = NULL, *tmp; + gboolean is_away; od = gc->proto_data; @@ -818,11 +830,11 @@ if (b == NULL) b = purple_find_buddy(purple_connection_get_account(gc), userinfo->sn); - + if (b) { presence = purple_buddy_get_presence(b); status = purple_presence_get_active_status(presence); - + message = g_strdup(purple_status_get_attr_string(status, "message")); itmsurl = g_strdup(purple_status_get_attr_string(status, "itmsurl")); @@ -831,25 +843,16 @@ if ((userinfo->flags & AIM_FLAG_AWAY)) { /* Away message? */ if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { - gchar *away_utf8; - tmp = oscar_encoding_extract(userinfo->away_encoding); - away_utf8 = oscar_encoding_to_utf8(account, tmp, userinfo->away, + message = oscar_encoding_to_utf8(account, tmp, userinfo->away, userinfo->away_len); g_free(tmp); - if (away_utf8 != NULL) { - message = purple_str_sub_away_formatters(away_utf8, purple_account_get_username(account)); - g_free(away_utf8); } - } } else { /* Available message? */ if ((userinfo->status != NULL) && userinfo->status[0] != '\0') { - tmp = oscar_encoding_to_utf8(account, userinfo->status_encoding, + message = oscar_encoding_to_utf8(account, userinfo->status_encoding, userinfo->status, userinfo->status_len); - /* Available messages are plain text */ - message = g_markup_escape_text(tmp, -1); - g_free(tmp); } #if defined (_WIN32) || defined (__APPLE__) if (userinfo->itmsurl && (userinfo->itmsurl[0] != '\0')) @@ -858,7 +861,24 @@ #endif } } - + + is_away = ((status && !purple_status_is_available(status)) || + (userinfo && (userinfo->flags & AIM_FLAG_AWAY))); + + if (strip_html_tags) { + /* Away messges 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. + */ + if (is_away) { + 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); @@ -866,6 +886,13 @@ g_free(message); message = tmp; } + } + + if (is_away) { + tmp = purple_str_sub_away_formatters(message, purple_account_get_username(account)); + g_free(message); + message = tmp; + } if (b) { if (purple_presence_is_online(presence)) { @@ -937,7 +964,7 @@ if (userinfo != NULL) bi = g_hash_table_lookup(od->buddyinfo, purple_normalize(account, userinfo->sn)); - + if ((bi != NULL) && (bi->ipaddr != 0)) { tmp = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", (bi->ipaddr & 0xff000000) >> 24, @@ -1948,6 +1975,7 @@ { char *message = NULL; char *itmsurl = NULL; + char *tmp; if (info->status != NULL && info->status[0] != '\0') /* Grab the available message */ @@ -1959,8 +1987,10 @@ itmsurl = oscar_encoding_to_utf8(account, info->itmsurl_encoding, info->itmsurl, info->itmsurl_len); + tmp = g_markup_escape_text(message, -1); purple_prpl_got_user_status(account, info->sn, status_id, - "message", message, "itmsurl", itmsurl, NULL); + "message", tmp, "itmsurl", itmsurl, NULL); + g_free(tmp); g_free(message); g_free(itmsurl); @@ -2760,7 +2790,7 @@ switch(reason) { case 0: /* Invalid (0) */ buf = g_strdup_printf( - dngettext(PACKAGE, + dngettext(PACKAGE, "You missed %hu message from %s because it was invalid.", "You missed %hu messages from %s because they were invalid.", nummissed), @@ -2769,7 +2799,7 @@ break; case 1: /* Message too large */ buf = g_strdup_printf( - dngettext(PACKAGE, + dngettext(PACKAGE, "You missed %hu message from %s because it was too large.", "You missed %hu messages from %s because they were too large.", nummissed), @@ -2778,7 +2808,7 @@ break; case 2: /* Rate exceeded */ buf = g_strdup_printf( - dngettext(PACKAGE, + dngettext(PACKAGE, "You missed %hu message from %s because the rate limit has been exceeded.", "You missed %hu messages from %s because the rate limit has been exceeded.", nummissed), @@ -2787,7 +2817,7 @@ break; case 3: /* Evil Sender */ buf = g_strdup_printf( - dngettext(PACKAGE, + dngettext(PACKAGE, "You missed %hu message from %s because he/she was too evil.", "You missed %hu messages from %s because he/she was too evil.", nummissed), @@ -2796,7 +2826,7 @@ break; case 4: /* Evil Receiver */ buf = g_strdup_printf( - dngettext(PACKAGE, + dngettext(PACKAGE, "You missed %hu message from %s because you are too evil.", "You missed %hu messages from %s because you are too evil.", nummissed), @@ -2805,7 +2835,7 @@ break; default: buf = g_strdup_printf( - dngettext(PACKAGE, + dngettext(PACKAGE, "You missed %hu message from %s for an unknown reason.", "You missed %hu messages from %s for an unknown reason.", nummissed), @@ -2861,9 +2891,9 @@ /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ statusmsg = oscar_icqstatus(state); splitmsg = g_strsplit(msg, "\r\n", 0); - + user_info = purple_notify_user_info_new(); - + purple_notify_user_info_add_pair(user_info, _("UIN"), who); purple_notify_user_info_add_pair(user_info, _("Status"), statusmsg); purple_notify_user_info_add_section_break(user_info); @@ -3054,7 +3084,7 @@ user_info = purple_notify_user_info_new(); - oscar_user_info_append_status(gc, user_info, NULL, userinfo); + oscar_user_info_append_status(gc, user_info, /* PurpleBuddy */ NULL, userinfo, /* strip_html_tags */ FALSE); if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { tmp = purple_str_seconds_to_string(userinfo->idletime*60); @@ -3069,12 +3099,12 @@ time_t t = userinfo->onlinesince; oscar_user_info_add_pair(user_info, _("Online Since"), purple_date_format_full(localtime(&t))); } - + if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) { time_t t = userinfo->membersince; oscar_user_info_add_pair(user_info, _("Member Since"), purple_date_format_full(localtime(&t))); } - + if (userinfo->capabilities != 0) { tmp = oscar_caps_to_string(userinfo->capabilities); oscar_user_info_add_pair(user_info, _("Capabilities"), tmp); @@ -3519,8 +3549,8 @@ if (code == AIM_RATE_CODE_LIMIT) { purple_debug_warning("oscar", _("The last action you attempted could not be " - "performed because you are over the rate limit. " - "Please wait 10 seconds and try again.")); + "performed because you are over the rate limit. " + "Please wait 10 seconds and try again.")); } return 1; @@ -3797,7 +3827,7 @@ return 0; user_info = purple_notify_user_info_new(); - + g_snprintf(who, sizeof(who), "%u", info->uin); buddy = purple_find_buddy(purple_connection_get_account(gc), who); if (buddy != NULL) @@ -3870,7 +3900,7 @@ } if (buddy != NULL) - oscar_user_info_append_status(gc, user_info, buddy, NULL); + oscar_user_info_append_status(gc, user_info, buddy, /* aim_userinfo_t */ NULL, /* strip_html_tags */ FALSE); oscar_user_info_convert_and_add(account, user_info, _("Additional Information"), info->info); purple_notify_user_info_add_section_break(user_info); @@ -3885,7 +3915,7 @@ } if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { purple_notify_user_info_add_section_header(user_info, _("Work Address")); - + oscar_user_info_convert_and_add(account, user_info, _("Address"), info->workaddr); oscar_user_info_convert_and_add(account, user_info, _("City"), info->workcity); oscar_user_info_convert_and_add(account, user_info, _("State"), info->workstate); @@ -3893,11 +3923,11 @@ } if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { purple_notify_user_info_add_section_header(user_info, _("Work Information")); - + oscar_user_info_convert_and_add(account, user_info, _("Company"), info->workcompany); oscar_user_info_convert_and_add(account, user_info, _("Division"), info->workdivision); oscar_user_info_convert_and_add(account, user_info, _("Position"), info->workposition); - + if (info->workwebpage && info->workwebpage[0] && (utf8 = oscar_utf8_try_convert(gc->account, info->workwebpage))) { char *webpage = g_strdup_printf("<a href=\"%s\">%s</a>", utf8, utf8); purple_notify_user_info_add_pair(user_info, _("Web Page"), webpage); @@ -4398,14 +4428,14 @@ /* If the length was too long, try stripping the HTML and then running it back through * purple_strdup_withhtml() and the encoding process. The result may be shorter. */ g_free((char *)args.msg); - + tmp2 = purple_markup_strip_html(tmp1); g_free(tmp1); /* re-escape the entities */ tmp1 = g_markup_escape_text(tmp2, -1); g_free(tmp2); - + tmp2 = purple_strdup_withhtml(tmp1); g_free(tmp1); tmp1 = tmp2; @@ -5636,7 +5666,7 @@ return "aim"; } -const char* oscar_list_emblem(PurpleBuddy *b) +const char *oscar_list_emblem(PurpleBuddy *b) { PurpleConnection *gc = NULL; OscarData *od = NULL; @@ -5666,7 +5696,7 @@ return "not-authorized"; } } - + if (userinfo != NULL ) { if (userinfo->flags & AIM_FLAG_ADMINISTRATOR) return "admin"; @@ -5682,17 +5712,23 @@ return NULL; } -void oscar_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full) { - PurpleConnection *gc = b->account->gc; - OscarData *od = gc->proto_data; - aim_userinfo_t *userinfo = aim_locate_finduserinfo(od, b->name); - - if (PURPLE_BUDDY_IS_ONLINE(b)) { - oscar_user_info_append_status(gc, user_info, b, userinfo); - - if (full) - oscar_user_info_append_extra_info(gc, user_info, b, userinfo); - } +void oscar_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full) +{ + PurpleConnection *gc; + OscarData *od; + aim_userinfo_t *userinfo; + + if (!PURPLE_BUDDY_IS_ONLINE(b)) + return; + + gc = b->account->gc; + od = gc->proto_data; + userinfo = aim_locate_finduserinfo(od, b->name); + + oscar_user_info_append_status(gc, user_info, b, userinfo, /* strip_html_tags */ TRUE); + + if (full) + oscar_user_info_append_extra_info(gc, user_info, b, userinfo); } char *oscar_status_text(PurpleBuddy *b) @@ -5727,7 +5763,7 @@ message = purple_status_get_attr_string(status, "message"); if (message != NULL) { - ret = g_markup_escape_text(message, -1); + ret = g_strdup(message); purple_util_chrreplace(ret, '\n', ' '); } }
--- a/libpurple/proxy.c Mon Jun 02 06:58:38 2008 +0000 +++ b/libpurple/proxy.c Tue Jun 03 05:23:38 2008 +0000 @@ -265,6 +265,7 @@ "'manual' but no proxy server is specified. Using " "Pidgin's proxy settings instead.\n"); g_free(info.host); + info.host = NULL; return purple_global_proxy_get_info(); } @@ -272,6 +273,7 @@ &info.username, NULL, NULL, NULL)) { g_free(info.host); + info.host = NULL; return purple_global_proxy_get_info(); } g_strchomp(info.username); @@ -280,7 +282,9 @@ &info.password, NULL, NULL, NULL)) { g_free(info.host); + info.host = NULL; g_free(info.username); + info.username = NULL; return purple_global_proxy_get_info(); } g_strchomp(info.password); @@ -289,8 +293,11 @@ &tmp, NULL, NULL, NULL)) { g_free(info.host); + info.host = NULL; g_free(info.username); + info.username = NULL; g_free(info.password); + info.password = NULL; return purple_global_proxy_get_info(); } info.port = atoi(tmp);
--- a/pidgin/gtkstatusbox.c Mon Jun 02 06:58:38 2008 +0000 +++ b/pidgin/gtkstatusbox.c Tue Jun 03 05:23:38 2008 +0000 @@ -209,7 +209,8 @@ for (l = purple_account_get_status_types(account); l != NULL; l = l->next) { PurpleStatusType *status_type = (PurpleStatusType *)l->data; - if (!purple_status_type_is_user_settable(status_type)) + if (!purple_status_type_is_user_settable(status_type) || + purple_status_type_is_independent(status_type)) continue; status_no++; if (statustype == status_type) @@ -769,7 +770,8 @@ for (i = 0; l; l = l->next) { PurpleStatusType *status_type = l->data; - if (!purple_status_type_is_user_settable(status_type)) + if (!purple_status_type_is_user_settable(status_type) || + purple_status_type_is_independent(status_type)) continue; if (active == i) @@ -1030,12 +1032,13 @@ PurpleStatusType *status_type = (PurpleStatusType *)l->data; PurpleStatusPrimitive prim; - if (!purple_status_type_is_user_settable(status_type)) + if (!purple_status_type_is_user_settable(status_type) || + purple_status_type_is_independent(status_type)) continue; - prim = purple_status_type_get_primitive(status_type); - - pixbuf = pidgin_status_box_get_pixbuf(status_box, prim); + prim = purple_status_type_get_primitive(status_type); + + pixbuf = pidgin_status_box_get_pixbuf(status_box, prim); pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_PRIMITIVE, pixbuf,