Author: ArcRiley Date: 2009-01-05 20:25:35 -0500 (Mon, 05 Jan 2009) New Revision: 1424
Added: trunk/concordance/src/utils.c trunk/concordance/src/utils.h Modified: trunk/concordance/setup.py Log: new conAddSocket function made from Core socket/channel creation code Modified: trunk/concordance/setup.py =================================================================== --- trunk/concordance/setup.py 2009-01-04 18:59:25 UTC (rev 1423) +++ trunk/concordance/setup.py 2009-01-06 01:25:35 UTC (rev 1424) @@ -51,6 +51,7 @@ name = 'concordance', sources = ['src/__init__.c', 'src/Core.c', + 'src/utils.c', ], include_dirs = ['/usr/include/glib-2.0', '/usr/lib/glib-2.0/include', Added: trunk/concordance/src/utils.c =================================================================== --- trunk/concordance/src/utils.c (rev 0) +++ trunk/concordance/src/utils.c 2009-01-06 01:25:35 UTC (rev 1424) @@ -0,0 +1,60 @@ +/* +# Concordance XMPP/Jingle Server 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 "glib.h" + +GIOChannel* +conAddSocket(gint fd, GIOCondition condition, GSourceFunc callback, + gpointer data, GMainContext* context) { /*\ + cdef : \*/ + GIOChannel* newChannel; + GSource* newSource; + + /* create a new channel using an OS-dependent function + + GIOChannel* g_io_channel_win32_new_fd (gint fd); + GIOChannel* g_io_channel_unix_new (gint fd); + */ + #ifdef MS_WINDOWS + newChannel = g_io_channel_win32_new_socket(fd); + #else + newChannel = g_io_channel_unix_new(fd); + #endif + + /* add this channel to our context watch + + Note that this block is a replacement for g_io_add_watch() which + uses our own context rather than the default context. + + GSource * g_io_create_watch (GIOChannel *channel, + GIOCondition condition); + void g_source_set_callback (GSource *source, + GSourceFunc func, + gpointer data, + GDestroyNotify notify); + guint g_source_attach (GSource *source, + GMainContext *context); + */ + newSource = g_io_create_watch(newChannel, condition); + g_source_set_callback(newSource, callback, data, NULL); + g_source_attach(newSource, context); + return newChannel; +} Property changes on: trunk/concordance/src/utils.c ___________________________________________________________________ Added: svn:keywords + Id Added: trunk/concordance/src/utils.h =================================================================== --- trunk/concordance/src/utils.h (rev 0) +++ trunk/concordance/src/utils.h 2009-01-06 01:25:35 UTC (rev 1424) @@ -0,0 +1,23 @@ +/* +# Concordance XMPP/Jingle Server 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$ +*/ + +GIOChannel* conAddSocket(gint fd, GIOCondition condition, GSourceFunc callback, + gpointer data, GMainContext* context); Property changes on: trunk/concordance/src/utils.h ___________________________________________________________________ Added: svn:keywords + Id _______________________________________________ PySoy-SVN mailing list PySoy-SVN@pysoy.org http://www.pysoy.org/mailman/listinfo/pysoy-svn