# HG changeset patch # User Nathan Walp # Date 1066108059 0 # Node ID 1930e3d00ecdd3fca84baf5bad060090f95b1a4a # Parent 49839c4cbb1cca46b3de4ad22ae8440c90d10167 [gaim-migrate @ 7838] prpl-specific normalize is back, after my crusade to kill it. committer: Tailor Script diff -r 49839c4cbb1c -r 1930e3d00ecd plugins/history.c --- a/plugins/history.c Tue Oct 14 04:44:43 2003 +0000 +++ b/plugins/history.c Tue Oct 14 05:07:39 2003 +0000 @@ -24,7 +24,7 @@ struct stat st; FILE *fd; char *userdir = g_strdup(gaim_user_dir()); - char *logfile = g_strdup_printf("%s.log", gaim_normalize(name)); + char *logfile = g_strdup_printf("%s.log", gaim_normalize(c->account, name)); char *path = g_build_filename(userdir, "logs", logfile, NULL); char buf[HISTORY_SIZE+1]; char *tmp, *tmp2; diff -r 49839c4cbb1c -r 1930e3d00ecd src/account.c --- a/src/account.c Tue Oct 14 04:44:43 2003 +0000 +++ b/src/account.c Tue Oct 14 05:07:39 2003 +0000 @@ -1526,12 +1526,12 @@ g_return_val_if_fail(name != NULL, NULL); - who = g_strdup(gaim_normalize(name)); + who = g_strdup(gaim_normalize(NULL, name)); for (l = gaim_accounts_get_all(); l != NULL; l = l->next) { account = (GaimAccount *)l->data; - if (!strcmp(gaim_normalize(gaim_account_get_username(account)), who)) { + if (!strcmp(gaim_normalize(NULL, gaim_account_get_username(account)), who)) { if (protocol != -1) { if (gaim_account_get_protocol(account) == protocol) break; @@ -1557,12 +1557,12 @@ g_return_val_if_fail(name != NULL, NULL); - who = g_strdup(gaim_normalize(name)); + who = g_strdup(gaim_normalize(NULL, name)); for (l = gaim_accounts_get_all(); l != NULL; l = l->next) { account = (GaimAccount *)l->data; - if (!strcmp(gaim_normalize(gaim_account_get_username(account)), who) && + if (!strcmp(gaim_normalize(NULL, gaim_account_get_username(account)), who) && (!protocol_id || !strcmp(account->protocol_id, protocol_id))) { break; diff -r 49839c4cbb1c -r 1930e3d00ecd src/blist.c --- a/src/blist.c Tue Oct 14 04:44:43 2003 +0000 +++ b/src/blist.c Tue Oct 14 05:07:39 2003 +0000 @@ -681,7 +681,7 @@ if(bnode->parent->parent != (GaimBlistNode*)g) { hb = g_new(struct _gaim_hbuddy, 1); - hb->name = g_strdup(gaim_normalize(buddy->name)); + hb->name = g_strdup(gaim_normalize(buddy->account, buddy->name)); hb->account = buddy->account; hb->group = bnode->parent->parent; g_hash_table_remove(gaimbuddylist->buddies, hb); @@ -727,7 +727,7 @@ hb = g_new(struct _gaim_hbuddy, 1); - hb->name = g_strdup(gaim_normalize(buddy->name)); + hb->name = g_strdup(gaim_normalize(buddy->account, buddy->name)); hb->account = buddy->account; hb->group = ((GaimBlistNode*)buddy)->parent->parent; @@ -853,7 +853,7 @@ GaimBuddy *b = (GaimBuddy*)bnode; struct _gaim_hbuddy *hb = g_new(struct _gaim_hbuddy, 1); - hb->name = g_strdup(gaim_normalize(b->name)); + hb->name = g_strdup(gaim_normalize(b->account, b->name)); hb->account = b->account; hb->group = cnode->parent; @@ -1055,7 +1055,7 @@ } - hb.name = g_strdup(gaim_normalize(buddy->name)); + hb.name = g_strdup(gaim_normalize(buddy->account, buddy->name)); hb.account = buddy->account; hb.group = ((GaimBlistNode*)buddy)->parent->parent; g_hash_table_remove(gaimbuddylist->buddies, &hb); @@ -1219,7 +1219,7 @@ if (!name) return NULL; - hb.name = g_strdup(gaim_normalize(name)); + hb.name = g_strdup(gaim_normalize(account, name)); hb.account = account; for(group = gaimbuddylist->root; group; group = group->next) { @@ -1246,7 +1246,7 @@ if (!name) return NULL; - hb.name = g_strdup(gaim_normalize(name)); + hb.name = g_strdup(gaim_normalize(account, name)); hb.account = account; hb.group = (GaimBlistNode*)group; @@ -1268,7 +1268,7 @@ if (!name) return NULL; - hb.name = g_strdup(gaim_normalize(name)); + hb.name = g_strdup(gaim_normalize(account, name)); hb.account = account; for(group = gaimbuddylist->root; group; group = group->next) { diff -r 49839c4cbb1c -r 1930e3d00ecd src/conversation.c --- a/src/conversation.c Tue Oct 14 04:44:43 2003 +0000 +++ b/src/conversation.c Tue Oct 14 05:07:39 2003 +0000 @@ -1293,6 +1293,8 @@ return chats; } + +/* This is deprecated, right? */ GaimConversation * gaim_find_conversation(const char *name) { @@ -1302,12 +1304,12 @@ g_return_val_if_fail(name != NULL, NULL); - cuser = g_strdup(gaim_normalize(name)); + cuser = g_strdup(gaim_normalize(NULL, name)); for (cnv = gaim_get_conversations(); cnv != NULL; cnv = cnv->next) { c = (GaimConversation *)cnv->data; - if (!gaim_utf8_strcasecmp(cuser, gaim_normalize(gaim_conversation_get_name(c)))) + if (!gaim_utf8_strcasecmp(cuser, gaim_normalize(NULL, gaim_conversation_get_name(c)))) break; c = NULL; @@ -1328,13 +1330,13 @@ g_return_val_if_fail(name != NULL, NULL); - cuser = g_strdup(gaim_normalize(name)); + cuser = g_strdup(gaim_normalize(account, name)); for (cnv = gaim_get_conversations(); cnv != NULL; cnv = cnv->next) { c = (GaimConversation *)cnv->data; if (!gaim_utf8_strcasecmp(cuser, - gaim_normalize(gaim_conversation_get_name(c))) && + gaim_normalize(account, gaim_conversation_get_name(c))) && account == gaim_conversation_get_account(c)) { break; @@ -1839,11 +1841,11 @@ char *str; const char *disp; - str = g_strdup(gaim_normalize(who)); + str = g_strdup(gaim_normalize(account, who)); disp = gaim_connection_get_display_name(gc); - if (!gaim_utf8_strcasecmp(str, gaim_normalize(gaim_account_get_username(account))) || - (disp && !gaim_utf8_strcasecmp(str, gaim_normalize(disp)))) { + if (!gaim_utf8_strcasecmp(str, gaim_normalize(account, gaim_account_get_username(account))) || + (disp && !gaim_utf8_strcasecmp(str, gaim_normalize(account, disp)))) { flags |= GAIM_MESSAGE_SEND; } diff -r 49839c4cbb1c -r 1930e3d00ecd src/dialogs.c --- a/src/dialogs.c Tue Oct 14 04:44:43 2003 +0000 +++ b/src/dialogs.c Tue Oct 14 05:07:39 2003 +0000 @@ -553,7 +553,7 @@ char *who; if (resp == GTK_RESPONSE_OK) { - who = g_strdup(gaim_normalize(gtk_entry_get_text(GTK_ENTRY(info->entry)))); + who = g_strdup(gaim_normalize(info->gc->account, gtk_entry_get_text(GTK_ENTRY(info->entry)))); if (!g_ascii_strcasecmp(who, "")) { g_free(who); @@ -966,7 +966,7 @@ GTK_FILE_SELECTION(gtkconv->dialogs.log)); g_snprintf(buf, BUF_LEN - 1, "%s" G_DIR_SEPARATOR_S "%s.log", - gaim_home_dir(), gaim_normalize(c->name)); + gaim_home_dir(), gaim_normalize(c->account, c->name)); g_object_set_data(G_OBJECT(gtkconv->dialogs.log), "dialog_type", "log dialog"); gtk_file_selection_set_filename(GTK_FILE_SELECTION(gtkconv->dialogs.log), @@ -1893,7 +1893,7 @@ name = g_object_get_data(G_OBJECT(filesel), "name"); tmp = gaim_user_dir(); g_snprintf(filename, PATHSIZE, "%s" G_DIR_SEPARATOR_S "logs" G_DIR_SEPARATOR_S "%s%s", tmp, - name ? gaim_normalize(name) : "system", name ? ".log" : ""); + name ? gaim_normalize(NULL, name) : "system", name ? ".log" : ""); file = (const char*)gtk_file_selection_get_filename(GTK_FILE_SELECTION(filesel)); strncpy(path, file, PATHSIZE - 1); @@ -1931,7 +1931,7 @@ gchar buf[BUF_LEN]; g_snprintf(buf, BUF_LEN - 1, "%s" G_DIR_SEPARATOR_S "%s%s", gaim_home_dir(), - name ? gaim_normalize(name) : "system", name ? ".log" : ""); + name ? gaim_normalize(NULL, name) : "system", name ? ".log" : ""); filesel = gtk_file_selection_new(_("Save Log File")); g_signal_connect(G_OBJECT(filesel), "delete_event", @@ -1960,7 +1960,7 @@ tmp = gaim_user_dir(); g_snprintf(filename, 256, "%s" G_DIR_SEPARATOR_S "logs" G_DIR_SEPARATOR_S "%s%s", tmp, - name ? gaim_normalize(name) : "system", name ? ".log" : ""); + name ? gaim_normalize(NULL, name) : "system", name ? ".log" : ""); if ((remove(filename)) == -1) { g_snprintf(buf, 256, _("Couldn't remove file %s." ), filename); @@ -2029,7 +2029,7 @@ if (view->name) { char *tmp = gaim_user_dir(); - g_snprintf(filename, 256, "%s" G_DIR_SEPARATOR_S "logs" G_DIR_SEPARATOR_S "%s.log", tmp, gaim_normalize(view->name)); + g_snprintf(filename, 256, "%s" G_DIR_SEPARATOR_S "logs" G_DIR_SEPARATOR_S "%s.log", tmp, gaim_normalize(NULL, view->name)); } else { char *tmp = gaim_user_dir(); g_snprintf(filename, 256, "%s" G_DIR_SEPARATOR_S "logs" G_DIR_SEPARATOR_S "system", tmp); @@ -2205,7 +2205,7 @@ if (name) { char *tmp = gaim_user_dir(); - g_snprintf(filename, 256, "%s" G_DIR_SEPARATOR_S "logs" G_DIR_SEPARATOR_S "%s.log", tmp, gaim_normalize(name)); + g_snprintf(filename, 256, "%s" G_DIR_SEPARATOR_S "logs" G_DIR_SEPARATOR_S "%s.log", tmp, gaim_normalize(NULL, name)); if ((fp = fopen(filename, "r")) == NULL) { g_snprintf(buf, BUF_LONG, _("Couldn't open log file %s."), filename); gaim_notify_error(NULL, NULL, buf, strerror(errno)); diff -r 49839c4cbb1c -r 1930e3d00ecd src/gtkconv.c --- a/src/gtkconv.c Tue Oct 14 04:44:43 2003 +0000 +++ b/src/gtkconv.c Tue Oct 14 05:07:39 2003 +0000 @@ -2819,7 +2819,7 @@ window = gtk_file_selection_new(_("Gaim - Save Conversation")); g_snprintf(buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S "%s.log", - gaim_home_dir(), gaim_normalize(c->name)); + gaim_home_dir(), gaim_normalize(c->account, c->name)); gtk_file_selection_set_filename(GTK_FILE_SELECTION(window), buf); g_object_set_data(G_OBJECT(GTK_FILE_SELECTION(window)->ok_button), "gaim_conversation", c); diff -r 49839c4cbb1c -r 1930e3d00ecd src/log.c --- a/src/log.c Tue Oct 14 04:44:43 2003 +0000 +++ b/src/log.c Tue Oct 14 05:07:39 2003 +0000 @@ -47,11 +47,11 @@ struct log_conversation *l; - strcpy(pname, gaim_normalize(name)); + strcpy(pname, gaim_normalize(NULL, name)); while (lc) { l = (struct log_conversation *)lc->data; - if (!gaim_utf8_strcasecmp(pname, gaim_normalize(l->name))) { + if (!gaim_utf8_strcasecmp(pname, gaim_normalize(NULL, l->name))) { g_free(pname); return l; } @@ -215,7 +215,7 @@ return fd; } - g_snprintf(realname, sizeof(realname), "%s.log", gaim_normalize(name)); + g_snprintf(realname, sizeof(realname), "%s.log", gaim_normalize(NULL, name)); fd = open_gaim_log_file(realname, &flag); if (fd && flag) { /* is a new file */ diff -r 49839c4cbb1c -r 1930e3d00ecd src/pounce.c --- a/src/pounce.c Tue Oct 14 04:44:43 2003 +0000 +++ b/src/pounce.c Tue Oct 14 05:07:39 2003 +0000 @@ -372,7 +372,7 @@ g_return_if_fail(pouncee != NULL); g_return_if_fail(events != GAIM_POUNCE_NONE); - norm_pouncee = g_strdup(gaim_normalize(pouncee)); + norm_pouncee = g_strdup(gaim_normalize(pouncer, pouncee)); for (l = gaim_pounces_get_all(); l != NULL; l = l_next) { @@ -381,7 +381,7 @@ if ((gaim_pounce_get_events(pounce) & events) && (gaim_pounce_get_pouncer(pounce) == pouncer) && - !gaim_utf8_strcasecmp(gaim_normalize(gaim_pounce_get_pouncee(pounce)), + !gaim_utf8_strcasecmp(gaim_normalize(pouncer, gaim_pounce_get_pouncee(pounce)), norm_pouncee)) { handler = g_hash_table_lookup(pounce_handlers, pounce->ui_type); @@ -411,7 +411,7 @@ g_return_val_if_fail(pouncee != NULL, NULL); g_return_val_if_fail(events != GAIM_POUNCE_NONE, NULL); - norm_pouncee = g_strdup(pouncee); + norm_pouncee = g_strdup(gaim_normalize(pouncer, pouncee)); for (l = gaim_pounces_get_all(); l != NULL; l = l->next) { @@ -419,7 +419,7 @@ if ((gaim_pounce_get_events(pounce) & events) && (gaim_pounce_get_pouncer(pounce) == pouncer) && - !gaim_utf8_strcasecmp(gaim_normalize(gaim_pounce_get_pouncee(pounce)), + !gaim_utf8_strcasecmp(gaim_normalize(pouncer, gaim_pounce_get_pouncee(pounce)), norm_pouncee)) { break; diff -r 49839c4cbb1c -r 1930e3d00ecd src/privacy.c --- a/src/privacy.c Tue Oct 14 04:44:43 2003 +0000 +++ b/src/privacy.c Tue Oct 14 05:07:39 2003 +0000 @@ -37,10 +37,10 @@ g_return_val_if_fail(account != NULL, FALSE); g_return_val_if_fail(who != NULL, FALSE); - name = g_strdup(gaim_normalize(who)); + name = g_strdup(gaim_normalize(account, who)); for (l = account->permit; l != NULL; l = l->next) { - if (!gaim_utf8_strcasecmp(name, gaim_normalize((char *)l->data))) + if (!gaim_utf8_strcasecmp(name, gaim_normalize(account, (char *)l->data))) break; } @@ -72,10 +72,10 @@ g_return_val_if_fail(account != NULL, FALSE); g_return_val_if_fail(who != NULL, FALSE); - name = g_strdup(gaim_normalize(who)); + name = g_strdup(gaim_normalize(account, who)); for (l = account->permit; l != NULL; l = l->next) { - if (!gaim_utf8_strcasecmp(name, gaim_normalize((char *)l->data))) + if (!gaim_utf8_strcasecmp(name, gaim_normalize(account, (char *)l->data))) break; } @@ -108,10 +108,10 @@ g_return_val_if_fail(account != NULL, FALSE); g_return_val_if_fail(who != NULL, FALSE); - name = g_strdup(gaim_normalize(who)); + name = g_strdup(gaim_normalize(account, who)); for (l = account->deny; l != NULL; l = l->next) { - if (!gaim_utf8_strcasecmp(name, gaim_normalize((char *)l->data))) + if (!gaim_utf8_strcasecmp(name, gaim_normalize(account, (char *)l->data))) break; } @@ -143,10 +143,10 @@ g_return_val_if_fail(account != NULL, FALSE); g_return_val_if_fail(who != NULL, FALSE); - name = g_strdup(gaim_normalize(who)); + name = g_strdup(gaim_normalize(account, who)); for (l = account->deny; l != NULL; l = l->next) { - if (!gaim_utf8_strcasecmp(name, gaim_normalize((char *)l->data))) + if (!gaim_utf8_strcasecmp(name, gaim_normalize(account, (char *)l->data))) break; } diff -r 49839c4cbb1c -r 1930e3d00ecd src/protocols/jabber/jabber.c --- a/src/protocols/jabber/jabber.c Tue Oct 14 04:44:43 2003 +0000 +++ b/src/protocols/jabber/jabber.c Tue Oct 14 05:07:39 2003 +0000 @@ -1038,7 +1038,7 @@ jabber_roster_group_rename, NULL, NULL, /* convo_closed */ /* XXX: thread_ids */ - NULL /* normalize */ + jabber_normalize /* normalize */ }; static GaimPluginInfo info = diff -r 49839c4cbb1c -r 1930e3d00ecd src/protocols/jabber/jutil.c --- a/src/protocols/jabber/jutil.c Tue Oct 14 04:44:43 2003 +0000 +++ b/src/protocols/jabber/jutil.c Tue Oct 14 05:07:39 2003 +0000 @@ -183,3 +183,14 @@ else return g_strdup(jid); } + +const char *jabber_normalize(const GaimAccount *account, const char *in) +{ + static char buf[2048]; /* maximum legal length of a jabber jid */ + char *tmp; + + tmp = jabber_get_bare_jid(in); + g_snprintf(buf, sizeof(buf), "%s", tmp); + g_free(tmp); + return buf; +} diff -r 49839c4cbb1c -r 1930e3d00ecd src/protocols/jabber/jutil.h --- a/src/protocols/jabber/jutil.h Tue Oct 14 04:44:43 2003 +0000 +++ b/src/protocols/jabber/jutil.h Tue Oct 14 05:07:39 2003 +0000 @@ -22,6 +22,8 @@ #ifndef _GAIM_JABBER_JID_H_ #define _GAIM_JABBER_JID_H_ +#include "account.h" + typedef struct _JabberID { char *node; @@ -38,4 +40,6 @@ time_t str_to_time(const char *timestamp); const char *jabber_get_state_string(int state); +const char *jabber_normalize(const GaimAccount *account, const char *in); + #endif /* _GAIM_JABBER_JID_H_ */ diff -r 49839c4cbb1c -r 1930e3d00ecd src/protocols/jabber/message.c --- a/src/protocols/jabber/message.c Tue Oct 14 04:44:43 2003 +0000 +++ b/src/protocols/jabber/message.c Tue Oct 14 05:07:39 2003 +0000 @@ -52,6 +52,24 @@ g_free(jm); } +static GaimConversation * +find_unnormalized_conv(const char *name, GaimAccount *account) +{ + GaimConversation *c = NULL; + GList *cnv; + + g_return_val_if_fail(name != NULL, NULL); + + for(cnv = gaim_get_conversations(); cnv; cnv = cnv->next) { + c = (GaimConversation*)cnv->data; + if(!gaim_utf8_strcasecmp(name, gaim_conversation_get_name(c)) && + account == gaim_conversation_get_account(c)) + return c; + } + + return NULL; +} + static void handle_chat(JabberMessage *jm) { JabberID *jid = jabber_id_new(jm->from); @@ -63,13 +81,13 @@ jb = jabber_buddy_find(jm->js, jm->from, TRUE); jbr = jabber_buddy_find_resource(jb, jabber_get_resource(jm->from)); - if(gaim_find_conversation_with_account(jm->from, jm->js->gc->account)) { + if(find_unnormalized_conv(jm->from, jm->js->gc->account)) { from = g_strdup(jm->from); } else if(jid->node) { GaimConversation *conv; from = g_strdup_printf("%s@%s", jid->node, jid->domain); - conv = gaim_find_conversation_with_account(from, jm->js->gc->account); + conv = find_unnormalized_conv(from, jm->js->gc->account); if(conv) gaim_conversation_set_name(conv, jm->from); g_free(from); diff -r 49839c4cbb1c -r 1930e3d00ecd src/protocols/msn/msn.c --- a/src/protocols/msn/msn.c Tue Oct 14 04:44:43 2003 +0000 +++ b/src/protocols/msn/msn.c Tue Oct 14 05:07:39 2003 +0000 @@ -36,7 +36,7 @@ static GaimPlugin *my_protocol = NULL; -static char *msn_normalize(const char *str); +static const char *msn_normalize(const GaimAccount *account, const char *str); typedef struct { @@ -461,7 +461,7 @@ gaim_connection_update_progress(gc, _("Connecting"), 0, MSN_CONNECT_STEPS); /* Hmm, I don't like this. */ - username = msn_normalize(gaim_account_get_username(account)); + username = msn_normalize(account, gaim_account_get_username(account)); if (strcmp(username, gaim_account_get_username(account))) gaim_account_set_username(account, username); @@ -650,11 +650,11 @@ { MsnSession *session = gc->proto_data; MsnGroup *msn_group = NULL; - char *who; + const char *who; char outparams[MSN_BUF_LEN]; GSList *l; - who = msn_normalize(name); + who = msn_normalize(gc->account, name); if (strchr(who, ' ')) { /* This is a broken blist entry. */ @@ -1186,8 +1186,8 @@ } } -static char * -msn_normalize(const char *str) +static const char * +msn_normalize(const GaimAccount *account, const char *str) { static char buf[BUF_LEN]; diff -r 49839c4cbb1c -r 1930e3d00ecd src/protocols/oscar/oscar.c --- a/src/protocols/oscar/oscar.c Tue Oct 14 04:44:43 2003 +0000 +++ b/src/protocols/oscar/oscar.c Tue Oct 14 05:07:39 2003 +0000 @@ -1792,10 +1792,10 @@ if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), info->sn)) gaim_connection_set_display_name(gc, info->sn); - bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(info->sn)); + bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, info->sn)); if (!bi) { bi = g_new0(struct buddyinfo, 1); - g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(info->sn)), bi); + g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(gc->account, info->sn)), bi); } bi->typingnot = FALSE; bi->ico_informed = FALSE; @@ -1839,7 +1839,7 @@ while (cur && aim_sncmp((char *)cur->data, info->sn)) cur = cur->next; if (!cur) { - od->requesticon = g_slist_append(od->requesticon, strdup(gaim_normalize(info->sn))); + od->requesticon = g_slist_append(od->requesticon, strdup(gaim_normalize(gc->account, info->sn))); if (od->icontimer) g_source_remove(od->icontimer); od->icontimer = g_timeout_add(500, gaim_icon_timerfunc, gc); @@ -1865,7 +1865,7 @@ serv_got_update(gc, info->sn, 0, 0, 0, 0, 0); - g_hash_table_remove(od->buddyinfo, gaim_normalize(info->sn)); + g_hash_table_remove(od->buddyinfo, gaim_normalize(gc->account, info->sn)); return 1; } @@ -2161,10 +2161,10 @@ struct buddyinfo *bi; const char *iconfile; - bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(userinfo->sn)); + bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, userinfo->sn)); if (!bi) { bi = g_new0(struct buddyinfo, 1); - g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(userinfo->sn)), bi); + g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(gc->account, userinfo->sn)), bi); } if (args->icbmflags & AIM_IMFLAGS_AWAY) @@ -4193,7 +4193,7 @@ GSList *list; for (list=gc->account->deny; (list && aim_sncmp(name, list->data)); list=list->next); if (!list) { - struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(name)); + struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); if (bi && bi->typingnot) { if (typing == GAIM_TYPING) aim_im_sendmtn(od->sess, 0x0001, name, 0x0002); @@ -4230,10 +4230,10 @@ struct stat st; gsize len; - bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(name)); + bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); if (!bi) { bi = g_new0(struct buddyinfo, 1); - g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(name)), bi); + g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(gc->account, name)), bi); } args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES; @@ -5364,7 +5364,7 @@ static char *oscar_tooltip_text(GaimBuddy *b) { GaimConnection *gc = b->account->gc; struct oscar_data *od = gc->proto_data; - struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(b->name)); + struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(b->account, b->name)); aim_userinfo_t *userinfo = aim_locate_finduserinfo(od->sess, b->name); gchar *tmp = NULL, *ret = g_strdup(""); @@ -5462,7 +5462,7 @@ else ret = g_strdup(_("Away")); } else if (GAIM_BUDDY_IS_ONLINE(b)) { - struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(b->name)); + struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(b->account, b->name)); if (bi->availmsg) ret = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); } else { diff -r 49839c4cbb1c -r 1930e3d00ecd src/protocols/toc/toc.c --- a/src/protocols/toc/toc.c Tue Oct 14 04:44:43 2003 +0000 +++ b/src/protocols/toc/toc.c Tue Oct 14 05:07:39 2003 +0000 @@ -634,7 +634,7 @@ else password = g_strdup(gaim_account_get_password(gc->account)); g_snprintf(snd, sizeof snd, "toc_signon %s %d %s %s %s \"%s\"", - AUTH_HOST, AUTH_PORT, gaim_normalize(username), + AUTH_HOST, AUTH_PORT, gaim_normalize(gc->account, username), roast_password(password), LANGUAGE, REVISION); g_free(password); if (sflap_send(gc, snd, -1, TYPE_DATA) < 0) { @@ -702,7 +702,7 @@ tdt->state = STATE_ONLINE; g_snprintf(snd, sizeof snd, "toc_signon %s %d %s %s %s \"%s\"", AUTH_HOST, AUTH_PORT, - gaim_normalize(gaim_account_get_username(gc->account)), + gaim_normalize(gc->account, gaim_account_get_username(gc->account)), roast_password(gaim_account_get_password(gc->account)), LANGUAGE, REVISION); if (sflap_send(gc, snd, -1, TYPE_DATA) < 0) { @@ -779,8 +779,8 @@ } else time_idle = 0; - tmp = g_strdup(gaim_normalize(gaim_account_get_username(gc->account))); - if (!strcmp(tmp, gaim_normalize(c))) + tmp = g_strdup(gaim_normalize(gc->account, gaim_account_get_username(gc->account))); + if (!strcmp(tmp, gaim_normalize(gc->account, c))) gaim_connection_set_display_name(gc, c); g_free(tmp); @@ -1067,7 +1067,7 @@ g_free(buf1); return -E2BIG; } - buf2 = g_strdup_printf("toc_send_im %s \"%s\"%s", gaim_normalize(name), buf1, + buf2 = g_strdup_printf("toc_send_im %s \"%s\"%s", gaim_normalize(gc->account, name), buf1, ((flags & GAIM_CONV_IM_AUTO_RESP) ? " auto" : "")); g_free(buf1); #else @@ -1091,7 +1091,7 @@ return -E2BIG; } - buf2 = g_strdup_printf("toc2_send_im_enc %s F U en \"%s\" %s", gaim_normalize(name), buf1, + buf2 = g_strdup_printf("toc2_send_im_enc %s F U en \"%s\" %s", gaim_normalize(gc->account, name), buf1, ((flags & GAIM_CONV_IM_AUTO_RESP) ? "auto" : "")); g_free(buf1); #endif @@ -1111,18 +1111,18 @@ g_free(buf); } -static void toc_get_info(GaimConnection *g, const char *name) +static void toc_get_info(GaimConnection *gc, const char *name) { char buf[BUF_LEN * 2]; - g_snprintf(buf, MSG_LEN, "toc_get_info %s", gaim_normalize(name)); - sflap_send(g, buf, -1, TYPE_DATA); + g_snprintf(buf, MSG_LEN, "toc_get_info %s", gaim_normalize(gc->account, name)); + sflap_send(gc, buf, -1, TYPE_DATA); } -static void toc_get_dir(GaimConnection *g, const char *name) +static void toc_get_dir(GaimConnection *gc, const char *name) { char buf[BUF_LEN * 2]; - g_snprintf(buf, MSG_LEN, "toc_get_dir %s", gaim_normalize(name)); - sflap_send(g, buf, -1, TYPE_DATA); + g_snprintf(buf, MSG_LEN, "toc_get_dir %s", gaim_normalize(gc->account, name)); + sflap_send(gc, buf, -1, TYPE_DATA); } static void toc_set_dir(GaimConnection *g, const char *first, const char *middle, const char *last, @@ -1184,55 +1184,56 @@ sflap_send(g, buf, -1, TYPE_DATA); } -static void toc_add_buddy(GaimConnection *g, const char *name, GaimGroup *group) +static void +toc_add_buddy(GaimConnection *gc, const char *name, GaimGroup *group) { char buf[BUF_LEN * 2]; - g_snprintf(buf, sizeof(buf), "toc_add_buddy %s", gaim_normalize(name)); - sflap_send(g, buf, -1, TYPE_DATA); - toc_set_config(g); + g_snprintf(buf, sizeof(buf), "toc_add_buddy %s", gaim_normalize(gc->account, name)); + sflap_send(gc, buf, -1, TYPE_DATA); + toc_set_config(gc); } -static void toc_add_buddies(GaimConnection *g, GList *buddies) +static void toc_add_buddies(GaimConnection *gc, GList *buddies) { char buf[BUF_LEN * 2]; int n; n = g_snprintf(buf, sizeof(buf), "toc_add_buddy"); while (buddies) { - if (strlen(gaim_normalize(buddies->data)) + n + 32 > MSG_LEN) { - sflap_send(g, buf, -1, TYPE_DATA); + if (strlen(gaim_normalize(gc->account, buddies->data)) + n + 32 > MSG_LEN) { + sflap_send(gc, buf, -1, TYPE_DATA); n = g_snprintf(buf, sizeof(buf), "toc_add_buddy"); } - n += g_snprintf(buf + n, sizeof(buf) - n, " %s", gaim_normalize(buddies->data)); + n += g_snprintf(buf + n, sizeof(buf) - n, " %s", gaim_normalize(gc->account, buddies->data)); buddies = buddies->next; } - sflap_send(g, buf, -1, TYPE_DATA); + sflap_send(gc, buf, -1, TYPE_DATA); } -static void toc_remove_buddy(GaimConnection *g, const char *name, const char *group) +static void toc_remove_buddy(GaimConnection *gc, const char *name, const char *group) { char buf[BUF_LEN * 2]; - g_snprintf(buf, sizeof(buf), "toc_remove_buddy %s", gaim_normalize(name)); - sflap_send(g, buf, -1, TYPE_DATA); - toc_set_config(g); + g_snprintf(buf, sizeof(buf), "toc_remove_buddy %s", gaim_normalize(gc->account, name)); + sflap_send(gc, buf, -1, TYPE_DATA); + toc_set_config(gc); } -static void toc_remove_buddies(GaimConnection *g, GList *buddies, const char *group) +static void toc_remove_buddies(GaimConnection *gc, GList *buddies, const char *group) { char buf[BUF_LEN * 2]; int n; n = g_snprintf(buf, sizeof(buf), "toc_remove_buddy"); while (buddies) { - if (strlen(gaim_normalize(buddies->data)) + n + 32 > MSG_LEN) { - sflap_send(g, buf, -1, TYPE_DATA); + if (strlen(gaim_normalize(gc->account, buddies->data)) + n + 32 > MSG_LEN) { + sflap_send(gc, buf, -1, TYPE_DATA); n = g_snprintf(buf, sizeof(buf), "toc_remove_buddy"); } - n += g_snprintf(buf + n, sizeof(buf) - n, " %s", gaim_normalize(buddies->data)); + n += g_snprintf(buf + n, sizeof(buf) - n, " %s", gaim_normalize(gc->account, buddies->data)); buddies = buddies->next; } - sflap_send(g, buf, -1, TYPE_DATA); - toc_set_config(g); + sflap_send(gc, buf, -1, TYPE_DATA); + toc_set_config(gc); } static void toc_set_idle(GaimConnection *g, int time) @@ -1289,12 +1290,12 @@ sflap_send(g, buf, -1, TYPE_DATA); } -static void toc_chat_invite(GaimConnection *g, int id, const char *message, const char *name) +static void toc_chat_invite(GaimConnection *gc, int id, const char *message, const char *name) { char buf[BUF_LONG]; g_snprintf(buf, sizeof(buf) / 2, "toc_chat_invite %d \"%s\" %s", id, - message ? message : "", gaim_normalize(name)); - sflap_send(g, buf, -1, TYPE_DATA); + message ? message : "", gaim_normalize(gc->account, name)); + sflap_send(gc, buf, -1, TYPE_DATA); } static void toc_chat_leave(GaimConnection *g, int id) @@ -1324,13 +1325,13 @@ } } -static void toc_chat_whisper(GaimConnection *g, int id, const char *who, const char *message) +static void toc_chat_whisper(GaimConnection *gc, int id, const char *who, const char *message) { char *buf1, *buf2; buf1 = escape_text(message); - buf2 = g_strdup_printf("toc_chat_whisper %d %s \"%s\"", id, gaim_normalize(who), buf1); + buf2 = g_strdup_printf("toc_chat_whisper %d %s \"%s\"", id, gaim_normalize(gc->account, who), buf1); g_free(buf1); - sflap_send(g, buf2, -1, TYPE_DATA); + sflap_send(gc, buf2, -1, TYPE_DATA); g_free(buf2); } @@ -1411,7 +1412,7 @@ char buf2[BUF_LEN * 2]; if (gc->account->perm_deny != 3) return; - g_snprintf(buf2, sizeof(buf2), "toc_add_permit %s", gaim_normalize(who)); + g_snprintf(buf2, sizeof(buf2), "toc_add_permit %s", gaim_normalize(gc->account, who)); sflap_send(gc, buf2, -1, TYPE_DATA); toc_set_config(gc); } @@ -1421,7 +1422,7 @@ char buf2[BUF_LEN * 2]; if (gc->account->perm_deny != 4) return; - g_snprintf(buf2, sizeof(buf2), "toc_add_deny %s", gaim_normalize(who)); + g_snprintf(buf2, sizeof(buf2), "toc_add_deny %s", gaim_normalize(gc->account, who)); sflap_send(gc, buf2, -1, TYPE_DATA); toc_set_config(gc); } @@ -1458,7 +1459,7 @@ at = g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); list = gc->account->permit; while (list) { - at += g_snprintf(buf2 + at, sizeof(buf2) - at, "%s ", gaim_normalize(list->data)); + at += g_snprintf(buf2 + at, sizeof(buf2) - at, "%s ", gaim_normalize(gc->account, list->data)); if (at > MSG_LEN + 32) { /* from out my ass comes greatness */ sflap_send(gc, buf2, -1, TYPE_DATA); at = g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); @@ -1476,7 +1477,7 @@ at = g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); list = gc->account->deny; while (list) { - at += g_snprintf(buf2 + at, sizeof(buf2) - at, "%s ", gaim_normalize(list->data)); + at += g_snprintf(buf2 + at, sizeof(buf2) - at, "%s ", gaim_normalize(gc->account, list->data)); if (at > MSG_LEN + 32) { /* from out my ass comes greatness */ sflap_send(gc, buf2, -1, TYPE_DATA); at = g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); diff -r 49839c4cbb1c -r 1930e3d00ecd src/protocols/yahoo/yahoo.c --- a/src/protocols/yahoo/yahoo.c Tue Oct 14 04:44:43 2003 +0000 +++ b/src/protocols/yahoo/yahoo.c Tue Oct 14 05:07:39 2003 +0000 @@ -859,7 +859,7 @@ { struct yahoo_packet *pack; GaimAccount *account = gaim_connection_get_account(gc); - const char *name = gaim_normalize(gaim_account_get_username(account)); + const char *name = gaim_normalize(account, gaim_account_get_username(account)); const char *pass = gaim_account_get_password(account); struct yahoo_data *yd = gc->proto_data; @@ -977,7 +977,7 @@ { struct yahoo_packet *pack = NULL; GaimAccount *account = gaim_connection_get_account(gc); - const char *name = gaim_normalize(gaim_account_get_username(account)); + const char *name = gaim_normalize(account, gaim_account_get_username(account)); const char *pass = gaim_account_get_password(account); struct yahoo_data *yd = gc->proto_data; @@ -1721,7 +1721,7 @@ pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH, YAHOO_STATUS_AVAILABLE, 0); - yahoo_packet_hash(pkt, 1, gaim_normalize(gaim_account_get_username(gaim_connection_get_account(gc)))); + yahoo_packet_hash(pkt, 1, gaim_normalize(gc->account, gaim_account_get_username(gaim_connection_get_account(gc)))); yahoo_send_packet(yd, pkt); yahoo_packet_free(pkt); @@ -1752,8 +1752,8 @@ pkt = yahoo_packet_new(YAHOO_SERVICE_WEBLOGIN, YAHOO_STATUS_WEBLOGIN, 0); - yahoo_packet_hash(pkt, 0, gaim_normalize(gaim_account_get_username(gaim_connection_get_account(gc)))); - yahoo_packet_hash(pkt, 1, gaim_normalize(gaim_account_get_username(gaim_connection_get_account(gc)))); + yahoo_packet_hash(pkt, 0, gaim_normalize(gc->account, gaim_account_get_username(gaim_connection_get_account(gc)))); + yahoo_packet_hash(pkt, 1, gaim_normalize(gc->account, gaim_account_get_username(gaim_connection_get_account(gc)))); yahoo_packet_hash(pkt, 6, yd->auth); yahoo_send_packet(yd, pkt); diff -r 49839c4cbb1c -r 1930e3d00ecd src/protocols/zephyr/ZAsyncLocate.c --- a/src/protocols/zephyr/ZAsyncLocate.c Tue Oct 14 04:44:43 2003 +0000 +++ b/src/protocols/zephyr/ZAsyncLocate.c Tue Oct 14 05:07:39 2003 +0000 @@ -4,7 +4,7 @@ * Created by: Marc Horowitz * * $Source$ - * $Author: warmenhoven $ + * $Author: faceprint $ * * Copyright (c) 1990,1991 by the Massachusetts Institute of Technology. * For copying and distribution information, see the file @@ -15,11 +15,11 @@ #include #ifndef lint -static const char rcsid_ZAsyncLocate_c[] = "$Id: ZAsyncLocate.c 2096 2001-07-31 01:00:39Z warmenhoven $"; +static const char rcsid_ZAsyncLocate_c[] = "$Id: ZAsyncLocate.c 7838 2003-10-14 05:07:39Z faceprint $"; #endif Code_t ZRequestLocations(user, zald, kind, auth) - char *user; + const char *user; register ZAsyncLocateData_t *zald; ZNotice_Kind_t kind; /* UNSAFE, UNACKED, or ACKED */ Z_AuthProc auth; diff -r 49839c4cbb1c -r 1930e3d00ecd src/protocols/zephyr/zephyr.c --- a/src/protocols/zephyr/zephyr.c Tue Oct 14 04:44:43 2003 +0000 +++ b/src/protocols/zephyr/zephyr.c Tue Oct 14 05:07:39 2003 +0000 @@ -71,7 +71,7 @@ return;\ } -static char *zephyr_normalize(const char *); +static const char *zephyr_normalize(const GaimAccount *, const char *); /* this is so bad, and if Zephyr weren't so fucked up to begin with I * wouldn't do this. but it is so i will. */ @@ -307,7 +307,7 @@ { GList *curr; for (curr = pending_zloc_names; curr != NULL; curr = curr->next) { - if (!g_ascii_strcasecmp(zephyr_normalize(who), (char*)curr->data)) { + if (!g_ascii_strcasecmp(zephyr_normalize(NULL, who), (char*)curr->data)) { g_free((char*)curr->data); pending_zloc_names = g_list_remove(pending_zloc_names, curr->data); return TRUE; @@ -465,8 +465,8 @@ if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) continue; if(b->account->gc == zgc) { - char *chk; - chk = zephyr_normalize(b->name); + const char *chk; + chk = zephyr_normalize(b->account, b->name); /* doesn't matter if this fails or not; we'll just move on to the next one */ ZRequestLocations(chk, &ald, UNACKED, ZAUTH); free(ald.user); @@ -783,9 +783,9 @@ notice.z_class = zt->class; notice.z_class_inst = zt->instance; if (!g_ascii_strcasecmp(zt->recipient, "*")) - notice.z_recipient = zephyr_normalize(""); + notice.z_recipient = zephyr_normalize(NULL, ""); else - notice.z_recipient = zephyr_normalize(zt->recipient); + notice.z_recipient = zephyr_normalize(NULL, zt->recipient); notice.z_sender = 0; notice.z_default_format = "Class $class, Instance $instance:\n" @@ -832,7 +832,7 @@ return 1; } -static char *zephyr_normalize(const char *orig) +static const char *zephyr_normalize(const GaimAccount *account, const char *orig) { static char buf[80]; if (!g_ascii_strcasecmp(orig, "")) { @@ -850,13 +850,13 @@ static void zephyr_zloc(GaimConnection *gc, const char *who) { ZAsyncLocateData_t ald; - - if (ZRequestLocations(zephyr_normalize(who), &ald, UNACKED, ZAUTH) + + if (ZRequestLocations(zephyr_normalize(gc->account, who), &ald, UNACKED, ZAUTH) != ZERR_NONE) { return; } pending_zloc_names = g_list_append(pending_zloc_names, - g_strdup(zephyr_normalize(who))); + g_strdup(zephyr_normalize(gc->account, who))); } static GList *zephyr_buddy_menu(GaimConnection *gc, const char *who) diff -r 49839c4cbb1c -r 1930e3d00ecd src/protocols/zephyr/zephyr.h --- a/src/protocols/zephyr/zephyr.h Tue Oct 14 04:44:43 2003 +0000 +++ b/src/protocols/zephyr/zephyr.h Tue Oct 14 05:07:39 2003 +0000 @@ -5,7 +5,7 @@ * * $Source$ * $Author: faceprint $ - * $Id: zephyr.h 5500 2003-04-15 04:18:00Z faceprint $ + * $Id: zephyr.h 7838 2003-10-14 05:07:39Z faceprint $ * * Copyright (c) 1987,1988,1991 by the Massachusetts Institute of * Technology. For copying and distribution information, see the @@ -89,7 +89,7 @@ int z_authent_len; char *z_ascii_authent; char *z_class; - char *z_class_inst; + const char *z_class_inst; char *z_opcode; char *z_sender; const char *z_recipient; @@ -161,7 +161,7 @@ Code_t ZFormatRawNoticeList ZP((ZNotice_t *notice, char *list[], int nitems, char **buffer, int *ret_len)); Code_t ZLocateUser ZP((char *, int *, Z_AuthProc)); -Code_t ZRequestLocations ZP((char *, ZAsyncLocateData_t *, +Code_t ZRequestLocations ZP((const char *, ZAsyncLocateData_t *, ZNotice_Kind_t, Z_AuthProc)); Code_t ZhmStat ZP((struct in_addr *, ZNotice_t *)); Code_t ZInitialize ZP((void)); diff -r 49839c4cbb1c -r 1930e3d00ecd src/prpl.h --- a/src/prpl.h Tue Oct 14 04:44:43 2003 +0000 +++ b/src/prpl.h Tue Oct 14 05:07:39 2003 +0000 @@ -306,7 +306,7 @@ void (*convo_closed)(GaimConnection *, const char *who); - char *(*normalize)(const char *); + const char *(*normalize)(const GaimAccount *, const char *); void (*set_buddy_icon)(GaimConnection *, const char *filename); diff -r 49839c4cbb1c -r 1930e3d00ecd src/server.c --- a/src/server.c Tue Oct 14 04:44:43 2003 +0000 +++ b/src/server.c Tue Oct 14 05:07:39 2003 +0000 @@ -1093,9 +1093,9 @@ if (signon && (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->options & OPT_PROTO_CORRECT_TIME)) { - char *tmp = g_strdup(gaim_normalize(name)); + char *tmp = g_strdup(gaim_normalize(account, name)); if (!gaim_utf8_strcasecmp(tmp, - gaim_normalize(gaim_account_get_username(account)))) { + gaim_normalize(account, gaim_account_get_username(account)))) { gc->evil = evil; gc->login_time_official = signon; diff -r 49839c4cbb1c -r 1930e3d00ecd src/util.c --- a/src/util.c Tue Oct 14 04:44:43 2003 +0000 +++ b/src/util.c Tue Oct 14 05:07:39 2003 +0000 @@ -1250,30 +1250,43 @@ * String Functions **************************************************************************/ const char * -gaim_normalize(const char *s) +gaim_normalize(const GaimAccount *account, const char *s) { - static char buf[BUF_LEN]; - char *tmp; - int i, j; + GaimPlugin *prpl = NULL; + GaimPluginProtocolInfo *prpl_info = NULL; + + if(account) + prpl = gaim_find_prpl(gaim_account_get_protocol(account)); - g_return_val_if_fail(s != NULL, NULL); + if(prpl) + prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); + + if(prpl_info && prpl_info->normalize) { + return prpl_info->normalize(account, s); + } else { + static char buf[BUF_LEN]; + char *tmp; + int i, j; - 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'; + 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); - g_snprintf(buf, sizeof(buf), "%s", tmp); - g_free(tmp); + 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); + g_snprintf(buf, sizeof(buf), "%s", tmp); + g_free(tmp); - return buf; + return buf; + } } /* Look for %n, %d, or %t in msg, and replace with the sender's name, date, diff -r 49839c4cbb1c -r 1930e3d00ecd src/util.h --- a/src/util.h Tue Oct 14 04:44:43 2003 +0000 +++ b/src/util.h Tue Oct 14 05:07:39 2003 +0000 @@ -302,11 +302,12 @@ * g_strdup() it. Also, calling normalize() twice in the same line * will lead to problems. * - * @param str The string to normalize. + * @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(const char *str); +const char *gaim_normalize(const GaimAccount *account, const char *str); /** * Looks for %n, %d, or %t in a string, and replaces them with the