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

« back to all changes in this revision

Viewing changes to .pc/python3-support.patch/_dbus_bindings/conn-methods.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
/* Implementation of normal Python-accessible methods on the _dbus_bindings
 
2
 * Connection type; separated out to keep the file size manageable.
 
3
 *
 
4
 * Copyright (C) 2006 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
static void
 
31
_object_path_unregister(DBusConnection *conn, void *user_data)
 
32
{
 
33
    PyGILState_STATE gil = PyGILState_Ensure();
 
34
    PyObject *tuple = NULL;
 
35
    Connection *conn_obj = NULL;
 
36
    PyObject *callable;
 
37
 
 
38
    conn_obj = (Connection *)DBusPyConnection_ExistingFromDBusConnection(conn);
 
39
    if (!conn_obj) goto out;
 
40
    TRACE(conn_obj);
 
41
 
 
42
    DBG("Connection at %p unregistering object path %s",
 
43
        conn_obj, PyString_AS_STRING((PyObject *)user_data));
 
44
    tuple = DBusPyConnection_GetObjectPathHandlers((PyObject *)conn_obj, (PyObject *)user_data);
 
45
    if (!tuple) goto out;
 
46
    if (tuple == Py_None) goto out;
 
47
 
 
48
    DBG("%s", "... yes we have handlers for that object path");
 
49
 
 
50
    /* 0'th item is the unregisterer (if that's a word) */
 
51
    callable = PyTuple_GetItem(tuple, 0);
 
52
    if (callable && callable != Py_None) {
 
53
        DBG("%s", "... and we even have an unregisterer");
 
54
        /* any return from the unregisterer is ignored */
 
55
        Py_XDECREF(PyObject_CallFunctionObjArgs(callable, conn_obj, NULL));
 
56
    }
 
57
out:
 
58
    Py_CLEAR(conn_obj);
 
59
    Py_CLEAR(tuple);
 
60
    /* the user_data (a Python str) is no longer ref'd by the DBusConnection */
 
61
    Py_CLEAR(user_data);
 
62
    if (PyErr_Occurred()) {
 
63
        PyErr_Print();
 
64
    }
 
65
    PyGILState_Release(gil);
 
66
}
 
67
 
 
68
static DBusHandlerResult
 
69
_object_path_message(DBusConnection *conn, DBusMessage *message,
 
70
                     void *user_data)
 
71
{
 
72
    DBusHandlerResult ret;
 
73
    PyGILState_STATE gil = PyGILState_Ensure();
 
74
    Connection *conn_obj = NULL;
 
75
    PyObject *tuple = NULL;
 
76
    PyObject *msg_obj;
 
77
    PyObject *callable;             /* borrowed */
 
78
 
 
79
    dbus_message_ref(message);
 
80
    msg_obj = DBusPyMessage_ConsumeDBusMessage(message);
 
81
    if (!msg_obj) {
 
82
        ret = DBUS_HANDLER_RESULT_NEED_MEMORY;
 
83
        goto out;
 
84
    }
 
85
 
 
86
    conn_obj = (Connection *)DBusPyConnection_ExistingFromDBusConnection(conn);
 
87
    if (!conn_obj) {
 
88
        ret = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 
89
        goto out;
 
90
    }
 
91
    TRACE(conn_obj);
 
92
 
 
93
    DBG("Connection at %p messaging object path %s",
 
94
        conn_obj, PyString_AS_STRING((PyObject *)user_data));
 
95
    DBG_DUMP_MESSAGE(message);
 
96
    tuple = DBusPyConnection_GetObjectPathHandlers((PyObject *)conn_obj, (PyObject *)user_data);
 
97
    if (!tuple || tuple == Py_None) {
 
98
        ret = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 
99
        goto out;
 
100
    }
 
101
 
 
102
    DBG("%s", "... yes we have handlers for that object path");
 
103
 
 
104
    /* 1st item (0-based) is the message callback */
 
105
    callable = PyTuple_GetItem(tuple, 1);
 
106
    if (!callable) {
 
107
        DBG("%s", "... error getting message handler from tuple");
 
108
        ret = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 
109
    }
 
110
    else if (callable == Py_None) {
 
111
        /* there was actually no handler after all */
 
112
        DBG("%s", "... but those handlers don't do messages");
 
113
        ret = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 
114
    }
 
115
    else {
 
116
        DBG("%s", "... and we have a message handler for that object path");
 
117
        ret = DBusPyConnection_HandleMessage(conn_obj, msg_obj, callable);
 
118
    }
 
119
 
 
120
out:
 
121
    Py_CLEAR(msg_obj);
 
122
    Py_CLEAR(conn_obj);
 
123
    Py_CLEAR(tuple);
 
124
    if (PyErr_Occurred()) {
 
125
        PyErr_Print();
 
126
    }
 
127
    PyGILState_Release(gil);
 
128
    return ret;
 
129
}
 
130
 
 
131
static const DBusObjectPathVTable _object_path_vtable = {
 
132
    _object_path_unregister,
 
133
    _object_path_message,
 
134
};
 
135
 
 
136
static DBusHandlerResult
 
137
_filter_message(DBusConnection *conn, DBusMessage *message, void *user_data)
 
