[pygobject] Wrap gio.SocketListener.accept_socket() and add a test
- From: Gian Mario Tagliaretti <gianmt src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [pygobject] Wrap gio.SocketListener.accept_socket() and add a test
- Date: Fri, 1 Jan 2010 11:41:56 +0000 (UTC)
commit c9496b29ef9ef232020a4044577d2947353953a5
Author: Gian Mario Tagliaretti <gianmt gnome org>
Date: Fri Jan 1 11:14:35 2010 +0100
Wrap gio.SocketListener.accept_socket() and add a test
gio/gsocket.override | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
tests/test_gsocket.py | 13 +++++++++++++
2 files changed, 60 insertions(+), 1 deletions(-)
---
diff --git a/gio/gsocket.override b/gio/gsocket.override
index 6745d6b..12b60a5 100644
--- a/gio/gsocket.override
+++ b/gio/gsocket.override
@@ -349,13 +349,59 @@ _wrap_g_socket_listener_accept(PyGObject *self, PyObject *args, PyObject *kwargs
}
return Py_BuildValue("(NN)", py_connection, py_source_object);
}
+%%
+override g_socket_listener_accept_socket kwargs
+static PyObject *
+_wrap_g_socket_listener_accept_socket(PyGObject *self,
+ PyObject *args,
+ PyObject *kwargs)
+{
+ static char *kwlist[] = { "cancellable", NULL };
+ GError *error = NULL;
+ PyGObject *py_cancellable = NULL;
+ GCancellable *cancellable;
+ PyObject *py_socket, *py_source_object;
+ GObject *source_object;
+ GSocket *socket;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"|O:gio.SocketListener.accept_socket",
+ kwlist,
+ &py_cancellable))
+ return NULL;
+
+
+ if (!pygio_check_cancellable(py_cancellable, &cancellable))
+ return NULL;
+
+ socket = g_socket_listener_accept_socket(G_SOCKET_LISTENER(self->obj),
+ &source_object,
+ cancellable,
+ &error);
+
+ if (pyg_error_check(&error))
+ return NULL;
+
+ if (socket)
+ py_socket = pygobject_new((GObject *)socket);
+ else {
+ py_socket = Py_None;
+ Py_INCREF(py_socket);
+ }
+
+ if (source_object)
+ py_source_object = pygobject_new((GObject *)source_object);
+ else {
+ py_source_object= Py_None;
+ Py_INCREF(py_source_object);
+ }
+ return Py_BuildValue("(NN)", py_socket, py_source_object);
+}
/* Could not write method GSocket.receive_from: No ArgType for GSocketAddress** */
/* Could not write method GSocket.receive_message: No ArgType for GSocketAddress** */
/* Could not write method GSocket.send_message: No ArgType for GOutputVector* */
/* Could not write method GSocket.create_source: No ArgType for GIOCondition */
/* Could not write method GSocketControlMessage.serialize: No ArgType for gpointer */
-/* Could not write method GSocketListener.accept_socket: No ArgType for GObject** */
/* Could not write method GSocketListener.accept_socket_async: No ArgType for GAsyncReadyCallback */
/* Could not write method GSocketListener.accept_socket_finish: No ArgType for GObject** */
/* Could not write method GSocketListener.accept_async: No ArgType for GAsyncReadyCallback */
diff --git a/tests/test_gsocket.py b/tests/test_gsocket.py
index 7789332..fd19cbb 100644
--- a/tests/test_gsocket.py
+++ b/tests/test_gsocket.py
@@ -61,3 +61,16 @@ class TestSocketListener(unittest.TestCase):
connection, source = listener.accept(cancellable=None)
self.failUnless(isinstance(connection, gio.TcpConnection))
+
+ def test_socket_listener_accept_socket(self):
+ address = gio.inet_address_new_from_string("127.0.0.1")
+ inetsock = gio.InetSocketAddress(address, 1024)
+
+ listener = gio.SocketListener()
+ listener.add_address(inetsock, gio.SOCKET_TYPE_STREAM, gio.SOCKET_PROTOCOL_TCP)
+
+ client = gio.SocketClient()
+ client.connect_to_host("127.0.0.1:1024", 1024)
+
+ socket, source = listener.accept_socket(cancellable=None)
+ self.failUnless(isinstance(socket, gio.Socket))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]