|
Packit |
130fc8 |
/* Implementation of D-Bus Message and subclasses (but see message-get-args.h
|
|
Packit |
130fc8 |
* and message-append.h for unserialization and serialization code).
|
|
Packit |
130fc8 |
*
|
|
Packit |
130fc8 |
* Copyright (C) 2006 Collabora Ltd. <http://www.collabora.co.uk/>
|
|
Packit |
130fc8 |
*
|
|
Packit |
130fc8 |
* Permission is hereby granted, free of charge, to any person
|
|
Packit |
130fc8 |
* obtaining a copy of this software and associated documentation
|
|
Packit |
130fc8 |
* files (the "Software"), to deal in the Software without
|
|
Packit |
130fc8 |
* restriction, including without limitation the rights to use, copy,
|
|
Packit |
130fc8 |
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
Packit |
130fc8 |
* of the Software, and to permit persons to whom the Software is
|
|
Packit |
130fc8 |
* furnished to do so, subject to the following conditions:
|
|
Packit |
130fc8 |
*
|
|
Packit |
130fc8 |
* The above copyright notice and this permission notice shall be
|
|
Packit |
130fc8 |
* included in all copies or substantial portions of the Software.
|
|
Packit |
130fc8 |
*
|
|
Packit |
130fc8 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
Packit |
130fc8 |
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
Packit |
130fc8 |
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
Packit |
130fc8 |
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
Packit |
130fc8 |
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
Packit |
130fc8 |
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
Packit |
130fc8 |
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
Packit |
130fc8 |
* DEALINGS IN THE SOFTWARE.
|
|
Packit |
130fc8 |
*/
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
#include "dbus_bindings-internal.h"
|
|
Packit |
130fc8 |
#include "message-internal.h"
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
static PyTypeObject MessageType, SignalMessageType, ErrorMessageType;
|
|
Packit |
130fc8 |
static PyTypeObject MethodReturnMessageType, MethodCallMessageType;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
static inline int Message_Check(PyObject *o)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
return (Py_TYPE(o) == &MessageType)
|
|
Packit |
130fc8 |
|| PyObject_IsInstance(o, (PyObject *)&MessageType);
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyObject *
|
|
Packit |
130fc8 |
DBusPy_RaiseUnusableMessage(void)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
DBusPyException_SetString("Message object is uninitialized, or has become "
|
|
Packit |
130fc8 |
"unusable due to error while appending "
|
|
Packit |
130fc8 |
"arguments");
|
|
Packit |
130fc8 |
return NULL;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(Message_tp_doc,
|
|
Packit |
130fc8 |
"A message to be sent or received over a D-Bus Connection.\n");
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
static void Message_tp_dealloc(Message *self)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
if (self->msg) {
|
|
Packit |
130fc8 |
dbus_message_unref(self->msg);
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
Py_TYPE(self)->tp_free((PyObject *)self);
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
Message_tp_new(PyTypeObject *type,
|
|
Packit |
130fc8 |
PyObject *args UNUSED,
|
|
Packit |
130fc8 |
PyObject *kwargs UNUSED)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
Message *self;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
self = (Message *)type->tp_alloc(type, 0);
|
|
Packit |
130fc8 |
if (!self) return NULL;
|
|
Packit |
130fc8 |
self->msg = NULL;
|
|
Packit |
130fc8 |
return (PyObject *)self;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
MethodCallMessage_tp_repr(PyObject *self)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
DBusMessage *msg = ((Message *)self)->msg;
|
|
Packit |
130fc8 |
const char *destination = dbus_message_get_destination(msg);
|
|
Packit |
130fc8 |
const char *path = dbus_message_get_path(msg);
|
|
Packit |
130fc8 |
const char *interface = dbus_message_get_interface(msg);
|
|
Packit |
130fc8 |
const char *member = dbus_message_get_member(msg);
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (!path)
|
|
Packit |
130fc8 |
path = "n/a";
|
|
Packit |
130fc8 |
if (!interface)
|
|
Packit |
130fc8 |
interface = "n/a";
|
|
Packit |
130fc8 |
if (!member)
|
|
Packit |
130fc8 |
member = "n/a";
|
|
Packit |
130fc8 |
if (!destination)
|
|
Packit |
130fc8 |
destination = "n/a";
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
return PyUnicode_FromFormat(
|
|
Packit |
130fc8 |
"<%s path: %s, iface: %s, member: %s dest: %s>",
|
|
Packit |
130fc8 |
Py_TYPE(self)->tp_name,
|
|
Packit |
130fc8 |
path, interface, member, destination);
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(MethodCallMessage_tp_doc, "A method-call message.\n"
|
|
Packit |
130fc8 |
"\n"
|
|
Packit |
130fc8 |
"Constructor::\n"
|
|
Packit |
130fc8 |
"\n"
|
|
Packit |
130fc8 |
" dbus.lowlevel.MethodCallMessage(destination: str or None, path: str,\n"
|
|
Packit |
130fc8 |
" interface: str or None, method: str)\n"
|
|
Packit |
130fc8 |
"\n"
|
|
Packit |
130fc8 |
"``destination`` is the destination bus name, or None to send the\n"
|
|
Packit |
130fc8 |
"message directly to the peer (usually the bus daemon).\n"
|
|
Packit |
130fc8 |
"\n"
|
|
Packit |
130fc8 |
"``path`` is the object-path of the object whose method is to be called.\n"
|
|
Packit |
130fc8 |
"\n"
|
|
Packit |
130fc8 |
"``interface`` is the interface qualifying the method name, or None to omit\n"
|
|
Packit |
130fc8 |
"the interface from the message header.\n"
|
|
Packit |
130fc8 |
"\n"
|
|
Packit |
130fc8 |
"``method`` is the method name (member name).\n"
|
|
Packit |
130fc8 |
);
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
static int
|
|
Packit |
130fc8 |
MethodCallMessage_tp_init(Message *self, PyObject *args, PyObject *kwargs)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
const char *destination, *path, *interface, *method;
|
|
Packit |
130fc8 |
static char *kwlist[] = {"destination", "path", "interface", "method", NULL};
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "zszs:__init__", kwlist,
|
|
Packit |
130fc8 |
&destination, &path, &interface,
|
|
Packit |
130fc8 |
&method)) {
|
|
Packit |
130fc8 |
return -1;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
if (destination && !dbus_py_validate_bus_name(destination, 1, 1)) return -1;
|
|
Packit |
130fc8 |
if (!dbus_py_validate_object_path(path)) return -1;
|
|
Packit |
130fc8 |
if (interface && !dbus_py_validate_interface_name(interface)) return -1;
|
|
Packit |
130fc8 |
if (!dbus_py_validate_member_name(method)) return -1;
|
|
Packit |
130fc8 |
if (self->msg) {
|
|
Packit |
130fc8 |
dbus_message_unref(self->msg);
|
|
Packit |
130fc8 |
self->msg = NULL;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
self->msg = dbus_message_new_method_call(destination, path, interface,
|
|
Packit |
130fc8 |
method);
|
|
Packit |
130fc8 |
if (!self->msg) {
|
|
Packit |
130fc8 |
PyErr_NoMemory();
|
|
Packit |
130fc8 |
return -1;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
return 0;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(MethodReturnMessage_tp_doc, "A method-return message.\n\n"
|
|
Packit |
130fc8 |
"Constructor::\n\n"
|
|
Packit |
130fc8 |
" dbus.lowlevel.MethodReturnMessage(method_call: MethodCallMessage)\n");
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
static int
|
|
Packit |
130fc8 |
MethodReturnMessage_tp_init(Message *self, PyObject *args, PyObject *kwargs)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
Message *other;
|
|
Packit |
130fc8 |
static char *kwlist[] = {"method_call", NULL};
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!:__init__", kwlist,
|
|
Packit |
130fc8 |
&MessageType, &other)) {
|
|
Packit |
130fc8 |
return -1;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
if (self->msg) {
|
|
Packit |
130fc8 |
dbus_message_unref(self->msg);
|
|
Packit |
130fc8 |
self->msg = NULL;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
self->msg = dbus_message_new_method_return(other->msg);
|
|
Packit |
130fc8 |
if (!self->msg) {
|
|
Packit |
130fc8 |
PyErr_NoMemory();
|
|
Packit |
130fc8 |
return -1;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
return 0;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(SignalMessage_tp_doc, "A signal message.\n\n"
|
|
Packit |
130fc8 |
"Constructor::\n\n"
|
|
Packit |
130fc8 |
" dbus.lowlevel.SignalMessage(path: str, interface: str, method: str)\n");
|
|
Packit |
130fc8 |
static int
|
|
Packit |
130fc8 |
SignalMessage_tp_init(Message *self, PyObject *args, PyObject *kwargs)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
const char *path, *interface, *name;
|
|
Packit |
130fc8 |
static char *kwlist[] = {"path", "interface", "name", NULL};
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sss:__init__", kwlist,
|
|
Packit |
130fc8 |
&path, &interface, &name)) {
|
|
Packit |
130fc8 |
return -1;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
if (!dbus_py_validate_object_path(path)) return -1;
|
|
Packit |
130fc8 |
if (!dbus_py_validate_interface_name(interface)) return -1;
|
|
Packit |
130fc8 |
if (!dbus_py_validate_member_name(name)) return -1;
|
|
Packit |
130fc8 |
if (self->msg) {
|
|
Packit |
130fc8 |
dbus_message_unref(self->msg);
|
|
Packit |
130fc8 |
self->msg = NULL;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
self->msg = dbus_message_new_signal(path, interface, name);
|
|
Packit |
130fc8 |
if (!self->msg) {
|
|
Packit |
130fc8 |
PyErr_NoMemory();
|
|
Packit |
130fc8 |
return -1;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
return 0;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
SignalMessage_tp_repr(PyObject *self)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
DBusMessage *msg = ((Message *)self)->msg;
|
|
Packit |
130fc8 |
const char *path = dbus_message_get_path(msg);
|
|
Packit |
130fc8 |
const char *interface = dbus_message_get_interface(msg);
|
|
Packit |
130fc8 |
const char *member = dbus_message_get_member(msg);
|
|
Packit |
130fc8 |
const char *destination = dbus_message_get_destination(msg);
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (!path)
|
|
Packit |
130fc8 |
path = "n/a";
|
|
Packit |
130fc8 |
if (!interface)
|
|
Packit |
130fc8 |
interface = "n/a";
|
|
Packit |
130fc8 |
if (!member)
|
|
Packit |
130fc8 |
member = "n/a";
|
|
Packit |
130fc8 |
if (!destination)
|
|
Packit |
130fc8 |
destination = "(broadcast)";
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
return PyUnicode_FromFormat("<%s path: %s, iface: %s, member: %s, dest: %s>",
|
|
Packit |
130fc8 |
Py_TYPE(self)->tp_name,
|
|
Packit |
130fc8 |
path, interface, member, destination);
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(ErrorMessage_tp_doc, "An error message.\n\n"
|
|
Packit |
130fc8 |
"Constructor::\n\n"
|
|
Packit |
130fc8 |
" dbus.lowlevel.ErrorMessage(reply_to: Message, error_name: str,\n"
|
|
Packit |
130fc8 |
" error_message: str or None)\n");
|
|
Packit |
130fc8 |
static int
|
|
Packit |
130fc8 |
ErrorMessage_tp_init(Message *self, PyObject *args, PyObject *kwargs)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
Message *reply_to;
|
|
Packit |
130fc8 |
const char *error_name, *error_message;
|
|
Packit |
130fc8 |
static char *kwlist[] = {"reply_to", "error_name", "error_message", NULL};
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!sz:__init__", kwlist,
|
|
Packit |
130fc8 |
&MessageType, &reply_to, &error_name,
|
|
Packit |
130fc8 |
&error_message)) {
|
|
Packit |
130fc8 |
return -1;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
if (!dbus_py_validate_error_name(error_name)) return -1;
|
|
Packit |
130fc8 |
if (self->msg) {
|
|
Packit |
130fc8 |
dbus_message_unref(self->msg);
|
|
Packit |
130fc8 |
self->msg = NULL;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
self->msg = dbus_message_new_error(reply_to->msg, error_name, error_message);
|
|
Packit |
130fc8 |
if (!self->msg) {
|
|
Packit |
130fc8 |
PyErr_NoMemory();
|
|
Packit |
130fc8 |
return -1;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
return 0;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
DBusMessage *
|
|
Packit |
130fc8 |
DBusPyMessage_BorrowDBusMessage(PyObject *msg)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
if (!Message_Check(msg)) {
|
|
Packit |
130fc8 |
PyErr_SetString(PyExc_TypeError,
|
|
Packit |
130fc8 |
"A dbus.lowlevel.Message instance is required");
|
|
Packit |
130fc8 |
return NULL;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
if (!((Message *)msg)->msg) {
|
|
Packit |
130fc8 |
DBusPy_RaiseUnusableMessage();
|
|
Packit |
130fc8 |
return NULL;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
return ((Message *)msg)->msg;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyObject *
|
|
Packit |
130fc8 |
DBusPyMessage_ConsumeDBusMessage(DBusMessage *msg)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
PyTypeObject *type;
|
|
Packit |
130fc8 |
Message *self;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
switch (dbus_message_get_type(msg)) {
|
|
Packit |
130fc8 |
case DBUS_MESSAGE_TYPE_METHOD_CALL:
|
|
Packit |
130fc8 |
type = &MethodCallMessageType;
|
|
Packit |
130fc8 |
break;
|
|
Packit |
130fc8 |
case DBUS_MESSAGE_TYPE_METHOD_RETURN:
|
|
Packit |
130fc8 |
type = &MethodReturnMessageType;
|
|
Packit |
130fc8 |
break;
|
|
Packit |
130fc8 |
case DBUS_MESSAGE_TYPE_ERROR:
|
|
Packit |
130fc8 |
type = &ErrorMessageType;
|
|
Packit |
130fc8 |
break;
|
|
Packit |
130fc8 |
case DBUS_MESSAGE_TYPE_SIGNAL:
|
|
Packit |
130fc8 |
type = &SignalMessageType;
|
|
Packit |
130fc8 |
break;
|
|
Packit |
130fc8 |
default:
|
|
Packit |
130fc8 |
type = &MessageType;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
self = (Message *)(type->tp_new) (type, dbus_py_empty_tuple, NULL);
|
|
Packit |
130fc8 |
if (!self) {
|
|
Packit |
130fc8 |
dbus_message_unref(msg);
|
|
Packit |
130fc8 |
return NULL;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
self->msg = msg;
|
|
Packit |
130fc8 |
return (PyObject *)self;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(Message_copy__doc__,
|
|
Packit |
130fc8 |
"message.copy() -> Message (or subclass)\n"
|
|
Packit |
130fc8 |
"Deep-copy the message, resetting the serial number to zero.\n");
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
Message_copy(Message *self, PyObject *args UNUSED)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
DBusMessage *msg;
|
|
Packit |
130fc8 |
if (!self->msg) return DBusPy_RaiseUnusableMessage();
|
|
Packit |
130fc8 |
msg = dbus_message_copy(self->msg);
|
|
Packit |
130fc8 |
if (!msg) return PyErr_NoMemory();
|
|
Packit |
130fc8 |
return DBusPyMessage_ConsumeDBusMessage(msg);
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(Message_get_auto_start__doc__,
|
|
Packit |
130fc8 |
"message.get_auto_start() -> bool\n"
|
|
Packit |
130fc8 |
"Return true if this message will cause an owner for the destination name\n"
|
|
Packit |
130fc8 |
"to be auto-started.\n");
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
Message_get_auto_start(Message *self, PyObject *unused UNUSED)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
if (!self->msg) return DBusPy_RaiseUnusableMessage();
|
|
Packit |
130fc8 |
return PyBool_FromLong(dbus_message_get_auto_start(self->msg));
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(Message_set_auto_start__doc__,
|
|
Packit |
130fc8 |
"message.set_auto_start(bool) -> None\n"
|
|
Packit |
130fc8 |
"Set whether this message will cause an owner for the destination name\n"
|
|
Packit |
130fc8 |
"to be auto-started.\n");
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
Message_set_auto_start(Message *self, PyObject *args)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
int value;
|
|
Packit |
130fc8 |
if (!PyArg_ParseTuple(args, "i", &value)) return NULL;
|
|
Packit |
130fc8 |
if (!self->msg) return DBusPy_RaiseUnusableMessage();
|
|
Packit |
130fc8 |
dbus_message_set_auto_start(self->msg, value ? TRUE : FALSE);
|
|
Packit |
130fc8 |
Py_INCREF(Py_None);
|
|
Packit |
130fc8 |
return Py_None;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(Message_get_no_reply__doc__,
|
|
Packit |
130fc8 |
"message.get_no_reply() -> bool\n"
|
|
Packit |
130fc8 |
"Return true if this message need not be replied to.\n");
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
Message_get_no_reply(Message *self, PyObject *unused UNUSED)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
if (!self->msg) return DBusPy_RaiseUnusableMessage();
|
|
Packit |
130fc8 |
return PyBool_FromLong(dbus_message_get_no_reply(self->msg));
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(Message_set_no_reply__doc__,
|
|
Packit |
130fc8 |
"message.set_no_reply(bool) -> None\n"
|
|
Packit |
130fc8 |
"Set whether no reply to this message is required.\n");
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
Message_set_no_reply(Message *self, PyObject *args)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
int value;
|
|
Packit |
130fc8 |
if (!PyArg_ParseTuple(args, "i", &value)) return NULL;
|
|
Packit |
130fc8 |
if (!self->msg) return DBusPy_RaiseUnusableMessage();
|
|
Packit |
130fc8 |
dbus_message_set_no_reply(self->msg, value ? TRUE : FALSE);
|
|
Packit |
130fc8 |
Py_RETURN_NONE;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(Message_get_reply_serial__doc__,
|
|
Packit |
130fc8 |
"message.get_reply_serial() -> long\n"
|
|
Packit |
130fc8 |
"Returns the serial that the message is a reply to or 0 if none.\n");
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
Message_get_reply_serial(Message *self, PyObject *unused UNUSED)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
if (!self->msg) return DBusPy_RaiseUnusableMessage();
|
|
Packit |
130fc8 |
return PyLong_FromUnsignedLong(dbus_message_get_reply_serial(self->msg));
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(Message_set_reply_serial__doc__,
|
|
Packit |
130fc8 |
"message.set_reply_serial(bool) -> None\n"
|
|
Packit |
130fc8 |
"Set the serial that this message is a reply to.\n");
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
Message_set_reply_serial(Message *self, PyObject *args)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
dbus_uint32_t value;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (!PyArg_ParseTuple(args, "k", &value)) return NULL;
|
|
Packit |
130fc8 |
if (!self->msg) return DBusPy_RaiseUnusableMessage();
|
|
Packit |
130fc8 |
if (!dbus_message_set_reply_serial(self->msg, value)) {
|
|
Packit |
130fc8 |
return PyErr_NoMemory();
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
Py_INCREF(Py_None);
|
|
Packit |
130fc8 |
return Py_None;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(Message_get_type__doc__,
|
|
Packit |
130fc8 |
"message.get_type() -> int\n\n"
|
|
Packit |
130fc8 |
"Returns the type of the message.\n");
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
Message_get_type(Message *self, PyObject *unused UNUSED)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
if (!self->msg) return DBusPy_RaiseUnusableMessage();
|
|
Packit |
130fc8 |
return NATIVEINT_FROMLONG(dbus_message_get_type(self->msg));
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(Message_get_serial__doc__,
|
|
Packit |
130fc8 |
"message.get_serial() -> long\n"
|
|
Packit |
130fc8 |
"Returns the serial of a message or 0 if none has been specified.\n"
|
|
Packit |
130fc8 |
"\n"
|
|
Packit |
130fc8 |
"The message's serial number is provided by the application sending the\n"
|
|
Packit |
130fc8 |
"message and is used to identify replies to this message. All messages\n"
|
|
Packit |
130fc8 |
"received on a connection will have a serial, but messages you haven't\n"
|
|
Packit |
130fc8 |
"sent yet may return 0.\n");
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
Message_get_serial(Message *self, PyObject *unused UNUSED)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
if (!self->msg) return DBusPy_RaiseUnusableMessage();
|
|
Packit |
130fc8 |
return PyLong_FromUnsignedLong(dbus_message_get_serial(self->msg));
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(Message_is_method_call__doc__,
|
|
Packit |
130fc8 |
"is_method_call(interface: str, member: str) -> bool");
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
Message_is_method_call(Message *self, PyObject *args)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
const char *interface, *method;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (!PyArg_ParseTuple(args, "ss:is_method_call", &interface, &method)) {
|
|
Packit |
130fc8 |
return NULL;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
if (!self->msg) return DBusPy_RaiseUnusableMessage();
|
|
Packit |
130fc8 |
return PyBool_FromLong(dbus_message_is_method_call(self->msg, interface,
|
|
Packit |
130fc8 |
method));
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(Message_is_error__doc__,
|
|
Packit |
130fc8 |
"is_error(error: str) -> bool");
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
Message_is_error(Message *self, PyObject *args)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
const char *error_name;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (!PyArg_ParseTuple(args, "s:is_error", &error_name)) {
|
|
Packit |
130fc8 |
return NULL;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
if (!self->msg) return DBusPy_RaiseUnusableMessage();
|
|
Packit |
130fc8 |
return PyBool_FromLong(dbus_message_is_error(self->msg, error_name));
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(Message_is_signal__doc__,
|
|
Packit |
130fc8 |
"is_signal(interface: str, member: str) -> bool");
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
Message_is_signal(Message *self, PyObject *args)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
const char *interface, *signal_name;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (!PyArg_ParseTuple(args, "ss:is_signal", &interface, &signal_name)) {
|
|
Packit |
130fc8 |
return NULL;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
if (!self->msg) return DBusPy_RaiseUnusableMessage();
|
|
Packit |
130fc8 |
return PyBool_FromLong(dbus_message_is_signal(self->msg, interface,
|
|
Packit |
130fc8 |
signal_name));
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(Message_get_member__doc__,
|
|
Packit |
130fc8 |
"get_member() -> str or None");
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
Message_get_member(Message *self, PyObject *unused UNUSED)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
const char *c_str;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (!self->msg) return DBusPy_RaiseUnusableMessage();
|
|
Packit |
130fc8 |
c_str = dbus_message_get_member(self->msg);
|
|
Packit |
130fc8 |
if (!c_str) {
|
|
Packit |
130fc8 |
Py_RETURN_NONE;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
return NATIVESTR_FROMSTR(c_str);
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(Message_has_member__doc__,
|
|
Packit |
130fc8 |
"has_member(name: str or None) -> bool");
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
Message_has_member(Message *self, PyObject *args)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
const char *name;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (!PyArg_ParseTuple(args, "z:has_member", &name)) {
|
|
Packit |
130fc8 |
return NULL;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
if (!self->msg) return DBusPy_RaiseUnusableMessage();
|
|
Packit |
130fc8 |
return PyBool_FromLong(dbus_message_has_member(self->msg, name));
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(Message_set_member__doc__,
|
|
Packit |
130fc8 |
"set_member(unique_name: str or None)");
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
Message_set_member(Message *self, PyObject *args)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
const char *name;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (!PyArg_ParseTuple(args, "z:set_member", &name)) {
|
|
Packit |
130fc8 |
return NULL;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
if (!self->msg) return DBusPy_RaiseUnusableMessage();
|
|
Packit |
130fc8 |
if (!dbus_py_validate_member_name(name)) return NULL;
|
|
Packit |
130fc8 |
if (!dbus_message_set_member(self->msg, name)) return PyErr_NoMemory();
|
|
Packit |
130fc8 |
Py_RETURN_NONE;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(Message_get_path__doc__,
|
|
Packit |
130fc8 |
"get_path() -> ObjectPath or None\n\n"
|
|
Packit |
130fc8 |
"Return the message's destination object path (if it's a method call) or\n"
|
|
Packit |
130fc8 |
"source object path (if it's a method reply or a signal) or None (if it\n"
|
|
Packit |
130fc8 |
"has no path).\n");
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
Message_get_path(Message *self, PyObject *unused UNUSED)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
const char *c_str;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (!self->msg) return DBusPy_RaiseUnusableMessage();
|
|
Packit |
130fc8 |
c_str = dbus_message_get_path(self->msg);
|
|
Packit |
130fc8 |
if (!c_str) {
|
|
Packit |
130fc8 |
Py_RETURN_NONE;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
return PyObject_CallFunction((PyObject *)&DBusPyObjectPath_Type, "(s)", c_str);
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(Message_get_path_decomposed__doc__,
|
|
Packit |
130fc8 |
"get_path_decomposed() -> list of str, or None\n\n"
|
|
Packit |
130fc8 |
"Return a list of path components (e.g. /foo/bar -> ['foo','bar'], / -> [])\n"
|
|
Packit |
130fc8 |
"or None if the message has no associated path.\n");
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
Message_get_path_decomposed(Message *self, PyObject *unused UNUSED)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
char **paths, **ptr;
|
|
Packit |
130fc8 |
PyObject *ret = PyList_New(0);
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (!ret) return NULL;
|
|
Packit |
130fc8 |
if (!self->msg) {
|
|
Packit |
130fc8 |
Py_CLEAR(ret);
|
|
Packit |
130fc8 |
return DBusPy_RaiseUnusableMessage();
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
if (!dbus_message_get_path_decomposed(self->msg, &paths)) {
|
|
Packit |
130fc8 |
Py_CLEAR(ret);
|
|
Packit |
130fc8 |
return PyErr_NoMemory();
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
if (!paths) {
|
|
Packit |
130fc8 |
Py_CLEAR(ret);
|
|
Packit |
130fc8 |
Py_RETURN_NONE;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
for (ptr = paths; *ptr; ptr++) {
|
|
Packit |
130fc8 |
PyObject *str = NATIVESTR_FROMSTR(*ptr);
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (!str) {
|
|
Packit |
130fc8 |
Py_CLEAR(ret);
|
|
Packit |
130fc8 |
break;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
if (PyList_Append(ret, str) < 0) {
|
|
Packit |
130fc8 |
Py_CLEAR(ret);
|
|
Packit |
130fc8 |
break;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
Py_CLEAR(str);
|
|
Packit |
130fc8 |
str = NULL;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
dbus_free_string_array(paths);
|
|
Packit |
130fc8 |
return ret;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(Message_has_path__doc__,
|
|
Packit |
130fc8 |
"has_path(name: str or None) -> bool");
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
Message_has_path(Message *self, PyObject *args)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
const char *name;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (!PyArg_ParseTuple(args, "z:has_path", &name)) {
|
|
Packit |
130fc8 |
return NULL;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
if (!self->msg) return DBusPy_RaiseUnusableMessage();
|
|
Packit |
130fc8 |
return PyBool_FromLong(dbus_message_has_path(self->msg, name));
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(Message_set_path__doc__,
|
|
Packit |
130fc8 |
"set_path(name: str or None)");
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
Message_set_path(Message *self, PyObject *args)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
const char *name;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (!PyArg_ParseTuple(args, "z:set_path", &name)) return NULL;
|
|
Packit |
130fc8 |
if (!self->msg) return DBusPy_RaiseUnusableMessage();
|
|
Packit |
130fc8 |
if (!dbus_message_has_path(self->msg, name)) return PyErr_NoMemory();
|
|
Packit |
130fc8 |
Py_RETURN_NONE;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(Message_get_signature__doc__,
|
|
Packit |
130fc8 |
"get_signature() -> Signature or None");
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
Message_get_signature(Message *self, PyObject *unused UNUSED)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
const char *c_str;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (!self->msg) return DBusPy_RaiseUnusableMessage();
|
|
Packit |
130fc8 |
c_str = dbus_message_get_signature(self->msg);
|
|
Packit |
130fc8 |
if (!c_str) {
|
|
Packit |
130fc8 |
return PyObject_CallFunction((PyObject *)&DBusPySignature_Type, "(s)", "");
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
return PyObject_CallFunction((PyObject *)&DBusPySignature_Type, "(s)", c_str);
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(Message_has_signature__doc__,
|
|
Packit |
130fc8 |
"has_signature(signature: str) -> bool");
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
Message_has_signature(Message *self, PyObject *args)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
const char *name;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (!PyArg_ParseTuple(args, "s:has_signature", &name)) {
|
|
Packit |
130fc8 |
return NULL;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
if (!self->msg) return DBusPy_RaiseUnusableMessage();
|
|
Packit |
130fc8 |
return PyBool_FromLong(dbus_message_has_signature(self->msg, name));
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(Message_get_sender__doc__,
|
|
Packit |
130fc8 |
"get_sender() -> str or None\n\n"
|
|
Packit |
130fc8 |
"Return the message's sender unique name, or None if none.\n");
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
Message_get_sender(Message *self, PyObject *unused UNUSED)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
const char *c_str;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (!self->msg) return DBusPy_RaiseUnusableMessage();
|
|
Packit |
130fc8 |
c_str = dbus_message_get_sender(self->msg);
|
|
Packit |
130fc8 |
if (!c_str) {
|
|
Packit |
130fc8 |
Py_RETURN_NONE;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
return NATIVESTR_FROMSTR(c_str);
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(Message_has_sender__doc__,
|
|
Packit |
130fc8 |
"has_sender(unique_name: str) -> bool");
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
Message_has_sender(Message *self, PyObject *args)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
const char *name;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (!PyArg_ParseTuple(args, "s:has_sender", &name)) {
|
|
Packit |
130fc8 |
return NULL;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
if (!self->msg) return DBusPy_RaiseUnusableMessage();
|
|
Packit |
130fc8 |
return PyBool_FromLong(dbus_message_has_sender(self->msg, name));
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(Message_set_sender__doc__,
|
|
Packit |
130fc8 |
"set_sender(unique_name: str or None)");
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
Message_set_sender(Message *self, PyObject *args)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
const char *name;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (!PyArg_ParseTuple(args, "z:set_sender", &name)) {
|
|
Packit |
130fc8 |
return NULL;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
if (!self->msg) return DBusPy_RaiseUnusableMessage();
|
|
Packit |
130fc8 |
if (!dbus_py_validate_bus_name(name, 1, 1)) return NULL;
|
|
Packit |
130fc8 |
if (!dbus_message_set_sender(self->msg, name)) return PyErr_NoMemory();
|
|
Packit |
130fc8 |
Py_RETURN_NONE;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(Message_get_destination__doc__,
|
|
Packit |
130fc8 |
"get_destination() -> str or None\n\n"
|
|
Packit |
130fc8 |
"Return the message's destination bus name, or None if none.\n");
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
Message_get_destination(Message *self, PyObject *unused UNUSED)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
const char *c_str;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (!self->msg) return DBusPy_RaiseUnusableMessage();
|
|
Packit |
130fc8 |
c_str = dbus_message_get_destination(self->msg);
|
|
Packit |
130fc8 |
if (!c_str) {
|
|
Packit |
130fc8 |
Py_RETURN_NONE;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
return NATIVESTR_FROMSTR(c_str);
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(Message_has_destination__doc__,
|
|
Packit |
130fc8 |
"has_destination(bus_name: str) -> bool");
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
Message_has_destination(Message *self, PyObject *args)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
const char *name;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (!PyArg_ParseTuple(args, "s:has_destination", &name)) {
|
|
Packit |
130fc8 |
return NULL;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
if (!self->msg) return DBusPy_RaiseUnusableMessage();
|
|
Packit |
130fc8 |
return PyBool_FromLong(dbus_message_has_destination(self->msg, name));
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(Message_set_destination__doc__,
|
|
Packit |
130fc8 |
"set_destination(bus_name: str or None)");
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
Message_set_destination(Message *self, PyObject *args)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
const char *name;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (!PyArg_ParseTuple(args, "z:set_destination", &name)) {
|
|
Packit |
130fc8 |
return NULL;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
if (!self->msg) return DBusPy_RaiseUnusableMessage();
|
|
Packit |
130fc8 |
if (!dbus_py_validate_bus_name(name, 1, 1)) return NULL;
|
|
Packit |
130fc8 |
if (!dbus_message_set_destination(self->msg, name)) return PyErr_NoMemory();
|
|
Packit |
130fc8 |
Py_RETURN_NONE;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(Message_get_interface__doc__,
|
|
Packit |
130fc8 |
"get_interface() -> str or None");
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
Message_get_interface(Message *self, PyObject *unused UNUSED)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
const char *c_str;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (!self->msg) return DBusPy_RaiseUnusableMessage();
|
|
Packit |
130fc8 |
c_str = dbus_message_get_interface(self->msg);
|
|
Packit |
130fc8 |
if (!c_str) {
|
|
Packit |
130fc8 |
Py_RETURN_NONE;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
return NATIVESTR_FROMSTR(c_str);
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(Message_has_interface__doc__,
|
|
Packit |
130fc8 |
"has_interface(interface: str or None) -> bool");
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
Message_has_interface(Message *self, PyObject *args)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
const char *name;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (!PyArg_ParseTuple(args, "z:has_interface", &name)) {
|
|
Packit |
130fc8 |
return NULL;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
if (!self->msg) return DBusPy_RaiseUnusableMessage();
|
|
Packit |
130fc8 |
return PyBool_FromLong(dbus_message_has_interface(self->msg, name));
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(Message_set_interface__doc__,
|
|
Packit |
130fc8 |
"set_interface(name: str or None)");
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
Message_set_interface(Message *self, PyObject *args)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
const char *name;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (!PyArg_ParseTuple(args, "z:set_interface", &name)) {
|
|
Packit |
130fc8 |
return NULL;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
if (!self->msg) return DBusPy_RaiseUnusableMessage();
|
|
Packit |
130fc8 |
if (!dbus_py_validate_interface_name(name)) return NULL;
|
|
Packit |
130fc8 |
if (!dbus_message_set_interface(self->msg, name)) return PyErr_NoMemory();
|
|
Packit |
130fc8 |
Py_RETURN_NONE;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(Message_get_error_name__doc__,
|
|
Packit |
130fc8 |
"get_error_name() -> str or None");
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
Message_get_error_name(Message *self, PyObject *unused UNUSED)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
const char *c_str;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (!self->msg) return DBusPy_RaiseUnusableMessage();
|
|
Packit |
130fc8 |
c_str = dbus_message_get_error_name(self->msg);
|
|
Packit |
130fc8 |
if (!c_str) {
|
|
Packit |
130fc8 |
Py_RETURN_NONE;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
return NATIVESTR_FROMSTR(c_str);
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(Message_set_error_name__doc__,
|
|
Packit |
130fc8 |
"set_error_name(name: str or None)");
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
Message_set_error_name(Message *self, PyObject *args)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
const char *name;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (!PyArg_ParseTuple(args, "z:set_error_name", &name)) {
|
|
Packit |
130fc8 |
return NULL;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
if (!self->msg) return DBusPy_RaiseUnusableMessage();
|
|
Packit |
130fc8 |
if (!dbus_py_validate_error_name(name)) return NULL;
|
|
Packit |
130fc8 |
if (!dbus_message_set_error_name(self->msg, name)) return PyErr_NoMemory();
|
|
Packit |
130fc8 |
Py_RETURN_NONE;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
static PyMethodDef Message_tp_methods[] = {
|
|
Packit |
130fc8 |
{"copy", (PyCFunction)Message_copy,
|
|
Packit |
130fc8 |
METH_NOARGS, Message_copy__doc__},
|
|
Packit |
130fc8 |
{"is_method_call", (PyCFunction)Message_is_method_call,
|
|
Packit |
130fc8 |
METH_VARARGS, Message_is_method_call__doc__},
|
|
Packit |
130fc8 |
{"is_signal", (PyCFunction)Message_is_signal,
|
|
Packit |
130fc8 |
METH_VARARGS, Message_is_signal__doc__},
|
|
Packit |
130fc8 |
{"is_error", (PyCFunction)Message_is_error,
|
|
Packit |
130fc8 |
METH_VARARGS, Message_is_error__doc__},
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
{"get_args_list", (PyCFunction)dbus_py_Message_get_args_list,
|
|
Packit |
130fc8 |
METH_VARARGS|METH_KEYWORDS, dbus_py_Message_get_args_list__doc__},
|
|
Packit |
130fc8 |
{"guess_signature", (PyCFunction)dbus_py_Message_guess_signature,
|
|
Packit |
130fc8 |
METH_VARARGS|METH_STATIC, dbus_py_Message_guess_signature__doc__},
|
|
Packit |
130fc8 |
{"append", (PyCFunction)dbus_py_Message_append,
|
|
Packit |
130fc8 |
METH_VARARGS|METH_KEYWORDS, dbus_py_Message_append__doc__},
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
{"get_auto_start", (PyCFunction)Message_get_auto_start,
|
|
Packit |
130fc8 |
METH_NOARGS, Message_get_auto_start__doc__},
|
|
Packit |
130fc8 |
{"set_auto_start", (PyCFunction)Message_set_auto_start,
|
|
Packit |
130fc8 |
METH_VARARGS, Message_set_auto_start__doc__},
|
|
Packit |
130fc8 |
{"get_destination", (PyCFunction)Message_get_destination,
|
|
Packit |
130fc8 |
METH_NOARGS, Message_get_destination__doc__},
|
|
Packit |
130fc8 |
{"set_destination", (PyCFunction)Message_set_destination,
|
|
Packit |
130fc8 |
METH_VARARGS, Message_set_destination__doc__},
|
|
Packit |
130fc8 |
{"has_destination", (PyCFunction)Message_has_destination,
|
|
Packit |
130fc8 |
METH_VARARGS, Message_has_destination__doc__},
|
|
Packit |
130fc8 |
{"get_error_name", (PyCFunction)Message_get_error_name,
|
|
Packit |
130fc8 |
METH_NOARGS, Message_get_error_name__doc__},
|
|
Packit |
130fc8 |
{"set_error_name", (PyCFunction)Message_set_error_name,
|
|
Packit |
130fc8 |
METH_VARARGS, Message_set_error_name__doc__},
|
|
Packit |
130fc8 |
{"get_interface", (PyCFunction)Message_get_interface,
|
|
Packit |
130fc8 |
METH_NOARGS, Message_get_interface__doc__},
|
|
Packit |
130fc8 |
{"set_interface", (PyCFunction)Message_set_interface,
|
|
Packit |
130fc8 |
METH_VARARGS, Message_set_interface__doc__},
|
|
Packit |
130fc8 |
{"has_interface", (PyCFunction)Message_has_interface,
|
|
Packit |
130fc8 |
METH_VARARGS, Message_has_interface__doc__},
|
|
Packit |
130fc8 |
{"get_member", (PyCFunction)Message_get_member,
|
|
Packit |
130fc8 |
METH_NOARGS, Message_get_member__doc__},
|
|
Packit |
130fc8 |
{"set_member", (PyCFunction)Message_set_member,
|
|
Packit |
130fc8 |
METH_VARARGS, Message_set_member__doc__},
|
|
Packit |
130fc8 |
{"has_member", (PyCFunction)Message_has_member,
|
|
Packit |
130fc8 |
METH_VARARGS, Message_has_member__doc__},
|
|
Packit |
130fc8 |
{"get_path", (PyCFunction)Message_get_path,
|
|
Packit |
130fc8 |
METH_NOARGS, Message_get_path__doc__},
|
|
Packit |
130fc8 |
{"get_path_decomposed", (PyCFunction)Message_get_path_decomposed,
|
|
Packit |
130fc8 |
METH_NOARGS, Message_get_path_decomposed__doc__},
|
|
Packit |
130fc8 |
{"set_path", (PyCFunction)Message_set_path,
|
|
Packit |
130fc8 |
METH_VARARGS, Message_set_path__doc__},
|
|
Packit |
130fc8 |
{"has_path", (PyCFunction)Message_has_path,
|
|
Packit |
130fc8 |
METH_VARARGS, Message_has_path__doc__},
|
|
Packit |
130fc8 |
{"get_no_reply", (PyCFunction)Message_get_no_reply,
|
|
Packit |
130fc8 |
METH_NOARGS, Message_get_no_reply__doc__},
|
|
Packit |
130fc8 |
{"set_no_reply", (PyCFunction)Message_set_no_reply,
|
|
Packit |
130fc8 |
METH_VARARGS, Message_set_no_reply__doc__},
|
|
Packit |
130fc8 |
{"get_reply_serial", (PyCFunction)Message_get_reply_serial,
|
|
Packit |
130fc8 |
METH_NOARGS, Message_get_reply_serial__doc__},
|
|
Packit |
130fc8 |
{"set_reply_serial", (PyCFunction)Message_set_reply_serial,
|
|
Packit |
130fc8 |
METH_VARARGS, Message_set_reply_serial__doc__},
|
|
Packit |
130fc8 |
{"get_sender", (PyCFunction)Message_get_sender,
|
|
Packit |
130fc8 |
METH_NOARGS, Message_get_sender__doc__},
|
|
Packit |
130fc8 |
{"set_sender", (PyCFunction)Message_set_sender,
|
|
Packit |
130fc8 |
METH_VARARGS, Message_set_sender__doc__},
|
|
Packit |
130fc8 |
{"has_sender", (PyCFunction)Message_has_sender,
|
|
Packit |
130fc8 |
METH_VARARGS, Message_has_sender__doc__},
|
|
Packit |
130fc8 |
{"get_serial", (PyCFunction)Message_get_serial,
|
|
Packit |
130fc8 |
METH_NOARGS, Message_get_serial__doc__},
|
|
Packit |
130fc8 |
{"get_signature", (PyCFunction)Message_get_signature,
|
|
Packit |
130fc8 |
METH_NOARGS, Message_get_signature__doc__},
|
|
Packit |
130fc8 |
{"has_signature", (PyCFunction)Message_has_signature,
|
|
Packit |
130fc8 |
METH_VARARGS, Message_has_signature__doc__},
|
|
Packit |
130fc8 |
{"get_type", (PyCFunction)Message_get_type,
|
|
Packit |
130fc8 |
METH_NOARGS, Message_get_type__doc__},
|
|
Packit |
130fc8 |
{NULL, NULL, 0, NULL}
|
|
Packit |
130fc8 |
};
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
static PyTypeObject MessageType = {
|
|
Packit |
130fc8 |
PyVarObject_HEAD_INIT(NULL, 0)
|
|
Packit |
130fc8 |
"dbus.lowlevel.Message", /*tp_name*/
|
|
Packit |
130fc8 |
sizeof(Message), /*tp_basicsize*/
|
|
Packit |
130fc8 |
0, /*tp_itemsize*/
|
|
Packit |
130fc8 |
(destructor)Message_tp_dealloc, /*tp_dealloc*/
|
|
Packit |
130fc8 |
0, /*tp_print*/
|
|
Packit |
130fc8 |
0, /*tp_getattr*/
|
|
Packit |
130fc8 |
0, /*tp_setattr*/
|
|
Packit |
130fc8 |
0, /*tp_compare*/
|
|
Packit |
130fc8 |
0, /*tp_repr*/
|
|
Packit |
130fc8 |
0, /*tp_as_number*/
|
|
Packit |
130fc8 |
0, /*tp_as_sequence*/
|
|
Packit |
130fc8 |
0, /*tp_as_mapping*/
|
|
Packit |
130fc8 |
0, /*tp_hash */
|
|
Packit |
130fc8 |
0, /*tp_call*/
|
|
Packit |
130fc8 |
0, /*tp_str*/
|
|
Packit |
130fc8 |
0, /*tp_getattro*/
|
|
Packit |
130fc8 |
0, /*tp_setattro*/
|
|
Packit |
130fc8 |
0, /*tp_as_buffer*/
|
|
Packit |
130fc8 |
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
|
|
Packit |
130fc8 |
Message_tp_doc, /* tp_doc */
|
|
Packit |
130fc8 |
0, /* tp_traverse */
|
|
Packit |
130fc8 |
0, /* tp_clear */
|
|
Packit |
130fc8 |
0, /* tp_richcompare */
|
|
Packit |
130fc8 |
0, /* tp_weaklistoffset */
|
|
Packit |
130fc8 |
0, /* tp_iter */
|
|
Packit |
130fc8 |
0, /* tp_iternext */
|
|
Packit |
130fc8 |
Message_tp_methods, /* tp_methods */
|
|
Packit |
130fc8 |
0, /* tp_members */
|
|
Packit |
130fc8 |
0, /* tp_getset */
|
|
Packit |
130fc8 |
0, /* tp_base */
|
|
Packit |
130fc8 |
0, /* tp_dict */
|
|
Packit |
130fc8 |
0, /* tp_descr_get */
|
|
Packit |
130fc8 |
0, /* tp_descr_set */
|
|
Packit |
130fc8 |
0, /* tp_dictoffset */
|
|
Packit |
130fc8 |
0, /* tp_init */
|
|
Packit |
130fc8 |
0, /* tp_alloc */
|
|
Packit |
130fc8 |
Message_tp_new, /* tp_new */
|
|
Packit |
130fc8 |
};
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
static PyTypeObject MethodCallMessageType = {
|
|
Packit |
130fc8 |
PyVarObject_HEAD_INIT(NULL, 0)
|
|
Packit |
130fc8 |
"dbus.lowlevel.MethodCallMessage", /*tp_name*/
|
|
Packit |
130fc8 |
0, /*tp_basicsize*/
|
|
Packit |
130fc8 |
0, /*tp_itemsize*/
|
|
Packit |
130fc8 |
0, /*tp_dealloc*/
|
|
Packit |
130fc8 |
0, /*tp_print*/
|
|
Packit |
130fc8 |
0, /*tp_getattr*/
|
|
Packit |
130fc8 |
0, /*tp_setattr*/
|
|
Packit |
130fc8 |
0, /*tp_compare*/
|
|
Packit |
130fc8 |
MethodCallMessage_tp_repr, /*tp_repr*/
|
|
Packit |
130fc8 |
0, /*tp_as_number*/
|
|
Packit |
130fc8 |
0, /*tp_as_sequence*/
|
|
Packit |
130fc8 |
0, /*tp_as_mapping*/
|
|
Packit |
130fc8 |
0, /*tp_hash */
|
|
Packit |
130fc8 |
0, /*tp_call*/
|
|
Packit |
130fc8 |
0, /*tp_str*/
|
|
Packit |
130fc8 |
0, /*tp_getattro*/
|
|
Packit |
130fc8 |
0, /*tp_setattro*/
|
|
Packit |
130fc8 |
0, /*tp_as_buffer*/
|
|
Packit |
130fc8 |
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
|
|
Packit |
130fc8 |
MethodCallMessage_tp_doc, /* tp_doc */
|
|
Packit |
130fc8 |
0, /* tp_traverse */
|
|
Packit |
130fc8 |
0, /* tp_clear */
|
|
Packit |
130fc8 |
0, /* tp_richcompare */
|
|
Packit |
130fc8 |
0, /* tp_weaklistoffset */
|
|
Packit |
130fc8 |
0, /* tp_iter */
|
|
Packit |
130fc8 |
0, /* tp_iternext */
|
|
Packit |
130fc8 |
0, /* tp_methods */
|
|
Packit |
130fc8 |
0, /* tp_members */
|
|
Packit |
130fc8 |
0, /* tp_getset */
|
|
Packit |
130fc8 |
DEFERRED_ADDRESS(&MessageType), /* tp_base */
|
|
Packit |
130fc8 |
0, /* tp_dict */
|
|
Packit |
130fc8 |
0, /* tp_descr_get */
|
|
Packit |
130fc8 |
0, /* tp_descr_set */
|
|
Packit |
130fc8 |
0, /* tp_dictoffset */
|
|
Packit |
130fc8 |
(initproc)MethodCallMessage_tp_init, /* tp_init */
|
|
Packit |
130fc8 |
0, /* tp_alloc */
|
|
Packit |
130fc8 |
0, /* tp_new */
|
|
Packit |
130fc8 |
};
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
static PyTypeObject MethodReturnMessageType = {
|
|
Packit |
130fc8 |
PyVarObject_HEAD_INIT(NULL, 0)
|
|
Packit |
130fc8 |
"dbus.lowlevel.MethodReturnMessage", /*tp_name*/
|
|
Packit |
130fc8 |
0, /*tp_basicsize*/
|
|
Packit |
130fc8 |
0, /*tp_itemsize*/
|
|
Packit |
130fc8 |
0, /*tp_dealloc*/
|
|
Packit |
130fc8 |
0, /*tp_print*/
|
|
Packit |
130fc8 |
0, /*tp_getattr*/
|
|
Packit |
130fc8 |
0, /*tp_setattr*/
|
|
Packit |
130fc8 |
0, /*tp_compare*/
|
|
Packit |
130fc8 |
0, /*tp_repr*/
|
|
Packit |
130fc8 |
0, /*tp_as_number*/
|
|
Packit |
130fc8 |
0, /*tp_as_sequence*/
|
|
Packit |
130fc8 |
0, /*tp_as_mapping*/
|
|
Packit |
130fc8 |
0, /*tp_hash */
|
|
Packit |
130fc8 |
0, /*tp_call*/
|
|
Packit |
130fc8 |
0, /*tp_str*/
|
|
Packit |
130fc8 |
0, /*tp_getattro*/
|
|
Packit |
130fc8 |
0, /*tp_setattro*/
|
|
Packit |
130fc8 |
0, /*tp_as_buffer*/
|
|
Packit |
130fc8 |
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
|
|
Packit |
130fc8 |
MethodReturnMessage_tp_doc, /* tp_doc */
|
|
Packit |
130fc8 |
0, /* tp_traverse */
|
|
Packit |
130fc8 |
0, /* tp_clear */
|
|
Packit |
130fc8 |
0, /* tp_richcompare */
|
|
Packit |
130fc8 |
0, /* tp_weaklistoffset */
|
|
Packit |
130fc8 |
0, /* tp_iter */
|
|
Packit |
130fc8 |
0, /* tp_iternext */
|
|
Packit |
130fc8 |
0, /* tp_methods */
|
|
Packit |
130fc8 |
0, /* tp_members */
|
|
Packit |
130fc8 |
0, /* tp_getset */
|
|
Packit |
130fc8 |
DEFERRED_ADDRESS(&MessageType), /* tp_base */
|
|
Packit |
130fc8 |
0, /* tp_dict */
|
|
Packit |
130fc8 |
0, /* tp_descr_get */
|
|
Packit |
130fc8 |
0, /* tp_descr_set */
|
|
Packit |
130fc8 |
0, /* tp_dictoffset */
|
|
Packit |
130fc8 |
(initproc)MethodReturnMessage_tp_init, /* tp_init */
|
|
Packit |
130fc8 |
0, /* tp_alloc */
|
|
Packit |
130fc8 |
0, /* tp_new */
|
|
Packit |
130fc8 |
};
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
static PyTypeObject SignalMessageType = {
|
|
Packit |
130fc8 |
PyVarObject_HEAD_INIT(NULL, 0)
|
|
Packit |
130fc8 |
"dbus.lowlevel.SignalMessage", /*tp_name*/
|
|
Packit |
130fc8 |
0, /*tp_basicsize*/
|
|
Packit |
130fc8 |
0, /*tp_itemsize*/
|
|
Packit |
130fc8 |
0, /*tp_dealloc*/
|
|
Packit |
130fc8 |
0, /*tp_print*/
|
|
Packit |
130fc8 |
0, /*tp_getattr*/
|
|
Packit |
130fc8 |
0, /*tp_setattr*/
|
|
Packit |
130fc8 |
0, /*tp_compare*/
|
|
Packit |
130fc8 |
SignalMessage_tp_repr, /*tp_repr*/
|
|
Packit |
130fc8 |
0, /*tp_as_number*/
|
|
Packit |
130fc8 |
0, /*tp_as_sequence*/
|
|
Packit |
130fc8 |
0, /*tp_as_mapping*/
|
|
Packit |
130fc8 |
0, /*tp_hash */
|
|
Packit |
130fc8 |
0, /*tp_call*/
|
|
Packit |
130fc8 |
0, /*tp_str*/
|
|
Packit |
130fc8 |
0, /*tp_getattro*/
|
|
Packit |
130fc8 |
0, /*tp_setattro*/
|
|
Packit |
130fc8 |
0, /*tp_as_buffer*/
|
|
Packit |
130fc8 |
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
|
|
Packit |
130fc8 |
SignalMessage_tp_doc, /* tp_doc */
|
|
Packit |
130fc8 |
0, /* tp_traverse */
|
|
Packit |
130fc8 |
0, /* tp_clear */
|
|
Packit |
130fc8 |
0, /* tp_richcompare */
|
|
Packit |
130fc8 |
0, /* tp_weaklistoffset */
|
|
Packit |
130fc8 |
0, /* tp_iter */
|
|
Packit |
130fc8 |
0, /* tp_iternext */
|
|
Packit |
130fc8 |
0, /* tp_methods */
|
|
Packit |
130fc8 |
0, /* tp_members */
|
|
Packit |
130fc8 |
0, /* tp_getset */
|
|
Packit |
130fc8 |
DEFERRED_ADDRESS(&MessageType), /* tp_base */
|
|
Packit |
130fc8 |
0, /* tp_dict */
|
|
Packit |
130fc8 |
0, /* tp_descr_get */
|
|
Packit |
130fc8 |
0, /* tp_descr_set */
|
|
Packit |
130fc8 |
0, /* tp_dictoffset */
|
|
Packit |
130fc8 |
(initproc)SignalMessage_tp_init, /* tp_init */
|
|
Packit |
130fc8 |
0, /* tp_alloc */
|
|
Packit |
130fc8 |
0, /* tp_new */
|
|
Packit |
130fc8 |
};
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
static PyTypeObject ErrorMessageType = {
|
|
Packit |
130fc8 |
PyVarObject_HEAD_INIT(NULL, 0)
|
|
Packit |
130fc8 |
"dbus.lowlevel.ErrorMessage", /*tp_name*/
|
|
Packit |
130fc8 |
0, /*tp_basicsize*/
|
|
Packit |
130fc8 |
0, /*tp_itemsize*/
|
|
Packit |
130fc8 |
0, /*tp_dealloc*/
|
|
Packit |
130fc8 |
0, /*tp_print*/
|
|
Packit |
130fc8 |
0, /*tp_getattr*/
|
|
Packit |
130fc8 |
0, /*tp_setattr*/
|
|
Packit |
130fc8 |
0, /*tp_compare*/
|
|
Packit |
130fc8 |
0, /*tp_repr*/
|
|
Packit |
130fc8 |
0, /*tp_as_number*/
|
|
Packit |
130fc8 |
0, /*tp_as_sequence*/
|
|
Packit |
130fc8 |
0, /*tp_as_mapping*/
|
|
Packit |
130fc8 |
0, /*tp_hash */
|
|
Packit |
130fc8 |
0, /*tp_call*/
|
|
Packit |
130fc8 |
0, /*tp_str*/
|
|
Packit |
130fc8 |
0, /*tp_getattro*/
|
|
Packit |
130fc8 |
0, /*tp_setattro*/
|
|
Packit |
130fc8 |
0, /*tp_as_buffer*/
|
|
Packit |
130fc8 |
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
|
|
Packit |
130fc8 |
ErrorMessage_tp_doc, /* tp_doc */
|
|
Packit |
130fc8 |
0, /* tp_traverse */
|
|
Packit |
130fc8 |
0, /* tp_clear */
|
|
Packit |
130fc8 |
0, /* tp_richcompare */
|
|
Packit |
130fc8 |
0, /* tp_weaklistoffset */
|
|
Packit |
130fc8 |
0, /* tp_iter */
|
|
Packit |
130fc8 |
0, /* tp_iternext */
|
|
Packit |
130fc8 |
0, /* tp_methods */
|
|
Packit |
130fc8 |
0, /* tp_members */
|
|
Packit |
130fc8 |
0, /* tp_getset */
|
|
Packit |
130fc8 |
DEFERRED_ADDRESS(&MessageType), /* tp_base */
|
|
Packit |
130fc8 |
0, /* tp_dict */
|
|
Packit |
130fc8 |
0, /* tp_descr_get */
|
|
Packit |
130fc8 |
0, /* tp_descr_set */
|
|
Packit |
130fc8 |
0, /* tp_dictoffset */
|
|
Packit |
130fc8 |
(initproc)ErrorMessage_tp_init, /* tp_init */
|
|
Packit |
130fc8 |
0, /* tp_alloc */
|
|
Packit |
130fc8 |
0, /* tp_new */
|
|
Packit |
130fc8 |
};
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
dbus_bool_t
|
|
Packit |
130fc8 |
dbus_py_init_message_types(void)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
if (PyType_Ready(&MessageType) < 0) return 0;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
MethodCallMessageType.tp_base = &MessageType;
|
|
Packit |
130fc8 |
if (PyType_Ready(&MethodCallMessageType) < 0) return 0;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
MethodReturnMessageType.tp_base = &MessageType;
|
|
Packit |
130fc8 |
if (PyType_Ready(&MethodReturnMessageType) < 0) return 0;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
SignalMessageType.tp_base = &MessageType;
|
|
Packit |
130fc8 |
if (PyType_Ready(&SignalMessageType) < 0) return 0;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
ErrorMessageType.tp_base = &MessageType;
|
|
Packit |
130fc8 |
if (PyType_Ready(&ErrorMessageType) < 0) return 0;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
return 1;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
dbus_bool_t
|
|
Packit |
130fc8 |
dbus_py_insert_message_types(PyObject *this_module)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
/* PyModule_AddObject steals a ref */
|
|
Packit |
130fc8 |
Py_INCREF (&MessageType);
|
|
Packit |
130fc8 |
Py_INCREF (&MethodCallMessageType);
|
|
Packit |
130fc8 |
Py_INCREF (&MethodReturnMessageType);
|
|
Packit |
130fc8 |
Py_INCREF (&ErrorMessageType);
|
|
Packit |
130fc8 |
Py_INCREF (&SignalMessageType);
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (PyModule_AddObject(this_module, "Message",
|
|
Packit |
130fc8 |
(PyObject *)&MessageType) < 0) return 0;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (PyModule_AddObject(this_module, "MethodCallMessage",
|
|
Packit |
130fc8 |
(PyObject *)&MethodCallMessageType) < 0) return 0;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (PyModule_AddObject(this_module, "MethodReturnMessage",
|
|
Packit |
130fc8 |
(PyObject *)&MethodReturnMessageType) < 0) return 0;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (PyModule_AddObject(this_module, "ErrorMessage",
|
|
Packit |
130fc8 |
(PyObject *)&ErrorMessageType) < 0) return 0;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (PyModule_AddObject(this_module, "SignalMessage",
|
|
Packit |
130fc8 |
(PyObject *)&SignalMessageType) < 0) return 0;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
return 1;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
/* vim:set ft=c cino< sw=4 sts=4 et: */
|