138
{
 
139
    DBusHandlerResult ret;
 
140
    PyGILState_STATE gil = PyGILState_Ensure();
 
141
    Connection *conn_obj = NULL;
 
142
    PyObject *callable = NULL;
 
143
    PyObject *msg_obj;
 
144
#ifndef DBUS_PYTHON_DISABLE_CHECKS
 
145
    Py_ssize_t i, size;
 
146
#endif
 
147
 
 
148
    dbus_message_ref(message);
 
149
    msg_obj = DBusPyMessage_ConsumeDBusMessage(message);
 
150
    if (!msg_obj) {
 
151
        DBG("%s", "OOM while trying to construct Message");
 
152
        ret = DBUS_HANDLER_RESULT_NEED_MEMORY;
 
153
        goto out;
 
154
    }
 
155
 
 
156
    conn_obj = (Connection *)DBusPyConnection_ExistingFromDBusConnection(conn);
 
157
    if (!conn_obj) {
 
158
        DBG("%s", "failed to traverse DBusConnection -> Connection weakref");
 
159
        ret = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 
160
        goto out;
 
161
    }
 
162
    TRACE(conn_obj);
 
163
 
 
164
    /* The user_data is a pointer to a Python object. To avoid
 
165
     * cross-library reference cycles, the DBusConnection isn't allowed
 
166
     * to reference it. However, as long as the Connection is still
 
167
     * alive, its ->filters list owns a reference to the same Python
 
168
     * object, so the object should also still be alive.
 
169
     *
 
170
     * To ensure that this works, be careful whenever manipulating the
 
171
     * filters list! (always put things in the list *before* giving
 
172
     * them to libdbus, etc.)
 
173
     */
 
174
#ifdef DBUS_PYTHON_DISABLE_CHECKS
 
175
    callable = (PyObject *)user_data;
 
176
#else
 
177
    size = PyList_GET_SIZE(conn_obj->filters);
 
178
    for (i = 0; i < size; i++) {
 
179
        callable = PyList_GET_ITEM(conn_obj->filters, i);
 
180
        if (callable == user_data) {
 
181
            Py_INCREF(callable);
 
182
            break;
 
183
        }
 
184
        else {
 
185
            callable = NULL;
 
186
        }
 
187
    }
 
188
 
 
189
    if (!callable) {
 
190
        DBG("... filter %p has vanished from ->filters, so not calling it",
 
191
            user_data);
 
192
        ret = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 
193
        goto out;
 
194
    }
 
195
#endif
 
196
 
 
197
    ret = DBusPyConnection_HandleMessage(conn_obj, msg_obj, callable);
 
198
out:
 
199
    Py_CLEAR(msg_obj);
 
200
    Py_CLEAR(conn_obj);
 
201
    Py_CLEAR(callable);
 
202
    PyGILState_Release(gil);
 
203
    return ret;
 
204
}
 
205
 
 
206
PyDoc_STRVAR(Connection__require_main_loop__doc__,
 
207
"_require_main_loop()\n\n"
 
208
"Raise an exception if this Connection is not bound to any main loop -\n"
 
209
"in this state, asynchronous calls, receiving signals and exporting objects\n"
 
210
"will not work.\n"
 
211
"\n"
 
212
"`dbus.mainloop.NULL_MAIN_LOOP` is treated like a valid main loop - if you're\n"
 
213
"using that, you presumably know what you're doing.\n");
 
214
static PyObject *
 
215
Connection__require_main_loop (Connection *self, PyObject *args UNUSED)
 
216
{
 
217
    if (!self->has_mainloop) {
 
218
        PyErr_SetString(PyExc_RuntimeError,
 
219
                        "To make asynchronous calls, receive signals or "
 
220
                        "export objects, D-Bus connections must be attached "
 
221
                        "to a main loop by passing mainloop=... to the "
 
222
                        "constructor or calling "
 
223
                        "dbus.set_default_main_loop(...)");
 
224
        return NULL;
 
225
    }
 
226
    Py_RETURN_NONE;
 
227
}
 
228
 
 
229
PyDoc_STRVAR(Connection_close__doc__,
 
230
"close()\n\n"
 
231
"Close the connection.");
 
232
static PyObject *
 
233
Connection_close (Connection *self, PyObject *args UNUSED)
 
234
{
 
235
    TRACE(self);
 
236
    /* Because the user explicitly asked to close the connection, we'll even
 
237
    let them close shared connections. */
 
238
    if (self->conn) {
 
239
        Py_BEGIN_ALLOW_THREADS
 
240
        dbus_connection_close(self->conn);
 
241
        Py_END_ALLOW_THREADS
 
242
    }
 
243
    Py_RETURN_NONE;
 
244
}
 
245
 
 
246
PyDoc_STRVAR(Connection_get_is_connected__doc__,
 
247
"get_is_connected() -> bool\n\n"
 
248
"Return true if this Connection is connected.\n");
 
249
static PyObject *
 
250
Connection_get_is_connected (Connection *self, PyObject *args UNUSED)
 
251
{
 
252
    dbus_bool_t ret;
 
253
 
 
254
    TRACE(self);
 
255
    DBUS_PY_RAISE_VIA_NULL_IF_FAIL(self->conn);
 
256
    Py_BEGIN_ALLOW_THREADS
 
257
    ret = dbus_connection_get_is_connected(self->conn);
 
258
    Py_END_ALLOW_THREADS
 
259
    return PyBool_FromLong(ret);
 
260
}
 
261
 
 
262
PyDoc_STRVAR(Connection_get_is_authenticated__doc__,
 
263
"get_is_authenticated() -> bool\n\n"
 
264
"Return true if this Connection was ever authenticated.\n");
 
265
static PyObject *
 
266
Connection_get_is_authenticated (Connection *self, PyObject *args UNUSED)
 
267
{
 
268
    dbus_bool_t ret;
 
269
 
 
270
    TRACE(self);
 
271
    DBUS_PY_RAISE_VIA_NULL_IF_FAIL(self->conn);
 
272
    Py_BEGIN_ALLOW_THREADS
 
273
    ret = dbus_connection_get_is_authenticated(self->conn);
 
274
    Py_END_ALLOW_THREADS
 
275
    return PyBool_FromLong(ret);
 
276
}
 
277
 
 
278
PyDoc_STRVAR(Connection_set_exit_on_disconnect__doc__,
 
279
"set_exit_on_disconnect(bool)\n\n"
 
280
"Set whether the C function ``_exit`` will be called when this Connection\n"
 
281
"becomes disconnected. This will cause the program to exit without calling\n"
 
282
"any cleanup code or exit handlers.\n"
 
283
"\n"
 
284
"The default is for this feature to be disabled for Connections and enabled\n"
 
285
"for Buses.\n");
 
286
static PyObject *
 
287
Connection_set_exit_on_disconnect (Connection *self, PyObject *args)
 
