linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC BlueZ 1/3] gdbus: Add g_dbus_list_interfaces function
@ 2012-03-06 12:07 Luiz Augusto von Dentz
  2012-03-06 12:07 ` [RFC BlueZ 2/3] core: Add Interfaces property to org.bluez.Adapter Luiz Augusto von Dentz
  2012-03-06 12:07 ` [RFC BlueZ 3/3] core: Add Interfaces property to org.bluez.Device Luiz Augusto von Dentz
  0 siblings, 2 replies; 9+ messages in thread
From: Luiz Augusto von Dentz @ 2012-03-06 12:07 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This function can be used to list interfaces registered in a given path
---
 gdbus/gdbus.h  |    2 ++
 gdbus/object.c |   34 ++++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/gdbus/gdbus.h b/gdbus/gdbus.h
index a0583e6..26ed6d2 100644
--- a/gdbus/gdbus.h
+++ b/gdbus/gdbus.h
@@ -119,6 +119,8 @@ gboolean g_dbus_register_interface(DBusConnection *connection,
 					GDBusDestroyFunction destroy);
 gboolean g_dbus_unregister_interface(DBusConnection *connection,
 					const char *path, const char *name);
+char **g_dbus_list_interfaces(DBusConnection *connection, const char *path,
+								int *num);
 
 gboolean g_dbus_register_security(const GDBusSecurityTable *security);
 gboolean g_dbus_unregister_security(const GDBusSecurityTable *security);
diff --git a/gdbus/object.c b/gdbus/object.c
index 8bc12f5..1701b8f 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -723,6 +723,40 @@ gboolean g_dbus_unregister_interface(DBusConnection *connection,
 	return TRUE;
 }
 
+char **g_dbus_list_interfaces(DBusConnection *connection, const char *path,
+								int *num)
+{
+	struct generic_data *data;
+	GSList *l;
+	char **array;
+	int i, n;
+
+	if (!dbus_connection_get_object_path_data(connection, path,
+						(void *) &data))
+		return NULL;
+
+	if (data->interfaces == NULL)
+		return NULL;
+
+	n = g_slist_length(data->interfaces);
+	array = g_new0(char *, n + 1);
+
+	for (i = 0, l = data->interfaces; l; l = l->next) {
+		struct interface_data *iface = l->data;
+
+		if (g_strcmp0(iface->name,
+				DBUS_INTERFACE_INTROSPECTABLE) == 0)
+			continue;
+
+		array[i++] = g_strdup(iface->name);
+	}
+
+	if (num)
+		*num = i;
+
+	return array;
+}
+
 gboolean g_dbus_register_security(const GDBusSecurityTable *security)
 {
 	if (security_table != NULL)
-- 
1.7.7.6


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-03-07 19:14 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-06 12:07 [RFC BlueZ 1/3] gdbus: Add g_dbus_list_interfaces function Luiz Augusto von Dentz
2012-03-06 12:07 ` [RFC BlueZ 2/3] core: Add Interfaces property to org.bluez.Adapter Luiz Augusto von Dentz
2012-03-06 12:07 ` [RFC BlueZ 3/3] core: Add Interfaces property to org.bluez.Device Luiz Augusto von Dentz
2012-03-06 12:57   ` Anderson Lizardo
2012-03-06 13:26     ` Luiz Augusto von Dentz
2012-03-06 14:35       ` Marcel Holtmann
2012-03-07  8:14         ` Luiz Augusto von Dentz
2012-03-07 14:39           ` Vinicius Costa Gomes
2012-03-07 19:14           ` Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).