# HG changeset patch # User Rob Flynn # Date 988331324 0 # Node ID baf57b74e818947df21ba428d5b567e0fe22f00c # Parent 300dcb2aa120ddc666028a097cfae9ff75101c84 [gaim-migrate @ 1766] msn normalizing of names and such committer: Tailor Script diff -r 300dcb2aa120 -r baf57b74e818 plugins/msn/msn.c --- a/plugins/msn/msn.c Thu Apr 26 22:45:02 2001 +0000 +++ b/plugins/msn/msn.c Fri Apr 27 00:28:44 2001 +0000 @@ -105,6 +105,7 @@ static void process_hotmail_msg(struct gaim_connection *gc, gchar *msgdata); void msn_des_win(GtkWidget *a, GtkWidget *b); void msn_newmail_dialog(const char *text); +static char *msn_normalize(const char *s); char tochar(char *h) { @@ -294,7 +295,7 @@ snprintf(buf, MSN_BUF_LEN, "The user %s (%s) wants to add you to their buddylist.", res[4], res[5]); ap->user = g_strdup(res[4]); - ap->friendly = url_decode(res[5]); + ap->friendly = g_strdup(url_decode(res[5])); ap->gc = gc; do_ask_dialog(buf, ap, (GtkFunction) msn_accept_add_permit, (GtkFunction) msn_cancel_add_permit); @@ -310,7 +311,7 @@ fcntl(source, F_SETFL, 0); - g_snprintf(buf, MSN_BUF_LEN, "ANS 1 %s %s %s\n", mc->gc->username, mc->secret, mc->session); + g_snprintf(buf, MSN_BUF_LEN, "ANS 1 %s %s %s\n",mc->gc->username, mc->secret, mc->session); msn_write(mc->fd, buf); gdk_input_remove(mc->inpa); @@ -713,7 +714,7 @@ { /* Looks like we were transfered here. Just send a sign on */ set_login_progress(gc, 3, "Signing On"); - g_snprintf(buf, MSN_BUF_LEN, "USR %d %s I %s\n", md->last_trid, md->policy, gc->username); + g_snprintf(buf, MSN_BUF_LEN, "USR %d %s I %s\n", md->last_trid, md->policy, gc->username); msn_write(md->fd, buf); /* Reset this bit */ @@ -834,7 +835,7 @@ } else { - md->friendly = url_decode(res[4]); + md->friendly = g_strdup(url_decode(res[4])); /* Ok, ok. Your account is FINALLY online. Ya think Microsoft * could have had any more steps involved? */ @@ -959,6 +960,8 @@ return; } + sprintf(gc->username, "%s", msn_normalize(gc->username)); + md->inpa = gdk_input_add(md->fd, GDK_INPUT_WRITE, msn_login_callback, gc); debug_printf("Connected.\n"); @@ -1323,6 +1326,38 @@ } } +static char *msn_normalize(const char *s) +{ + static char buf[BUF_LEN]; + char *t, *u; + int x = 0; + + g_return_val_if_fail((s != NULL), NULL); + + u = t = g_strdup(s); + + g_strdown(t); + + while (*t && (x < BUF_LEN - 1)) { + if (*t != ' ') + buf[x++] = *t; + t++; + } + buf[x] = '\0'; + g_free(u); + + if (!strchr(buf, '@')) { + strcat(buf, "@hotmail.com"); /* if they don't specify something, it will be hotmail.com. msn.com + is valid too, but hey, if they wanna use it, they gotta enter it + themselves. */ + } else if ((u = strchr(strchr(buf, '@'), '/')) != NULL) { + *u = '\0'; + } + + return buf; +} + + static char **msn_list_icon(int uc) { if (uc == UC_UNAVAILABLE) @@ -1370,6 +1405,7 @@ ret->chat_whisper = NULL; ret->chat_send = NULL; ret->keepalive = NULL; + ret->normalize = msn_normalize; my_protocol = ret; }