~ubuntu-branches/ubuntu/precise/dbus-python/precise

« back to all changes in this revision

Viewing changes to .pc/python3-support.patch/_dbus_bindings/message.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 D-Bus Message and subclasses (but see message-get-args.h
 
2
 * and message-append.h for unserialization and serialization code).
 
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 "message-internal.h"
 
29
 
 
30
static PyTypeObject MessageType, SignalMessageType, ErrorMessageType;
 
31
static PyTypeObject MethodReturnMessageType, MethodCallMessageType;
 
32
 
 
33
static inline int Message_Check(PyObject *o)
 
34
{
 
35
    return (Py_TYPE(o) == &MessageType)
 
36
            || PyObject_IsInstance(o, (PyObject *)&MessageType);
 
37
}
 
38
 
 
39
PyObject *
 
40
DBusPy_RaiseUnusableMessage(void)
 
41
{
 
42
    DBusPyException_SetString("Message object is uninitialized, or has become "
 
43
                              "unusable due to error while appending "
 
44
                              "arguments");
 
45
    return NULL;
 
46
}
 
47
 
 
48
PyDoc_STRVAR(Message_tp_doc,
 
49
"A message to be sent or received over a D-Bus Connection.\n");
 
50
 
 
51
static void Message_tp_dealloc(Message *self)
 
52
{
 
53
    if (self->msg) {
 
54
        dbus_message_unref(self->msg);
 
55
    }
 
56
    Py_TYPE(self)->tp_free((PyObject *)self);
 
57
}
 
58
 
 
59
static PyObject *
 
60
Message_tp_new(PyTypeObject *type,
 
61
               PyObject *args UNUSED,
 
62
               PyObject *kwargs UNUSED)
 
63
{
 
64
    Message *self;
 
65
 
 
66
    self = (Message *)type->tp_alloc(type, 0);
 
67
    if (!self) return NULL;
 
68
    self->msg = NULL;
 
69
    return (PyObject *)self;
 
70
}
 
71
 
 
72
PyDoc_STRVAR(MethodCallMessage_tp_doc, "A method-call message.\n"
 
73
"\n"
 
74
"Constructor::\n"
 
75
"\n"
 
76
"    dbus.lowlevel.MethodCallMessage(destination: str or None, path: str,\n"
 
77
"                                    interface: str or None, method: str)\n"
 
78
"\n"
 
79
"``destination`` is the destination bus name, or None to send the\n"
 
80
"message directly to the peer (usually the bus daemon).\n"
 
81
"\n"
 
82
"``path`` is the object-path of the object whose method is to be called.\n"
 
83
"\n"
 
84
"``interface`` is the interface qualifying the method name, or None to omit\n"
 
85
"the interface from the message header.\n"
 
86
"\n"
 
87
"``method`` is the method name (member name).\n"
 
88
);
 
89
 
 
90
static int
 
91
MethodCallMessage_tp_init(Message *self, PyObject *args, PyObject *kwargs)
 
92
{
 
93
    const char *destination, *path, *interface, *method;
 
94
    static char *kwlist[] = {"destination", "path", "interface", "method", NULL};
 
95
 
 
96
    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "zszs:__init__", kwlist,
 
97
                                     &destination, &path, &interface,
 
98
                                     &method)) {
 
99
        return -1;
 
100
    }
 
101
    if (destination && !dbus_py_validate_bus_name(destination, 1, 1)) return -1;
 
102
    if (!dbus_py_validate_object_path(path)) return -1;
 
103
    if (interface && !dbus_py_validate_interface_name(interface)) return -1;
 
104
    if (!dbus_py_validate_member_name(method)) return -1;
 
105
    if (self->msg) {
 
106
        dbus_message_unref(self->msg);
 
107
        self->msg = NULL;
 
108
    }
 
109
    self->msg = dbus_message_new_method_call(destination, path, interface,
 
110
                                             method);
 
111
    if (!self->msg) {
 
112
        PyErr_NoMemory();
 
113
        return -1;
 
114
    }
 
115
    return 0;
 
116
}
 
117
 
 
118
PyDoc_STRVAR(MethodReturnMessage_tp_doc, "A method-return message.\n\n"
 
119
"Constructor::\n\n"
 
120
"    dbus.lowlevel.MethodReturnMessage(method_call: MethodCallMessage)\n");
 
121
 
 
122
static int
 
123
MethodReturnMessage_tp_init(Message *self, PyObject *args, PyObject *kwargs)
 
124
{
 
125
    Message *other;
 
126
    static char *kwlist[] = {"method_call", NULL};
 
127
 
 
128
    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!:__init__", kwlist,
 
129
                                     &MessageType, &other)) {
 
130
        return -1;
 
131
    }
 
132
    if (self->msg) {
 
133
        dbus_message_unref(self->msg);
 
134
        self->msg = NULL;
 
135
    }
 
136
    self->msg = dbus_message_new_method_return(other->msg);
 
137
    if (!self->msg) {
 
138
        PyErr_NoMemory();
 
139
        return -1;
 
140
    }
 
141
    return 0;
 
142
}
 
143
 
 
144
PyDoc_STRVAR(SignalMessage_tp_doc, "A signal message.\n\n"
 
145
"Constructor::\n\n"
 
146
"   dbus.lowlevel.SignalMessage(path: str, interface: str, method: str)\n");
 
147
static int
 
148
SignalMessage_tp_init(Message *self, PyObject *args, PyObject *kwargs)
 
149
{
 
150
    const char *path, *interface, *name;
 
151
    static char *kwlist[] = {"path", "interface", "name", NULL};
 
152
 
 
153
    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sss:__init__", kwlist,
 
154
                                    &path, &interface, &name)) {
 
155
      return -1;
 
156
    }
 
157
    if (!dbus_py_validate_object_path(path)) return -1;
 
158
    if (!dbus_py_validate_interface_name(interface)) return -1;
 
159
    if (!dbus_py_validate_member_name(name)) return -1;
 
160
    if (self->msg) {
 
161
        dbus_message_unref(self->msg);
 
162
        self->msg = NULL;
 
163
    }
 
164
    self->msg = dbus_message_new_signal(path, interface, name);
 
165
    if (!self->msg) {
 
166
        PyErr_NoMemory();
 
167
        return -1;
 
168
    }
 
