Author: ArcRiley
Date: 2009-02-26 12:18:33 -0500 (Thu, 26 Feb 2009)
New Revision: 1524

Removed:
   trunk/concordance/src/_core/__init__.h
   trunk/concordance/src/nodes/Session.c
   trunk/concordance/src/nodes/Session.h
Modified:
   trunk/concordance/src/_core/__init__.c
   trunk/concordance/src/services/Service.c
   trunk/concordance/src/sockets/__init__.c
   trunk/concordance/src/utils.c
Log:
Setting svn:keywords, doing some cleanup on src/ tree


Modified: trunk/concordance/src/_core/__init__.c
===================================================================
--- trunk/concordance/src/_core/__init__.c      2009-02-26 07:14:05 UTC (rev 
1523)
+++ trunk/concordance/src/_core/__init__.c      2009-02-26 17:18:33 UTC (rev 
1524)
@@ -19,9 +19,8 @@
 # $Id$
 */
 
-#include "__init__.h"
+#include "concordance.h"
 
-
 static gpointer
 _core_loop(gpointer n) {
   /* create and run the GMainLoop, terminates thread on g_main_loop_quit()

Deleted: trunk/concordance/src/_core/__init__.h
===================================================================
--- trunk/concordance/src/_core/__init__.h      2009-02-26 07:14:05 UTC (rev 
1523)
+++ trunk/concordance/src/_core/__init__.h      2009-02-26 17:18:33 UTC (rev 
1524)
@@ -1,27 +0,0 @@
-/*
-# Concordance XMPP Service Framework
-#
-# Copyright (C) 2009 Copyleft Games Group
-#
-#  This program is free software; you can redistribute it and/or modify
-#  it under the terms of the GNU Affero General Public License as published
-#  by the Free Software Foundation, either version 3 of the License, or
-#  (at your option) any later version.
-#
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#  GNU Affero General Public License for more details.
-#
-#  You should have received a copy of the GNU Affero General Public License
-#  along with this program; if not, see http://www.gnu.org/licenses
-#
-# $Id$
-*/
-
-#ifndef _CORE_INIT_H
-#define _CORE_INIT_H
-
-#include "utils.h"
-
-#endif

Deleted: trunk/concordance/src/nodes/Session.c
===================================================================
--- trunk/concordance/src/nodes/Session.c       2009-02-26 07:14:05 UTC (rev 
1523)
+++ trunk/concordance/src/nodes/Session.c       2009-02-26 17:18:33 UTC (rev 
1524)
@@ -1,836 +0,0 @@
-/*
-# Concordance XMPP Service Framework
-#
-# Copyright (C) 2009 Copyleft Games Group
-#
-#  This program is free software; you can redistribute it and/or modify
-#  it under the terms of the GNU Affero General Public License as published
-#  by the Free Software Foundation, either version 3 of the License, or
-#  (at your option) any later version.
-#
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#  GNU Affero General Public License for more details.
-#
-#  You should have received a copy of the GNU Affero General Public License
-#  along with this program; if not, see http://www.gnu.org/licenses
-#
-# $Id$
-*/
-
-#include "Session.h"
-
-static gboolean    concordSession_gioRead        (GIOChannel*, GIOCondition,
-                                                  gpointer);
-static gboolean    concordSession_gioWrite       (GIOChannel*, GIOCondition,
-                                                  gpointer);
-static void        concordSession_xmlStart       (gpointer, const XML_Char*,
-                                                  const XML_Char**);
-static void        concordSession_xmlEnd         (gpointer, const XML_Char*);
-static void        concordSession_xmlCharData    (gpointer, const XML_Char*,
-                                                  gint);
-static void        concordSession_reply_streamError
-                                                 (concordSession_Data*,
-                                                  gchar*, gchar*);
-
-
-                                                                          /*\
-cdef class Core :                                                         \*/
-  static char concordSession_Doc[] = "Test";
-
-  static PyObject*
-  concordSession_new(PyTypeObject* type, PyObject* args, PyObject* kwds) {/*\
-    cdef :                                                                \*/
-      concordSession_Object* self;
-
-    /* allocate self */
-    self = (concordSession_Object*) type->tp_alloc(type, 0);
-
-    if (self)
-      self->data = NULL;
-
-    /* return either the new instance or NULL */
-    return (PyObject*) self;
-  }
-
-
-  static int
-  concordSession_init(PyObject* s, PyObject* args, PyObject* kwds) {      /*\
-    cdef :                                                                \*/
-      concordSession_Object*  self = (concordSession_Object*) s;
-
-    /* accept no arguments (yet)
-
-       From http://docs.python.org/3.0/c-api/arg.html :
-         :  The list of format units ends here; the string after the colon is
-            used as the function name in error messages (the “associated
-            value” of the exception that PyArg_ParseTuple raises).
-    */
-    if (!PyArg_ParseTuple(args, "|:Session"))
-      return -1;
-
-    return 0;
-  }
-
-
-  static void
-  concordSession_dealloc(concordSession_Object* self) {                   /*\
-    cdef :                                                                \*/
-
-    if (self->data) {
-      /* lock data mutex, clear ourselves from it, then unlock
-
-         void           g_mutex_lock             (GMutex *mutex);
-         void           g_mutex_unlock           (GMutex *mutex);
-      */
-      g_mutex_lock(self->data->lock);
-      self->data->self = NULL;
-      g_mutex_unlock(self->data->lock);
-    }
-
-    PyObject_Del(self);
-  }
-
-
-  static PyObject*
-  concordSession_getattro(concordSession_Object* self, PyObject* key) {
-    return PyObject_GenericGetAttr((PyObject*) self, key);
-  }
-
-
-  static int
-  concordSession_setattro(concordSession_Object* self, PyObject* key,
-                          PyObject* value) {
-    return PyObject_GenericSetAttr((PyObject*) self, key, value);
-  }
-
-  /*
-  #
-  ###########################################################################
-  #
-  # MainLoop thread functions (nogil)
-  #                                                                        */
-
-  concordSession_Data*
-  concordSession_create(concordCore_Object* core, gint socket) {          /*\
-    cdef :                                                                \*/
-      concordSession_Data* session;
-
-    /* create new session, create lock, and store the pointer to parent Core
-
-       gpointer         g_malloc                 (gsize n_bytes);
-       GMutex *         g_mutex_new              ();
-    */
-    session = g_malloc(sizeof(concordSession_Data));
-    session->self = NULL;
-    session->lock = g_mutex_new();
-    session->core = core;
-
-    /* create channel and add it to our context watchlist
-
-       GIOChannel*      concordAddSocket         (gint fd,
-                                                  GIOCondition condition,
-                                                  GSourceFunc callback,
-                                                  gpointer data,
-                                                  GMainContext* context);
-       GIOStatus        g_io_channel_set_encoding(GIOChannel *channel,
-                                                  const gchar *encoding,
-                                                  GError **error);
-       void             g_io_channel_set_buffered(GIOChannel *channel,
-                                                  gboolean buffered);
-    */
-    session->chan = concordAddSocket(socket, G_IO_IN | G_IO_HUP,
-                                     (GSourceFunc) concordSession_gioRead,
-                                     (gpointer) session, core->context);
-    g_io_channel_set_encoding(session->chan, NULL, NULL);
-    g_io_channel_set_buffered(session->chan, FALSE);
-
-    /* initialize session strings
-
-       GString*         g_string_new             (const gchar *init);
-    */
-    session->wbuff = g_string_new("");      /* write buffer */
-    session->ebuff = g_string_new("");      /* element buffer */
-    session->efrom = g_string_new("");      /* element origin */
-    session->eto   = g_string_new("");      /* element destination */
-
-    /* initialize session state */
-    session->state = CONCORD_E_OPEN;
-    session->depth = 0;
-
-    /* create the XML parser for this session
-
-       XML_Parser       XML_ParserCreateNS       (const XML_Char *encoding
-                                                  XML_Char sep);
-       void             XML_SetUserData          (XML_Parser parser,
-                                                  void *userData);
-       void             XML_SetElementHandler    (XML_Parser parser,
-                                                  XML_StartElementHandler 
start,
-                                                  XML_EndElementHandler end);
-       void             XML_SetCharacterDataHandler
-                                                 (XML_Parser parser,
-                                                  XML_CharacterDataHandler);
-    */
-    session->pars = XML_ParserCreateNS(NULL, 32); /* space is separator*/
-    XML_SetUserData(session->pars, session);
-    XML_SetElementHandler(session->pars, concordSession_xmlStart,
-                          concordSession_xmlEnd);
-    XML_SetCharacterDataHandler(session->pars, concordSession_xmlCharData);
-
-    /* lookup hostname
-
-       int getnameinfo(const struct sockaddr *sa, socklen_t salen,
-                       char *host, size_t hostlen,
-                       char *serv, size_t servlen, int flags);
-
-       ret = getnameinfo(&addr, addrlen, session->host, 255, NULL, 0, 0);
-
-       NOTE : this needs to be moved to a GMainLoop function so DNS lookups
-       won't block
-    */
-
-    /* return the new session data pointer */
-    return session;
-  }
-
-
-  static void
-  concordSession_destroy(concordSession_Data* session) {                  /*\
-    cdef :                                                                \*/
-
-    /* free the mutex lock
-
-       void             g_mutex_free             (GMutex *mutex);
-    */
-    g_mutex_free(session->lock);
-  }
-
-
-  void
-  concordSession_send(concordSession_Data* session, gchar* str,
-                      gint len) {                                         /*\
-    cdef :                                                                \*/
-      guint sent;
-
-    /* make sure the session write buffer is empty first */
-    if (session->wbuff->len == 0) {
-      /* send as much data as the channel will take
-
-         GIOStatus      g_io_channel_write_chars (GIOChannel *channel,
-                                                  const gchar *buf,
-                                                  gssize count,
-                                                  gsize *bytes_written,
-                                                  GError **error);
-      */
-      g_io_channel_write_chars(session->chan, str, len, &sent, NULL);
-
-
-      if (len != sent) {
-        /* append unsent string to the session write buffer
-
-           GString*     g_string_append_len      (GString *string,
-                                                  const gchar *val,
-                                                  gssize len);
-        */
-        session->wbuff = g_string_append_len(session->wbuff,
-                                             str+sent, len-sent);
-
-        /* add a watch to send more when the channel is ready for it
-
-           gint         concordAddWatch          (GIOChannel* channel,
-                                                  GIOCondition condition,
-                                                  GSourceFunc callback,
-                                                  gpointer data,
-                                                  GMainContext* context)
-        */
-        concordAddWatch(session->chan, G_IO_OUT,
-                        (GSourceFunc) concordSession_gioWrite,
-                        (gpointer) session, session->core->context);
-      }
-    }
-    else
-      /* There is already data waiting to be sent, buffer this directly
-         and let the existing watch send it when ready
-
-         see above for g_string_append_len prototype
-      */
-      session->wbuff = g_string_append_len(session->wbuff, str, len);
-  }
-
-  /*
-  #
-  ###########################################################################
-  #
-  # Channel Callbacks
-  #                                                                        */
-
-  static gboolean
-  concordSession_gioRead(GIOChannel* channel, GIOCondition condition,
-                         gpointer data) {                                 /*\
-    cdef :                                                                \*/
-      concordSession_Data*  session = (concordSession_Data*) data;
-      GIOStatus             status;
-      gchar                 buff[4096];
-      guint                 buff_len = 0;
-
-    if (condition == G_IO_IN) {
-
-      /* read channel to parser
-
-         GIOStatus      g_io_channel_read_chars  (GIOChannel *channel,
-                                                  gchar *buf,
-                                                  gsize count,
-                                                  gsize *bytes_read,
-                                                  GError **error);
-         XML_Status     XML_Parse                (XML_Parser parser,
-                                                  const char *s,
-                                                  int len,
-                                                  int isFinal);
-      */
-      status = g_io_channel_read_chars(channel, buff, 4096, &buff_len, NULL);
-      if (status == G_IO_STATUS_NORMAL && buff_len > 0) {
-        /* parse XML data
-
-           XML_Parse will execute the appropriate callback(s) found in the
-           "XML Handlers" section below.  If the stream has been closed
-           the session->state will be reset to CONCORD_E_CLOSE (== FALSE)
-           to indicate that the session needs to get wrapped up.
-        */
-        if (XML_Parse(session->pars, buff, buff_len, FALSE) && session->state)
-          /* return true so GMainLoop will continue watching this channel */
-          return TRUE;
-      }
-    }
-
-    /* G_IO_EOF, read EOF, or an unknown channel error has occured
-
-       GIOStatus        g_io_channel_shutdown    (GIOChannel *channel,
-                                                  gboolean flush,
-                                                  GError **err);
-    */
-    g_io_channel_shutdown(channel, FALSE, NULL);
-
-
-    /* close out parser cleanly
-
-       void             XML_ParserFree           (XML_Parser parser);
-    */
-    XML_Parse(session->pars, NULL, 0, TRUE);
-    XML_ParserFree(session->pars);
-
-
-    /* return false so GMainLoop will stop watching this channel */
-    return FALSE;
-  }
-
-
-  static gboolean
-  concordSession_gioWrite(GIOChannel* channel, GIOCondition condition,
-                          gpointer data) {                                /*\
-    cdef :                                                                \*/
-      concordSession_Data*  session = (concordSession_Data*) data;
-      gint                  sent;
-
-    /* send as much data as the channel will take
-
-       GIOStatus        g_io_channel_write_chars (GIOChannel *channel,
-                                                  const gchar *buf,
-                                                  gssize count,
-                                                  gsize *bytes_written,
-                                                  GError **error);
-    */
-    g_io_channel_write_chars(channel, session->wbuff->str, session->wbuff->len,
-                             &sent, NULL);
-
-    /* erase what we've just written
-
-       GString*         g_string_erase           (GString *string,
-                                                  gssize pos,
-                                                  gssize len);
-    */
-    session->wbuff = g_string_erase(session->wbuff, 0, sent);
-
-    /* keep this event alive only if there's more in the buffer to write */
-    return (session->wbuff->len != 0);
-  }
-
-  /*
-  #
-  ###########################################################################
-  #
-  # Element responses
-  #                                                                        */
-  static void
-  concordSession_reply_stream(concordSession_Data* session,
-                              gchar* version) {                           /*\
-    cdef :                                                                \*/
-      concordCore_Object*   core = session->core;
-      GString*              buff;
-      gchar*                error = NULL;
-
-    /* initialize response buffer
-
-       GString*         g_string_new             (const gchar *init);
-    */
-    buff = g_string_new("");
-
-    /* init <stream:stream>, <stream:features>, and <mechanisms>
-
-       void             g_string_printf          (GString *string,
-                                                  const gchar *format,
-                                                  ...);
-    */
-    g_string_printf(buff,
-                    "<?xml version='1.0' encoding='UTF-8'?>"
-                    "<stream:stream xmlns='jabber:client'"
-                    " xmlns:stream='http://etherx.jabber.org/streams'"
-                    " from='%s' id='%s'%s>",
-                    "selket.apogean.org", "concordance-1",
-                    conSession_getVersion(version, &error));
-
-    if (error) {
-      /* a stream error has taken place!
-
-         send the <stream:stream> element we have so far, free the buffer,
-         then pass control over concordSession_reply_streamError for the rest.
-      */
-      concordSession_send(session, buff->str, buff->len);
-      g_string_free(buff, TRUE);
-      concordSession_reply_streamError(session, error, "");
-      return;
-    }
-
-    /* open stream:features and mechanisms element */
-    buff = g_string_append(buff, "<stream:features><mechanisms"
-                                 " xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>");
-
-    /* add a <mechanism> element for each supported SASL mechanism
-
-       int              gsasl_server_support_p   (Gsasl* ctx,
-                                                  const char* name);
-       GString*         g_string_append          (GString *string,
-                                                  const gchar *val);
-    */
-    if (gsasl_server_support_p(core->saslCntx, "DIGEST-MD5"))
-      buff = g_string_append(buff, "<mechanism>DIGEST-MD5</mechanism>");
-    if (gsasl_server_support_p(core->saslCntx, "PLAIN"))
-      buff = g_string_append(buff, "<mechanism>PLAIN</mechanism>");
-
-    /* close <mechanisms> and <stream:features>, then send buffer */
-    buff = g_string_append(buff, "</mechanisms></stream:features>");
-    concordSession_send(session, buff->str, buff->len);
-
-    /* free response buffer before returning
-
-       gchar*           g_string_free            (GString *string,
-                                                  gboolean free_segment);
-    */
-    g_string_free(buff, TRUE);
-  }
-
-
-  static void
-  concordSession_reply_streamError(concordSession_Data* session,
-                                   gchar* err, gchar* txt) {              /*\
-    cdef :                                                                \*/
-      GString*              buff;
-
-    /* initialize response buffer
-
-       GString*         g_string_new             (const gchar *init);
-    */
-    buff = g_string_new("");
-
-    /* printf error and send it
-
-       void             g_string_printf          (GString *string,
-                                                  const gchar *format,
-                                                  ...);
-    */
-    g_string_printf(buff,
-                    "<stream:error><%s"
-                    " xmlns='urn:ietf:params:xml:ns:xmpp-streams'/>"
-                    "<text xmlns='urn:ietf:params:xml:ns:xmpp-streams'>"
-                    "%s</text></stream:error></stream:stream>",
-                    err, txt);
-    concordSession_send(session, buff->str, buff->len);
-
-    /* CLOSE the session state so the socket will close properly */
-    session->state = CONCORD_E_CLOSE;
-
-    /* free response buffer before returning
-
-       gchar*           g_string_free            (GString *string,
-                                                  gboolean free_segment);
-    */
-    g_string_free(buff, TRUE);
-  }
-
-
-  static void
-  concordSession_reply_saslChallenge(concordSession_Data* session) {      /*\
-    cdef :                                                                \*/
-
-
-    return;
-    /*
-       gchar*           g_base64_encode          (const guchar *data,
-                                                  gsize len);
-    */
-
-
-
-    /*g_string_printf(buff,
-                    "<challenge xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>"
-                    "%s</challenge>", ""); */
-  }
-
-  static void
-  concordSession_reply_saslFailure(concordSession_Data* session,
-                                   gchar* failure) {                      /*\
-    cdef :                                                                \*/
-      GString* buff;
-
-    /* printf failure to a GString, then send it
-
-       GString*         g_string_new             (const gchar *init);
-       void             g_string_printf          (GString *string,
-                                                  const gchar *format,
-                                                  ...);
-       gchar*           g_string_free            (GString *string,
-                                                  gboolean free_segment);
-    */
-    buff = g_string_new("");
-    g_string_printf(buff, "<failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>"
-                          "%s</failure>", failure);
-    concordSession_send(session, buff->str, buff->len);
-    g_string_free(buff, TRUE);
-  }
-
-  /*
-  #
-  ###########################################################################
-  #
-  # XML Callbacks
-  #                                                                        */
-  static void
-  concordSession_xmlStart(gpointer data, const XML_Char* name,
-                          const XML_Char** atts) {                        /*\
-    cdef :                                                                \*/
-      concordSession_Data*  session = (concordSession_Data*) data;
-      gchar**               element;
-      gint                  i;
-      gchar*                attr;
-
-    /* split name by namespace and element
-
-    gchar**             g_strsplit               (const gchar *string,
-                                                  const gchar *delimiter,
-                                                  gint max_tokens);
-    */
-    element = g_strsplit(name, " ", 2);
-
-    /* this from http://www.xml.com/pub/a/1999/09/expat/index.html?page=2 */
-    for (i = 0; i < session->depth; i++)
-      printf("  ");
-
-    printf("<%s xmlns='%s'", element[1], element[0]);
-    for (i = 0; atts[i]; i += 2)
-      printf(" %s='%s'", atts[i], atts[i + 1]);
-    printf(">\n");
-
-    switch (session->depth) {
-      /* match element by depth, namespace, and finally element name
-
-         gint           g_ascii_strcasecmp       (const gchar* str1,
-                                                  const gchar* str2);
-         Returns -1, 0 or 1, if str1 is <, == or > than str2.
-      */
-      case 0 : {
-        /* only stream:stream element is valid at depth == 0
-
-           if anything else is sent, session->state will be changed from
-           CONCORD_E_OPEN to CONCORD_E_CLOSE and the session will be closed
-           in the concordCore_sessionRead just after the XMLParse call (above).
-        */
-        if (g_ascii_strcasecmp(name,
-                               "http://etherx.jabber.org/streams stream") == 0)
-          concordSession_reply_stream(session,
-                                      concordSearchAttributes(atts, 
"version"));
-        else
-          session->state = CONCORD_E_CLOSE;
-        break;
-      }
-
-      case 1 : {
-        if (g_ascii_strcasecmp(element[0], "jabber:client") == 0) {
-          /* ensure it's a valid element for the jabber:client namespace
-
-             see http://xmpp.org/rfcs/rfc3920.html#def
-          */
-          if (g_ascii_strcasecmp(element[1], "iq") == 0 ||
-              g_ascii_strcasecmp(element[1], "message") == 0 ||
-              g_ascii_strcasecmp(element[1], "presence") == 0) {
-            /* set the client mode */
-            session->state = CONCORD_E_CLIENT;
-
-            /* check and copy "to" and "from" attributes
-
-               GString* g_string_assign          (GString *string,
-                                                  const gchar *rval);
-            */
-            if (!(attr = concordSearchAttributes(atts, "to")))
-              attr = "";
-            session->eto = g_string_assign(session->eto, attr);
-            if (!(attr = concordSearchAttributes(atts, "from")))
-              attr = "";
-            session->efrom = g_string_assign(session->efrom, attr);
-            printf("--------- from: %s to: %s\n",
-                   session->efrom->str, session->eto->str);
-
-            /* copy element and attributes to ebuff
-
-               void     g_string_printf          (GString *string,
-                                                  const gchar *format,
-                                                  ...);
-               void     g_string_append_printf   (GString *string,
-                                                  const gchar *format,
-                                                  ...);
-            */
-            g_string_printf(session->ebuff, "<%s xmlns='%s'",
-                            element[1], element[0]);
-            for (i = 0; atts[i]; i += 2)
-              g_string_append_printf(session->ebuff, " %s='%s'",
-                                     atts[i], atts[i+1]);
-            g_string_append_printf(session->ebuff, ">");
-          }
-          else
-            concordSession_reply_streamError(session, "invalid-xml",
-                                             "invalid element for"
-                                             "jabber:client namespace");
-        }
-        if (g_ascii_strcasecmp(element[0],
-                               "urn:ietf:params:xml:ns:xmpp-sasl") == 0) {
-          if (g_ascii_strcasecmp(element[1], "auth") == 0) {
-            gchar* mec = concordSearchAttributes(atts, "mechanism");
-            if (mec && gsasl_server_support_p(session->core->saslCntx, mec)) {
-              /* initiate server session
-
-                 int    gsasl_server_start       (Gsasl* ctx,
-                                                  const char* mech,
-                                                  Gsasl_session** sctx);
-              */
-              printf("------ init %s mechanism\n", mec);
-              gsasl_server_start(session->core->saslCntx, mec,
-                                 &session->sctx);
-              session->state = CONCORD_E_SASL;
-            }
-            else {
-              concordSession_reply_saslFailure(session,
-                                               "<invalid-mechanism/>");
-              session->state = CONCORD_E_CLOSE;
-            }
-          }
-
-          /* remaining: response, abort */
-        }
-
-        /* other depth=1 namespaces */
-        break;
-      }
-
-      default : {
-        /* process inner tags depending on state */
-        if (session->state == CONCORD_E_CLIENT) {
-          /* copy element and attributes to ebuff
-
-             void       g_string_append_printf   (GString *string,
-                                                  const gchar *format,
-                                                  ...);
-          */
-          g_string_append_printf(session->ebuff, "<%s xmlns='%s'",
-                                 element[1], element[0]);
-          for (i = 0; atts[i]; i += 2)
-            g_string_append_printf(session->ebuff, " %s='%s'",
-                                   atts[i], atts[i+1]);
-          g_string_append_printf(session->ebuff, ">");
-        }
-        break;
-      }
-    }
-
-    /* increase XML depth regardless of element */
-    session->depth++;
-
-    /* free the element string array
-
-       void             g_strfreev               (gchar **str_array);
-    */
-    g_strfreev(element);
-  }
-
-
-  static void
-  concordSession_xmlEnd(gpointer data, const XML_Char* name) {            /*\
-    cdef :                                                                \*/
-      concordSession_Data*  session = (concordSession_Data*) data;
-      gchar**               element;
-      gint                  i;
-
-    /* decrease XML depth */
-    session->depth--;
-
-
-    /* split name by namespace and element
-
-    gchar**             g_strsplit               (const gchar *string,
-                                                  const gchar *delimiter,
-                                                  gint max_tokens);
-    */
-    element = g_strsplit(name, " ", 2);
-
-    for (i = 0; i < session->depth; i++)
-      printf("  ");
-    printf("</%s>\n", element[1]);
-
-    switch (session->depth) {
-      case 0 : {
-        /* close session when </stream:stream> is sent */
-        session->state = CONCORD_E_CLOSE;
-        break;
-      }
-      case 1 : {
-        switch (session->state) {
-          case CONCORD_E_CLIENT : {
-            /* copy final element close to ebuff
-
-               void     g_string_append_printf   (GString *string,
-                                                  const gchar *format,
-                                                  ...);
-            */
-            g_string_append_printf(session->ebuff, "</%s>", element[1]);
-            concordCore_queuePush(session->core, session);
-            break;
-          }
-          case CONCORD_E_SASL : {
-            concordSession_reply_saslChallenge(session);
-            break;
-          }
-        }
-
-        /* reset the element strings when returning to depth 1
-
-           GString*     g_string_assign          (GString *string,
-                                                  const gchar *rval);
-        */
-        session->ebuff = g_string_assign(session->ebuff, "");
-        session->efrom = g_string_assign(session->efrom, "");
-        session->eto   = g_string_assign(session->eto,   "");
-
-        break;
-      }
-      default : {
-        if (session->state == CONCORD_E_CLIENT) {
-          /* copy element close to ebuff
-
-             void       g_string_append_printf   (GString *string,
-                                                  const gchar *format,
-                                                  ...);
-          */
-          g_string_append_printf(session->ebuff, "</%s>", element[1]);
-        }
-        break;
-      }
-    }
-
-    /* free the element string array before returning
-
-       void             g_strfreev               (gchar **str_array);
-    */
-    g_strfreev(element);
-  }
-
-
-  static void
-  concordSession_xmlCharData(gpointer data, const XML_Char* str,
-                             gint str_len) {                              /*\
-    cdef :                                                                \*/
-      concordSession_Data*  session = (concordSession_Data*) data;
-      gint                  i;
-      gchar*                strn;
-
-    /* output to stdout for debugging */
-    strn = g_strndup(str, str_len);
-    for (i = 0; i < session->depth; i++)
-      printf("  ");
-    printf("\"%s\"\n", strn);
-    g_free(strn);
-
-    if (session->state == CONCORD_E_OPEN)
-      /* character data should be ignored at the stream level */
-      return;
-
-    /* append character data to element buffer
-
-       GString*         g_string_append_len      (GString *string,
-                                                  const gchar *val,
-                                                  gssize len);
-    */
-    session->ebuff = g_string_append_len(session->ebuff, str, str_len);
-  }
-
-  /*
-  #
-  ###########################################################################
-  #
-  # global structs
-  #                                                                        */
-
-  static PyMethodDef concordSession_Methods[] = {
-    { NULL, NULL },     /* sentinel */
-  };
-
-  PyTypeObject concordSession_Type = {
-    PyVarObject_HEAD_INIT(NULL, 0)
-    "concordance.Session",                       /*tp_name*/
-    sizeof(concordSession_Object),               /*tp_basicsize*/
-    0,                                           /*tp_itemsize*/
-    /* methods */
-    (destructor) concordSession_dealloc,         /*tp_dealloc*/
-    0,                                           /*tp_print*/
-    (getattrfunc) 0,                             /*tp_getattr*/
-    (setattrfunc) 0,                             /*tp_setattr*/
-    0,                                           /*tp_compare*/
-    0,                                           /*tp_repr*/
-    0,                                           /*tp_as_number*/
-    0,                                           /*tp_as_sequence*/
-    0,                                           /*tp_as_mapping*/
-    0,                                           /*tp_hash*/
-    0,                                           /*tp_call*/
-    0,                                           /*tp_str*/
-    (getattrofunc) concordSession_getattro,      /*tp_getattro*/
-    (setattrofunc) concordSession_setattro,      /*tp_setattro*/
-    0,                                           /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,    /*tp_flags*/
-    concordSession_Doc,                          /*tp_doc*/
-    0,                                           /*tp_traverse*/
-    0,                                           /*tp_clear*/
-    0,                                           /*tp_richcompare*/
-    0,                                           /*tp_weaklistoffset*/
-    0,                                           /*tp_iter*/
-    0,                                           /*tp_iternext*/
-    concordSession_Methods,                      /*tp_methods*/
-    0,                                           /*tp_members*/
-    0,                                           /*tp_getset*/
-    0,                                           /*tp_base*/
-    0,                                           /*tp_dict*/
-    0,                                           /*tp_descr_get*/
-    0,                                           /*tp_descr_set*/
-    0,                                           /*tp_dictoffset*/
-    concordSession_init,                         /*tp_init*/
-    0,                                           /*tp_alloc*/
-    concordSession_new,                          /*tp_new*/
-    0,                                           /*tp_free*/
-    0,                                           /*tp_is_gc*/
-  };

Deleted: trunk/concordance/src/nodes/Session.h
===================================================================
--- trunk/concordance/src/nodes/Session.h       2009-02-26 07:14:05 UTC (rev 
1523)
+++ trunk/concordance/src/nodes/Session.h       2009-02-26 17:18:33 UTC (rev 
1524)
@@ -1,51 +0,0 @@
-/*
-# Concordance XMPP Service Framework
-#
-# Copyright (C) 2009 Copyleft Games Group
-#
-#  This program is free software; you can redistribute it and/or modify
-#  it under the terms of the GNU Affero General Public License as published
-#  by the Free Software Foundation, either version 3 of the License, or
-#  (at your option) any later version.
-#
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#  GNU Affero General Public License for more details.
-#
-#  You should have received a copy of the GNU Affero General Public License
-#  along with this program; if not, see http://www.gnu.org/licenses
-#
-# $Id$
-*/
-
-#ifndef CONCORD_SESSION_H
-#define CONCORD_SESSION_H
-
-#include "__init__.h"
-#include "Core.h"
-
-
-/* __init__.h contains:
-     concordSession_Type
-     concordSession_Data
-     concordSession_Object
-*/
-
-
-enum concordSession_State {
-  CONCORD_E_CLOSE = 0,              /* close </stream>           */
-  CONCORD_E_OPEN,                   /* inside <stream>           */
-  CONCORD_E_CLIENT,                 /* <iq> <message> <presence> */
-  CONCORD_E_SASL,                   /* <auth> <response>         */
-};
-
-
-concordSession_Data*    concordSession_create    (concordCore_Object*, gint); 
-void                    concordSession_send      (concordSession_Data*,
-                                                  gchar*, gint);
-
-
-#define concordSession_Check(v)  (Py_TYPE(v) == &concordSession_Type)
-
-#endif


Property changes on: trunk/concordance/src/services/Service.c
___________________________________________________________________
Added: svn:keywords
   + Id


Property changes on: trunk/concordance/src/sockets/__init__.c
___________________________________________________________________
Added: svn:keywords
   + Id


Property changes on: trunk/concordance/src/utils.c
___________________________________________________________________
Added: svn:keywords
   + Id

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

Reply via email to