Mercurial > pidgin.yaz
comparison libpurple/protocols/jabber/auth.c @ 20814:bde477ec6a71
Stop jabber setting wants_to_die itself. This involved plumbing disconnection
reasons into jabber_parse_error in a slightly dubious fashion. I'd appreciate
someone sanity-checking this rev.
author | Will Thompson <will.thompson@collabora.co.uk> |
---|---|
date | Tue, 09 Oct 2007 13:32:58 +0000 |
parents | 682543aced31 |
children | 7a7b3a425666 |
comparison
equal
deleted
inserted
replaced
20813:66e7b104b4ea | 20814:bde477ec6a71 |
---|---|
539 const char *type = xmlnode_get_attrib(packet, "type"); | 539 const char *type = xmlnode_get_attrib(packet, "type"); |
540 | 540 |
541 if(type && !strcmp(type, "result")) { | 541 if(type && !strcmp(type, "result")) { |
542 jabber_stream_set_state(js, JABBER_STREAM_CONNECTED); | 542 jabber_stream_set_state(js, JABBER_STREAM_CONNECTED); |
543 } else { | 543 } else { |
544 char *msg = jabber_parse_error(js, packet); | 544 PurpleDisconnectReason reason = PURPLE_REASON_NETWORK_ERROR; |
545 char *msg = jabber_parse_error(js, packet, &reason); | |
545 xmlnode *error; | 546 xmlnode *error; |
546 const char *err_code; | 547 const char *err_code; |
547 PurpleDisconnectReason reason = PURPLE_REASON_NETWORK_ERROR; | 548 |
548 | 549 /* FIXME: Why is this not in jabber_parse_error? */ |
549 if((error = xmlnode_get_child(packet, "error")) && | 550 if((error = xmlnode_get_child(packet, "error")) && |
550 (err_code = xmlnode_get_attrib(error, "code")) && | 551 (err_code = xmlnode_get_attrib(error, "code")) && |
551 !strcmp(err_code, "401")) { | 552 !strcmp(err_code, "401")) { |
552 js->gc->wants_to_die = TRUE; | |
553 reason = PURPLE_REASON_AUTHENTICATION_FAILED; | 553 reason = PURPLE_REASON_AUTHENTICATION_FAILED; |
554 /* Clear the pasword if it isn't being saved */ | 554 /* Clear the pasword if it isn't being saved */ |
555 if (!purple_account_get_remember_password(js->gc->account)) | 555 if (!purple_account_get_remember_password(js->gc->account)) |
556 purple_account_set_password(js->gc->account, NULL); | 556 purple_account_set_password(js->gc->account, NULL); |
557 } | 557 } |
571 if(!type) { | 571 if(!type) { |
572 purple_connection_error_reason (js->gc, PURPLE_REASON_NETWORK_ERROR, | 572 purple_connection_error_reason (js->gc, PURPLE_REASON_NETWORK_ERROR, |
573 _("Invalid response from server.")); | 573 _("Invalid response from server.")); |
574 return; | 574 return; |
575 } else if(!strcmp(type, "error")) { | 575 } else if(!strcmp(type, "error")) { |
576 char *msg = jabber_parse_error(js, packet); | 576 PurpleDisconnectReason reason = PURPLE_REASON_NETWORK_ERROR; |
577 purple_connection_error_reason (js->gc, PURPLE_REASON_NETWORK_ERROR, | 577 char *msg = jabber_parse_error(js, packet, &reason); |
578 msg); | 578 purple_connection_error_reason (js->gc, reason, msg); |
579 g_free(msg); | 579 g_free(msg); |
580 } else if(!strcmp(type, "result")) { | 580 } else if(!strcmp(type, "result")) { |
581 query = xmlnode_get_child(packet, "query"); | 581 query = xmlnode_get_child(packet, "query"); |
582 if(js->stream_id && xmlnode_get_child(query, "digest")) { | 582 if(js->stream_id && xmlnode_get_child(query, "digest")) { |
583 unsigned char hashval[20]; | 583 unsigned char hashval[20]; |
973 jabber_stream_set_state(js, JABBER_STREAM_REINITIALIZING); | 973 jabber_stream_set_state(js, JABBER_STREAM_REINITIALIZING); |
974 } | 974 } |
975 | 975 |
976 void jabber_auth_handle_failure(JabberStream *js, xmlnode *packet) | 976 void jabber_auth_handle_failure(JabberStream *js, xmlnode *packet) |
977 { | 977 { |
978 char *msg = jabber_parse_error(js, packet); | 978 PurpleDisconnectReason reason = PURPLE_REASON_NETWORK_ERROR; |
979 char *msg = jabber_parse_error(js, packet, &reason); | |
979 | 980 |
980 if(!msg) { | 981 if(!msg) { |
981 purple_connection_error_reason (js->gc, PURPLE_REASON_NETWORK_ERROR, | 982 purple_connection_error_reason (js->gc, PURPLE_REASON_NETWORK_ERROR, |
982 _("Invalid response from server.")); | 983 _("Invalid response from server.")); |
983 } else { | 984 } else { |
984 purple_connection_error_reason (js->gc, PURPLE_REASON_NETWORK_ERROR, | 985 purple_connection_error_reason (js->gc, reason, msg); |
985 msg); | |
986 g_free(msg); | 986 g_free(msg); |
987 } | 987 } |
988 } | 988 } |