288
{
 
289
    int exit_on_disconnect;
 
290
 
 
291
    TRACE(self);
 
292
    DBUS_PY_RAISE_VIA_NULL_IF_FAIL(self->conn);
 
293
    if (!PyArg_ParseTuple(args, "i:set_exit_on_disconnect",
 
294
                          &exit_on_disconnect)) {
 
295
        return NULL;
 
296
    }
 
297
    Py_BEGIN_ALLOW_THREADS
 
298
    dbus_connection_set_exit_on_disconnect(self->conn,
 
299
                                           exit_on_disconnect ? 1 : 0);
 
300
    Py_END_ALLOW_THREADS
 
301
    Py_RETURN_NONE;
 
302
}
 
303
 
 
304
PyDoc_STRVAR(Connection_send_message__doc__,
 
305
"send_message(msg) -> long\n\n"
 
306
"Queue the given message for sending, and return the message serial number.\n"
 
307
"\n"
 
308
":Parameters:\n"
 
309
"   `msg` : dbus.lowlevel.Message\n"
 
310
"       The message to be sent.\n"
 
311
);
 
312
static PyObject *
 
313
Connection_send_message(Connection *self, PyObject *args)
 
314
{
 
315
    dbus_bool_t ok;
 
316
    PyObject *obj;
 
317
    DBusMessage *msg;
 
318
    dbus_uint32_t serial;
 
319
 
 
320
    TRACE(self);
 
321
    DBUS_PY_RAISE_VIA_NULL_IF_FAIL(self->conn);
 
322
    if (!PyArg_ParseTuple(args, "O", &obj)) return NULL;
 
323
 
 
324
    msg = DBusPyMessage_BorrowDBusMessage(obj);
 
325
    if (!msg) return NULL;
 
326
 
 
327
    Py_BEGIN_ALLOW_THREADS
 
328
    ok = dbus_connection_send(self->conn, msg, &serial);
 
329
    Py_END_ALLOW_THREADS
 
330
 
 
331
    if (!ok) {
 
332
        return PyErr_NoMemory();
 
333
    }
 
334
 
 
335
    return PyLong_FromUnsignedLong(serial);
 
336
}
 
337
 
 
338
PyDoc_STRVAR(Connection_set_allow_anonymous__doc__,
 
339
"set_allow_anonymous(bool)\n\n"
 
340
"Allows anonymous clients. Call this on the server side of a connection in a on_connection_added callback"
 
341
);
 
342
static PyObject *
 
343
Connection_set_allow_anonymous(Connection *self, PyObject *args)
 
344
{
 
345
    dbus_bool_t t;
 
346
 
 
347
    TRACE(self);
 
348
    DBUS_PY_RAISE_VIA_NULL_IF_FAIL(self->conn);
 
349
    if (!PyArg_ParseTuple(args, "i", &t)) {
 
350
        return NULL;
 
351
    }
 
352
 
 
353
    Py_BEGIN_ALLOW_THREADS
 
354
    dbus_connection_set_allow_anonymous(self->conn, t ? 1 : 0);
 
355
    Py_END_ALLOW_THREADS
 
356
    Py_RETURN_NONE;
 
357
}
 
358
 
 
359
/* The timeout is in seconds here, since that's conventional in Python. */
 
360
PyDoc_STRVAR(Connection_send_message_with_reply__doc__,
 
361
"send_message_with_reply(msg, reply_handler, timeout_s=-1, "
 
362
"require_main_loop=False) -> dbus.lowlevel.PendingCall\n\n"
 
363
"Queue the message for sending; expect a reply via the returned PendingCall,\n"
 
364
"which can also be used to cancel the pending call.\n"
 
365
"\n"
 
366
":Parameters:\n"
 
367
"   `msg` : dbus.lowlevel.Message\n"
 
368
"       The message to be sent\n"
 
369
"   `reply_handler` : callable\n"
 
370
"       Asynchronous reply handler: will be called with one positional\n"
 
371
"       parameter, a Message instance representing the reply.\n"
 
372
"   `timeout_s` : float\n"
 
373
"       If the reply takes more than this many seconds, a timeout error\n"
 
374
"       will be created locally and raised instead. If this timeout is\n"
 
375
"       negative (default), a sane default (supplied by libdbus) is used.\n"
 
376
"   `require_main_loop` : bool\n"
 
377
"       If True, raise RuntimeError if this Connection does not have a main\n"
 
378
"       loop configured. If False (default) and there is no main loop, you are\n"
 
379
"       responsible for calling block() on the PendingCall.\n"
 
380
"\n"
 
381
);
 
382
static PyObject *
 
383
Connection_send_message_with_reply(Connection *self, PyObject *args, PyObject *kw)
 
384
{
 
385
    dbus_bool_t ok;
 
386
    double timeout_s = -1.0;
 
387
    int timeout_ms;
 
388
    PyObject *obj, *callable;
 
389
    DBusMessage *msg;
 
390
    DBusPendingCall *pending;
 
391
    int require_main_loop = 0;
 
392
    static char *argnames[] = {"msg", "reply_handler", "timeout_s",
 
393
                               "require_main_loop", NULL};
 
394
 
 
395
    TRACE(self);
 
396
    DBUS_PY_RAISE_VIA_NULL_IF_FAIL(self->conn);
 
397
    if (!PyArg_ParseTupleAndKeywords(args, kw,
 
398
                                     "OO|di:send_message_with_reply",
 
399
                                     argnames,
 
400
                                     &obj, &callable, &timeout_s,
 
401
                                     &require_main_loop)) {
 
402
        return NULL;
 
403
    }
 
404
    if (require_main_loop && !Connection__require_main_loop(self, NULL)) {
 
405
        return NULL;
 
406
    }
 
407
 
 
408
    msg = DBusPyMessage_BorrowDBusMessage(obj);
 
409
    if (!msg) return NULL;
 
410
 
 
411
    if (timeout_s < 0) {
 
412
        timeout_ms = -1;
 
413
    }
 
414
    else {
 
415
        if (timeout_s > ((double)INT_MAX) / 1000.0) {
 
416
            PyErr_SetString(PyExc_ValueError, "Timeout too long");
 
417
            return NULL;
 
418
        }
 
419
        timeout_ms = (int)(timeout_s * 1000.0);
 
420
    }
 
421
 
 
422
    Py_BEGIN_ALLOW_THREADS
 
423
    ok = dbus_connection_send_with_reply(self->conn, msg, &pending,
 
424
                                         timeout_ms);
 
425
    Py_END_ALLOW_THREADS
 
426
 
 
427
    if (!ok) {
 
428
        return PyErr_NoMemory();
 
429
    }
 
430
 
 
431
    if (!pending) {
 
432
        /* connection is disconnected (doesn't return FALSE!) */
 
433
        return DBusPyException_SetString ("Connection is disconnected - "
 
434
                                          "unable to make method call");
 
435
    }
 
436
 
 
437
    return DBusPyPendingCall_ConsumeDBusPendingCall(pending, callable);
 
438
}
 
