From: Nathan W. <fac...@us...> - 2003-10-14 05:07:43
|
Update of /cvsroot/gaim/gaim/src In directory sc8-pr-cvs1:/tmp/cvs-serv21452/src Modified Files: account.c blist.c conversation.c dialogs.c gtkblist.c gtkconv.c log.c pounce.c privacy.c prpl.h server.c util.c util.h Log Message: prpl-specific normalize is back, after my crusade to kill it. Index: account.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/account.c,v retrieving revision 1.68 retrieving revision 1.69 diff -u -d -p -r1.68 -r1.69 --- account.c 5 Oct 2003 22:41:29 -0000 1.68 +++ account.c 14 Oct 2003 05:07:37 -0000 1.69 @@ -1526,12 +1526,12 @@ gaim_accounts_find_with_prpl_num(const c 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 @@ gaim_accounts_find(const char *name, con 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; Index: blist.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/blist.c,v retrieving revision 1.103 retrieving revision 1.104 diff -u -d -p -r1.103 -r1.104 --- blist.c 13 Oct 2003 03:48:35 -0000 1.103 +++ blist.c 14 Oct 2003 05:07:37 -0000 1.104 @@ -681,7 +681,7 @@ void gaim_blist_add_buddy (GaimBuddy *b 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 @@ void gaim_blist_add_buddy (GaimBuddy *b 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 @@ void gaim_blist_add_contact(GaimContact 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 @@ void gaim_blist_remove_buddy (GaimBuddy } - 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 @@ GaimBuddy *gaim_find_buddy(GaimAccount * 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 @@ GaimBuddy *gaim_find_buddy_in_group(Gaim 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 @@ GSList *gaim_find_buddies(GaimAccount *a 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) { Index: conversation.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/conversation.c,v retrieving revision 1.566 retrieving revision 1.567 diff -u -d -p -r1.566 -r1.567 --- conversation.c 14 Oct 2003 03:34:55 -0000 1.566 +++ conversation.c 14 Oct 2003 05:07:37 -0000 1.567 @@ -1293,6 +1293,8 @@ gaim_get_chats(void) return chats; } + +/* This is deprecated, right? */ GaimConversation * gaim_find_conversation(const char *name) { @@ -1302,12 +1304,12 @@ gaim_find_conversation(const char *name) 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 @@ gaim_find_conversation_with_account(cons 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 @@ gaim_conv_chat_write(GaimConvChat *chat, 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; } Index: dialogs.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/dialogs.c,v retrieving revision 1.550 retrieving revision 1.551 diff -u -d -p -r1.550 -r1.551 --- dialogs.c 13 Oct 2003 00:11:48 -0000 1.550 +++ dialogs.c 14 Oct 2003 05:07:37 -0000 1.551 @@ -553,7 +553,7 @@ static void do_info(GtkWidget *widget, i 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 @@ void show_log_dialog(GaimConversation *c 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 @@ static void do_save_log(GtkWidget *w, Gt 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 @@ static void show_save_log(GtkWidget *w, 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 @@ static void do_clear_log_file(GtkWidget 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 @@ static void log_show_convo(struct view_l 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 @@ void show_log(char *nm) 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)); Index: gtkblist.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/gtkblist.c,v retrieving revision 1.111 retrieving revision 1.112 diff -u -d -p -r1.111 -r1.112 --- gtkblist.c 13 Oct 2003 03:48:36 -0000 1.111 +++ gtkblist.c 14 Oct 2003 05:07:38 -0000 1.112 @@ -3432,7 +3432,7 @@ static GtkTreeIter sort_method_status(Ga static int get_log_size(char *name) { - char *logname = g_strdup_printf("%s.log", gaim_normalize(name)); + char *logname = g_strdup_printf("%s.log", gaim_normalize(NULL, name)); char *filename = g_build_filename(gaim_user_dir(), "logs", logname, NULL); struct stat st; Index: gtkconv.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/gtkconv.c,v retrieving revision 1.213 retrieving revision 1.214 diff -u -d -p -r1.213 -r1.214 --- gtkconv.c 12 Oct 2003 21:00:23 -0000 1.213 +++ gtkconv.c 14 Oct 2003 05:07:38 -0000 1.214 @@ -2819,7 +2819,7 @@ save_convo(GtkWidget *save, GaimConversa 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); Index: log.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/log.c,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -p -r1.29 -r1.30 --- log.c 1 Oct 2003 07:15:50 -0000 1.29 +++ log.c 14 Oct 2003 05:07:38 -0000 1.30 @@ -47,11 +47,11 @@ struct log_conversation *find_log_info(c 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 @@ FILE *open_log_file(const char *name, in 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 */ Index: pounce.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/pounce.c,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -p -r1.27 -r1.28 --- pounce.c 3 Oct 2003 21:49:11 -0000 1.27 +++ pounce.c 14 Oct 2003 05:07:38 -0000 1.28 @@ -372,7 +372,7 @@ gaim_pounce_execute(const GaimAccount *p 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 @@ gaim_pounce_execute(const GaimAccount *p 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 @@ gaim_find_pounce(const GaimAccount *poun 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 @@ gaim_find_pounce(const GaimAccount *poun 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; Index: privacy.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/privacy.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -p -r1.6 -r1.7 --- privacy.c 1 Oct 2003 06:17:28 -0000 1.6 +++ privacy.c 14 Oct 2003 05:07:38 -0000 1.7 @@ -37,10 +37,10 @@ gaim_privacy_permit_add(GaimAccount *acc 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 @@ gaim_privacy_permit_remove(GaimAccount * 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 @@ gaim_privacy_deny_add(GaimAccount *accou 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 @@ gaim_privacy_deny_remove(GaimAccount *ac 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; } Index: prpl.h =================================================================== RCS file: /cvsroot/gaim/gaim/src/prpl.h,v retrieving revision 1.136 retrieving revision 1.137 diff -u -d -p -r1.136 -r1.137 --- prpl.h 2 Oct 2003 02:54:02 -0000 1.136 +++ prpl.h 14 Oct 2003 05:07:38 -0000 1.137 @@ -306,7 +306,7 @@ struct _GaimPluginProtocolInfo 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); Index: server.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/server.c,v retrieving revision 1.374 retrieving revision 1.375 diff -u -d -p -r1.374 -r1.375 --- server.c 2 Oct 2003 02:54:02 -0000 1.374 +++ server.c 14 Oct 2003 05:07:38 -0000 1.375 @@ -1093,9 +1093,9 @@ void serv_got_update(GaimConnection *gc, 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; Index: util.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/util.c,v retrieving revision 1.226 retrieving revision 1.227 diff -u -d -p -r1.226 -r1.227 --- util.c 5 Oct 2003 18:32:43 -0000 1.226 +++ util.c 14 Oct 2003 05:07:38 -0000 1.227 @@ -1250,30 +1250,43 @@ gaim_fd_get_ip(int fd) * 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; - g_return_val_if_fail(s != NULL, NULL); + if(account) + prpl = gaim_find_prpl(gaim_account_get_protocol(account)); - 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'; + if(prpl) + prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); - 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); + if(prpl_info && prpl_info->normalize) { + return prpl_info->normalize(account, s); + } else { + static char buf[BUF_LEN]; + char *tmp; + int i, j; - return buf; + 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); + + return buf; + } } /* Look for %n, %d, or %t in msg, and replace with the sender's name, date, Index: util.h =================================================================== RCS file: /cvsroot/gaim/gaim/src/util.h,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -p -r1.27 -r1.28 --- util.h 5 Oct 2003 18:32:43 -0000 1.27 +++ util.h 14 Oct 2003 05:07:38 -0000 1.28 @@ -302,11 +302,12 @@ char *gaim_fd_get_ip(int fd); * 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 |