im.pidgin.pidgin: 15b495a6774e316e3d7962181284bcf13b9ccffa
jeff2 at soc.pidgin.im
jeff2 at soc.pidgin.im
Sun Jan 13 21:10:38 EST 2008
-----------------------------------------------------------------
Revision: 15b495a6774e316e3d7962181284bcf13b9ccffa
Ancestor: 394a96091e6eace0c8f3a50b977554efc9697a56
Author: jeff2 at soc.pidgin.im
Date: 2008-01-14T02:06:47
Branch: im.pidgin.pidgin
Modified files:
COPYRIGHT libpurple/protocols/myspace/myspace.c
libpurple/protocols/myspace/myspace.h
ChangeLog:
Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
This makes buddy names treated the same regardless of case and spacing. It
also allows user IDs to be normalized into usernames, _if_ the user is on
the buddy list (making it work in the general case is #4631).
This allows you to IM 6221 and have a conversion with 'tom' instead of his
number. Closes #2802.
mtn: beginning commit on branch 'im.pidgin.pidgin'
mtn: misuse: empty log message; commit canceled
-------------- next part --------------
============================================================
--- COPYRIGHT b91fce4af2a143fe7359257867dee5d995e4e5bd
+++ COPYRIGHT b4dcb769e1bd1cd9ff853e6969b2c1a83f0320e9
@@ -426,6 +426,7 @@ Dan Willemsen
Andrew Whewell
Simon Wilkinson
Dan Willemsen
+Justin Williams (Jaywalker)
Jason Willis
Matt Wilson
Dan Winship
============================================================
--- libpurple/protocols/myspace/myspace.c bf9e4fcc342a9748b6a432ac717a6b1201aa8793
+++ libpurple/protocols/myspace/myspace.c 05c7086a97082f4c49b014e0eeb35e30545d4591
@@ -2316,6 +2316,69 @@ msim_remove_buddy(PurpleConnection *gc,
msim_msg_free(blocklist_msg);
}
+/**
+ * Borrowed this code from oscar_normalize. Added checking for "if userid, get name before normalizing"
+ *
+ * Basically... Returns a string that has been formated with all the spaces and caps removed.
+ */
+const char *msim_normalize(const PurpleAccount *account, const char *str) {
+ static char normalized[BUF_LEN];
+ MsimSession *session;
+ char *tmp1, *tmp2;
+ int i, j;
+ guint id;
+
+ g_return_val_if_fail(str != NULL, NULL);
+
+ if (msim_is_userid(str)) {
+ /* Have user ID, we need to get their username first :) */
+ const char *username;
+
+ /* If the account does not exist, we can't look up the user. */
+ g_return_val_if_fail(account != NULL, str);
+ g_return_val_if_fail(account->gc != NULL, str);
+ g_return_val_if_fail(account->gc->state == PURPLE_CONNECTED, str);
+
+ purple_debug_info("msim_normalize", "%s is a userid\n",str);
+
+ session = (MsimSession *)account->gc->proto_data;
+ id = atol(str);
+ username = msim_uid2username_from_blist(session, id);
+ if (!username) {
+ /* Not in buddy list... scheisse... TODO: Manual Lookup! */
+ /* Note: manual lookup using msim_lookup_user() is a problem inside
+ * msim_normalize(), because msim_lookup_user() calls a callback function
+ * when the user information has been looked up, but msim_normalize() expects
+ * the result immediately. */
+ purple_debug_info("msim_normalize", "Failure! %s is not in my list\n", str);
+ strncpy(normalized, str, BUF_LEN);
+ } else {
+ purple_debug_info("msim_normalize","%d is %s\n", id, username);
+ strncpy(normalized, username, BUF_LEN);
+ }
+ } else {
+ /* Have username. */
+ strncpy(normalized, str, BUF_LEN);
+ }
+
+ /* Strip spaces. */
+ for (i=0, j=0; normalized[j]; i++, j++) {
+ while (normalized[j] == ' ')
+ j++;
+ normalized[i] = normalized[j];
+ }
+ normalized[i] = '\0';
+
+ /* Lowercase and perform UTF-8 normalization. */
+ tmp1 = g_utf8_strdown(normalized, -1);
+ tmp2 = g_utf8_normalize(tmp1, -1, G_NORMALIZE_DEFAULT);
+ g_snprintf(normalized, sizeof(normalized), "%s", tmp2);
+ g_free(tmp2);
+ g_free(tmp1);
+
+ return normalized;
+}
+
/** Return whether the buddy can be messaged while offline.
*
* The protocol supports offline messages in just the same way as online
@@ -2970,7 +3033,7 @@ static PurplePluginProtocolInfo prpl_inf
NULL, /* rename_group */
NULL, /* buddy_free */
NULL, /* convo_closed */
- NULL, /* normalize */
+ msim_normalize, /* normalize */
NULL, /* set_buddy_icon */
NULL, /* remove_group */
NULL, /* get_cb_real_name */
============================================================
--- libpurple/protocols/myspace/myspace.h 3ff7642b4fa1325f420abb169ac45be9d51bdef5
+++ libpurple/protocols/myspace/myspace.h 50d31f83cf565063f2203381be6c680af00cb3fd
@@ -201,6 +201,8 @@ void msim_remove_buddy(PurpleConnection
void msim_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group);
void msim_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group);
+const char *msim_normalize(const PurpleAccount *account, const char *str);
+
gboolean msim_offline_message(const PurpleBuddy *buddy);
void msim_close(PurpleConnection *gc);
More information about the Commits
mailing list