|
Packit |
130fc8 |
/* Main module source for the _dbus_bindings extension.
|
|
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 |
|
|
Packit |
130fc8 |
#include <Python.h>
|
|
Packit |
130fc8 |
#include <structmember.h>
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(module_doc,
|
|
Packit |
130fc8 |
"Low-level Python bindings for libdbus. Don't use this module directly -\n"
|
|
Packit |
130fc8 |
"the public API is provided by the `dbus`, `dbus.service`, `dbus.mainloop`\n"
|
|
Packit |
130fc8 |
"and `dbus.mainloop.glib` modules, with a lower-level API provided by the\n"
|
|
Packit |
130fc8 |
"`dbus.lowlevel` module.\n"
|
|
Packit |
130fc8 |
);
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
/* Global functions - validation wrappers ===========================*/
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(validate_bus_name__doc__,
|
|
Packit |
130fc8 |
"validate_bus_name(name, allow_unique=True, allow_well_known=True)\n"
|
|
Packit |
130fc8 |
"\n"
|
|
Packit |
130fc8 |
"Raise ValueError if the argument is not a valid bus name.\n"
|
|
Packit |
130fc8 |
"\n"
|
|
Packit |
130fc8 |
"By default both unique and well-known names are accepted.\n"
|
|
Packit |
130fc8 |
"\n"
|
|
Packit |
130fc8 |
":Parameters:\n"
|
|
Packit |
130fc8 |
" `name` : str\n"
|
|
Packit |
130fc8 |
" The name to be validated\n"
|
|
Packit |
130fc8 |
" `allow_unique` : bool\n"
|
|
Packit |
130fc8 |
" If False, unique names of the form :1.123 will be rejected\n"
|
|
Packit |
130fc8 |
" `allow_well_known` : bool\n"
|
|
Packit |
130fc8 |
" If False, well-known names of the form com.example.Foo\n"
|
|
Packit |
130fc8 |
" will be rejected\n"
|
|
Packit |
130fc8 |
":Since: 0.80\n"
|
|
Packit |
130fc8 |
);
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
validate_bus_name(PyObject *unused UNUSED, PyObject *args, PyObject *kwargs)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
const char *name;
|
|
Packit |
130fc8 |
int allow_unique = 1;
|
|
Packit |
130fc8 |
int allow_well_known = 1;
|
|
Packit |
130fc8 |
static char *argnames[] = { "name", "allow_unique", "allow_well_known",
|
|
Packit |
130fc8 |
NULL };
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
|
Packit |
130fc8 |
"s|ii:validate_bus_name", argnames,
|
|
Packit |
130fc8 |
&name, &allow_unique,
|
|
Packit |
130fc8 |
&allow_well_known)) {
|
|
Packit |
130fc8 |
return NULL;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
if (!dbus_py_validate_bus_name(name, !!allow_unique, !!allow_well_known)) {
|
|
Packit |
130fc8 |
return NULL;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
Py_RETURN_NONE;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(validate_member_name__doc__,
|
|
Packit |
130fc8 |
"validate_member_name(name)\n"
|
|
Packit |
130fc8 |
"\n"
|
|
Packit |
130fc8 |
"Raise ValueError if the argument is not a valid member (signal or method) "
|
|
Packit |
130fc8 |
"name.\n"
|
|
Packit |
130fc8 |
"\n"
|
|
Packit |
130fc8 |
":Since: 0.80\n"
|
|
Packit |
130fc8 |
);
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
validate_member_name(PyObject *unused UNUSED, PyObject *args)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
const char *name;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (!PyArg_ParseTuple(args, "s:validate_member_name", &name)) {
|
|
Packit |
130fc8 |
return NULL;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
if (!dbus_py_validate_member_name(name)) {
|
|
Packit |
130fc8 |
return NULL;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
Py_RETURN_NONE;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(validate_interface_name__doc__,
|
|
Packit |
130fc8 |
"validate_interface_name(name)\n\n"
|
|
Packit |
130fc8 |
"Raise ValueError if the given string is not a valid interface name.\n"
|
|
Packit |
130fc8 |
"\n"
|
|
Packit |
130fc8 |
":Since: 0.80\n"
|
|
Packit |
130fc8 |
);
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(validate_error_name__doc__,
|
|
Packit |
130fc8 |
"validate_error_name(name)\n\n"
|
|
Packit |
130fc8 |
"Raise ValueError if the given string is not a valid error name.\n"
|
|
Packit |
130fc8 |
"\n"
|
|
Packit |
130fc8 |
":Since: 0.80\n"
|
|
Packit |
130fc8 |
);
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
validate_interface_name(PyObject *unused UNUSED, PyObject *args)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
const char *name;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (!PyArg_ParseTuple(args, "s:validate_interface_name", &name)) {
|
|
Packit |
130fc8 |
return NULL;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
if (!dbus_py_validate_interface_name(name)) {
|
|
Packit |
130fc8 |
return NULL;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
Py_RETURN_NONE;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(validate_object_path__doc__,
|
|
Packit |
130fc8 |
"validate_object_path(name)\n\n"
|
|
Packit |
130fc8 |
"Raise ValueError if the given string is not a valid object path.\n"
|
|
Packit |
130fc8 |
"\n"
|
|
Packit |
130fc8 |
":Since: 0.80\n"
|
|
Packit |
130fc8 |
);
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
validate_object_path(PyObject *unused UNUSED, PyObject *args)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
const char *name;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (!PyArg_ParseTuple(args, "s:validate_object_path", &name)) {
|
|
Packit |
130fc8 |
return NULL;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
if (!dbus_py_validate_object_path(name)) {
|
|
Packit |
130fc8 |
return NULL;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
Py_RETURN_NONE;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
/* Global functions - main loop =====================================*/
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
/* The main loop if none is passed to the constructor */
|
|
Packit |
130fc8 |
static PyObject *default_main_loop = NULL;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
/* Return a new reference to the default main loop */
|
|
Packit |
130fc8 |
PyObject *
|
|
Packit |
130fc8 |
dbus_py_get_default_main_loop(void)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
if (!default_main_loop) {
|
|
Packit |
130fc8 |
Py_RETURN_NONE;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
Py_INCREF(default_main_loop);
|
|
Packit |
130fc8 |
return default_main_loop;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(get_default_main_loop__doc__,
|
|
Packit |
130fc8 |
"get_default_main_loop() -> object\n\n"
|
|
Packit |
130fc8 |
"Return the global default dbus-python main loop wrapper, which is used\n"
|
|
Packit |
130fc8 |
"when no main loop wrapper is passed to the Connection constructor.\n"
|
|
Packit |
130fc8 |
"\n"
|
|
Packit |
130fc8 |
"If None, there is no default and you should always pass the mainloop\n"
|
|
Packit |
130fc8 |
"parameter to the constructor - if you don't, then asynchronous calls,\n"
|
|
Packit |
130fc8 |
"connecting to signals and exporting objects will raise an exception.\n"
|
|
Packit |
130fc8 |
"There is no default until set_default_main_loop is called.\n");
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
get_default_main_loop(PyObject *always_null UNUSED,
|
|
Packit |
130fc8 |
PyObject *no_args UNUSED)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
return dbus_py_get_default_main_loop();
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyDoc_STRVAR(set_default_main_loop__doc__,
|
|
Packit |
130fc8 |
"set_default_main_loop(object)\n\n"
|
|
Packit |
130fc8 |
"Change the global default dbus-python main loop wrapper, which is used\n"
|
|
Packit |
130fc8 |
"when no main loop wrapper is passed to the Connection constructor.\n"
|
|
Packit |
130fc8 |
"\n"
|
|
Packit |
130fc8 |
"If None, return to the initial situation: there is no default, and you\n"
|
|
Packit |
130fc8 |
"must always pass the mainloop parameter to the constructor.\n"
|
|
Packit |
130fc8 |
"\n"
|
|
Packit |
130fc8 |
"Two types of main loop wrapper are planned in dbus-python.\n"
|
|
Packit |
130fc8 |
"Native main-loop wrappers are instances of `dbus.mainloop.NativeMainLoop`\n"
|
|
Packit |
130fc8 |
"supplied by extension modules like `dbus.mainloop.glib`: they have no\n"
|
|
Packit |
130fc8 |
"Python API, but connect themselves to ``libdbus`` using native code.\n"
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
"Python main-loop wrappers are not yet implemented. They will be objects\n"
|
|
Packit |
130fc8 |
"supporting the interface defined by `dbus.mainloop.MainLoop`, with an\n"
|
|
Packit |
130fc8 |
"API entirely based on Python methods.\n"
|
|
Packit |
130fc8 |
"\n"
|
|
Packit |
130fc8 |
);
|
|
Packit |
130fc8 |
static PyObject *
|
|
Packit |
130fc8 |
set_default_main_loop(PyObject *always_null UNUSED,
|
|
Packit |
130fc8 |
PyObject *args)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
PyObject *new_loop, *old_loop;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (!PyArg_ParseTuple(args, "O", &new_loop)) {
|
|
Packit |
130fc8 |
return NULL;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
if (!dbus_py_check_mainloop_sanity(new_loop)) {
|
|
Packit |
130fc8 |
return NULL;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
old_loop = default_main_loop;
|
|
Packit |
130fc8 |
Py_INCREF(new_loop);
|
|
Packit |
130fc8 |
default_main_loop = new_loop;
|
|
Packit |
130fc8 |
Py_CLEAR(old_loop);
|
|
Packit |
130fc8 |
Py_RETURN_NONE;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
static PyMethodDef module_functions[] = {
|
|
Packit |
130fc8 |
#define ENTRY(name,flags) {#name, (PyCFunction)name, flags, name##__doc__}
|
|
Packit |
130fc8 |
ENTRY(validate_interface_name, METH_VARARGS),
|
|
Packit |
130fc8 |
ENTRY(validate_member_name, METH_VARARGS),
|
|
Packit |
130fc8 |
ENTRY(validate_bus_name, METH_VARARGS|METH_KEYWORDS),
|
|
Packit |
130fc8 |
ENTRY(validate_object_path, METH_VARARGS),
|
|
Packit |
130fc8 |
ENTRY(set_default_main_loop, METH_VARARGS),
|
|
Packit |
130fc8 |
ENTRY(get_default_main_loop, METH_NOARGS),
|
|
Packit |
130fc8 |
/* validate_error_name is just implemented as validate_interface_name */
|
|
Packit |
130fc8 |
{"validate_error_name", validate_interface_name,
|
|
Packit |
130fc8 |
METH_VARARGS, validate_error_name__doc__},
|
|
Packit |
130fc8 |
#undef ENTRY
|
|
Packit |
130fc8 |
{NULL, NULL, 0, NULL}
|
|
Packit |
130fc8 |
};
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyMODINIT_FUNC
|
|
Packit |
130fc8 |
#ifdef PY3
|
|
Packit |
130fc8 |
PyInit__dbus_bindings(void)
|
|
Packit |
130fc8 |
#else
|
|
Packit |
130fc8 |
init_dbus_bindings(void)
|
|
Packit |
130fc8 |
#endif
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
PyObject *this_module = NULL, *c_api;
|
|
Packit |
130fc8 |
static const int API_count = DBUS_BINDINGS_API_COUNT;
|
|
Packit |
130fc8 |
static _dbus_py_func_ptr dbus_bindings_API[DBUS_BINDINGS_API_COUNT];
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
#ifdef PY3
|
|
Packit |
130fc8 |
static struct PyModuleDef moduledef = {
|
|
Packit |
130fc8 |
PyModuleDef_HEAD_INIT,
|
|
Packit |
130fc8 |
"_dbus_bindings", /* m_name */
|
|
Packit |
130fc8 |
module_doc, /* m_doc */
|
|
Packit |
130fc8 |
-1, /* m_size */
|
|
Packit |
130fc8 |
module_functions, /* m_methods */
|
|
Packit |
130fc8 |
NULL, /* m_reload */
|
|
Packit |
130fc8 |
NULL, /* m_traverse */
|
|
Packit |
130fc8 |
NULL, /* m_clear */
|
|
Packit |
130fc8 |
NULL /* m_free */
|
|
Packit |
130fc8 |
};
|
|
Packit |
130fc8 |
#endif
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
dbus_bindings_API[0] = (_dbus_py_func_ptr)&API_count;
|
|
Packit |
130fc8 |
dbus_bindings_API[1] = (_dbus_py_func_ptr)DBusPyConnection_BorrowDBusConnection;
|
|
Packit |
130fc8 |
dbus_bindings_API[2] = (_dbus_py_func_ptr)DBusPyNativeMainLoop_New4;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
default_main_loop = NULL;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (!dbus_py_init_generic()) goto init_error;
|
|
Packit |
130fc8 |
if (!dbus_py_init_abstract()) goto init_error;
|
|
Packit |
130fc8 |
if (!dbus_py_init_signature()) goto init_error;
|
|
Packit |
130fc8 |
if (!dbus_py_init_int_types()) goto init_error;
|
|
Packit |
130fc8 |
if (!dbus_py_init_unixfd_type()) goto init_error;
|
|
Packit |
130fc8 |
if (!dbus_py_init_string_types()) goto init_error;
|
|
Packit |
130fc8 |
if (!dbus_py_init_float_types()) goto init_error;
|
|
Packit |
130fc8 |
if (!dbus_py_init_container_types()) goto init_error;
|
|
Packit |
130fc8 |
if (!dbus_py_init_byte_types()) goto init_error;
|
|
Packit |
130fc8 |
if (!dbus_py_init_message_types()) goto init_error;
|
|
Packit |
130fc8 |
if (!dbus_py_init_pending_call()) goto init_error;
|
|
Packit |
130fc8 |
if (!dbus_py_init_mainloop()) goto init_error;
|
|
Packit |
130fc8 |
if (!dbus_py_init_libdbus_conn_types()) goto init_error;
|
|
Packit |
130fc8 |
if (!dbus_py_init_conn_types()) goto init_error;
|
|
Packit |
130fc8 |
if (!dbus_py_init_server_types()) goto init_error;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
#ifdef PY3
|
|
Packit |
130fc8 |
this_module = PyModule_Create(&moduledef);
|
|
Packit |
130fc8 |
#else
|
|
Packit |
130fc8 |
this_module = Py_InitModule3("_dbus_bindings",
|
|
Packit |
130fc8 |
module_functions, module_doc);
|
|
Packit |
130fc8 |
#endif
|
|
Packit |
130fc8 |
if (!this_module) goto init_error;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (!dbus_py_insert_abstract_types(this_module)) goto init_error;
|
|
Packit |
130fc8 |
if (!dbus_py_insert_signature(this_module)) goto init_error;
|
|
Packit |
130fc8 |
if (!dbus_py_insert_int_types(this_module)) goto init_error;
|
|
Packit |
130fc8 |
if (!dbus_py_insert_unixfd_type(this_module)) goto init_error;
|
|
Packit |
130fc8 |
if (!dbus_py_insert_string_types(this_module)) goto init_error;
|
|
Packit |
130fc8 |
if (!dbus_py_insert_float_types(this_module)) goto init_error;
|
|
Packit |
130fc8 |
if (!dbus_py_insert_container_types(this_module)) goto init_error;
|
|
Packit |
130fc8 |
if (!dbus_py_insert_byte_types(this_module)) goto init_error;
|
|
Packit |
130fc8 |
if (!dbus_py_insert_message_types(this_module)) goto init_error;
|
|
Packit |
130fc8 |
if (!dbus_py_insert_pending_call(this_module)) goto init_error;
|
|
Packit |
130fc8 |
if (!dbus_py_insert_mainloop_types(this_module)) goto init_error;
|
|
Packit |
130fc8 |
if (!dbus_py_insert_libdbus_conn_types(this_module)) goto init_error;
|
|
Packit |
130fc8 |
if (!dbus_py_insert_conn_types(this_module)) goto init_error;
|
|
Packit |
130fc8 |
if (!dbus_py_insert_server_types(this_module)) goto init_error;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (PyModule_AddStringConstant(this_module, "BUS_DAEMON_NAME",
|
|
Packit |
130fc8 |
DBUS_SERVICE_DBUS) < 0) goto init_error;
|
|
Packit |
130fc8 |
if (PyModule_AddStringConstant(this_module, "BUS_DAEMON_PATH",
|
|
Packit |
130fc8 |
DBUS_PATH_DBUS) < 0) goto init_error;
|
|
Packit |
130fc8 |
if (PyModule_AddStringConstant(this_module, "BUS_DAEMON_IFACE",
|
|
Packit |
130fc8 |
DBUS_INTERFACE_DBUS) < 0) goto init_error;
|
|
Packit |
130fc8 |
if (PyModule_AddStringConstant(this_module, "LOCAL_PATH",
|
|
Packit |
130fc8 |
DBUS_PATH_LOCAL) < 0) goto init_error;
|
|
Packit |
130fc8 |
if (PyModule_AddStringConstant(this_module, "LOCAL_IFACE",
|
|
Packit |
130fc8 |
DBUS_INTERFACE_LOCAL) < 0) goto init_error;
|
|
Packit |
130fc8 |
if (PyModule_AddStringConstant(this_module, "INTROSPECTABLE_IFACE",
|
|
Packit |
130fc8 |
DBUS_INTERFACE_INTROSPECTABLE) < 0)
|
|
Packit |
130fc8 |
goto init_error;
|
|
Packit |
130fc8 |
if (PyModule_AddStringConstant(this_module, "PEER_IFACE",
|
|
Packit |
130fc8 |
DBUS_INTERFACE_PEER) < 0) goto init_error;
|
|
Packit |
130fc8 |
if (PyModule_AddStringConstant(this_module, "PROPERTIES_IFACE",
|
|
Packit |
130fc8 |
DBUS_INTERFACE_PROPERTIES) < 0)
|
|
Packit |
130fc8 |
goto init_error;
|
|
Packit |
130fc8 |
if (PyModule_AddStringConstant(this_module,
|
|
Packit |
130fc8 |
"DBUS_INTROSPECT_1_0_XML_PUBLIC_IDENTIFIER",
|
|
Packit |
130fc8 |
DBUS_INTROSPECT_1_0_XML_PUBLIC_IDENTIFIER) < 0)
|
|
Packit |
130fc8 |
goto init_error;
|
|
Packit |
130fc8 |
if (PyModule_AddStringConstant(this_module,
|
|
Packit |
130fc8 |
"DBUS_INTROSPECT_1_0_XML_SYSTEM_IDENTIFIER",
|
|
Packit |
130fc8 |
DBUS_INTROSPECT_1_0_XML_SYSTEM_IDENTIFIER) < 0)
|
|
Packit |
130fc8 |
goto init_error;
|
|
Packit |
130fc8 |
if (PyModule_AddStringConstant(this_module,
|
|
Packit |
130fc8 |
"DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE",
|
|
Packit |
130fc8 |
DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE) < 0)
|
|
Packit |
130fc8 |
goto init_error;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
#define ADD_CONST_VAL(x, v) \
|
|
Packit |
130fc8 |
if (PyModule_AddIntConstant(this_module, x, v) < 0) goto init_error;
|
|
Packit |
130fc8 |
#define ADD_CONST_PREFIXED(x) ADD_CONST_VAL(#x, DBUS_##x)
|
|
Packit |
130fc8 |
#define ADD_CONST(x) ADD_CONST_VAL(#x, x)
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
ADD_CONST(DBUS_START_REPLY_SUCCESS)
|
|
Packit |
130fc8 |
ADD_CONST(DBUS_START_REPLY_ALREADY_RUNNING)
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(RELEASE_NAME_REPLY_RELEASED)
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(RELEASE_NAME_REPLY_NON_EXISTENT)
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(RELEASE_NAME_REPLY_NOT_OWNER)
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(REQUEST_NAME_REPLY_PRIMARY_OWNER)
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(REQUEST_NAME_REPLY_IN_QUEUE)
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(REQUEST_NAME_REPLY_EXISTS)
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(REQUEST_NAME_REPLY_ALREADY_OWNER)
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(NAME_FLAG_ALLOW_REPLACEMENT)
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(NAME_FLAG_REPLACE_EXISTING)
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(NAME_FLAG_DO_NOT_QUEUE)
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(BUS_SESSION)
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(BUS_SYSTEM)
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(BUS_STARTER)
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(MESSAGE_TYPE_INVALID)
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(MESSAGE_TYPE_METHOD_CALL)
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(MESSAGE_TYPE_METHOD_RETURN)
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(MESSAGE_TYPE_ERROR)
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(MESSAGE_TYPE_SIGNAL)
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(TYPE_INVALID)
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(TYPE_BYTE)
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(TYPE_BOOLEAN)
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(TYPE_INT16)
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(TYPE_UINT16)
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(TYPE_INT32)
|
|
Packit |
130fc8 |
#ifdef DBUS_TYPE_UNIX_FD
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(TYPE_UNIX_FD)
|
|
Packit |
130fc8 |
#endif
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(TYPE_UINT32)
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(TYPE_INT64)
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(TYPE_UINT64)
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(TYPE_DOUBLE)
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(TYPE_STRING)
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(TYPE_OBJECT_PATH)
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(TYPE_SIGNATURE)
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(TYPE_ARRAY)
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(TYPE_STRUCT)
|
|
Packit |
130fc8 |
ADD_CONST_VAL("STRUCT_BEGIN", DBUS_STRUCT_BEGIN_CHAR)
|
|
Packit |
130fc8 |
ADD_CONST_VAL("STRUCT_END", DBUS_STRUCT_END_CHAR)
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(TYPE_VARIANT)
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(TYPE_DICT_ENTRY)
|
|
Packit |
130fc8 |
ADD_CONST_VAL("DICT_ENTRY_BEGIN", DBUS_DICT_ENTRY_BEGIN_CHAR)
|
|
Packit |
130fc8 |
ADD_CONST_VAL("DICT_ENTRY_END", DBUS_DICT_ENTRY_END_CHAR)
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(HANDLER_RESULT_HANDLED)
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(HANDLER_RESULT_NOT_YET_HANDLED)
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(HANDLER_RESULT_NEED_MEMORY)
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(WATCH_READABLE)
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(WATCH_WRITABLE)
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(WATCH_HANGUP)
|
|
Packit |
130fc8 |
ADD_CONST_PREFIXED(WATCH_ERROR)
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (PyModule_AddStringConstant(this_module, "__docformat__",
|
|
Packit |
130fc8 |
"restructuredtext") < 0) goto init_error;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (PyModule_AddStringConstant(this_module, "__version__",
|
|
Packit |
130fc8 |
PACKAGE_VERSION) < 0) goto init_error;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (PyModule_AddIntConstant(this_module, "_python_version",
|
|
Packit |
130fc8 |
PY_VERSION_HEX) < 0) goto init_error;
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
#ifdef PY3
|
|
Packit |
130fc8 |
c_api = PyCapsule_New((void *)dbus_bindings_API,
|
|
Packit |
130fc8 |
PYDBUS_CAPSULE_NAME, NULL);
|
|
Packit |
130fc8 |
#else
|
|
Packit |
130fc8 |
c_api = PyCObject_FromVoidPtr ((void *)dbus_bindings_API, NULL);
|
|
Packit |
130fc8 |
#endif
|
|
Packit |
130fc8 |
if (!c_api) {
|
|
Packit |
130fc8 |
goto init_error;
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
PyModule_AddObject(this_module, "_C_API", c_api);
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
#ifdef PY3
|
|
Packit |
130fc8 |
return this_module;
|
|
Packit |
130fc8 |
init_error:
|
|
Packit |
130fc8 |
Py_CLEAR(this_module);
|
|
Packit |
130fc8 |
return NULL;
|
|
Packit |
130fc8 |
#else
|
|
Packit |
130fc8 |
init_error:
|
|
Packit |
130fc8 |
return;
|
|
Packit |
130fc8 |
#endif
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
/* vim:set ft=c cino< sw=4 sts=4 et: */
|