Mercurial > pidgin.yaz
comparison libpurple/protocols/oscar/oscar.c @ 31654:b39a2bd81566
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
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Mon, 14 Feb 2011 03:51:05 +0000 |
parents | a8cc50c2279f |
children | 3fe2bd895946 |
comparison
equal
deleted
inserted
replaced
31653:f1874b08b3f9 | 31654:b39a2bd81566 |
---|---|
2826 od->rights.maxwatchers = (guint)maxwatchers; | 2826 od->rights.maxwatchers = (guint)maxwatchers; |
2827 | 2827 |
2828 return 1; | 2828 return 1; |
2829 } | 2829 } |
2830 | 2830 |
2831 static void oscar_format_username(PurpleConnection *gc, const char *new_display_name) | |
2832 { | |
2833 OscarData *od; | |
2834 const char *old_display_name, *username; | |
2835 char *tmp, *at_sign; | |
2836 | |
2837 old_display_name = purple_connection_get_display_name(gc); | |
2838 if (old_display_name && strchr(old_display_name, '@')) { | |
2839 purple_debug_info("oscar", "Cowardly refusing to attempt to format " | |
2840 "screen name because the current formatting according to " | |
2841 "the server (%s) appears to be an email address\n", | |
2842 old_display_name); | |
2843 return; | |
2844 } | |
2845 | |
2846 username = purple_account_get_username(purple_connection_get_account(gc)); | |
2847 if (oscar_util_name_compare(username, new_display_name)) { | |
2848 purple_notify_error(gc, NULL, _("The new formatting is invalid."), | |
2849 _("Username formatting can change only capitalization and whitespace.")); | |
2850 return; | |
2851 } | |
2852 | |
2853 tmp = g_strdup(new_display_name); | |
2854 | |
2855 /* | |
2856 * If our local username is an email address then strip off the domain. | |
2857 * This allows formatting to work if the user entered their username as | |
2858 * 'something@aim.com' or possibly other AOL-owned domains. | |
2859 */ | |
2860 at_sign = strchr(tmp, '@'); | |
2861 if (at_sign) | |
2862 at_sign[0] = '\0'; | |
2863 | |
2864 od = purple_connection_get_protocol_data(gc); | |
2865 if (!flap_connection_getbytype(od, SNAC_FAMILY_ADMIN)) { | |
2866 /* We don't have a connection to an "admin" server. Make one. */ | |
2867 od->setnick = TRUE; | |
2868 g_free(od->newformatting); | |
2869 od->newformatting = tmp; | |
2870 aim_srv_requestnew(od, SNAC_FAMILY_ADMIN); | |
2871 } else { | |
2872 aim_admin_setnick(od, flap_connection_getbytype(od, SNAC_FAMILY_ADMIN), tmp); | |
2873 g_free(tmp); | |
2874 } | |
2875 } | |
2876 | |
2831 static int purple_bosrights(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) { | 2877 static int purple_bosrights(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) { |
2832 PurpleConnection *gc; | 2878 PurpleConnection *gc; |
2833 PurpleAccount *account; | 2879 PurpleAccount *account; |
2834 PurpleStatus *status; | 2880 PurpleStatus *status; |
2835 gboolean is_available; | 2881 gboolean is_available; |
2858 | 2904 |
2859 if (purple_account_get_user_info(account) != NULL) | 2905 if (purple_account_get_user_info(account) != NULL) |
2860 serv_set_info(gc, purple_account_get_user_info(account)); | 2906 serv_set_info(gc, purple_account_get_user_info(account)); |
2861 | 2907 |
2862 username = purple_account_get_username(account); | 2908 username = purple_account_get_username(account); |
2863 if (!od->icq && strcmp(username, purple_connection_get_display_name(gc)) != 0) | 2909 if (!od->icq && strcmp(username, purple_connection_get_display_name(gc)) != 0) { |
2864 /* | 2910 /* |
2865 * Format the username for AIM accounts if it's different | 2911 * Format the username for AIM accounts if it's different |
2866 * than what's currently set. | 2912 * than what's currently set. |
2867 */ | 2913 */ |
2868 oscar_format_username(gc, username); | 2914 oscar_format_username(gc, username); |
2915 } | |
2869 | 2916 |
2870 /* Set our available message based on the current status */ | 2917 /* Set our available message based on the current status */ |
2871 status = purple_account_get_active_status(account); | 2918 status = purple_account_get_active_status(account); |
2872 is_available = purple_status_is_available(status); | 2919 is_available = purple_status_is_available(status); |
2873 if (is_available) | 2920 if (is_available) |
5194 _("Cancel"), NULL, | 5241 _("Cancel"), NULL, |
5195 purple_connection_get_account(gc), NULL, NULL, | 5242 purple_connection_get_account(gc), NULL, NULL, |
5196 gc); | 5243 gc); |
5197 } | 5244 } |
5198 | 5245 |
5199 void oscar_format_username(PurpleConnection *gc, const char *nick) { | |
5200 OscarData *od = purple_connection_get_protocol_data(gc); | |
5201 if (!oscar_util_name_compare(purple_account_get_username(purple_connection_get_account(gc)), nick)) { | |
5202 if (!flap_connection_getbytype(od, SNAC_FAMILY_ADMIN)) { | |
5203 od->setnick = TRUE; | |
5204 g_free(od->newformatting); | |
5205 od->newformatting = g_strdup(nick); | |
5206 aim_srv_requestnew(od, SNAC_FAMILY_ADMIN); | |
5207 } else { | |
5208 aim_admin_setnick(od, flap_connection_getbytype(od, SNAC_FAMILY_ADMIN), nick); | |
5209 } | |
5210 } else { | |
5211 purple_notify_error(gc, NULL, _("The new formatting is invalid."), | |
5212 _("Username formatting can change only capitalization and whitespace.")); | |
5213 } | |
5214 } | |
5215 | |
5216 static void oscar_confirm_account(PurplePluginAction *action) | 5246 static void oscar_confirm_account(PurplePluginAction *action) |
5217 { | 5247 { |
5218 PurpleConnection *gc; | 5248 PurpleConnection *gc; |
5219 OscarData *od; | 5249 OscarData *od; |
5220 FlapConnection *conn; | 5250 FlapConnection *conn; |