summaryrefslogtreecommitdiff
path: root/gdbus
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2012-12-28 14:50:59 +0200
committerMarcel Holtmann <marcel@holtmann.org>2012-12-30 10:49:44 -0800
commit1fbd845b552d13185252c5ced6997d891cc6b102 (patch)
treea3e1f5cd39c9ffd88e6d0fd42e36783abe3fbbfd /gdbus
parent7ccd0235ff22fd79b39cfaaf8d65f5a309058571 (diff)
downloadconnman-1fbd845b552d13185252c5ced6997d891cc6b102.tar.gz
connman-1fbd845b552d13185252c5ced6997d891cc6b102.tar.bz2
connman-1fbd845b552d13185252c5ced6997d891cc6b102.zip
gdbus: Introduce G_DBUS_METHOD_FLAG_EXPERIMENTAL
This flag can be used to mark methods as experimental, marked methods are disable by default and can be enabled by setting G_DBUS_FLAG_ENABLE_EXPERIMENTAL using g_dbus_set_flags.
Diffstat (limited to 'gdbus')
-rw-r--r--gdbus/gdbus.h27
-rw-r--r--gdbus/object.c21
2 files changed, 45 insertions, 3 deletions
diff --git a/gdbus/gdbus.h b/gdbus/gdbus.h
index 582e944f..86b5affc 100644
--- a/gdbus/gdbus.h
+++ b/gdbus/gdbus.h
@@ -88,10 +88,15 @@ typedef void (* GDBusSecurityFunction) (DBusConnection *connection,
gboolean interaction,
GDBusPendingReply pending);
+enum GDBusFlags {
+ G_DBUS_FLAG_ENABLE_EXPERIMENTAL = (1 << 0),
+};
+
enum GDBusMethodFlags {
- G_DBUS_METHOD_FLAG_DEPRECATED = (1 << 0),
- G_DBUS_METHOD_FLAG_NOREPLY = (1 << 1),
- G_DBUS_METHOD_FLAG_ASYNC = (1 << 2),
+ G_DBUS_METHOD_FLAG_DEPRECATED = (1 << 0),
+ G_DBUS_METHOD_FLAG_NOREPLY = (1 << 1),
+ G_DBUS_METHOD_FLAG_ASYNC = (1 << 2),
+ G_DBUS_METHOD_FLAG_EXPERIMENTAL = (1 << 3),
};
enum GDBusSignalFlags {
@@ -173,6 +178,20 @@ struct GDBusSecurityTable {
.function = _function, \
.flags = G_DBUS_METHOD_FLAG_ASYNC | G_DBUS_METHOD_FLAG_DEPRECATED
+#define GDBUS_EXPERIMENTAL_METHOD(_name, _in_args, _out_args, _function) \
+ .name = _name, \
+ .in_args = _in_args, \
+ .out_args = _out_args, \
+ .function = _function, \
+ .flags = G_DBUS_METHOD_FLAG_EXPERIMENTAL
+
+#define GDBUS_EXPERIMENTAL_ASYNC_METHOD(_name, _in_args, _out_args, _function) \
+ .name = _name, \
+ .in_args = _in_args, \
+ .out_args = _out_args, \
+ .function = _function, \
+ .flags = G_DBUS_METHOD_FLAG_ASYNC | G_DBUS_METHOD_FLAG_EXPERIMENTAL
+
#define GDBUS_NOREPLY_METHOD(_name, _in_args, _out_args, _function) \
.name = _name, \
.in_args = _in_args, \
@@ -189,6 +208,8 @@ struct GDBusSecurityTable {
.args = _args, \
.flags = G_DBUS_SIGNAL_FLAG_DEPRECATED
+void g_dbus_set_flags(int flags);
+
gboolean g_dbus_register_interface(DBusConnection *connection,
const char *path, const char *name,
const GDBusMethodTable *methods,
diff --git a/gdbus/object.c b/gdbus/object.c
index e13daf7d..5fe4c7c4 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -84,6 +84,7 @@ struct property_data {
DBusMessage *message;
};
+static int global_flags = 0;
static struct generic_data *root;
static gboolean process_changes(gpointer user_data);
@@ -129,6 +130,12 @@ static void generate_interface_xml(GString *gstr, struct interface_data *iface)
G_DBUS_METHOD_FLAG_DEPRECATED;
gboolean noreply = method->flags &
G_DBUS_METHOD_FLAG_NOREPLY;
+ gboolean experimental = method->flags &
+ G_DBUS_METHOD_FLAG_EXPERIMENTAL;
+
+ if (!(global_flags & G_DBUS_FLAG_ENABLE_EXPERIMENTAL) &&
+ experimental)
+ continue;
if (!deprecated && !noreply &&
!(method->in_args && method->in_args->name) &&
@@ -1022,10 +1029,19 @@ static DBusHandlerResult generic_message(DBusConnection *connection,
for (method = iface->methods; method &&
method->name && method->function; method++) {
+ gboolean experimental = method->flags &
+ G_DBUS_METHOD_FLAG_EXPERIMENTAL;
+
if (dbus_message_is_method_call(message, iface->name,
method->name) == FALSE)
continue;
+ if (experimental) {
+ const char *env = g_getenv("GDBUS_EXPERIMENTAL");
+ if (g_strcmp0(env, "1") != 0)
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ }
+
if (g_dbus_args_have_signature(method->in_args,
message) == FALSE)
continue;
@@ -1692,3 +1708,8 @@ gboolean g_dbus_detach_object_manager(DBusConnection *connection)
return TRUE;
}
+
+void g_dbus_set_flags(int flags)
+{
+ global_flags = flags;
+}