extern int E_BLUEZ_EVENT_ELEMENT_DEL;
extern int E_BLUEZ_EVENT_ELEMENT_UPDATED;
extern int E_BLUEZ_EVENT_DEVICE_FOUND;
+ // TODO: extern int E_BLUEZ_EVENT_DEVICE_DISAPPEARED;
typedef struct _E_Bluez_Element E_Bluez_Element;
typedef struct _E_Bluez_Array E_Bluez_Array;
struct _E_Bluez_Device_Found
{
- E_Bluez_Element *adapter;
- const char *name;
- E_Bluez_Array *array;
+ E_Bluez_Element *adapter;
+ const char *name;
+ E_Bluez_Array *array;
};
/* General Public API */
EAPI Eina_Bool e_bluez_manager_default_adapter(E_DBus_Method_Return_Cb cb, void *data) EINA_WARN_UNUSED_RESULT;
/* Adapter Methods */
- EAPI Eina_Bool e_bluez_adapter_agent_register(E_Bluez_Element *element, const char *object_path, const char *capability, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
- EAPI Eina_Bool e_bluez_adapter_agent_unregister(E_Bluez_Element *element, const char *object_path, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
- EAPI Eina_Bool e_bluez_adapter_address_get(E_Bluez_Element *element, const char **address) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
- EAPI Eina_Bool e_bluez_adapter_name_get(E_Bluez_Element *element, const char **name) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+ EAPI E_Bluez_Element *e_bluez_adapter_get(const char *path) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+
+ EAPI Eina_Bool e_bluez_adapter_agent_register(E_Bluez_Element *element, const char *object_path, const char *capability, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
+ EAPI Eina_Bool e_bluez_adapter_agent_unregister(E_Bluez_Element *element, const char *object_path, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
+ EAPI Eina_Bool e_bluez_adapter_address_get(const E_Bluez_Element *element, const char **address) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
+ EAPI Eina_Bool e_bluez_adapter_name_get(const E_Bluez_Element *element, const char **name) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
EAPI Eina_Bool e_bluez_adapter_name_set(E_Bluez_Element *element, const char *name, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1,2) EINA_WARN_UNUSED_RESULT;
- EAPI Eina_Bool e_bluez_adapter_powered_get(E_Bluez_Element *element, Eina_Bool *powered) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+ EAPI Eina_Bool e_bluez_adapter_powered_get(const E_Bluez_Element *element, Eina_Bool *powered) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
EAPI Eina_Bool e_bluez_adapter_powered_set(E_Bluez_Element *profile, Eina_Bool powered, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
- EAPI Eina_Bool e_bluez_adapter_discoverable_get(E_Bluez_Element *element, Eina_Bool *discoverable) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
- EAPI Eina_Bool e_bluez_adapter_discoverable_set(E_Bluez_Element *profile, Eina_Bool discoverable, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+ EAPI Eina_Bool e_bluez_adapter_discoverable_get(const E_Bluez_Element *element, Eina_Bool *discoverable) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+ EAPI Eina_Bool e_bluez_adapter_discoverable_set(E_Bluez_Element *profile, Eina_Bool discoverable, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
EAPI Eina_Bool e_bluez_adapter_discoverable_timeout_get(const E_Bluez_Element *element, unsigned int *timeout) EINA_ARG_NONNULL(1,2) EINA_WARN_UNUSED_RESULT;
EAPI Eina_Bool e_bluez_adapter_discoverable_timeout_set(E_Bluez_Element *element, unsigned int timeout, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
- EAPI Eina_Bool e_bluez_adapter_discovering_get(E_Bluez_Element *element, Eina_Bool *discovering) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+ EAPI Eina_Bool e_bluez_adapter_discovering_get(const E_Bluez_Element *element, Eina_Bool *discovering) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
EAPI Eina_Bool e_bluez_adapter_start_discovery(E_Bluez_Element *element, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
EAPI Eina_Bool e_bluez_adapter_stop_discovery(E_Bluez_Element *element, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
- EAPI Eina_Bool e_bluez_adapter_create_paired_device(E_Bluez_Element *element, const char *object_path, const char *capability, const char *device, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1,2,4) EINA_WARN_UNUSED_RESULT;
+ EAPI Eina_Bool e_bluez_adapter_create_paired_device(E_Bluez_Element *element, const char *object_path, const char *capability, const char *device, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1, 2, 4) EINA_WARN_UNUSED_RESULT;
/* Device Found Methods */
EAPI void e_bluez_devicefound_free(E_Bluez_Device_Found *device) EINA_ARG_NONNULL(1);
EAPI const char *e_bluez_devicefound_alias_get(const E_Bluez_Device_Found *device) EINA_ARG_NONNULL(1);
/* Devices Methods */
- EAPI Eina_Bool e_bluez_device_name_get(E_Bluez_Element *element, const char **name) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+ EAPI E_Bluez_Element *e_bluez_device_get(const char *path) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+ EAPI Eina_Bool e_bluez_device_name_get(const E_Bluez_Element *element, const char **name) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
+ EAPI Eina_Bool e_bluez_device_alias_get(const E_Bluez_Element *element, const char **alias) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
+ EAPI Eina_Bool e_bluez_device_paired_get(const E_Bluez_Element *element, Eina_Bool *paired) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
/* Low-Level API:
*
#include "e_bluez_private.h"
+E_Bluez_Element *
+e_bluez_adapter_get(const char *path)
+{
+ E_Bluez_Element *adapter;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
+
+ adapter = e_bluez_element_get(path);
+ if (!adapter)
+ return NULL;
+
+ if (!e_bluez_element_is_adapter(adapter))
+ {
+ WRN("path '%s' is not a adapter!", path);
+ return NULL;
+ }
+
+ return adapter;
+}
+
static void
_device_found_callback(void *data, DBusMessage *msg)
{
{
const char name[] = "RegisterAgent";
+ EINA_SAFETY_ON_NULL_RETURN_VAL(element, 0);
EINA_SAFETY_ON_NULL_RETURN_VAL(object_path, 0);
return e_bluez_element_call_with_path_and_string
* @return 1 on success, 0 otherwise.
*/
Eina_Bool
-e_bluez_adapter_address_get(E_Bluez_Element *element, const char **address)
+e_bluez_adapter_address_get(const E_Bluez_Element *element, const char **address)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(element, 0);
EINA_SAFETY_ON_NULL_RETURN_VAL(address, 0);
* @return 1 on success, 0 otherwise.
*/
Eina_Bool
-e_bluez_adapter_name_get(E_Bluez_Element *element, const char **name)
+e_bluez_adapter_name_get(const E_Bluez_Element *element, const char **name)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(element, 0);
EINA_SAFETY_ON_NULL_RETURN_VAL(name, 0);
* @see e_bluez_adapter_powered_set()
*/
Eina_Bool
-e_bluez_adapter_powered_get(E_Bluez_Element *element, Eina_Bool *powered)
+e_bluez_adapter_powered_get(const E_Bluez_Element *element, Eina_Bool *powered)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(element, 0);
EINA_SAFETY_ON_NULL_RETURN_VAL(powered, 0);
* @see e_bluez_adapter_discoverable_set()
*/
Eina_Bool
-e_bluez_adapter_discoverable_get(E_Bluez_Element *element, Eina_Bool *discoverable)
+e_bluez_adapter_discoverable_get(const E_Bluez_Element *element, Eina_Bool *discoverable)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(element, 0);
EINA_SAFETY_ON_NULL_RETURN_VAL(discoverable, 0);
* @see e_bluez_adapter_discovering_set()
*/
Eina_Bool
-e_bluez_adapter_discovering_get(E_Bluez_Element *element, Eina_Bool *discovering)
+e_bluez_adapter_discovering_get(const E_Bluez_Element *element, Eina_Bool *discovering)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(element, 0);
EINA_SAFETY_ON_NULL_RETURN_VAL(discovering, 0);
#include "e_bluez_private.h"
+E_Bluez_Element *
+e_bluez_device_get(const char *path)
+{
+ E_Bluez_Element *device;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
+
+ device = e_bluez_element_get(path);
+ if (!device)
+ return NULL;
+
+ if (!e_bluez_element_is_device(device))
+ {
+ WRN("path '%s' is not a device!", path);
+ return NULL;
+ }
+
+ return device;
+}
+
/**
* Get property "Name" value.
*
* @return 1 on success, 0 otherwise.
*/
Eina_Bool
-e_bluez_device_name_get(E_Bluez_Element *element, const char **name)
+e_bluez_device_name_get(const E_Bluez_Element *element, const char **name)
{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(element, 0);
EINA_SAFETY_ON_NULL_RETURN_VAL(name, 0);
return e_bluez_element_property_get_stringshared
(element, e_bluez_prop_name, NULL, name);
}
+
+/**
+ * Get property "Alias" value.
+ *
+ * If this property isn't found then 0 is returned.
+ * If zero is returned, then this call failed and parameter-returned
+ * values shall be considered invalid.
+ *
+ * @param address where to store the property value, must be a pointer
+ * to string (const char **), it will not be allocated or
+ * copied and references will be valid until element changes,
+ * so copy it if you want to use it later.
+ *
+ * @return 1 on success, 0 otherwise.
+ */
+Eina_Bool
+e_bluez_device_alias_get(const E_Bluez_Element *element, const char **alias)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(element, 0);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(alias, 0);
+
+ return e_bluez_element_property_get_stringshared
+ (element, e_bluez_prop_alias, NULL, alias);
+}
+
+/**
+ * Get property "Paired" value.
+ *
+ * If this property isn't found then 0 is returned.
+ * If zero is returned, then this call failed and parameter-returned
+ * values shall be considered invalid.
+ *
+ * @param powered where to store the property value, must be a pointer
+ * to boolean (Eina_Bool *).
+ *
+ * @return 1 on success, 0 otherwise.
+ */
+Eina_Bool
+e_bluez_device_paired_get(const E_Bluez_Element *element, Eina_Bool *paired)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(element, 0);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(paired, 0);
+
+ return e_bluez_element_property_get_stringshared
+ (element, e_bluez_prop_paired, NULL, paired);
+}