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
);
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
)
46 dbus_message_unref (self
->msg
);
48 self
->ob_type
->tp_free ((PyObject
*)self
);
52 Message_tp_new (PyTypeObject
*type
,
53 PyObject
*args UNUSED
,
54 PyObject
*kwargs UNUSED
)
58 self
= (Message
*)type
->tp_alloc (type
, 0);
59 if (!self
) return 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");
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
,
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;
83 dbus_message_unref (self
->msg
);
86 self
->msg
= dbus_message_new_method_call (destination
, path
, interface
,
95 PyDoc_STRVAR(MethodReturnMessage_tp_doc
, "A method-return message.\n\n"
96 "MethodReturnMessage(method_call: MethodCallMessage)\n");
98 MethodReturnMessage_tp_init (Message
*self
, PyObject
*args
, PyObject
*kwargs
)
101 static char *kwlist
[] = {"method_call", NULL
};
103 if (!PyArg_ParseTupleAndKeywords (args
, kwargs
, "O!:__init__", kwlist
,
104 &MessageType
, &other
)) {
108 dbus_message_unref (self
->msg
);
111 self
->msg
= dbus_message_new_method_return (other
->msg
);
119 PyDoc_STRVAR(SignalMessage_tp_doc
, "A signal message.\n\n"
120 "SignalMessage(path: str, interface: str, method: str)\n");
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
)) {
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;
135 dbus_message_unref (self
->msg
);
138 self
->msg
= dbus_message_new_signal (path
, interface
, name
);
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");
150 ErrorMessage_tp_init (Message
*self
, PyObject
*args
, PyObject
*kwargs
)
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
,
161 if (!dbus_py_validate_error_name(error_name
)) return -1;
163 dbus_message_unref (self
->msg
);
166 self
->msg
= dbus_message_new_error (reply_to
->msg
, error_name
, error_message
);
175 DBusPyMessage_BorrowDBusMessage(PyObject
*msg
)
177 if (!Message_Check (msg
)) {
178 PyErr_SetString (PyExc_TypeError
,
179 "A _dbus_bindings.Message instance is required");
182 if (!((Message
*)msg
)->msg
) {
183 DBusException_UnusableMessage();
186 return ((Message
*)msg
)->msg
;
190 Message_ConsumeDBusMessage (DBusMessage
*msg
)
195 switch (dbus_message_get_type (msg
)) {
196 case DBUS_MESSAGE_TYPE_METHOD_CALL
:
197 type
= &MethodCallMessageType
;
199 case DBUS_MESSAGE_TYPE_METHOD_RETURN
:
200 type
= &MethodReturnMessageType
;
202 case DBUS_MESSAGE_TYPE_ERROR
:
203 type
= &ErrorMessageType
;
205 case DBUS_MESSAGE_TYPE_SIGNAL
:
206 type
= &SignalMessageType
;
212 self
= (Message
*)(type
->tp_new
) (type
, empty_tuple
, NULL
);
214 dbus_message_unref(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");
225 Message_copy (Message
*self
, PyObject
*args UNUSED
)
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");
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");
250 Message_set_auto_start (Message
*self
, PyObject
*args
)
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
);
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");
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");
274 Message_set_no_reply (Message
*self
, PyObject
*args
)
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
);
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");
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");
297 Message_set_reply_serial (Message
*self
, PyObject
*args
)
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();
310 PyDoc_STRVAR(Message_get_type__doc__
,
311 "message.get_type() -> int\n\n"
312 "Returns the type of the message.\n");
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"
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");
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");
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
)) {
345 if (!self
->msg
) return DBusException_UnusableMessage();
346 return PyBool_FromLong (dbus_message_is_method_call (self
->msg
, interface
,
350 PyDoc_STRVAR(Message_is_error__doc__
,
351 "is_error(error: str) -> bool");
353 Message_is_error (Message
*self
, PyObject
*args
)
355 const char *error_name
;
357 if (!PyArg_ParseTuple(args
, "s:is_error", &error_name
)) {
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");
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
)) {
374 if (!self
->msg
) return DBusException_UnusableMessage();
375 return PyBool_FromLong (dbus_message_is_signal (self
->msg
, interface
,
379 PyDoc_STRVAR(Message_get_member__doc__
,
380 "get_member() -> str or None");
382 Message_get_member (Message
*self
, PyObject
*unused UNUSED
)
386 if (!self
->msg
) return DBusException_UnusableMessage();
387 c_str
= dbus_message_get_member (self
->msg
);
391 return PyString_FromString(c_str
);
394 PyDoc_STRVAR(Message_has_member__doc__
,
395 "has_member(name: str or None) -> bool");
397 Message_has_member (Message
*self
, PyObject
*args
)
401 if (!PyArg_ParseTuple(args
, "z:has_member", &name
)) {
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)");
411 Message_set_member (Message
*self
, PyObject
*args
)
415 if (!PyArg_ParseTuple(args
, "z:set_member", &name
)) {
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();
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"
430 Message_get_path (Message
*self
, PyObject
*unused UNUSED
)
434 if (!self
->msg
) return DBusException_UnusableMessage();
435 c_str
= dbus_message_get_path (self
->msg
);
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");
447 Message_get_path_decomposed (Message
*self
, PyObject
*unused UNUSED
)
450 PyObject
*ret
= PyList_New(0);
452 if (!ret
) return NULL
;
455 return DBusException_UnusableMessage ();
457 if (!dbus_message_get_path_decomposed (self
->msg
, &paths
)) {
459 return PyErr_NoMemory ();
465 for (ptr
= paths
; *ptr
; ptr
++) {
466 PyObject
*str
= PyString_FromString (*ptr
);
473 if (PyList_Append (ret
, str
) < 0) {
481 dbus_free_string_array (paths
);
485 PyDoc_STRVAR(Message_has_path__doc__
,
486 "has_path(name: str or None) -> bool");
488 Message_has_path (Message
*self
, PyObject
*args
)
492 if (!PyArg_ParseTuple(args
, "z:has_path", &name
)) {
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)");
502 Message_set_path (Message
*self
, PyObject
*args
)
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();
512 PyDoc_STRVAR(Message_get_signature__doc__
,
513 "get_signature() -> Signature or None");
515 Message_get_signature (Message
*self
, PyObject
*unused UNUSED
)
519 if (!self
->msg
) return DBusException_UnusableMessage();
520 c_str
= dbus_message_get_signature (self
->msg
);
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");
530 Message_has_signature (Message
*self
, PyObject
*args
)
534 if (!PyArg_ParseTuple(args
, "s:has_signature", &name
)) {
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");
545 Message_get_sender (Message
*self
, PyObject
*unused UNUSED
)
549 if (!self
->msg
) return DBusException_UnusableMessage();
550 c_str
= dbus_message_get_sender (self
->msg
);
554 return PyString_FromString(c_str
);
557 PyDoc_STRVAR(Message_has_sender__doc__
,
558 "has_sender(unique_name: str) -> bool");
560 Message_has_sender (Message
*self
, PyObject
*args
)
564 if (!PyArg_ParseTuple(args
, "s:has_sender", &name
)) {
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)");
574 Message_set_sender (Message
*self
, PyObject
*args
)
578 if (!PyArg_ParseTuple(args
, "z:set_sender", &name
)) {
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();
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");
591 Message_get_destination(Message
*self
, PyObject
*unused UNUSED
)
595 if (!self
->msg
) return DBusException_UnusableMessage();
596 c_str
= dbus_message_get_destination(self
->msg
);
600 return PyString_FromString(c_str
);
603 PyDoc_STRVAR(Message_has_destination__doc__
,
604 "has_destination(bus_name: str) -> bool");
606 Message_has_destination (Message
*self
, PyObject
*args
)
610 if (!PyArg_ParseTuple(args
, "s:has_destination", &name
)) {
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)");
620 Message_set_destination (Message
*self
, PyObject
*args
)
624 if (!PyArg_ParseTuple(args
, "z:set_destination", &name
)) {
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();
633 PyDoc_STRVAR(Message_get_interface__doc__
,
634 "get_interface() -> str or None");
636 Message_get_interface (Message
*self
, PyObject
*unused UNUSED
)
640 if (!self
->msg
) return DBusException_UnusableMessage();
641 c_str
= dbus_message_get_interface (self
->msg
);
645 return PyString_FromString(c_str
);
648 PyDoc_STRVAR(Message_has_interface__doc__
,
649 "has_interface(interface: str or None) -> bool");
651 Message_has_interface(Message
*self
, PyObject
*args
)
655 if (!PyArg_ParseTuple(args
, "z:has_interface", &name
)) {
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)");
665 Message_set_interface (Message
*self
, PyObject
*args
)
669 if (!PyArg_ParseTuple(args
, "z:set_interface", &name
)) {
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();
678 PyDoc_STRVAR(Message_get_error_name__doc__
,
679 "get_error_name() -> str or None");
681 Message_get_error_name (Message
*self
, PyObject
*unused UNUSED
)
685 if (!self
->msg
) return DBusException_UnusableMessage();
686 c_str
= dbus_message_get_error_name (self
->msg
);
690 return PyString_FromString(c_str
);
693 PyDoc_STRVAR(Message_set_error_name__doc__
,
694 "set_error_name(name: str or None)");
696 Message_set_error_name(Message
*self
, PyObject
*args
)
700 if (!PyArg_ParseTuple(args
, "z:set_error_name", &name
)) {
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();
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
)
791 "dbus.lowlevel.Message", /*tp_name*/
792 sizeof(Message
), /*tp_basicsize*/
794 (destructor
)Message_tp_dealloc
, /*tp_dealloc*/
801 0, /*tp_as_sequence*/
809 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
, /*tp_flags*/
810 Message_tp_doc
, /* tp_doc */
813 0, /* tp_richcompare */
814 0, /* tp_weaklistoffset */
817 Message_tp_methods
, /* tp_methods */
822 0, /* tp_descr_get */
823 0, /* tp_descr_set */
824 0, /* tp_dictoffset */
827 Message_tp_new
, /* tp_new */
830 static PyTypeObject MethodCallMessageType
= {
831 PyObject_HEAD_INIT(NULL
)
833 "dbus.lowlevel.MethodCallMessage", /*tp_name*/
843 0, /*tp_as_sequence*/
851 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
, /*tp_flags*/
852 MethodCallMessage_tp_doc
, /* tp_doc */
855 0, /* tp_richcompare */
856 0, /* tp_weaklistoffset */
862 DEFERRED_ADDRESS(&MessageType
), /* tp_base */
864 0, /* tp_descr_get */
865 0, /* tp_descr_set */
866 0, /* tp_dictoffset */
867 (initproc
)MethodCallMessage_tp_init
, /* tp_init */
872 static PyTypeObject MethodReturnMessageType
= {
873 PyObject_HEAD_INIT(NULL
)
875 "dbus.lowlevel.MethodReturnMessage", /*tp_name*/
885 0, /*tp_as_sequence*/
893 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
, /*tp_flags*/
894 MethodReturnMessage_tp_doc
, /* tp_doc */
897 0, /* tp_richcompare */
898 0, /* tp_weaklistoffset */
904 DEFERRED_ADDRESS(&MessageType
), /* tp_base */
906 0, /* tp_descr_get */
907 0, /* tp_descr_set */
908 0, /* tp_dictoffset */
909 (initproc
)MethodReturnMessage_tp_init
, /* tp_init */
914 static PyTypeObject SignalMessageType
= {
915 PyObject_HEAD_INIT(NULL
)
917 "dbus.lowlevel.SignalMessage", /*tp_name*/
927 0, /*tp_as_sequence*/
935 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
, /*tp_flags*/
936 SignalMessage_tp_doc
, /* tp_doc */
939 0, /* tp_richcompare */
940 0, /* tp_weaklistoffset */
946 DEFERRED_ADDRESS(&MessageType
), /* tp_base */
948 0, /* tp_descr_get */
949 0, /* tp_descr_set */
950 0, /* tp_dictoffset */
951 (initproc
)SignalMessage_tp_init
, /* tp_init */
956 static PyTypeObject ErrorMessageType
= {
957 PyObject_HEAD_INIT(NULL
)
959 "dbus.lowlevel.ErrorMessage", /*tp_name*/
969 0, /*tp_as_sequence*/
977 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
, /*tp_flags*/
978 ErrorMessage_tp_doc
, /* tp_doc */
981 0, /* tp_richcompare */
982 0, /* tp_weaklistoffset */
988 DEFERRED_ADDRESS(&MessageType
), /* tp_base */
990 0, /* tp_descr_get */
991 0, /* tp_descr_set */
992 0, /* tp_dictoffset */
993 (initproc
)ErrorMessage_tp_init
, /* tp_init */
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;
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;
1039 /* vim:set ft=c cino< sw=4 sts=4 et: */