Author: ArcRiley Date: 2009-01-06 13:42:49 -0500 (Tue, 06 Jan 2009) New Revision: 1428
Modified: trunk/concordance/src/Core.c trunk/concordance/src/Core.h Log: Responds to xmpp-client stream start Modified: trunk/concordance/src/Core.c =================================================================== --- trunk/concordance/src/Core.c 2009-01-06 05:46:26 UTC (rev 1427) +++ trunk/concordance/src/Core.c 2009-01-06 18:42:49 UTC (rev 1428) @@ -57,11 +57,14 @@ static char* kwlist[] = {"client", "server", 0}; - #ifdef MS_WINDOWS + /* a little windows startup code */ + #ifdef MS_WINDOWS if (WSAStartup( MAKEWORD(2,2), &wsaData )){ printf("FAIL\n"); } - #endif + #endif + + /* set defaults for optional arguments 0.0.0.0 listens on every IP interface @@ -371,6 +374,10 @@ g_io_channel_set_buffered(newSession->chan, FALSE); + /* initialize channel mode to 0 */ + newSession->mode = 0; + + /* create the XML parser for this session XML_Parser XML_ParserCreate (const XML_Char *encoding); @@ -475,11 +482,29 @@ /* 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", name); + + printf("<%s", name); for (i = 0; atts[i]; i += 2) printf(" %s='%s'", atts[i], atts[i + 1]); - printf("\n"); + printf(">\n"); session->depth++; + + if (strcmp(name, "stream:stream")==0) { + /* write stream:stream tags + + 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, + "<?xml version='1.0' encoding=\"UTF-8\"?>", + 38, &i, NULL); + g_io_channel_write_chars(session->chan, + "<stream:stream from=\"selket.apogean.org\" id=\"1\" xmlns:stream=\"http://etherx.jabber.org/streams\" xmlns=\"jabber:client\">", + 118, &i, NULL); + } } @@ -488,9 +513,15 @@ cdef : \*/ conSession* session = (conSession*) s; conCoreObject* self = session->core; + gint i; /* temporary*/ + session->depth--; + for (i = 0; i < session->depth; i++) + printf(" "); + printf("</%s>\n", name); } + static PyMethodDef conCore_methods[] = { { NULL, NULL }, }; Modified: trunk/concordance/src/Core.h =================================================================== --- trunk/concordance/src/Core.h 2009-01-06 05:46:26 UTC (rev 1427) +++ trunk/concordance/src/Core.h 2009-01-06 18:42:49 UTC (rev 1428) @@ -53,15 +53,23 @@ GThread* thread; /* thread ID for mainloop thread */ } conCoreObject; +enum conSessionState { + CON_MODE_TLS = 1, /* TLS is enabled */ + CON_MODE_STREAM = 2, /* stream:stream is received */ +}; + typedef struct { PyObject* self; /* Session object for this or NULL */ conCoreObject* core; /* Core this session belongs to */ GIOChannel* chan; /* Glib IO channel for this session */ XML_Parser pars; /* expat parser for this session */ gchar host[256]; /* verified hostname or NULL */ + guint mode; /* current session state */ gint depth; /* temporary */ } conSession; + + PyTypeObject conCore_Type; #define conCoreObject_Check(v) (Py_TYPE(v) == &conCore_Type) _______________________________________________ PySoy-SVN mailing list PySoy-SVN@pysoy.org http://www.pysoy.org/mailman/listinfo/pysoy-svn