169
    return 0;
 
170
}
 
171
 
 
172
PyDoc_STRVAR(ErrorMessage_tp_doc, "An error message.\n\n"
 
173
"Constructor::\n\n"
 
174
"   dbus.lowlevel.ErrorMessage(reply_to: Message, error_name: str,\n"
 
175
"                              error_message: str or None)\n");
 
176
static int
 
177
ErrorMessage_tp_init(Message *self, PyObject *args, PyObject *kwargs)
 
178
{
 
179
    Message *reply_to;
 
180
    const char *error_name, *error_message;
 
181
    static char *kwlist[] = {"reply_to", "error_name", "error_message", NULL};
 
182
 
 
183
    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!sz:__init__", kwlist,
 
184
                                      &MessageType, &reply_to, &error_name,
 
185
                                      &error_message)) {
 
186
        return -1;
 
187
    }
 
188
    if (!dbus_py_validate_error_name(error_name)) return -1;
 
189
    if (self->msg) {
 
190
        dbus_message_unref(self->msg);
 
191
        self->msg = NULL;
 
192
    }
 
193
    self->msg = dbus_message_new_error(reply_to->msg, error_name, error_message);
 
194
    if (!self->msg) {
 
195
        PyErr_NoMemory();
 
196
        return -1;
 
197
    }
 
198
    return 0;
 
199
}
 
200
 
 
201
DBusMessage *
 
202
DBusPyMessage_BorrowDBusMessage(PyObject *msg)
 
203
{
 
204
    if (!Message_Check(msg)) {
 
205
        PyErr_SetString(PyExc_TypeError,
 
206
                       "A dbus.lowlevel.Message instance is required");
 
207
        return NULL;
 
208
    }
 
209
    if (!((Message *)msg)->msg) {
 
210
        DBusPy_RaiseUnusableMessage();
 
211
        return NULL;
 
212
    }
 
213
    return ((Message *)msg)->msg;
 
214
}
 
215
 
 
216
PyObject *
 
217
DBusPyMessage_ConsumeDBusMessage(DBusMessage *msg)
 
218
{
 
219
    PyTypeObject *type;
 
220
    Message *self;
 
221
 
 
222
    switch (dbus_message_get_type(msg)) {
 
223
    case DBUS_MESSAGE_TYPE_METHOD_CALL:
 
224
        type = &MethodCallMessageType;
 
225
        break;
 
226
    case DBUS_MESSAGE_TYPE_METHOD_RETURN:
 
227
        type = &MethodReturnMessageType;
 
228
        break;
 
229
    case DBUS_MESSAGE_TYPE_ERROR:
 
230
        type = &ErrorMessageType;
 
231
        break;
 
232
    case DBUS_MESSAGE_TYPE_SIGNAL:
 
233
        type = &SignalMessageType;
 
234
        break;
 
235
    default:
 
236
        type = &MessageType;
 
237
    }
 
238
 
 
239
    self = (Message *)(type->tp_new) (type, dbus_py_empty_tuple, NULL);
 
240
    if (!self) {
 
241
        dbus_message_unref(msg);
 
242
        return NULL;
 
243
    }
 
244
    self->msg = msg;
 
245
    return (PyObject *)self;
 
246
}
 
247
 
 
248
PyDoc_STRVAR(Message_copy__doc__,
 
249
"message.copy() -> Message (or subclass)\n"
 
250
"Deep-copy the message, resetting the serial number to zero.\n");
 
251
static PyObject *
 
252
Message_copy(Message *self, PyObject *args UNUSED)
 
253
{
 
254
    DBusMessage *msg;
 
255
    if (!self->msg) return DBusPy_RaiseUnusableMessage();
 
256
    msg = dbus_message_copy(self->msg);
 
257
    if (!msg) return PyErr_NoMemory();
 
258
    return DBusPyMessage_ConsumeDBusMessage(msg);
 
259
}
 
260
 
 
261
PyDoc_STRVAR(Message_get_auto_start__doc__,
 
262
"message.get_auto_start() -> bool\n"
 
263
"Return true if this message will cause an owner for the destination name\n"
 
264
"to be auto-started.\n");
 
265
static PyObject *
 
266
Message_get_auto_start(Message *self, PyObject *unused UNUSED)
 
267
{
 
268
    if (!self->msg) return DBusPy_RaiseUnusableMessage();
 
269
    return PyBool_FromLong(dbus_message_get_auto_start(self->msg));
 
270
}
 
271
 
 
272
PyDoc_STRVAR(Message_set_auto_start__doc__,
 
273
"message.set_auto_start(bool) -> None\n"
 
274
"Set whether this message will cause an owner for the destination name\n"
 
275
"to be auto-started.\n");
 
276
static PyObject *
 
277
Message_set_auto_start(Message *self, PyObject *args)
 
278
{
 
279
    int value;
 
280
    if (!PyArg_ParseTuple(args, "i", &value)) return NULL;
 
281
    if (!self->msg) return DBusPy_RaiseUnusableMessage();
 
282
    dbus_message_set_auto_start(self->msg, value ? TRUE : FALSE);
 
283
    Py_INCREF(Py_None);
 
284
    return Py_None;
 
285
}
 
286
 
 
287
PyDoc_STRVAR(Message_get_no_reply__doc__,
 
288
"message.get_no_reply() -> bool\n"
 
289
"Return true if this message need not be replied to.\n");
 
290
static PyObject *
 
291
Message_get_no_reply(Message *self, PyObject *unused UNUSED)
 
292
{
 
293
    if (!self->msg) return DBusPy_RaiseUnusableMessage();
 
294
    return PyBool_FromLong(dbus_message_get_no_reply(self->msg));
 
295
}
 
296
 
 
297
PyDoc_STRVAR(Message_set_no_reply__doc__,
 
298
"message.set_no_reply(bool) -> None\n"
 
299
"Set whether no reply to this message is required.\n");
 
300
static PyObject *
 
301
Message_set_no_reply(Message *self, PyObject *args)
 
302
{
 
303
    int value;
 
304
    if (!PyArg_ParseTuple(args, "i", &value)) return NULL;
 
305
    if (!self->msg) return DBusPy_RaiseUnusableMessage();
 
306
    dbus_message_set_no_reply(self->msg, value ? TRUE : FALSE);
 
307
    Py_RETURN_NONE;
 
308
}
 
