1 /* Implementation of D-Bus Message and subclasses (but see message-get-args.h
2 * and message-append.h for unserialization and serialization code).
4 * Copyright (C) 2006 Collabora Ltd.
6 * Licensed under the Academic Free License version 2.1
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 static void _dbg_dump_message(DBusMessage
*message
)
30 fprintf(stderr
, "DBusMessage at %p\n", message
);
32 s
= dbus_message_get_destination(message
);
34 fprintf(stderr
, "\tdestination %s\n", s
);
36 s
= dbus_message_get_interface(message
);
38 fprintf(stderr
, "\tinterface %s\n", s
);
40 s
= dbus_message_get_member(message
);
42 fprintf(stderr
, "\tmember %s\n", s
);
44 s
= dbus_message_get_path(message
);
46 fprintf(stderr
, "\tpath %s\n", s
);
48 # define DBG_DUMP_MESSAGE(x) _dbg_dump_message(x)
50 # define DBG_DUMP_MESSAGE(x) do {} while(0)
53 static PyTypeObject MessageType
, SignalMessageType
, ErrorMessageType
;
54 static PyTypeObject MethodReturnMessageType
, MethodCallMessageType
;
56 static inline int Message_Check (PyObject
*o
)
58 return (o
->ob_type
== &MessageType
)
59 || PyObject_IsInstance(o
, (PyObject
*)&MessageType
);
67 PyDoc_STRVAR(Message_tp_doc
,
68 "A message to be sent or received over a D-Bus Connection.\n");
70 static void Message_tp_dealloc (Message
*self
)
73 dbus_message_unref (self
->msg
);
75 self
->ob_type
->tp_free ((PyObject
*)self
);
79 Message_tp_new (PyTypeObject
*type
, PyObject
*args
, PyObject
*kwargs
)
83 self
= (Message
*)type
->tp_alloc (type
, 0);
84 if (!self
) return NULL
;
86 return (PyObject
*)self
;
89 PyDoc_STRVAR(MethodCallMessage_tp_doc
, "A method-call message.\n\n"
90 "MethodCallMessage(destination: str or None, path: str,\n"
91 " interface: str or None, method: str)\n");
93 MethodCallMessage_tp_init (Message
*self
, PyObject
*args
, PyObject
*kwargs
)
95 const char *destination
, *path
, *interface
, *method
;
96 static char *kwlist
[] = {"destination", "path", "interface", "method", NULL
};
98 if (!PyArg_ParseTupleAndKeywords (args
, kwargs
, "zszs:__init__", kwlist
,
99 &destination
, &path
, &interface
,
103 if (destination
&& !_validate_bus_name(destination
, 1, 1)) return -1;
104 if (!_validate_object_path(path
)) return -1;
105 if (interface
&& !_validate_interface_name(interface
)) return -1;
106 if (!_validate_member_name(method
)) return -1;
108 dbus_message_unref (self
->msg
);
111 self
->msg
= dbus_message_new_method_call (destination
, path
, interface
,
120 PyDoc_STRVAR(MethodReturnMessage_tp_doc
, "A method-return message.\n\n"
121 "MethodReturnMessage(method_call: MethodCallMessage)\n");
123 MethodReturnMessage_tp_init (Message
*self
, PyObject
*args
, PyObject
*kwargs
)
126 static char *kwlist
[] = {"method_call", NULL
};
128 if (!PyArg_ParseTupleAndKeywords (args
, kwargs
, "O!:__init__", kwlist
,
129 &MessageType
, &other
)) {
133 dbus_message_unref (self
->msg
);
136 self
->msg
= dbus_message_new_method_return (other
->msg
);
144 PyDoc_STRVAR(SignalMessage_tp_doc
, "A signal message.\n\n"
145 "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 (!_validate_object_path(path
)) return -1;
157 if (!_validate_interface_name(interface
)) return -1;
158 if (!_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"
172 "ErrorMessage(reply_to: Message, error_name: str,\n"
173 " error_message: str or None)\n");
175 ErrorMessage_tp_init (Message
*self
, PyObject
*args
, PyObject
*kwargs
)
178 const char *error_name
, *error_message
;
179 static char *kwlist
[] = {"reply_to", "error_name", "error_message", NULL
};
181 if (!PyArg_ParseTupleAndKeywords (args
, kwargs
, "O!sz:__init__", kwlist
,
182 &MessageType
, &reply_to
, &error_name
,
186 if (!_validate_error_name(error_name
)) return -1;
188 dbus_message_unref (self
->msg
);
191 self
->msg
= dbus_message_new_error (reply_to
->msg
, error_name
, error_message
);
200 Message_BorrowDBusMessage (PyObject
*msg
)
202 if (!Message_Check (msg
)) {
203 PyErr_SetString (PyExc_TypeError
,
204 "A _dbus_bindings.Message instance is required");
207 if (!((Message
*)msg
)->msg
) {
208 DBusException_UnusableMessage();
211 return ((Message
*)msg
)->msg
;
215 Message_ConsumeDBusMessage (DBusMessage
*msg
)
220 switch (dbus_message_get_type (msg
)) {
221 case DBUS_MESSAGE_TYPE_METHOD_CALL
:
222 type
= &MethodCallMessageType
;
224 case DBUS_MESSAGE_TYPE_METHOD_RETURN
:
225 type
= &MethodReturnMessageType
;
227 case DBUS_MESSAGE_TYPE_ERROR
:
228 type
= &ErrorMessageType
;
230 case DBUS_MESSAGE_TYPE_SIGNAL
:
231 type
= &SignalMessageType
;
237 self
= (Message
*)(type
->tp_new
) (type
, empty_tuple
, NULL
);
239 dbus_message_unref(msg
);
243 return (PyObject
*)self
;
246 PyDoc_STRVAR(Message_copy__doc__
,
247 "message.copy() -> Message (or subclass)\n"
248 "Deep-copy the message, resetting the serial number to zero.\n");
250 Message_copy (Message
*self
, PyObject
*args
)
253 if (!self
->msg
) return DBusException_UnusableMessage();
254 msg
= dbus_message_copy(self
->msg
);
255 if (!msg
) return PyErr_NoMemory();
256 return Message_ConsumeDBusMessage(msg
);
259 PyDoc_STRVAR(Message_get_auto_start__doc__
,
260 "message.get_auto_start() -> bool\n"
261 "Return true if this message will cause an owner for the destination name\n"
262 "to be auto-started.\n");
264 Message_get_auto_start (Message
*self
, PyObject
*unused
)
266 if (!self
->msg
) return DBusException_UnusableMessage();
267 return PyBool_FromLong (dbus_message_get_auto_start (self
->msg
));
270 PyDoc_STRVAR(Message_set_auto_start__doc__
,
271 "message.set_auto_start(bool) -> None\n"
272 "Set whether this message will cause an owner for the destination name\n"
273 "to be auto-started.\n");
275 Message_set_auto_start (Message
*self
, PyObject
*args
)
278 if (!PyArg_ParseTuple (args
, "i", &value
)) return NULL
;
279 if (!self
->msg
) return DBusException_UnusableMessage();
280 dbus_message_set_auto_start (self
->msg
, value
? TRUE
: FALSE
);
285 PyDoc_STRVAR(Message_get_no_reply__doc__
,
286 "message.get_no_reply() -> bool\n"
287 "Return true if this message need not be replied to.\n");
289 Message_get_no_reply (Message
*self
, PyObject
*unused
)
291 if (!self
->msg
) return DBusException_UnusableMessage();
292 return PyBool_FromLong (dbus_message_get_no_reply (self
->msg
));
295 PyDoc_STRVAR(Message_set_no_reply__doc__
,
296 "message.set_no_reply(bool) -> None\n"
297 "Set whether no reply to this message is required.\n");
299 Message_set_no_reply (Message
*self
, PyObject
*args
)
302 if (!PyArg_ParseTuple (args
, "i", &value
)) return NULL
;
303 if (!self
->msg
) return DBusException_UnusableMessage();
304 dbus_message_set_no_reply (self
->msg
, value
? TRUE
: FALSE
);
308 PyDoc_STRVAR(Message_get_reply_serial__doc__
,
309 "message.get_reply_serial() -> long\n"
310 "Returns the serial that the message is a reply to or 0 if none.\n");
312 Message_get_reply_serial (Message
*self
, PyObject
*unused
)
314 if (!self
->msg
) return DBusException_UnusableMessage();
315 return PyLong_FromUnsignedLong (dbus_message_get_reply_serial (self
->msg
));
318 PyDoc_STRVAR(Message_set_reply_serial__doc__
,
319 "message.set_reply_serial(bool) -> None\n"
320 "Set the serial that this message is a reply to.\n");
322 Message_set_reply_serial (Message
*self
, PyObject
*args
)
326 if (!PyArg_ParseTuple (args
, "k", &value
)) return NULL
;
327 if (!self
->msg
) return DBusException_UnusableMessage();
328 if (!dbus_message_set_reply_serial (self
->msg
, value
)) {
329 return PyErr_NoMemory();
335 PyDoc_STRVAR(Message_get_type__doc__
,
336 "message.get_type() -> int\n\n"
337 "Returns the type of the message.\n");
339 Message_get_type (Message
*self
, PyObject
*unused
)
341 if (!self
->msg
) return DBusException_UnusableMessage();
342 return PyInt_FromLong (dbus_message_get_type (self
->msg
));
345 PyDoc_STRVAR(Message_get_serial__doc__
,
346 "message.get_serial() -> long\n"
347 "Returns the serial of a message or 0 if none has been specified.\n"
349 "The message's serial number is provided by the application sending the\n"
350 "message and is used to identify replies to this message. All messages\n"
351 "received on a connection will have a serial, but messages you haven't\n"
352 "sent yet may return 0.\n");
354 Message_get_serial (Message
*self
, PyObject
*unused
)
356 if (!self
->msg
) return DBusException_UnusableMessage();
357 return PyLong_FromUnsignedLong (dbus_message_get_serial (self
->msg
));
360 PyDoc_STRVAR(Message_is_method_call__doc__
,
361 "is_method_call(interface: str, member: str) -> bool");
363 Message_is_method_call (Message
*self
, PyObject
*args
)
365 const char *interface
, *method
;
367 if (!PyArg_ParseTuple(args
, "ss:is_method_call", &interface
, &method
)) {
370 if (!self
->msg
) return DBusException_UnusableMessage();
371 return PyBool_FromLong (dbus_message_is_method_call (self
->msg
, interface
,
375 PyDoc_STRVAR(Message_is_error__doc__
,
376 "is_error(error: str) -> bool");
378 Message_is_error (Message
*self
, PyObject
*args
)
380 const char *error_name
;
382 if (!PyArg_ParseTuple(args
, "s:is_error", &error_name
)) {
385 if (!self
->msg
) return DBusException_UnusableMessage();
386 return PyBool_FromLong (dbus_message_is_error (self
->msg
, error_name
));
389 PyDoc_STRVAR(Message_is_signal__doc__
,
390 "is_signal(interface: str, member: str) -> bool");
392 Message_is_signal (Message
*self
, PyObject
*args
)
394 const char *interface
, *signal_name
;
396 if (!PyArg_ParseTuple(args
, "ss:is_signal", &interface
, &signal_name
)) {
399 if (!self
->msg
) return DBusException_UnusableMessage();
400 return PyBool_FromLong (dbus_message_is_signal (self
->msg
, interface
,
404 PyDoc_STRVAR(Message_get_member__doc__
,
405 "get_member() -> str or None");
407 Message_get_member (Message
*self
, PyObject
*unused
)
411 if (!self
->msg
) return DBusException_UnusableMessage();
412 c_str
= dbus_message_get_member (self
->msg
);
416 return PyString_FromString(c_str
);
419 PyDoc_STRVAR(Message_has_member__doc__
,
420 "has_member(name: str or None) -> bool");
422 Message_has_member (Message
*self
, PyObject
*args
)
426 if (!PyArg_ParseTuple(args
, "z:has_member", &name
)) {
429 if (!self
->msg
) return DBusException_UnusableMessage();
430 return PyBool_FromLong (dbus_message_has_member(self
->msg
, name
));
433 PyDoc_STRVAR(Message_set_member__doc__
,
434 "set_member(unique_name: str or None)");
436 Message_set_member (Message
*self
, PyObject
*args
)
440 if (!PyArg_ParseTuple(args
, "z:set_member", &name
)) {
443 if (!self
->msg
) return DBusException_UnusableMessage();
444 if (!_validate_member_name(name
)) return NULL
;
445 if (!dbus_message_set_member (self
->msg
, name
)) return PyErr_NoMemory();
449 PyDoc_STRVAR(Message_get_path__doc__
,
450 "get_path() -> ObjectPath or None\n\n"
451 "Return the message's destination object path (if it's a method call) or\n"
452 "source object path (if it's a method reply or a signal) or None (if it\n"
455 Message_get_path (Message
*self
, PyObject
*unused
)
459 if (!self
->msg
) return DBusException_UnusableMessage();
460 c_str
= dbus_message_get_path (self
->msg
);
464 return PyObject_CallFunction((PyObject
*)&ObjectPathType
, "(s)", c_str
);
467 PyDoc_STRVAR(Message_get_path_decomposed__doc__
,
468 "get_path_decomposed() -> list of str, or None\n\n"
469 "Return a list of path components (e.g. /foo/bar -> ['foo','bar'], / -> [])\n"
470 "or None if the message has no associated path.\n");
472 Message_get_path_decomposed (Message
*self
, PyObject
*unused
)
475 PyObject
*ret
= PyList_New(0);
477 if (!ret
) return NULL
;
480 return DBusException_UnusableMessage ();
482 if (!dbus_message_get_path_decomposed (self
->msg
, &paths
)) {
484 return PyErr_NoMemory ();
490 for (ptr
= paths
; *ptr
; ptr
++) {
491 PyObject
*str
= PyString_FromString (*ptr
);
498 if (PyList_Append (ret
, str
) < 0) {
506 dbus_free_string_array (paths
);
510 PyDoc_STRVAR(Message_has_path__doc__
,
511 "has_path(name: str or None) -> bool");
513 Message_has_path (Message
*self
, PyObject
*args
)
517 if (!PyArg_ParseTuple(args
, "z:has_path", &name
)) {
520 if (!self
->msg
) return DBusException_UnusableMessage();
521 return PyBool_FromLong (dbus_message_has_path(self
->msg
, name
));
524 PyDoc_STRVAR(Message_set_path__doc__
,
525 "set_path(name: str or None)");
527 Message_set_path (Message
*self
, PyObject
*args
)
531 if (!PyArg_ParseTuple(args
, "z:set_path", &name
)) return NULL
;
532 if (!self
->msg
) return DBusException_UnusableMessage();
533 if (!dbus_message_has_path(self
->msg
, name
)) return PyErr_NoMemory();
537 PyDoc_STRVAR(Message_get_signature__doc__
,
538 "get_signature() -> Signature or None");
540 Message_get_signature (Message
*self
, PyObject
*unused
)
544 if (!self
->msg
) return DBusException_UnusableMessage();
545 c_str
= dbus_message_get_signature (self
->msg
);
547 return PyObject_CallFunction((PyObject
*)&SignatureType
, "(s)", "");
549 return PyObject_CallFunction((PyObject
*)&SignatureType
, "(s)", c_str
);
552 PyDoc_STRVAR(Message_has_signature__doc__
,
553 "has_signature(signature: str) -> bool");
555 Message_has_signature (Message
*self
, PyObject
*args
)
559 if (!PyArg_ParseTuple(args
, "s:has_signature", &name
)) {
562 if (!self
->msg
) return DBusException_UnusableMessage();
563 return PyBool_FromLong (dbus_message_has_signature (self
->msg
, name
));
566 PyDoc_STRVAR(Message_get_sender__doc__
,
567 "get_sender() -> str or None\n\n"
568 "Return the message's sender unique name, or None if none.\n");
570 Message_get_sender (Message
*self
, PyObject
*unused
)
574 if (!self
->msg
) return DBusException_UnusableMessage();
575 c_str
= dbus_message_get_sender (self
->msg
);
579 return PyString_FromString(c_str
);
582 PyDoc_STRVAR(Message_has_sender__doc__
,
583 "has_sender(unique_name: str) -> bool");
585 Message_has_sender (Message
*self
, PyObject
*args
)
589 if (!PyArg_ParseTuple(args
, "s:has_sender", &name
)) {
592 if (!self
->msg
) return DBusException_UnusableMessage();
593 return PyBool_FromLong (dbus_message_has_sender (self
->msg
, name
));
596 PyDoc_STRVAR(Message_set_sender__doc__
,
597 "set_sender(unique_name: str or None)");
599 Message_set_sender (Message
*self
, PyObject
*args
)
603 if (!PyArg_ParseTuple(args
, "z:set_sender", &name
)) {
606 if (!self
->msg
) return DBusException_UnusableMessage();
607 if (!_validate_bus_name(name
, 1, 0)) return NULL
;
608 if (!dbus_message_set_sender (self
->msg
, name
)) return PyErr_NoMemory();
612 PyDoc_STRVAR(Message_get_destination__doc__
,
613 "get_destination() -> str or None\n\n"
614 "Return the message's destination bus name, or None if none.\n");
616 Message_get_destination(Message
*self
, PyObject
*unused
)
620 if (!self
->msg
) return DBusException_UnusableMessage();
621 c_str
= dbus_message_get_destination(self
->msg
);
625 return PyString_FromString(c_str
);
628 PyDoc_STRVAR(Message_has_destination__doc__
,
629 "has_destination(bus_name: str) -> bool");
631 Message_has_destination (Message
*self
, PyObject
*args
)
635 if (!PyArg_ParseTuple(args
, "s:has_destination", &name
)) {
638 if (!self
->msg
) return DBusException_UnusableMessage();
639 return PyBool_FromLong (dbus_message_has_destination (self
->msg
, name
));
642 PyDoc_STRVAR(Message_set_destination__doc__
,
643 "set_destination(bus_name: str or None)");
645 Message_set_destination (Message
*self
, PyObject
*args
)
649 if (!PyArg_ParseTuple(args
, "z:set_destination", &name
)) {
652 if (!self
->msg
) return DBusException_UnusableMessage();
653 if (!_validate_bus_name(name
, 1, 1)) return NULL
;
654 if (!dbus_message_set_destination (self
->msg
, name
)) return PyErr_NoMemory();
658 PyDoc_STRVAR(Message_get_interface__doc__
,
659 "get_interface() -> str or None");
661 Message_get_interface (Message
*self
, PyObject
*unused
)
665 if (!self
->msg
) return DBusException_UnusableMessage();
666 c_str
= dbus_message_get_interface (self
->msg
);
670 return PyString_FromString(c_str
);
673 PyDoc_STRVAR(Message_has_interface__doc__
,
674 "has_interface(interface: str or None) -> bool");
676 Message_has_interface(Message
*self
, PyObject
*args
)
680 if (!PyArg_ParseTuple(args
, "z:has_interface", &name
)) {
683 if (!self
->msg
) return DBusException_UnusableMessage();
684 return PyBool_FromLong(dbus_message_has_interface (self
->msg
, name
));
687 PyDoc_STRVAR(Message_set_interface__doc__
,
688 "set_interface(name: str or None)");
690 Message_set_interface (Message
*self
, PyObject
*args
)
694 if (!PyArg_ParseTuple(args
, "z:set_interface", &name
)) {
697 if (!self
->msg
) return DBusException_UnusableMessage();
698 if (!_validate_interface_name(name
)) return NULL
;
699 if (!dbus_message_set_interface (self
->msg
, name
)) return PyErr_NoMemory();
703 PyDoc_STRVAR(Message_get_error_name__doc__
,
704 "get_error_name() -> str or None");
706 Message_get_error_name (Message
*self
, PyObject
*unused
)
710 if (!self
->msg
) return DBusException_UnusableMessage();
711 c_str
= dbus_message_get_error_name (self
->msg
);
715 return PyString_FromString(c_str
);
718 PyDoc_STRVAR(Message_set_error_name__doc__
,
719 "set_error_name(name: str or None)");
721 Message_set_error_name(Message
*self
, PyObject
*args
)
725 if (!PyArg_ParseTuple(args
, "z:set_error_name", &name
)) {
728 if (!self
->msg
) return DBusException_UnusableMessage();
729 if (!_validate_error_name(name
)) return NULL
;
730 if (!dbus_message_set_error_name(self
->msg
, name
)) return PyErr_NoMemory();
734 #include "message-append-impl.h"
735 #include "message-get-args-impl.h"
737 static PyMethodDef Message_tp_methods
[] = {
738 {"copy", (PyCFunction
)Message_copy
,
739 METH_NOARGS
, Message_copy__doc__
},
740 {"is_method_call", (PyCFunction
)Message_is_method_call
,
741 METH_VARARGS
, Message_is_method_call__doc__
},
742 {"is_signal", (PyCFunction
)Message_is_signal
,
743 METH_VARARGS
, Message_is_signal__doc__
},
744 {"is_error", (PyCFunction
)Message_is_error
,
745 METH_VARARGS
, Message_is_error__doc__
},
747 {"get_args_list", (PyCFunction
)Message_get_args_list
,
748 METH_VARARGS
|METH_KEYWORDS
, Message_get_args_list__doc__
},
749 {"guess_signature", (PyCFunction
)Message_guess_signature
,
750 METH_VARARGS
|METH_STATIC
, Message_guess_signature__doc__
},
751 {"append", (PyCFunction
)Message_append
,
752 METH_VARARGS
|METH_KEYWORDS
, Message_append__doc__
},
754 {"get_auto_start", (PyCFunction
)Message_get_auto_start
,
755 METH_NOARGS
, Message_get_auto_start__doc__
},
756 {"set_auto_start", (PyCFunction
)Message_set_auto_start
,
757 METH_VARARGS
, Message_set_auto_start__doc__
},
758 {"get_destination", (PyCFunction
)Message_get_destination
,
759 METH_NOARGS
, Message_get_destination__doc__
},
760 {"set_destination", (PyCFunction
)Message_set_destination
,
761 METH_VARARGS
, Message_set_destination__doc__
},
762 {"has_destination", (PyCFunction
)Message_has_destination
,
763 METH_VARARGS
, Message_has_destination__doc__
},
764 {"get_error_name", (PyCFunction
)Message_get_error_name
,
765 METH_NOARGS
, Message_get_error_name__doc__
},
766 {"set_error_name", (PyCFunction
)Message_set_error_name
,
767 METH_VARARGS
, Message_set_error_name__doc__
},
768 {"get_interface", (PyCFunction
)Message_get_interface
,
769 METH_NOARGS
, Message_get_interface__doc__
},
770 {"set_interface", (PyCFunction
)Message_set_interface
,
771 METH_VARARGS
, Message_set_interface__doc__
},
772 {"has_interface", (PyCFunction
)Message_has_interface
,
773 METH_VARARGS
, Message_has_interface__doc__
},
774 {"get_member", (PyCFunction
)Message_get_member
,
775 METH_NOARGS
, Message_get_member__doc__
},
776 {"set_member", (PyCFunction
)Message_set_member
,
777 METH_VARARGS
, Message_set_member__doc__
},
778 {"has_member", (PyCFunction
)Message_has_member
,
779 METH_VARARGS
, Message_has_member__doc__
},
780 {"get_path", (PyCFunction
)Message_get_path
,
781 METH_NOARGS
, Message_get_path__doc__
},
782 {"get_path_decomposed", (PyCFunction
)Message_get_path_decomposed
,
783 METH_NOARGS
, Message_get_path_decomposed__doc__
},
784 {"set_path", (PyCFunction
)Message_set_path
,
785 METH_VARARGS
, Message_set_path__doc__
},
786 {"has_path", (PyCFunction
)Message_has_path
,
787 METH_VARARGS
, Message_has_path__doc__
},
788 {"get_no_reply", (PyCFunction
)Message_get_no_reply
,
789 METH_NOARGS
, Message_get_no_reply__doc__
},
790 {"set_no_reply", (PyCFunction
)Message_set_no_reply
,
791 METH_VARARGS
, Message_set_no_reply__doc__
},
792 {"get_reply_serial", (PyCFunction
)Message_get_reply_serial
,
793 METH_NOARGS
, Message_get_reply_serial__doc__
},
794 {"set_reply_serial", (PyCFunction
)Message_set_reply_serial
,
795 METH_VARARGS
, Message_set_reply_serial__doc__
},
796 {"get_sender", (PyCFunction
)Message_get_sender
,
797 METH_NOARGS
, Message_get_sender__doc__
},
798 {"set_sender", (PyCFunction
)Message_set_sender
,
799 METH_VARARGS
, Message_set_sender__doc__
},
800 {"has_sender", (PyCFunction
)Message_has_sender
,
801 METH_VARARGS
, Message_has_sender__doc__
},
802 {"get_serial", (PyCFunction
)Message_get_serial
,
803 METH_NOARGS
, Message_get_serial__doc__
},
804 {"get_signature", (PyCFunction
)Message_get_signature
,
805 METH_NOARGS
, Message_get_signature__doc__
},
806 {"has_signature", (PyCFunction
)Message_has_signature
,
807 METH_VARARGS
, Message_has_signature__doc__
},
808 {"get_type", (PyCFunction
)Message_get_type
,
809 METH_NOARGS
, Message_get_type__doc__
},
810 {NULL
, NULL
, 0, NULL
}
813 static PyTypeObject MessageType
= {
814 PyObject_HEAD_INIT(NULL
)
816 "_dbus_bindings.Message", /*tp_name*/
817 sizeof(Message
), /*tp_basicsize*/
819 (destructor
)Message_tp_dealloc
, /*tp_dealloc*/
826 0, /*tp_as_sequence*/
834 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
, /*tp_flags*/
835 Message_tp_doc
, /* tp_doc */
838 0, /* tp_richcompare */
839 0, /* tp_weaklistoffset */
842 Message_tp_methods
, /* tp_methods */
847 0, /* tp_descr_get */
848 0, /* tp_descr_set */
849 0, /* tp_dictoffset */
852 Message_tp_new
, /* tp_new */
855 static PyTypeObject MethodCallMessageType
= {
856 PyObject_HEAD_INIT(NULL
)
858 "_dbus_bindings.MethodCallMessage", /*tp_name*/
868 0, /*tp_as_sequence*/
876 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
, /*tp_flags*/
877 MethodCallMessage_tp_doc
, /* tp_doc */
880 0, /* tp_richcompare */
881 0, /* tp_weaklistoffset */
887 DEFERRED_ADDRESS(&MessageType
), /* tp_base */
889 0, /* tp_descr_get */
890 0, /* tp_descr_set */
891 0, /* tp_dictoffset */
892 (initproc
)MethodCallMessage_tp_init
, /* tp_init */
897 static PyTypeObject MethodReturnMessageType
= {
898 PyObject_HEAD_INIT(NULL
)
900 "_dbus_bindings.MethodReturnMessage", /*tp_name*/
910 0, /*tp_as_sequence*/
918 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
, /*tp_flags*/
919 MethodReturnMessage_tp_doc
, /* tp_doc */
922 0, /* tp_richcompare */
923 0, /* tp_weaklistoffset */
929 DEFERRED_ADDRESS(&MessageType
), /* tp_base */
931 0, /* tp_descr_get */
932 0, /* tp_descr_set */
933 0, /* tp_dictoffset */
934 (initproc
)MethodReturnMessage_tp_init
, /* tp_init */
939 static PyTypeObject SignalMessageType
= {
940 PyObject_HEAD_INIT(NULL
)
942 "_dbus_bindings.SignalMessage", /*tp_name*/
952 0, /*tp_as_sequence*/
960 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
, /*tp_flags*/
961 SignalMessage_tp_doc
, /* tp_doc */
964 0, /* tp_richcompare */
965 0, /* tp_weaklistoffset */
971 DEFERRED_ADDRESS(&MessageType
), /* tp_base */
973 0, /* tp_descr_get */
974 0, /* tp_descr_set */
975 0, /* tp_dictoffset */
976 (initproc
)SignalMessage_tp_init
, /* tp_init */
981 static PyTypeObject ErrorMessageType
= {
982 PyObject_HEAD_INIT(NULL
)
984 "_dbus_bindings.ErrorMessage", /*tp_name*/
994 0, /*tp_as_sequence*/
1002 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
, /*tp_flags*/
1003 ErrorMessage_tp_doc
, /* tp_doc */
1004 0, /* tp_traverse */
1006 0, /* tp_richcompare */
1007 0, /* tp_weaklistoffset */
1009 0, /* tp_iternext */
1013 DEFERRED_ADDRESS(&MessageType
), /* tp_base */
1015 0, /* tp_descr_get */
1016 0, /* tp_descr_set */
1017 0, /* tp_dictoffset */
1018 (initproc
)ErrorMessage_tp_init
, /* tp_init */
1024 init_message_types(void)
1026 if (PyType_Ready(&MessageType
) < 0) return 0;
1028 MethodCallMessageType
.tp_base
= &MessageType
;
1029 if (PyType_Ready(&MethodCallMessageType
) < 0) return 0;
1031 MethodReturnMessageType
.tp_base
= &MessageType
;
1032 if (PyType_Ready(&MethodReturnMessageType
) < 0) return 0;
1034 SignalMessageType
.tp_base
= &MessageType
;
1035 if (PyType_Ready(&SignalMessageType
) < 0) return 0;
1037 ErrorMessageType
.tp_base
= &MessageType
;
1038 if (PyType_Ready(&ErrorMessageType
) < 0) return 0;
1044 insert_message_types(PyObject
*this_module
)
1046 if (PyModule_AddObject(this_module
, "Message",
1047 (PyObject
*)&MessageType
) < 0) return 0;
1049 if (PyModule_AddObject(this_module
, "MethodCallMessage",
1050 (PyObject
*)&MethodCallMessageType
) < 0) return 0;
1052 if (PyModule_AddObject(this_module
, "MethodReturnMessage",
1053 (PyObject
*)&MethodReturnMessageType
) < 0) return 0;
1055 if (PyModule_AddObject(this_module
, "ErrorMessage",
1056 (PyObject
*)&ErrorMessageType
) < 0) return 0;
1058 if (PyModule_AddObject(this_module
, "SignalMessage",
1059 (PyObject
*)&SignalMessageType
) < 0) return 0;
1064 /* vim:set ft=c cino< sw=4 sts=4 et: */