File: | build/temp.linux-x86_64-3.8/../../dbus_bindings/message.c |
Warning: | line 544, column 25 PyObject ownership leak with reference count of 1 |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* Implementation of D-Bus Message and subclasses (but see message-get-args.h | |||
2 | * and message-append.h for unserialization and serialization code). | |||
3 | * | |||
4 | * Copyright (C) 2006 Collabora Ltd. <http://www.collabora.co.uk/> | |||
5 | * | |||
6 | * SPDX-License-Identifier: MIT | |||
7 | * | |||
8 | * Permission is hereby granted, free of charge, to any person | |||
9 | * obtaining a copy of this software and associated documentation | |||
10 | * files (the "Software"), to deal in the Software without | |||
11 | * restriction, including without limitation the rights to use, copy, | |||
12 | * modify, merge, publish, distribute, sublicense, and/or sell copies | |||
13 | * of the Software, and to permit persons to whom the Software is | |||
14 | * furnished to do so, subject to the following conditions: | |||
15 | * | |||
16 | * The above copyright notice and this permission notice shall be | |||
17 | * included in all copies or substantial portions of the Software. | |||
18 | * | |||
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |||
20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |||
21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |||
22 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | |||
23 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | |||
24 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |||
25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |||
26 | * DEALINGS IN THE SOFTWARE. | |||
27 | */ | |||
28 | ||||
29 | #include "dbus_bindings-internal.h" | |||
30 | #include "message-internal.h" | |||
31 | ||||
32 | static PyTypeObject MessageType, SignalMessageType, ErrorMessageType; | |||
33 | static PyTypeObject MethodReturnMessageType, MethodCallMessageType; | |||
34 | ||||
35 | static inline int Message_Check(PyObject *o) | |||
36 | { | |||
37 | return (Py_TYPE(o)(((PyObject*)(o))->ob_type) == &MessageType) | |||
38 | || PyObject_IsInstance(o, (PyObject *)&MessageType); | |||
39 | } | |||
40 | ||||
41 | PyObject * | |||
42 | DBusPy_RaiseUnusableMessage(void) | |||
43 | { | |||
44 | DBusPyException_SetString("Message object is uninitialized, or has become " | |||
45 | "unusable due to error while appending " | |||
46 | "arguments"); | |||
47 | return NULL((void*)0); | |||
48 | } | |||
49 | ||||
50 | PyDoc_STRVAR(Message_tp_doc,static const char Message_tp_doc[] = "A message to be sent or received over a D-Bus Connection.\n" | |||
51 | "A message to be sent or received over a D-Bus Connection.\n")static const char Message_tp_doc[] = "A message to be sent or received over a D-Bus Connection.\n"; | |||
52 | ||||
53 | static void Message_tp_dealloc(Message *self) | |||
54 | { | |||
55 | if (self->msg) { | |||
56 | dbus_message_unref(self->msg); | |||
57 | } | |||
58 | Py_TYPE(self)(((PyObject*)(self))->ob_type)->tp_free((PyObject *)self); | |||
59 | } | |||
60 | ||||
61 | static PyObject * | |||
62 | Message_tp_new(PyTypeObject *type, | |||
63 | PyObject *args UNUSED__attribute__((__unused__)), | |||
64 | PyObject *kwargs UNUSED__attribute__((__unused__))) | |||
65 | { | |||
66 | Message *self; | |||
67 | ||||
68 | self = (Message *)type->tp_alloc(type, 0); | |||
69 | if (!self) return NULL((void*)0); | |||
70 | self->msg = NULL((void*)0); | |||
71 | return (PyObject *)self; | |||
72 | } | |||
73 | ||||
74 | static PyObject * | |||
75 | MethodCallMessage_tp_repr(PyObject *self) | |||
76 | { | |||
77 | DBusMessage *msg = ((Message *)self)->msg; | |||
78 | const char *destination = dbus_message_get_destination(msg); | |||
79 | const char *path = dbus_message_get_path(msg); | |||
80 | const char *interface = dbus_message_get_interface(msg); | |||
81 | const char *member = dbus_message_get_member(msg); | |||
82 | ||||
83 | if (!path) | |||
84 | path = "n/a"; | |||
85 | if (!interface) | |||
86 | interface = "n/a"; | |||
87 | if (!member) | |||
88 | member = "n/a"; | |||
89 | if (!destination) | |||
90 | destination = "n/a"; | |||
91 | ||||
92 | return PyUnicode_FromFormat( | |||
93 | "<%s path: %s, iface: %s, member: %s dest: %s>", | |||
94 | Py_TYPE(self)(((PyObject*)(self))->ob_type)->tp_name, | |||
95 | path, interface, member, destination); | |||
96 | } | |||
97 | ||||
98 | PyDoc_STRVAR(MethodCallMessage_tp_doc,static const char MethodCallMessage_tp_doc[] = "dbus.lowlevel.MethodCallMessage(destination: str or None, path: str, " "interface: str or None, method: str)\n""\n""A method-call message.\n" "\n""``destination`` is the destination bus name, or None to send the\n" "message directly to the peer (usually the bus daemon).\n""\n" "``path`` is the object-path of the object whose method is to be called.\n" "\n""``interface`` is the interface qualifying the method name, or None to omit\n" "the interface from the message header.\n""\n""``method`` is the method name (member name).\n" | |||
99 | "dbus.lowlevel.MethodCallMessage(destination: str or None, path: str, "static const char MethodCallMessage_tp_doc[] = "dbus.lowlevel.MethodCallMessage(destination: str or None, path: str, " "interface: str or None, method: str)\n""\n""A method-call message.\n" "\n""``destination`` is the destination bus name, or None to send the\n" "message directly to the peer (usually the bus daemon).\n""\n" "``path`` is the object-path of the object whose method is to be called.\n" "\n""``interface`` is the interface qualifying the method name, or None to omit\n" "the interface from the message header.\n""\n""``method`` is the method name (member name).\n" | |||
100 | "interface: str or None, method: str)\n"static const char MethodCallMessage_tp_doc[] = "dbus.lowlevel.MethodCallMessage(destination: str or None, path: str, " "interface: str or None, method: str)\n""\n""A method-call message.\n" "\n""``destination`` is the destination bus name, or None to send the\n" "message directly to the peer (usually the bus daemon).\n""\n" "``path`` is the object-path of the object whose method is to be called.\n" "\n""``interface`` is the interface qualifying the method name, or None to omit\n" "the interface from the message header.\n""\n""``method`` is the method name (member name).\n" | |||
101 | "\n"static const char MethodCallMessage_tp_doc[] = "dbus.lowlevel.MethodCallMessage(destination: str or None, path: str, " "interface: str or None, method: str)\n""\n""A method-call message.\n" "\n""``destination`` is the destination bus name, or None to send the\n" "message directly to the peer (usually the bus daemon).\n""\n" "``path`` is the object-path of the object whose method is to be called.\n" "\n""``interface`` is the interface qualifying the method name, or None to omit\n" "the interface from the message header.\n""\n""``method`` is the method name (member name).\n" | |||
102 | "A method-call message.\n"static const char MethodCallMessage_tp_doc[] = "dbus.lowlevel.MethodCallMessage(destination: str or None, path: str, " "interface: str or None, method: str)\n""\n""A method-call message.\n" "\n""``destination`` is the destination bus name, or None to send the\n" "message directly to the peer (usually the bus daemon).\n""\n" "``path`` is the object-path of the object whose method is to be called.\n" "\n""``interface`` is the interface qualifying the method name, or None to omit\n" "the interface from the message header.\n""\n""``method`` is the method name (member name).\n" | |||
103 | "\n"static const char MethodCallMessage_tp_doc[] = "dbus.lowlevel.MethodCallMessage(destination: str or None, path: str, " "interface: str or None, method: str)\n""\n""A method-call message.\n" "\n""``destination`` is the destination bus name, or None to send the\n" "message directly to the peer (usually the bus daemon).\n""\n" "``path`` is the object-path of the object whose method is to be called.\n" "\n""``interface`` is the interface qualifying the method name, or None to omit\n" "the interface from the message header.\n""\n""``method`` is the method name (member name).\n" | |||
104 | "``destination`` is the destination bus name, or None to send the\n"static const char MethodCallMessage_tp_doc[] = "dbus.lowlevel.MethodCallMessage(destination: str or None, path: str, " "interface: str or None, method: str)\n""\n""A method-call message.\n" "\n""``destination`` is the destination bus name, or None to send the\n" "message directly to the peer (usually the bus daemon).\n""\n" "``path`` is the object-path of the object whose method is to be called.\n" "\n""``interface`` is the interface qualifying the method name, or None to omit\n" "the interface from the message header.\n""\n""``method`` is the method name (member name).\n" | |||
105 | "message directly to the peer (usually the bus daemon).\n"static const char MethodCallMessage_tp_doc[] = "dbus.lowlevel.MethodCallMessage(destination: str or None, path: str, " "interface: str or None, method: str)\n""\n""A method-call message.\n" "\n""``destination`` is the destination bus name, or None to send the\n" "message directly to the peer (usually the bus daemon).\n""\n" "``path`` is the object-path of the object whose method is to be called.\n" "\n""``interface`` is the interface qualifying the method name, or None to omit\n" "the interface from the message header.\n""\n""``method`` is the method name (member name).\n" | |||
106 | "\n"static const char MethodCallMessage_tp_doc[] = "dbus.lowlevel.MethodCallMessage(destination: str or None, path: str, " "interface: str or None, method: str)\n""\n""A method-call message.\n" "\n""``destination`` is the destination bus name, or None to send the\n" "message directly to the peer (usually the bus daemon).\n""\n" "``path`` is the object-path of the object whose method is to be called.\n" "\n""``interface`` is the interface qualifying the method name, or None to omit\n" "the interface from the message header.\n""\n""``method`` is the method name (member name).\n" | |||
107 | "``path`` is the object-path of the object whose method is to be called.\n"static const char MethodCallMessage_tp_doc[] = "dbus.lowlevel.MethodCallMessage(destination: str or None, path: str, " "interface: str or None, method: str)\n""\n""A method-call message.\n" "\n""``destination`` is the destination bus name, or None to send the\n" "message directly to the peer (usually the bus daemon).\n""\n" "``path`` is the object-path of the object whose method is to be called.\n" "\n""``interface`` is the interface qualifying the method name, or None to omit\n" "the interface from the message header.\n""\n""``method`` is the method name (member name).\n" | |||
108 | "\n"static const char MethodCallMessage_tp_doc[] = "dbus.lowlevel.MethodCallMessage(destination: str or None, path: str, " "interface: str or None, method: str)\n""\n""A method-call message.\n" "\n""``destination`` is the destination bus name, or None to send the\n" "message directly to the peer (usually the bus daemon).\n""\n" "``path`` is the object-path of the object whose method is to be called.\n" "\n""``interface`` is the interface qualifying the method name, or None to omit\n" "the interface from the message header.\n""\n""``method`` is the method name (member name).\n" | |||
109 | "``interface`` is the interface qualifying the method name, or None to omit\n"static const char MethodCallMessage_tp_doc[] = "dbus.lowlevel.MethodCallMessage(destination: str or None, path: str, " "interface: str or None, method: str)\n""\n""A method-call message.\n" "\n""``destination`` is the destination bus name, or None to send the\n" "message directly to the peer (usually the bus daemon).\n""\n" "``path`` is the object-path of the object whose method is to be called.\n" "\n""``interface`` is the interface qualifying the method name, or None to omit\n" "the interface from the message header.\n""\n""``method`` is the method name (member name).\n" | |||
110 | "the interface from the message header.\n"static const char MethodCallMessage_tp_doc[] = "dbus.lowlevel.MethodCallMessage(destination: str or None, path: str, " "interface: str or None, method: str)\n""\n""A method-call message.\n" "\n""``destination`` is the destination bus name, or None to send the\n" "message directly to the peer (usually the bus daemon).\n""\n" "``path`` is the object-path of the object whose method is to be called.\n" "\n""``interface`` is the interface qualifying the method name, or None to omit\n" "the interface from the message header.\n""\n""``method`` is the method name (member name).\n" | |||
111 | "\n"static const char MethodCallMessage_tp_doc[] = "dbus.lowlevel.MethodCallMessage(destination: str or None, path: str, " "interface: str or None, method: str)\n""\n""A method-call message.\n" "\n""``destination`` is the destination bus name, or None to send the\n" "message directly to the peer (usually the bus daemon).\n""\n" "``path`` is the object-path of the object whose method is to be called.\n" "\n""``interface`` is the interface qualifying the method name, or None to omit\n" "the interface from the message header.\n""\n""``method`` is the method name (member name).\n" | |||
112 | "``method`` is the method name (member name).\n"static const char MethodCallMessage_tp_doc[] = "dbus.lowlevel.MethodCallMessage(destination: str or None, path: str, " "interface: str or None, method: str)\n""\n""A method-call message.\n" "\n""``destination`` is the destination bus name, or None to send the\n" "message directly to the peer (usually the bus daemon).\n""\n" "``path`` is the object-path of the object whose method is to be called.\n" "\n""``interface`` is the interface qualifying the method name, or None to omit\n" "the interface from the message header.\n""\n""``method`` is the method name (member name).\n" | |||
113 | )static const char MethodCallMessage_tp_doc[] = "dbus.lowlevel.MethodCallMessage(destination: str or None, path: str, " "interface: str or None, method: str)\n""\n""A method-call message.\n" "\n""``destination`` is the destination bus name, or None to send the\n" "message directly to the peer (usually the bus daemon).\n""\n" "``path`` is the object-path of the object whose method is to be called.\n" "\n""``interface`` is the interface qualifying the method name, or None to omit\n" "the interface from the message header.\n""\n""``method`` is the method name (member name).\n"; | |||
114 | ||||
115 | static int | |||
116 | MethodCallMessage_tp_init(Message *self, PyObject *args, PyObject *kwargs) | |||
117 | { | |||
118 | const char *destination, *path, *interface, *method; | |||
119 | static char *kwlist[] = {"destination", "path", "interface", "method", NULL((void*)0)}; | |||
120 | ||||
121 | if (!PyArg_ParseTupleAndKeywords_PyArg_ParseTupleAndKeywords_SizeT(args, kwargs, "zszs:__init__", kwlist, | |||
122 | &destination, &path, &interface, | |||
123 | &method)) { | |||
124 | return -1; | |||
125 | } | |||
126 | if (destination && !dbus_py_validate_bus_name(destination, 1, 1)) return -1; | |||
127 | if (!dbus_py_validate_object_path(path)) return -1; | |||
128 | if (interface && !dbus_py_validate_interface_name(interface)) return -1; | |||
129 | if (!dbus_py_validate_member_name(method)) return -1; | |||
130 | if (self->msg) { | |||
131 | dbus_message_unref(self->msg); | |||
132 | self->msg = NULL((void*)0); | |||
133 | } | |||
134 | self->msg = dbus_message_new_method_call(destination, path, interface, | |||
135 | method); | |||
136 | if (!self->msg) { | |||
137 | PyErr_NoMemory(); | |||
138 | return -1; | |||
139 | } | |||
140 | return 0; | |||
141 | } | |||
142 | ||||
143 | PyDoc_STRVAR(MethodReturnMessage_tp_doc,static const char MethodReturnMessage_tp_doc[] = "dbus.lowlevel.MethodReturnMessage(method_call: MethodCallMessage)\n" "\n""A method-return message." | |||
144 | "dbus.lowlevel.MethodReturnMessage(method_call: MethodCallMessage)\n"static const char MethodReturnMessage_tp_doc[] = "dbus.lowlevel.MethodReturnMessage(method_call: MethodCallMessage)\n" "\n""A method-return message." | |||
145 | "\n"static const char MethodReturnMessage_tp_doc[] = "dbus.lowlevel.MethodReturnMessage(method_call: MethodCallMessage)\n" "\n""A method-return message." | |||
146 | "A method-return message.")static const char MethodReturnMessage_tp_doc[] = "dbus.lowlevel.MethodReturnMessage(method_call: MethodCallMessage)\n" "\n""A method-return message."; | |||
147 | ||||
148 | static int | |||
149 | MethodReturnMessage_tp_init(Message *self, PyObject *args, PyObject *kwargs) | |||
150 | { | |||
151 | Message *other; | |||
152 | static char *kwlist[] = {"method_call", NULL((void*)0)}; | |||
153 | ||||
154 | if (!PyArg_ParseTupleAndKeywords_PyArg_ParseTupleAndKeywords_SizeT(args, kwargs, "O!:__init__", kwlist, | |||
155 | &MessageType, &other)) { | |||
156 | return -1; | |||
157 | } | |||
158 | if (self->msg) { | |||
159 | dbus_message_unref(self->msg); | |||
160 | self->msg = NULL((void*)0); | |||
161 | } | |||
162 | self->msg = dbus_message_new_method_return(other->msg); | |||
163 | if (!self->msg) { | |||
164 | PyErr_NoMemory(); | |||
165 | return -1; | |||
166 | } | |||
167 | return 0; | |||
168 | } | |||
169 | ||||
170 | PyDoc_STRVAR(SignalMessage_tp_doc,static const char SignalMessage_tp_doc[] = "dbus.lowlevel.SignalMessage(path: str, interface: str, method: str)\n" "\n""A signal message.\n" | |||
171 | "dbus.lowlevel.SignalMessage(path: str, interface: str, method: str)\n"static const char SignalMessage_tp_doc[] = "dbus.lowlevel.SignalMessage(path: str, interface: str, method: str)\n" "\n""A signal message.\n" | |||
172 | "\n"static const char SignalMessage_tp_doc[] = "dbus.lowlevel.SignalMessage(path: str, interface: str, method: str)\n" "\n""A signal message.\n" | |||
173 | "A signal message.\n")static const char SignalMessage_tp_doc[] = "dbus.lowlevel.SignalMessage(path: str, interface: str, method: str)\n" "\n""A signal message.\n"; | |||
174 | static int | |||
175 | SignalMessage_tp_init(Message *self, PyObject *args, PyObject *kwargs) | |||
176 | { | |||
177 | const char *path, *interface, *name; | |||
178 | static char *kwlist[] = {"path", "interface", "name", NULL((void*)0)}; | |||
179 | ||||
180 | if (!PyArg_ParseTupleAndKeywords_PyArg_ParseTupleAndKeywords_SizeT(args, kwargs, "sss:__init__", kwlist, | |||
181 | &path, &interface, &name)) { | |||
182 | return -1; | |||
183 | } | |||
184 | if (!dbus_py_validate_object_path(path)) return -1; | |||
185 | if (!dbus_py_validate_interface_name(interface)) return -1; | |||
186 | if (!dbus_py_validate_member_name(name)) return -1; | |||
187 | if (self->msg) { | |||
188 | dbus_message_unref(self->msg); | |||
189 | self->msg = NULL((void*)0); | |||
190 | } | |||
191 | self->msg = dbus_message_new_signal(path, interface, name); | |||
192 | if (!self->msg) { | |||
193 | PyErr_NoMemory(); | |||
194 | return -1; | |||
195 | } | |||
196 | return 0; | |||
197 | } | |||
198 | ||||
199 | static PyObject * | |||
200 | SignalMessage_tp_repr(PyObject *self) | |||
201 | { | |||
202 | DBusMessage *msg = ((Message *)self)->msg; | |||
203 | const char *path = dbus_message_get_path(msg); | |||
204 | const char *interface = dbus_message_get_interface(msg); | |||
205 | const char *member = dbus_message_get_member(msg); | |||
206 | const char *destination = dbus_message_get_destination(msg); | |||
207 | ||||
208 | if (!path) | |||
209 | path = "n/a"; | |||
210 | if (!interface) | |||
211 | interface = "n/a"; | |||
212 | if (!member) | |||
213 | member = "n/a"; | |||
214 | if (!destination) | |||
215 | destination = "(broadcast)"; | |||
216 | ||||
217 | return PyUnicode_FromFormat("<%s path: %s, iface: %s, member: %s, dest: %s>", | |||
218 | Py_TYPE(self)(((PyObject*)(self))->ob_type)->tp_name, | |||
219 | path, interface, member, destination); | |||
220 | } | |||
221 | ||||
222 | PyDoc_STRVAR(ErrorMessage_tp_doc,static const char ErrorMessage_tp_doc[] = "dbus.lowlevel.ErrorMessage(reply_to: Message, error_name: str, " "error_message: str or None)\n""\n""An error message.\n" | |||
223 | "dbus.lowlevel.ErrorMessage(reply_to: Message, error_name: str, "static const char ErrorMessage_tp_doc[] = "dbus.lowlevel.ErrorMessage(reply_to: Message, error_name: str, " "error_message: str or None)\n""\n""An error message.\n" | |||
224 | "error_message: str or None)\n"static const char ErrorMessage_tp_doc[] = "dbus.lowlevel.ErrorMessage(reply_to: Message, error_name: str, " "error_message: str or None)\n""\n""An error message.\n" | |||
225 | "\n"static const char ErrorMessage_tp_doc[] = "dbus.lowlevel.ErrorMessage(reply_to: Message, error_name: str, " "error_message: str or None)\n""\n""An error message.\n" | |||
226 | "An error message.\n")static const char ErrorMessage_tp_doc[] = "dbus.lowlevel.ErrorMessage(reply_to: Message, error_name: str, " "error_message: str or None)\n""\n""An error message.\n"; | |||
227 | static int | |||
228 | ErrorMessage_tp_init(Message *self, PyObject *args, PyObject *kwargs) | |||
229 | { | |||
230 | Message *reply_to; | |||
231 | const char *error_name, *error_message; | |||
232 | static char *kwlist[] = {"reply_to", "error_name", "error_message", NULL((void*)0)}; | |||
233 | ||||
234 | if (!PyArg_ParseTupleAndKeywords_PyArg_ParseTupleAndKeywords_SizeT(args, kwargs, "O!sz:__init__", kwlist, | |||
235 | &MessageType, &reply_to, &error_name, | |||
236 | &error_message)) { | |||
237 | return -1; | |||
238 | } | |||
239 | if (!dbus_py_validate_error_namedbus_py_validate_interface_name(error_name)) return -1; | |||
240 | if (self->msg) { | |||
241 | dbus_message_unref(self->msg); | |||
242 | self->msg = NULL((void*)0); | |||
243 | } | |||
244 | self->msg = dbus_message_new_error(reply_to->msg, error_name, error_message); | |||
245 | if (!self->msg) { | |||
246 | PyErr_NoMemory(); | |||
247 | return -1; | |||
248 | } | |||
249 | return 0; | |||
250 | } | |||
251 | ||||
252 | DBusMessage * | |||
253 | DBusPyMessage_BorrowDBusMessage(PyObject *msg) | |||
254 | { | |||
255 | if (!Message_Check(msg)) { | |||
256 | PyErr_SetString(PyExc_TypeError, | |||
257 | "A dbus.lowlevel.Message instance is required"); | |||
258 | return NULL((void*)0); | |||
259 | } | |||
260 | if (!((Message *)msg)->msg) { | |||
261 | DBusPy_RaiseUnusableMessage(); | |||
262 | return NULL((void*)0); | |||
263 | } | |||
264 | return ((Message *)msg)->msg; | |||
265 | } | |||
266 | ||||
267 | PyObject * | |||
268 | DBusPyMessage_ConsumeDBusMessage(DBusMessage *msg) | |||
269 | { | |||
270 | PyTypeObject *type; | |||
271 | Message *self; | |||
272 | ||||
273 | switch (dbus_message_get_type(msg)) { | |||
274 | case DBUS_MESSAGE_TYPE_METHOD_CALL1: | |||
275 | type = &MethodCallMessageType; | |||
276 | break; | |||
277 | case DBUS_MESSAGE_TYPE_METHOD_RETURN2: | |||
278 | type = &MethodReturnMessageType; | |||
279 | break; | |||
280 | case DBUS_MESSAGE_TYPE_ERROR3: | |||
281 | type = &ErrorMessageType; | |||
282 | break; | |||
283 | case DBUS_MESSAGE_TYPE_SIGNAL4: | |||
284 | type = &SignalMessageType; | |||
285 | break; | |||
286 | default: | |||
287 | type = &MessageType; | |||
288 | } | |||
289 | ||||
290 | self = (Message *)(type->tp_new) (type, dbus_py_empty_tuple, NULL((void*)0)); | |||
291 | if (!self) { | |||
292 | dbus_message_unref(msg); | |||
293 | return NULL((void*)0); | |||
294 | } | |||
295 | self->msg = msg; | |||
296 | return (PyObject *)self; | |||
297 | } | |||
298 | ||||
299 | PyDoc_STRVAR(Message_copy__doc__,static const char Message_copy__doc__[] = "message.copy() -> Message (or subclass)\n" "Deep-copy the message, resetting the serial number to zero.\n" | |||
300 | "message.copy() -> Message (or subclass)\n"static const char Message_copy__doc__[] = "message.copy() -> Message (or subclass)\n" "Deep-copy the message, resetting the serial number to zero.\n" | |||
301 | "Deep-copy the message, resetting the serial number to zero.\n")static const char Message_copy__doc__[] = "message.copy() -> Message (or subclass)\n" "Deep-copy the message, resetting the serial number to zero.\n"; | |||
302 | static PyObject * | |||
303 | Message_copy(Message *self, PyObject *args UNUSED__attribute__((__unused__))) | |||
304 | { | |||
305 | DBusMessage *msg; | |||
306 | if (!self->msg) return DBusPy_RaiseUnusableMessage(); | |||
307 | msg = dbus_message_copy(self->msg); | |||
308 | if (!msg) return PyErr_NoMemory(); | |||
309 | return DBusPyMessage_ConsumeDBusMessage(msg); | |||
310 | } | |||
311 | ||||
312 | PyDoc_STRVAR(Message_get_auto_start__doc__,static const char Message_get_auto_start__doc__[] = "message.get_auto_start() -> bool\n" "Return true if this message will cause an owner for the destination name\n" "to be auto-started.\n" | |||
313 | "message.get_auto_start() -> bool\n"static const char Message_get_auto_start__doc__[] = "message.get_auto_start() -> bool\n" "Return true if this message will cause an owner for the destination name\n" "to be auto-started.\n" | |||
314 | "Return true if this message will cause an owner for the destination name\n"static const char Message_get_auto_start__doc__[] = "message.get_auto_start() -> bool\n" "Return true if this message will cause an owner for the destination name\n" "to be auto-started.\n" | |||
315 | "to be auto-started.\n")static const char Message_get_auto_start__doc__[] = "message.get_auto_start() -> bool\n" "Return true if this message will cause an owner for the destination name\n" "to be auto-started.\n"; | |||
316 | static PyObject * | |||
317 | Message_get_auto_start(Message *self, PyObject *unused UNUSED__attribute__((__unused__))) | |||
318 | { | |||
319 | if (!self->msg) return DBusPy_RaiseUnusableMessage(); | |||
320 | return PyBool_FromLong(dbus_message_get_auto_start(self->msg)); | |||
321 | } | |||
322 | ||||
323 | PyDoc_STRVAR(Message_set_auto_start__doc__,static const char Message_set_auto_start__doc__[] = "message.set_auto_start(bool) -> None\n" "Set whether this message will cause an owner for the destination name\n" "to be auto-started.\n" | |||
324 | "message.set_auto_start(bool) -> None\n"static const char Message_set_auto_start__doc__[] = "message.set_auto_start(bool) -> None\n" "Set whether this message will cause an owner for the destination name\n" "to be auto-started.\n" | |||
325 | "Set whether this message will cause an owner for the destination name\n"static const char Message_set_auto_start__doc__[] = "message.set_auto_start(bool) -> None\n" "Set whether this message will cause an owner for the destination name\n" "to be auto-started.\n" | |||
326 | "to be auto-started.\n")static const char Message_set_auto_start__doc__[] = "message.set_auto_start(bool) -> None\n" "Set whether this message will cause an owner for the destination name\n" "to be auto-started.\n"; | |||
327 | static PyObject * | |||
328 | Message_set_auto_start(Message *self, PyObject *args) | |||
329 | { | |||
330 | int value; | |||
331 | if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "i", &value)) return NULL((void*)0); | |||
332 | if (!self->msg) return DBusPy_RaiseUnusableMessage(); | |||
333 | dbus_message_set_auto_start(self->msg, value ? TRUE1 : FALSE0); | |||
334 | Py_INCREF(Py_None)_Py_INCREF(((PyObject*)((&_Py_NoneStruct)))); | |||
335 | return Py_None(&_Py_NoneStruct); | |||
336 | } | |||
337 | ||||
338 | PyDoc_STRVAR(Message_get_no_reply__doc__,static const char Message_get_no_reply__doc__[] = "message.get_no_reply() -> bool\n" "Return true if this message need not be replied to.\n" | |||
339 | "message.get_no_reply() -> bool\n"static const char Message_get_no_reply__doc__[] = "message.get_no_reply() -> bool\n" "Return true if this message need not be replied to.\n" | |||
340 | "Return true if this message need not be replied to.\n")static const char Message_get_no_reply__doc__[] = "message.get_no_reply() -> bool\n" "Return true if this message need not be replied to.\n"; | |||
341 | static PyObject * | |||
342 | Message_get_no_reply(Message *self, PyObject *unused UNUSED__attribute__((__unused__))) | |||
343 | { | |||
344 | if (!self->msg) return DBusPy_RaiseUnusableMessage(); | |||
345 | return PyBool_FromLong(dbus_message_get_no_reply(self->msg)); | |||
346 | } | |||
347 | ||||
348 | PyDoc_STRVAR(Message_set_no_reply__doc__,static const char Message_set_no_reply__doc__[] = "message.set_no_reply(bool) -> None\n" "Set whether no reply to this message is required.\n" | |||
349 | "message.set_no_reply(bool) -> None\n"static const char Message_set_no_reply__doc__[] = "message.set_no_reply(bool) -> None\n" "Set whether no reply to this message is required.\n" | |||
350 | "Set whether no reply to this message is required.\n")static const char Message_set_no_reply__doc__[] = "message.set_no_reply(bool) -> None\n" "Set whether no reply to this message is required.\n"; | |||
351 | static PyObject * | |||
352 | Message_set_no_reply(Message *self, PyObject *args) | |||
353 | { | |||
354 | int value; | |||
355 | if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "i", &value)) return NULL((void*)0); | |||
356 | if (!self->msg) return DBusPy_RaiseUnusableMessage(); | |||
357 | dbus_message_set_no_reply(self->msg, value ? TRUE1 : FALSE0); | |||
358 | Py_RETURN_NONEreturn _Py_INCREF(((PyObject*)((&_Py_NoneStruct)))), (& _Py_NoneStruct); | |||
359 | } | |||
360 | ||||
361 | PyDoc_STRVAR(Message_get_reply_serial__doc__,static const char Message_get_reply_serial__doc__[] = "message.get_reply_serial() -> long\n" "Returns the serial that the message is a reply to or 0 if none.\n" | |||
362 | "message.get_reply_serial() -> long\n"static const char Message_get_reply_serial__doc__[] = "message.get_reply_serial() -> long\n" "Returns the serial that the message is a reply to or 0 if none.\n" | |||
363 | "Returns the serial that the message is a reply to or 0 if none.\n")static const char Message_get_reply_serial__doc__[] = "message.get_reply_serial() -> long\n" "Returns the serial that the message is a reply to or 0 if none.\n"; | |||
364 | static PyObject * | |||
365 | Message_get_reply_serial(Message *self, PyObject *unused UNUSED__attribute__((__unused__))) | |||
366 | { | |||
367 | if (!self->msg) return DBusPy_RaiseUnusableMessage(); | |||
368 | return PyLong_FromUnsignedLong(dbus_message_get_reply_serial(self->msg)); | |||
369 | } | |||
370 | ||||
371 | PyDoc_STRVAR(Message_set_reply_serial__doc__,static const char Message_set_reply_serial__doc__[] = "message.set_reply_serial(bool) -> None\n" "Set the serial that this message is a reply to.\n" | |||
372 | "message.set_reply_serial(bool) -> None\n"static const char Message_set_reply_serial__doc__[] = "message.set_reply_serial(bool) -> None\n" "Set the serial that this message is a reply to.\n" | |||
373 | "Set the serial that this message is a reply to.\n")static const char Message_set_reply_serial__doc__[] = "message.set_reply_serial(bool) -> None\n" "Set the serial that this message is a reply to.\n"; | |||
374 | static PyObject * | |||
375 | Message_set_reply_serial(Message *self, PyObject *args) | |||
376 | { | |||
377 | dbus_uint32_t value; | |||
378 | ||||
379 | if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "k", &value)) return NULL((void*)0); | |||
380 | if (!self->msg) return DBusPy_RaiseUnusableMessage(); | |||
381 | if (!dbus_message_set_reply_serial(self->msg, value)) { | |||
382 | return PyErr_NoMemory(); | |||
383 | } | |||
384 | Py_INCREF(Py_None)_Py_INCREF(((PyObject*)((&_Py_NoneStruct)))); | |||
385 | return Py_None(&_Py_NoneStruct); | |||
386 | } | |||
387 | ||||
388 | PyDoc_STRVAR(Message_get_type__doc__,static const char Message_get_type__doc__[] = "message.get_type() -> int\n\n" "Returns the type of the message.\n" | |||
389 | "message.get_type() -> int\n\n"static const char Message_get_type__doc__[] = "message.get_type() -> int\n\n" "Returns the type of the message.\n" | |||
390 | "Returns the type of the message.\n")static const char Message_get_type__doc__[] = "message.get_type() -> int\n\n" "Returns the type of the message.\n"; | |||
391 | static PyObject * | |||
392 | Message_get_type(Message *self, PyObject *unused UNUSED__attribute__((__unused__))) | |||
393 | { | |||
394 | if (!self->msg) return DBusPy_RaiseUnusableMessage(); | |||
395 | return PyLong_FromLong(dbus_message_get_type(self->msg)); | |||
396 | } | |||
397 | ||||
398 | PyDoc_STRVAR(Message_get_serial__doc__,static const char Message_get_serial__doc__[] = "message.get_serial() -> long\n" "Returns the serial of a message or 0 if none has been specified.\n" "\n""The message's serial number is provided by the application sending the\n" "message and is used to identify replies to this message. All messages\n" "received on a connection will have a serial, but messages you haven't\n" "sent yet may return 0.\n" | |||
399 | "message.get_serial() -> long\n"static const char Message_get_serial__doc__[] = "message.get_serial() -> long\n" "Returns the serial of a message or 0 if none has been specified.\n" "\n""The message's serial number is provided by the application sending the\n" "message and is used to identify replies to this message. All messages\n" "received on a connection will have a serial, but messages you haven't\n" "sent yet may return 0.\n" | |||
400 | "Returns the serial of a message or 0 if none has been specified.\n"static const char Message_get_serial__doc__[] = "message.get_serial() -> long\n" "Returns the serial of a message or 0 if none has been specified.\n" "\n""The message's serial number is provided by the application sending the\n" "message and is used to identify replies to this message. All messages\n" "received on a connection will have a serial, but messages you haven't\n" "sent yet may return 0.\n" | |||
401 | "\n"static const char Message_get_serial__doc__[] = "message.get_serial() -> long\n" "Returns the serial of a message or 0 if none has been specified.\n" "\n""The message's serial number is provided by the application sending the\n" "message and is used to identify replies to this message. All messages\n" "received on a connection will have a serial, but messages you haven't\n" "sent yet may return 0.\n" | |||
402 | "The message's serial number is provided by the application sending the\n"static const char Message_get_serial__doc__[] = "message.get_serial() -> long\n" "Returns the serial of a message or 0 if none has been specified.\n" "\n""The message's serial number is provided by the application sending the\n" "message and is used to identify replies to this message. All messages\n" "received on a connection will have a serial, but messages you haven't\n" "sent yet may return 0.\n" | |||
403 | "message and is used to identify replies to this message. All messages\n"static const char Message_get_serial__doc__[] = "message.get_serial() -> long\n" "Returns the serial of a message or 0 if none has been specified.\n" "\n""The message's serial number is provided by the application sending the\n" "message and is used to identify replies to this message. All messages\n" "received on a connection will have a serial, but messages you haven't\n" "sent yet may return 0.\n" | |||
404 | "received on a connection will have a serial, but messages you haven't\n"static const char Message_get_serial__doc__[] = "message.get_serial() -> long\n" "Returns the serial of a message or 0 if none has been specified.\n" "\n""The message's serial number is provided by the application sending the\n" "message and is used to identify replies to this message. All messages\n" "received on a connection will have a serial, but messages you haven't\n" "sent yet may return 0.\n" | |||
405 | "sent yet may return 0.\n")static const char Message_get_serial__doc__[] = "message.get_serial() -> long\n" "Returns the serial of a message or 0 if none has been specified.\n" "\n""The message's serial number is provided by the application sending the\n" "message and is used to identify replies to this message. All messages\n" "received on a connection will have a serial, but messages you haven't\n" "sent yet may return 0.\n"; | |||
406 | static PyObject * | |||
407 | Message_get_serial(Message *self, PyObject *unused UNUSED__attribute__((__unused__))) | |||
408 | { | |||
409 | if (!self->msg) return DBusPy_RaiseUnusableMessage(); | |||
410 | return PyLong_FromUnsignedLong(dbus_message_get_serial(self->msg)); | |||
411 | } | |||
412 | ||||
413 | PyDoc_STRVAR(Message_is_method_call__doc__,static const char Message_is_method_call__doc__[] = "is_method_call(interface: str, member: str) -> bool" | |||
414 | "is_method_call(interface: str, member: str) -> bool")static const char Message_is_method_call__doc__[] = "is_method_call(interface: str, member: str) -> bool"; | |||
415 | static PyObject * | |||
416 | Message_is_method_call(Message *self, PyObject *args) | |||
417 | { | |||
418 | const char *interface, *method; | |||
419 | ||||
420 | if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "ss:is_method_call", &interface, &method)) { | |||
421 | return NULL((void*)0); | |||
422 | } | |||
423 | if (!self->msg) return DBusPy_RaiseUnusableMessage(); | |||
424 | return PyBool_FromLong(dbus_message_is_method_call(self->msg, interface, | |||
425 | method)); | |||
426 | } | |||
427 | ||||
428 | PyDoc_STRVAR(Message_is_error__doc__,static const char Message_is_error__doc__[] = "is_error(error: str) -> bool" | |||
429 | "is_error(error: str) -> bool")static const char Message_is_error__doc__[] = "is_error(error: str) -> bool"; | |||
430 | static PyObject * | |||
431 | Message_is_error(Message *self, PyObject *args) | |||
432 | { | |||
433 | const char *error_name; | |||
434 | ||||
435 | if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "s:is_error", &error_name)) { | |||
436 | return NULL((void*)0); | |||
437 | } | |||
438 | if (!self->msg) return DBusPy_RaiseUnusableMessage(); | |||
439 | return PyBool_FromLong(dbus_message_is_error(self->msg, error_name)); | |||
440 | } | |||
441 | ||||
442 | PyDoc_STRVAR(Message_is_signal__doc__,static const char Message_is_signal__doc__[] = "is_signal(interface: str, member: str) -> bool" | |||
443 | "is_signal(interface: str, member: str) -> bool")static const char Message_is_signal__doc__[] = "is_signal(interface: str, member: str) -> bool"; | |||
444 | static PyObject * | |||
445 | Message_is_signal(Message *self, PyObject *args) | |||
446 | { | |||
447 | const char *interface, *signal_name; | |||
448 | ||||
449 | if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "ss:is_signal", &interface, &signal_name)) { | |||
450 | return NULL((void*)0); | |||
451 | } | |||
452 | if (!self->msg) return DBusPy_RaiseUnusableMessage(); | |||
453 | return PyBool_FromLong(dbus_message_is_signal(self->msg, interface, | |||
454 | signal_name)); | |||
455 | } | |||
456 | ||||
457 | PyDoc_STRVAR(Message_get_member__doc__,static const char Message_get_member__doc__[] = "get_member() -> str or None" | |||
458 | "get_member() -> str or None")static const char Message_get_member__doc__[] = "get_member() -> str or None"; | |||
459 | static PyObject * | |||
460 | Message_get_member(Message *self, PyObject *unused UNUSED__attribute__((__unused__))) | |||
461 | { | |||
462 | const char *c_str; | |||
463 | ||||
464 | if (!self->msg) return DBusPy_RaiseUnusableMessage(); | |||
465 | c_str = dbus_message_get_member(self->msg); | |||
466 | if (!c_str) { | |||
467 | Py_RETURN_NONEreturn _Py_INCREF(((PyObject*)((&_Py_NoneStruct)))), (& _Py_NoneStruct); | |||
468 | } | |||
469 | return PyUnicode_FromString(c_str); | |||
470 | } | |||
471 | ||||
472 | PyDoc_STRVAR(Message_has_member__doc__,static const char Message_has_member__doc__[] = "has_member(name: str or None) -> bool" | |||
473 | "has_member(name: str or None) -> bool")static const char Message_has_member__doc__[] = "has_member(name: str or None) -> bool"; | |||
474 | static PyObject * | |||
475 | Message_has_member(Message *self, PyObject *args) | |||
476 | { | |||
477 | const char *name; | |||
478 | ||||
479 | if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "z:has_member", &name)) { | |||
480 | return NULL((void*)0); | |||
481 | } | |||
482 | if (!self->msg) return DBusPy_RaiseUnusableMessage(); | |||
483 | return PyBool_FromLong(dbus_message_has_member(self->msg, name)); | |||
484 | } | |||
485 | ||||
486 | PyDoc_STRVAR(Message_set_member__doc__,static const char Message_set_member__doc__[] = "set_member(unique_name: str or None)" | |||
487 | "set_member(unique_name: str or None)")static const char Message_set_member__doc__[] = "set_member(unique_name: str or None)"; | |||
488 | static PyObject * | |||
489 | Message_set_member(Message *self, PyObject *args) | |||
490 | { | |||
491 | const char *name; | |||
492 | ||||
493 | if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "z:set_member", &name)) { | |||
494 | return NULL((void*)0); | |||
495 | } | |||
496 | if (!self->msg) return DBusPy_RaiseUnusableMessage(); | |||
497 | if (!dbus_py_validate_member_name(name)) return NULL((void*)0); | |||
498 | if (!dbus_message_set_member(self->msg, name)) return PyErr_NoMemory(); | |||
499 | Py_RETURN_NONEreturn _Py_INCREF(((PyObject*)((&_Py_NoneStruct)))), (& _Py_NoneStruct); | |||
500 | } | |||
501 | ||||
502 | PyDoc_STRVAR(Message_get_path__doc__,static const char Message_get_path__doc__[] = "get_path() -> ObjectPath or None\n\n" "Return the message's destination object path (if it's a method call) or\n" "source object path (if it's a method reply or a signal) or None (if it\n" "has no path).\n" | |||
503 | "get_path() -> ObjectPath or None\n\n"static const char Message_get_path__doc__[] = "get_path() -> ObjectPath or None\n\n" "Return the message's destination object path (if it's a method call) or\n" "source object path (if it's a method reply or a signal) or None (if it\n" "has no path).\n" | |||
504 | "Return the message's destination object path (if it's a method call) or\n"static const char Message_get_path__doc__[] = "get_path() -> ObjectPath or None\n\n" "Return the message's destination object path (if it's a method call) or\n" "source object path (if it's a method reply or a signal) or None (if it\n" "has no path).\n" | |||
505 | "source object path (if it's a method reply or a signal) or None (if it\n"static const char Message_get_path__doc__[] = "get_path() -> ObjectPath or None\n\n" "Return the message's destination object path (if it's a method call) or\n" "source object path (if it's a method reply or a signal) or None (if it\n" "has no path).\n" | |||
506 | "has no path).\n")static const char Message_get_path__doc__[] = "get_path() -> ObjectPath or None\n\n" "Return the message's destination object path (if it's a method call) or\n" "source object path (if it's a method reply or a signal) or None (if it\n" "has no path).\n"; | |||
507 | static PyObject * | |||
508 | Message_get_path(Message *self, PyObject *unused UNUSED__attribute__((__unused__))) | |||
509 | { | |||
510 | const char *c_str; | |||
511 | ||||
512 | if (!self->msg) return DBusPy_RaiseUnusableMessage(); | |||
513 | c_str = dbus_message_get_path(self->msg); | |||
514 | if (!c_str) { | |||
515 | Py_RETURN_NONEreturn _Py_INCREF(((PyObject*)((&_Py_NoneStruct)))), (& _Py_NoneStruct); | |||
516 | } | |||
517 | return PyObject_CallFunction_PyObject_CallFunction_SizeT((PyObject *)&DBusPyObjectPath_Type, "(s)", c_str); | |||
518 | } | |||
519 | ||||
520 | PyDoc_STRVAR(Message_get_path_decomposed__doc__,static const char Message_get_path_decomposed__doc__[] = "get_path_decomposed() -> list of str, or None\n\n" "Return a list of path components (e.g. /foo/bar -> ['foo','bar'], / -> [])\n" "or None if the message has no associated path.\n" | |||
521 | "get_path_decomposed() -> list of str, or None\n\n"static const char Message_get_path_decomposed__doc__[] = "get_path_decomposed() -> list of str, or None\n\n" "Return a list of path components (e.g. /foo/bar -> ['foo','bar'], / -> [])\n" "or None if the message has no associated path.\n" | |||
522 | "Return a list of path components (e.g. /foo/bar -> ['foo','bar'], / -> [])\n"static const char Message_get_path_decomposed__doc__[] = "get_path_decomposed() -> list of str, or None\n\n" "Return a list of path components (e.g. /foo/bar -> ['foo','bar'], / -> [])\n" "or None if the message has no associated path.\n" | |||
523 | "or None if the message has no associated path.\n")static const char Message_get_path_decomposed__doc__[] = "get_path_decomposed() -> list of str, or None\n\n" "Return a list of path components (e.g. /foo/bar -> ['foo','bar'], / -> [])\n" "or None if the message has no associated path.\n"; | |||
524 | static PyObject * | |||
525 | Message_get_path_decomposed(Message *self, PyObject *unused UNUSED__attribute__((__unused__))) | |||
526 | { | |||
527 | char **paths, **ptr; | |||
528 | PyObject *ret = PyList_New(0); | |||
529 | ||||
530 | if (!ret) return NULL((void*)0); | |||
| ||||
531 | if (!self->msg) { | |||
532 | Py_CLEAR(ret)do { PyObject *_py_tmp = ((PyObject*)(ret)); if (_py_tmp != ( (void*)0)) { (ret) = ((void*)0); _Py_DECREF(((PyObject*)(_py_tmp ))); } } while (0); | |||
533 | return DBusPy_RaiseUnusableMessage(); | |||
534 | } | |||
535 | if (!dbus_message_get_path_decomposed(self->msg, &paths)) { | |||
536 | Py_CLEAR(ret)do { PyObject *_py_tmp = ((PyObject*)(ret)); if (_py_tmp != ( (void*)0)) { (ret) = ((void*)0); _Py_DECREF(((PyObject*)(_py_tmp ))); } } while (0); | |||
537 | return PyErr_NoMemory(); | |||
538 | } | |||
539 | if (!paths) { | |||
540 | Py_CLEAR(ret)do { PyObject *_py_tmp = ((PyObject*)(ret)); if (_py_tmp != ( (void*)0)) { (ret) = ((void*)0); _Py_DECREF(((PyObject*)(_py_tmp ))); } } while (0); | |||
541 | Py_RETURN_NONEreturn _Py_INCREF(((PyObject*)((&_Py_NoneStruct)))), (& _Py_NoneStruct); | |||
542 | } | |||
543 | for (ptr = paths; *ptr; ptr++) { | |||
544 | PyObject *str = PyUnicode_FromString(*ptr); | |||
| ||||
545 | ||||
546 | if (!str) { | |||
547 | Py_CLEAR(ret)do { PyObject *_py_tmp = ((PyObject*)(ret)); if (_py_tmp != ( (void*)0)) { (ret) = ((void*)0); _Py_DECREF(((PyObject*)(_py_tmp ))); } } while (0); | |||
548 | break; | |||
549 | } | |||
550 | if (PyList_Append(ret, str) < 0) { | |||
551 | Py_CLEAR(ret)do { PyObject *_py_tmp = ((PyObject*)(ret)); if (_py_tmp != ( (void*)0)) { (ret) = ((void*)0); _Py_DECREF(((PyObject*)(_py_tmp ))); } } while (0); | |||
552 | break; | |||
553 | } | |||
554 | Py_CLEAR(str)do { PyObject *_py_tmp = ((PyObject*)(str)); if (_py_tmp != ( (void*)0)) { (str) = ((void*)0); _Py_DECREF(((PyObject*)(_py_tmp ))); } } while (0); | |||
555 | str = NULL((void*)0); | |||
556 | } | |||
557 | dbus_free_string_array(paths); | |||
558 | return ret; | |||
559 | } | |||
560 | ||||
561 | PyDoc_STRVAR(Message_has_path__doc__,static const char Message_has_path__doc__[] = "has_path(name: str or None) -> bool" | |||
562 | "has_path(name: str or None) -> bool")static const char Message_has_path__doc__[] = "has_path(name: str or None) -> bool"; | |||
563 | static PyObject * | |||
564 | Message_has_path(Message *self, PyObject *args) | |||
565 | { | |||
566 | const char *name; | |||
567 | ||||
568 | if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "z:has_path", &name)) { | |||
569 | return NULL((void*)0); | |||
570 | } | |||
571 | if (!self->msg) return DBusPy_RaiseUnusableMessage(); | |||
572 | return PyBool_FromLong(dbus_message_has_path(self->msg, name)); | |||
573 | } | |||
574 | ||||
575 | PyDoc_STRVAR(Message_set_path__doc__,static const char Message_set_path__doc__[] = "set_path(name: str or None)" | |||
576 | "set_path(name: str or None)")static const char Message_set_path__doc__[] = "set_path(name: str or None)"; | |||
577 | static PyObject * | |||
578 | Message_set_path(Message *self, PyObject *args) | |||
579 | { | |||
580 | const char *name; | |||
581 | ||||
582 | if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "z:set_path", &name)) return NULL((void*)0); | |||
583 | if (!self->msg) return DBusPy_RaiseUnusableMessage(); | |||
584 | if (!dbus_message_has_path(self->msg, name)) return PyErr_NoMemory(); | |||
585 | Py_RETURN_NONEreturn _Py_INCREF(((PyObject*)((&_Py_NoneStruct)))), (& _Py_NoneStruct); | |||
586 | } | |||
587 | ||||
588 | PyDoc_STRVAR(Message_get_signature__doc__,static const char Message_get_signature__doc__[] = "get_signature() -> Signature or None" | |||
589 | "get_signature() -> Signature or None")static const char Message_get_signature__doc__[] = "get_signature() -> Signature or None"; | |||
590 | static PyObject * | |||
591 | Message_get_signature(Message *self, PyObject *unused UNUSED__attribute__((__unused__))) | |||
592 | { | |||
593 | const char *c_str; | |||
594 | ||||
595 | if (!self->msg) return DBusPy_RaiseUnusableMessage(); | |||
596 | c_str = dbus_message_get_signature(self->msg); | |||
597 | if (!c_str) { | |||
598 | return PyObject_CallFunction_PyObject_CallFunction_SizeT((PyObject *)&DBusPySignature_Type, "(s)", ""); | |||
599 | } | |||
600 | return PyObject_CallFunction_PyObject_CallFunction_SizeT((PyObject *)&DBusPySignature_Type, "(s)", c_str); | |||
601 | } | |||
602 | ||||
603 | PyDoc_STRVAR(Message_has_signature__doc__,static const char Message_has_signature__doc__[] = "has_signature(signature: str) -> bool" | |||
604 | "has_signature(signature: str) -> bool")static const char Message_has_signature__doc__[] = "has_signature(signature: str) -> bool"; | |||
605 | static PyObject * | |||
606 | Message_has_signature(Message *self, PyObject *args) | |||
607 | { | |||
608 | const char *name; | |||
609 | ||||
610 | if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "s:has_signature", &name)) { | |||
611 | return NULL((void*)0); | |||
612 | } | |||
613 | if (!self->msg) return DBusPy_RaiseUnusableMessage(); | |||
614 | return PyBool_FromLong(dbus_message_has_signature(self->msg, name)); | |||
615 | } | |||
616 | ||||
617 | PyDoc_STRVAR(Message_get_sender__doc__,static const char Message_get_sender__doc__[] = "get_sender() -> str or None\n\n" "Return the message's sender unique name, or None if none.\n" | |||
618 | "get_sender() -> str or None\n\n"static const char Message_get_sender__doc__[] = "get_sender() -> str or None\n\n" "Return the message's sender unique name, or None if none.\n" | |||
619 | "Return the message's sender unique name, or None if none.\n")static const char Message_get_sender__doc__[] = "get_sender() -> str or None\n\n" "Return the message's sender unique name, or None if none.\n"; | |||
620 | static PyObject * | |||
621 | Message_get_sender(Message *self, PyObject *unused UNUSED__attribute__((__unused__))) | |||
622 | { | |||
623 | const char *c_str; | |||
624 | ||||
625 | if (!self->msg) return DBusPy_RaiseUnusableMessage(); | |||
626 | c_str = dbus_message_get_sender(self->msg); | |||
627 | if (!c_str) { | |||
628 | Py_RETURN_NONEreturn _Py_INCREF(((PyObject*)((&_Py_NoneStruct)))), (& _Py_NoneStruct); | |||
629 | } | |||
630 | return PyUnicode_FromString(c_str); | |||
631 | } | |||
632 | ||||
633 | PyDoc_STRVAR(Message_has_sender__doc__,static const char Message_has_sender__doc__[] = "has_sender(unique_name: str) -> bool" | |||
634 | "has_sender(unique_name: str) -> bool")static const char Message_has_sender__doc__[] = "has_sender(unique_name: str) -> bool"; | |||
635 | static PyObject * | |||
636 | Message_has_sender(Message *self, PyObject *args) | |||
637 | { | |||
638 | const char *name; | |||
639 | ||||
640 | if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "s:has_sender", &name)) { | |||
641 | return NULL((void*)0); | |||
642 | } | |||
643 | if (!self->msg) return DBusPy_RaiseUnusableMessage(); | |||
644 | return PyBool_FromLong(dbus_message_has_sender(self->msg, name)); | |||
645 | } | |||
646 | ||||
647 | PyDoc_STRVAR(Message_set_sender__doc__,static const char Message_set_sender__doc__[] = "set_sender(unique_name: str or None)" | |||
648 | "set_sender(unique_name: str or None)")static const char Message_set_sender__doc__[] = "set_sender(unique_name: str or None)"; | |||
649 | static PyObject * | |||
650 | Message_set_sender(Message *self, PyObject *args) | |||
651 | { | |||
652 | const char *name; | |||
653 | ||||
654 | if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "z:set_sender", &name)) { | |||
655 | return NULL((void*)0); | |||
656 | } | |||
657 | if (!self->msg) return DBusPy_RaiseUnusableMessage(); | |||
658 | if (!dbus_py_validate_bus_name(name, 1, 1)) return NULL((void*)0); | |||
659 | if (!dbus_message_set_sender(self->msg, name)) return PyErr_NoMemory(); | |||
660 | Py_RETURN_NONEreturn _Py_INCREF(((PyObject*)((&_Py_NoneStruct)))), (& _Py_NoneStruct); | |||
661 | } | |||
662 | ||||
663 | PyDoc_STRVAR(Message_get_destination__doc__,static const char Message_get_destination__doc__[] = "get_destination() -> str or None\n\n" "Return the message's destination bus name, or None if none.\n" | |||
664 | "get_destination() -> str or None\n\n"static const char Message_get_destination__doc__[] = "get_destination() -> str or None\n\n" "Return the message's destination bus name, or None if none.\n" | |||
665 | "Return the message's destination bus name, or None if none.\n")static const char Message_get_destination__doc__[] = "get_destination() -> str or None\n\n" "Return the message's destination bus name, or None if none.\n"; | |||
666 | static PyObject * | |||
667 | Message_get_destination(Message *self, PyObject *unused UNUSED__attribute__((__unused__))) | |||
668 | { | |||
669 | const char *c_str; | |||
670 | ||||
671 | if (!self->msg) return DBusPy_RaiseUnusableMessage(); | |||
672 | c_str = dbus_message_get_destination(self->msg); | |||
673 | if (!c_str) { | |||
674 | Py_RETURN_NONEreturn _Py_INCREF(((PyObject*)((&_Py_NoneStruct)))), (& _Py_NoneStruct); | |||
675 | } | |||
676 | return PyUnicode_FromString(c_str); | |||
677 | } | |||
678 | ||||
679 | PyDoc_STRVAR(Message_has_destination__doc__,static const char Message_has_destination__doc__[] = "has_destination(bus_name: str) -> bool" | |||
680 | "has_destination(bus_name: str) -> bool")static const char Message_has_destination__doc__[] = "has_destination(bus_name: str) -> bool"; | |||
681 | static PyObject * | |||
682 | Message_has_destination(Message *self, PyObject *args) | |||
683 | { | |||
684 | const char *name; | |||
685 | ||||
686 | if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "s:has_destination", &name)) { | |||
687 | return NULL((void*)0); | |||
688 | } | |||
689 | if (!self->msg) return DBusPy_RaiseUnusableMessage(); | |||
690 | return PyBool_FromLong(dbus_message_has_destination(self->msg, name)); | |||
691 | } | |||
692 | ||||
693 | PyDoc_STRVAR(Message_set_destination__doc__,static const char Message_set_destination__doc__[] = "set_destination(bus_name: str or None)" | |||
694 | "set_destination(bus_name: str or None)")static const char Message_set_destination__doc__[] = "set_destination(bus_name: str or None)"; | |||
695 | static PyObject * | |||
696 | Message_set_destination(Message *self, PyObject *args) | |||
697 | { | |||
698 | const char *name; | |||
699 | ||||
700 | if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "z:set_destination", &name)) { | |||
701 | return NULL((void*)0); | |||
702 | } | |||
703 | if (!self->msg) return DBusPy_RaiseUnusableMessage(); | |||
704 | if (!dbus_py_validate_bus_name(name, 1, 1)) return NULL((void*)0); | |||
705 | if (!dbus_message_set_destination(self->msg, name)) return PyErr_NoMemory(); | |||
706 | Py_RETURN_NONEreturn _Py_INCREF(((PyObject*)((&_Py_NoneStruct)))), (& _Py_NoneStruct); | |||
707 | } | |||
708 | ||||
709 | PyDoc_STRVAR(Message_get_interface__doc__,static const char Message_get_interface__doc__[] = "get_interface() -> str or None" | |||
710 | "get_interface() -> str or None")static const char Message_get_interface__doc__[] = "get_interface() -> str or None"; | |||
711 | static PyObject * | |||
712 | Message_get_interface(Message *self, PyObject *unused UNUSED__attribute__((__unused__))) | |||
713 | { | |||
714 | const char *c_str; | |||
715 | ||||
716 | if (!self->msg) return DBusPy_RaiseUnusableMessage(); | |||
717 | c_str = dbus_message_get_interface(self->msg); | |||
718 | if (!c_str) { | |||
719 | Py_RETURN_NONEreturn _Py_INCREF(((PyObject*)((&_Py_NoneStruct)))), (& _Py_NoneStruct); | |||
720 | } | |||
721 | return PyUnicode_FromString(c_str); | |||
722 | } | |||
723 | ||||
724 | PyDoc_STRVAR(Message_has_interface__doc__,static const char Message_has_interface__doc__[] = "has_interface(interface: str or None) -> bool" | |||
725 | "has_interface(interface: str or None) -> bool")static const char Message_has_interface__doc__[] = "has_interface(interface: str or None) -> bool"; | |||
726 | static PyObject * | |||
727 | Message_has_interface(Message *self, PyObject *args) | |||
728 | { | |||
729 | const char *name; | |||
730 | ||||
731 | if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "z:has_interface", &name)) { | |||
732 | return NULL((void*)0); | |||
733 | } | |||
734 | if (!self->msg) return DBusPy_RaiseUnusableMessage(); | |||
735 | return PyBool_FromLong(dbus_message_has_interface(self->msg, name)); | |||
736 | } | |||
737 | ||||
738 | PyDoc_STRVAR(Message_set_interface__doc__,static const char Message_set_interface__doc__[] = "set_interface(name: str or None)" | |||
739 | "set_interface(name: str or None)")static const char Message_set_interface__doc__[] = "set_interface(name: str or None)"; | |||
740 | static PyObject * | |||
741 | Message_set_interface(Message *self, PyObject *args) | |||
742 | { | |||
743 | const char *name; | |||
744 | ||||
745 | if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "z:set_interface", &name)) { | |||
746 | return NULL((void*)0); | |||
747 | } | |||
748 | if (!self->msg) return DBusPy_RaiseUnusableMessage(); | |||
749 | if (!dbus_py_validate_interface_name(name)) return NULL((void*)0); | |||
750 | if (!dbus_message_set_interface(self->msg, name)) return PyErr_NoMemory(); | |||
751 | Py_RETURN_NONEreturn _Py_INCREF(((PyObject*)((&_Py_NoneStruct)))), (& _Py_NoneStruct); | |||
752 | } | |||
753 | ||||
754 | PyDoc_STRVAR(Message_get_error_name__doc__,static const char Message_get_error_name__doc__[] = "get_error_name() -> str or None" | |||
755 | "get_error_name() -> str or None")static const char Message_get_error_name__doc__[] = "get_error_name() -> str or None"; | |||
756 | static PyObject * | |||
757 | Message_get_error_name(Message *self, PyObject *unused UNUSED__attribute__((__unused__))) | |||
758 | { | |||
759 | const char *c_str; | |||
760 | ||||
761 | if (!self->msg) return DBusPy_RaiseUnusableMessage(); | |||
762 | c_str = dbus_message_get_error_name(self->msg); | |||
763 | if (!c_str) { | |||
764 | Py_RETURN_NONEreturn _Py_INCREF(((PyObject*)((&_Py_NoneStruct)))), (& _Py_NoneStruct); | |||
765 | } | |||
766 | return PyUnicode_FromString(c_str); | |||
767 | } | |||
768 | ||||
769 | PyDoc_STRVAR(Message_set_error_name__doc__,static const char Message_set_error_name__doc__[] = "set_error_name(name: str or None)" | |||
770 | "set_error_name(name: str or None)")static const char Message_set_error_name__doc__[] = "set_error_name(name: str or None)"; | |||
771 | static PyObject * | |||
772 | Message_set_error_name(Message *self, PyObject *args) | |||
773 | { | |||
774 | const char *name; | |||
775 | ||||
776 | if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "z:set_error_name", &name)) { | |||
777 | return NULL((void*)0); | |||
778 | } | |||
779 | if (!self->msg) return DBusPy_RaiseUnusableMessage(); | |||
780 | if (!dbus_py_validate_error_namedbus_py_validate_interface_name(name)) return NULL((void*)0); | |||
781 | if (!dbus_message_set_error_name(self->msg, name)) return PyErr_NoMemory(); | |||
782 | Py_RETURN_NONEreturn _Py_INCREF(((PyObject*)((&_Py_NoneStruct)))), (& _Py_NoneStruct); | |||
783 | } | |||
784 | ||||
785 | static PyMethodDef Message_tp_methods[] = { | |||
786 | {"copy", (PyCFunction) (void (*)(void)) Message_copy, | |||
787 | METH_NOARGS0x0004, Message_copy__doc__}, | |||
788 | {"is_method_call", (PyCFunction) (void (*)(void)) Message_is_method_call, | |||
789 | METH_VARARGS0x0001, Message_is_method_call__doc__}, | |||
790 | {"is_signal", (PyCFunction) (void (*)(void)) Message_is_signal, | |||
791 | METH_VARARGS0x0001, Message_is_signal__doc__}, | |||
792 | {"is_error", (PyCFunction) (void (*)(void)) Message_is_error, | |||
793 | METH_VARARGS0x0001, Message_is_error__doc__}, | |||
794 | ||||
795 | {"get_args_list", (PyCFunction) (void (*)(void)) dbus_py_Message_get_args_list, | |||
796 | METH_VARARGS0x0001|METH_KEYWORDS0x0002, dbus_py_Message_get_args_list__doc__}, | |||
797 | {"guess_signature", (PyCFunction) (void (*)(void)) dbus_py_Message_guess_signature, | |||
798 | METH_VARARGS0x0001|METH_STATIC0x0020, dbus_py_Message_guess_signature__doc__}, | |||
799 | {"append", (PyCFunction) (void (*)(void)) dbus_py_Message_append, | |||
800 | METH_VARARGS0x0001|METH_KEYWORDS0x0002, dbus_py_Message_append__doc__}, | |||
801 | ||||
802 | {"get_auto_start", (PyCFunction) (void (*)(void)) Message_get_auto_start, | |||
803 | METH_NOARGS0x0004, Message_get_auto_start__doc__}, | |||
804 | {"set_auto_start", (PyCFunction) (void (*)(void)) Message_set_auto_start, | |||
805 | METH_VARARGS0x0001, Message_set_auto_start__doc__}, | |||
806 | {"get_destination", (PyCFunction) (void (*)(void)) Message_get_destination, | |||
807 | METH_NOARGS0x0004, Message_get_destination__doc__}, | |||
808 | {"set_destination", (PyCFunction) (void (*)(void)) Message_set_destination, | |||
809 | METH_VARARGS0x0001, Message_set_destination__doc__}, | |||
810 | {"has_destination", (PyCFunction) (void (*)(void)) Message_has_destination, | |||
811 | METH_VARARGS0x0001, Message_has_destination__doc__}, | |||
812 | {"get_error_name", (PyCFunction) (void (*)(void)) Message_get_error_name, | |||
813 | METH_NOARGS0x0004, Message_get_error_name__doc__}, | |||
814 | {"set_error_name", (PyCFunction) (void (*)(void)) Message_set_error_name, | |||
815 | METH_VARARGS0x0001, Message_set_error_name__doc__}, | |||
816 | {"get_interface", (PyCFunction) (void (*)(void)) Message_get_interface, | |||
817 | METH_NOARGS0x0004, Message_get_interface__doc__}, | |||
818 | {"set_interface", (PyCFunction) (void (*)(void))Message_set_interface, | |||
819 | METH_VARARGS0x0001, Message_set_interface__doc__}, | |||
820 | {"has_interface", (PyCFunction) (void (*)(void))Message_has_interface, | |||
821 | METH_VARARGS0x0001, Message_has_interface__doc__}, | |||
822 | {"get_member", (PyCFunction) (void (*)(void))Message_get_member, | |||
823 | METH_NOARGS0x0004, Message_get_member__doc__}, | |||
824 | {"set_member", (PyCFunction) (void (*)(void))Message_set_member, | |||
825 | METH_VARARGS0x0001, Message_set_member__doc__}, | |||
826 | {"has_member", (PyCFunction) (void (*)(void))Message_has_member, | |||
827 | METH_VARARGS0x0001, Message_has_member__doc__}, | |||
828 | {"get_path", (PyCFunction) (void (*)(void))Message_get_path, | |||
829 | METH_NOARGS0x0004, Message_get_path__doc__}, | |||
830 | {"get_path_decomposed", (PyCFunction) (void (*)(void))Message_get_path_decomposed, | |||
831 | METH_NOARGS0x0004, Message_get_path_decomposed__doc__}, | |||
832 | {"set_path", (PyCFunction) (void (*)(void))Message_set_path, | |||
833 | METH_VARARGS0x0001, Message_set_path__doc__}, | |||
834 | {"has_path", (PyCFunction) (void (*)(void))Message_has_path, | |||
835 | METH_VARARGS0x0001, Message_has_path__doc__}, | |||
836 | {"get_no_reply", (PyCFunction) (void (*)(void))Message_get_no_reply, | |||
837 | METH_NOARGS0x0004, Message_get_no_reply__doc__}, | |||
838 | {"set_no_reply", (PyCFunction) (void (*)(void))Message_set_no_reply, | |||
839 | METH_VARARGS0x0001, Message_set_no_reply__doc__}, | |||
840 | {"get_reply_serial", (PyCFunction) (void (*)(void))Message_get_reply_serial, | |||
841 | METH_NOARGS0x0004, Message_get_reply_serial__doc__}, | |||
842 | {"set_reply_serial", (PyCFunction) (void (*)(void))Message_set_reply_serial, | |||
843 | METH_VARARGS0x0001, Message_set_reply_serial__doc__}, | |||
844 | {"get_sender", (PyCFunction) (void (*)(void))Message_get_sender, | |||
845 | METH_NOARGS0x0004, Message_get_sender__doc__}, | |||
846 | {"set_sender", (PyCFunction) (void (*)(void))Message_set_sender, | |||
847 | METH_VARARGS0x0001, Message_set_sender__doc__}, | |||
848 | {"has_sender", (PyCFunction) (void (*)(void))Message_has_sender, | |||
849 | METH_VARARGS0x0001, Message_has_sender__doc__}, | |||
850 | {"get_serial", (PyCFunction) (void (*)(void))Message_get_serial, | |||
851 | METH_NOARGS0x0004, Message_get_serial__doc__}, | |||
852 | {"get_signature", (PyCFunction) (void (*)(void))Message_get_signature, | |||
853 | METH_NOARGS0x0004, Message_get_signature__doc__}, | |||
854 | {"has_signature", (PyCFunction) (void (*)(void))Message_has_signature, | |||
855 | METH_VARARGS0x0001, Message_has_signature__doc__}, | |||
856 | {"get_type", (PyCFunction) (void (*)(void))Message_get_type, | |||
857 | METH_NOARGS0x0004, Message_get_type__doc__}, | |||
858 | {NULL((void*)0), NULL((void*)0), 0, NULL((void*)0)} | |||
859 | }; | |||
860 | ||||
861 | static PyTypeObject MessageType = { | |||
862 | PyVarObject_HEAD_INIT(NULL, 0){ { 1, ((void*)0) }, 0 }, | |||
863 | "dbus.lowlevel.Message", /*tp_name*/ | |||
864 | sizeof(Message), /*tp_basicsize*/ | |||
865 | 0, /*tp_itemsize*/ | |||
866 | (destructor)Message_tp_dealloc, /*tp_dealloc*/ | |||
867 | 0, /*tp_print*/ | |||
868 | 0, /*tp_getattr*/ | |||
869 | 0, /*tp_setattr*/ | |||
870 | 0, /*tp_compare*/ | |||
871 | 0, /*tp_repr*/ | |||
872 | 0, /*tp_as_number*/ | |||
873 | 0, /*tp_as_sequence*/ | |||
874 | 0, /*tp_as_mapping*/ | |||
875 | 0, /*tp_hash */ | |||
876 | 0, /*tp_call*/ | |||
877 | 0, /*tp_str*/ | |||
878 | 0, /*tp_getattro*/ | |||
879 | 0, /*tp_setattro*/ | |||
880 | 0, /*tp_as_buffer*/ | |||
881 | Py_TPFLAGS_DEFAULT( 0 | (1UL << 18) | 0) | Py_TPFLAGS_BASETYPE(1UL << 10), /*tp_flags*/ | |||
882 | Message_tp_doc, /* tp_doc */ | |||
883 | 0, /* tp_traverse */ | |||
884 | 0, /* tp_clear */ | |||
885 | 0, /* tp_richcompare */ | |||
886 | 0, /* tp_weaklistoffset */ | |||
887 | 0, /* tp_iter */ | |||
888 | 0, /* tp_iternext */ | |||
889 | Message_tp_methods, /* tp_methods */ | |||
890 | 0, /* tp_members */ | |||
891 | 0, /* tp_getset */ | |||
892 | 0, /* tp_base */ | |||
893 | 0, /* tp_dict */ | |||
894 | 0, /* tp_descr_get */ | |||
895 | 0, /* tp_descr_set */ | |||
896 | 0, /* tp_dictoffset */ | |||
897 | 0, /* tp_init */ | |||
898 | 0, /* tp_alloc */ | |||
899 | Message_tp_new, /* tp_new */ | |||
900 | }; | |||
901 | ||||
902 | static PyTypeObject MethodCallMessageType = { | |||
903 | PyVarObject_HEAD_INIT(NULL, 0){ { 1, ((void*)0) }, 0 }, | |||
904 | "dbus.lowlevel.MethodCallMessage", /*tp_name*/ | |||
905 | 0, /*tp_basicsize*/ | |||
906 | 0, /*tp_itemsize*/ | |||
907 | 0, /*tp_dealloc*/ | |||
908 | 0, /*tp_print*/ | |||
909 | 0, /*tp_getattr*/ | |||
910 | 0, /*tp_setattr*/ | |||
911 | 0, /*tp_compare*/ | |||
912 | MethodCallMessage_tp_repr, /*tp_repr*/ | |||
913 | 0, /*tp_as_number*/ | |||
914 | 0, /*tp_as_sequence*/ | |||
915 | 0, /*tp_as_mapping*/ | |||
916 | 0, /*tp_hash */ | |||
917 | 0, /*tp_call*/ | |||
918 | 0, /*tp_str*/ | |||
919 | 0, /*tp_getattro*/ | |||
920 | 0, /*tp_setattro*/ | |||
921 | 0, /*tp_as_buffer*/ | |||
922 | Py_TPFLAGS_DEFAULT( 0 | (1UL << 18) | 0) | Py_TPFLAGS_BASETYPE(1UL << 10), /*tp_flags*/ | |||
923 | MethodCallMessage_tp_doc, /* tp_doc */ | |||
924 | 0, /* tp_traverse */ | |||
925 | 0, /* tp_clear */ | |||
926 | 0, /* tp_richcompare */ | |||
927 | 0, /* tp_weaklistoffset */ | |||
928 | 0, /* tp_iter */ | |||
929 | 0, /* tp_iternext */ | |||
930 | 0, /* tp_methods */ | |||
931 | 0, /* tp_members */ | |||
932 | 0, /* tp_getset */ | |||
933 | DEFERRED_ADDRESS(&MessageType)0, /* tp_base */ | |||
934 | 0, /* tp_dict */ | |||
935 | 0, /* tp_descr_get */ | |||
936 | 0, /* tp_descr_set */ | |||
937 | 0, /* tp_dictoffset */ | |||
938 | (initproc)MethodCallMessage_tp_init, /* tp_init */ | |||
939 | 0, /* tp_alloc */ | |||
940 | 0, /* tp_new */ | |||
941 | }; | |||
942 | ||||
943 | static PyTypeObject MethodReturnMessageType = { | |||
944 | PyVarObject_HEAD_INIT(NULL, 0){ { 1, ((void*)0) }, 0 }, | |||
945 | "dbus.lowlevel.MethodReturnMessage", /*tp_name*/ | |||
946 | 0, /*tp_basicsize*/ | |||
947 | 0, /*tp_itemsize*/ | |||
948 | 0, /*tp_dealloc*/ | |||
949 | 0, /*tp_print*/ | |||
950 | 0, /*tp_getattr*/ | |||
951 | 0, /*tp_setattr*/ | |||
952 | 0, /*tp_compare*/ | |||
953 | 0, /*tp_repr*/ | |||
954 | 0, /*tp_as_number*/ | |||
955 | 0, /*tp_as_sequence*/ | |||
956 | 0, /*tp_as_mapping*/ | |||
957 | 0, /*tp_hash */ | |||
958 | 0, /*tp_call*/ | |||
959 | 0, /*tp_str*/ | |||
960 | 0, /*tp_getattro*/ | |||
961 | 0, /*tp_setattro*/ | |||
962 | 0, /*tp_as_buffer*/ | |||
963 | Py_TPFLAGS_DEFAULT( 0 | (1UL << 18) | 0) | Py_TPFLAGS_BASETYPE(1UL << 10), /*tp_flags*/ | |||
964 | MethodReturnMessage_tp_doc, /* tp_doc */ | |||
965 | 0, /* tp_traverse */ | |||
966 | 0, /* tp_clear */ | |||
967 | 0, /* tp_richcompare */ | |||
968 | 0, /* tp_weaklistoffset */ | |||
969 | 0, /* tp_iter */ | |||
970 | 0, /* tp_iternext */ | |||
971 | 0, /* tp_methods */ | |||
972 | 0, /* tp_members */ | |||
973 | 0, /* tp_getset */ | |||
974 | DEFERRED_ADDRESS(&MessageType)0, /* tp_base */ | |||
975 | 0, /* tp_dict */ | |||
976 | 0, /* tp_descr_get */ | |||
977 | 0, /* tp_descr_set */ | |||
978 | 0, /* tp_dictoffset */ | |||
979 | (initproc)MethodReturnMessage_tp_init, /* tp_init */ | |||
980 | 0, /* tp_alloc */ | |||
981 | 0, /* tp_new */ | |||
982 | }; | |||
983 | ||||
984 | static PyTypeObject SignalMessageType = { | |||
985 | PyVarObject_HEAD_INIT(NULL, 0){ { 1, ((void*)0) }, 0 }, | |||
986 | "dbus.lowlevel.SignalMessage", /*tp_name*/ | |||
987 | 0, /*tp_basicsize*/ | |||
988 | 0, /*tp_itemsize*/ | |||
989 | 0, /*tp_dealloc*/ | |||
990 | 0, /*tp_print*/ | |||
991 | 0, /*tp_getattr*/ | |||
992 | 0, /*tp_setattr*/ | |||
993 | 0, /*tp_compare*/ | |||
994 | SignalMessage_tp_repr, /*tp_repr*/ | |||
995 | 0, /*tp_as_number*/ | |||
996 | 0, /*tp_as_sequence*/ | |||
997 | 0, /*tp_as_mapping*/ | |||
998 | 0, /*tp_hash */ | |||
999 | 0, /*tp_call*/ | |||
1000 | 0, /*tp_str*/ | |||
1001 | 0, /*tp_getattro*/ | |||
1002 | 0, /*tp_setattro*/ | |||
1003 | 0, /*tp_as_buffer*/ | |||
1004 | Py_TPFLAGS_DEFAULT( 0 | (1UL << 18) | 0) | Py_TPFLAGS_BASETYPE(1UL << 10), /*tp_flags*/ | |||
1005 | SignalMessage_tp_doc, /* tp_doc */ | |||
1006 | 0, /* tp_traverse */ | |||
1007 | 0, /* tp_clear */ | |||
1008 | 0, /* tp_richcompare */ | |||
1009 | 0, /* tp_weaklistoffset */ | |||
1010 | 0, /* tp_iter */ | |||
1011 | 0, /* tp_iternext */ | |||
1012 | 0, /* tp_methods */ | |||
1013 | 0, /* tp_members */ | |||
1014 | 0, /* tp_getset */ | |||
1015 | DEFERRED_ADDRESS(&MessageType)0, /* tp_base */ | |||
1016 | 0, /* tp_dict */ | |||
1017 | 0, /* tp_descr_get */ | |||
1018 | 0, /* tp_descr_set */ | |||
1019 | 0, /* tp_dictoffset */ | |||
1020 | (initproc)SignalMessage_tp_init, /* tp_init */ | |||
1021 | 0, /* tp_alloc */ | |||
1022 | 0, /* tp_new */ | |||
1023 | }; | |||
1024 | ||||
1025 | static PyTypeObject ErrorMessageType = { | |||
1026 | PyVarObject_HEAD_INIT(NULL, 0){ { 1, ((void*)0) }, 0 }, | |||
1027 | "dbus.lowlevel.ErrorMessage", /*tp_name*/ | |||
1028 | 0, /*tp_basicsize*/ | |||
1029 | 0, /*tp_itemsize*/ | |||
1030 | 0, /*tp_dealloc*/ | |||
1031 | 0, /*tp_print*/ | |||
1032 | 0, /*tp_getattr*/ | |||
1033 | 0, /*tp_setattr*/ | |||
1034 | 0, /*tp_compare*/ | |||
1035 | 0, /*tp_repr*/ | |||
1036 | 0, /*tp_as_number*/ | |||
1037 | 0, /*tp_as_sequence*/ | |||
1038 | 0, /*tp_as_mapping*/ | |||
1039 | 0, /*tp_hash */ | |||
1040 | 0, /*tp_call*/ | |||
1041 | 0, /*tp_str*/ | |||
1042 | 0, /*tp_getattro*/ | |||
1043 | 0, /*tp_setattro*/ | |||
1044 | 0, /*tp_as_buffer*/ | |||
1045 | Py_TPFLAGS_DEFAULT( 0 | (1UL << 18) | 0) | Py_TPFLAGS_BASETYPE(1UL << 10), /*tp_flags*/ | |||
1046 | ErrorMessage_tp_doc, /* tp_doc */ | |||
1047 | 0, /* tp_traverse */ | |||
1048 | 0, /* tp_clear */ | |||
1049 | 0, /* tp_richcompare */ | |||
1050 | 0, /* tp_weaklistoffset */ | |||
1051 | 0, /* tp_iter */ | |||
1052 | 0, /* tp_iternext */ | |||
1053 | 0, /* tp_methods */ | |||
1054 | 0, /* tp_members */ | |||
1055 | 0, /* tp_getset */ | |||
1056 | DEFERRED_ADDRESS(&MessageType)0, /* tp_base */ | |||
1057 | 0, /* tp_dict */ | |||
1058 | 0, /* tp_descr_get */ | |||
1059 | 0, /* tp_descr_set */ | |||
1060 | 0, /* tp_dictoffset */ | |||
1061 | (initproc)ErrorMessage_tp_init, /* tp_init */ | |||
1062 | 0, /* tp_alloc */ | |||
1063 | 0, /* tp_new */ | |||
1064 | }; | |||
1065 | ||||
1066 | dbus_bool_t | |||
1067 | dbus_py_init_message_types(void) | |||
1068 | { | |||
1069 | if (PyType_Ready(&MessageType) < 0) return 0; | |||
1070 | ||||
1071 | MethodCallMessageType.tp_base = &MessageType; | |||
1072 | if (PyType_Ready(&MethodCallMessageType) < 0) return 0; | |||
1073 | ||||
1074 | MethodReturnMessageType.tp_base = &MessageType; | |||
1075 | if (PyType_Ready(&MethodReturnMessageType) < 0) return 0; | |||
1076 | ||||
1077 | SignalMessageType.tp_base = &MessageType; | |||
1078 | if (PyType_Ready(&SignalMessageType) < 0) return 0; | |||
1079 | ||||
1080 | ErrorMessageType.tp_base = &MessageType; | |||
1081 | if (PyType_Ready(&ErrorMessageType) < 0) return 0; | |||
1082 | ||||
1083 | return 1; | |||
1084 | } | |||
1085 | ||||
1086 | dbus_bool_t | |||
1087 | dbus_py_insert_message_types(PyObject *this_module) | |||
1088 | { | |||
1089 | /* PyModule_AddObject steals a ref */ | |||
1090 | Py_INCREF (&MessageType)_Py_INCREF(((PyObject*)(&MessageType))); | |||
1091 | Py_INCREF (&MethodCallMessageType)_Py_INCREF(((PyObject*)(&MethodCallMessageType))); | |||
1092 | Py_INCREF (&MethodReturnMessageType)_Py_INCREF(((PyObject*)(&MethodReturnMessageType))); | |||
1093 | Py_INCREF (&ErrorMessageType)_Py_INCREF(((PyObject*)(&ErrorMessageType))); | |||
1094 | Py_INCREF (&SignalMessageType)_Py_INCREF(((PyObject*)(&SignalMessageType))); | |||
1095 | ||||
1096 | if (PyModule_AddObject(this_module, "Message", | |||
1097 | (PyObject *)&MessageType) < 0) return 0; | |||
1098 | ||||
1099 | if (PyModule_AddObject(this_module, "MethodCallMessage", | |||
1100 | (PyObject *)&MethodCallMessageType) < 0) return 0; | |||
1101 | ||||
1102 | if (PyModule_AddObject(this_module, "MethodReturnMessage", | |||
1103 | (PyObject *)&MethodReturnMessageType) < 0) return 0; | |||
1104 | ||||
1105 | if (PyModule_AddObject(this_module, "ErrorMessage", | |||
1106 | (PyObject *)&ErrorMessageType) < 0) return 0; | |||
1107 | ||||
1108 | if (PyModule_AddObject(this_module, "SignalMessage", | |||
1109 | (PyObject *)&SignalMessageType) < 0) return 0; | |||
1110 | ||||
1111 | return 1; | |||
1112 | } | |||
1113 | ||||
1114 | /* vim:set ft=c cino< sw=4 sts=4 et: */ |
1 | #ifndef PyUnicode_FromString |
2 | struct _object; |
3 | typedef struct _object PyObject; |
4 | PyObject* clang_analyzer_PyObject_New_Reference(); |
5 | PyObject *PyUnicode_FromString(const char *u) { |
6 | return clang_analyzer_PyObject_New_Reference(); |
7 | } |
8 | #else |
9 | #warning "API PyUnicode_FromString is defined as a macro." |
10 | #endif |