Author: ArcRiley
Date: 2009-01-08 01:59:24 -0500 (Thu, 08 Jan 2009)
New Revision: 1443

Modified:
   trunk/concordance/src/Core.c
Log:
  * added element chardata storage to new session String (ebuff)
  * renamed conCore_saslAuth to conCore_saslChallenge
  * getting ready to add Python callbacks


Modified: trunk/concordance/src/Core.c
===================================================================
--- trunk/concordance/src/Core.c        2009-01-08 06:57:15 UTC (rev 1442)
+++ trunk/concordance/src/Core.c        2009-01-08 06:59:24 UTC (rev 1443)
@@ -463,13 +463,13 @@
       g_io_channel_set_buffered(newSession->chan, FALSE);
 
 
-      /* initialize session write buffer
+      /* initialize session write and element buffers
 
          GString*       g_string_new             (const gchar *init);
       */
       newSession->wbuff = g_string_new("");
+      newSession->ebuff = g_string_new("");
 
-
       /* initialize session state */
       newSession->state = CON_E_OPEN;
       newSession->depth = 0;
@@ -701,10 +701,11 @@
 
 
   static void
-  conCore_saslAuth(conSession* session) {                                 /*\
+  conCore_saslChallenge(conSession* session) {                            /*\
     cdef :                                                                \*/
       conCoreObject*        self = session->core;
 
+    
     return; /* unfinished */
     /* gchar*           g_base64_encode          (const guchar *data,
                                                   gsize len);
@@ -758,6 +759,7 @@
            in the conCore_sessionRead just after the XMLParse call (above).
         */
         if (strcmp(name, "http://etherx.jabber.org/streams stream") == 0)
+          /* need to test version and other important attributes */
           conCore_stream(session);
         else
           session->state = CON_E_CLOSE;
@@ -775,7 +777,7 @@
               */
               printf("------ init %s mechanism\n", mech);
               gsasl_server_start(self->saslCntx, mech, &session->sctx);
-              session->state = CON_E_SASL_AUTH;
+              session->state = CON_E_SASL;
             }
             else {
               conCore_saslFailure(session, "<invalid-mechanism/>");
@@ -813,6 +815,9 @@
       gchar**               element;
       gint                  i;
 
+    /* decrease XML depth */
+    session->depth--;
+
     /* split name by namespace and element
 
     gchar**             g_strsplit               (const gchar *string,
@@ -821,18 +826,30 @@
     */
     element = g_strsplit(name, " ", 2);
 
-    /* decrease XML depth */
-    session->depth--;
+    if (session->depth == 1) {
+      switch (session->state) {
+        case CON_E_SASL :
+          conCore_saslChallenge(session);
+      }
 
+      /* reset the element chardata buffer when returning to stream depth
+
+         GString*       g_string_assign          (GString *string,
+                                                  const gchar *rval);
+      */
+      session->ebuff = g_string_assign(session->ebuff, "");
+    }
+    
+
     for (i = 0; i < session->depth; i++)
       printf("  ");
     printf("</%s>\n", element[1]);
 
-    /* free the element string array
+    /* free the element string array before returning
 
        void             g_strfreev               (gchar **str_array);
     */
-    g_strfreev(element);    
+    g_strfreev(element);
   }
 
 
@@ -844,11 +861,24 @@
       gint                  i;
       gchar*                strn;
 
+    /* This is used repeatedly in the following code
+
+       GString*         g_string_append_len      (GString *string,
+                                                  const gchar *val,
+                                                  gssize len);
+    */
+    switch (session->state) {
+      case CON_E_SASL :
+        /* append Base64 (p)response data to element buffer */
+        session->ebuff = g_string_append_len(session->ebuff, str, str_len);
+    }
+
     strn = g_strndup(str, str_len);
     for (i = 0; i < session->depth; i++)
       printf("  ");
     printf("\"%s\"\n", strn);
     g_free(strn);
+
   }
 
   /*

_______________________________________________
PySoy-SVN mailing list
PySoy-SVN@pysoy.org
http://www.pysoy.org/mailman/listinfo/pysoy-svn

Reply via email to