439
 
 
440
/* Again, the timeout is in seconds, since that's conventional in Python. */
 
441
PyDoc_STRVAR(Connection_send_message_with_reply_and_block__doc__,
 
442
"send_message_with_reply_and_block(msg, timeout_s=-1)"
 
443
" -> dbus.lowlevel.Message\n\n"
 
444
"Send the message and block while waiting for a reply.\n"
 
445
"\n"
 
446
"This does not re-enter the main loop, so it can lead to a deadlock, if\n"
 
447
"the called method tries to make a synchronous call to a method in this\n"
 
448
"application. As such, it's probably a bad idea.\n"
 
449
"\n"
 
450
":Parameters:\n"
 
451
"   `msg` : dbus.lowlevel.Message\n"
 
452
"       The message to be sent\n"
 
453
"   `timeout_s` : float\n"
 
454
"       If the reply takes more than this many seconds, a timeout error\n"
 
455
"       will be created locally and raised instead. If this timeout is\n"
 
456
"       negative (default), a sane default (supplied by libdbus) is used.\n"
 
457
":Returns:\n"
 
458
"   A `dbus.lowlevel.Message` instance (probably a `dbus.lowlevel.MethodReturnMessage`) on success\n"
 
459
":Raises dbus.DBusException:\n"
 
460
"   On error (including if the reply arrives but is an\n"
 
461
"   error message)\n"
 
462
"\n"
 
463
);
 
464
static PyObject *
 
465
Connection_send_message_with_reply_and_block(Connection *self, PyObject *args)
 
466
{
 
467
    double timeout_s = -1.0;
 
468
    int timeout_ms;
 
469
    PyObject *obj;
 
470
    DBusMessage *msg, *reply;
 
471
    DBusError error;
 
472
 
 
473
    TRACE(self);
 
474
    DBUS_PY_RAISE_VIA_NULL_IF_FAIL(self->conn);
 
475
    if (!PyArg_ParseTuple(args, "O|d:send_message_with_reply_and_block", &obj,
 
476
                          &timeout_s)) {
 
477
        return NULL;
 
478
    }
 
479
 
 
480
    msg = DBusPyMessage_BorrowDBusMessage(obj);
 
481
    if (!msg) return NULL;
 
482
 
 
483
    if (timeout_s < 0) {
 
484
        timeout_ms = -1;
 
485
    }
 
486
    else {
 
487
        if (timeout_s > ((double)INT_MAX) / 1000.0) {
 
488
            PyErr_SetString(PyExc_ValueError, "Timeout too long");
 
489
            return NULL;
 
490
        }
 
491
        timeout_ms = (int)(timeout_s * 1000.0);
 
492
    }
 
493
 
 
494
    dbus_error_init(&error);
 
495
    Py_BEGIN_ALLOW_THREADS
 
496
    reply = dbus_connection_send_with_reply_and_block(self->conn, msg,
 
497
                                                      timeout_ms, &error);
 
498
    Py_END_ALLOW_THREADS
 
499
 
 
500
    /* FIXME: if we instead used send_with_reply and blocked on the resulting
 
501
     * PendingCall, then we could get all args from the error, not just
 
502
     * the first */
 
503
    if (!reply) {
 
504
        return DBusPyException_ConsumeError(&error);
 
505
    }
 
506
    return DBusPyMessage_ConsumeDBusMessage(reply);
 
507
}
 
508
 
 
509
PyDoc_STRVAR(Connection_flush__doc__,
 
510
"flush()\n\n"
 
511
"Block until the outgoing message queue is empty.\n");
 
512
static PyObject *
 
513
Connection_flush (Connection *self, PyObject *args UNUSED)
 
514
{
 
515
    TRACE(self);
 
516
    DBUS_PY_RAISE_VIA_NULL_IF_FAIL(self->conn);
 
517
    Py_BEGIN_ALLOW_THREADS
 
518
    dbus_connection_flush (self->conn);
 
519
    Py_END_ALLOW_THREADS
 
520
    Py_RETURN_NONE;
 
521
}
 
522
 
 
523
/* Unsupported:
 
524
 * dbus_connection_preallocate_send
 
525
 * dbus_connection_free_preallocated_send
 
526
 * dbus_connection_send_preallocated
 
527
 * dbus_connection_borrow_message
 
528
 * dbus_connection_return_message
 
529
 * dbus_connection_steal_borrowed_message
 
530
 * dbus_connection_pop_message
 
531
 */
 
532
 
 
533
/* Non-main-loop handling not yet implemented: */
 
534
    /* dbus_connection_read_write_dispatch */
 
535
    /* dbus_connection_read_write */
 
536
 
 
537
/* Main loop handling not yet implemented: */
 
538
    /* dbus_connection_get_dispatch_status */
 
539
    /* dbus_connection_dispatch */
 
540
    /* dbus_connection_set_watch_functions */
 
541
    /* dbus_connection_set_timeout_functions */
 
542
    /* dbus_connection_set_wakeup_main_function */
 
543
    /* dbus_connection_set_dispatch_status_function */
 
544
 
 
545
/* Normally in Python this would be called fileno(), but I don't want to
 
546
 * encourage people to select() on it */
 
547
PyDoc_STRVAR(Connection_get_unix_fd__doc__,
 
548
"get_unix_fd() -> int or None\n\n"
 
549
"Get the connection's UNIX file descriptor, if any.\n\n"
 
550
"This can be used for SELinux access control checks with ``getpeercon()``\n"
 
551
"for example. **Do not** read or write to the file descriptor, or try to\n"
 
552
"``select()`` on it.\n");
 
