[pygobject] Wrap gio.SocketListener.add_address() and add a test
- From: Gian Mario Tagliaretti <gianmt src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [pygobject] Wrap gio.SocketListener.add_address() and add a test
- Date: Thu, 31 Dec 2009 14:41:07 +0000 (UTC)
commit 3829d7667b19126fb74562b28d271e616b154c99
Author: Gian Mario Tagliaretti <gianmt gnome org>
Date: Thu Dec 31 15:25:10 2009 +0100
Wrap gio.SocketListener.add_address() and add a test
gio/gsocket.override | 57 ++++++++++++++++++++++++++++++++++++++++++++++++-
tests/test_gsocket.py | 9 +++++++
2 files changed, 65 insertions(+), 1 deletions(-)
---
diff --git a/gio/gsocket.override b/gio/gsocket.override
index bb13254..f40e4df 100644
--- a/gio/gsocket.override
+++ b/gio/gsocket.override
@@ -248,13 +248,68 @@ _wrap_g_socket_client_connect_to_service_async(PyGObject *self,
pygio_notify_free(notify);
return NULL;
}
+%%
+override g_socket_listener_add_address kwargs
+static PyObject *
+_wrap_g_socket_listener_add_address(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "address", "type", "protocol",
+ "source_object", NULL };
+ GSocketProtocol protocol;
+ PyObject *py_type = NULL, *py_protocol = NULL;
+ GError *error = NULL;
+ gboolean ret;
+ GSocketType type;
+ GSocketAddress *effective_address;
+ PyGObject *address, *py_source_object = NULL;
+ GObject *source_object;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O!OO|O!:gio.SocketListener.add_address",
+ kwlist,
+ &PyGSocketAddress_Type, &address,
+ &py_type, &py_protocol,
+ &PyGObject_Type, &source_object,
+ &PyGSocketAddress_Type, &effective_address))
+ return NULL;
+
+ if (pyg_enum_get_value(G_TYPE_SOCKET_TYPE, py_type, (gpointer)&type))
+ return NULL;
+
+ if (pyg_enum_get_value(G_TYPE_SOCKET_PROTOCOL, py_protocol, (gpointer)&protocol))
+ return NULL;
+
+ if (py_source_object == NULL || (PyObject*)py_source_object == Py_None)
+ source_object = NULL;
+ else if (pygobject_check(py_source_object, &PyGObject_Type))
+ source_object = G_OBJECT(py_source_object->obj);
+ else {
+ PyErr_SetString(PyExc_TypeError, "source_object should be a gobject.GObject or None");
+ return NULL;
+ }
+
+ ret = g_socket_listener_add_address(G_SOCKET_LISTENER(self->obj),
+ G_SOCKET_ADDRESS(address->obj),
+ type, protocol,
+ source_object,
+ &effective_address,
+ &error);
+
+ if (pyg_error_check(&error))
+ return NULL;
+
+ if (ret)
+ return pygobject_new((GObject *)effective_address);
+ else {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+}
/* 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.add_address: No ArgType for GSocketAddress** */
/* 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** */
diff --git a/tests/test_gsocket.py b/tests/test_gsocket.py
index 9ac2398..b5b3694 100644
--- a/tests/test_gsocket.py
+++ b/tests/test_gsocket.py
@@ -39,3 +39,12 @@ class TestSocketAddress(unittest.TestCase):
loop = glib.MainLoop()
loop.run()
+
+class TestSocketListener(unittest.TestCase):
+ def test_socket_listener_add_address(self):
+ address = gio.inet_address_new_from_string("127.0.0.1")
+ inetsock = gio.InetSocketAddress(address, 1024)
+
+ listener = gio.SocketListener()
+ effective = listener.add_address(inetsock, gio.SOCKET_TYPE_STREAM, gio.SOCKET_PROTOCOL_TCP)
+ self.failUnless(isinstance(effective, gio.InetSocketAddress))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]