1 /* -*- Mode: C; c-basic-offset: 4 -*-
2 * pygobject - Python bindings for GObject
3 * Copyright (C) 2009 Gian Mario Tagliaretti
5 * gsocket.override: module overrides for GSocket and related types
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
24 override g_socket_condition_check kwargs
26 _wrap_g_socket_condition_check(PyGObject *self,
30 static char *kwlist[] = { "condition", NULL };
33 if (!PyArg_ParseTupleAndKeywords(args, kwargs,
34 "i:gio.Socket.condition_check",
38 ret = g_socket_condition_check(G_SOCKET(self->obj), condition);
40 return pyg_flags_from_gtype(G_TYPE_IO_CONDITION, ret);
43 override g_socket_condition_wait kwargs
45 _wrap_g_socket_condition_wait(PyGObject *self,
49 static char *kwlist[] = { "condition", "cancellable", NULL };
52 PyGObject *py_cancellable = NULL;
53 GCancellable *cancellable;
56 if (!PyArg_ParseTupleAndKeywords(args, kwargs,
57 "i|O:gio.Socket.condition_wait",
58 kwlist, &condition, &cancellable))
61 if (!pygio_check_cancellable(py_cancellable, &cancellable))
64 ret = g_socket_condition_wait(G_SOCKET(self->obj), condition,
67 return PyBool_FromLong(ret);
70 override g_socket_address_enumerator_next_async kwargs
72 _wrap_g_socket_address_enumerator_next_async(PyGObject *self,
76 static char *kwlist[] = { "callback", "cancellable", "user_data", NULL };
78 PyGObject *py_cancellable = NULL;
79 GCancellable *cancellable;
81 notify = pygio_notify_new();
83 if (!PyArg_ParseTupleAndKeywords(args, kwargs,
84 "O|OO:gio.SocketAddressEnumerator.next_async",
91 if (!pygio_notify_callback_is_valid(notify))
94 if (!pygio_check_cancellable(py_cancellable, &cancellable))
97 pygio_notify_reference_callback(notify);
99 g_socket_address_enumerator_next_async(G_SOCKET_ADDRESS_ENUMERATOR(self->obj),
101 (GAsyncReadyCallback) async_result_callback_marshal,
108 pygio_notify_free(notify);
112 override g_socket_client_connect_async kwargs
114 _wrap_g_socket_client_connect_async(PyGObject *self,
118 static char *kwlist[] = { "callback", "connectable", "cancellable", "user_data", NULL };
120 PyGObject *py_cancellable = NULL;
121 GCancellable *cancellable;
122 PyGObject *py_connectable;
124 notify = pygio_notify_new();
126 if (!PyArg_ParseTupleAndKeywords(args, kwargs,
127 "OO|OO:gio.SocketClient.connect_async",
135 if (!pygio_notify_callback_is_valid(notify))
138 if (!pygio_check_cancellable(py_cancellable, &cancellable))
141 pygio_notify_reference_callback(notify);
143 g_socket_client_connect_async(G_SOCKET_CLIENT(self->obj),
144 G_SOCKET_CONNECTABLE(py_connectable->obj),
146 (GAsyncReadyCallback) async_result_callback_marshal,
153 pygio_notify_free(notify);
157 override g_socket_client_connect_to_host_async kwargs
159 _wrap_g_socket_client_connect_to_host_async(PyGObject *self,
163 static char *kwlist[] = { "callback", "host_and_port", "default_port",
164 "cancellable", "user_data", NULL };
166 PyGObject *py_cancellable = NULL;
167 GCancellable *cancellable;
168 gchar *host_and_port;
169 guint16 default_port;
171 notify = pygio_notify_new();
173 if (!PyArg_ParseTupleAndKeywords(args, kwargs,
174 "OsH|OO:gio.SocketClient.connect_to_host_async",
183 if (!pygio_notify_callback_is_valid(notify))
186 if (!pygio_check_cancellable(py_cancellable, &cancellable))
189 pygio_notify_reference_callback(notify);
191 g_socket_client_connect_to_host_async(G_SOCKET_CLIENT(self->obj),
192 host_and_port, default_port,
194 (GAsyncReadyCallback) async_result_callback_marshal,
201 pygio_notify_free(notify);
205 override g_socket_client_connect_to_service_async kwargs
207 _wrap_g_socket_client_connect_to_service_async(PyGObject *self,
211 static char *kwlist[] = { "callback", "domain", "service",
212 "cancellable", "user_data", NULL };
214 PyGObject *py_cancellable = NULL;
215 GCancellable *cancellable;
216 gchar *domain, *service;
218 notify = pygio_notify_new();
220 if (!PyArg_ParseTupleAndKeywords(args, kwargs,
221 "Oss|OO:gio.SocketClient.connect_to_service_async",
230 if (!pygio_notify_callback_is_valid(notify))
233 if (!pygio_check_cancellable(py_cancellable, &cancellable))
236 pygio_notify_reference_callback(notify);
238 g_socket_client_connect_to_service_async(G_SOCKET_CLIENT(self->obj),
241 (GAsyncReadyCallback) async_result_callback_marshal,
248 pygio_notify_free(notify);
252 override g_socket_listener_add_address kwargs
254 _wrap_g_socket_listener_add_address(PyGObject *self, PyObject *args, PyObject *kwargs)
256 static char *kwlist[] = { "address", "type", "protocol",
257 "source_object", NULL };
258 GSocketProtocol protocol;
259 PyObject *py_type = NULL, *py_protocol = NULL;
260 GError *error = NULL;
263 GSocketAddress *effective_address;
264 PyGObject *address, *py_source_object = NULL;
265 GObject *source_object;
267 if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O!OO|O!:gio.SocketListener.add_address",
269 &PyGSocketAddress_Type, &address,
270 &py_type, &py_protocol,
271 &PyGObject_Type, &source_object,
272 &PyGSocketAddress_Type, &effective_address))
275 if (pyg_enum_get_value(G_TYPE_SOCKET_TYPE, py_type, (gpointer)&type))
278 if (pyg_enum_get_value(G_TYPE_SOCKET_PROTOCOL, py_protocol, (gpointer)&protocol))
281 if (py_source_object == NULL || (PyObject*)py_source_object == Py_None)
282 source_object = NULL;
283 else if (pygobject_check(py_source_object, &PyGObject_Type))
284 source_object = G_OBJECT(py_source_object->obj);
286 PyErr_SetString(PyExc_TypeError, "source_object should be a gobject.GObject or None");
290 ret = g_socket_listener_add_address(G_SOCKET_LISTENER(self->obj),
291 G_SOCKET_ADDRESS(address->obj),
297 if (pyg_error_check(&error))
301 return pygobject_new((GObject *)effective_address);
308 override g_socket_listener_accept kwargs
310 _wrap_g_socket_listener_accept(PyGObject *self, PyObject *args, PyObject *kwargs)
312 static char *kwlist[] = { "cancellable", NULL };
313 GError *error = NULL;
314 PyGObject *py_cancellable = NULL;
315 GCancellable *cancellable;
316 PyObject *py_connection, *py_source_object;
317 GObject *source_object;
318 GSocketConnection *connection;
320 if (!PyArg_ParseTupleAndKeywords(args, kwargs,"|O:gio.SocketListener.accept",
326 if (!pygio_check_cancellable(py_cancellable, &cancellable))
329 connection = g_socket_listener_accept(G_SOCKET_LISTENER(self->obj),
334 if (pyg_error_check(&error))
338 py_connection = pygobject_new((GObject *)connection);
340 py_connection = Py_None;
341 Py_INCREF(py_connection);
345 py_source_object = pygobject_new((GObject *)source_object);
347 py_source_object= Py_None;
348 Py_INCREF(py_source_object);
350 return Py_BuildValue("(NN)", py_connection, py_source_object);
353 override g_socket_listener_accept_async kwargs
355 _wrap_g_socket_listener_accept_async(PyGObject *self,
359 static char *kwlist[] = { "callback", "cancellable", "user_data", NULL };
361 PyGObject *py_cancellable = NULL;
362 GCancellable *cancellable;
364 notify = pygio_notify_new();
366 if (!PyArg_ParseTupleAndKeywords(args, kwargs,
367 "O|OO:gio.SocketListener.accept_async",
374 if (!pygio_notify_callback_is_valid(notify))
377 if (!pygio_check_cancellable(py_cancellable, &cancellable))
380 pygio_notify_reference_callback(notify);
382 g_socket_listener_accept_async(G_SOCKET_LISTENER(self->obj),
384 (GAsyncReadyCallback) async_result_callback_marshal,
391 pygio_notify_free(notify);
395 override g_socket_listener_accept_finish kwargs
397 _wrap_g_socket_listener_accept_finish(PyGObject *self,
401 static char *kwlist[] = { "result", NULL };
402 GError *error = NULL;
404 PyObject *py_connection, *py_source_object;
405 GObject *source_object;
406 GSocketConnection *connection;
408 if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O!:gio.SocketListener.accept_finish",
410 &PyGAsyncResult_Type, &result))
413 connection = g_socket_listener_accept_finish(G_SOCKET_LISTENER(self->obj),
414 G_ASYNC_RESULT(result->obj),
418 if (pyg_error_check(&error))
422 py_connection = pygobject_new((GObject *)connection);
424 py_connection = Py_None;
425 Py_INCREF(py_connection);
429 py_source_object = pygobject_new((GObject *)source_object);
431 py_source_object= Py_None;
432 Py_INCREF(py_source_object);
434 return Py_BuildValue("(NN)", py_connection, py_source_object);
437 override g_socket_listener_accept_socket kwargs
439 _wrap_g_socket_listener_accept_socket(PyGObject *self,
443 static char *kwlist[] = { "cancellable", NULL };
444 GError *error = NULL;
445 PyGObject *py_cancellable = NULL;
446 GCancellable *cancellable;
447 PyObject *py_socket, *py_source_object;
448 GObject *source_object;
451 if (!PyArg_ParseTupleAndKeywords(args, kwargs,"|O:gio.SocketListener.accept_socket",
457 if (!pygio_check_cancellable(py_cancellable, &cancellable))
460 socket = g_socket_listener_accept_socket(G_SOCKET_LISTENER(self->obj),
465 if (pyg_error_check(&error))
469 py_socket = pygobject_new((GObject *)socket);
472 Py_INCREF(py_socket);
476 py_source_object = pygobject_new((GObject *)source_object);
478 py_source_object= Py_None;
479 Py_INCREF(py_source_object);
481 return Py_BuildValue("(NN)", py_socket, py_source_object);
484 override g_socket_listener_accept_socket_async kwargs
486 _wrap_g_socket_listener_accept_socket_async(PyGObject *self,
490 static char *kwlist[] = { "callback", "cancellable", "user_data", NULL };
492 PyGObject *py_cancellable = NULL;
493 GCancellable *cancellable;
495 notify = pygio_notify_new();
497 if (!PyArg_ParseTupleAndKeywords(args, kwargs,
498 "O|OO:gio.SocketListener.accept_socket_async",
505 if (!pygio_notify_callback_is_valid(notify))
508 if (!pygio_check_cancellable(py_cancellable, &cancellable))
511 pygio_notify_reference_callback(notify);
513 g_socket_listener_accept_socket_async(G_SOCKET_LISTENER(self->obj),
515 (GAsyncReadyCallback) async_result_callback_marshal,
522 pygio_notify_free(notify);
526 override g_socket_listener_accept_socket_finish kwargs
528 _wrap_g_socket_listener_accept_socket_finish(PyGObject *self,
532 static char *kwlist[] = { "result", NULL };
533 GError *error = NULL;
535 PyObject *py_socket, *py_source_object;
536 GObject *source_object;
539 if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O!:gio.SocketListener.accept_socket_finish",
541 &PyGAsyncResult_Type, &result))
544 socket = g_socket_listener_accept_socket_finish(G_SOCKET_LISTENER(self->obj),
545 G_ASYNC_RESULT(result->obj),
549 if (pyg_error_check(&error))
553 py_socket = pygobject_new((GObject *)socket);
556 Py_INCREF(py_socket);
560 py_source_object = pygobject_new((GObject *)source_object);
562 py_source_object= Py_None;
563 Py_INCREF(py_source_object);
565 return Py_BuildValue("(NN)", py_socket, py_source_object);
568 /* Could not write method GSocketAddress.to_native: No ArgType for gpointer */
569 /* Could not write method GSocket.receive_from: No ArgType for GSocketAddress** */
570 /* Could not write method GSocket.receive_message: No ArgType for GSocketAddress** */
571 /* Could not write method GSocket.send_message: No ArgType for GOutputVector* */
572 /* Could not write method GSocket.create_source: No ArgType for GIOCondition */
573 /* Could not write method GSocketControlMessage.serialize: No ArgType for gpointer */
574 /* Could not write function socket_address_new_from_native: No ArgType for gpointer */
575 /* Could not write function socket_control_message_deserialize: No ArgType for gpointer */