dbus-common.h revision 1a37b9b9043ef83e9900e460a9a1fccced3acf89
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
#pragma once
/***
This file is part of systemd.
Copyright 2010 Lennart Poettering
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <inttypes.h>
#ifndef DBUS_ERROR_UNKNOWN_OBJECT
#define DBUS_ERROR_UNKNOWN_OBJECT "org.freedesktop.DBus.Error.UnknownObject"
#endif
#ifndef DBUS_ERROR_UNKNOWN_INTERFACE
#define DBUS_ERROR_UNKNOWN_INTERFACE "org.freedesktop.DBus.Error.UnknownInterface"
#endif
#ifndef DBUS_ERROR_UNKNOWN_PROPERTY
#define DBUS_ERROR_UNKNOWN_PROPERTY "org.freedesktop.DBus.Error.UnknownProperty"
#endif
#ifndef DBUS_ERROR_PROPERTY_READ_ONLY
#define DBUS_ERROR_PROPERTY_READ_ONLY "org.freedesktop.DBus.Error.PropertyReadOnly"
#endif
#define BUS_PROPERTIES_INTERFACE \
" <interface name=\"org.freedesktop.DBus.Properties\">\n" \
" <method name=\"Get\">\n" \
" <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n" \
" <arg name=\"property\" direction=\"in\" type=\"s\"/>\n" \
" <arg name=\"value\" direction=\"out\" type=\"v\"/>\n" \
" </method>\n" \
" <method name=\"GetAll\">\n" \
" <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n" \
" <arg name=\"properties\" direction=\"out\" type=\"a{sv}\"/>\n" \
" </method>\n" \
" <method name=\"Set\">\n" \
" <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n" \
" <arg name=\"property\" direction=\"in\" type=\"s\"/>\n" \
" <arg name=\"value\" direction=\"in\" type=\"v\"/>\n" \
" </method>\n" \
" <signal name=\"PropertiesChanged\">\n" \
" <arg type=\"s\" name=\"interface\"/>\n" \
" <arg type=\"a{sv}\" name=\"changed_properties\"/>\n" \
" <arg type=\"as\" name=\"invalidated_properties\"/>\n" \
" </signal>\n" \
" </interface>\n"
#define BUS_INTROSPECTABLE_INTERFACE \
" <interface name=\"org.freedesktop.DBus.Introspectable\">\n" \
" <method name=\"Introspect\">\n" \
" <arg name=\"data\" type=\"s\" direction=\"out\"/>\n" \
" </method>\n" \
" </interface>\n"
#define BUS_PEER_INTERFACE \
"<interface name=\"org.freedesktop.DBus.Peer\">\n" \
" <method name=\"Ping\"/>\n" \
" <method name=\"GetMachineId\">\n" \
" <arg type=\"s\" name=\"machine_uuid\" direction=\"out\"/>\n" \
" </method>\n" \
"</interface>\n"
#define BUS_GENERIC_INTERFACES_LIST \
"org.freedesktop.DBus.Properties\0" \
"org.freedesktop.DBus.Introspectable\0" \
"org.freedesktop.DBus.Peer\0"
int bus_check_peercred(DBusConnection *c);
int bus_connect_system_ssh(const char *user, const char *host, DBusConnection **_bus, DBusError *error);
typedef struct BusProperty {
const char *property; /* name of the property */
const char *signature;
* uint16_t is sufficient, because we have no structs too big.
* -Werror=overflow will catch it if this does not hold. */
bool indirect; /* data is indirect, ie. not base+offset, but *(base+offset) */
} BusProperty;
typedef struct BusBoundProperties {
const char *interface; /* interface of the properties */
const void *const base; /* base pointer to which the offset must be added to reach data */
DBusMessage *reply);
DBusConnection *c,
int error);
DBusConnection *c,
const char *introspection,
const char *interfaces,
const BusBoundProperties *bound_properties);
const char *value; \
\
assert(i); \
\
\
return -ENOMEM; \
\
return 0; \
}
const char *value; \
\
assert(i); \
\
dbus_message_iter_get_basic(i, &value); \
\
if (f < 0) \
return f; \
\
*field = f; \
return 0; \
}
const char *bus_errno_to_dbus(int error);
DBusMessage* bus_properties_changed_new(const char *path, const char *interface, const char *properties);
DBusMessage* bus_properties_changed_one_new(const char *path, const char *interface, const char *property);
const char *destination,
const char *path,
const char *interface,
const char *method,
int first_arg_type, ...);
const char *bus_message_get_sender_with_fallback(DBusMessage *m);