Minor xml fix to xmpp server
authorArt Cancro <ajc@citadel.org>
Wed, 28 Nov 2007 04:10:52 +0000 (04:10 +0000)
committerArt Cancro <ajc@citadel.org>
Wed, 28 Nov 2007 04:10:52 +0000 (04:10 +0000)
citadel/modules/jabber/serv_xmpp.c
citadel/modules/jabber/serv_xmpp.h
citadel/modules/jabber/xmpp_sasl_service.c

index 90425064ddcb2a7ee7e930b26ae38700d1c09045..e24f1869b5581436aa45659856b22882d88ad7dc 100644 (file)
@@ -122,6 +122,9 @@ void xmpp_xml_start(void *data, const char *supplied_el, const char **attr) {
                        if (!strcasecmp(attr[i], "type")) iqtype = attr[i+1];
                        if (!strcasecmp(attr[i], "id")) iqid = attr[i+1];
                }
+               if (iqtype != NULL) {
+                       safestrncpy(XMPP->iq_type, iqtype, sizeof XMPP->iq_type);
+               }
                if ((iqtype != NULL) && (iqid != NULL)) {
                        if (!strcasecmp(iqtype, "set")) {
                                safestrncpy(XMPP->iq_bind_id, iqid, sizeof XMPP->iq_bind_id);
@@ -165,10 +168,17 @@ void xmpp_xml_end(void *data, const char *supplied_el) {
 
        else if (!strcasecmp(el, "iq")) {
 
+               /*
+                * iq type="get"
+                */
+               if (!strcasecmp(XMPP->iq_type, "get")) {
+                       lprintf(CTDL_DEBUG, "\e[32m DISCO DUCK! \e[0m\n");
+               }
 
-               /* If this <iq> stanza was a "bind" attempt, process it ... */
-
-               if ( (!IsEmptyStr(XMPP->iq_bind_id)) && (!IsEmptyStr(XMPP->iq_client_resource)) ) {
+               /*
+                * If this <iq> stanza was a "bind" attempt, process it ...
+                */
+               else if ( (!IsEmptyStr(XMPP->iq_bind_id)) && (!IsEmptyStr(XMPP->iq_client_resource)) ) {
 
                        /* Generate the "full JID" of the client resource */
 
@@ -202,7 +212,7 @@ void xmpp_xml_end(void *data, const char *supplied_el) {
                /* Now clear these fields out so they don't get used by a future stanza */
                XMPP->iq_bind_id[0] = 0;
                XMPP->iq_client_resource[0] = 0;
-               XMPP->iq_session = 1;
+               XMPP->iq_session = 0;
        }
 
        else if (!strcasecmp(el, "auth")) {
index c5fb645c9e441b282657ec9d0cd93722c5ade098..7a902fcd6f9e36e869dfb3abf0c59d36a99f794a 100644 (file)
@@ -11,6 +11,7 @@ struct citxmpp {                      /* Information about the current session */
        int chardata_alloc;
        char client_jid[256];           /* "full JID" of the client */
 
+       char iq_type[256];
        char iq_bind_id[256];           /* for <iq> stanzas */
        char iq_client_resource[256];   /* resource name requested by the client */
        int iq_session;                 /* nonzero == client is requesting a session */
index 9e9aef6ff666328178c7cba8f0438666b2baf8d1..4803fca026fccbbc46ca20ea111c8ef107b0a450 100644 (file)
@@ -99,7 +99,7 @@ void xmpp_output_auth_mechs(void) {
  */
 void xmpp_sasl_auth(char *sasl_auth_mech, char *authstring) {
 
-       if (strcasecmp(XMPP->sasl_auth_mech, "PLAIN")) {
+       if (strcasecmp(sasl_auth_mech, "PLAIN")) {
                cprintf("<failure xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">");
                cprintf("<invalid-mechanism/>");
                cprintf("</failure>");