[pygobject] Wrap gio.Resolver.lookup_service() and add a test



commit 9d56ce775f56fff1b1ef3c75843c0583e39f75c3
Author: Gian Mario Tagliaretti <gianmt gnome org>
Date:   Wed Dec 30 11:11:32 2009 +0100

    Wrap gio.Resolver.lookup_service() and add a test

 gio/gresolver.override  |   42 ++++++++++++++++++++++++++++++++++++++++++
 tests/test_gresolver.py |    5 +++++
 2 files changed, 47 insertions(+), 0 deletions(-)
---
diff --git a/gio/gresolver.override b/gio/gresolver.override
index 17a0224..1930c67 100644
--- a/gio/gresolver.override
+++ b/gio/gresolver.override
@@ -183,3 +183,45 @@ _wrap_g_resolver_lookup_by_address_async(PyGObject *self,
     pygio_notify_free(notify);
     return NULL;
 }
+%%
+override g_resolver_lookup_service kwargs
+static PyObject *
+_wrap_g_resolver_lookup_service(PyGObject *self,
+                                PyObject *args,
+                                PyObject *kwargs)
+{
+    static char *kwlist[] = { "service", "protocol",
+                              "domain", "cancellable", NULL };
+    gchar *service, *protocol, *domain;
+    PyGObject *pycancellable = NULL;
+    GCancellable *cancellable;
+    GList *targets;
+    GError *error = NULL;
+    PyObject *ret;
+
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+                                    "sss|O:gio.Resolver.lookup_service",
+                                    kwlist,
+                                    &service,
+                                    &protocol,
+                                    &domain,
+                                    &pycancellable))
+        return NULL;
+    
+    if (!pygio_check_cancellable(pycancellable, &cancellable))
+	return NULL;
+    
+    targets = g_resolver_lookup_service(G_RESOLVER(self->obj),
+                                        service, protocol, domain,
+                                        cancellable, &error);
+    
+    if (targets) {
+        PYLIST_FROMGLIST(ret, targets,
+                        pyg_boxed_new(G_TYPE_SRV_TARGET, list_item, TRUE, TRUE),
+                        g_resolver_free_targets, NULL);
+        return ret;
+    } else {
+        Py_INCREF(Py_None);
+        return Py_None;
+    }
+}
diff --git a/tests/test_gresolver.py b/tests/test_gresolver.py
index 736caaa..03e79cc 100644
--- a/tests/test_gresolver.py
+++ b/tests/test_gresolver.py
@@ -45,3 +45,8 @@ class TestResolver(unittest.TestCase):
 
         loop = glib.MainLoop()
         loop.run()
+
+    def test_resolver_lookup_service(self):
+        targets = self.resolver.lookup_service("xmpp-client", "tcp", "google.com")
+        self.failUnless(isinstance(targets[0], gio.SrvTarget))
+



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]