Mercurial > pidgin
changeset 31209:0dade4c34d24
merge of '25bd5b382cc84daef94ed59dab062fea9d1613f9'
and '2679e81d33ef8b6f8087c9d7aa5f4e563a32f3d1'
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Tue, 15 Feb 2011 01:49:11 +0000 |
parents | d235da74af79 (current diff) 6e6379254def (diff) |
children | 5dccfd26108b |
files | |
diffstat | 9 files changed, 126 insertions(+), 44 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/account.h Sun Feb 13 01:27:17 2011 +0000 +++ b/libpurple/account.h Tue Feb 15 01:49:11 2011 +0000 @@ -143,6 +143,7 @@ * buddies are added to your permit list. Currently we have to * iterate through the entire list if we want to check if someone * is permitted or denied. We should do this for 3.0.0. + * Or maybe use a GTree. */ GSList *permit; /**< Permit list. */ GSList *deny; /**< Deny list. */
--- a/libpurple/protocols/myspace/myspace.c Sun Feb 13 01:27:17 2011 +0000 +++ b/libpurple/protocols/myspace/myspace.c Tue Feb 15 01:49:11 2011 +0000 @@ -385,21 +385,22 @@ g_return_val_if_fail(buddy != NULL, NULL); - user = msim_get_user_from_buddy(buddy, TRUE); - account = purple_buddy_get_account(buddy); gc = purple_account_get_connection(account); session = (MsimSession *)gc->proto_data; display_name = headline = NULL; - /* Retrieve display name and/or headline, depending on user preference. */ - if (purple_account_get_bool(session->account, "show_headline", TRUE)) { - headline = user->headline; - } - - if (purple_account_get_bool(session->account, "show_display_name", FALSE)) { - display_name = user->display_name; + user = msim_get_user_from_buddy(buddy, FALSE); + if (user != NULL) { + /* Retrieve display name and/or headline, depending on user preference. */ + if (purple_account_get_bool(account, "show_headline", TRUE)) { + headline = user->headline; + } + + if (purple_account_get_bool(account, "show_display_name", FALSE)) { + display_name = user->display_name; + } } /* Return appropriate combination of display name and/or headline, or neither. */
--- a/libpurple/protocols/oscar/oscar.c Sun Feb 13 01:27:17 2011 +0000 +++ b/libpurple/protocols/oscar/oscar.c Tue Feb 15 01:49:11 2011 +0000 @@ -2828,6 +2828,52 @@ 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 @@ 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 @@ 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;
--- a/libpurple/protocols/oscar/oscarcommon.h Sun Feb 13 01:27:17 2011 +0000 +++ b/libpurple/protocols/oscar/oscarcommon.h Tue Feb 15 01:49:11 2011 +0000 @@ -102,6 +102,5 @@ 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);
--- a/libpurple/tests/Makefile.am Sun Feb 13 01:27:17 2011 +0000 +++ b/libpurple/tests/Makefile.am Tue Feb 15 01:49:11 2011 +0000 @@ -14,6 +14,7 @@ test_jabber_digest_md5.c \ test_jabber_jutil.c \ test_jabber_scram.c \ + test_oscar_util.c \ test_qq.c \ test_yahoo_util.c \ test_util.c \ @@ -30,6 +31,7 @@ check_libpurple_LDADD=\ $(top_builddir)/libpurple/protocols/jabber/libjabber.la \ + $(top_builddir)/libpurple/protocols/oscar/liboscar.la \ $(top_builddir)/libpurple/protocols/qq/libqq_tmp.la \ $(top_builddir)/libpurple/protocols/yahoo/libymsg.la \ $(top_builddir)/libpurple/libpurple.la \
--- a/libpurple/tests/check_libpurple.c Sun Feb 13 01:27:17 2011 +0000 +++ b/libpurple/tests/check_libpurple.c Tue Feb 15 01:49:11 2011 +0000 @@ -88,6 +88,7 @@ srunner_add_suite(sr, jabber_digest_md5_suite()); srunner_add_suite(sr, jabber_jutil_suite()); srunner_add_suite(sr, jabber_scram_suite()); + srunner_add_suite(sr, oscar_util_suite()); srunner_add_suite(sr, qq_suite()); srunner_add_suite(sr, yahoo_util_suite()); srunner_add_suite(sr, util_suite());
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libpurple/tests/test_oscar_util.c Tue Feb 15 01:49:11 2011 +0000 @@ -0,0 +1,47 @@ +#include <string.h> + +#include "tests.h" +#include "../protocols/oscar/oscar.h" + +START_TEST(test_oscar_util_name_compare) +{ + int i; + const char *good[] = { + "test", + "TEST", + "Test", + "teSt", + " TesT", + "test ", + " T E s T " + }; + const char *bad[] = { + "toast", + "test@example.com", + "test@aim.com" + }; + + for (i = 0; i < G_N_ELEMENTS(good); i++) { + ck_assert_int_eq(0, oscar_util_name_compare("test", good[i])); + ck_assert_int_eq(0, oscar_util_name_compare(good[i], "test")); + } + for (i = 0; i < G_N_ELEMENTS(bad); i++) { + ck_assert_int_ne(0, oscar_util_name_compare("test", bad[i])); + ck_assert_int_ne(0, oscar_util_name_compare(bad[i], "test")); + } +} +END_TEST + +Suite *oscar_util_suite(void) +{ + Suite *s; + TCase *tc; + + s = suite_create("OSCAR Utility Functions"); + + tc = tcase_create("Convert IM from network format to HTML"); + tcase_add_test(tc, test_oscar_util_name_compare); + suite_add_tcase(s, tc); + + return s; +}
--- a/libpurple/tests/tests.h Sun Feb 13 01:27:17 2011 +0000 +++ b/libpurple/tests/tests.h Tue Feb 15 01:49:11 2011 +0000 @@ -13,6 +13,7 @@ Suite * jabber_digest_md5_suite(void); Suite * jabber_jutil_suite(void); Suite * jabber_scram_suite(void); +Suite * oscar_util_suite(void); Suite * qq_suite(void); Suite * yahoo_util_suite(void); Suite * util_suite(void);
--- a/pidgin/gtkconv.c Sun Feb 13 01:27:17 2011 +0000 +++ b/pidgin/gtkconv.c Tue Feb 15 01:49:11 2011 +0000 @@ -78,9 +78,9 @@ #define AUTO_RESPONSE "<AUTO-REPLY> : " -typedef enum -{ - PIDGIN_CONV_SET_TITLE = 1 << 0, +typedef enum +{ + PIDGIN_CONV_SET_TITLE = 1 << 0, PIDGIN_CONV_BUDDY_ICON = 1 << 1, PIDGIN_CONV_MENU = 1 << 2, PIDGIN_CONV_TAB_ICON = 1 << 3, @@ -2192,9 +2192,9 @@ (event->keyval == GDK_Left) || (event->keyval == GDK_Right) || (event->keyval == GDK_Page_Up) || - (event->keyval == GDK_KP_Page_Up) || + (event->keyval == GDK_KP_Page_Up) || (event->keyval == GDK_Page_Down) || - (event->keyval == GDK_KP_Page_Down) || + (event->keyval == GDK_KP_Page_Down) || (event->keyval == GDK_Home) || (event->keyval == GDK_End) || (event->keyval == GDK_Tab) || @@ -2430,8 +2430,8 @@ if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) { PurpleBuddy *b = purple_find_buddy(account, name); if (b != NULL) { - PurplePresence *p; - p = purple_buddy_get_presence(b); + PurplePresence *p; + p = purple_buddy_get_presence(b); if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_AWAY)) return away_list; if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_UNAVAILABLE)) @@ -6127,7 +6127,7 @@ /* Currently GTK+ maintains our sorted list after it's in the tree. * This may change if it turns out we can manage it faster ourselves. - */ + */ gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_KEY_COLUMN, GTK_SORT_ASCENDING); } @@ -6479,13 +6479,13 @@ gtk_widget_show(win->menu.get_info); gtk_widget_hide(win->menu.invite); gtk_widget_show(win->menu.alias); - if (purple_privacy_check(account, purple_conversation_get_name(conv))) { - gtk_widget_hide(win->menu.unblock); - gtk_widget_show(win->menu.block); - } else { - gtk_widget_hide(win->menu.block); - gtk_widget_show(win->menu.unblock); - } + if (purple_privacy_check(account, purple_conversation_get_name(conv))) { + gtk_widget_hide(win->menu.unblock); + gtk_widget_show(win->menu.block); + } else { + gtk_widget_hide(win->menu.block); + gtk_widget_show(win->menu.unblock); + } if ((account == NULL) || purple_find_buddy(account, purple_conversation_get_name(conv)) == NULL) { gtk_widget_show(win->menu.add); @@ -6706,7 +6706,7 @@ char *title; PurpleConvIm *im = NULL; PurpleAccount *account = purple_conversation_get_account(conv); - PurpleBuddy *buddy = NULL; + PurpleBuddy *buddy = NULL; char *markup = NULL; AtkObject *accessibility_obj; /* I think this is a little longer than it needs to be but I'm lazy. */