309
 
 
310
PyDoc_STRVAR(Message_get_reply_serial__doc__,
 
311
"message.get_reply_serial() -> long\n"
 
312
"Returns the serial that the message is a reply to or 0 if none.\n");
 
313
static PyObject *
 
314
Message_get_reply_serial(Message *self, PyObject *unused UNUSED)
 
315
{
 
316
    if (!self->msg) return DBusPy_RaiseUnusableMessage();
 
317
    return PyLong_FromUnsignedLong(dbus_message_get_reply_serial(self->msg));
 
318
}
 
319
 
 
320
PyDoc_STRVAR(Message_set_reply_serial__doc__,
 
321
"message.set_reply_serial(bool) -> None\n"
 
322
"Set the serial that this message is a reply to.\n");
 
323
static PyObject *
 
324
Message_set_reply_serial(Message *self, PyObject *args)
 
325
{
 
326
    dbus_uint32_t value;
 
327
 
 
328
    if (!PyArg_ParseTuple(args, "k", &value)) return NULL;
 
329
    if (!self->msg) return DBusPy_RaiseUnusableMessage();
 
330
    if (!dbus_message_set_reply_serial(self->msg, value)) {
 
331
        return PyErr_NoMemory();
 
332
    }
 
333
    Py_INCREF(Py_None);
 
334
    return Py_None;
 
335
}
 
336
 
 
337
PyDoc_STRVAR(Message_get_type__doc__,
 
338
"message.get_type() -> int\n\n"
 
339
"Returns the type of the message.\n");
 
340
static PyObject *
 
341
Message_get_type(Message *self, PyObject *unused UNUSED)
 
342
{
 
343
    if (!self->msg) return DBusPy_RaiseUnusableMessage();
 
344
    return PyInt_FromLong(dbus_message_get_type(self->msg));
 
345
}
 
346
 
 
347
PyDoc_STRVAR(Message_get_serial__doc__,
 
348
"message.get_serial() -> long\n"
 
349
"Returns the serial of a message or 0 if none has been specified.\n"
 
350
"\n"
 
351
"The message's serial number is provided by the application sending the\n"
 
352
"message and is used to identify replies to this message. All messages\n"
 
353
"received on a connection will have a serial, but messages you haven't\n"
 
354
"sent yet may return 0.\n");
 
355
static PyObject *
 
356
Message_get_serial(Message *self, PyObject *unused UNUSED)
 
357
{
 
358
    if (!self->msg) return DBusPy_RaiseUnusableMessage();
 
359
    return PyLong_FromUnsignedLong(dbus_message_get_serial(self->msg));
 
360
}
 
361
 
 
362
PyDoc_STRVAR(Message_is_method_call__doc__,
 
363
"is_method_call(interface: str, member: str) -> bool");
 
364
static PyObject *
 
365
Message_is_method_call(Message *self, PyObject *args)
 
366
{
 
367
    const char *interface, *method;
 
368
 
 
369
    if (!PyArg_ParseTuple(args, "ss:is_method_call", &interface, &method)) {
 
370
        return NULL;
 
371
    }
 
372
    if (!self->msg) return DBusPy_RaiseUnusableMessage();
 
373
    return PyBool_FromLong(dbus_message_is_method_call(self->msg, interface,
 
374
                                                       method));
 
375
}
 
376
 
 
377
PyDoc_STRVAR(Message_is_error__doc__,
 
378
"is_error(error: str) -> bool");
 
379
static PyObject *
 
380
Message_is_error(Message *self, PyObject *args)
 
381
{
 
382
    const char *error_name;
 
383
 
 
384
    if (!PyArg_ParseTuple(args, "s:is_error", &error_name)) {
 
385
        return NULL;
 
386
    }
 
387
    if (!self->msg) return DBusPy_RaiseUnusableMessage();
 
388
    return PyBool_FromLong(dbus_message_is_error(self->msg, error_name));
 
389
}
 
390
 
 
391
PyDoc_STRVAR(Message_is_signal__doc__,
 
392
"is_signal(interface: str, member: str) -> bool");
 
393
static PyObject *
 
394
Message_is_signal(Message *self, PyObject *args)
 
395
{
 
396
    const char *interface, *signal_name;
 
397
 
 
398
    if (!PyArg_ParseTuple(args, "ss:is_signal", &interface, &signal_name)) {
 
399
        return NULL;
 
400
    }
 
401
    if (!self->msg) return DBusPy_RaiseUnusableMessage();
 
402
    return PyBool_FromLong(dbus_message_is_signal(self->msg, interface,
 
403
                                                    signal_name));
 
404
}
 
405
 
 
406
PyDoc_STRVAR(Message_get_member__doc__,
 
407
"get_member() -> str or None");
 
408
static PyObject *
 
409
Message_get_member(Message *self, PyObject *unused UNUSED)
 
410
{
 
411
    const char *c_str;
 
412
 
 
413
    if (!self->msg) return DBusPy_RaiseUnusableMessage();
 
414
    c_str = dbus_message_get_member(self->msg);
 
415
    if (!c_str) {
 
416
        Py_RETURN_NONE;
 
417
    }
 
418
    return PyString_FromString(c_str);
 
419
}
 
420
 
 
421
PyDoc_STRVAR(Message_has_member__doc__,
 
422
"has_member(name: str or None) -> bool");
 
423
static PyObject *
 
424
Message_has_member(Message *self, PyObject *args)
 
425
{
 
426
    const char *name;
 
427
 
 
428
    if (!PyArg_ParseTuple(args, "z:has_member", &name)) {
 
429
        return NULL;
 
430
    }
 
431
    if (!self->msg) return DBusPy_RaiseUnusableMessage();
 
432
    return PyBool_FromLong(dbus_message_has_member(self->msg, name));
 
433
}
 
434
 
 
435
PyDoc_STRVAR(Message_set_member__doc__,
 
436
"set_member(unique_name: str or None)");
 
437
static PyObject *
 
438
Message_set_member(Message *self, PyObject *args)
 
