1
/* An extremely thin wrapper around a libdbus Connection, for use by
4
* Copyright (C) 2008 Collabora Ltd. <http://www.collabora.co.uk/>
6
* Permission is hereby granted, free of charge, to any person
7
* obtaining a copy of this software and associated documentation
8
* files (the "Software"), to deal in the Software without
9
* restriction, including without limitation the rights to use, copy,
10
* modify, merge, publish, distribute, sublicense, and/or sell copies
11
* of the Software, and to permit persons to whom the Software is
12
* furnished to do so, subject to the following conditions:
14
* The above copyright notice and this permission notice shall be
15
* included in all copies or substantial portions of the Software.
17
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24
* DEALINGS IN THE SOFTWARE.
27
#include "dbus_bindings-internal.h"
28
#include "conn-internal.h"
30
PyDoc_STRVAR(DBusPyLibDBusConnection_tp_doc,
31
"A reference to a ``DBusConnection`` from ``libdbus``, which might not\n"
32
"have been attached to a `dbus.connection.Connection` yet.\n"
34
"Cannot be instantiated from Python. The only use of this object is to\n"
35
"pass it to the ``dbus.connection.Connection`` constructor instead of an\n"
39
/** Create a DBusPyLibDBusConnection from a DBusConnection.
42
DBusPyLibDBusConnection_New(DBusConnection *conn)
44
DBusPyLibDBusConnection *self = NULL;
46
DBUS_PY_RAISE_VIA_NULL_IF_FAIL(conn);
48
self = (DBusPyLibDBusConnection *)(DBusPyLibDBusConnection_Type.tp_alloc(
49
&DBusPyLibDBusConnection_Type, 0));
54
self->conn = dbus_connection_ref (conn);
56
return (PyObject *)self;
61
DBusPyLibDBusConnection_tp_dealloc(Connection *self)
63
DBusConnection *conn = self->conn;
64
PyObject *et, *ev, *etb;
66
/* avoid clobbering any pending exception */
67
PyErr_Fetch(&et, &ev, &etb);
72
dbus_connection_unref(conn);
75
PyErr_Restore(et, ev, etb);
76
(self->ob_type->tp_free)((PyObject *) self);
79
PyTypeObject DBusPyLibDBusConnection_Type = {
80
PyObject_HEAD_INIT(NULL)
82
"_dbus_bindings._LibDBusConnection",
83
sizeof(DBusPyLibDBusConnection),
86
(destructor)DBusPyLibDBusConnection_tp_dealloc,
102
DBusPyLibDBusConnection_tp_doc,
106
dbus_py_init_libdbus_conn_types(void)
108
if (PyType_Ready(&DBusPyLibDBusConnection_Type) < 0)
115
dbus_py_insert_libdbus_conn_types(PyObject *this_module)
117
/* PyModule_AddObject steals a ref */
118
Py_INCREF (&DBusPyLibDBusConnection_Type);
120
if (PyModule_AddObject(this_module, "_LibDBusConnection",
121
(PyObject *)&DBusPyLibDBusConnection_Type) < 0)
127
/* vim:set ft=c cino< sw=4 sts=4 et: */