diff options
author | Matt Ranostay <matt.ranostay@konsulko.com> | 2018-09-24 14:40:32 +0800 |
---|---|---|
committer | Matt Ranostay <matt.ranostay@konsulko.com> | 2018-11-12 03:58:47 -0800 |
commit | 62a466a8934bd3240aa202bdf28103617220619b (patch) | |
tree | bfc6ad2f91df886875baae4cc652331213055ff8 /binding/bluetooth-api.h | |
parent | 8e9fed1ef996277bc192bddbeb07747a2b9981fa (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.h | 32 |
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, |