439
{
 
440
    const char *name;
 
441
 
 
442
    if (!PyArg_ParseTuple(args, "z:set_member", &name)) {
 
443
        return NULL;
 
444
    }
 
445
    if (!self->msg) return DBusPy_RaiseUnusableMessage();
 
446
    if (!dbus_py_validate_member_name(name)) return NULL;
 
447
    if (!dbus_message_set_member(self->msg, name)) return PyErr_NoMemory();
 
448
    Py_RETURN_NONE;
 
449
}
 
450
 
 
451
PyDoc_STRVAR(Message_get_path__doc__,
 
452
"get_path() -> ObjectPath or None\n\n"
 
453
"Return the message's destination object path (if it's a method call) or\n"
 
454
"source object path (if it's a method reply or a signal) or None (if it\n"
 
455
"has no path).\n");
 
456
static PyObject *
 
457
Message_get_path(Message *self, PyObject *unused UNUSED)
 
458
{
 
459
    const char *c_str;
 
460
 
 
461
    if (!self->msg) return DBusPy_RaiseUnusableMessage();
 
462
    c_str = dbus_message_get_path(self->msg);
 
463
    if (!c_str) {
 
464
        Py_RETURN_NONE;
 
465
    }
 
466
    return PyObject_CallFunction((PyObject *)&DBusPyObjectPath_Type, "(s)", c_str);
 
467
}
 
468
 
 
469
PyDoc_STRVAR(Message_get_path_decomposed__doc__,
 
470
"get_path_decomposed() -> list of str, or None\n\n"
 
471
"Return a list of path components (e.g. /foo/bar -> ['foo','bar'], / -> [])\n"
 
472
"or None if the message has no associated path.\n");
 
473
static PyObject *
 
474
Message_get_path_decomposed(Message *self, PyObject *unused UNUSED)
 
475
{
 
476
    char **paths, **ptr;
 
477
    PyObject *ret = PyList_New(0);
 
478
 
 
479
    if (!ret) return NULL;
 
480
    if (!self->msg) {
 
481
        Py_CLEAR(ret);
 
482
        return DBusPy_RaiseUnusableMessage();
 
483
    }
 
484
    if (!dbus_message_get_path_decomposed(self->msg, &paths)) {
 
485
        Py_CLEAR(ret);
 
486
        return PyErr_NoMemory();
 
487
    }
 
488
    if (!paths) {
 
489
        Py_CLEAR(ret);
 
490
        Py_RETURN_NONE;
 
491
    }
 
492
    for (ptr = paths; *ptr; ptr++) {
 
493
        PyObject *str = PyString_FromString(*ptr);
 
494
 
 
495
        if (!str) {
 
496
            Py_CLEAR(ret);
 
497
            break;
 
498
        }
 
499
        if (PyList_Append(ret, str) < 0) {
 
500
            Py_CLEAR(ret);
 
501
            break;
 
502
        }
 
503
        Py_CLEAR(str);
 
504
        str = NULL;
 
505
    }
 
506
    dbus_free_string_array(paths);
 
507
    return ret;
 
508
}
 
509
 
 
510
PyDoc_STRVAR(Message_has_path__doc__,
 
511
"has_path(name: str or None) -> bool");
 
512
static PyObject *
 
513
Message_has_path(Message *self, PyObject *args)
 
514
{
 
515
    const char *name;
 
516
 
 
517
    if (!PyArg_ParseTuple(args, "z:has_path", &name)) {
 
518
        return NULL;
 
519
    }
 
520
    if (!self->msg) return DBusPy_RaiseUnusableMessage();
 
521
    return PyBool_FromLong(dbus_message_has_path(self->msg, name));
 
522
}
 
523
 
 
524
PyDoc_STRVAR(Message_set_path__doc__,
 
525
"set_path(name: str or None)");
 
526
static PyObject *
 
527
Message_set_path(Message *self, PyObject *args)
 
528
{
 
529
    const char *name;
 
530
 
 
531
    if (!PyArg_ParseTuple(args, "z:set_path", &name)) return NULL;
 
532
    if (!self->msg) return DBusPy_RaiseUnusableMessage();
 
533
    if (!dbus_message_has_path(self->msg, name)) return PyErr_NoMemory();
 
534
    Py_RETURN_NONE;
 
535
}
 
536
 
 
537
PyDoc_STRVAR(Message_get_signature__doc__,
 
538
"get_signature() -> Signature or None");
 
539
static PyObject *
 
540
Message_get_signature(Message *self, PyObject *unused UNUSED)
 
541
{
 
542
    const char *c_str;
 
543
 
 
544
    if (!self->msg) return DBusPy_RaiseUnusableMessage();
 
545
    c_str = dbus_message_get_signature(self->msg);
 
546
    if (!c_str) {
 
547
        return PyObject_CallFunction((PyObject *)&DBusPySignature_Type, "(s)", "");
 
548
    }
 
549
    return PyObject_CallFunction((PyObject *)&DBusPySignature_Type, "(s)", c_str);
 
550
}
 
551
 
 
552
PyDoc_STRVAR(Message_has_signature__doc__,
 
553
"has_signature(signature: str) -> bool");
 
554
static PyObject *
 
555
Message_has_signature(Message *self, PyObject *args)
 
556
{
 
557
    const char *name;
 
558
 
 
559
    if (!PyArg_ParseTuple(args, "s:has_signature", &name)) {
 
560
        return NULL;
 
561
    }
 
562
    if (!self->msg) return DBusPy_RaiseUnusableMessage();
 
563
    return PyBool_FromLong(dbus_message_has_signature(self->msg, name));
 
564
}
 
565
 
 
566
PyDoc_STRVAR(Message_get_sender__doc__,
 
567
"get_sender() -> str or None\n\n"
 
568
"Return the message's sender unique name, or None if none.\n");
 
569
static PyObject *
 
570
Message_get_sender(Message *self, PyObject *unused UNUSED)
 
571
{
 
572
    const char *c_str;
 
573
 
 
574
    if (!self->msg) return DBusPy_RaiseUnusableMessage();
 
575
    c_str = dbus_message_get_sender(self->msg);
 
576
    if (!c_str) {
 
577
        Py_RETURN_NONE;
 
578
    }
 
579
    return PyString_FromString(c_str);
 
580
}
 