553
static PyObject *
 
554
Connection_get_unix_fd (Connection *self, PyObject *unused UNUSED)
 
555
{
 
556
    int fd;
 
557
    dbus_bool_t ok;
 
558
 
 
559
    TRACE(self);
 
560
    DBUS_PY_RAISE_VIA_NULL_IF_FAIL(self->conn);
 
561
    Py_BEGIN_ALLOW_THREADS
 
562
    ok = dbus_connection_get_unix_fd (self->conn, &fd);
 
563
    Py_END_ALLOW_THREADS
 
564
    if (!ok) Py_RETURN_NONE;
 
565
    return PyInt_FromLong(fd);
 
566
}
 
567
 
 
568
PyDoc_STRVAR(Connection_get_peer_unix_user__doc__,
 
569
"get_peer_unix_user() -> long or None\n\n"
 
570
"Get the UNIX user ID at the other end of the connection, if it has been\n"
 
571
"authenticated. Return None if this is a non-UNIX platform or the\n"
 
572
"connection has not been authenticated.\n");
 
573
static PyObject *
 
574
Connection_get_peer_unix_user (Connection *self, PyObject *unused UNUSED)
 
575
{
 
576
    unsigned long uid;
 
577
    dbus_bool_t ok;
 
578
 
 
579
    TRACE(self);
 
580
    DBUS_PY_RAISE_VIA_NULL_IF_FAIL(self->conn);
 
581
    Py_BEGIN_ALLOW_THREADS
 
582
    ok = dbus_connection_get_unix_user (self->conn, &uid);
 
583
    Py_END_ALLOW_THREADS
 
584
    if (!ok) Py_RETURN_NONE;
 
585
    return PyLong_FromUnsignedLong (uid);
 
586
}
 
587
 
 
588
PyDoc_STRVAR(Connection_get_peer_unix_process_id__doc__,
 
589
"get_peer_unix_process_id() -> long or None\n\n"
 
590
"Get the UNIX process ID at the other end of the connection, if it has been\n"
 
591
"authenticated. Return None if this is a non-UNIX platform or the\n"
 
592
"connection has not been authenticated.\n");
 
593
static PyObject *
 
594
Connection_get_peer_unix_process_id (Connection *self, PyObject *unused UNUSED)
 
595
{
 
596
    unsigned long pid;
 
597
    dbus_bool_t ok;
 
598
 
 
599
    TRACE(self);
 
600
    DBUS_PY_RAISE_VIA_NULL_IF_FAIL(self->conn);
 
601
    Py_BEGIN_ALLOW_THREADS
 
602
    ok = dbus_connection_get_unix_process_id (self->conn, &pid);
 
603
    Py_END_ALLOW_THREADS
 
604
    if (!ok) Py_RETURN_NONE;
 
605
    return PyLong_FromUnsignedLong (pid);
 
606
}
 
607
 
 
608
/* TODO: wrap dbus_connection_set_unix_user_function Pythonically */
 
609
 
 
610
PyDoc_STRVAR(Connection_add_message_filter__doc__,
 
611
"add_message_filter(callable)\n\n"
 
612
"Add the given message filter to the internal list.\n\n"
 
613
"Filters are handlers that are run on all incoming messages, prior to the\n"
 
614
"objects registered to handle object paths.\n"
 
615
"\n"
 
616
"Filters are run in the order that they were added. The same handler can\n"
 
617
"be added as a filter more than once, in which case it will be run more\n"
 
618
"than once. Filters added during a filter callback won't be run on the\n"
 
619
"message being processed.\n"
 
620
);
 
621
static PyObject *
 
622
Connection_add_message_filter(Connection *self, PyObject *callable)
 
623
{
 
624
    dbus_bool_t ok;
 
625
 
 
626
    TRACE(self);
 
627
    DBUS_PY_RAISE_VIA_NULL_IF_FAIL(self->conn);
 
628
    /* The callable must be referenced by ->filters *before* it is
 
629
     * given to libdbus, which does not own a reference to it.
 
630
     */
 
631
    if (PyList_Append(self->filters, callable) < 0) {
 
632
        return NULL;
 
633
    }
 
634
 
 
635
    Py_BEGIN_ALLOW_THREADS
 
636
    ok = dbus_connection_add_filter(self->conn, _filter_message, callable,
 
637
                                    NULL);
 
638
    Py_END_ALLOW_THREADS
 
639
 
 
640
    if (!ok) {
 
641
        Py_XDECREF(PyObject_CallMethod(self->filters, "remove", "(O)",
 
642
                                       callable));
 
643
        PyErr_NoMemory();
 
644
        return NULL;
 
645
    }
 
646
    Py_RETURN_NONE;
 
647
}
 
648
 
 
649
PyDoc_STRVAR(Connection_remove_message_filter__doc__,
 
650
"remove_message_filter(callable)\n\n"
 
651
"Remove the given message filter (see `add_message_filter` for details).\n"
 
652
"\n"
 
653
":Raises LookupError:\n"
 
654
"   The given callable is not among the registered filters\n");
 
655
static PyObject *
 
656
Connection_remove_message_filter(Connection *self, PyObject *callable)
 
657
{
 
658
    PyObject *obj;
 
659
 
 
660
    TRACE(self);
 
661
    DBUS_PY_RAISE_VIA_NULL_IF_FAIL(self->conn);
 
662
    /* It's safe to do this before removing it from libdbus, because
 
663
     * the presence of callable in our arguments means we have a ref
 
664
     * to it. */
 
665
    obj = PyObject_CallMethod(self->filters, "remove", "(O)", callable);
 
666
    if (!obj) return NULL;
 
667
    Py_CLEAR(obj);
 
668
 
 
669
    Py_BEGIN_ALLOW_THREADS
 
670
    dbus_connection_remove_filter(self->conn, _filter_message, callable);
 
671
    Py_END_ALLOW_THREADS
 
672
 
 
673
    Py_RETURN_NONE;
 
674
}
 
