_dbus_bindings: split out conn, conn-methods into separate translation units
[dbus-python-phuang.git] / _dbus_bindings / message-impl.h
blobe0189a7cd07759573ccd636ecf5ee5bfd7bd12da
1 /* Implementation of D-Bus Message and subclasses (but see message-get-args.h
2 * and message-append.h for unserialization and serialization code).
4 * Copyright (C) 2006 Collabora Ltd.
6 * Licensed under the Academic Free License version 2.1
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 static PyTypeObject MessageType, SignalMessageType, ErrorMessageType;
27 static PyTypeObject MethodReturnMessageType, MethodCallMessageType;
29 static inline int Message_Check (PyObject *o)
31 return (o->ob_type == &MessageType)
32 || PyObject_IsInstance(o, (PyObject *)&MessageType);
35 typedef struct {
36 PyObject_HEAD
37 DBusMessage *msg;
38 } Message;
40 PyDoc_STRVAR(Message_tp_doc,
41 "A message to be sent or received over a D-Bus Connection.\n");
43 static void Message_tp_dealloc (Message *self)
45 if (self->msg) {
46 dbus_message_unref (self->msg);
48 self->ob_type->tp_free ((PyObject *)self);
51 static PyObject *
52 Message_tp_new (PyTypeObject *type,
53 PyObject *args UNUSED,
54 PyObject *kwargs UNUSED)
56 Message *self;
58 self = (Message *)type->tp_alloc (type, 0);
59 if (!self) return NULL;
60 self->msg = NULL;
61 return (PyObject *)self;
64 PyDoc_STRVAR(MethodCallMessage_tp_doc, "A method-call message.\n\n"
65 "MethodCallMessage(destination: str or None, path: str,\n"
66 " interface: str or None, method: str)\n");
67 static int
68 MethodCallMessage_tp_init (Message *self, PyObject *args, PyObject *kwargs)
70 const char *destination, *path, *interface, *method;
71 static char *kwlist[] = {"destination", "path", "interface", "method", NULL};
73 if (!PyArg_ParseTupleAndKeywords (args, kwargs, "zszs:__init__", kwlist,
74 &destination, &path, &interface,
75 &method)) {
76 return -1;
78 if (destination && !dbus_py_validate_bus_name(destination, 1, 1)) return -1;
79 if (!dbus_py_validate_object_path(path)) return -1;
80 if (interface && !dbus_py_validate_interface_name(interface)) return -1;
81 if (!dbus_py_validate_member_name(method)) return -1;
82 if (self->msg) {
83 dbus_message_unref (self->msg);
84 self->msg = NULL;
86 self->msg = dbus_message_new_method_call (destination, path, interface,
87 method);
88 if (!self->msg) {
89 PyErr_NoMemory();
90 return -1;
92 return 0;
95 PyDoc_STRVAR(MethodReturnMessage_tp_doc, "A method-return message.\n\n"
96 "MethodReturnMessage(method_call: MethodCallMessage)\n");
97 static int
98 MethodReturnMessage_tp_init (Message *self, PyObject *args, PyObject *kwargs)
100 Message *other;
101 static char *kwlist[] = {"method_call", NULL};
103 if (!PyArg_ParseTupleAndKeywords (args, kwargs, "O!:__init__", kwlist,
104 &MessageType, &other)) {
105 return -1;
107 if (self->msg) {
108 dbus_message_unref (self->msg);
109 self->msg = NULL;
111 self->msg = dbus_message_new_method_return (other->msg);
112 if (!self->msg) {
113 PyErr_NoMemory();
114 return -1;
116 return 0;
119 PyDoc_STRVAR(SignalMessage_tp_doc, "A signal message.\n\n"
120 "SignalMessage(path: str, interface: str, method: str)\n");
121 static int
122 SignalMessage_tp_init (Message *self, PyObject *args, PyObject *kwargs)
124 const char *path, *interface, *name;
125 static char *kwlist[] = {"path", "interface", "name", NULL};
127 if (!PyArg_ParseTupleAndKeywords (args, kwargs, "sss:__init__", kwlist,
128 &path, &interface, &name)) {
129 return -1;
131 if (!dbus_py_validate_object_path(path)) return -1;
132 if (!dbus_py_validate_interface_name(interface)) return -1;
133 if (!dbus_py_validate_member_name(name)) return -1;
134 if (self->msg) {
135 dbus_message_unref (self->msg);
136 self->msg = NULL;
138 self->msg = dbus_message_new_signal (path, interface, name);
139 if (!self->msg) {
140 PyErr_NoMemory();
141 return -1;
143 return 0;
146 PyDoc_STRVAR(ErrorMessage_tp_doc, "An error message.\n\n"
147 "ErrorMessage(reply_to: Message, error_name: str,\n"
148 " error_message: str or None)\n");
149 static int
150 ErrorMessage_tp_init (Message *self, PyObject *args, PyObject *kwargs)
152 Message *reply_to;
153 const char *error_name, *error_message;
154 static char *kwlist[] = {"reply_to", "error_name", "error_message", NULL};
156 if (!PyArg_ParseTupleAndKeywords (args, kwargs, "O!sz:__init__", kwlist,
157 &MessageType, &reply_to, &error_name,
158 &error_message)) {
159 return -1;
161 if (!dbus_py_validate_error_name(error_name)) return -1;
162 if (self->msg) {
163 dbus_message_unref (self->msg);
164 self->msg = NULL;
166 self->msg = dbus_message_new_error (reply_to->msg, error_name, error_message);
167 if (!self->msg) {
168 PyErr_NoMemory();
169 return -1;
171 return 0;
174 DBusMessage *
175 DBusPyMessage_BorrowDBusMessage(PyObject *msg)
177 if (!Message_Check (msg)) {
178 PyErr_SetString (PyExc_TypeError,
179 "A _dbus_bindings.Message instance is required");
180 return NULL;
182 if (!((Message *)msg)->msg) {
183 DBusException_UnusableMessage();
184 return NULL;
186 return ((Message *)msg)->msg;
189 static PyObject *
190 Message_ConsumeDBusMessage (DBusMessage *msg)
192 PyTypeObject *type;
193 Message *self;
195 switch (dbus_message_get_type (msg)) {
196 case DBUS_MESSAGE_TYPE_METHOD_CALL:
197 type = &MethodCallMessageType;
198 break;
199 case DBUS_MESSAGE_TYPE_METHOD_RETURN:
200 type = &MethodReturnMessageType;
201 break;
202 case DBUS_MESSAGE_TYPE_ERROR:
203 type = &ErrorMessageType;
204 break;
205 case DBUS_MESSAGE_TYPE_SIGNAL:
206 type = &SignalMessageType;
207 break;
208 default:
209 type = &MessageType;
212 self = (Message *)(type->tp_new) (type, empty_tuple, NULL);
213 if (!self) {
214 dbus_message_unref(msg);
215 return NULL;
217 self->msg = msg;
218 return (PyObject *)self;
221 PyDoc_STRVAR(Message_copy__doc__,
222 "message.copy() -> Message (or subclass)\n"
223 "Deep-copy the message, resetting the serial number to zero.\n");
224 static PyObject *
225 Message_copy (Message *self, PyObject *args UNUSED)
227 DBusMessage *msg;
228 if (!self->msg) return DBusException_UnusableMessage();
229 msg = dbus_message_copy(self->msg);
230 if (!msg) return PyErr_NoMemory();
231 return Message_ConsumeDBusMessage(msg);
234 PyDoc_STRVAR(Message_get_auto_start__doc__,
235 "message.get_auto_start() -> bool\n"
236 "Return true if this message will cause an owner for the destination name\n"
237 "to be auto-started.\n");
238 static PyObject *
239 Message_get_auto_start (Message *self, PyObject *unused UNUSED)
241 if (!self->msg) return DBusException_UnusableMessage();
242 return PyBool_FromLong (dbus_message_get_auto_start (self->msg));
245 PyDoc_STRVAR(Message_set_auto_start__doc__,
246 "message.set_auto_start(bool) -> None\n"
247 "Set whether this message will cause an owner for the destination name\n"
248 "to be auto-started.\n");
249 static PyObject *
250 Message_set_auto_start (Message *self, PyObject *args)
252 int value;
253 if (!PyArg_ParseTuple (args, "i", &value)) return NULL;
254 if (!self->msg) return DBusException_UnusableMessage();
255 dbus_message_set_auto_start (self->msg, value ? TRUE : FALSE);
256 Py_INCREF(Py_None);
257 return Py_None;
260 PyDoc_STRVAR(Message_get_no_reply__doc__,
261 "message.get_no_reply() -> bool\n"
262 "Return true if this message need not be replied to.\n");
263 static PyObject *
264 Message_get_no_reply (Message *self, PyObject *unused UNUSED)
266 if (!self->msg) return DBusException_UnusableMessage();
267 return PyBool_FromLong (dbus_message_get_no_reply (self->msg));
270 PyDoc_STRVAR(Message_set_no_reply__doc__,
271 "message.set_no_reply(bool) -> None\n"
272 "Set whether no reply to this message is required.\n");
273 static PyObject *
274 Message_set_no_reply (Message *self, PyObject *args)
276 int value;
277 if (!PyArg_ParseTuple (args, "i", &value)) return NULL;
278 if (!self->msg) return DBusException_UnusableMessage();
279 dbus_message_set_no_reply (self->msg, value ? TRUE : FALSE);
280 Py_RETURN_NONE;
283 PyDoc_STRVAR(Message_get_reply_serial__doc__,
284 "message.get_reply_serial() -> long\n"
285 "Returns the serial that the message is a reply to or 0 if none.\n");
286 static PyObject *
287 Message_get_reply_serial (Message *self, PyObject *unused UNUSED)
289 if (!self->msg) return DBusException_UnusableMessage();
290 return PyLong_FromUnsignedLong (dbus_message_get_reply_serial (self->msg));
293 PyDoc_STRVAR(Message_set_reply_serial__doc__,
294 "message.set_reply_serial(bool) -> None\n"
295 "Set the serial that this message is a reply to.\n");
296 static PyObject *
297 Message_set_reply_serial (Message *self, PyObject *args)
299 dbus_uint32_t value;
301 if (!PyArg_ParseTuple (args, "k", &value)) return NULL;
302 if (!self->msg) return DBusException_UnusableMessage();
303 if (!dbus_message_set_reply_serial (self->msg, value)) {
304 return PyErr_NoMemory();
306 Py_INCREF(Py_None);
307 return Py_None;
310 PyDoc_STRVAR(Message_get_type__doc__,
311 "message.get_type() -> int\n\n"
312 "Returns the type of the message.\n");
313 static PyObject *
314 Message_get_type (Message *self, PyObject *unused UNUSED)
316 if (!self->msg) return DBusException_UnusableMessage();
317 return PyInt_FromLong (dbus_message_get_type (self->msg));
320 PyDoc_STRVAR(Message_get_serial__doc__,
321 "message.get_serial() -> long\n"
322 "Returns the serial of a message or 0 if none has been specified.\n"
323 "\n"
324 "The message's serial number is provided by the application sending the\n"
325 "message and is used to identify replies to this message. All messages\n"
326 "received on a connection will have a serial, but messages you haven't\n"
327 "sent yet may return 0.\n");
328 static PyObject *
329 Message_get_serial (Message *self, PyObject *unused UNUSED)
331 if (!self->msg) return DBusException_UnusableMessage();
332 return PyLong_FromUnsignedLong (dbus_message_get_serial (self->msg));
335 PyDoc_STRVAR(Message_is_method_call__doc__,
336 "is_method_call(interface: str, member: str) -> bool");
337 static PyObject *
338 Message_is_method_call (Message *self, PyObject *args)
340 const char *interface, *method;
342 if (!PyArg_ParseTuple(args, "ss:is_method_call", &interface, &method)) {
343 return NULL;
345 if (!self->msg) return DBusException_UnusableMessage();
346 return PyBool_FromLong (dbus_message_is_method_call (self->msg, interface,
347 method));
350 PyDoc_STRVAR(Message_is_error__doc__,
351 "is_error(error: str) -> bool");
352 static PyObject *
353 Message_is_error (Message *self, PyObject *args)
355 const char *error_name;
357 if (!PyArg_ParseTuple(args, "s:is_error", &error_name)) {
358 return NULL;
360 if (!self->msg) return DBusException_UnusableMessage();
361 return PyBool_FromLong (dbus_message_is_error (self->msg, error_name));
364 PyDoc_STRVAR(Message_is_signal__doc__,
365 "is_signal(interface: str, member: str) -> bool");
366 static PyObject *
367 Message_is_signal (Message *self, PyObject *args)
369 const char *interface, *signal_name;
371 if (!PyArg_ParseTuple(args, "ss:is_signal", &interface, &signal_name)) {
372 return NULL;
374 if (!self->msg) return DBusException_UnusableMessage();
375 return PyBool_FromLong (dbus_message_is_signal (self->msg, interface,
376 signal_name));
379 PyDoc_STRVAR(Message_get_member__doc__,
380 "get_member() -> str or None");
381 static PyObject *
382 Message_get_member (Message *self, PyObject *unused UNUSED)
384 const char *c_str;
386 if (!self->msg) return DBusException_UnusableMessage();
387 c_str = dbus_message_get_member (self->msg);
388 if (!c_str) {
389 Py_RETURN_NONE;
391 return PyString_FromString(c_str);
394 PyDoc_STRVAR(Message_has_member__doc__,
395 "has_member(name: str or None) -> bool");
396 static PyObject *
397 Message_has_member (Message *self, PyObject *args)
399 const char *name;
401 if (!PyArg_ParseTuple(args, "z:has_member", &name)) {
402 return NULL;
404 if (!self->msg) return DBusException_UnusableMessage();
405 return PyBool_FromLong (dbus_message_has_member(self->msg, name));
408 PyDoc_STRVAR(Message_set_member__doc__,
409 "set_member(unique_name: str or None)");
410 static PyObject *
411 Message_set_member (Message *self, PyObject *args)
413 const char *name;
415 if (!PyArg_ParseTuple(args, "z:set_member", &name)) {
416 return NULL;
418 if (!self->msg) return DBusException_UnusableMessage();
419 if (!dbus_py_validate_member_name(name)) return NULL;
420 if (!dbus_message_set_member (self->msg, name)) return PyErr_NoMemory();
421 Py_RETURN_NONE;
424 PyDoc_STRVAR(Message_get_path__doc__,
425 "get_path() -> ObjectPath or None\n\n"
426 "Return the message's destination object path (if it's a method call) or\n"
427 "source object path (if it's a method reply or a signal) or None (if it\n"
428 "has no path).\n");
429 static PyObject *
430 Message_get_path (Message *self, PyObject *unused UNUSED)
432 const char *c_str;
434 if (!self->msg) return DBusException_UnusableMessage();
435 c_str = dbus_message_get_path (self->msg);
436 if (!c_str) {
437 Py_RETURN_NONE;
439 return PyObject_CallFunction((PyObject *)&ObjectPathType, "(s)", c_str);
442 PyDoc_STRVAR(Message_get_path_decomposed__doc__,
443 "get_path_decomposed() -> list of str, or None\n\n"
444 "Return a list of path components (e.g. /foo/bar -> ['foo','bar'], / -> [])\n"
445 "or None if the message has no associated path.\n");
446 static PyObject *
447 Message_get_path_decomposed (Message *self, PyObject *unused UNUSED)
449 char **paths, **ptr;
450 PyObject *ret = PyList_New(0);
452 if (!ret) return NULL;
453 if (!self->msg) {
454 Py_DECREF (ret);
455 return DBusException_UnusableMessage ();
457 if (!dbus_message_get_path_decomposed (self->msg, &paths)) {
458 Py_DECREF (ret);
459 return PyErr_NoMemory ();
461 if (!paths) {
462 Py_DECREF(ret);
463 Py_RETURN_NONE;
465 for (ptr = paths; *ptr; ptr++) {
466 PyObject *str = PyString_FromString (*ptr);
468 if (!str) {
469 Py_DECREF (ret);
470 ret = NULL;
471 break;
473 if (PyList_Append (ret, str) < 0) {
474 Py_DECREF (ret);
475 ret = NULL;
476 break;
478 Py_DECREF (str);
479 str = NULL;
481 dbus_free_string_array (paths);
482 return ret;
485 PyDoc_STRVAR(Message_has_path__doc__,
486 "has_path(name: str or None) -> bool");
487 static PyObject *
488 Message_has_path (Message *self, PyObject *args)
490 const char *name;
492 if (!PyArg_ParseTuple(args, "z:has_path", &name)) {
493 return NULL;
495 if (!self->msg) return DBusException_UnusableMessage();
496 return PyBool_FromLong (dbus_message_has_path(self->msg, name));
499 PyDoc_STRVAR(Message_set_path__doc__,
500 "set_path(name: str or None)");
501 static PyObject *
502 Message_set_path (Message *self, PyObject *args)
504 const char *name;
506 if (!PyArg_ParseTuple(args, "z:set_path", &name)) return NULL;
507 if (!self->msg) return DBusException_UnusableMessage();
508 if (!dbus_message_has_path(self->msg, name)) return PyErr_NoMemory();
509 Py_RETURN_NONE;
512 PyDoc_STRVAR(Message_get_signature__doc__,
513 "get_signature() -> Signature or None");
514 static PyObject *
515 Message_get_signature (Message *self, PyObject *unused UNUSED)
517 const char *c_str;
519 if (!self->msg) return DBusException_UnusableMessage();
520 c_str = dbus_message_get_signature (self->msg);
521 if (!c_str) {
522 return PyObject_CallFunction((PyObject *)&SignatureType, "(s)", "");
524 return PyObject_CallFunction((PyObject *)&SignatureType, "(s)", c_str);
527 PyDoc_STRVAR(Message_has_signature__doc__,
528 "has_signature(signature: str) -> bool");
529 static PyObject *
530 Message_has_signature (Message *self, PyObject *args)
532 const char *name;
534 if (!PyArg_ParseTuple(args, "s:has_signature", &name)) {
535 return NULL;
537 if (!self->msg) return DBusException_UnusableMessage();
538 return PyBool_FromLong (dbus_message_has_signature (self->msg, name));
541 PyDoc_STRVAR(Message_get_sender__doc__,
542 "get_sender() -> str or None\n\n"
543 "Return the message's sender unique name, or None if none.\n");
544 static PyObject *
545 Message_get_sender (Message *self, PyObject *unused UNUSED)
547 const char *c_str;
549 if (!self->msg) return DBusException_UnusableMessage();
550 c_str = dbus_message_get_sender (self->msg);
551 if (!c_str) {
552 Py_RETURN_NONE;
554 return PyString_FromString(c_str);
557 PyDoc_STRVAR(Message_has_sender__doc__,
558 "has_sender(unique_name: str) -> bool");
559 static PyObject *
560 Message_has_sender (Message *self, PyObject *args)
562 const char *name;
564 if (!PyArg_ParseTuple(args, "s:has_sender", &name)) {
565 return NULL;
567 if (!self->msg) return DBusException_UnusableMessage();
568 return PyBool_FromLong (dbus_message_has_sender (self->msg, name));
571 PyDoc_STRVAR(Message_set_sender__doc__,
572 "set_sender(unique_name: str or None)");
573 static PyObject *
574 Message_set_sender (Message *self, PyObject *args)
576 const char *name;
578 if (!PyArg_ParseTuple(args, "z:set_sender", &name)) {
579 return NULL;
581 if (!self->msg) return DBusException_UnusableMessage();
582 if (!dbus_py_validate_bus_name(name, 1, 0)) return NULL;
583 if (!dbus_message_set_sender (self->msg, name)) return PyErr_NoMemory();
584 Py_RETURN_NONE;
587 PyDoc_STRVAR(Message_get_destination__doc__,
588 "get_destination() -> str or None\n\n"
589 "Return the message's destination bus name, or None if none.\n");
590 static PyObject *
591 Message_get_destination(Message *self, PyObject *unused UNUSED)
593 const char *c_str;
595 if (!self->msg) return DBusException_UnusableMessage();
596 c_str = dbus_message_get_destination(self->msg);
597 if (!c_str) {
598 Py_RETURN_NONE;
600 return PyString_FromString(c_str);
603 PyDoc_STRVAR(Message_has_destination__doc__,
604 "has_destination(bus_name: str) -> bool");
605 static PyObject *
606 Message_has_destination (Message *self, PyObject *args)
608 const char *name;
610 if (!PyArg_ParseTuple(args, "s:has_destination", &name)) {
611 return NULL;
613 if (!self->msg) return DBusException_UnusableMessage();
614 return PyBool_FromLong (dbus_message_has_destination (self->msg, name));
617 PyDoc_STRVAR(Message_set_destination__doc__,
618 "set_destination(bus_name: str or None)");
619 static PyObject *
620 Message_set_destination (Message *self, PyObject *args)
622 const char *name;
624 if (!PyArg_ParseTuple(args, "z:set_destination", &name)) {
625 return NULL;
627 if (!self->msg) return DBusException_UnusableMessage();
628 if (!dbus_py_validate_bus_name(name, 1, 1)) return NULL;
629 if (!dbus_message_set_destination (self->msg, name)) return PyErr_NoMemory();
630 Py_RETURN_NONE;
633 PyDoc_STRVAR(Message_get_interface__doc__,
634 "get_interface() -> str or None");
635 static PyObject *
636 Message_get_interface (Message *self, PyObject *unused UNUSED)
638 const char *c_str;
640 if (!self->msg) return DBusException_UnusableMessage();
641 c_str = dbus_message_get_interface (self->msg);
642 if (!c_str) {
643 Py_RETURN_NONE;
645 return PyString_FromString(c_str);
648 PyDoc_STRVAR(Message_has_interface__doc__,
649 "has_interface(interface: str or None) -> bool");
650 static PyObject *
651 Message_has_interface(Message *self, PyObject *args)
653 const char *name;
655 if (!PyArg_ParseTuple(args, "z:has_interface", &name)) {
656 return NULL;
658 if (!self->msg) return DBusException_UnusableMessage();
659 return PyBool_FromLong(dbus_message_has_interface (self->msg, name));
662 PyDoc_STRVAR(Message_set_interface__doc__,
663 "set_interface(name: str or None)");
664 static PyObject *
665 Message_set_interface (Message *self, PyObject *args)
667 const char *name;
669 if (!PyArg_ParseTuple(args, "z:set_interface", &name)) {
670 return NULL;
672 if (!self->msg) return DBusException_UnusableMessage();
673 if (!dbus_py_validate_interface_name(name)) return NULL;
674 if (!dbus_message_set_interface (self->msg, name)) return PyErr_NoMemory();
675 Py_RETURN_NONE;
678 PyDoc_STRVAR(Message_get_error_name__doc__,
679 "get_error_name() -> str or None");
680 static PyObject *
681 Message_get_error_name (Message *self, PyObject *unused UNUSED)
683 const char *c_str;
685 if (!self->msg) return DBusException_UnusableMessage();
686 c_str = dbus_message_get_error_name (self->msg);
687 if (!c_str) {
688 Py_RETURN_NONE;
690 return PyString_FromString(c_str);
693 PyDoc_STRVAR(Message_set_error_name__doc__,
694 "set_error_name(name: str or None)");
695 static PyObject *
696 Message_set_error_name(Message *self, PyObject *args)
698 const char *name;
700 if (!PyArg_ParseTuple(args, "z:set_error_name", &name)) {
701 return NULL;
703 if (!self->msg) return DBusException_UnusableMessage();
704 if (!dbus_py_validate_error_name(name)) return NULL;
705 if (!dbus_message_set_error_name(self->msg, name)) return PyErr_NoMemory();
706 Py_RETURN_NONE;
709 #include "message-append-impl.h"
710 #include "message-get-args-impl.h"
712 static PyMethodDef Message_tp_methods[] = {
713 {"copy", (PyCFunction)Message_copy,
714 METH_NOARGS, Message_copy__doc__},
715 {"is_method_call", (PyCFunction)Message_is_method_call,
716 METH_VARARGS, Message_is_method_call__doc__},
717 {"is_signal", (PyCFunction)Message_is_signal,
718 METH_VARARGS, Message_is_signal__doc__},
719 {"is_error", (PyCFunction)Message_is_error,
720 METH_VARARGS, Message_is_error__doc__},
722 {"get_args_list", (PyCFunction)Message_get_args_list,
723 METH_VARARGS|METH_KEYWORDS, Message_get_args_list__doc__},
724 {"guess_signature", (PyCFunction)Message_guess_signature,
725 METH_VARARGS|METH_STATIC, Message_guess_signature__doc__},
726 {"append", (PyCFunction)Message_append,
727 METH_VARARGS|METH_KEYWORDS, Message_append__doc__},
729 {"get_auto_start", (PyCFunction)Message_get_auto_start,
730 METH_NOARGS, Message_get_auto_start__doc__},
731 {"set_auto_start", (PyCFunction)Message_set_auto_start,
732 METH_VARARGS, Message_set_auto_start__doc__},
733 {"get_destination", (PyCFunction)Message_get_destination,
734 METH_NOARGS, Message_get_destination__doc__},
735 {"set_destination", (PyCFunction)Message_set_destination,
736 METH_VARARGS, Message_set_destination__doc__},
737 {"has_destination", (PyCFunction)Message_has_destination,
738 METH_VARARGS, Message_has_destination__doc__},
739 {"get_error_name", (PyCFunction)Message_get_error_name,
740 METH_NOARGS, Message_get_error_name__doc__},
741 {"set_error_name", (PyCFunction)Message_set_error_name,
742 METH_VARARGS, Message_set_error_name__doc__},
743 {"get_interface", (PyCFunction)Message_get_interface,
744 METH_NOARGS, Message_get_interface__doc__},
745 {"set_interface", (PyCFunction)Message_set_interface,
746 METH_VARARGS, Message_set_interface__doc__},
747 {"has_interface", (PyCFunction)Message_has_interface,
748 METH_VARARGS, Message_has_interface__doc__},
749 {"get_member", (PyCFunction)Message_get_member,
750 METH_NOARGS, Message_get_member__doc__},
751 {"set_member", (PyCFunction)Message_set_member,
752 METH_VARARGS, Message_set_member__doc__},
753 {"has_member", (PyCFunction)Message_has_member,
754 METH_VARARGS, Message_has_member__doc__},
755 {"get_path", (PyCFunction)Message_get_path,
756 METH_NOARGS, Message_get_path__doc__},
757 {"get_path_decomposed", (PyCFunction)Message_get_path_decomposed,
758 METH_NOARGS, Message_get_path_decomposed__doc__},
759 {"set_path", (PyCFunction)Message_set_path,
760 METH_VARARGS, Message_set_path__doc__},
761 {"has_path", (PyCFunction)Message_has_path,
762 METH_VARARGS, Message_has_path__doc__},
763 {"get_no_reply", (PyCFunction)Message_get_no_reply,
764 METH_NOARGS, Message_get_no_reply__doc__},
765 {"set_no_reply", (PyCFunction)Message_set_no_reply,
766 METH_VARARGS, Message_set_no_reply__doc__},
767 {"get_reply_serial", (PyCFunction)Message_get_reply_serial,
768 METH_NOARGS, Message_get_reply_serial__doc__},
769 {"set_reply_serial", (PyCFunction)Message_set_reply_serial,
770 METH_VARARGS, Message_set_reply_serial__doc__},
771 {"get_sender", (PyCFunction)Message_get_sender,
772 METH_NOARGS, Message_get_sender__doc__},
773 {"set_sender", (PyCFunction)Message_set_sender,
774 METH_VARARGS, Message_set_sender__doc__},
775 {"has_sender", (PyCFunction)Message_has_sender,
776 METH_VARARGS, Message_has_sender__doc__},
777 {"get_serial", (PyCFunction)Message_get_serial,
778 METH_NOARGS, Message_get_serial__doc__},
779 {"get_signature", (PyCFunction)Message_get_signature,
780 METH_NOARGS, Message_get_signature__doc__},
781 {"has_signature", (PyCFunction)Message_has_signature,
782 METH_VARARGS, Message_has_signature__doc__},
783 {"get_type", (PyCFunction)Message_get_type,
784 METH_NOARGS, Message_get_type__doc__},
785 {NULL, NULL, 0, NULL}
788 static PyTypeObject MessageType = {
789 PyObject_HEAD_INIT(NULL)
790 0, /*ob_size*/
791 "dbus.lowlevel.Message", /*tp_name*/
792 sizeof(Message), /*tp_basicsize*/
793 0, /*tp_itemsize*/
794 (destructor)Message_tp_dealloc, /*tp_dealloc*/
795 0, /*tp_print*/
796 0, /*tp_getattr*/
797 0, /*tp_setattr*/
798 0, /*tp_compare*/
799 0, /*tp_repr*/
800 0, /*tp_as_number*/
801 0, /*tp_as_sequence*/
802 0, /*tp_as_mapping*/
803 0, /*tp_hash */
804 0, /*tp_call*/
805 0, /*tp_str*/
806 0, /*tp_getattro*/
807 0, /*tp_setattro*/
808 0, /*tp_as_buffer*/
809 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
810 Message_tp_doc, /* tp_doc */
811 0, /* tp_traverse */
812 0, /* tp_clear */
813 0, /* tp_richcompare */
814 0, /* tp_weaklistoffset */
815 0, /* tp_iter */
816 0, /* tp_iternext */
817 Message_tp_methods, /* tp_methods */
818 0, /* tp_members */
819 0, /* tp_getset */
820 0, /* tp_base */
821 0, /* tp_dict */
822 0, /* tp_descr_get */
823 0, /* tp_descr_set */
824 0, /* tp_dictoffset */
825 0, /* tp_init */
826 0, /* tp_alloc */
827 Message_tp_new, /* tp_new */
830 static PyTypeObject MethodCallMessageType = {
831 PyObject_HEAD_INIT(NULL)
832 0, /*ob_size*/
833 "dbus.lowlevel.MethodCallMessage", /*tp_name*/
834 0, /*tp_basicsize*/
835 0, /*tp_itemsize*/
836 0, /*tp_dealloc*/
837 0, /*tp_print*/
838 0, /*tp_getattr*/
839 0, /*tp_setattr*/
840 0, /*tp_compare*/
841 0, /*tp_repr*/
842 0, /*tp_as_number*/
843 0, /*tp_as_sequence*/
844 0, /*tp_as_mapping*/
845 0, /*tp_hash */
846 0, /*tp_call*/
847 0, /*tp_str*/
848 0, /*tp_getattro*/
849 0, /*tp_setattro*/
850 0, /*tp_as_buffer*/
851 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
852 MethodCallMessage_tp_doc, /* tp_doc */
853 0, /* tp_traverse */
854 0, /* tp_clear */
855 0, /* tp_richcompare */
856 0, /* tp_weaklistoffset */
857 0, /* tp_iter */
858 0, /* tp_iternext */
859 0, /* tp_methods */
860 0, /* tp_members */
861 0, /* tp_getset */
862 DEFERRED_ADDRESS(&MessageType), /* tp_base */
863 0, /* tp_dict */
864 0, /* tp_descr_get */
865 0, /* tp_descr_set */
866 0, /* tp_dictoffset */
867 (initproc)MethodCallMessage_tp_init, /* tp_init */
868 0, /* tp_alloc */
869 0, /* tp_new */
872 static PyTypeObject MethodReturnMessageType = {
873 PyObject_HEAD_INIT(NULL)
874 0, /*ob_size*/
875 "dbus.lowlevel.MethodReturnMessage", /*tp_name*/
876 0, /*tp_basicsize*/
877 0, /*tp_itemsize*/
878 0, /*tp_dealloc*/
879 0, /*tp_print*/
880 0, /*tp_getattr*/
881 0, /*tp_setattr*/
882 0, /*tp_compare*/
883 0, /*tp_repr*/
884 0, /*tp_as_number*/
885 0, /*tp_as_sequence*/
886 0, /*tp_as_mapping*/
887 0, /*tp_hash */
888 0, /*tp_call*/
889 0, /*tp_str*/
890 0, /*tp_getattro*/
891 0, /*tp_setattro*/
892 0, /*tp_as_buffer*/
893 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
894 MethodReturnMessage_tp_doc, /* tp_doc */
895 0, /* tp_traverse */
896 0, /* tp_clear */
897 0, /* tp_richcompare */
898 0, /* tp_weaklistoffset */
899 0, /* tp_iter */
900 0, /* tp_iternext */
901 0, /* tp_methods */
902 0, /* tp_members */
903 0, /* tp_getset */
904 DEFERRED_ADDRESS(&MessageType), /* tp_base */
905 0, /* tp_dict */
906 0, /* tp_descr_get */
907 0, /* tp_descr_set */
908 0, /* tp_dictoffset */
909 (initproc)MethodReturnMessage_tp_init, /* tp_init */
910 0, /* tp_alloc */
911 0, /* tp_new */
914 static PyTypeObject SignalMessageType = {
915 PyObject_HEAD_INIT(NULL)
916 0, /*ob_size*/
917 "dbus.lowlevel.SignalMessage", /*tp_name*/
918 0, /*tp_basicsize*/
919 0, /*tp_itemsize*/
920 0, /*tp_dealloc*/
921 0, /*tp_print*/
922 0, /*tp_getattr*/
923 0, /*tp_setattr*/
924 0, /*tp_compare*/
925 0, /*tp_repr*/
926 0, /*tp_as_number*/
927 0, /*tp_as_sequence*/
928 0, /*tp_as_mapping*/
929 0, /*tp_hash */
930 0, /*tp_call*/
931 0, /*tp_str*/
932 0, /*tp_getattro*/
933 0, /*tp_setattro*/
934 0, /*tp_as_buffer*/
935 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
936 SignalMessage_tp_doc, /* tp_doc */
937 0, /* tp_traverse */
938 0, /* tp_clear */
939 0, /* tp_richcompare */
940 0, /* tp_weaklistoffset */
941 0, /* tp_iter */
942 0, /* tp_iternext */
943 0, /* tp_methods */
944 0, /* tp_members */
945 0, /* tp_getset */
946 DEFERRED_ADDRESS(&MessageType), /* tp_base */
947 0, /* tp_dict */
948 0, /* tp_descr_get */
949 0, /* tp_descr_set */
950 0, /* tp_dictoffset */
951 (initproc)SignalMessage_tp_init, /* tp_init */
952 0, /* tp_alloc */
953 0, /* tp_new */
956 static PyTypeObject ErrorMessageType = {
957 PyObject_HEAD_INIT(NULL)
958 0, /*ob_size*/
959 "dbus.lowlevel.ErrorMessage", /*tp_name*/
960 0, /*tp_basicsize*/
961 0, /*tp_itemsize*/
962 0, /*tp_dealloc*/
963 0, /*tp_print*/
964 0, /*tp_getattr*/
965 0, /*tp_setattr*/
966 0, /*tp_compare*/
967 0, /*tp_repr*/
968 0, /*tp_as_number*/
969 0, /*tp_as_sequence*/
970 0, /*tp_as_mapping*/
971 0, /*tp_hash */
972 0, /*tp_call*/
973 0, /*tp_str*/
974 0, /*tp_getattro*/
975 0, /*tp_setattro*/
976 0, /*tp_as_buffer*/
977 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
978 ErrorMessage_tp_doc, /* tp_doc */
979 0, /* tp_traverse */
980 0, /* tp_clear */
981 0, /* tp_richcompare */
982 0, /* tp_weaklistoffset */
983 0, /* tp_iter */
984 0, /* tp_iternext */
985 0, /* tp_methods */
986 0, /* tp_members */
987 0, /* tp_getset */
988 DEFERRED_ADDRESS(&MessageType), /* tp_base */
989 0, /* tp_dict */
990 0, /* tp_descr_get */
991 0, /* tp_descr_set */
992 0, /* tp_dictoffset */
993 (initproc)ErrorMessage_tp_init, /* tp_init */
994 0, /* tp_alloc */
995 0, /* tp_new */
998 static inline int
999 init_message_types(void)
1001 if (PyType_Ready(&MessageType) < 0) return 0;
1003 MethodCallMessageType.tp_base = &MessageType;
1004 if (PyType_Ready(&MethodCallMessageType) < 0) return 0;
1006 MethodReturnMessageType.tp_base = &MessageType;
1007 if (PyType_Ready(&MethodReturnMessageType) < 0) return 0;
1009 SignalMessageType.tp_base = &MessageType;
1010 if (PyType_Ready(&SignalMessageType) < 0) return 0;
1012 ErrorMessageType.tp_base = &MessageType;
1013 if (PyType_Ready(&ErrorMessageType) < 0) return 0;
1015 return 1;
1018 static inline int
1019 insert_message_types(PyObject *this_module)
1021 if (PyModule_AddObject(this_module, "Message",
1022 (PyObject *)&MessageType) < 0) return 0;
1024 if (PyModule_AddObject(this_module, "MethodCallMessage",
1025 (PyObject *)&MethodCallMessageType) < 0) return 0;
1027 if (PyModule_AddObject(this_module, "MethodReturnMessage",
1028 (PyObject *)&MethodReturnMessageType) < 0) return 0;
1030 if (PyModule_AddObject(this_module, "ErrorMessage",
1031 (PyObject *)&ErrorMessageType) < 0) return 0;
1033 if (PyModule_AddObject(this_module, "SignalMessage",
1034 (PyObject *)&SignalMessageType) < 0) return 0;
1036 return 1;
1039 /* vim:set ft=c cino< sw=4 sts=4 et: */