summaryrefslogtreecommitdiffstats
path: root/binding/bluetooth-api.h
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2018-09-24 14:40:32 +0800
committerMatt Ranostay <matt.ranostay@konsulko.com>2018-11-23 08:49:14 -0800
commitcfd9944c77a61215250c3b0f81978a1236d4c590 (patch)
treeb345083c1061d156b2bf1168d7474c419a18864a /binding/bluetooth-api.h
parentdfff48e48f646e021e6d2b8326cd7fdc3d706d9c (diff)
binding: bluetooth: return adapter/device versus bluez path
To allow this binding API to be bluetooth stack agnostic remove pure bluez paths, and replace with generic fields. Bug-AGL: SPEC-1630 Change-Id: Iadba73782b6339df2ca5937e16a654e7ef3e477b Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Diffstat (limited to 'binding/bluetooth-api.h')
-rw-r--r--binding/bluetooth-api.h32
1 files changed, 29 insertions, 3 deletions
diff --git a/binding/bluetooth-api.h b/binding/bluetooth-api.h
index 50bf501..d8df0af 100644
--- a/binding/bluetooth-api.h
+++ b/binding/bluetooth-api.h
@@ -37,6 +37,18 @@
#define BLUEZ_OBJECT_PATH "/"
#define BLUEZ_PATH "/org/bluez"
+#define BLUEZ_ROOT_PATH(_t) \
+ ({ \
+ const char *__t = (_t); \
+ size_t __len = strlen(BLUEZ_PATH) + 1 + \
+ strlen(__t) + 1; \
+ char *__tpath; \
+ __tpath = alloca(__len + 1 + 1); \
+ snprintf(__tpath, __len + 1, \
+ BLUEZ_PATH "/%s", __t); \
+ __tpath; \
+ })
+
#define FREEDESKTOP_INTROSPECT "org.freedesktop.DBus.Introspectable"
#define FREEDESKTOP_PROPERTIES "org.freedesktop.DBus.Properties"
#define FREEDESKTOP_OBJECTMANAGER "org.freedesktop.DBus.ObjectManager"
@@ -52,7 +64,22 @@
struct bluetooth_state;
-static inline const char *bluez_strip_path(const char *path)
+static inline gchar *bluez_return_adapter(const char *path)
+{
+ gchar **strings = g_strsplit(path, "/", -1);
+ gchar *adapter;
+
+ if (g_strv_length(strings) < 3) {
+ g_strfreev(strings);
+ return NULL;
+ }
+ adapter = g_strdup(strings[3]);
+ g_strfreev(strings);
+
+ return adapter;
+}
+
+static inline gchar *bluez_return_device(const char *path)
{
const char *basename;
@@ -61,10 +88,9 @@ static inline const char *bluez_strip_path(const char *path)
return NULL;
basename++;
/* at least one character */
- return *basename ? basename : NULL;
+ return *basename ? g_strdup(basename) : NULL;
}
-
struct call_work *call_work_create_unlocked(struct bluetooth_state *ns,
const char *access_type, const char *type_arg,
const char *method, const char *bluez_method,