675
 
 
676
PyDoc_STRVAR(Connection__register_object_path__doc__,
 
677
"register_object_path(path, on_message, on_unregister=None, fallback=False)\n"
 
678
"\n"
 
679
"Register a callback to be called when messages arrive at the given\n"
 
680
"object-path. Used to export objects' methods on the bus in a low-level\n"
 
681
"way. For the high-level interface to this functionality (usually\n"
 
682
"recommended) see the `dbus.service.Object` base class.\n"
 
683
"\n"
 
684
":Parameters:\n"
 
685
"   `path` : str\n"
 
686
"       Object path to be acted on\n"
 
687
"   `on_message` : callable\n"
 
688
"       Called when a message arrives at the given object-path, with\n"
 
689
"       two positional parameters: the first is this Connection,\n"
 
690
"       the second is the incoming `dbus.lowlevel.Message`.\n"
 
691
"   `on_unregister` : callable or None\n"
 
692
"       If not None, called when the callback is unregistered.\n"
 
693
"   `fallback` : bool\n"
 
694
"       If True (the default is False), when a message arrives for a\n"
 
695
"       'subdirectory' of the given path and there is no more specific\n"
 
696
"       handler, use this handler. Normally this handler is only run if\n"
 
697
"       the paths match exactly.\n"
 
698
);
 
699
static PyObject *
 
700
Connection__register_object_path(Connection *self, PyObject *args,
 
701
                                 PyObject *kwargs)
 
702
{
 
703
    dbus_bool_t ok;
 
704
    int fallback = 0;
 
705
    PyObject *callbacks, *path, *tuple, *on_message, *on_unregister = Py_None;
 
706
    static char *argnames[] = {"path", "on_message", "on_unregister",
 
707
                               "fallback", NULL};
 
708
 
 
709
    TRACE(self);
 
710
    DBUS_PY_RAISE_VIA_NULL_IF_FAIL(self->conn);
 
711
    if (!Connection__require_main_loop(self, NULL)) {
 
712
        return NULL;
 
713
    }
 
714
    if (!PyArg_ParseTupleAndKeywords(args, kwargs,
 
715
                                     "OO|Oi:_register_object_path",
 
716
                                     argnames,
 
717
                                     &path,
 
718
                                     &on_message, &on_unregister,
 
719
                                     &fallback)) return NULL;
 
720
 
 
721
    /* Take a reference to path, which we give away to libdbus in a moment.
 
722
 
 
723
    Also, path needs to be a string (not a subclass which could do something
 
724
    mad) to preserve the desirable property that the DBusConnection can
 
725
    never strongly reference the Connection, even indirectly.
 
726
    */
 
727
    if (PyString_CheckExact(path)) {
 
728
        Py_INCREF(path);
 
729
    }
 
730
    else if (PyUnicode_Check(path)) {
 
731
        path = PyUnicode_AsUTF8String(path);
 
732
        if (!path) return NULL;
 
733
    }
 
734
    else if (PyString_Check(path)) {
 
735
        path = PyString_FromString(PyString_AS_STRING(path));
 
736
        if (!path) return NULL;
 
737
    }
 
738
    else {
 
739
        PyErr_SetString(PyExc_TypeError, "path must be a str or unicode object");
 
740
        return NULL;
 
741
    }
 
742
 
 
743
    if (!dbus_py_validate_object_path(PyString_AS_STRING(path))) {
 
744
        Py_CLEAR(path);
 
745
        return NULL;
 
746
    }
 
747
 
 
748
    tuple = Py_BuildValue("(OO)", on_unregister, on_message);
 
749
    if (!tuple) {
 
750
        Py_CLEAR(path);
 
751
        return NULL;
 
752
    }
 
753
 
 
754
    /* Guard against registering a handler that already exists. */
 
755
    callbacks = PyDict_GetItem(self->object_paths, path);
 
756
    if (callbacks && callbacks != Py_None) {
 
757
        PyErr_Format(PyExc_KeyError, "Can't register the object-path "
 
758
                     "handler for '%s': there is already a handler",
 
759
                     PyString_AS_STRING(path));
 
760
        Py_CLEAR(tuple);
 
761
        Py_CLEAR(path);
 
762
        return NULL;
 
763
    }
 
764
 
 
765
    /* Pre-allocate a slot in the dictionary, so we know we'll be able
 
766
     * to replace it with the callbacks without OOM.
 
767
     * This ensures we can keep libdbus' opinion of whether those
 
768
     * paths are handled in sync with our own. */
 
769
    if (PyDict_SetItem(self->object_paths, path, Py_None) < 0) {
 
770
        Py_CLEAR(tuple);
 
771
        Py_CLEAR(path);
 
772
        return NULL;
 
773
    }
 
774
 
 
775
    Py_BEGIN_ALLOW_THREADS
 
776
    if (fallback) {
 
777
        ok = dbus_connection_register_fallback(self->conn,
 
778
                                               PyString_AS_STRING(path),
 
779
                                               &_object_path_vtable,
 
780
                                               path);
 
781
    }
 
782
    else {
 
783
        ok = dbus_connection_register_object_path(self->conn,
 
784
                                                  PyString_AS_STRING(path),
 
785
                                                  &_object_path_vtable,
 
786
                                                  path);
 
787
    }
 
788
    Py_END_ALLOW_THREADS
 
789
 
 
790
    if (ok) {
 
791
        if (PyDict_SetItem(self->object_paths, path, tuple) < 0) {
 
792
            /* That shouldn't have happened, we already allocated enough
 
793
            memory for it. Oh well, try to undo the registration to keep
 
794
            things in sync. If this fails too, we've leaked a bit of
 
795
            memory in libdbus, but tbh we should never get here anyway. */
 
796
            Py_BEGIN_ALLOW_THREADS
 
797
            ok = dbus_connection_unregister_object_path(self->conn,
 
798
                                                    PyString_AS_STRING(path));
 
799
            Py_END_ALLOW_THREADS
 
800
            return NULL;
 
801
        }
 
802
        /* don't DECREF path: libdbus owns a ref now */
 
803
        Py_CLEAR(tuple);
 
804
        Py_RETURN_NONE;
 
805
    }
 
806
    else {
 
807
        /* Oops, OOM. Tidy up, if we can, ignoring any error. */
 
808
        PyDict_DelItem(self->object_paths, path);
 
809
        PyErr_Clear();
 
810
        Py_CLEAR(tuple);
 
811
        Py_CLEAR(path);
 
812
        PyErr_NoMemory();
 
813
        return NULL;
 
814
    }
 
815
}
 
