# HG changeset patch # User Luke Schierer # Date 1049078324 0 # Node ID 0230df73f56a445418519db040a73c68f47608e7 # Parent 10a0917c1c0f227c8fb50dcb68150df9207379bc [gaim-migrate @ 5249] (21:35:04) Robot101: now we have a confusing optional jabber server option (21:36:00) Robot101: it becomes infinitely confusing to append jabber.org to someone's username when they've specified a server further down in the same dialog committer: Tailor Script diff -r 10a0917c1c0f -r 0230df73f56a src/protocols/jabber/jabber.c --- a/src/protocols/jabber/jabber.c Sun Mar 30 23:14:57 2003 +0000 +++ b/src/protocols/jabber/jabber.c Mon Mar 31 02:38:44 2003 +0000 @@ -82,9 +82,9 @@ #define UC_DND (0x10 | UC_UNAVAILABLE) #define UC_ERROR (0x20 | UC_UNAVAILABLE) -#define DEFAULT_SERVER "jabber.org" #define DEFAULT_GROUPCHAT "conference.jabber.org" #define DEFAULT_PORT 5222 +#define DEFAULT_RESOURCE "Gaim" #define USEROPT_PORT 0 #define USEROPT_CONN_SERVER 1 @@ -248,10 +248,11 @@ static char *create_valid_jid(const char *given, char *server, char *resource) { char *valid; - - if (!strchr(given, '@')) + char *tmp; + + if (!(tmp = strchr(given, '@'))) valid = g_strdup_printf("%s@%s/%s", given, server, resource); - else if (!strchr(strchr(given, '@'), '/')) + else if (!strchr(tmp, '/')) valid = g_strdup_printf("%s/%s", given, resource); else valid = g_strdup(given); @@ -259,6 +260,25 @@ return valid; } +/* checks the username of a GC is a valid JID and appends * + * the resource if necessary. returns NULL for invalid JID. * + * for jabber_login and jabber_register_user */ +static char *create_login_name(struct gaim_connection *gc) +{ + char *given = gc->account->username; + char *valid; + char *tmp; + + if (!(tmp = strchr(given, '@'))) + valid = NULL; + else if (!strchr(tmp, '/')) + valid = g_strdup_printf("%s/%s", given, DEFAULT_RESOURCE); + else + valid = g_strdup(given); + + return valid; +} + /* * Dispose of a gaim_jid_struct */ @@ -2267,7 +2287,13 @@ { struct gaim_connection *gc = new_gaim_conn(account); struct jabber_data *jd = gc->proto_data = g_new0(struct jabber_data, 1); - char *loginname = create_valid_jid(account->username, DEFAULT_SERVER, "Gaim"); + char *loginname = create_login_name(gc); + + if (!loginname) { + hide_login_progress(gc, _("Jabber IDs must be of the form user@server")); + signoff(gc); + return; + } jd->buddies = g_hash_table_new(g_str_hash, g_str_equal); jd->chats = NULL; /* we have no chats yet */ @@ -4124,7 +4150,13 @@ { struct gaim_connection *gc = new_gaim_conn(account); struct jabber_data *jd = gc->proto_data = g_new0(struct jabber_data, 1); - char *loginname = create_valid_jid(account->username, DEFAULT_SERVER, "Gaim"); + char *loginname = create_login_name(gc); + + if (!loginname) { + hide_login_progress(gc, _("Jabber IDs must be of the form user@server")); + signoff(gc); + return; + } /* * These do nothing during registration @@ -4232,12 +4264,12 @@ puo = g_new0(struct proto_user_opt, 1); puo->label = g_strdup(_("Port:")); - puo->def = g_strdup("5222"); + puo->def = g_strdup_printf("%d", DEFAULT_PORT); puo->pos = USEROPT_PORT; ret->user_opts = g_list_append(ret->user_opts, puo); puo = g_new0(struct proto_user_opt, 1); - puo->label = g_strdup(_("Connect Server:")); + puo->label = g_strdup(_("Connect Server:\n(optional)")); puo->def = g_strdup(""); puo->pos = USEROPT_CONN_SERVER; ret->user_opts = g_list_append(ret->user_opts, puo);