# HG changeset patch # User Nathan Walp # Date 1077202661 0 # Node ID dd6fe7d965aad3c04eec652c4ffdfc8a7a811266 # Parent bc850664b5594206023cd4ca6d8198c93e7284cc [gaim-migrate @ 9020] committing piecemeal sucks, but filetransfer isn't ready for prime time yet. hopefully this doesn't break anything. this should fix the problems with empty packets, fix a bug in MUC conferencing, and re-add the option for changing passwords on XMPP servers, until I write the code to actually detect that. Hopefully this compiles, and I didn't break anything. committer: Tailor Script diff -r bc850664b559 -r dd6fe7d965aa src/protocols/jabber/auth.c --- a/src/protocols/jabber/auth.c Thu Feb 19 14:52:09 2004 +0000 +++ b/src/protocols/jabber/auth.c Thu Feb 19 14:57:41 2004 +0000 @@ -32,28 +32,35 @@ #include "util.h" #include "sslconn.h" - -void -jabber_auth_start(JabberStream *js, xmlnode *packet) +gboolean +jabber_process_starttls(JabberStream *js, xmlnode *packet) { - xmlnode *mechs, *mechnode; xmlnode *starttls; - xmlnode *auth; - - gboolean digest_md5 = FALSE, plain=FALSE; if((starttls = xmlnode_get_child(packet, "starttls"))) { if(gaim_account_get_bool(js->gc->account, "use_tls", TRUE) && gaim_ssl_is_supported()) { jabber_send_raw(js, "", -1); - return; + return TRUE; } else if(xmlnode_get_child(starttls, "required")) { gaim_connection_error(js->gc, _("Server requires SSL for login")); - return; + return TRUE; } } + return FALSE; +} + +void +jabber_auth_start(JabberStream *js, xmlnode *packet) +{ + xmlnode *mechs, *mechnode; + xmlnode *auth; + + gboolean digest_md5 = FALSE, plain=FALSE; + + if(js->registration) { jabber_register_start(js); return; diff -r bc850664b559 -r dd6fe7d965aa src/protocols/jabber/auth.h --- a/src/protocols/jabber/auth.h Thu Feb 19 14:52:09 2004 +0000 +++ b/src/protocols/jabber/auth.h Thu Feb 19 14:57:41 2004 +0000 @@ -25,6 +25,7 @@ #include "jabber.h" #include "xmlnode.h" +gboolean jabber_process_starttls(JabberStream *js, xmlnode *packet); void jabber_auth_start(JabberStream *js, xmlnode *packet); void jabber_auth_start_old(JabberStream *js); void jabber_auth_handle_challenge(JabberStream *js, xmlnode *packet); diff -r bc850664b559 -r dd6fe7d965aa src/protocols/jabber/jabber.c --- a/src/protocols/jabber/jabber.c Thu Feb 19 14:52:09 2004 +0000 +++ b/src/protocols/jabber/jabber.c Thu Feb 19 14:57:41 2004 +0000 @@ -96,6 +96,11 @@ static void jabber_stream_features_parse(JabberStream *js, xmlnode *packet) { + if(xmlnode_get_child(packet, "starttls")) { + if(jabber_process_starttls(js, packet)) + return; + } + if(xmlnode_get_child(packet, "mechanisms")) { jabber_auth_start(js, packet); } else if(xmlnode_get_child(packet, "bind")) { @@ -109,6 +114,13 @@ jabber_iq_set_callback(iq, jabber_bind_result_cb, NULL); jabber_iq_send(iq); + } else /* if(xmlnode_get_child_with_namespace(packet, "auth")) */ { + /* If we get an empty stream:features packet, or we explicitly get + * an auth feature with namespace http://jabber.org/features/iq-auth + * we should revert back to iq:auth authentication, even though we're + * connecting to an XMPP server. */ + js->auth_type = JABBER_AUTH_IQ_AUTH; + jabber_stream_set_state(js, JABBER_STREAM_AUTHENTICATING); } } @@ -805,11 +817,10 @@ case JABBER_STREAM_AUTHENTICATING: gaim_connection_update_progress(js->gc, _("Authenticating"), js->gsc ? 6 : 3, JABBER_CONNECT_STEPS); - if(js->protocol_version == JABBER_PROTO_0_9) { - if(js->registration) - jabber_register_start(js); - else - jabber_auth_start_old(js); + if(js->protocol_version == JABBER_PROTO_0_9 && js->registration) { + jabber_register_start(js); + } else if(js->auth_type == JABBER_AUTH_IQ_AUTH) { + jabber_auth_start_old(js); } break; case JABBER_STREAM_REINITIALIZING: @@ -1084,7 +1095,6 @@ static GList *jabber_actions(GaimConnection *gc) { - JabberStream *js = gc->proto_data; GList *m = NULL; struct proto_actions_menu *pam; @@ -1094,13 +1104,13 @@ pam->gc = gc; m = g_list_append(m, pam); - if(js->protocol_version == JABBER_PROTO_0_9) { + /* if (js->protocol_options & CHANGE_PASSWORD) { */ pam = g_new0(struct proto_actions_menu, 1); pam->label = _("Change Password"); pam->callback = jabber_password_change; pam->gc = gc; m = g_list_append(m, pam); - } + /* } */ return m; } diff -r bc850664b559 -r dd6fe7d965aa src/protocols/jabber/jabber.h --- a/src/protocols/jabber/jabber.h Thu Feb 19 14:52:09 2004 +0000 +++ b/src/protocols/jabber/jabber.h Thu Feb 19 14:57:41 2004 +0000 @@ -51,9 +51,10 @@ JABBER_PROTO_1_0 } protocol_version; enum { - JABBER_AUTH_NONE, + JABBER_AUTH_UNKNOWN, JABBER_AUTH_DIGEST_MD5, - JABBER_AUTH_PLAIN + JABBER_AUTH_PLAIN, + JABBER_AUTH_IQ_AUTH } auth_type; char *stream_id; JabberStreamState state; diff -r bc850664b559 -r dd6fe7d965aa src/protocols/jabber/parser.c --- a/src/protocols/jabber/parser.c Thu Feb 19 14:52:09 2004 +0000 +++ b/src/protocols/jabber/parser.c Thu Feb 19 14:57:41 2004 +0000 @@ -49,6 +49,8 @@ js->stream_id = g_strdup(attrib_values[i]); } } + if(js->protocol_version == JABBER_PROTO_0_9) + js->auth_type = JABBER_AUTH_IQ_AUTH; if(js->state == JABBER_STREAM_INITIALIZING) jabber_stream_set_state(js, JABBER_STREAM_AUTHENTICATING); diff -r bc850664b559 -r dd6fe7d965aa src/protocols/jabber/presence.c --- a/src/protocols/jabber/presence.c Thu Feb 19 14:52:09 2004 +0000 +++ b/src/protocols/jabber/presence.c Thu Feb 19 14:57:41 2004 +0000 @@ -39,10 +39,13 @@ { JabberChat *chat = val; xmlnode *presence = user_data; - char *chat_jid = key; + const char *chat_bare_jid = key; + char *chat_full_jid = g_strdup_printf("%s/%s", chat_bare_jid, + gaim_conv_chat_get_nick(GAIM_CONV_CHAT(chat->conv))); - xmlnode_set_attrib(presence, "to", chat_jid); + xmlnode_set_attrib(presence, "to", chat_full_jid); jabber_send(chat->js, presence); + g_free(chat_full_jid); } void jabber_presence_fake_to_self(JabberStream *js, const char *away_state, const char *msg) {