581
 
 
582
PyDoc_STRVAR(Message_has_sender__doc__,
 
583
"has_sender(unique_name: str) -> bool");
 
584
static PyObject *
 
585
Message_has_sender(Message *self, PyObject *args)
 
586
{
 
587
  const char *name;
 
588
 
 
589
  if (!PyArg_ParseTuple(args, "s:has_sender", &name)) {
 
590
      return NULL;
 
591
  }
 
592
  if (!self->msg) return DBusPy_RaiseUnusableMessage();
 
593
  return PyBool_FromLong(dbus_message_has_sender(self->msg, name));
 
594
}
 
595
 
 
596
PyDoc_STRVAR(Message_set_sender__doc__,
 
597
"set_sender(unique_name: str or None)");
 
598
static PyObject *
 
599
Message_set_sender(Message *self, PyObject *args)
 
600
{
 
601
    const char *name;
 
602
 
 
603
    if (!PyArg_ParseTuple(args, "z:set_sender", &name)) {
 
604
        return NULL;
 
605
    }
 
606
    if (!self->msg) return DBusPy_RaiseUnusableMessage();
 
607
    if (!dbus_py_validate_bus_name(name, 1, 1)) return NULL;
 
608
    if (!dbus_message_set_sender(self->msg, name)) return PyErr_NoMemory();
 
609
    Py_RETURN_NONE;
 
610
}
 
611
 
 
612
PyDoc_STRVAR(Message_get_destination__doc__,
 
613
"get_destination() -> str or None\n\n"
 
614
"Return the message's destination bus name, or None if none.\n");
 
615
static PyObject *
 
616
Message_get_destination(Message *self, PyObject *unused UNUSED)
 
617
{
 
618
    const char *c_str;
 
619
 
 
620
    if (!self->msg) return DBusPy_RaiseUnusableMessage();
 
621
    c_str = dbus_message_get_destination(self->msg);
 
622
    if (!c_str) {
 
623
        Py_RETURN_NONE;
 
624
    }
 
625
    return PyString_FromString(c_str);
 
626
}
 
627
 
 
628
PyDoc_STRVAR(Message_has_destination__doc__,
 
629
"has_destination(bus_name: str) -> bool");
 
630
static PyObject *
 
631
Message_has_destination(Message *self, PyObject *args)
 
632
{
 
633
    const char *name;
 
634
 
 
635
    if (!PyArg_ParseTuple(args, "s:has_destination", &name)) {
 
636
        return NULL;
 
637
    }
 
638
    if (!self->msg) return DBusPy_RaiseUnusableMessage();
 
639
    return PyBool_FromLong(dbus_message_has_destination(self->msg, name));
 
640
}
 
641
 
 
642
PyDoc_STRVAR(Message_set_destination__doc__,
 
643
"set_destination(bus_name: str or None)");
 
644
static PyObject *
 
645
Message_set_destination(Message *self, PyObject *args)
 
646
{
 
647
    const char *name;
 
648
 
 
649
    if (!PyArg_ParseTuple(args, "z:set_destination", &name)) {
 
650
        return NULL;
 
651
    }
 
652
    if (!self->msg) return DBusPy_RaiseUnusableMessage();
 
653
    if (!dbus_py_validate_bus_name(name, 1, 1)) return NULL;
 
654
    if (!dbus_message_set_destination(self->msg, name)) return PyErr_NoMemory();
 
655
    Py_RETURN_NONE;
 
656
}
 
657
 
 
658
PyDoc_STRVAR(Message_get_interface__doc__,
 
659
"get_interface() -> str or None");
 
660
static PyObject *
 
661
Message_get_interface(Message *self, PyObject *unused UNUSED)
 
662
{
 
663
    const char *c_str;
 
664
 
 
665
    if (!self->msg) return DBusPy_RaiseUnusableMessage();
 
666
    c_str = dbus_message_get_interface(self->msg);
 
667
    if (!c_str) {
 
668
        Py_RETURN_NONE;
 
669
    }
 
670
    return PyString_FromString(c_str);
 
671
}
 
672
 
 
673
PyDoc_STRVAR(Message_has_interface__doc__,
 
674
"has_interface(interface: str or None) -> bool");
 
675
static PyObject *
 
676
Message_has_interface(Message *self, PyObject *args)
 
677
{
 
678
    const char *name;
 
679
 
 
680
    if (!PyArg_ParseTuple(args, "z:has_interface", &name)) {
 
681
        return NULL;
 
682
    }
 
683
    if (!self->msg) return DBusPy_RaiseUnusableMessage();
 
684
    return PyBool_FromLong(dbus_message_has_interface(self->msg, name));
 
685
}
 
686
 
 
687
PyDoc_STRVAR(Message_set_interface__doc__,
 
688
"set_interface(name: str or None)");
 
689
static PyObject *
 
690
Message_set_interface(Message *self, PyObject *args)
 
691
{
 
692
    const char *name;
 
693
 
 
694
    if (!PyArg_ParseTuple(args, "z:set_interface", &name)) {
 
695
        return NULL;
 
696
    }
 
697
    if (!self->msg) return DBusPy_RaiseUnusableMessage();
 
698
    if (!dbus_py_validate_interface_name(name)) return NULL;
 
699
    if (!dbus_message_set_interface(self->msg, name)) return PyErr_NoMemory();
 
700
    Py_RETURN_NONE;
 
701
}
 
702
 
 
703
PyDoc_STRVAR(Message_get_error_name__doc__,
 
704
"get_error_name() -> str or None");
 
705
static PyObject *
 
706
Message_get_error_name(Message *self, PyObject *unused UNUSED)
 
707
{
 
708
    const char *c_str;
 
709
 
 
710
    if (!self->msg) return DBusPy_RaiseUnusableMessage();
 
711
    c_str = dbus_message_get_error_name(self->msg);
 
712
    if (!c_str) {
 
713
        Py_RETURN_NONE;
 
714
    }
 
715
    return PyString_FromString(c_str);
 
716
}
 
717
 
 
718
PyDoc_STRVAR(Message_set_error_name__doc__,
 
719
"set_error_name(name: str or None)");
 
720
static PyObject *
 
721
Message_set_error_name(Message *self, PyObject *args)
 