816
 
 
817
PyDoc_STRVAR(Connection__unregister_object_path__doc__,
 
818
"unregister_object_path(path)\n\n"
 
819
"Remove a previously registered handler for the given object path.\n"
 
820
"\n"
 
821
":Parameters:\n"
 
822
"   `path` : str\n"
 
823
"       The object path whose handler is to be removed\n"
 
824
":Raises KeyError: if there is no handler registered for exactly that\n"
 
825
"   object path.\n"
 
826
);
 
827
static PyObject *
 
828
Connection__unregister_object_path(Connection *self, PyObject *args,
 
829
                                   PyObject *kwargs)
 
830
{
 
831
    dbus_bool_t ok;
 
832
    PyObject *path;
 
833
    PyObject *callbacks;
 
834
    static char *argnames[] = {"path", NULL};
 
835
 
 
836
    TRACE(self);
 
837
    DBUS_PY_RAISE_VIA_NULL_IF_FAIL(self->conn);
 
838
    if (!PyArg_ParseTupleAndKeywords(args, kwargs,
 
839
                                     "O:_unregister_object_path",
 
840
                                     argnames, &path)) return NULL;
 
841
 
 
842
    /* Take a ref to the path. Same comments as for _register_object_path. */
 
843
    if (PyString_CheckExact(path)) {
 
844
        Py_INCREF(path);
 
845
    }
 
846
    else if (PyUnicode_Check(path)) {
 
847
        path = PyUnicode_AsUTF8String(path);
 
848
        if (!path) return NULL;
 
849
    }
 
850
    else if (PyString_Check(path)) {
 
851
        path = PyString_FromString(PyString_AS_STRING(path));
 
852
        if (!path) return NULL;
 
853
    }
 
854
    else {
 
855
        PyErr_SetString(PyExc_TypeError, "path must be a str or unicode object");
 
856
        return NULL;
 
857
    }
 
858
 
 
859
    /* Guard against unregistering a handler that doesn't, in fact, exist,
 
860
    or whose unregistration is already in progress. */
 
861
    callbacks = PyDict_GetItem(self->object_paths, path);
 
862
    if (!callbacks || callbacks == Py_None) {
 
863
        PyErr_Format(PyExc_KeyError, "Can't unregister the object-path "
 
864
                     "handler for '%s': there is no such handler",
 
865
                     PyString_AS_STRING(path));
 
866
        Py_CLEAR(path);
 
867
        return NULL;
 
868
    }
 
869
 
 
870
    /* Hang on to a reference to the callbacks for the moment. */
 
871
    Py_INCREF(callbacks);
 
872
 
 
873
    /* Get rid of the object-path while we still have the GIL, to
 
874
    guard against unregistering twice from different threads (which
 
875
    causes undefined behaviour in libdbus).
 
876
 
 
877
    Because deletion would make it possible for the re-insertion below
 
878
    to fail, we instead set the handler to None as a placeholder.
 
879
    */
 
880
    if (PyDict_SetItem(self->object_paths, path, Py_None) < 0) {
 
881
        /* If that failed, there's no need to be paranoid as below - the
 
882
        callbacks are still set, so we failed, but at least everything
 
883
        is in sync. */
 
884
        Py_CLEAR(callbacks);
 
885
        Py_CLEAR(path);
 
886
        return NULL;
 
887
    }
 
888
 
 
889
    /* BEGIN PARANOIA
 
890
    This is something of a critical section - the dict of object-paths
 
891
    and libdbus' internal structures are out of sync for a bit. We have
 
892
    to be able to cope with that.
 
893
 
 
894
    It's really annoying that dbus_connection_unregister_object_path
 
895
    can fail, *and* has undefined behaviour if the object path has
 
896
    already been unregistered. Either/or would be fine.
 
897
    */
 
898
 
 
899
    Py_BEGIN_ALLOW_THREADS
 
900
    ok = dbus_connection_unregister_object_path(self->conn,
 
901
                                                PyString_AS_STRING(path));
 
902
    Py_END_ALLOW_THREADS
 
903
 
 
904
    if (ok) {
 
905
        Py_CLEAR(callbacks);
 
906
        PyDict_DelItem(self->object_paths, path);
 
907
        /* END PARANOIA on successful code path */
 
908
        /* The above can't fail unless by some strange trickery the key is no
 
909
        longer present. Ignore any errors. */
 
910
        Py_CLEAR(path);
 
911
        PyErr_Clear();
 
912
        Py_RETURN_NONE;
 
913
    }
 
914
    else {
 
915
        /* Oops, OOM. Put the callbacks back in the dict so
 
916
         * we'll have another go if/when the user frees some memory
 
917
         * and tries calling this method again. */
 
918
        PyDict_SetItem(self->object_paths, path, callbacks);
 
919
        /* END PARANOIA on failing code path */
 
920
        /* If the SetItem failed, there's nothing we can do about it - but
 
921
        since we know it's an existing entry, it shouldn't be able to fail
 
922
        anyway. */
 
923
        Py_CLEAR(path);
 
924
        Py_CLEAR(callbacks);
 
925
        return PyErr_NoMemory();
 
926
    }
 
927
}
 
928
 
 
929
PyDoc_STRVAR(Connection_list_exported_child_objects__doc__,
 
930
"list_exported_child_objects(path: str) -> list of str\n\n"
 
931
"Return a list of the names of objects exported on this Connection as\n"
 
932
"direct children of the given object path.\n"
 
933
"\n"
 
934
"Each name returned may be converted to a valid object path using\n"
 
935
"``dbus.ObjectPath('%s%s%s' % (path, (path != '/' and '/' or ''), name))``.\n"
 
936
"For the purposes of this function, every parent or ancestor of an exported\n"
 
937
"object is considered to be an exported object, even if it's only an object\n"
 
938
"synthesized by the library to support introspection.\n");
 
939
static PyObject *
 
940
Connection_list_exported_child_objects (Connection *self, PyObject *args,
 
941
                                        PyObject *kwargs)
 
