diff options
Diffstat (limited to 'gio/gresolver.override')
-rw-r--r-- | gio/gresolver.override | 57 |
1 files changed, 57 insertions, 0 deletions
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; + } +} |