mirror of git://git.sysmocom.de/ofono
gdbus: Introduce G_DBUS_SIGNAL_FLAG_EXPERIMENTAL
This flag can be used to mark signals as experimental, marked signals are disabled by default and can be enabled by setting G_DBUS_FLAG_ENABLE_EXPERIMENTAL using g_dbus_set_flags.
This commit is contained in:
parent
4b50c0bd05
commit
4b14fcc9a1
|
@ -100,7 +100,8 @@ enum GDBusMethodFlags {
|
||||||
};
|
};
|
||||||
|
|
||||||
enum GDBusSignalFlags {
|
enum GDBusSignalFlags {
|
||||||
G_DBUS_SIGNAL_FLAG_DEPRECATED = (1 << 0),
|
G_DBUS_SIGNAL_FLAG_DEPRECATED = (1 << 0),
|
||||||
|
G_DBUS_SIGNAL_FLAG_EXPERIMENTAL = (1 << 1),
|
||||||
};
|
};
|
||||||
|
|
||||||
enum GDBusPropertyFlags {
|
enum GDBusPropertyFlags {
|
||||||
|
@ -208,6 +209,11 @@ struct GDBusSecurityTable {
|
||||||
.args = _args, \
|
.args = _args, \
|
||||||
.flags = G_DBUS_SIGNAL_FLAG_DEPRECATED
|
.flags = G_DBUS_SIGNAL_FLAG_DEPRECATED
|
||||||
|
|
||||||
|
#define GDBUS_EXPERIMENTAL_SIGNAL(_name, _args) \
|
||||||
|
.name = _name, \
|
||||||
|
.args = _args, \
|
||||||
|
.flags = G_DBUS_SIGNAL_FLAG_EXPERIMENTAL
|
||||||
|
|
||||||
void g_dbus_set_flags(int flags);
|
void g_dbus_set_flags(int flags);
|
||||||
|
|
||||||
gboolean g_dbus_register_interface(DBusConnection *connection,
|
gboolean g_dbus_register_interface(DBusConnection *connection,
|
||||||
|
|
|
@ -164,6 +164,12 @@ static void generate_interface_xml(GString *gstr, struct interface_data *iface)
|
||||||
for (signal = iface->signals; signal && signal->name; signal++) {
|
for (signal = iface->signals; signal && signal->name; signal++) {
|
||||||
gboolean deprecated = signal->flags &
|
gboolean deprecated = signal->flags &
|
||||||
G_DBUS_SIGNAL_FLAG_DEPRECATED;
|
G_DBUS_SIGNAL_FLAG_DEPRECATED;
|
||||||
|
gboolean experimental = signal->flags &
|
||||||
|
G_DBUS_SIGNAL_FLAG_EXPERIMENTAL;
|
||||||
|
|
||||||
|
if (!(global_flags & G_DBUS_FLAG_ENABLE_EXPERIMENTAL) &&
|
||||||
|
experimental)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (!deprecated && !(signal->args && signal->args->name))
|
if (!deprecated && !(signal->args && signal->args->name))
|
||||||
g_string_append_printf(gstr,
|
g_string_append_printf(gstr,
|
||||||
|
@ -1266,10 +1272,17 @@ static gboolean check_signal(DBusConnection *conn, const char *path,
|
||||||
}
|
}
|
||||||
|
|
||||||
for (signal = iface->signals; signal && signal->name; signal++) {
|
for (signal = iface->signals; signal && signal->name; signal++) {
|
||||||
if (!strcmp(signal->name, name)) {
|
if (strcmp(signal->name, name) != 0)
|
||||||
*args = signal->args;
|
continue;
|
||||||
return TRUE;
|
|
||||||
|
if (signal->flags & G_DBUS_SIGNAL_FLAG_EXPERIMENTAL) {
|
||||||
|
const char *env = g_getenv("GDBUS_EXPERIMENTAL");
|
||||||
|
if (g_strcmp0(env, "1") != 0)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*args = signal->args;
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
error("No signal named %s on interface %s", name, interface);
|
error("No signal named %s on interface %s", name, interface);
|
||||||
|
|
Loading…
Reference in New Issue