942
{
 
943
    const char *path;
 
944
    char **kids, **kid_ptr;
 
945
    dbus_bool_t ok;
 
946
    PyObject *ret;
 
947
    static char *argnames[] = {"path", NULL};
 
948
 
 
949
    DBUS_PY_RAISE_VIA_NULL_IF_FAIL(self->conn);
 
950
    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s", argnames, &path)) {
 
951
        return NULL;
 
952
    }
 
953
 
 
954
    if (!dbus_py_validate_object_path(path)) {
 
955
        return NULL;
 
956
    }
 
957
 
 
958
    Py_BEGIN_ALLOW_THREADS
 
959
    ok = dbus_connection_list_registered(self->conn, path, &kids);
 
960
    Py_END_ALLOW_THREADS
 
961
 
 
962
    if (!ok) {
 
963
        return PyErr_NoMemory();
 
964
    }
 
965
 
 
966
    ret = PyList_New(0);
 
967
    if (!ret) {
 
968
        return NULL;
 
969
    }
 
970
    for (kid_ptr = kids; *kid_ptr; kid_ptr++) {
 
971
        PyObject *tmp = PyString_FromString(*kid_ptr);
 
972
 
 
973
        if (!tmp) {
 
974
            Py_CLEAR(ret);
 
975
            return NULL;
 
976
        }
 
977
        if (PyList_Append(ret, tmp) < 0) {
 
978
            Py_CLEAR(tmp);
 
979
            Py_CLEAR(ret);
 
980
            return NULL;
 
981
        }
 
982
        Py_CLEAR(tmp);
 
983
    }
 
984
 
 
985
    dbus_free_string_array(kids);
 
986
 
 
987
    return ret;
 
988
}
 
989
 
 
990
    /* dbus_connection_get_object_path_data - not useful to Python,
 
991
     * the object path data is just a PyString containing the path */
 
992
    /* dbus_connection_list_registered could be useful, though */
 
993
 
 
994
/* dbus_connection_set_change_sigpipe - sets global state */
 
995
 
 
996
/* Maxima. Does Python code ever need to manipulate these?
 
997
 * OTOH they're easy to wrap */
 
998
    /* dbus_connection_set_max_message_size */
 
999
    /* dbus_connection_get_max_message_size */
 
1000
    /* dbus_connection_set_max_received_size */
 
1001
    /* dbus_connection_get_max_received_size */
 
1002
 
 
1003
/* dbus_connection_get_outgoing_size - almost certainly unneeded */
 
1004
 
 
1005
PyDoc_STRVAR(new_for_bus__doc__,
 
1006
"Connection._new_for_bus([address: str or int]) -> Connection\n"
 
1007
"\n"
 
1008
"If the address is an int it must be one of the constants BUS_SESSION,\n"
 
1009
"BUS_SYSTEM, BUS_STARTER; if a string, it must be a D-Bus address.\n"
 
1010
"The default is BUS_SESSION.\n"
 
1011
);
 
1012
 
 
1013
PyDoc_STRVAR(get_unique_name__doc__,
 
1014
"get_unique_name() -> str\n\n"
 
1015
"Return this application's unique name on this bus.\n"
 
1016
"\n"
 
1017
":Raises DBusException: if the connection has no unique name yet\n"
 
1018
"   (for Bus objects this can't happen, for peer-to-peer connections\n"
 
1019
"   this means you haven't called `set_unique_name`)\n");
 
1020
 
 
1021
PyDoc_STRVAR(set_unique_name__doc__,
 
1022
"set_unique_name(str)\n\n"
 
1023
"Set this application's unique name on this bus. Raise ValueError if it has\n"
 
1024
"already been set.\n");
 
1025
 
 
1026
struct PyMethodDef DBusPyConnection_tp_methods[] = {
 
1027
#define ENTRY(name, flags) {#name, (PyCFunction)Connection_##name, flags, Connection_##name##__doc__}
 
1028
    ENTRY(_require_main_loop, METH_NOARGS),
 
1029
    ENTRY(close, METH_NOARGS),
 
1030
    ENTRY(flush, METH_NOARGS),
 
1031
    ENTRY(get_is_connected, METH_NOARGS),
 
1032
    ENTRY(get_is_authenticated, METH_NOARGS),
 
1033
    ENTRY(set_exit_on_disconnect, METH_VARARGS),
 
1034
    ENTRY(get_unix_fd, METH_NOARGS),
 
1035
    ENTRY(get_peer_unix_user, METH_NOARGS),
 
1036
    ENTRY(get_peer_unix_process_id, METH_NOARGS),
 
1037
    ENTRY(add_message_filter, METH_O),
 
1038
    ENTRY(_register_object_path, METH_VARARGS|METH_KEYWORDS),
 
1039
    ENTRY(remove_message_filter, METH_O),
 
1040
    ENTRY(send_message, METH_VARARGS),
 
1041
    ENTRY(send_message_with_reply, METH_VARARGS|METH_KEYWORDS),
 
1042
    ENTRY(send_message_with_reply_and_block, METH_VARARGS),
 
1043
    ENTRY(_unregister_object_path, METH_VARARGS|METH_KEYWORDS),
 
1044
    ENTRY(list_exported_child_objects, METH_VARARGS|METH_KEYWORDS),
 
1045
    {"_new_for_bus", (PyCFunction)DBusPyConnection_NewForBus,
 
1046
        METH_CLASS|METH_VARARGS|METH_KEYWORDS,
 
1047
        new_for_bus__doc__},
 
1048
    {"get_unique_name", (PyCFunction)DBusPyConnection_GetUniqueName,
 
1049
        METH_NOARGS,
 
1050
        get_unique_name__doc__},
 
1051
    {"set_unique_name", (PyCFunction)DBusPyConnection_SetUniqueName,
 
1052
        METH_VARARGS,
 
1053
        set_unique_name__doc__},
 
1054
    ENTRY(set_allow_anonymous, METH_VARARGS),
 
1055
    {NULL},
 
1056
#undef ENTRY
 
1057
};
 
1058
 
 
1059
/* vim:set ft=c cino< sw=4 sts=4 et: */