From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ 4/8] gdbus: Check if the interface being registered is valid
Date: Sun, 23 Dec 2012 22:15:14 +0200 [thread overview]
Message-ID: <1356293718-9348-4-git-send-email-luiz.dentz@gmail.com> (raw)
In-Reply-To: <1356293718-9348-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This prevent registering interfaces that are empty or have all members
marked as experiemental.
---
gdbus/object.c | 42 ++++++++++++++++++++++++++++++++++++------
1 file changed, 36 insertions(+), 6 deletions(-)
diff --git a/gdbus/object.c b/gdbus/object.c
index 7b58eea..d864bf5 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -1177,7 +1177,7 @@ static const GDBusSignalTable manager_signals[] = {
{ }
};
-static void add_interface(struct generic_data *data,
+static gboolean add_interface(struct generic_data *data,
const char *name,
const GDBusMethodTable *methods,
const GDBusSignalTable *signals,
@@ -1186,7 +1186,32 @@ static void add_interface(struct generic_data *data,
GDBusDestroyFunction destroy)
{
struct interface_data *iface;
+ const GDBusMethodTable *method;
+ const GDBusSignalTable *signal;
+ const GDBusPropertyTable *property;
+
+ for (method = methods; method && method->name; method++) {
+ if (!check_experimental(method->flags,
+ G_DBUS_METHOD_FLAG_EXPERIMENTAL))
+ goto done;
+ }
+
+ for (signal = signals; signal && signal->name; signal++) {
+ if (!check_experimental(signal->flags,
+ G_DBUS_SIGNAL_FLAG_EXPERIMENTAL))
+ goto done;
+ }
+
+ for (property = properties; property && property->name; property++) {
+ if (!check_experimental(property->flags,
+ G_DBUS_PROPERTY_FLAG_EXPERIMENTAL))
+ goto done;
+ }
+ /* Nothing to register */
+ return FALSE;
+
+done:
iface = g_new0(struct interface_data, 1);
iface->name = g_strdup(name);
iface->methods = methods;
@@ -1197,13 +1222,15 @@ static void add_interface(struct generic_data *data,
data->interfaces = g_slist_append(data->interfaces, iface);
if (data->parent == NULL)
- return;
+ return TRUE;
data->added = g_slist_append(data->added, iface);
if (data->process_id > 0)
- return;
+ return TRUE;
data->process_id = g_idle_add(process_changes, data);
+
+ return TRUE;
}
static struct generic_data *object_path_ref(DBusConnection *connection,
@@ -1364,15 +1391,18 @@ gboolean g_dbus_register_interface(DBusConnection *connection,
return FALSE;
}
+ if (!add_interface(data, name, methods, signals, properties, user_data,
+ destroy)) {
+ object_path_unref(connection, path);
+ return FALSE;
+ }
+
if (properties != NULL && !find_interface(data->interfaces,
DBUS_INTERFACE_PROPERTIES))
add_interface(data, DBUS_INTERFACE_PROPERTIES,
properties_methods, properties_signals, NULL,
data, NULL);
- add_interface(data, name, methods, signals, properties, user_data,
- destroy);
-
g_free(data->introspect);
data->introspect = NULL;
--
1.7.11.7
next prev parent reply other threads:[~2012-12-23 20:15 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-23 20:15 [PATCH BlueZ 1/8] gdbus: Introduce G_DBUS_METHOD_FLAG_EXPERIMENTAL Luiz Augusto von Dentz
2012-12-23 20:15 ` [PATCH BlueZ 2/8] gdbus: Introduce G_DBUS_SIGNAL_FLAG_EXPERIMENTAL Luiz Augusto von Dentz
2012-12-23 20:15 ` [PATCH BlueZ 3/8] gdbus: Introduce G_DBUS_PROPERTY_FLAG_EXPERIMENTAL Luiz Augusto von Dentz
2012-12-23 20:15 ` Luiz Augusto von Dentz [this message]
2012-12-23 20:15 ` [PATCH BlueZ 5/8] gdbus: Call check_signals when sending signals with g_dbus_send_message Luiz Augusto von Dentz
2012-12-23 20:15 ` [PATCH BlueZ 6/8] media: Enable RegisterPlayer and UnregisterPlayer methods as experimental Luiz Augusto von Dentz
2012-12-23 20:15 ` [PATCH BlueZ 7/8] player: Enable MediaPlayer1 interface " Luiz Augusto von Dentz
2012-12-23 20:15 ` [PATCH BlueZ 8/8] AVRCP: Fix not checking for media_player_controller_create Luiz Augusto von Dentz
2012-12-23 20:58 ` [PATCH BlueZ 1/8] gdbus: Introduce G_DBUS_METHOD_FLAG_EXPERIMENTAL Marcel Holtmann
2012-12-23 22:06 ` Luiz Augusto von Dentz
2012-12-23 23:35 ` Marcel Holtmann
2012-12-24 0:12 ` Luiz Augusto von Dentz
2012-12-27 8:42 ` Luiz Augusto von Dentz
2012-12-27 17:49 ` Marcel Holtmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1356293718-9348-4-git-send-email-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox