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\n"
72 "MethodCallMessage(destination: str or None, path: str,\n"
73 " interface: str or None, method: str)\n");
75 MethodCallMessage_tp_init(Message
*self
, PyObject
*args
, PyObject
*kwargs
)
77 const char *destination
, *path
, *interface
, *method
;
78 static char *kwlist
[] = {"destination", "path", "interface", "method", NULL
};
80 if (!PyArg_ParseTupleAndKeywords(args
, kwargs
, "zszs:__init__", kwlist
,
81 &destination
, &path
, &interface
,
85 if (destination
&& !dbus_py_validate_bus_name(destination
, 1, 1)) return -1;
86 if (!dbus_py_validate_object_path(path
)) return -1;
87 if (interface
&& !dbus_py_validate_interface_name(interface
)) return -1;
88 if (!dbus_py_validate_member_name(method
)) return -1;
90 dbus_message_unref(self
->msg
);
93 self
->msg
= dbus_message_new_method_call(destination
, path
, interface
,
102 PyDoc_STRVAR(MethodReturnMessage_tp_doc
, "A method-return message.\n\n"
103 "MethodReturnMessage(method_call: MethodCallMessage)\n");
105 MethodReturnMessage_tp_init(Message
*self
, PyObject
*args
, PyObject
*kwargs
)
108 static char *kwlist
[] = {"method_call", NULL
};
110 if (!PyArg_ParseTupleAndKeywords(args
, kwargs
, "O!:__init__", kwlist
,
111 &MessageType
, &other
)) {
115 dbus_message_unref(self
->msg
);
118 self
->msg
= dbus_message_new_method_return(other
->msg
);
126 PyDoc_STRVAR(SignalMessage_tp_doc
, "A signal message.\n\n"
127 "SignalMessage(path: str, interface: str, method: str)\n");
129 SignalMessage_tp_init(Message
*self
, PyObject
*args
, PyObject
*kwargs
)
131 const char *path
, *interface
, *name
;
132 static char *kwlist
[] = {"path", "interface", "name", NULL
};
134 if (!PyArg_ParseTupleAndKeywords(args
, kwargs
, "sss:__init__", kwlist
,
135 &path
, &interface
, &name
)) {
138 if (!dbus_py_validate_object_path(path
)) return -1;
139 if (!dbus_py_validate_interface_name(interface
)) return -1;
140 if (!dbus_py_validate_member_name(name
)) return -1;
142 dbus_message_unref(self
->msg
);
145 self
->msg
= dbus_message_new_signal(path
, interface
, name
);
153 PyDoc_STRVAR(ErrorMessage_tp_doc
, "An error message.\n\n"
154 "ErrorMessage(reply_to: Message, error_name: str,\n"
155 " error_message: str or None)\n");
157 ErrorMessage_tp_init(Message
*self
, PyObject
*args
, PyObject
*kwargs
)
160 const char *error_name
, *error_message
;
161 static char *kwlist
[] = {"reply_to", "error_name", "error_message", NULL
};
163 if (!PyArg_ParseTupleAndKeywords(args
, kwargs
, "O!sz:__init__", kwlist
,
164 &MessageType
, &reply_to
, &error_name
,
168 if (!dbus_py_validate_error_name(error_name
)) return -1;
170 dbus_message_unref(self
->msg
);
173 self
->msg
= dbus_message_new_error(reply_to
->msg
, error_name
, error_message
);
182 DBusPyMessage_BorrowDBusMessage(PyObject
*msg
)
184 if (!Message_Check(msg
)) {
185 PyErr_SetString(PyExc_TypeError
,
186 "A _dbus_bindings.Message instance is required");
189 if (!((Message
*)msg
)->msg
) {
190 DBusPy_RaiseUnusableMessage();
193 return ((Message
*)msg
)->msg
;
197 DBusPyMessage_ConsumeDBusMessage(DBusMessage
*msg
)
202 switch (dbus_message_get_type(msg
)) {
203 case DBUS_MESSAGE_TYPE_METHOD_CALL
:
204 type
= &MethodCallMessageType
;
206 case DBUS_MESSAGE_TYPE_METHOD_RETURN
:
207 type
= &MethodReturnMessageType
;
209 case DBUS_MESSAGE_TYPE_ERROR
:
210 type
= &ErrorMessageType
;
212 case DBUS_MESSAGE_TYPE_SIGNAL
:
213 type
= &SignalMessageType
;
219 self
= (Message
*)(type
->tp_new
) (type
, dbus_py_empty_tuple
, NULL
);
221 dbus_message_unref(msg
);
225 return (PyObject
*)self
;
228 PyDoc_STRVAR(Message_copy__doc__
,
229 "message.copy() -> Message (or subclass)\n"
230 "Deep-copy the message, resetting the serial number to zero.\n");
232 Message_copy(Message
*self
, PyObject
*args UNUSED
)
235 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
236 msg
= dbus_message_copy(self
->msg
);
237 if (!msg
) return PyErr_NoMemory();
238 return DBusPyMessage_ConsumeDBusMessage(msg
);
241 PyDoc_STRVAR(Message_get_auto_start__doc__
,
242 "message.get_auto_start() -> bool\n"
243 "Return true if this message will cause an owner for the destination name\n"
244 "to be auto-started.\n");
246 Message_get_auto_start(Message
*self
, PyObject
*unused UNUSED
)
248 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
249 return PyBool_FromLong(dbus_message_get_auto_start(self
->msg
));
252 PyDoc_STRVAR(Message_set_auto_start__doc__
,
253 "message.set_auto_start(bool) -> None\n"
254 "Set whether this message will cause an owner for the destination name\n"
255 "to be auto-started.\n");
257 Message_set_auto_start(Message
*self
, PyObject
*args
)
260 if (!PyArg_ParseTuple(args
, "i", &value
)) return NULL
;
261 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
262 dbus_message_set_auto_start(self
->msg
, value
? TRUE
: FALSE
);
267 PyDoc_STRVAR(Message_get_no_reply__doc__
,
268 "message.get_no_reply() -> bool\n"
269 "Return true if this message need not be replied to.\n");
271 Message_get_no_reply(Message
*self
, PyObject
*unused UNUSED
)
273 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
274 return PyBool_FromLong(dbus_message_get_no_reply(self
->msg
));
277 PyDoc_STRVAR(Message_set_no_reply__doc__
,
278 "message.set_no_reply(bool) -> None\n"
279 "Set whether no reply to this message is required.\n");
281 Message_set_no_reply(Message
*self
, PyObject
*args
)
284 if (!PyArg_ParseTuple(args
, "i", &value
)) return NULL
;
285 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
286 dbus_message_set_no_reply(self
->msg
, value
? TRUE
: FALSE
);
290 PyDoc_STRVAR(Message_get_reply_serial__doc__
,
291 "message.get_reply_serial() -> long\n"
292 "Returns the serial that the message is a reply to or 0 if none.\n");
294 Message_get_reply_serial(Message
*self
, PyObject
*unused UNUSED
)
296 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
297 return PyLong_FromUnsignedLong(dbus_message_get_reply_serial(self
->msg
));
300 PyDoc_STRVAR(Message_set_reply_serial__doc__
,
301 "message.set_reply_serial(bool) -> None\n"
302 "Set the serial that this message is a reply to.\n");
304 Message_set_reply_serial(Message
*self
, PyObject
*args
)
308 if (!PyArg_ParseTuple(args
, "k", &value
)) return NULL
;
309 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
310 if (!dbus_message_set_reply_serial(self
->msg
, value
)) {
311 return PyErr_NoMemory();
317 PyDoc_STRVAR(Message_get_type__doc__
,
318 "message.get_type() -> int\n\n"
319 "Returns the type of the message.\n");
321 Message_get_type(Message
*self
, PyObject
*unused UNUSED
)
323 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
324 return PyInt_FromLong(dbus_message_get_type(self
->msg
));
327 PyDoc_STRVAR(Message_get_serial__doc__
,
328 "message.get_serial() -> long\n"
329 "Returns the serial of a message or 0 if none has been specified.\n"
331 "The message's serial number is provided by the application sending the\n"
332 "message and is used to identify replies to this message. All messages\n"
333 "received on a connection will have a serial, but messages you haven't\n"
334 "sent yet may return 0.\n");
336 Message_get_serial(Message
*self
, PyObject
*unused UNUSED
)
338 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
339 return PyLong_FromUnsignedLong(dbus_message_get_serial(self
->msg
));
342 PyDoc_STRVAR(Message_is_method_call__doc__
,
343 "is_method_call(interface: str, member: str) -> bool");
345 Message_is_method_call(Message
*self
, PyObject
*args
)
347 const char *interface
, *method
;
349 if (!PyArg_ParseTuple(args
, "ss:is_method_call", &interface
, &method
)) {
352 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
353 return PyBool_FromLong(dbus_message_is_method_call(self
->msg
, interface
,
357 PyDoc_STRVAR(Message_is_error__doc__
,
358 "is_error(error: str) -> bool");
360 Message_is_error(Message
*self
, PyObject
*args
)
362 const char *error_name
;
364 if (!PyArg_ParseTuple(args
, "s:is_error", &error_name
)) {
367 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
368 return PyBool_FromLong(dbus_message_is_error(self
->msg
, error_name
));
371 PyDoc_STRVAR(Message_is_signal__doc__
,
372 "is_signal(interface: str, member: str) -> bool");
374 Message_is_signal(Message
*self
, PyObject
*args
)
376 const char *interface
, *signal_name
;
378 if (!PyArg_ParseTuple(args
, "ss:is_signal", &interface
, &signal_name
)) {
381 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
382 return PyBool_FromLong(dbus_message_is_signal(self
->msg
, interface
,
386 PyDoc_STRVAR(Message_get_member__doc__
,
387 "get_member() -> str or None");
389 Message_get_member(Message
*self
, PyObject
*unused UNUSED
)
393 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
394 c_str
= dbus_message_get_member(self
->msg
);
398 return PyString_FromString(c_str
);
401 PyDoc_STRVAR(Message_has_member__doc__
,
402 "has_member(name: str or None) -> bool");
404 Message_has_member(Message
*self
, PyObject
*args
)
408 if (!PyArg_ParseTuple(args
, "z:has_member", &name
)) {
411 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
412 return PyBool_FromLong(dbus_message_has_member(self
->msg
, name
));
415 PyDoc_STRVAR(Message_set_member__doc__
,
416 "set_member(unique_name: str or None)");
418 Message_set_member(Message
*self
, PyObject
*args
)
422 if (!PyArg_ParseTuple(args
, "z:set_member", &name
)) {
425 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
426 if (!dbus_py_validate_member_name(name
)) return NULL
;
427 if (!dbus_message_set_member(self
->msg
, name
)) return PyErr_NoMemory();
431 PyDoc_STRVAR(Message_get_path__doc__
,
432 "get_path() -> ObjectPath or None\n\n"
433 "Return the message's destination object path (if it's a method call) or\n"
434 "source object path (if it's a method reply or a signal) or None (if it\n"
437 Message_get_path(Message
*self
, PyObject
*unused UNUSED
)
441 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
442 c_str
= dbus_message_get_path(self
->msg
);
446 return PyObject_CallFunction((PyObject
*)&DBusPyObjectPath_Type
, "(s)", c_str
);
449 PyDoc_STRVAR(Message_get_path_decomposed__doc__
,
450 "get_path_decomposed() -> list of str, or None\n\n"
451 "Return a list of path components (e.g. /foo/bar -> ['foo','bar'], / -> [])\n"
452 "or None if the message has no associated path.\n");
454 Message_get_path_decomposed(Message
*self
, PyObject
*unused UNUSED
)
457 PyObject
*ret
= PyList_New(0);
459 if (!ret
) return NULL
;
462 return DBusPy_RaiseUnusableMessage();
464 if (!dbus_message_get_path_decomposed(self
->msg
, &paths
)) {
466 return PyErr_NoMemory();
472 for (ptr
= paths
; *ptr
; ptr
++) {
473 PyObject
*str
= PyString_FromString(*ptr
);
480 if (PyList_Append(ret
, str
) < 0) {
488 dbus_free_string_array(paths
);
492 PyDoc_STRVAR(Message_has_path__doc__
,
493 "has_path(name: str or None) -> bool");
495 Message_has_path(Message
*self
, PyObject
*args
)
499 if (!PyArg_ParseTuple(args
, "z:has_path", &name
)) {
502 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
503 return PyBool_FromLong(dbus_message_has_path(self
->msg
, name
));
506 PyDoc_STRVAR(Message_set_path__doc__
,
507 "set_path(name: str or None)");
509 Message_set_path(Message
*self
, PyObject
*args
)
513 if (!PyArg_ParseTuple(args
, "z:set_path", &name
)) return NULL
;
514 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
515 if (!dbus_message_has_path(self
->msg
, name
)) return PyErr_NoMemory();
519 PyDoc_STRVAR(Message_get_signature__doc__
,
520 "get_signature() -> Signature or None");
522 Message_get_signature(Message
*self
, PyObject
*unused UNUSED
)
526 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
527 c_str
= dbus_message_get_signature(self
->msg
);
529 return PyObject_CallFunction((PyObject
*)&DBusPySignature_Type
, "(s)", "");
531 return PyObject_CallFunction((PyObject
*)&DBusPySignature_Type
, "(s)", c_str
);
534 PyDoc_STRVAR(Message_has_signature__doc__
,
535 "has_signature(signature: str) -> bool");
537 Message_has_signature(Message
*self
, PyObject
*args
)
541 if (!PyArg_ParseTuple(args
, "s:has_signature", &name
)) {
544 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
545 return PyBool_FromLong(dbus_message_has_signature(self
->msg
, name
));
548 PyDoc_STRVAR(Message_get_sender__doc__
,
549 "get_sender() -> str or None\n\n"
550 "Return the message's sender unique name, or None if none.\n");
552 Message_get_sender(Message
*self
, PyObject
*unused UNUSED
)
556 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
557 c_str
= dbus_message_get_sender(self
->msg
);
561 return PyString_FromString(c_str
);
564 PyDoc_STRVAR(Message_has_sender__doc__
,
565 "has_sender(unique_name: str) -> bool");
567 Message_has_sender(Message
*self
, PyObject
*args
)
571 if (!PyArg_ParseTuple(args
, "s:has_sender", &name
)) {
574 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
575 return PyBool_FromLong(dbus_message_has_sender(self
->msg
, name
));
578 PyDoc_STRVAR(Message_set_sender__doc__
,
579 "set_sender(unique_name: str or None)");
581 Message_set_sender(Message
*self
, PyObject
*args
)
585 if (!PyArg_ParseTuple(args
, "z:set_sender", &name
)) {
588 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
589 if (!dbus_py_validate_bus_name(name
, 1, 0)) return NULL
;
590 if (!dbus_message_set_sender(self
->msg
, name
)) return PyErr_NoMemory();
594 PyDoc_STRVAR(Message_get_destination__doc__
,
595 "get_destination() -> str or None\n\n"
596 "Return the message's destination bus name, or None if none.\n");
598 Message_get_destination(Message
*self
, PyObject
*unused UNUSED
)
602 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
603 c_str
= dbus_message_get_destination(self
->msg
);
607 return PyString_FromString(c_str
);
610 PyDoc_STRVAR(Message_has_destination__doc__
,
611 "has_destination(bus_name: str) -> bool");
613 Message_has_destination(Message
*self
, PyObject
*args
)
617 if (!PyArg_ParseTuple(args
, "s:has_destination", &name
)) {
620 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
621 return PyBool_FromLong(dbus_message_has_destination(self
->msg
, name
));
624 PyDoc_STRVAR(Message_set_destination__doc__
,
625 "set_destination(bus_name: str or None)");
627 Message_set_destination(Message
*self
, PyObject
*args
)
631 if (!PyArg_ParseTuple(args
, "z:set_destination", &name
)) {
634 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
635 if (!dbus_py_validate_bus_name(name
, 1, 1)) return NULL
;
636 if (!dbus_message_set_destination(self
->msg
, name
)) return PyErr_NoMemory();
640 PyDoc_STRVAR(Message_get_interface__doc__
,
641 "get_interface() -> str or None");
643 Message_get_interface(Message
*self
, PyObject
*unused UNUSED
)
647 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
648 c_str
= dbus_message_get_interface(self
->msg
);
652 return PyString_FromString(c_str
);
655 PyDoc_STRVAR(Message_has_interface__doc__
,
656 "has_interface(interface: str or None) -> bool");
658 Message_has_interface(Message
*self
, PyObject
*args
)
662 if (!PyArg_ParseTuple(args
, "z:has_interface", &name
)) {
665 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
666 return PyBool_FromLong(dbus_message_has_interface(self
->msg
, name
));
669 PyDoc_STRVAR(Message_set_interface__doc__
,
670 "set_interface(name: str or None)");
672 Message_set_interface(Message
*self
, PyObject
*args
)
676 if (!PyArg_ParseTuple(args
, "z:set_interface", &name
)) {
679 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
680 if (!dbus_py_validate_interface_name(name
)) return NULL
;
681 if (!dbus_message_set_interface(self
->msg
, name
)) return PyErr_NoMemory();
685 PyDoc_STRVAR(Message_get_error_name__doc__
,
686 "get_error_name() -> str or None");
688 Message_get_error_name(Message
*self
, PyObject
*unused UNUSED
)
692 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
693 c_str
= dbus_message_get_error_name(self
->msg
);
697 return PyString_FromString(c_str
);
700 PyDoc_STRVAR(Message_set_error_name__doc__
,
701 "set_error_name(name: str or None)");
703 Message_set_error_name(Message
*self
, PyObject
*args
)
707 if (!PyArg_ParseTuple(args
, "z:set_error_name", &name
)) {
710 if (!self
->msg
) return DBusPy_RaiseUnusableMessage();
711 if (!dbus_py_validate_error_name(name
)) return NULL
;
712 if (!dbus_message_set_error_name(self
->msg
, name
)) return PyErr_NoMemory();
716 static PyMethodDef Message_tp_methods
[] = {
717 {"copy", (PyCFunction
)Message_copy
,
718 METH_NOARGS
, Message_copy__doc__
},
719 {"is_method_call", (PyCFunction
)Message_is_method_call
,
720 METH_VARARGS
, Message_is_method_call__doc__
},
721 {"is_signal", (PyCFunction
)Message_is_signal
,
722 METH_VARARGS
, Message_is_signal__doc__
},
723 {"is_error", (PyCFunction
)Message_is_error
,
724 METH_VARARGS
, Message_is_error__doc__
},
726 {"get_args_list", (PyCFunction
)dbus_py_Message_get_args_list
,
727 METH_VARARGS
|METH_KEYWORDS
, dbus_py_Message_get_args_list__doc__
},
728 {"guess_signature", (PyCFunction
)dbus_py_Message_guess_signature
,
729 METH_VARARGS
|METH_STATIC
, dbus_py_Message_guess_signature__doc__
},
730 {"append", (PyCFunction
)dbus_py_Message_append
,
731 METH_VARARGS
|METH_KEYWORDS
, dbus_py_Message_append__doc__
},
733 {"get_auto_start", (PyCFunction
)Message_get_auto_start
,
734 METH_NOARGS
, Message_get_auto_start__doc__
},
735 {"set_auto_start", (PyCFunction
)Message_set_auto_start
,
736 METH_VARARGS
, Message_set_auto_start__doc__
},
737 {"get_destination", (PyCFunction
)Message_get_destination
,
738 METH_NOARGS
, Message_get_destination__doc__
},
739 {"set_destination", (PyCFunction
)Message_set_destination
,
740 METH_VARARGS
, Message_set_destination__doc__
},
741 {"has_destination", (PyCFunction
)Message_has_destination
,
742 METH_VARARGS
, Message_has_destination__doc__
},
743 {"get_error_name", (PyCFunction
)Message_get_error_name
,
744 METH_NOARGS
, Message_get_error_name__doc__
},
745 {"set_error_name", (PyCFunction
)Message_set_error_name
,
746 METH_VARARGS
, Message_set_error_name__doc__
},
747 {"get_interface", (PyCFunction
)Message_get_interface
,
748 METH_NOARGS
, Message_get_interface__doc__
},
749 {"set_interface", (PyCFunction
)Message_set_interface
,
750 METH_VARARGS
, Message_set_interface__doc__
},
751 {"has_interface", (PyCFunction
)Message_has_interface
,
752 METH_VARARGS
, Message_has_interface__doc__
},
753 {"get_member", (PyCFunction
)Message_get_member
,
754 METH_NOARGS
, Message_get_member__doc__
},
755 {"set_member", (PyCFunction
)Message_set_member
,
756 METH_VARARGS
, Message_set_member__doc__
},
757 {"has_member", (PyCFunction
)Message_has_member
,
758 METH_VARARGS
, Message_has_member__doc__
},
759 {"get_path", (PyCFunction
)Message_get_path
,
760 METH_NOARGS
, Message_get_path__doc__
},
761 {"get_path_decomposed", (PyCFunction
)Message_get_path_decomposed
,
762 METH_NOARGS
, Message_get_path_decomposed__doc__
},
763 {"set_path", (PyCFunction
)Message_set_path
,
764 METH_VARARGS
, Message_set_path__doc__
},
765 {"has_path", (PyCFunction
)Message_has_path
,
766 METH_VARARGS
, Message_has_path__doc__
},
767 {"get_no_reply", (PyCFunction
)Message_get_no_reply
,
768 METH_NOARGS
, Message_get_no_reply__doc__
},
769 {"set_no_reply", (PyCFunction
)Message_set_no_reply
,
770 METH_VARARGS
, Message_set_no_reply__doc__
},
771 {"get_reply_serial", (PyCFunction
)Message_get_reply_serial
,
772 METH_NOARGS
, Message_get_reply_serial__doc__
},
773 {"set_reply_serial", (PyCFunction
)Message_set_reply_serial
,
774 METH_VARARGS
, Message_set_reply_serial__doc__
},
775 {"get_sender", (PyCFunction
)Message_get_sender
,
776 METH_NOARGS
, Message_get_sender__doc__
},
777 {"set_sender", (PyCFunction
)Message_set_sender
,
778 METH_VARARGS
, Message_set_sender__doc__
},
779 {"has_sender", (PyCFunction
)Message_has_sender
,
780 METH_VARARGS
, Message_has_sender__doc__
},
781 {"get_serial", (PyCFunction
)Message_get_serial
,
782 METH_NOARGS
, Message_get_serial__doc__
},
783 {"get_signature", (PyCFunction
)Message_get_signature
,
784 METH_NOARGS
, Message_get_signature__doc__
},
785 {"has_signature", (PyCFunction
)Message_has_signature
,
786 METH_VARARGS
, Message_has_signature__doc__
},
787 {"get_type", (PyCFunction
)Message_get_type
,
788 METH_NOARGS
, Message_get_type__doc__
},
789 {NULL
, NULL
, 0, NULL
}
792 static PyTypeObject MessageType
= {
793 PyObject_HEAD_INIT(NULL
)
795 "dbus.lowlevel.Message", /*tp_name*/
796 sizeof(Message
), /*tp_basicsize*/
798 (destructor
)Message_tp_dealloc
, /*tp_dealloc*/
805 0, /*tp_as_sequence*/
813 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
, /*tp_flags*/
814 Message_tp_doc
, /* tp_doc */
817 0, /* tp_richcompare */
818 0, /* tp_weaklistoffset */
821 Message_tp_methods
, /* tp_methods */
826 0, /* tp_descr_get */
827 0, /* tp_descr_set */
828 0, /* tp_dictoffset */
831 Message_tp_new
, /* tp_new */
834 static PyTypeObject MethodCallMessageType
= {
835 PyObject_HEAD_INIT(NULL
)
837 "dbus.lowlevel.MethodCallMessage", /*tp_name*/
847 0, /*tp_as_sequence*/
855 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
, /*tp_flags*/
856 MethodCallMessage_tp_doc
, /* tp_doc */
859 0, /* tp_richcompare */
860 0, /* tp_weaklistoffset */
866 DEFERRED_ADDRESS(&MessageType
), /* tp_base */
868 0, /* tp_descr_get */
869 0, /* tp_descr_set */
870 0, /* tp_dictoffset */
871 (initproc
)MethodCallMessage_tp_init
, /* tp_init */
876 static PyTypeObject MethodReturnMessageType
= {
877 PyObject_HEAD_INIT(NULL
)
879 "dbus.lowlevel.MethodReturnMessage", /*tp_name*/
889 0, /*tp_as_sequence*/
897 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
, /*tp_flags*/
898 MethodReturnMessage_tp_doc
, /* tp_doc */
901 0, /* tp_richcompare */
902 0, /* tp_weaklistoffset */
908 DEFERRED_ADDRESS(&MessageType
), /* tp_base */
910 0, /* tp_descr_get */
911 0, /* tp_descr_set */
912 0, /* tp_dictoffset */
913 (initproc
)MethodReturnMessage_tp_init
, /* tp_init */
918 static PyTypeObject SignalMessageType
= {
919 PyObject_HEAD_INIT(NULL
)
921 "dbus.lowlevel.SignalMessage", /*tp_name*/
931 0, /*tp_as_sequence*/
939 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
, /*tp_flags*/
940 SignalMessage_tp_doc
, /* tp_doc */
943 0, /* tp_richcompare */
944 0, /* tp_weaklistoffset */
950 DEFERRED_ADDRESS(&MessageType
), /* tp_base */
952 0, /* tp_descr_get */
953 0, /* tp_descr_set */
954 0, /* tp_dictoffset */
955 (initproc
)SignalMessage_tp_init
, /* tp_init */
960 static PyTypeObject ErrorMessageType
= {
961 PyObject_HEAD_INIT(NULL
)
963 "dbus.lowlevel.ErrorMessage", /*tp_name*/
973 0, /*tp_as_sequence*/
981 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
, /*tp_flags*/
982 ErrorMessage_tp_doc
, /* tp_doc */
985 0, /* tp_richcompare */
986 0, /* tp_weaklistoffset */
992 DEFERRED_ADDRESS(&MessageType
), /* tp_base */
994 0, /* tp_descr_get */
995 0, /* tp_descr_set */
996 0, /* tp_dictoffset */
997 (initproc
)ErrorMessage_tp_init
, /* tp_init */
1003 dbus_py_init_message_types(void)
1005 if (PyType_Ready(&MessageType
) < 0) return 0;
1007 MethodCallMessageType
.tp_base
= &MessageType
;
1008 if (PyType_Ready(&MethodCallMessageType
) < 0) return 0;
1010 MethodReturnMessageType
.tp_base
= &MessageType
;
1011 if (PyType_Ready(&MethodReturnMessageType
) < 0) return 0;
1013 SignalMessageType
.tp_base
= &MessageType
;
1014 if (PyType_Ready(&SignalMessageType
) < 0) return 0;
1016 ErrorMessageType
.tp_base
= &MessageType
;
1017 if (PyType_Ready(&ErrorMessageType
) < 0) return 0;
1023 dbus_py_insert_message_types(PyObject
*this_module
)
1025 if (PyModule_AddObject(this_module
, "Message",
1026 (PyObject
*)&MessageType
) < 0) return 0;
1028 if (PyModule_AddObject(this_module
, "MethodCallMessage",
1029 (PyObject
*)&MethodCallMessageType
) < 0) return 0;
1031 if (PyModule_AddObject(this_module
, "MethodReturnMessage",
1032 (PyObject
*)&MethodReturnMessageType
) < 0) return 0;
1034 if (PyModule_AddObject(this_module
, "ErrorMessage",
1035 (PyObject
*)&ErrorMessageType
) < 0) return 0;
1037 if (PyModule_AddObject(this_module
, "SignalMessage",
1038 (PyObject
*)&SignalMessageType
) < 0) return 0;
1043 /* vim:set ft=c cino< sw=4 sts=4 et: */