diff options
| author | Gian Mario Tagliaretti <gianmt@gnome.org> | 2009-12-29 12:40:50 +0100 |
|---|---|---|
| committer | Gian Mario Tagliaretti <gianmt@gnome.org> | 2009-12-29 13:27:40 +0100 |
| commit | 7589128515b79d836365247dc876538c6352da23 (patch) | |
| tree | 923f80d6ca9186d905882d3c62f05f5d606c1f13 /gio | |
| parent | 604d2bf220b1fefa415baaedbdb2882dbaf9e07e (diff) | |
| download | pygobject-7589128515b79d836365247dc876538c6352da23.tar.gz pygobject-7589128515b79d836365247dc876538c6352da23.tar.xz pygobject-7589128515b79d836365247dc876538c6352da23.zip | |
Wrap gio.Resolver.lookup_by_name() and add a couple of tests
Diffstat (limited to 'gio')
| -rw-r--r-- | gio/Makefile.am | 1 | ||||
| -rw-r--r-- | gio/gio.override | 1 | ||||
| -rw-r--r-- | gio/gresolver.override | 57 |
3 files changed, 59 insertions, 0 deletions
diff --git a/gio/Makefile.am b/gio/Makefile.am index 1c5b41f..51a8fbc 100644 --- a/gio/Makefile.am +++ b/gio/Makefile.am @@ -55,6 +55,7 @@ GIO_OVERRIDES = \ gmemoryoutputstream.override \ gmount.override \ goutputstream.override \ + gresolver.override \ gvolume.override \ gvolumemonitor.override diff --git a/gio/gio.override b/gio/gio.override index c9b13c3..62833ee 100644 --- a/gio/gio.override +++ b/gio/gio.override @@ -247,6 +247,7 @@ include gmount.override ginputstream.override goutputstream.override + gresolver.override gvolume.override gvolumemonitor.override %% diff --git a/gio/gresolver.override b/gio/gresolver.override new file mode 100644 index 0000000..1f2d9b6 --- /dev/null +++ b/gio/gresolver.override @@ -0,0 +1,57 @@ +/* -*- Mode: C; c-basic-offset: 4 -*- + * pygobject - Python bindings for GObject + * Copyright (C) 2009 Gian Mario Tagliaretti + * + * gresolver.override: module overrides for GResolver + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + */ +%% +override g_resolver_lookup_by_name kwargs +static PyObject * +_wrap_g_resolver_lookup_by_name(PyGObject *self, + PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "hostname", "cancellable", NULL }; + gchar *hostname; + PyGObject *pycancellable = NULL; + GCancellable *cancellable; + GList *addr; + GError *error = NULL; + PyObject *ret; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "s|O:gio.Resolver.lookup_by_name", + kwlist, + &hostname, + &pycancellable)) + return NULL; + + if (!pygio_check_cancellable(pycancellable, &cancellable)) + return NULL; + + addr = g_resolver_lookup_by_name(G_RESOLVER(self->obj), + hostname, cancellable, &error); + + if (addr) { + PYLIST_FROMGLIST(ret, addr, pygobject_new(list_item), g_resolver_free_addresses, NULL); + return ret; + } else { + Py_INCREF(Py_None); + return Py_None; + } +} |