722
{
 
723
    const char *name;
 
724
 
 
725
    if (!PyArg_ParseTuple(args, "z:set_error_name", &name)) {
 
726
        return NULL;
 
727
    }
 
728
    if (!self->msg) return DBusPy_RaiseUnusableMessage();
 
729
    if (!dbus_py_validate_error_name(name)) return NULL;
 
730
    if (!dbus_message_set_error_name(self->msg, name)) return PyErr_NoMemory();
 
731
    Py_RETURN_NONE;
 
732
}
 
733
 
 
734
static PyMethodDef Message_tp_methods[] = {
 
735
    {"copy", (PyCFunction)Message_copy,
 
736
      METH_NOARGS, Message_copy__doc__},
 
737
    {"is_method_call", (PyCFunction)Message_is_method_call,
 
738
      METH_VARARGS, Message_is_method_call__doc__},
 
739
    {"is_signal", (PyCFunction)Message_is_signal,
 
740
      METH_VARARGS, Message_is_signal__doc__},
 
741
    {"is_error", (PyCFunction)Message_is_error,
 
742
      METH_VARARGS, Message_is_error__doc__},
 
743
 
 
744
    {"get_args_list", (PyCFunction)dbus_py_Message_get_args_list,
 
745
      METH_VARARGS|METH_KEYWORDS, dbus_py_Message_get_args_list__doc__},
 
746
    {"guess_signature", (PyCFunction)dbus_py_Message_guess_signature,
 
747
      METH_VARARGS|METH_STATIC, dbus_py_Message_guess_signature__doc__},
 
748
    {"append", (PyCFunction)dbus_py_Message_append,
 
749
      METH_VARARGS|METH_KEYWORDS, dbus_py_Message_append__doc__},
 
750
 
 
751
    {"get_auto_start", (PyCFunction)Message_get_auto_start,
 
752
      METH_NOARGS, Message_get_auto_start__doc__},
 
753
    {"set_auto_start", (PyCFunction)Message_set_auto_start,
 
754
      METH_VARARGS, Message_set_auto_start__doc__},
 
755
    {"get_destination", (PyCFunction)Message_get_destination,
 
756
      METH_NOARGS, Message_get_destination__doc__},
 
757
    {"set_destination", (PyCFunction)Message_set_destination,
 
758
      METH_VARARGS, Message_set_destination__doc__},
 
759
    {"has_destination", (PyCFunction)Message_has_destination,
 
760
      METH_VARARGS, Message_has_destination__doc__},
 
761
    {"get_error_name", (PyCFunction)Message_get_error_name,
 
762
      METH_NOARGS, Message_get_error_name__doc__},
 
763
    {"set_error_name", (PyCFunction)Message_set_error_name,
 
764
      METH_VARARGS, Message_set_error_name__doc__},
 
765
    {"get_interface", (PyCFunction)Message_get_interface,
 
766
      METH_NOARGS, Message_get_interface__doc__},
 
767
    {"set_interface", (PyCFunction)Message_set_interface,
 
768
      METH_VARARGS, Message_set_interface__doc__},
 
769
    {"has_interface", (PyCFunction)Message_has_interface,
 
770
      METH_VARARGS, Message_has_interface__doc__},
 
771
    {"get_member", (PyCFunction)Message_get_member,
 
772
      METH_NOARGS, Message_get_member__doc__},
 
773
    {"set_member", (PyCFunction)Message_set_member,
 
774
      METH_VARARGS, Message_set_member__doc__},
 
775
    {"has_member", (PyCFunction)Message_has_member,
 
776
      METH_VARARGS, Message_has_member__doc__},
 
777
    {"get_path", (PyCFunction)Message_get_path,
 
778
      METH_NOARGS, Message_get_path__doc__},
 
779
    {"get_path_decomposed", (PyCFunction)Message_get_path_decomposed,
 
780
      METH_NOARGS, Message_get_path_decomposed__doc__},
 
781
    {"set_path", (PyCFunction)Message_set_path,
 
782
      METH_VARARGS, Message_set_path__doc__},
 
783
    {"has_path", (PyCFunction)Message_has_path,
 
784
      METH_VARARGS, Message_has_path__doc__},
 
785
    {"get_no_reply", (PyCFunction)Message_get_no_reply,
 
786
      METH_NOARGS, Message_get_no_reply__doc__},
 
787
    {"set_no_reply", (PyCFunction)Message_set_no_reply,
 
788
      METH_VARARGS, Message_set_no_reply__doc__},
 
789
    {"get_reply_serial", (PyCFunction)Message_get_reply_serial,
 
790
      METH_NOARGS, Message_get_reply_serial__doc__},
 
791
    {"set_reply_serial", (PyCFunction)Message_set_reply_serial,
 
792
      METH_VARARGS, Message_set_reply_serial__doc__},
 
793
    {"get_sender", (PyCFunction)Message_get_sender,
 
794
      METH_NOARGS, Message_get_sender__doc__},
 
795
    {"set_sender", (PyCFunction)Message_set_sender,
 
796
      METH_VARARGS, Message_set_sender__doc__},
 
797
    {"has_sender", (PyCFunction)Message_has_sender,
 
798
      METH_VARARGS, Message_has_sender__doc__},
 
799
    {"get_serial", (PyCFunction)Message_get_serial,
 
800
      METH_NOARGS, Message_get_serial__doc__},
 
801
    {"get_signature", (PyCFunction)Message_get_signature,
 
802
      METH_NOARGS, Message_get_signature__doc__},
 
803
    {"has_signature", (PyCFunction)Message_has_signature,
 
804
      METH_VARARGS, Message_has_signature__doc__},
 
805
    {"get_type", (PyCFunction)Message_get_type,
 
806
      METH_NOARGS, Message_get_type__doc__},
 
807
    {NULL, NULL, 0, NULL}
 
808
};
 
