comparison libpurple/protocols/jabber/auth.c @ 26465:ae41d8e827e3

Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
author Paul Aurich <paul@darkrain42.org>
date Fri, 13 Mar 2009 02:26:45 +0000
parents 5f9a24d1c25e
children bc7fac8e2f79
comparison
equal deleted inserted replaced
26464:a4a5825fb1bb 26465:ae41d8e827e3
34 #include "auth.h" 34 #include "auth.h"
35 #include "jabber.h" 35 #include "jabber.h"
36 #include "iq.h" 36 #include "iq.h"
37 #include "notify.h" 37 #include "notify.h"
38 38
39 static void auth_old_result_cb(JabberStream *js, xmlnode *packet, 39 static void auth_old_result_cb(JabberStream *js, const char *from,
40 gpointer data); 40 JabberIqType type, const char *id,
41 xmlnode *packet, gpointer data);
41 42
42 gboolean 43 gboolean
43 jabber_process_starttls(JabberStream *js, xmlnode *packet) 44 jabber_process_starttls(JabberStream *js, xmlnode *packet)
44 { 45 {
45 xmlnode *starttls; 46 xmlnode *starttls;
564 _("Server does not use any supported authentication method")); 565 _("Server does not use any supported authentication method"));
565 } 566 }
566 #endif 567 #endif
567 } 568 }
568 569
569 static void auth_old_result_cb(JabberStream *js, xmlnode *packet, gpointer data) 570 static void auth_old_result_cb(JabberStream *js, const char *from,
570 { 571 JabberIqType type, const char *id,
571 const char *type = xmlnode_get_attrib(packet, "type"); 572 xmlnode *packet, gpointer data)
572 573 {
573 if(type && !strcmp(type, "result")) { 574 if (type == JABBER_IQ_RESULT) {
574 jabber_stream_set_state(js, JABBER_STREAM_CONNECTED); 575 jabber_stream_set_state(js, JABBER_STREAM_CONNECTED);
575 } else { 576 } else {
576 PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR; 577 PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
577 char *msg = jabber_parse_error(js, packet, &reason); 578 char *msg = jabber_parse_error(js, packet, &reason);
578 xmlnode *error; 579 xmlnode *error;
591 purple_connection_error_reason (js->gc, reason, msg); 592 purple_connection_error_reason (js->gc, reason, msg);
592 g_free(msg); 593 g_free(msg);
593 } 594 }
594 } 595 }
595 596
596 static void auth_old_cb(JabberStream *js, xmlnode *packet, gpointer data) 597 static void auth_old_cb(JabberStream *js, const char *from,
598 JabberIqType type, const char *id,
599 xmlnode *packet, gpointer data)
597 { 600 {
598 JabberIq *iq; 601 JabberIq *iq;
599 xmlnode *query, *x; 602 xmlnode *query, *x;
600 const char *type = xmlnode_get_attrib(packet, "type");
601 const char *pw = purple_connection_get_password(js->gc); 603 const char *pw = purple_connection_get_password(js->gc);
602 604
603 if(!type) { 605 if (type == JABBER_IQ_ERROR) {
604 purple_connection_error_reason (js->gc,
605 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
606 _("Invalid response from server."));
607 return;
608 } else if(!strcmp(type, "error")) {
609 PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR; 606 PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
610 char *msg = jabber_parse_error(js, packet, &reason); 607 char *msg = jabber_parse_error(js, packet, &reason);
611 purple_connection_error_reason (js->gc, reason, msg); 608 purple_connection_error_reason (js->gc, reason, msg);
612 g_free(msg); 609 g_free(msg);
613 } else if(!strcmp(type, "result")) { 610 } else if (type == JABBER_IQ_RESULT) {
614 query = xmlnode_get_child(packet, "query"); 611 query = xmlnode_get_child(packet, "query");
615 if(js->stream_id && xmlnode_get_child(query, "digest")) { 612 if(js->stream_id && xmlnode_get_child(query, "digest")) {
616 char *s, *hash; 613 char *s, *hash;
617 614
618 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:auth"); 615 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:auth");