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
27 static void _dbg_dump_message(DBusMessage
*message
)
30 fprintf(stderr
, "DBusMessage at %p\n", message
);
32 s
= dbus_message_get_destination(message
);
34 fprintf(stderr
, "\tdestination %s\n", s
);
36 s
= dbus_message_get_interface(message
);
38 fprintf(stderr
, "\tinterface %s\n", s
);
40 s
= dbus_message_get_member(message
);
42 fprintf(stderr
, "\tmember %s\n", s
);
44 s
= dbus_message_get_path(message
);
46 fprintf(stderr
, "\tpath %s\n", s
);
48 # define DBG_DUMP_MESSAGE(x) _dbg_dump_message(x)
50 # define DBG_DUMP_MESSAGE(x) do {} while(0)
53 static PyTypeObject MessageType
, SignalMessageType
, ErrorMessageType
;
54 static PyTypeObject MethodReturnMessageType
, MethodCallMessageType
;
56 static inline int Message_Check (PyObject
*o
)
58 return (o
->ob_type
== &MessageType
)
59 || PyObject_IsInstance(o
, (PyObject
*)&MessageType
);
67 PyDoc_STRVAR(Message_tp_doc
,
68 "A message to be sent or received over a D-Bus Connection.\n");
70 static void Message_tp_dealloc (Message
*self
)
73 dbus_message_unref (self
->msg
);
75 self
->ob_type
->tp_free ((PyObject
*)self
);
79 Message_tp_new (PyTypeObject
*type
,
80 PyObject
*args UNUSED
,
81 PyObject
*kwargs UNUSED
)
85 self
= (Message
*)type
->tp_alloc (type
, 0);
86 if (!self
) return NULL
;
88 return (PyObject
*)self
;
91 PyDoc_STRVAR(MethodCallMessage_tp_doc
, "A method-call message.\n\n"
92 "MethodCallMessage(destination: str or None, path: str,\n"
93 " interface: str or None, method: str)\n");
95 MethodCallMessage_tp_init (Message
*self
, PyObject
*args
, PyObject
*kwargs
)
97 const char *destination
, *path
, *interface
, *method
;
98 static char *kwlist
[] = {"destination", "path", "interface", "method", NULL
};
100 if (!PyArg_ParseTupleAndKeywords (args
, kwargs
, "zszs:__init__", kwlist
,
101 &destination
, &path
, &interface
,
105 if (destination
&& !_validate_bus_name(destination
, 1, 1)) return -1;
106 if (!_validate_object_path(path
)) return -1;
107 if (interface
&& !_validate_interface_name(interface
)) return -1;
108 if (!_validate_member_name(method
)) return -1;
110 dbus_message_unref (self
->msg
);
113 self
->msg
= dbus_message_new_method_call (destination
, path
, interface
,
122 PyDoc_STRVAR(MethodReturnMessage_tp_doc
, "A method-return message.\n\n"
123 "MethodReturnMessage(method_call: MethodCallMessage)\n");
125 MethodReturnMessage_tp_init (Message
*self
, PyObject
*args
, PyObject
*kwargs
)
128 static char *kwlist
[] = {"method_call", NULL
};
130 if (!PyArg_ParseTupleAndKeywords (args
, kwargs
, "O!:__init__", kwlist
,
131 &MessageType
, &other
)) {
135 dbus_message_unref (self
->msg
);
138 self
->msg
= dbus_message_new_method_return (other
->msg
);
146 PyDoc_STRVAR(SignalMessage_tp_doc
, "A signal message.\n\n"
147 "SignalMessage(path: str, interface: str, method: str)\n");
149 SignalMessage_tp_init (Message
*self
, PyObject
*args
, PyObject
*kwargs
)
151 const char *path
, *interface
, *name
;
152 static char *kwlist
[] = {"path", "interface", "name", NULL
};
154 if (!PyArg_ParseTupleAndKeywords (args
, kwargs
, "sss:__init__", kwlist
,
155 &path
, &interface
, &name
)) {
158 if (!_validate_object_path(path
)) return -1;
159 if (!_validate_interface_name(interface
)) return -1;
160 if (!_validate_member_name(name
)) return -1;
162 dbus_message_unref (self
->msg
);
165 self
->msg
= dbus_message_new_signal (path
, interface
, name
);
173 PyDoc_STRVAR(ErrorMessage_tp_doc
, "An error message.\n\n"
174 "ErrorMessage(reply_to: Message, error_name: str,\n"
175 " error_message: str or None)\n");
177 ErrorMessage_tp_init (Message
*self
, PyObject
*args
, PyObject
*kwargs
)
180 const char *error_name
, *error_message
;
181 static char *kwlist
[] = {"reply_to", "error_name", "error_message", NULL
};
183 if (!PyArg_ParseTupleAndKeywords (args
, kwargs
, "O!sz:__init__", kwlist
,
184 &MessageType
, &reply_to
, &error_name
,
188 if (!_validate_error_name(error_name
)) return -1;
190 dbus_message_unref (self
->msg
);
193 self
->msg
= dbus_message_new_error (reply_to
->msg
, error_name
, error_message
);
202 Message_BorrowDBusMessage (PyObject
*msg
)
204 if (!Message_Check (msg
)) {
205 PyErr_SetString (PyExc_TypeError
,
206 "A _dbus_bindings.Message instance is required");
209 if (!((Message
*)msg
)->msg
) {
210 DBusException_UnusableMessage();
213 return ((Message
*)msg
)->msg
;
217 Message_ConsumeDBusMessage (DBusMessage
*msg
)
222 switch (dbus_message_get_type (msg
)) {
223 case DBUS_MESSAGE_TYPE_METHOD_CALL
:
224 type
= &MethodCallMessageType
;
226 case DBUS_MESSAGE_TYPE_METHOD_RETURN
:
227 type
= &MethodReturnMessageType
;
229 case DBUS_MESSAGE_TYPE_ERROR
:
230 type
= &ErrorMessageType
;
232 case DBUS_MESSAGE_TYPE_SIGNAL
:
233 type
= &SignalMessageType
;
239 self
= (Message
*)(type
->tp_new
) (type
, empty_tuple
, NULL
);
241 dbus_message_unref(msg
);
245 return (PyObject
*)self
;
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");
252 Message_copy (Message
*self
, PyObject
*args UNUSED
)
255 if (!self
->msg
) return DBusException_UnusableMessage();
256 msg
= dbus_message_copy(self
->msg
);
257 if (!msg
) return PyErr_NoMemory();
258 return Message_ConsumeDBusMessage(msg
);
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");
266 Message_get_auto_start (Message
*self
, PyObject
*unused UNUSED
)
268 if (!self
->msg
) return DBusException_UnusableMessage();
269 return PyBool_FromLong (dbus_message_get_auto_start (self
->msg
));
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");
277 Message_set_auto_start (Message
*self
, PyObject
*args
)
280 if (!PyArg_ParseTuple (args
, "i", &value
)) return NULL
;
281 if (!self
->msg
) return DBusException_UnusableMessage();
282 dbus_message_set_auto_start (self
->msg
, value
? TRUE
: FALSE
);
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");
291 Message_get_no_reply (Message
*self
, PyObject
*unused UNUSED
)
293 if (!self
->msg
) return DBusException_UnusableMessage();
294 return PyBool_FromLong (dbus_message_get_no_reply (self
->msg
));
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");
301 Message_set_no_reply (Message
*self
, PyObject
*args
)
304 if (!PyArg_ParseTuple (args
, "i", &value
)) return NULL
;
305 if (!self
->msg
) return DBusException_UnusableMessage();
306 dbus_message_set_no_reply (self
->msg
, value
? TRUE
: FALSE
);
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");
314 Message_get_reply_serial (Message
*self
, PyObject
*unused UNUSED
)
316 if (!self
->msg
) return DBusException_UnusableMessage();
317 return PyLong_FromUnsignedLong (dbus_message_get_reply_serial (self
->msg
));
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");
324 Message_set_reply_serial (Message
*self
, PyObject
*args
)
328 if (!PyArg_ParseTuple (args
, "k", &value
)) return NULL
;
329 if (!self
->msg
) return DBusException_UnusableMessage();
330 if (!dbus_message_set_reply_serial (self
->msg
, value
)) {
331 return PyErr_NoMemory();
337 PyDoc_STRVAR(Message_get_type__doc__
,
338 "message.get_type() -> int\n\n"
339 "Returns the type of the message.\n");
341 Message_get_type (Message
*self
, PyObject
*unused UNUSED
)
343 if (!self
->msg
) return DBusException_UnusableMessage();
344 return PyInt_FromLong (dbus_message_get_type (self
->msg
));
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"
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");
356 Message_get_serial (Message
*self
, PyObject
*unused UNUSED
)
358 if (!self
->msg
) return DBusException_UnusableMessage();
359 return PyLong_FromUnsignedLong (dbus_message_get_serial (self
->msg
));
362 PyDoc_STRVAR(Message_is_method_call__doc__
,
363 "is_method_call(interface: str, member: str) -> bool");
365 Message_is_method_call (Message
*self
, PyObject
*args
)
367 const char *interface
, *method
;
369 if (!PyArg_ParseTuple(args
, "ss:is_method_call", &interface
, &method
)) {
372 if (!self
->msg
) return DBusException_UnusableMessage();
373 return PyBool_FromLong (dbus_message_is_method_call (self
->msg
, interface
,
377 PyDoc_STRVAR(Message_is_error__doc__
,
378 "is_error(error: str) -> bool");
380 Message_is_error (Message
*self
, PyObject
*args
)
382 const char *error_name
;
384 if (!PyArg_ParseTuple(args
, "s:is_error", &error_name
)) {
387 if (!self
->msg
) return DBusException_UnusableMessage();
388 return PyBool_FromLong (dbus_message_is_error (self
->msg
, error_name
));
391 PyDoc_STRVAR(Message_is_signal__doc__
,
392 "is_signal(interface: str, member: str) -> bool");
394 Message_is_signal (Message
*self
, PyObject
*args
)
396 const char *interface
, *signal_name
;
398 if (!PyArg_ParseTuple(args
, "ss:is_signal", &interface
, &signal_name
)) {
401 if (!self
->msg
) return DBusException_UnusableMessage();
402 return PyBool_FromLong (dbus_message_is_signal (self
->msg
, interface
,
406 PyDoc_STRVAR(Message_get_member__doc__
,
407 "get_member() -> str or None");
409 Message_get_member (Message
*self
, PyObject
*unused UNUSED
)
413 if (!self
->msg
) return DBusException_UnusableMessage();
414 c_str
= dbus_message_get_member (self
->msg
);
418 return PyString_FromString(c_str
);
421 PyDoc_STRVAR(Message_has_member__doc__
,
422 "has_member(name: str or None) -> bool");
424 Message_has_member (Message
*self
, PyObject
*args
)
428 if (!PyArg_ParseTuple(args
, "z:has_member", &name
)) {
431 if (!self
->msg
) return DBusException_UnusableMessage();
432 return PyBool_FromLong (dbus_message_has_member(self
->msg
, name
));
435 PyDoc_STRVAR(Message_set_member__doc__
,
436 "set_member(unique_name: str or None)");
438 Message_set_member (Message
*self
, PyObject
*args
)
442 if (!PyArg_ParseTuple(args
, "z:set_member", &name
)) {
445 if (!self
->msg
) return DBusException_UnusableMessage();
446 if (!_validate_member_name(name
)) return NULL
;
447 if (!dbus_message_set_member (self
->msg
, name
)) return PyErr_NoMemory();
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"
457 Message_get_path (Message
*self
, PyObject
*unused UNUSED
)
461 if (!self
->msg
) return DBusException_UnusableMessage();
462 c_str
= dbus_message_get_path (self
->msg
);
466 return PyObject_CallFunction((PyObject
*)&ObjectPathType
, "(s)", c_str
);
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");
474 Message_get_path_decomposed (Message
*self
, PyObject
*unused UNUSED
)
477 PyObject
*ret
= PyList_New(0);
479 if (!ret
) return NULL
;
482 return DBusException_UnusableMessage ();
484 if (!dbus_message_get_path_decomposed (self
->msg
, &paths
)) {
486 return PyErr_NoMemory ();
492 for (ptr
= paths
; *ptr
; ptr
++) {
493 PyObject
*str
= PyString_FromString (*ptr
);
500 if (PyList_Append (ret
, str
) < 0) {
508 dbus_free_string_array (paths
);
512 PyDoc_STRVAR(Message_has_path__doc__
,
513 "has_path(name: str or None) -> bool");
515 Message_has_path (Message
*self
, PyObject
*args
)
519 if (!PyArg_ParseTuple(args
, "z:has_path", &name
)) {
522 if (!self
->msg
) return DBusException_UnusableMessage();
523 return PyBool_FromLong (dbus_message_has_path(self
->msg
, name
));
526 PyDoc_STRVAR(Message_set_path__doc__
,
527 "set_path(name: str or None)");
529 Message_set_path (Message
*self
, PyObject
*args
)
533 if (!PyArg_ParseTuple(args
, "z:set_path", &name
)) return NULL
;
534 if (!self
->msg
) return DBusException_UnusableMessage();
535 if (!dbus_message_has_path(self
->msg
, name
)) return PyErr_NoMemory();
539 PyDoc_STRVAR(Message_get_signature__doc__
,
540 "get_signature() -> Signature or None");
542 Message_get_signature (Message
*self
, PyObject
*unused UNUSED
)
546 if (!self
->msg
) return DBusException_UnusableMessage();
547 c_str
= dbus_message_get_signature (self
->msg
);
549 return PyObject_CallFunction((PyObject
*)&SignatureType
, "(s)", "");
551 return PyObject_CallFunction((PyObject
*)&SignatureType
, "(s)", c_str
);
554 PyDoc_STRVAR(Message_has_signature__doc__
,
555 "has_signature(signature: str) -> bool");
557 Message_has_signature (Message
*self
, PyObject
*args
)
561 if (!PyArg_ParseTuple(args
, "s:has_signature", &name
)) {
564 if (!self
->msg
) return DBusException_UnusableMessage();
565 return PyBool_FromLong (dbus_message_has_signature (self
->msg
, name
));
568 PyDoc_STRVAR(Message_get_sender__doc__
,
569 "get_sender() -> str or None\n\n"
570 "Return the message's sender unique name, or None if none.\n");
572 Message_get_sender (Message
*self
, PyObject
*unused UNUSED
)
576 if (!self
->msg
) return DBusException_UnusableMessage();
577 c_str
= dbus_message_get_sender (self
->msg
);
581 return PyString_FromString(c_str
);
584 PyDoc_STRVAR(Message_has_sender__doc__
,
585 "has_sender(unique_name: str) -> bool");
587 Message_has_sender (Message
*self
, PyObject
*args
)
591 if (!PyArg_ParseTuple(args
, "s:has_sender", &name
)) {
594 if (!self
->msg
) return DBusException_UnusableMessage();
595 return PyBool_FromLong (dbus_message_has_sender (self
->msg
, name
));
598 PyDoc_STRVAR(Message_set_sender__doc__
,
599 "set_sender(unique_name: str or None)");
601 Message_set_sender (Message
*self
, PyObject
*args
)
605 if (!PyArg_ParseTuple(args
, "z:set_sender", &name
)) {
608 if (!self
->msg
) return DBusException_UnusableMessage();
609 if (!_validate_bus_name(name
, 1, 0)) return NULL
;
610 if (!dbus_message_set_sender (self
->msg
, name
)) return PyErr_NoMemory();
614 PyDoc_STRVAR(Message_get_destination__doc__
,
615 "get_destination() -> str or None\n\n"
616 "Return the message's destination bus name, or None if none.\n");
618 Message_get_destination(Message
*self
, PyObject
*unused UNUSED
)
622 if (!self
->msg
) return DBusException_UnusableMessage();
623 c_str
= dbus_message_get_destination(self
->msg
);
627 return PyString_FromString(c_str
);
630 PyDoc_STRVAR(Message_has_destination__doc__
,
631 "has_destination(bus_name: str) -> bool");
633 Message_has_destination (Message
*self
, PyObject
*args
)
637 if (!PyArg_ParseTuple(args
, "s:has_destination", &name
)) {
640 if (!self
->msg
) return DBusException_UnusableMessage();
641 return PyBool_FromLong (dbus_message_has_destination (self
->msg
, name
));
644 PyDoc_STRVAR(Message_set_destination__doc__
,
645 "set_destination(bus_name: str or None)");
647 Message_set_destination (Message
*self
, PyObject
*args
)
651 if (!PyArg_ParseTuple(args
, "z:set_destination", &name
)) {
654 if (!self
->msg
) return DBusException_UnusableMessage();
655 if (!_validate_bus_name(name
, 1, 1)) return NULL
;
656 if (!dbus_message_set_destination (self
->msg
, name
)) return PyErr_NoMemory();
660 PyDoc_STRVAR(Message_get_interface__doc__
,
661 "get_interface() -> str or None");
663 Message_get_interface (Message
*self
, PyObject
*unused UNUSED
)
667 if (!self
->msg
) return DBusException_UnusableMessage();
668 c_str
= dbus_message_get_interface (self
->msg
);
672 return PyString_FromString(c_str
);
675 PyDoc_STRVAR(Message_has_interface__doc__
,
676 "has_interface(interface: str or None) -> bool");
678 Message_has_interface(Message
*self
, PyObject
*args
)
682 if (!PyArg_ParseTuple(args
, "z:has_interface", &name
)) {
685 if (!self
->msg
) return DBusException_UnusableMessage();
686 return PyBool_FromLong(dbus_message_has_interface (self
->msg
, name
));
689 PyDoc_STRVAR(Message_set_interface__doc__
,
690 "set_interface(name: str or None)");
692 Message_set_interface (Message
*self
, PyObject
*args
)
696 if (!PyArg_ParseTuple(args
, "z:set_interface", &name
)) {
699 if (!self
->msg
) return DBusException_UnusableMessage();
700 if (!_validate_interface_name(name
)) return NULL
;
701 if (!dbus_message_set_interface (self
->msg
, name
)) return PyErr_NoMemory();
705 PyDoc_STRVAR(Message_get_error_name__doc__
,
706 "get_error_name() -> str or None");
708 Message_get_error_name (Message
*self
, PyObject
*unused UNUSED
)
712 if (!self
->msg
) return DBusException_UnusableMessage();
713 c_str
= dbus_message_get_error_name (self
->msg
);
717 return PyString_FromString(c_str
);
720 PyDoc_STRVAR(Message_set_error_name__doc__
,
721 "set_error_name(name: str or None)");
723 Message_set_error_name(Message
*self
, PyObject
*args
)
727 if (!PyArg_ParseTuple(args
, "z:set_error_name", &name
)) {
730 if (!self
->msg
) return DBusException_UnusableMessage();
731 if (!_validate_error_name(name
)) return NULL
;
732 if (!dbus_message_set_error_name(self
->msg
, name
)) return PyErr_NoMemory();
736 #include "message-append-impl.h"
737 #include "message-get-args-impl.h"
739 static PyMethodDef Message_tp_methods
[] = {
740 {"copy", (PyCFunction
)Message_copy
,
741 METH_NOARGS
, Message_copy__doc__
},
742 {"is_method_call", (PyCFunction
)Message_is_method_call
,
743 METH_VARARGS
, Message_is_method_call__doc__
},
744 {"is_signal", (PyCFunction
)Message_is_signal
,
745 METH_VARARGS
, Message_is_signal__doc__
},
746 {"is_error", (PyCFunction
)Message_is_error
,
747 METH_VARARGS
, Message_is_error__doc__
},
749 {"get_args_list", (PyCFunction
)Message_get_args_list
,
750 METH_VARARGS
|METH_KEYWORDS
, Message_get_args_list__doc__
},
751 {"guess_signature", (PyCFunction
)Message_guess_signature
,
752 METH_VARARGS
|METH_STATIC
, Message_guess_signature__doc__
},
753 {"append", (PyCFunction
)Message_append
,
754 METH_VARARGS
|METH_KEYWORDS
, Message_append__doc__
},
756 {"get_auto_start", (PyCFunction
)Message_get_auto_start
,
757 METH_NOARGS
, Message_get_auto_start__doc__
},
758 {"set_auto_start", (PyCFunction
)Message_set_auto_start
,
759 METH_VARARGS
, Message_set_auto_start__doc__
},
760 {"get_destination", (PyCFunction
)Message_get_destination
,
761 METH_NOARGS
, Message_get_destination__doc__
},
762 {"set_destination", (PyCFunction
)Message_set_destination
,
763 METH_VARARGS
, Message_set_destination__doc__
},
764 {"has_destination", (PyCFunction
)Message_has_destination
,
765 METH_VARARGS
, Message_has_destination__doc__
},
766 {"get_error_name", (PyCFunction
)Message_get_error_name
,
767 METH_NOARGS
, Message_get_error_name__doc__
},
768 {"set_error_name", (PyCFunction
)Message_set_error_name
,
769 METH_VARARGS
, Message_set_error_name__doc__
},
770 {"get_interface", (PyCFunction
)Message_get_interface
,
771 METH_NOARGS
, Message_get_interface__doc__
},
772 {"set_interface", (PyCFunction
)Message_set_interface
,
773 METH_VARARGS
, Message_set_interface__doc__
},
774 {"has_interface", (PyCFunction
)Message_has_interface
,
775 METH_VARARGS
, Message_has_interface__doc__
},
776 {"get_member", (PyCFunction
)Message_get_member
,
777 METH_NOARGS
, Message_get_member__doc__
},
778 {"set_member", (PyCFunction
)Message_set_member
,
779 METH_VARARGS
, Message_set_member__doc__
},
780 {"has_member", (PyCFunction
)Message_has_member
,
781 METH_VARARGS
, Message_has_member__doc__
},
782 {"get_path", (PyCFunction
)Message_get_path
,
783 METH_NOARGS
, Message_get_path__doc__
},
784 {"get_path_decomposed", (PyCFunction
)Message_get_path_decomposed
,
785 METH_NOARGS
, Message_get_path_decomposed__doc__
},
786 {"set_path", (PyCFunction
)Message_set_path
,
787 METH_VARARGS
, Message_set_path__doc__
},
788 {"has_path", (PyCFunction
)Message_has_path
,
789 METH_VARARGS
, Message_has_path__doc__
},
790 {"get_no_reply", (PyCFunction
)Message_get_no_reply
,
791 METH_NOARGS
, Message_get_no_reply__doc__
},
792 {"set_no_reply", (PyCFunction
)Message_set_no_reply
,
793 METH_VARARGS
, Message_set_no_reply__doc__
},
794 {"get_reply_serial", (PyCFunction
)Message_get_reply_serial
,
795 METH_NOARGS
, Message_get_reply_serial__doc__
},
796 {"set_reply_serial", (PyCFunction
)Message_set_reply_serial
,
797 METH_VARARGS
, Message_set_reply_serial__doc__
},
798 {"get_sender", (PyCFunction
)Message_get_sender
,
799 METH_NOARGS
, Message_get_sender__doc__
},
800 {"set_sender", (PyCFunction
)Message_set_sender
,
801 METH_VARARGS
, Message_set_sender__doc__
},
802 {"has_sender", (PyCFunction
)Message_has_sender
,
803 METH_VARARGS
, Message_has_sender__doc__
},
804 {"get_serial", (PyCFunction
)Message_get_serial
,
805 METH_NOARGS
, Message_get_serial__doc__
},
806 {"get_signature", (PyCFunction
)Message_get_signature
,
807 METH_NOARGS
, Message_get_signature__doc__
},
808 {"has_signature", (PyCFunction
)Message_has_signature
,
809 METH_VARARGS
, Message_has_signature__doc__
},
810 {"get_type", (PyCFunction
)Message_get_type
,
811 METH_NOARGS
, Message_get_type__doc__
},
812 {NULL
, NULL
, 0, NULL
}
815 static PyTypeObject MessageType
= {
816 PyObject_HEAD_INIT(NULL
)
818 "_dbus_bindings.Message", /*tp_name*/
819 sizeof(Message
), /*tp_basicsize*/
821 (destructor
)Message_tp_dealloc
, /*tp_dealloc*/
828 0, /*tp_as_sequence*/
836 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
, /*tp_flags*/
837 Message_tp_doc
, /* tp_doc */
840 0, /* tp_richcompare */
841 0, /* tp_weaklistoffset */
844 Message_tp_methods
, /* tp_methods */
849 0, /* tp_descr_get */
850 0, /* tp_descr_set */
851 0, /* tp_dictoffset */
854 Message_tp_new
, /* tp_new */
857 static PyTypeObject MethodCallMessageType
= {
858 PyObject_HEAD_INIT(NULL
)
860 "_dbus_bindings.MethodCallMessage", /*tp_name*/
870 0, /*tp_as_sequence*/
878 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
, /*tp_flags*/
879 MethodCallMessage_tp_doc
, /* tp_doc */
882 0, /* tp_richcompare */
883 0, /* tp_weaklistoffset */
889 DEFERRED_ADDRESS(&MessageType
), /* tp_base */
891 0, /* tp_descr_get */
892 0, /* tp_descr_set */
893 0, /* tp_dictoffset */
894 (initproc
)MethodCallMessage_tp_init
, /* tp_init */
899 static PyTypeObject MethodReturnMessageType
= {
900 PyObject_HEAD_INIT(NULL
)
902 "_dbus_bindings.MethodReturnMessage", /*tp_name*/
912 0, /*tp_as_sequence*/
920 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
, /*tp_flags*/
921 MethodReturnMessage_tp_doc
, /* tp_doc */
924 0, /* tp_richcompare */
925 0, /* tp_weaklistoffset */
931 DEFERRED_ADDRESS(&MessageType
), /* tp_base */
933 0, /* tp_descr_get */
934 0, /* tp_descr_set */
935 0, /* tp_dictoffset */
936 (initproc
)MethodReturnMessage_tp_init
, /* tp_init */
941 static PyTypeObject SignalMessageType
= {
942 PyObject_HEAD_INIT(NULL
)
944 "_dbus_bindings.SignalMessage", /*tp_name*/
954 0, /*tp_as_sequence*/
962 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
, /*tp_flags*/
963 SignalMessage_tp_doc
, /* tp_doc */
966 0, /* tp_richcompare */
967 0, /* tp_weaklistoffset */
973 DEFERRED_ADDRESS(&MessageType
), /* tp_base */
975 0, /* tp_descr_get */
976 0, /* tp_descr_set */
977 0, /* tp_dictoffset */
978 (initproc
)SignalMessage_tp_init
, /* tp_init */
983 static PyTypeObject ErrorMessageType
= {
984 PyObject_HEAD_INIT(NULL
)
986 "_dbus_bindings.ErrorMessage", /*tp_name*/
996 0, /*tp_as_sequence*/
1004 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
, /*tp_flags*/
1005 ErrorMessage_tp_doc
, /* tp_doc */
1006 0, /* tp_traverse */
1008 0, /* tp_richcompare */
1009 0, /* tp_weaklistoffset */
1011 0, /* tp_iternext */
1015 DEFERRED_ADDRESS(&MessageType
), /* tp_base */
1017 0, /* tp_descr_get */
1018 0, /* tp_descr_set */
1019 0, /* tp_dictoffset */
1020 (initproc
)ErrorMessage_tp_init
, /* tp_init */
1026 init_message_types(void)
1028 if (PyType_Ready(&MessageType
) < 0) return 0;
1030 MethodCallMessageType
.tp_base
= &MessageType
;
1031 if (PyType_Ready(&MethodCallMessageType
) < 0) return 0;
1033 MethodReturnMessageType
.tp_base
= &MessageType
;
1034 if (PyType_Ready(&MethodReturnMessageType
) < 0) return 0;
1036 SignalMessageType
.tp_base
= &MessageType
;
1037 if (PyType_Ready(&SignalMessageType
) < 0) return 0;
1039 ErrorMessageType
.tp_base
= &MessageType
;
1040 if (PyType_Ready(&ErrorMessageType
) < 0) return 0;
1046 insert_message_types(PyObject
*this_module
)
1048 if (PyModule_AddObject(this_module
, "Message",
1049 (PyObject
*)&MessageType
) < 0) return 0;
1051 if (PyModule_AddObject(this_module
, "MethodCallMessage",
1052 (PyObject
*)&MethodCallMessageType
) < 0) return 0;
1054 if (PyModule_AddObject(this_module
, "MethodReturnMessage",
1055 (PyObject
*)&MethodReturnMessageType
) < 0) return 0;
1057 if (PyModule_AddObject(this_module
, "ErrorMessage",
1058 (PyObject
*)&ErrorMessageType
) < 0) return 0;
1060 if (PyModule_AddObject(this_module
, "SignalMessage",
1061 (PyObject
*)&SignalMessageType
) < 0) return 0;
1066 /* vim:set ft=c cino< sw=4 sts=4 et: */