gaim/gaim

082bd8d4e408
Parents 15627e6d3fe7
Children fad67df529e4
sf patch #1243998, from Evan Schoenberg, also some changes by me
Basically novell needed a prpl->normalize function that
didn't remove spaces. But I didn't like having the default
normalize code make the string lowercase and remove spaces,
so I changed the default to basically do nothing.

Anyhoo, if you think of yourself as the primary contact for
one of the PRPLs, you may want to make sure your PRPL has a
normalize function, if it needs one.
--- a/src/protocols/irc/irc.c Sun Jul 24 13:59:07 2005 -0400
+++ b/src/protocols/irc/irc.c Sun Jul 24 15:27:39 2005 -0400
@@ -668,7 +668,7 @@
NULL, /* rename_group */
NULL, /* buddy_free */
NULL, /* convo_closed */
- NULL, /* normalize */
+ gaim_normalize_nocase, /* normalize */
NULL, /* set_buddy_icon */
NULL, /* remove_group */
NULL, /* get_cb_real_name */
--- a/src/protocols/novell/novell.c Sun Jul 24 13:59:07 2005 -0400
+++ b/src/protocols/novell/novell.c Sun Jul 24 15:27:39 2005 -0400
@@ -3439,7 +3439,7 @@
novell_rename_group, /* rename_group */
NULL, /* buddy_free */
novell_convo_closed, /* convo_closed */
- NULL, /* normalize */
+ gaim_normalize_nocase, /* normalize */
NULL, /* set_buddy_icon */
novell_remove_group, /* remove_group */
NULL, /* get_cb_real_name */
--- a/src/protocols/oscar/oscar.c Sun Jul 24 13:59:07 2005 -0400
+++ b/src/protocols/oscar/oscar.c Sun Jul 24 15:27:39 2005 -0400
@@ -7464,6 +7464,33 @@
oscar_direct_im_destroy(od, dim);
}
+static const char *
+oscar_normalize(const GaimAccount *account, const char *str)
+{
+ static char buf[BUF_LEN];
+ char *tmp1, *tmp2;
+ int i, j;
+
+ g_return_val_if_fail(str != NULL, NULL);
+
+ strncpy(buf, str, BUF_LEN);
+ for (i=0, j=0; buf[j]; i++, j++)
+ {
+ while (buf[j] == ' ')
+ j++;
+ buf[i] = buf[j];
+ }
+ buf[i] = '\0';
+
+ tmp1 = g_utf8_strdown(buf, -1);
+ tmp2 = g_utf8_normalize(tmp1, -1, G_NORMALIZE_DEFAULT);
+ g_snprintf(buf, sizeof(buf), "%s", tmp2);
+ g_free(tmp2);
+ g_free(tmp1);
+
+ return buf;
+}
+
static GaimPluginProtocolInfo prpl_info =
{
OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE,
@@ -7519,7 +7546,7 @@
#endif
NULL, /* buddy_free */
oscar_convo_closed, /* convo_closed */
- NULL, /* normalize */
+ oscar_normalize, /* normalize */
oscar_set_icon, /* set_buddy_icon */
NULL, /* remove_group */
NULL, /* get_cb_real_name */
--- a/src/protocols/toc/toc.c Sun Jul 24 13:59:07 2005 -0400
+++ b/src/protocols/toc/toc.c Sun Jul 24 15:27:39 2005 -0400
@@ -1376,6 +1376,33 @@
sflap_send(gc, "", 0, TYPE_KEEPALIVE);
}
+static const char *
+toc_normalize(const GaimAccount *account, const char *str)
+{
+ static char buf[BUF_LEN];
+ char *tmp1, *tmp2;
+ int i, j;
+
+ g_return_val_if_fail(str != NULL, NULL);
+
+ strncpy(buf, str, BUF_LEN);
+ for (i=0, j=0; buf[j]; i++, j++)
+ {
+ while (buf[j] == ' ')
+ j++;
+ buf[i] = buf[j];
+ }
+ buf[i] = '\0';
+
+ tmp1 = g_utf8_strdown(buf, -1);
+ tmp2 = g_utf8_normalize(tmp1, -1, G_NORMALIZE_DEFAULT);
+ g_snprintf(buf, sizeof(buf), "%s", tmp2);
+ g_free(tmp2);
+ g_free(tmp1);
+
+ return buf;
+}
+
static const char *toc_list_icon(GaimAccount *a, GaimBuddy *b)
{
if (!b || (b && b->name && b->name[0] == '+')) {
@@ -2156,7 +2183,7 @@
NULL, /* rename_group */
NULL, /* buddy_free */
NULL, /* convo_closed */
- NULL, /* normalize */
+ toc_normalize, /* normalize */
NULL, /* set_buddy_icon */
NULL, /* remove_group */
NULL, /* get_cb_real_name */
--- a/src/protocols/yahoo/yahoo.c Sun Jul 24 13:59:07 2005 -0400
+++ b/src/protocols/yahoo/yahoo.c Sun Jul 24 15:27:39 2005 -0400
@@ -3603,7 +3603,7 @@
yahoo_rename_group,
NULL, /* buddy_free */
NULL, /* convo_closed */
- NULL, /* normalize */
+ gaim_normalize_nocase, /* normalize */
yahoo_set_buddy_icon,
NULL, /* void (*remove_group)(GaimConnection *gc, const char *group);*/
NULL, /* char *(*get_cb_real_name)(GaimConnection *gc, int id, const char *who); */
--- a/src/protocols/zephyr/zephyr.c Sun Jul 24 13:59:07 2005 -0400
+++ b/src/protocols/zephyr/zephyr.c Sun Jul 24 15:27:39 2005 -0400
@@ -168,7 +168,6 @@
}
char *local_zephyr_normalize(zephyr_account* zephyr,const char *);
-static const char *zephyr_normalize(const GaimAccount *, const char *);
static void zephyr_chat_set_topic(GaimConnection * gc, int id, const char *topic);
char* zephyr_tzc_deescape_str(const char *message);
--- a/src/util.c Sun Jul 24 13:59:07 2005 -0400
+++ b/src/util.c Sun Jul 24 15:27:39 2005 -0400
@@ -2083,7 +2083,7 @@
* String Functions
**************************************************************************/
const char *
-gaim_normalize(const GaimAccount *account, const char *s)
+gaim_normalize(const GaimAccount *account, const char *str)
{
GaimPlugin *prpl = NULL;
GaimPluginProtocolInfo *prpl_info = NULL;
@@ -2096,35 +2096,45 @@
prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl);
if(prpl_info && prpl_info->normalize)
- ret = prpl_info->normalize(account, s);
-
- if(!ret) {
+ ret = prpl_info->normalize(account, str);
+
+ if(!ret)
+ {
static char buf[BUF_LEN];
char *tmp;
- int i, j;
-
- g_return_val_if_fail(s != NULL, NULL);
-
- strncpy(buf, s, BUF_LEN);
- for (i=0, j=0; buf[j]; i++, j++) {
- while (buf[j] == ' ')
- j++;
- buf[i] = buf[j];
- }
- buf[i] = '\0';
-
- tmp = g_utf8_strdown(buf, -1);
- g_snprintf(buf, sizeof(buf), "%s", tmp);
- g_free(tmp);
- tmp = g_utf8_normalize(buf, -1, G_NORMALIZE_DEFAULT);
+
+ tmp = g_utf8_normalize(str, -1, G_NORMALIZE_DEFAULT);
g_snprintf(buf, sizeof(buf), "%s", tmp);
g_free(tmp);
ret = buf;
}
+
return ret;
}
+/*
+ * You probably don't want to call this directly, it is
+ * mainly for use as a PRPL callback function. See the
+ * comments in util.h.
+ */
+const char *
+gaim_normalize_nocase(const GaimAccount *account, const char *str)
+{
+ static char buf[BUF_LEN];
+ char *tmp1, *tmp2;
+
+ g_return_val_if_fail(str != NULL, NULL);
+
+ tmp1 = g_utf8_strdown(str, -1);
+ tmp2 = g_utf8_normalize(tmp1, -1, G_NORMALIZE_DEFAULT);
+ g_snprintf(buf, sizeof(buf), "%s", tmp2);
+ g_free(tmp2);
+ g_free(tmp1);
+
+ return buf;
+}
+
gchar *
gaim_str_sub_away_formatters(const char *str, const char *name)
{
--- a/src/util.h Sun Jul 24 13:59:07 2005 -0400
+++ b/src/util.h Sun Jul 24 15:27:39 2005 -0400
@@ -435,6 +435,20 @@
const char *gaim_normalize(const GaimAccount *account, const char *str);
/**
+ * Normalizes a string, so that it is suitable for comparison.
+ *
+ * This is one possible implementation for the PRPL callback
+ * function "normalize." It returns a lowercase and UTF-8
+ * normalized version of the string.
+ *
+ * @param account The account the string belongs to.
+ * @param str The string to normalize.
+ *
+ * @return A pointer to the normalized version stored in a static buffer.
+ */
+const char *gaim_normalize_nocase(const GaimAccount *account, const char *str);
+
+/**
* Compares two strings to see if the first contains the second as
* a proper prefix.
*