diff options
author | Mark Doliner <markdoliner@pidgin.im> | 2011-02-14 03:51:05 +0000 |
---|---|---|
committer | Mark Doliner <markdoliner@pidgin.im> | 2011-02-14 03:51:05 +0000 |
commit | 24757a1a7866596b2123641bfbeccec9c2d455b9 (patch) | |
tree | 90a262b36c54962f937fa89ff066d8188f824ac7 | |
parent | 9893adc3f4df57a40f0ef16c5395b3c0ca4aba97 (diff) | |
download | pidgin-24757a1a7866596b2123641bfbeccec9c2d455b9.tar.gz |
Small changes to how we format oscar screen names. We now
1. Don't attempt to format a screen name
2. Unless it's @aim.com (or possibly other AOL-owned domains), in which
case we strip off the domain and format the basename only
Hopefully fixes #13043, fixes #12376, fixes #11740
-rw-r--r-- | libpurple/protocols/oscar/oscar.c | 66 | ||||
-rw-r--r-- | libpurple/protocols/oscar/oscarcommon.h | 1 |
2 files changed, 48 insertions, 19 deletions
diff --git a/libpurple/protocols/oscar/oscar.c b/libpurple/protocols/oscar/oscar.c index 7123150bfb..6cce2bdf0b 100644 --- a/libpurple/protocols/oscar/oscar.c +++ b/libpurple/protocols/oscar/oscar.c @@ -2828,6 +2828,52 @@ static int purple_parse_buddyrights(OscarData *od, FlapConnection *conn, FlapFra return 1; } +static void oscar_format_username(PurpleConnection *gc, const char *new_display_name) +{ + OscarData *od; + const char *old_display_name, *username; + char *tmp, *at_sign; + + old_display_name = purple_connection_get_display_name(gc); + if (old_display_name && strchr(old_display_name, '@')) { + purple_debug_info("oscar", "Cowardly refusing to attempt to format " + "screen name because the current formatting according to " + "the server (%s) appears to be an email address\n", + old_display_name); + return; + } + + username = purple_account_get_username(purple_connection_get_account(gc)); + if (oscar_util_name_compare(username, new_display_name)) { + purple_notify_error(gc, NULL, _("The new formatting is invalid."), + _("Username formatting can change only capitalization and whitespace.")); + return; + } + + tmp = g_strdup(new_display_name); + + /* + * If our local username is an email address then strip off the domain. + * This allows formatting to work if the user entered their username as + * 'something@aim.com' or possibly other AOL-owned domains. + */ + at_sign = strchr(tmp, '@'); + if (at_sign) + at_sign[0] = '\0'; + + od = purple_connection_get_protocol_data(gc); + if (!flap_connection_getbytype(od, SNAC_FAMILY_ADMIN)) { + /* We don't have a connection to an "admin" server. Make one. */ + od->setnick = TRUE; + g_free(od->newformatting); + od->newformatting = tmp; + aim_srv_requestnew(od, SNAC_FAMILY_ADMIN); + } else { + aim_admin_setnick(od, flap_connection_getbytype(od, SNAC_FAMILY_ADMIN), tmp); + g_free(tmp); + } +} + static int purple_bosrights(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) { PurpleConnection *gc; PurpleAccount *account; @@ -2860,12 +2906,13 @@ static int purple_bosrights(OscarData *od, FlapConnection *conn, FlapFrame *fr, serv_set_info(gc, purple_account_get_user_info(account)); username = purple_account_get_username(account); - if (!od->icq && strcmp(username, purple_connection_get_display_name(gc)) != 0) + if (!od->icq && strcmp(username, purple_connection_get_display_name(gc)) != 0) { /* * Format the username for AIM accounts if it's different * than what's currently set. */ oscar_format_username(gc, username); + } /* Set our available message based on the current status */ status = purple_account_get_active_status(account); @@ -5196,23 +5243,6 @@ oscar_show_icq_privacy_opts(PurplePluginAction *action) gc); } -void oscar_format_username(PurpleConnection *gc, const char *nick) { - OscarData *od = purple_connection_get_protocol_data(gc); - if (!oscar_util_name_compare(purple_account_get_username(purple_connection_get_account(gc)), nick)) { - if (!flap_connection_getbytype(od, SNAC_FAMILY_ADMIN)) { - od->setnick = TRUE; - g_free(od->newformatting); - od->newformatting = g_strdup(nick); - aim_srv_requestnew(od, SNAC_FAMILY_ADMIN); - } else { - aim_admin_setnick(od, flap_connection_getbytype(od, SNAC_FAMILY_ADMIN), nick); - } - } else { - purple_notify_error(gc, NULL, _("The new formatting is invalid."), - _("Username formatting can change only capitalization and whitespace.")); - } -} - static void oscar_confirm_account(PurplePluginAction *action) { PurpleConnection *gc; diff --git a/libpurple/protocols/oscar/oscarcommon.h b/libpurple/protocols/oscar/oscarcommon.h index 383fdcb91b..31cda51a1f 100644 --- a/libpurple/protocols/oscar/oscarcommon.h +++ b/libpurple/protocols/oscar/oscarcommon.h @@ -102,6 +102,5 @@ gboolean oscar_can_receive_file(PurpleConnection *gc, const char *who); void oscar_send_file(PurpleConnection *gc, const char *who, const char *file); PurpleXfer *oscar_new_xfer(PurpleConnection *gc, const char *who); gboolean oscar_offline_message(const PurpleBuddy *buddy); -void oscar_format_username(PurpleConnection *gc, const char *nick); GList *oscar_actions(PurplePlugin *plugin, gpointer context); void oscar_init(PurplePlugin *plugin, gboolean is_icq); |