809
 
 
810
static PyTypeObject MessageType = {
 
811
    PyObject_HEAD_INIT(NULL)
 
812
    0,                         /*ob_size*/
 
813
    "dbus.lowlevel.Message",   /*tp_name*/
 
814
    sizeof(Message),     /*tp_basicsize*/
 
815
    0,                         /*tp_itemsize*/
 
816
    (destructor)Message_tp_dealloc, /*tp_dealloc*/
 
817
    0,                         /*tp_print*/
 
818
    0,                         /*tp_getattr*/
 
819
    0,                         /*tp_setattr*/
 
820
    0,                         /*tp_compare*/
 
821
    0,                         /*tp_repr*/
 
822
    0,                         /*tp_as_number*/
 
823
    0,                         /*tp_as_sequence*/
 
824
    0,                         /*tp_as_mapping*/
 
825
    0,                         /*tp_hash */
 
826
    0,                         /*tp_call*/
 
827
    0,                         /*tp_str*/
 
828
    0,                         /*tp_getattro*/
 
829
    0,                         /*tp_setattro*/
 
830
    0,                         /*tp_as_buffer*/
 
831
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
 
832
    Message_tp_doc,            /* tp_doc */
 
833
    0,                         /* tp_traverse */
 
834
    0,                         /* tp_clear */
 
835
    0,                         /* tp_richcompare */
 
836
    0,                         /* tp_weaklistoffset */
 
837
    0,                         /* tp_iter */
 
838
    0,                         /* tp_iternext */
 
839
    Message_tp_methods,        /* tp_methods */
 
840
    0,                         /* tp_members */
 
841
    0,                         /* tp_getset */
 
842
    0,                         /* tp_base */
 
843
    0,                         /* tp_dict */
 
844
    0,                         /* tp_descr_get */
 
845
    0,                         /* tp_descr_set */
 
846
    0,                         /* tp_dictoffset */
 
847
    0,                         /* tp_init */
 
848
    0,                         /* tp_alloc */
 
849
    Message_tp_new,            /* tp_new */
 
850
};
 
851
 
 
852
static PyTypeObject MethodCallMessageType = {
 
853
    PyObject_HEAD_INIT(NULL)
 
854
    0,                         /*ob_size*/
 
855
    "dbus.lowlevel.MethodCallMessage",  /*tp_name*/
 
856
    0,                         /*tp_basicsize*/
 
857
    0,                         /*tp_itemsize*/
 
858
    0,                         /*tp_dealloc*/
 
859
    0,                         /*tp_print*/
 
860
    0,                         /*tp_getattr*/
 
861
    0,                         /*tp_setattr*/
 
862
    0,                         /*tp_compare*/
 
863
    0,                         /*tp_repr*/
 
864
    0,                         /*tp_as_number*/
 
865
    0,                         /*tp_as_sequence*/
 
866
    0,                         /*tp_as_mapping*/
 
867
    0,                         /*tp_hash */
 
868
    0,                         /*tp_call*/
 
869
    0,                         /*tp_str*/
 
870
    0,                         /*tp_getattro*/
 
871
    0,                         /*tp_setattro*/
 
872
    0,                         /*tp_as_buffer*/
 
873
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
 
874
    MethodCallMessage_tp_doc,  /* tp_doc */
 
875
    0,                         /* tp_traverse */
 
876
    0,                         /* tp_clear */
 
877
    0,                         /* tp_richcompare */
 
878
    0,                         /* tp_weaklistoffset */
 
879
    0,                         /* tp_iter */
 
880
    0,                         /* tp_iternext */
 
881
    0,                         /* tp_methods */
 
882
    0,                         /* tp_members */
 
883
    0,                         /* tp_getset */
 
884
    DEFERRED_ADDRESS(&MessageType),   /* tp_base */
 
885
    0,                         /* tp_dict */
 
886
    0,                         /* tp_descr_get */
 
887
    0,                         /* tp_descr_set */
 
888
    0,                         /* tp_dictoffset */
 
889
    (initproc)MethodCallMessage_tp_init,    /* tp_init */
 
890
    0,                         /* tp_alloc */
 
891
    0,                         /* tp_new */
 
892
};
 
893
 
 
894
static PyTypeObject MethodReturnMessageType = {
 
895
    PyObject_HEAD_INIT(NULL)
 
896
    0,                         /*ob_size*/
 
897
    "dbus.lowlevel.MethodReturnMessage",  /*tp_name*/
 
898
    0,                         /*tp_basicsize*/
 
899
    0,                         /*tp_itemsize*/
 
900
    0,                         /*tp_dealloc*/
 
901
    0,                         /*tp_print*/
 
902
    0,                         /*tp_getattr*/
 
903
    0,                         /*tp_setattr*/
 
904
    0,                         /*tp_compare*/
 
905
    0,                         /*tp_repr*/
 
906
    0,                         /*tp_as_number*/
 
907
    0,                         /*tp_as_sequence*/
 
908
    0,                         /*tp_as_mapping*/
 
909
    0,                         /*tp_hash */
 
910
    0,                         /*tp_call*/
 
911
    0,                         /*tp_str*/
 
912
    0,                         /*tp_getattro*/
 
913
    0,                         /*tp_setattro*/
 
914
    0,                         /*tp_as_buffer*/
 
915
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
 
916
    MethodReturnMessage_tp_doc,  /* tp_doc */
 
917
    0,                         /* tp_traverse */
 
918
    0,                         /* tp_clear */
 
919
    0,                         /* tp_richcompare */
 
920
    0,                         /* tp_weaklistoffset */
 
921
    0,                         /* tp_iter */
 
922
    0,                         /* tp_iternext */
 
923
    0,                         /* tp_methods */
 
924
    0,                         /* tp_members */
 
925
    0,                         /* tp_getset */
 
926
    DEFERRED_ADDRESS(&MessageType),   /* tp_base */
 
927
    0,                         /* tp_dict */
 
928
    0,                         /* tp_descr_get */
 
929
    0,                         /* tp_descr_set */
 
930
    0,                         /* tp_dictoffset */
 
931
    (initproc)MethodReturnMessage_tp_init,    /* tp_init */
 
932
    0,                         /* tp_alloc */
 
933
    0,                         /* tp_new */
 
934
};
 
