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 #include "dbus_bindings-internal.h"
27 #include "message-internal.h"
29 static PyTypeObject MessageType
, SignalMessageType
, ErrorMessageType
;
30 static PyTypeObject MethodReturnMessageType
, MethodCallMessageType
;
32 static inline int Message_Check(PyObject
*o
)
34 return (o
->ob_type
== &MessageType
)
35 || PyObject_IsInstance(o
, (PyObject
*)&MessageType
);
39 DBusPy_RaiseUnusableMessage(void)
41 PyErr_SetString(DBusPyException
,
42 "Message object is uninitialized, or has become unusable "
43 "due to error while appending arguments");
47 PyDoc_STRVAR(Message_tp_doc
,
48 "A message to be sent or received over a D-Bus Connection.\n");
50 static void Message_tp_dealloc(Message
*self
)
53 dbus_message_unref(self
->msg
);
55 self
->ob_type
->tp_free((PyObject
*)self
);
59 Message_tp_new(PyTypeObject
*type
,
60 PyObject
*args UNUSED
,
61 PyObject
*kwargs UNUSED
)
65 self
= (Message
*)type
->tp_alloc(type
, 0);
66 if (!self
) return NULL
;
68 return (PyObject
*)self
;
71 PyDoc_STRVAR(MethodCallMessage_tp_doc
, "A method-call message.\n"
75 " dbus.lowlevel.MethodCallMessage(destination: str or None, path: str,\n"
76 " interface: str or None, method: str)\n"
78 "``destination`` is the destination bus name, or None to send the\n"
79 "message directly to the peer (usually the bus daemon).\n"
81 "``path`` is the object-path of the object whose method is to be called.\n"
83 "``interface`` is the interface qualifying the method name, or None to omit\n"
84 "the interface from the message header.\n"
86 "``method`` is the method name (member name).\n"
90 MethodCallMessage_tp_init(Message
*self
, PyObject
*args
, PyObject
*kwargs
)
92 const char *destination
, *path
, *interface
, *method
;
93 static char *kwlist
[] = {"destination", "path", "interface", "method", NULL
};
95 if (!PyArg_ParseTupleAndKeywords(args
, kwargs
, "zszs:__init__", kwlist
,
96 &destination
, &path
, &interface
,
100 if (destination
&& !dbus_py_validate_bus_name(destination
, 1, 1)) return -1;
101 if (!dbus_py_validate_object_path(path
)) return -1;
102 if (interface
&& !dbus_py_validate_interface_name(interface
)) return -1;
103 if (!dbus_py_validate_member_name(method
)) return -1;
105 dbus_message_unref(self
->msg
);
108 self
->msg
= dbus_message_new_method_call(destination
, path
, interface
,
117 PyDoc_STRVAR(MethodReturnMessage_tp_doc
, "A method-return message.\n\n"
119 " dbus.lowlevel.MethodReturnMessage(method_call: MethodCallMessage)\n");
122 MethodReturnMessage_tp_init(Message
*self
, PyObject
*args
, PyObject
*kwargs
)
125 static char *kwlist
[] = {"method_call", NULL
};
127 if (!PyArg_ParseTupleAndKeywords(args
, kwargs
, "O!:__init__", kwlist
,
128 &MessageType
, &other
)) {
132 dbus_message_unref(self
->msg
);
135 self
->msg
= dbus_message_new_method_return(other
->msg
);
143 PyDoc_STRVAR(SignalMessage_tp_doc
, "A signal message.\n\n"
145 " dbus.lowlevel.SignalMessage(path: str, interface: str, method: str)\n");
147 SignalMessage_tp_init(Message
*self
, PyObject
*args
, PyObject
*kwargs
)
149 const char *path
, *interface
, *name
;
150 static char *kwlist
[] = {"path", "interface", "name", NULL
};
152 if (!PyArg_ParseTupleAndKeywords(args
, kwargs
, "sss:__init__", kwlist
,
153 &path
, &interface
, &name
)) {
156 if (!dbus_py_validate_object_path(path
)) return -1;
157 if (!dbus_py_validate_interface_name(interface
)) return -1;
158 if (!dbus_py_validate_member_name(name
)) return -1;
160 dbus_message_unref(self
->msg
);
163 self
->msg
= dbus_message_new_signal(path
, interface
, name
);
171 PyDoc_STRVAR(ErrorMessage_tp_doc
, "An error message.\n\n"
173 " dbus.lowlevel.ErrorMessage(reply_to: Message, error_name: str,\n"
174 " error_message: str or None)\n");
176 ErrorMessage_tp_init(Message
*self
, PyObject
*args
, PyObject
*kwargs
)
179 const char *error_name
, *error_message
;
180 static char *kwlist
[] = {"reply_to", "error_name", "error_message", NULL
};
182 if (!PyArg_ParseTupleAndKeywords(args
, kwargs
, "O!sz:__init__", kwlist
,
183 &MessageType
, &reply_to
, &error_name
,
187 if (!dbus_py_validate_error_name(error_name
)) return -1;
189 dbus_message_unref(self
->msg
);
192 self
->msg
= dbus_message_new_error(reply_to
->msg
, error_name
, error_message
);
201 DBusPyMessage_BorrowDBusMessage(PyObject
*msg
)
203 if (!Message_Check(msg
)) {
204 PyErr_SetString(PyExc_TypeError
,
205 "A dbus.lowlevel.Message instance is required");
208 if (!((Message
*)msg
)->msg
) {
209 DBusPy_RaiseUnusableMessage();
212 return ((Message
*)msg
)->msg
;
216 DBusPyMessage_ConsumeDBusMessage(DBusMessage
*msg
)
221 switch (dbus_message_get_type(msg
)) {
222 case DBUS_MESSAGE_TYPE_METHOD_CALL
:
223 type
= &MethodCallMessageType
;
225 case DBUS_MESSAGE_TYPE_METHOD_RETURN
:
226 type
= &MethodReturnMessageType
;
228 case DBUS_MESSAGE_TYPE_ERROR
:
229 type
= &ErrorMessageType
;
231 case DBUS_MESSAGE_TYPE_SIGNAL
:
232 type
= &SignalMessageType
;
238 self
= (Message
*)(type
->tp_new
) (type
, dbus_py_empty_tuple
, NULL
);
240 dbus_message_unref(msg
);
244 return (PyObject
*)self
;
247 PyDoc_STRVAR(Message_copy__doc__
,
248 "message.copy() -> Message (or subclass)\n"
249 "Deep-copy the message, resetting the serial number to zero.\n");
251 Message_copy(Message
*self
, PyObject
*args UNUSED
)
254 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
255 msg
= dbus_message_copy(self
->msg
);
256 if (!msg
) return PyErr_NoMemory();
257 return DBusPyMessage_ConsumeDBusMessage(msg
);
260 PyDoc_STRVAR(Message_get_auto_start__doc__
,
261 "message.get_auto_start() -> bool\n"
262 "Return true if this message will cause an owner for the destination name\n"
263 "to be auto-started.\n");
265 Message_get_auto_start(Message
*self
, PyObject
*unused UNUSED
)
267 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
268 return PyBool_FromLong(dbus_message_get_auto_start(self
->msg
));
271 PyDoc_STRVAR(Message_set_auto_start__doc__
,
272 "message.set_auto_start(bool) -> None\n"
273 "Set whether this message will cause an owner for the destination name\n"
274 "to be auto-started.\n");
276 Message_set_auto_start(Message
*self
, PyObject
*args
)
279 if (!PyArg_ParseTuple(args
, "i", &value
)) return NULL
;
280 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
281 dbus_message_set_auto_start(self
->msg
, value
? TRUE
: FALSE
);
286 PyDoc_STRVAR(Message_get_no_reply__doc__
,
287 "message.get_no_reply() -> bool\n"
288 "Return true if this message need not be replied to.\n");
290 Message_get_no_reply(Message
*self
, PyObject
*unused UNUSED
)
292 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
293 return PyBool_FromLong(dbus_message_get_no_reply(self
->msg
));
296 PyDoc_STRVAR(Message_set_no_reply__doc__
,
297 "message.set_no_reply(bool) -> None\n"
298 "Set whether no reply to this message is required.\n");
300 Message_set_no_reply(Message
*self
, PyObject
*args
)
303 if (!PyArg_ParseTuple(args
, "i", &value
)) return NULL
;
304 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
305 dbus_message_set_no_reply(self
->msg
, value
? TRUE
: FALSE
);
309 PyDoc_STRVAR(Message_get_reply_serial__doc__
,
310 "message.get_reply_serial() -> long\n"
311 "Returns the serial that the message is a reply to or 0 if none.\n");
313 Message_get_reply_serial(Message
*self
, PyObject
*unused UNUSED
)
315 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
316 return PyLong_FromUnsignedLong(dbus_message_get_reply_serial(self
->msg
));
319 PyDoc_STRVAR(Message_set_reply_serial__doc__
,
320 "message.set_reply_serial(bool) -> None\n"
321 "Set the serial that this message is a reply to.\n");
323 Message_set_reply_serial(Message
*self
, PyObject
*args
)
327 if (!PyArg_ParseTuple(args
, "k", &value
)) return NULL
;
328 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
329 if (!dbus_message_set_reply_serial(self
->msg
, value
)) {
330 return PyErr_NoMemory();
336 PyDoc_STRVAR(Message_get_type__doc__
,
337 "message.get_type() -> int\n\n"
338 "Returns the type of the message.\n");
340 Message_get_type(Message
*self
, PyObject
*unused UNUSED
)
342 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
343 return PyInt_FromLong(dbus_message_get_type(self
->msg
));
346 PyDoc_STRVAR(Message_get_serial__doc__
,
347 "message.get_serial() -> long\n"
348 "Returns the serial of a message or 0 if none has been specified.\n"
350 "The message's serial number is provided by the application sending the\n"
351 "message and is used to identify replies to this message. All messages\n"
352 "received on a connection will have a serial, but messages you haven't\n"
353 "sent yet may return 0.\n");
355 Message_get_serial(Message
*self
, PyObject
*unused UNUSED
)
357 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
358 return PyLong_FromUnsignedLong(dbus_message_get_serial(self
->msg
));
361 PyDoc_STRVAR(Message_is_method_call__doc__
,
362 "is_method_call(interface: str, member: str) -> bool");
364 Message_is_method_call(Message
*self
, PyObject
*args
)
366 const char *interface
, *method
;
368 if (!PyArg_ParseTuple(args
, "ss:is_method_call", &interface
, &method
)) {
371 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
372 return PyBool_FromLong(dbus_message_is_method_call(self
->msg
, interface
,
376 PyDoc_STRVAR(Message_is_error__doc__
,
377 "is_error(error: str) -> bool");
379 Message_is_error(Message
*self
, PyObject
*args
)
381 const char *error_name
;
383 if (!PyArg_ParseTuple(args
, "s:is_error", &error_name
)) {
386 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
387 return PyBool_FromLong(dbus_message_is_error(self
->msg
, error_name
));
390 PyDoc_STRVAR(Message_is_signal__doc__
,
391 "is_signal(interface: str, member: str) -> bool");
393 Message_is_signal(Message
*self
, PyObject
*args
)
395 const char *interface
, *signal_name
;
397 if (!PyArg_ParseTuple(args
, "ss:is_signal", &interface
, &signal_name
)) {
400 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
401 return PyBool_FromLong(dbus_message_is_signal(self
->msg
, interface
,
405 PyDoc_STRVAR(Message_get_member__doc__
,
406 "get_member() -> str or None");
408 Message_get_member(Message
*self
, PyObject
*unused UNUSED
)
412 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
413 c_str
= dbus_message_get_member(self
->msg
);
417 return PyString_FromString(c_str
);
420 PyDoc_STRVAR(Message_has_member__doc__
,
421 "has_member(name: str or None) -> bool");
423 Message_has_member(Message
*self
, PyObject
*args
)
427 if (!PyArg_ParseTuple(args
, "z:has_member", &name
)) {
430 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
431 return PyBool_FromLong(dbus_message_has_member(self
->msg
, name
));
434 PyDoc_STRVAR(Message_set_member__doc__
,
435 "set_member(unique_name: str or None)");
437 Message_set_member(Message
*self
, PyObject
*args
)
441 if (!PyArg_ParseTuple(args
, "z:set_member", &name
)) {
444 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
445 if (!dbus_py_validate_member_name(name
)) return NULL
;
446 if (!dbus_message_set_member(self
->msg
, name
)) return PyErr_NoMemory();
450 PyDoc_STRVAR(Message_get_path__doc__
,
451 "get_path() -> ObjectPath or None\n\n"
452 "Return the message's destination object path (if it's a method call) or\n"
453 "source object path (if it's a method reply or a signal) or None (if it\n"
456 Message_get_path(Message
*self
, PyObject
*unused UNUSED
)
460 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
461 c_str
= dbus_message_get_path(self
->msg
);
465 return PyObject_CallFunction((PyObject
*)&DBusPyObjectPath_Type
, "(s)", c_str
);
468 PyDoc_STRVAR(Message_get_path_decomposed__doc__
,
469 "get_path_decomposed() -> list of str, or None\n\n"
470 "Return a list of path components (e.g. /foo/bar -> ['foo','bar'], / -> [])\n"
471 "or None if the message has no associated path.\n");
473 Message_get_path_decomposed(Message
*self
, PyObject
*unused UNUSED
)
476 PyObject
*ret
= PyList_New(0);
478 if (!ret
) return NULL
;
481 return DBusPy_RaiseUnusableMessage();
483 if (!dbus_message_get_path_decomposed(self
->msg
, &paths
)) {
485 return PyErr_NoMemory();
491 for (ptr
= paths
; *ptr
; ptr
++) {
492 PyObject
*str
= PyString_FromString(*ptr
);
499 if (PyList_Append(ret
, str
) < 0) {
507 dbus_free_string_array(paths
);
511 PyDoc_STRVAR(Message_has_path__doc__
,
512 "has_path(name: str or None) -> bool");
514 Message_has_path(Message
*self
, PyObject
*args
)
518 if (!PyArg_ParseTuple(args
, "z:has_path", &name
)) {
521 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
522 return PyBool_FromLong(dbus_message_has_path(self
->msg
, name
));
525 PyDoc_STRVAR(Message_set_path__doc__
,
526 "set_path(name: str or None)");
528 Message_set_path(Message
*self
, PyObject
*args
)
532 if (!PyArg_ParseTuple(args
, "z:set_path", &name
)) return NULL
;
533 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
534 if (!dbus_message_has_path(self
->msg
, name
)) return PyErr_NoMemory();
538 PyDoc_STRVAR(Message_get_signature__doc__
,
539 "get_signature() -> Signature or None");
541 Message_get_signature(Message
*self
, PyObject
*unused UNUSED
)
545 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
546 c_str
= dbus_message_get_signature(self
->msg
);
548 return PyObject_CallFunction((PyObject
*)&DBusPySignature_Type
, "(s)", "");
550 return PyObject_CallFunction((PyObject
*)&DBusPySignature_Type
, "(s)", c_str
);
553 PyDoc_STRVAR(Message_has_signature__doc__
,
554 "has_signature(signature: str) -> bool");
556 Message_has_signature(Message
*self
, PyObject
*args
)
560 if (!PyArg_ParseTuple(args
, "s:has_signature", &name
)) {
563 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
564 return PyBool_FromLong(dbus_message_has_signature(self
->msg
, name
));
567 PyDoc_STRVAR(Message_get_sender__doc__
,
568 "get_sender() -> str or None\n\n"
569 "Return the message's sender unique name, or None if none.\n");
571 Message_get_sender(Message
*self
, PyObject
*unused UNUSED
)
575 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
576 c_str
= dbus_message_get_sender(self
->msg
);
580 return PyString_FromString(c_str
);
583 PyDoc_STRVAR(Message_has_sender__doc__
,
584 "has_sender(unique_name: str) -> bool");
586 Message_has_sender(Message
*self
, PyObject
*args
)
590 if (!PyArg_ParseTuple(args
, "s:has_sender", &name
)) {
593 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
594 return PyBool_FromLong(dbus_message_has_sender(self
->msg
, name
));
597 PyDoc_STRVAR(Message_set_sender__doc__
,
598 "set_sender(unique_name: str or None)");
600 Message_set_sender(Message
*self
, PyObject
*args
)
604 if (!PyArg_ParseTuple(args
, "z:set_sender", &name
)) {
607 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
608 if (!dbus_py_validate_bus_name(name
, 1, 0)) return NULL
;
609 if (!dbus_message_set_sender(self
->msg
, name
)) return PyErr_NoMemory();
613 PyDoc_STRVAR(Message_get_destination__doc__
,
614 "get_destination() -> str or None\n\n"
615 "Return the message's destination bus name, or None if none.\n");
617 Message_get_destination(Message
*self
, PyObject
*unused UNUSED
)
621 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
622 c_str
= dbus_message_get_destination(self
->msg
);
626 return PyString_FromString(c_str
);
629 PyDoc_STRVAR(Message_has_destination__doc__
,
630 "has_destination(bus_name: str) -> bool");
632 Message_has_destination(Message
*self
, PyObject
*args
)
636 if (!PyArg_ParseTuple(args
, "s:has_destination", &name
)) {
639 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
640 return PyBool_FromLong(dbus_message_has_destination(self
->msg
, name
));
643 PyDoc_STRVAR(Message_set_destination__doc__
,
644 "set_destination(bus_name: str or None)");
646 Message_set_destination(Message
*self
, PyObject
*args
)
650 if (!PyArg_ParseTuple(args
, "z:set_destination", &name
)) {
653 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
654 if (!dbus_py_validate_bus_name(name
, 1, 1)) return NULL
;
655 if (!dbus_message_set_destination(self
->msg
, name
)) return PyErr_NoMemory();
659 PyDoc_STRVAR(Message_get_interface__doc__
,
660 "get_interface() -> str or None");
662 Message_get_interface(Message
*self
, PyObject
*unused UNUSED
)
666 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
667 c_str
= dbus_message_get_interface(self
->msg
);
671 return PyString_FromString(c_str
);
674 PyDoc_STRVAR(Message_has_interface__doc__
,
675 "has_interface(interface: str or None) -> bool");
677 Message_has_interface(Message
*self
, PyObject
*args
)
681 if (!PyArg_ParseTuple(args
, "z:has_interface", &name
)) {
684 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
685 return PyBool_FromLong(dbus_message_has_interface(self
->msg
, name
));
688 PyDoc_STRVAR(Message_set_interface__doc__
,
689 "set_interface(name: str or None)");
691 Message_set_interface(Message
*self
, PyObject
*args
)
695 if (!PyArg_ParseTuple(args
, "z:set_interface", &name
)) {
698 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
699 if (!dbus_py_validate_interface_name(name
)) return NULL
;
700 if (!dbus_message_set_interface(self
->msg
, name
)) return PyErr_NoMemory();
704 PyDoc_STRVAR(Message_get_error_name__doc__
,
705 "get_error_name() -> str or None");
707 Message_get_error_name(Message
*self
, PyObject
*unused UNUSED
)
711 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
712 c_str
= dbus_message_get_error_name(self
->msg
);
716 return PyString_FromString(c_str
);
719 PyDoc_STRVAR(Message_set_error_name__doc__
,
720 "set_error_name(name: str or None)");
722 Message_set_error_name(Message
*self
, PyObject
*args
)
726 if (!PyArg_ParseTuple(args
, "z:set_error_name", &name
)) {
729 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
730 if (!dbus_py_validate_error_name(name
)) return NULL
;
731 if (!dbus_message_set_error_name(self
->msg
, name
)) return PyErr_NoMemory();
735 static PyMethodDef Message_tp_methods
[] = {
736 {"copy", (PyCFunction
)Message_copy
,
737 METH_NOARGS
, Message_copy__doc__
},
738 {"is_method_call", (PyCFunction
)Message_is_method_call
,
739 METH_VARARGS
, Message_is_method_call__doc__
},
740 {"is_signal", (PyCFunction
)Message_is_signal
,
741 METH_VARARGS
, Message_is_signal__doc__
},
742 {"is_error", (PyCFunction
)Message_is_error
,
743 METH_VARARGS
, Message_is_error__doc__
},
745 {"get_args_list", (PyCFunction
)dbus_py_Message_get_args_list
,
746 METH_VARARGS
|METH_KEYWORDS
, dbus_py_Message_get_args_list__doc__
},
747 {"guess_signature", (PyCFunction
)dbus_py_Message_guess_signature
,
748 METH_VARARGS
|METH_STATIC
, dbus_py_Message_guess_signature__doc__
},
749 {"append", (PyCFunction
)dbus_py_Message_append
,
750 METH_VARARGS
|METH_KEYWORDS
, dbus_py_Message_append__doc__
},
752 {"get_auto_start", (PyCFunction
)Message_get_auto_start
,
753 METH_NOARGS
, Message_get_auto_start__doc__
},
754 {"set_auto_start", (PyCFunction
)Message_set_auto_start
,
755 METH_VARARGS
, Message_set_auto_start__doc__
},
756 {"get_destination", (PyCFunction
)Message_get_destination
,
757 METH_NOARGS
, Message_get_destination__doc__
},
758 {"set_destination", (PyCFunction
)Message_set_destination
,
759 METH_VARARGS
, Message_set_destination__doc__
},
760 {"has_destination", (PyCFunction
)Message_has_destination
,
761 METH_VARARGS
, Message_has_destination__doc__
},
762 {"get_error_name", (PyCFunction
)Message_get_error_name
,
763 METH_NOARGS
, Message_get_error_name__doc__
},
764 {"set_error_name", (PyCFunction
)Message_set_error_name
,
765 METH_VARARGS
, Message_set_error_name__doc__
},
766 {"get_interface", (PyCFunction
)Message_get_interface
,
767 METH_NOARGS
, Message_get_interface__doc__
},
768 {"set_interface", (PyCFunction
)Message_set_interface
,
769 METH_VARARGS
, Message_set_interface__doc__
},
770 {"has_interface", (PyCFunction
)Message_has_interface
,
771 METH_VARARGS
, Message_has_interface__doc__
},
772 {"get_member", (PyCFunction
)Message_get_member
,
773 METH_NOARGS
, Message_get_member__doc__
},
774 {"set_member", (PyCFunction
)Message_set_member
,
775 METH_VARARGS
, Message_set_member__doc__
},
776 {"has_member", (PyCFunction
)Message_has_member
,
777 METH_VARARGS
, Message_has_member__doc__
},
778 {"get_path", (PyCFunction
)Message_get_path
,
779 METH_NOARGS
, Message_get_path__doc__
},
780 {"get_path_decomposed", (PyCFunction
)Message_get_path_decomposed
,
781 METH_NOARGS
, Message_get_path_decomposed__doc__
},
782 {"set_path", (PyCFunction
)Message_set_path
,
783 METH_VARARGS
, Message_set_path__doc__
},
784 {"has_path", (PyCFunction
)Message_has_path
,
785 METH_VARARGS
, Message_has_path__doc__
},
786 {"get_no_reply", (PyCFunction
)Message_get_no_reply
,
787 METH_NOARGS
, Message_get_no_reply__doc__
},
788 {"set_no_reply", (PyCFunction
)Message_set_no_reply
,
789 METH_VARARGS
, Message_set_no_reply__doc__
},
790 {"get_reply_serial", (PyCFunction
)Message_get_reply_serial
,
791 METH_NOARGS
, Message_get_reply_serial__doc__
},
792 {"set_reply_serial", (PyCFunction
)Message_set_reply_serial
,
793 METH_VARARGS
, Message_set_reply_serial__doc__
},
794 {"get_sender", (PyCFunction
)Message_get_sender
,
795 METH_NOARGS
, Message_get_sender__doc__
},
796 {"set_sender", (PyCFunction
)Message_set_sender
,
797 METH_VARARGS
, Message_set_sender__doc__
},
798 {"has_sender", (PyCFunction
)Message_has_sender
,
799 METH_VARARGS
, Message_has_sender__doc__
},
800 {"get_serial", (PyCFunction
)Message_get_serial
,
801 METH_NOARGS
, Message_get_serial__doc__
},
802 {"get_signature", (PyCFunction
)Message_get_signature
,
803 METH_NOARGS
, Message_get_signature__doc__
},
804 {"has_signature", (PyCFunction
)Message_has_signature
,
805 METH_VARARGS
, Message_has_signature__doc__
},
806 {"get_type", (PyCFunction
)Message_get_type
,
807 METH_NOARGS
, Message_get_type__doc__
},
808 {NULL
, NULL
, 0, NULL
}
811 static PyTypeObject MessageType
= {
812 PyObject_HEAD_INIT(NULL
)
814 "dbus.lowlevel.Message", /*tp_name*/
815 sizeof(Message
), /*tp_basicsize*/
817 (destructor
)Message_tp_dealloc
, /*tp_dealloc*/
824 0, /*tp_as_sequence*/
832 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
, /*tp_flags*/
833 Message_tp_doc
, /* tp_doc */
836 0, /* tp_richcompare */
837 0, /* tp_weaklistoffset */
840 Message_tp_methods
, /* tp_methods */
845 0, /* tp_descr_get */
846 0, /* tp_descr_set */
847 0, /* tp_dictoffset */
850 Message_tp_new
, /* tp_new */
853 static PyTypeObject MethodCallMessageType
= {
854 PyObject_HEAD_INIT(NULL
)
856 "dbus.lowlevel.MethodCallMessage", /*tp_name*/
866 0, /*tp_as_sequence*/
874 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
, /*tp_flags*/
875 MethodCallMessage_tp_doc
, /* tp_doc */
878 0, /* tp_richcompare */
879 0, /* tp_weaklistoffset */
885 DEFERRED_ADDRESS(&MessageType
), /* tp_base */
887 0, /* tp_descr_get */
888 0, /* tp_descr_set */
889 0, /* tp_dictoffset */
890 (initproc
)MethodCallMessage_tp_init
, /* tp_init */
895 static PyTypeObject MethodReturnMessageType
= {
896 PyObject_HEAD_INIT(NULL
)
898 "dbus.lowlevel.MethodReturnMessage", /*tp_name*/
908 0, /*tp_as_sequence*/
916 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
, /*tp_flags*/
917 MethodReturnMessage_tp_doc
, /* tp_doc */
920 0, /* tp_richcompare */
921 0, /* tp_weaklistoffset */
927 DEFERRED_ADDRESS(&MessageType
), /* tp_base */
929 0, /* tp_descr_get */
930 0, /* tp_descr_set */
931 0, /* tp_dictoffset */
932 (initproc
)MethodReturnMessage_tp_init
, /* tp_init */
937 static PyTypeObject SignalMessageType
= {
938 PyObject_HEAD_INIT(NULL
)
940 "dbus.lowlevel.SignalMessage", /*tp_name*/
950 0, /*tp_as_sequence*/
958 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
, /*tp_flags*/
959 SignalMessage_tp_doc
, /* tp_doc */
962 0, /* tp_richcompare */
963 0, /* tp_weaklistoffset */
969 DEFERRED_ADDRESS(&MessageType
), /* tp_base */
971 0, /* tp_descr_get */
972 0, /* tp_descr_set */
973 0, /* tp_dictoffset */
974 (initproc
)SignalMessage_tp_init
, /* tp_init */
979 static PyTypeObject ErrorMessageType
= {
980 PyObject_HEAD_INIT(NULL
)
982 "dbus.lowlevel.ErrorMessage", /*tp_name*/
992 0, /*tp_as_sequence*/
1000 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
, /*tp_flags*/
1001 ErrorMessage_tp_doc
, /* tp_doc */
1002 0, /* tp_traverse */
1004 0, /* tp_richcompare */
1005 0, /* tp_weaklistoffset */
1007 0, /* tp_iternext */
1011 DEFERRED_ADDRESS(&MessageType
), /* tp_base */
1013 0, /* tp_descr_get */
1014 0, /* tp_descr_set */
1015 0, /* tp_dictoffset */
1016 (initproc
)ErrorMessage_tp_init
, /* tp_init */
1022 dbus_py_init_message_types(void)
1024 if (PyType_Ready(&MessageType
) < 0) return 0;
1026 MethodCallMessageType
.tp_base
= &MessageType
;
1027 if (PyType_Ready(&MethodCallMessageType
) < 0) return 0;
1029 MethodReturnMessageType
.tp_base
= &MessageType
;
1030 if (PyType_Ready(&MethodReturnMessageType
) < 0) return 0;
1032 SignalMessageType
.tp_base
= &MessageType
;
1033 if (PyType_Ready(&SignalMessageType
) < 0) return 0;
1035 ErrorMessageType
.tp_base
= &MessageType
;
1036 if (PyType_Ready(&ErrorMessageType
) < 0) return 0;
1042 dbus_py_insert_message_types(PyObject
*this_module
)
1044 if (PyModule_AddObject(this_module
, "Message",
1045 (PyObject
*)&MessageType
) < 0) return 0;
1047 if (PyModule_AddObject(this_module
, "MethodCallMessage",
1048 (PyObject
*)&MethodCallMessageType
) < 0) return 0;
1050 if (PyModule_AddObject(this_module
, "MethodReturnMessage",
1051 (PyObject
*)&MethodReturnMessageType
) < 0) return 0;
1053 if (PyModule_AddObject(this_module
, "ErrorMessage",
1054 (PyObject
*)&ErrorMessageType
) < 0) return 0;
1056 if (PyModule_AddObject(this_module
, "SignalMessage",
1057 (PyObject
*)&SignalMessageType
) < 0) return 0;
1062 /* vim:set ft=c cino< sw=4 sts=4 et: */