~jderose/ubuntu/precise/dbus-python/oneiric-backport

« back to all changes in this revision

Viewing changes to .pc/since-0.84.0.patch/_dbus_bindings/libdbusconn.c

  • Committer: Package Import Robot
  • Author(s): Barry Warsaw
  • Date: 2012-01-12 14:47:33 UTC
  • Revision ID: package-import@ubuntu.com-20120112144733-xtfbmgw30h0j40d2
Tags: 0.84.0-2ubuntu1
* debian/patches:
  - since-0.84.0.patch: Upstream unreleased changes from git tag
    dbus-python-0.84.0 to HEAD.  This is a precursor to the following.
  - python3-support.patch: Upstream unreleased changes from git
    `python3` branch for supporting Python 3. (LP: #893091)
* debian/rules: Enable the test suite.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* An extremely thin wrapper around a libdbus Connection, for use by
 
2
 * Server.
 
3
 *
 
4
 * Copyright (C) 2008 Collabora Ltd. <http://www.collabora.co.uk/>
 
5
 *
 
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:
 
13
 *
 
14
 * The above copyright notice and this permission notice shall be
 
15
 * included in all copies or substantial portions of the Software.
 
16
 *
 
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.
 
25
 */
 
26
 
 
27
#include "dbus_bindings-internal.h"
 
28
#include "conn-internal.h"
 
29
 
 
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"
 
33
"\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"
 
36
"address.\n"
 
37
);
 
38
 
 
39
/** Create a DBusPyLibDBusConnection from a DBusConnection.
 
40
 */
 
41
PyObject *
 
42
DBusPyLibDBusConnection_New(DBusConnection *conn)
 
43
{
 
44
    DBusPyLibDBusConnection *self = NULL;
 
45
 
 
46
    DBUS_PY_RAISE_VIA_NULL_IF_FAIL(conn);
 
47
 
 
48
    self = (DBusPyLibDBusConnection *)(DBusPyLibDBusConnection_Type.tp_alloc(
 
49
        &DBusPyLibDBusConnection_Type, 0));
 
50
 
 
51
    if (!self)
 
52
        return NULL;
 
53
 
 
54
    self->conn = dbus_connection_ref (conn);
 
55
 
 
56
    return (PyObject *)self;
 
57
}
 
58
 
 
59
/* Destructor */
 
60
static void
 
61
DBusPyLibDBusConnection_tp_dealloc(Connection *self)
 
62
{
 
63
    DBusConnection *conn = self->conn;
 
64
    PyObject *et, *ev, *etb;
 
65
 
 
66
    /* avoid clobbering any pending exception */
 
67
    PyErr_Fetch(&et, &ev, &etb);
 
68
 
 
69
    self->conn = NULL;
 
70
 
 
71
    if (conn) {
 
72
        dbus_connection_unref(conn);
 
73
    }
 
74
 
 
75
    PyErr_Restore(et, ev, etb);
 
76
    (self->ob_type->tp_free)((PyObject *) self);
 
77
}
 
78
 
 
79
PyTypeObject DBusPyLibDBusConnection_Type = {
 
80
    PyObject_HEAD_INIT(NULL)
 
81
    0,                      /*ob_size*/
 
82
    "_dbus_bindings._LibDBusConnection",
 
83
    sizeof(DBusPyLibDBusConnection),
 
84
    0,                      /*tp_itemsize*/
 
85
    /* methods */
 
86
    (destructor)DBusPyLibDBusConnection_tp_dealloc,
 
87
    0,                      /*tp_print*/
 
88
    0,                      /*tp_getattr*/
 
89
    0,                      /*tp_setattr*/
 
90
    0,                      /*tp_compare*/
 
91
    0,                      /*tp_repr*/
 
92
    0,                      /*tp_as_number*/
 
93
    0,                      /*tp_as_sequence*/
 
94
    0,                      /*tp_as_mapping*/
 
95
    0,                      /*tp_hash*/
 
96
    0,                      /*tp_call*/
 
97
    0,                      /*tp_str*/
 
98
    0,                      /*tp_getattro*/
 
99
    0,                      /*tp_setattro*/
 
100
    0,                      /*tp_as_buffer*/
 
101
    Py_TPFLAGS_DEFAULT,
 
102
    DBusPyLibDBusConnection_tp_doc,
 
103
};
 
104
 
 
105
dbus_bool_t
 
106
dbus_py_init_libdbus_conn_types(void)
 
107
{
 
108
    if (PyType_Ready(&DBusPyLibDBusConnection_Type) < 0)
 
109
        return FALSE;
 
110
 
 
111
    return TRUE;
 
112
}
 
113
 
 
114
dbus_bool_t
 
115
dbus_py_insert_libdbus_conn_types(PyObject *this_module)
 
116
{
 
117
    /* PyModule_AddObject steals a ref */
 
118
    Py_INCREF (&DBusPyLibDBusConnection_Type);
 
119
 
 
120
    if (PyModule_AddObject(this_module, "_LibDBusConnection",
 
121
                           (PyObject *)&DBusPyLibDBusConnection_Type) < 0)
 
122
        return FALSE;
 
123
 
 
124
    return TRUE;
 
125
}
 
126
 
 
127
/* vim:set ft=c cino< sw=4 sts=4 et: */