935
 
 
936
static PyTypeObject SignalMessageType = {
 
937
    PyObject_HEAD_INIT(NULL)
 
938
    0,                         /*ob_size*/
 
939
    "dbus.lowlevel.SignalMessage",  /*tp_name*/
 
940
    0,                         /*tp_basicsize*/
 
941
    0,                         /*tp_itemsize*/
 
942
    0,                         /*tp_dealloc*/
 
943
    0,                         /*tp_print*/
 
944
    0,                         /*tp_getattr*/
 
945
    0,                         /*tp_setattr*/
 
946
    0,                         /*tp_compare*/
 
947
    0,                         /*tp_repr*/
 
948
    0,                         /*tp_as_number*/
 
949
    0,                         /*tp_as_sequence*/
 
950
    0,                         /*tp_as_mapping*/
 
951
    0,                         /*tp_hash */
 
952
    0,                         /*tp_call*/
 
953
    0,                         /*tp_str*/
 
954
    0,                         /*tp_getattro*/
 
955
    0,                         /*tp_setattro*/
 
956
    0,                         /*tp_as_buffer*/
 
957
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
 
958
    SignalMessage_tp_doc,  /* tp_doc */
 
959
    0,                         /* tp_traverse */
 
960
    0,                         /* tp_clear */
 
961
    0,                         /* tp_richcompare */
 
962
    0,                         /* tp_weaklistoffset */
 
963
    0,                         /* tp_iter */
 
964
    0,                         /* tp_iternext */
 
965
    0,                         /* tp_methods */
 
966
    0,                         /* tp_members */
 
967
    0,                         /* tp_getset */
 
968
    DEFERRED_ADDRESS(&MessageType),   /* tp_base */
 
969
    0,                         /* tp_dict */
 
970
    0,                         /* tp_descr_get */
 
971
    0,                         /* tp_descr_set */
 
972
    0,                         /* tp_dictoffset */
 
973
    (initproc)SignalMessage_tp_init,    /* tp_init */
 
974
    0,                         /* tp_alloc */
 
975
    0,                         /* tp_new */
 
976
};
 
977
 
 
978
static PyTypeObject ErrorMessageType = {
 
979
    PyObject_HEAD_INIT(NULL)
 
980
    0,                         /*ob_size*/
 
981
    "dbus.lowlevel.ErrorMessage",  /*tp_name*/
 
982
    0,                         /*tp_basicsize*/
 
983
    0,                         /*tp_itemsize*/
 
984
    0,                         /*tp_dealloc*/
 
985
    0,                         /*tp_print*/
 
986
    0,                         /*tp_getattr*/
 
987
    0,                         /*tp_setattr*/
 
988
    0,                         /*tp_compare*/
 
989
    0,                         /*tp_repr*/
 
990
    0,                         /*tp_as_number*/
 
991
    0,                         /*tp_as_sequence*/
 
992
    0,                         /*tp_as_mapping*/
 
993
    0,                         /*tp_hash */
 
994
    0,                         /*tp_call*/
 
995
    0,                         /*tp_str*/
 
996
    0,                         /*tp_getattro*/
 
997
    0,                         /*tp_setattro*/
 
998
    0,                         /*tp_as_buffer*/
 
999
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
 
1000
    ErrorMessage_tp_doc,  /* tp_doc */
 
1001
    0,                         /* tp_traverse */
 
1002
    0,                         /* tp_clear */
 
1003
    0,                         /* tp_richcompare */
 
1004
    0,                         /* tp_weaklistoffset */
 
1005
    0,                         /* tp_iter */
 
1006
    0,                         /* tp_iternext */
 
1007
    0,                         /* tp_methods */
 
1008
    0,                         /* tp_members */
 
1009
    0,                         /* tp_getset */
 
1010
    DEFERRED_ADDRESS(&MessageType),   /* tp_base */
 
1011
    0,                         /* tp_dict */
 
1012
    0,                         /* tp_descr_get */
 
1013
    0,                         /* tp_descr_set */
 
1014
    0,                         /* tp_dictoffset */
 
1015
    (initproc)ErrorMessage_tp_init,    /* tp_init */
 
1016
    0,                         /* tp_alloc */
 
1017
    0,                         /* tp_new */
 
1018
};
 
1019
 
 
1020
dbus_bool_t
 
1021
dbus_py_init_message_types(void)
 
1022
{
 
1023
    if (PyType_Ready(&MessageType) < 0) return 0;
 
1024
 
 
1025
    MethodCallMessageType.tp_base = &MessageType;
 
1026
    if (PyType_Ready(&MethodCallMessageType) < 0) return 0;
 
1027
 
 
1028
    MethodReturnMessageType.tp_base = &MessageType;
 
1029
    if (PyType_Ready(&MethodReturnMessageType) < 0) return 0;
 
1030
 
 
1031
    SignalMessageType.tp_base = &MessageType;
 
1032
    if (PyType_Ready(&SignalMessageType) < 0) return 0;
 
1033
 
 
1034
    ErrorMessageType.tp_base = &MessageType;
 
1035
    if (PyType_Ready(&ErrorMessageType) < 0) return 0;
 
1036
 
 
1037
    return 1;
 
1038
}
 
1039
 
 
1040
dbus_bool_t
 
1041
dbus_py_insert_message_types(PyObject *this_module)
 
1042
{
 
1043
    /* PyModule_AddObject steals a ref */
 
1044
    Py_INCREF (&MessageType);
 
1045
    Py_INCREF (&MethodCallMessageType);
 
1046
    Py_INCREF (&MethodReturnMessageType);
 
1047
    Py_INCREF (&ErrorMessageType);
 
1048
    Py_INCREF (&SignalMessageType);
 
1049
 
 
1050
    if (PyModule_AddObject(this_module, "Message",
 
1051
                         (PyObject *)&MessageType) < 0) return 0;
 
1052
 
 
1053
    if (PyModule_AddObject(this_module, "MethodCallMessage",
 
1054
                         (PyObject *)&MethodCallMessageType) < 0) return 0;
 
1055
 
 
1056
    if (PyModule_AddObject(this_module, "MethodReturnMessage",
 
1057
                         (PyObject *)&MethodReturnMessageType) < 0) return 0;
 
1058
 
 
1059
    if (PyModule_AddObject(this_module, "ErrorMessage",
 
1060
                         (PyObject *)&ErrorMessageType) < 0) return 0;
 
1061
 
 
1062
    if (PyModule_AddObject(this_module, "SignalMessage",
 
1063
                         (PyObject *)&SignalMessageType) < 0) return 0;
 
1064
 
 
1065
    return 1;
 
1066
}
 
1067
 
 
1068
/* vim:set ft=c cino< sw=4 sts=4 et: */