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 library is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation; either version 2.1 of the License, or
11 * (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "dbus_bindings-internal.h"
25 #include "message-internal.h"
27 static PyTypeObject MessageType
, SignalMessageType
, ErrorMessageType
;
28 static PyTypeObject MethodReturnMessageType
, MethodCallMessageType
;
30 static inline int Message_Check(PyObject
*o
)
32 return (o
->ob_type
== &MessageType
)
33 || PyObject_IsInstance(o
, (PyObject
*)&MessageType
);
37 DBusPy_RaiseUnusableMessage(void)
39 DBusPyException_SetString("Message object is uninitialized, or has become "
40 "unusable due to error while appending "
45 PyDoc_STRVAR(Message_tp_doc
,
46 "A message to be sent or received over a D-Bus Connection.\n");
48 static void Message_tp_dealloc(Message
*self
)
51 dbus_message_unref(self
->msg
);
53 self
->ob_type
->tp_free((PyObject
*)self
);
57 Message_tp_new(PyTypeObject
*type
,
58 PyObject
*args UNUSED
,
59 PyObject
*kwargs UNUSED
)
63 self
= (Message
*)type
->tp_alloc(type
, 0);
64 if (!self
) return NULL
;
66 return (PyObject
*)self
;
69 PyDoc_STRVAR(MethodCallMessage_tp_doc
, "A method-call message.\n"
73 " dbus.lowlevel.MethodCallMessage(destination: str or None, path: str,\n"
74 " interface: str or None, method: str)\n"
76 "``destination`` is the destination bus name, or None to send the\n"
77 "message directly to the peer (usually the bus daemon).\n"
79 "``path`` is the object-path of the object whose method is to be called.\n"
81 "``interface`` is the interface qualifying the method name, or None to omit\n"
82 "the interface from the message header.\n"
84 "``method`` is the method name (member name).\n"
88 MethodCallMessage_tp_init(Message
*self
, PyObject
*args
, PyObject
*kwargs
)
90 const char *destination
, *path
, *interface
, *method
;
91 static char *kwlist
[] = {"destination", "path", "interface", "method", NULL
};
93 if (!PyArg_ParseTupleAndKeywords(args
, kwargs
, "zszs:__init__", kwlist
,
94 &destination
, &path
, &interface
,
98 if (destination
&& !dbus_py_validate_bus_name(destination
, 1, 1)) return -1;
99 if (!dbus_py_validate_object_path(path
)) return -1;
100 if (interface
&& !dbus_py_validate_interface_name(interface
)) return -1;
101 if (!dbus_py_validate_member_name(method
)) return -1;
103 dbus_message_unref(self
->msg
);
106 self
->msg
= dbus_message_new_method_call(destination
, path
, interface
,
115 PyDoc_STRVAR(MethodReturnMessage_tp_doc
, "A method-return message.\n\n"
117 " dbus.lowlevel.MethodReturnMessage(method_call: MethodCallMessage)\n");
120 MethodReturnMessage_tp_init(Message
*self
, PyObject
*args
, PyObject
*kwargs
)
123 static char *kwlist
[] = {"method_call", NULL
};
125 if (!PyArg_ParseTupleAndKeywords(args
, kwargs
, "O!:__init__", kwlist
,
126 &MessageType
, &other
)) {
130 dbus_message_unref(self
->msg
);
133 self
->msg
= dbus_message_new_method_return(other
->msg
);
141 PyDoc_STRVAR(SignalMessage_tp_doc
, "A signal message.\n\n"
143 " dbus.lowlevel.SignalMessage(path: str, interface: str, method: str)\n");
145 SignalMessage_tp_init(Message
*self
, PyObject
*args
, PyObject
*kwargs
)
147 const char *path
, *interface
, *name
;
148 static char *kwlist
[] = {"path", "interface", "name", NULL
};
150 if (!PyArg_ParseTupleAndKeywords(args
, kwargs
, "sss:__init__", kwlist
,
151 &path
, &interface
, &name
)) {
154 if (!dbus_py_validate_object_path(path
)) return -1;
155 if (!dbus_py_validate_interface_name(interface
)) return -1;
156 if (!dbus_py_validate_member_name(name
)) return -1;
158 dbus_message_unref(self
->msg
);
161 self
->msg
= dbus_message_new_signal(path
, interface
, name
);
169 PyDoc_STRVAR(ErrorMessage_tp_doc
, "An error message.\n\n"
171 " dbus.lowlevel.ErrorMessage(reply_to: Message, error_name: str,\n"
172 " error_message: str or None)\n");
174 ErrorMessage_tp_init(Message
*self
, PyObject
*args
, PyObject
*kwargs
)
177 const char *error_name
, *error_message
;
178 static char *kwlist
[] = {"reply_to", "error_name", "error_message", NULL
};
180 if (!PyArg_ParseTupleAndKeywords(args
, kwargs
, "O!sz:__init__", kwlist
,
181 &MessageType
, &reply_to
, &error_name
,
185 if (!dbus_py_validate_error_name(error_name
)) return -1;
187 dbus_message_unref(self
->msg
);
190 self
->msg
= dbus_message_new_error(reply_to
->msg
, error_name
, error_message
);
199 DBusPyMessage_BorrowDBusMessage(PyObject
*msg
)
201 if (!Message_Check(msg
)) {
202 PyErr_SetString(PyExc_TypeError
,
203 "A dbus.lowlevel.Message instance is required");
206 if (!((Message
*)msg
)->msg
) {
207 DBusPy_RaiseUnusableMessage();
210 return ((Message
*)msg
)->msg
;
214 DBusPyMessage_ConsumeDBusMessage(DBusMessage
*msg
)
219 switch (dbus_message_get_type(msg
)) {
220 case DBUS_MESSAGE_TYPE_METHOD_CALL
:
221 type
= &MethodCallMessageType
;
223 case DBUS_MESSAGE_TYPE_METHOD_RETURN
:
224 type
= &MethodReturnMessageType
;
226 case DBUS_MESSAGE_TYPE_ERROR
:
227 type
= &ErrorMessageType
;
229 case DBUS_MESSAGE_TYPE_SIGNAL
:
230 type
= &SignalMessageType
;
236 self
= (Message
*)(type
->tp_new
) (type
, dbus_py_empty_tuple
, NULL
);
238 dbus_message_unref(msg
);
242 return (PyObject
*)self
;
245 PyDoc_STRVAR(Message_copy__doc__
,
246 "message.copy() -> Message (or subclass)\n"
247 "Deep-copy the message, resetting the serial number to zero.\n");
249 Message_copy(Message
*self
, PyObject
*args UNUSED
)
252 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
253 msg
= dbus_message_copy(self
->msg
);
254 if (!msg
) return PyErr_NoMemory();
255 return DBusPyMessage_ConsumeDBusMessage(msg
);
258 PyDoc_STRVAR(Message_get_auto_start__doc__
,
259 "message.get_auto_start() -> bool\n"
260 "Return true if this message will cause an owner for the destination name\n"
261 "to be auto-started.\n");
263 Message_get_auto_start(Message
*self
, PyObject
*unused UNUSED
)
265 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
266 return PyBool_FromLong(dbus_message_get_auto_start(self
->msg
));
269 PyDoc_STRVAR(Message_set_auto_start__doc__
,
270 "message.set_auto_start(bool) -> None\n"
271 "Set whether this message will cause an owner for the destination name\n"
272 "to be auto-started.\n");
274 Message_set_auto_start(Message
*self
, PyObject
*args
)
277 if (!PyArg_ParseTuple(args
, "i", &value
)) return NULL
;
278 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
279 dbus_message_set_auto_start(self
->msg
, value
? TRUE
: FALSE
);
284 PyDoc_STRVAR(Message_get_no_reply__doc__
,
285 "message.get_no_reply() -> bool\n"
286 "Return true if this message need not be replied to.\n");
288 Message_get_no_reply(Message
*self
, PyObject
*unused UNUSED
)
290 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
291 return PyBool_FromLong(dbus_message_get_no_reply(self
->msg
));
294 PyDoc_STRVAR(Message_set_no_reply__doc__
,
295 "message.set_no_reply(bool) -> None\n"
296 "Set whether no reply to this message is required.\n");
298 Message_set_no_reply(Message
*self
, PyObject
*args
)
301 if (!PyArg_ParseTuple(args
, "i", &value
)) return NULL
;
302 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
303 dbus_message_set_no_reply(self
->msg
, value
? TRUE
: FALSE
);
307 PyDoc_STRVAR(Message_get_reply_serial__doc__
,
308 "message.get_reply_serial() -> long\n"
309 "Returns the serial that the message is a reply to or 0 if none.\n");
311 Message_get_reply_serial(Message
*self
, PyObject
*unused UNUSED
)
313 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
314 return PyLong_FromUnsignedLong(dbus_message_get_reply_serial(self
->msg
));
317 PyDoc_STRVAR(Message_set_reply_serial__doc__
,
318 "message.set_reply_serial(bool) -> None\n"
319 "Set the serial that this message is a reply to.\n");
321 Message_set_reply_serial(Message
*self
, PyObject
*args
)
325 if (!PyArg_ParseTuple(args
, "k", &value
)) return NULL
;
326 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
327 if (!dbus_message_set_reply_serial(self
->msg
, value
)) {
328 return PyErr_NoMemory();
334 PyDoc_STRVAR(Message_get_type__doc__
,
335 "message.get_type() -> int\n\n"
336 "Returns the type of the message.\n");
338 Message_get_type(Message
*self
, PyObject
*unused UNUSED
)
340 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
341 return PyInt_FromLong(dbus_message_get_type(self
->msg
));
344 PyDoc_STRVAR(Message_get_serial__doc__
,
345 "message.get_serial() -> long\n"
346 "Returns the serial of a message or 0 if none has been specified.\n"
348 "The message's serial number is provided by the application sending the\n"
349 "message and is used to identify replies to this message. All messages\n"
350 "received on a connection will have a serial, but messages you haven't\n"
351 "sent yet may return 0.\n");
353 Message_get_serial(Message
*self
, PyObject
*unused UNUSED
)
355 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
356 return PyLong_FromUnsignedLong(dbus_message_get_serial(self
->msg
));
359 PyDoc_STRVAR(Message_is_method_call__doc__
,
360 "is_method_call(interface: str, member: str) -> bool");
362 Message_is_method_call(Message
*self
, PyObject
*args
)
364 const char *interface
, *method
;
366 if (!PyArg_ParseTuple(args
, "ss:is_method_call", &interface
, &method
)) {
369 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
370 return PyBool_FromLong(dbus_message_is_method_call(self
->msg
, interface
,
374 PyDoc_STRVAR(Message_is_error__doc__
,
375 "is_error(error: str) -> bool");
377 Message_is_error(Message
*self
, PyObject
*args
)
379 const char *error_name
;
381 if (!PyArg_ParseTuple(args
, "s:is_error", &error_name
)) {
384 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
385 return PyBool_FromLong(dbus_message_is_error(self
->msg
, error_name
));
388 PyDoc_STRVAR(Message_is_signal__doc__
,
389 "is_signal(interface: str, member: str) -> bool");
391 Message_is_signal(Message
*self
, PyObject
*args
)
393 const char *interface
, *signal_name
;
395 if (!PyArg_ParseTuple(args
, "ss:is_signal", &interface
, &signal_name
)) {
398 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
399 return PyBool_FromLong(dbus_message_is_signal(self
->msg
, interface
,
403 PyDoc_STRVAR(Message_get_member__doc__
,
404 "get_member() -> str or None");
406 Message_get_member(Message
*self
, PyObject
*unused UNUSED
)
410 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
411 c_str
= dbus_message_get_member(self
->msg
);
415 return PyString_FromString(c_str
);
418 PyDoc_STRVAR(Message_has_member__doc__
,
419 "has_member(name: str or None) -> bool");
421 Message_has_member(Message
*self
, PyObject
*args
)
425 if (!PyArg_ParseTuple(args
, "z:has_member", &name
)) {
428 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
429 return PyBool_FromLong(dbus_message_has_member(self
->msg
, name
));
432 PyDoc_STRVAR(Message_set_member__doc__
,
433 "set_member(unique_name: str or None)");
435 Message_set_member(Message
*self
, PyObject
*args
)
439 if (!PyArg_ParseTuple(args
, "z:set_member", &name
)) {
442 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
443 if (!dbus_py_validate_member_name(name
)) return NULL
;
444 if (!dbus_message_set_member(self
->msg
, name
)) return PyErr_NoMemory();
448 PyDoc_STRVAR(Message_get_path__doc__
,
449 "get_path() -> ObjectPath or None\n\n"
450 "Return the message's destination object path (if it's a method call) or\n"
451 "source object path (if it's a method reply or a signal) or None (if it\n"
454 Message_get_path(Message
*self
, PyObject
*unused UNUSED
)
458 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
459 c_str
= dbus_message_get_path(self
->msg
);
463 return PyObject_CallFunction((PyObject
*)&DBusPyObjectPath_Type
, "(s)", c_str
);
466 PyDoc_STRVAR(Message_get_path_decomposed__doc__
,
467 "get_path_decomposed() -> list of str, or None\n\n"
468 "Return a list of path components (e.g. /foo/bar -> ['foo','bar'], / -> [])\n"
469 "or None if the message has no associated path.\n");
471 Message_get_path_decomposed(Message
*self
, PyObject
*unused UNUSED
)
474 PyObject
*ret
= PyList_New(0);
476 if (!ret
) return NULL
;
479 return DBusPy_RaiseUnusableMessage();
481 if (!dbus_message_get_path_decomposed(self
->msg
, &paths
)) {
483 return PyErr_NoMemory();
489 for (ptr
= paths
; *ptr
; ptr
++) {
490 PyObject
*str
= PyString_FromString(*ptr
);
497 if (PyList_Append(ret
, str
) < 0) {
505 dbus_free_string_array(paths
);
509 PyDoc_STRVAR(Message_has_path__doc__
,
510 "has_path(name: str or None) -> bool");
512 Message_has_path(Message
*self
, PyObject
*args
)
516 if (!PyArg_ParseTuple(args
, "z:has_path", &name
)) {
519 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
520 return PyBool_FromLong(dbus_message_has_path(self
->msg
, name
));
523 PyDoc_STRVAR(Message_set_path__doc__
,
524 "set_path(name: str or None)");
526 Message_set_path(Message
*self
, PyObject
*args
)
530 if (!PyArg_ParseTuple(args
, "z:set_path", &name
)) return NULL
;
531 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
532 if (!dbus_message_has_path(self
->msg
, name
)) return PyErr_NoMemory();
536 PyDoc_STRVAR(Message_get_signature__doc__
,
537 "get_signature() -> Signature or None");
539 Message_get_signature(Message
*self
, PyObject
*unused UNUSED
)
543 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
544 c_str
= dbus_message_get_signature(self
->msg
);
546 return PyObject_CallFunction((PyObject
*)&DBusPySignature_Type
, "(s)", "");
548 return PyObject_CallFunction((PyObject
*)&DBusPySignature_Type
, "(s)", c_str
);
551 PyDoc_STRVAR(Message_has_signature__doc__
,
552 "has_signature(signature: str) -> bool");
554 Message_has_signature(Message
*self
, PyObject
*args
)
558 if (!PyArg_ParseTuple(args
, "s:has_signature", &name
)) {
561 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
562 return PyBool_FromLong(dbus_message_has_signature(self
->msg
, name
));
565 PyDoc_STRVAR(Message_get_sender__doc__
,
566 "get_sender() -> str or None\n\n"
567 "Return the message's sender unique name, or None if none.\n");
569 Message_get_sender(Message
*self
, PyObject
*unused UNUSED
)
573 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
574 c_str
= dbus_message_get_sender(self
->msg
);
578 return PyString_FromString(c_str
);
581 PyDoc_STRVAR(Message_has_sender__doc__
,
582 "has_sender(unique_name: str) -> bool");
584 Message_has_sender(Message
*self
, PyObject
*args
)
588 if (!PyArg_ParseTuple(args
, "s:has_sender", &name
)) {
591 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
592 return PyBool_FromLong(dbus_message_has_sender(self
->msg
, name
));
595 PyDoc_STRVAR(Message_set_sender__doc__
,
596 "set_sender(unique_name: str or None)");
598 Message_set_sender(Message
*self
, PyObject
*args
)
602 if (!PyArg_ParseTuple(args
, "z:set_sender", &name
)) {
605 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
606 if (!dbus_py_validate_bus_name(name
, 1, 0)) return NULL
;
607 if (!dbus_message_set_sender(self
->msg
, name
)) return PyErr_NoMemory();
611 PyDoc_STRVAR(Message_get_destination__doc__
,
612 "get_destination() -> str or None\n\n"
613 "Return the message's destination bus name, or None if none.\n");
615 Message_get_destination(Message
*self
, PyObject
*unused UNUSED
)
619 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
620 c_str
= dbus_message_get_destination(self
->msg
);
624 return PyString_FromString(c_str
);
627 PyDoc_STRVAR(Message_has_destination__doc__
,
628 "has_destination(bus_name: str) -> bool");
630 Message_has_destination(Message
*self
, PyObject
*args
)
634 if (!PyArg_ParseTuple(args
, "s:has_destination", &name
)) {
637 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
638 return PyBool_FromLong(dbus_message_has_destination(self
->msg
, name
));
641 PyDoc_STRVAR(Message_set_destination__doc__
,
642 "set_destination(bus_name: str or None)");
644 Message_set_destination(Message
*self
, PyObject
*args
)
648 if (!PyArg_ParseTuple(args
, "z:set_destination", &name
)) {
651 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
652 if (!dbus_py_validate_bus_name(name
, 1, 1)) return NULL
;
653 if (!dbus_message_set_destination(self
->msg
, name
)) return PyErr_NoMemory();
657 PyDoc_STRVAR(Message_get_interface__doc__
,
658 "get_interface() -> str or None");
660 Message_get_interface(Message
*self
, PyObject
*unused UNUSED
)
664 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
665 c_str
= dbus_message_get_interface(self
->msg
);
669 return PyString_FromString(c_str
);
672 PyDoc_STRVAR(Message_has_interface__doc__
,
673 "has_interface(interface: str or None) -> bool");
675 Message_has_interface(Message
*self
, PyObject
*args
)
679 if (!PyArg_ParseTuple(args
, "z:has_interface", &name
)) {
682 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
683 return PyBool_FromLong(dbus_message_has_interface(self
->msg
, name
));
686 PyDoc_STRVAR(Message_set_interface__doc__
,
687 "set_interface(name: str or None)");
689 Message_set_interface(Message
*self
, PyObject
*args
)
693 if (!PyArg_ParseTuple(args
, "z:set_interface", &name
)) {
696 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
697 if (!dbus_py_validate_interface_name(name
)) return NULL
;
698 if (!dbus_message_set_interface(self
->msg
, name
)) return PyErr_NoMemory();
702 PyDoc_STRVAR(Message_get_error_name__doc__
,
703 "get_error_name() -> str or None");
705 Message_get_error_name(Message
*self
, PyObject
*unused UNUSED
)
709 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
710 c_str
= dbus_message_get_error_name(self
->msg
);
714 return PyString_FromString(c_str
);
717 PyDoc_STRVAR(Message_set_error_name__doc__
,
718 "set_error_name(name: str or None)");
720 Message_set_error_name(Message
*self
, PyObject
*args
)
724 if (!PyArg_ParseTuple(args
, "z:set_error_name", &name
)) {
727 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
728 if (!dbus_py_validate_error_name(name
)) return NULL
;
729 if (!dbus_message_set_error_name(self
->msg
, name
)) return PyErr_NoMemory();
733 static PyMethodDef Message_tp_methods
[] = {
734 {"copy", (PyCFunction
)Message_copy
,
735 METH_NOARGS
, Message_copy__doc__
},
736 {"is_method_call", (PyCFunction
)Message_is_method_call
,
737 METH_VARARGS
, Message_is_method_call__doc__
},
738 {"is_signal", (PyCFunction
)Message_is_signal
,
739 METH_VARARGS
, Message_is_signal__doc__
},
740 {"is_error", (PyCFunction
)Message_is_error
,
741 METH_VARARGS
, Message_is_error__doc__
},
743 {"get_args_list", (PyCFunction
)dbus_py_Message_get_args_list
,
744 METH_VARARGS
|METH_KEYWORDS
, dbus_py_Message_get_args_list__doc__
},
745 {"guess_signature", (PyCFunction
)dbus_py_Message_guess_signature
,
746 METH_VARARGS
|METH_STATIC
, dbus_py_Message_guess_signature__doc__
},
747 {"append", (PyCFunction
)dbus_py_Message_append
,
748 METH_VARARGS
|METH_KEYWORDS
, dbus_py_Message_append__doc__
},
750 {"get_auto_start", (PyCFunction
)Message_get_auto_start
,
751 METH_NOARGS
, Message_get_auto_start__doc__
},
752 {"set_auto_start", (PyCFunction
)Message_set_auto_start
,
753 METH_VARARGS
, Message_set_auto_start__doc__
},
754 {"get_destination", (PyCFunction
)Message_get_destination
,
755 METH_NOARGS
, Message_get_destination__doc__
},
756 {"set_destination", (PyCFunction
)Message_set_destination
,
757 METH_VARARGS
, Message_set_destination__doc__
},
758 {"has_destination", (PyCFunction
)Message_has_destination
,
759 METH_VARARGS
, Message_has_destination__doc__
},
760 {"get_error_name", (PyCFunction
)Message_get_error_name
,
761 METH_NOARGS
, Message_get_error_name__doc__
},
762 {"set_error_name", (PyCFunction
)Message_set_error_name
,
763 METH_VARARGS
, Message_set_error_name__doc__
},
764 {"get_interface", (PyCFunction
)Message_get_interface
,
765 METH_NOARGS
, Message_get_interface__doc__
},
766 {"set_interface", (PyCFunction
)Message_set_interface
,
767 METH_VARARGS
, Message_set_interface__doc__
},
768 {"has_interface", (PyCFunction
)Message_has_interface
,
769 METH_VARARGS
, Message_has_interface__doc__
},
770 {"get_member", (PyCFunction
)Message_get_member
,
771 METH_NOARGS
, Message_get_member__doc__
},
772 {"set_member", (PyCFunction
)Message_set_member
,
773 METH_VARARGS
, Message_set_member__doc__
},
774 {"has_member", (PyCFunction
)Message_has_member
,
775 METH_VARARGS
, Message_has_member__doc__
},
776 {"get_path", (PyCFunction
)Message_get_path
,
777 METH_NOARGS
, Message_get_path__doc__
},
778 {"get_path_decomposed", (PyCFunction
)Message_get_path_decomposed
,
779 METH_NOARGS
, Message_get_path_decomposed__doc__
},
780 {"set_path", (PyCFunction
)Message_set_path
,
781 METH_VARARGS
, Message_set_path__doc__
},
782 {"has_path", (PyCFunction
)Message_has_path
,
783 METH_VARARGS
, Message_has_path__doc__
},
784 {"get_no_reply", (PyCFunction
)Message_get_no_reply
,
785 METH_NOARGS
, Message_get_no_reply__doc__
},
786 {"set_no_reply", (PyCFunction
)Message_set_no_reply
,
787 METH_VARARGS
, Message_set_no_reply__doc__
},
788 {"get_reply_serial", (PyCFunction
)Message_get_reply_serial
,
789 METH_NOARGS
, Message_get_reply_serial__doc__
},
790 {"set_reply_serial", (PyCFunction
)Message_set_reply_serial
,
791 METH_VARARGS
, Message_set_reply_serial__doc__
},
792 {"get_sender", (PyCFunction
)Message_get_sender
,
793 METH_NOARGS
, Message_get_sender__doc__
},
794 {"set_sender", (PyCFunction
)Message_set_sender
,
795 METH_VARARGS
, Message_set_sender__doc__
},
796 {"has_sender", (PyCFunction
)Message_has_sender
,
797 METH_VARARGS
, Message_has_sender__doc__
},
798 {"get_serial", (PyCFunction
)Message_get_serial
,
799 METH_NOARGS
, Message_get_serial__doc__
},
800 {"get_signature", (PyCFunction
)Message_get_signature
,
801 METH_NOARGS
, Message_get_signature__doc__
},
802 {"has_signature", (PyCFunction
)Message_has_signature
,
803 METH_VARARGS
, Message_has_signature__doc__
},
804 {"get_type", (PyCFunction
)Message_get_type
,
805 METH_NOARGS
, Message_get_type__doc__
},
806 {NULL
, NULL
, 0, NULL
}
809 static PyTypeObject MessageType
= {
810 PyObject_HEAD_INIT(NULL
)
812 "dbus.lowlevel.Message", /*tp_name*/
813 sizeof(Message
), /*tp_basicsize*/
815 (destructor
)Message_tp_dealloc
, /*tp_dealloc*/
822 0, /*tp_as_sequence*/
830 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
, /*tp_flags*/
831 Message_tp_doc
, /* tp_doc */
834 0, /* tp_richcompare */
835 0, /* tp_weaklistoffset */
838 Message_tp_methods
, /* tp_methods */
843 0, /* tp_descr_get */
844 0, /* tp_descr_set */
845 0, /* tp_dictoffset */
848 Message_tp_new
, /* tp_new */
851 static PyTypeObject MethodCallMessageType
= {
852 PyObject_HEAD_INIT(NULL
)
854 "dbus.lowlevel.MethodCallMessage", /*tp_name*/
864 0, /*tp_as_sequence*/
872 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
, /*tp_flags*/
873 MethodCallMessage_tp_doc
, /* tp_doc */
876 0, /* tp_richcompare */
877 0, /* tp_weaklistoffset */
883 DEFERRED_ADDRESS(&MessageType
), /* tp_base */
885 0, /* tp_descr_get */
886 0, /* tp_descr_set */
887 0, /* tp_dictoffset */
888 (initproc
)MethodCallMessage_tp_init
, /* tp_init */
893 static PyTypeObject MethodReturnMessageType
= {
894 PyObject_HEAD_INIT(NULL
)
896 "dbus.lowlevel.MethodReturnMessage", /*tp_name*/
906 0, /*tp_as_sequence*/
914 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
, /*tp_flags*/
915 MethodReturnMessage_tp_doc
, /* tp_doc */
918 0, /* tp_richcompare */
919 0, /* tp_weaklistoffset */
925 DEFERRED_ADDRESS(&MessageType
), /* tp_base */
927 0, /* tp_descr_get */
928 0, /* tp_descr_set */
929 0, /* tp_dictoffset */
930 (initproc
)MethodReturnMessage_tp_init
, /* tp_init */
935 static PyTypeObject SignalMessageType
= {
936 PyObject_HEAD_INIT(NULL
)
938 "dbus.lowlevel.SignalMessage", /*tp_name*/
948 0, /*tp_as_sequence*/
956 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
, /*tp_flags*/
957 SignalMessage_tp_doc
, /* tp_doc */
960 0, /* tp_richcompare */
961 0, /* tp_weaklistoffset */
967 DEFERRED_ADDRESS(&MessageType
), /* tp_base */
969 0, /* tp_descr_get */
970 0, /* tp_descr_set */
971 0, /* tp_dictoffset */
972 (initproc
)SignalMessage_tp_init
, /* tp_init */
977 static PyTypeObject ErrorMessageType
= {
978 PyObject_HEAD_INIT(NULL
)
980 "dbus.lowlevel.ErrorMessage", /*tp_name*/
990 0, /*tp_as_sequence*/
998 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
, /*tp_flags*/
999 ErrorMessage_tp_doc
, /* tp_doc */
1000 0, /* tp_traverse */
1002 0, /* tp_richcompare */
1003 0, /* tp_weaklistoffset */
1005 0, /* tp_iternext */
1009 DEFERRED_ADDRESS(&MessageType
), /* tp_base */
1011 0, /* tp_descr_get */
1012 0, /* tp_descr_set */
1013 0, /* tp_dictoffset */
1014 (initproc
)ErrorMessage_tp_init
, /* tp_init */
1020 dbus_py_init_message_types(void)
1022 if (PyType_Ready(&MessageType
) < 0) return 0;
1024 MethodCallMessageType
.tp_base
= &MessageType
;
1025 if (PyType_Ready(&MethodCallMessageType
) < 0) return 0;
1027 MethodReturnMessageType
.tp_base
= &MessageType
;
1028 if (PyType_Ready(&MethodReturnMessageType
) < 0) return 0;
1030 SignalMessageType
.tp_base
= &MessageType
;
1031 if (PyType_Ready(&SignalMessageType
) < 0) return 0;
1033 ErrorMessageType
.tp_base
= &MessageType
;
1034 if (PyType_Ready(&ErrorMessageType
) < 0) return 0;
1040 dbus_py_insert_message_types(PyObject
*this_module
)
1042 if (PyModule_AddObject(this_module
, "Message",
1043 (PyObject
*)&MessageType
) < 0) return 0;
1045 if (PyModule_AddObject(this_module
, "MethodCallMessage",
1046 (PyObject
*)&MethodCallMessageType
) < 0) return 0;
1048 if (PyModule_AddObject(this_module
, "MethodReturnMessage",
1049 (PyObject
*)&MethodReturnMessageType
) < 0) return 0;
1051 if (PyModule_AddObject(this_module
, "ErrorMessage",
1052 (PyObject
*)&ErrorMessageType
) < 0) return 0;
1054 if (PyModule_AddObject(this_module
, "SignalMessage",
1055 (PyObject
*)&SignalMessageType
) < 0) return 0;
1060 /* vim:set ft=c cino< sw=4 sts=4 et: */