}
static int
+_on_cmd_adapter_get_name(char *cmd, char *args)
+{
+ const char *name;
+ char *next_args;
+ E_Bluez_Element *element = _element_from_args(args, &next_args);
+
+ if (!element)
+ return 1;
+
+ if (e_bluez_adapter_name_get(element, &name))
+ printf(":::Adapter name = \"%s\"\n", name);
+ else
+ fputs("ERROR: can't get adapter name\n", stderr);
+ return 1;
+}
+
+_on_cmd_adapter_set_name(char *cmd, char *args)
+{
+ char *path, *next_args;
+ E_Bluez_Element *element = _element_from_args(args, &next_args);
+
+ if (!element)
+ return 1;
+
+ if (!next_args) {
+ fprintf(stderr, "ERROR: missing name value\n");
+ return 1;
+ }
+
+ if (e_bluez_adapter_name_set(element, next_args, _method_success_check,
+ "adapter_set_name"))
+ printf(":::Adapter %s Name set to %s\n", element->path, next_args);
+ else
+ fputs("ERROR: can't set adapter name\n", stderr);
+ return 1;
+}
+
+static int
_on_cmd_adapter_get_powered(char *cmd, char *args)
{
char *next_args;
}
static int
+_on_cmd_adapter_get_discoverable(char *cmd, char *args)
+{
+ char *next_args;
+ bool discoverable;
+ E_Bluez_Element *element = _element_from_args(args, &next_args);
+
+ if (!element)
+ return 1;
+
+ if (e_bluez_adapter_discoverable_get(element, &discoverable))
+ printf(":::Adapter discoverable = \"%hhu\"\n", discoverable);
+ else
+ fputs("ERROR: can't get adapter discoverable\n", stderr);
+ return 1;
+}
+
+static int
+_on_cmd_adapter_set_discoverable(char *cmd, char *args)
+{
+ char *next_args;
+ bool discoverable;
+ E_Bluez_Element *element = _element_from_args(args, &next_args);
+
+ if (!element)
+ return 1;
+
+ if (!args)
+ {
+ fputs("ERROR: missing the discoverable value\n", stderr);
+ return 1;
+ }
+
+ discoverable = !!atol(next_args);
+
+ if (e_bluez_adapter_discoverable_set
+ (element, discoverable, _method_success_check, "adapter_set_discoverable"))
+ printf(":::Adapter %s discoverable set to %hhu\n", element->path, discoverable);
+ else
+ fputs("ERROR: can't set adapter discoverable\n", stderr);
+ return 1;
+}
+
+static int
+_on_cmd_adapter_get_discoverable_timeout(char *cmd, char *args)
+{
+ char *next_args;
+ unsigned int timeout;
+ E_Bluez_Element *element = _element_from_args(args, &next_args);
+
+ if (!element)
+ return 1;
+
+ if (e_bluez_adapter_discoverable_timeout_get(element, &timeout))
+ printf(":::Adapter %s DiscovableTimeout = %hu\n", element->path, timeout);
+ else
+ fputs("ERROR: can't get adapter discoverable timeout\n", stderr);
+ return 1;
+}
+
+static int
+_on_cmd_adapter_set_discoverable_timeout(char *cmd, char *args)
+{
+ char *device_path, *next_args, *p;
+ unsigned int timeout;
+ E_Bluez_Element *element = _element_from_args(args, &next_args);
+
+ if (!element)
+ return 1;
+
+ if (!next_args) {
+ fprintf(stderr, "ERROR: missing timeout value\n");
+ return 1;
+ }
+
+ timeout = strtol(next_args, &p, 0);
+ if (p == next_args)
+ {
+ fprintf(stderr, "ERROR: invalid number \"%s\".\n", next_args);
+ return 1;
+ }
+
+ if (e_bluez_adapter_discoverable_timeout_set(element, timeout,
+ _method_success_check,
+ "adapter_set_discoverable_timeout"))
+ printf(":::Adapter %s scan interval set to %hu\n", element->path, timeout);
+ else
+ fputs("ERROR: can't set adapter discoverable timeout\n", stderr);
+ return 1;
+}
+
+static int
_on_cmd_adapter_get_discovering(char *cmd, char *args)
{
char *next_args;
{"adapter_register_agent", _on_cmd_adapter_register_agent},
{"adapter_unregister_agent", _on_cmd_adapter_unregister_agent},
{"adapter_get_address", _on_cmd_adapter_get_address},
+ {"adapter_get_name", _on_cmd_adapter_get_name},
+ {"adapter_set_name", _on_cmd_adapter_set_name},
{"adapter_get_powered", _on_cmd_adapter_get_powered},
{"adapter_set_powered", _on_cmd_adapter_set_powered},
+ {"adapter_get_discoverable", _on_cmd_adapter_get_discoverable},
+ {"adapter_set_discoverable", _on_cmd_adapter_set_discoverable},
+ {"adapter_get_discoverable_timeout", _on_cmd_adapter_get_discoverable_timeout},
+ {"adapter_set_discoverable_timeout", _on_cmd_adapter_set_discoverable_timeout},
{"adapter_get_discovering", _on_cmd_adapter_get_discovering},
{"adapter_start_discovery", _on_cmd_adapter_start_discovery},
{"adapter_stop_discovery", _on_cmd_adapter_stop_discovery},
EAPI 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 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 bool e_bluez_adapter_address_get(E_Bluez_Element *element, const char **address) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+ EAPI bool e_bluez_adapter_name_get(E_Bluez_Element *element, const char **name) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+ EAPI 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 bool e_bluez_adapter_powered_get(E_Bluez_Element *element, bool *powered) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-
EAPI bool e_bluez_adapter_powered_set(E_Bluez_Element *profile, bool powered, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+ EAPI bool e_bluez_adapter_discoverable_get(E_Bluez_Element *element, bool *discoverable) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+ EAPI bool e_bluez_adapter_discoverable_set(E_Bluez_Element *profile, bool discoverable, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+ EAPI 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 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 bool e_bluez_adapter_discovering_get(E_Bluez_Element *element, bool *discovering) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
EAPI 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 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;
}
/**
+ * Get property "Name" 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 name 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.
+ */
+bool
+e_bluez_adapter_name_get(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);
+}
+
+/**
+ * Call method SetProperty("Name", name) at the given element on server.
+ *
+ * This is a server call, not local, so it may fail and in that case
+ * no property is updated locally. If the value was set the event
+ * E_BLUEZ_EVENT_ELEMENT_UPDATED will be added to main loop.
+ *
+ * @param name value to set.
+ * @param cb function to call when server replies or some error happens.
+ * @param data data to give to cb when it is called.
+ *
+ * @return 1 on success, 0 otherwise.
+ * @see e_bluez_adapter_name_get()
+ */
+bool
+e_bluez_adapter_name_set(E_Bluez_Element *element, const char *name, E_DBus_Method_Return_Cb cb, const void *data)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(element, 0);
+ return e_bluez_element_property_set_full
+ (element, e_bluez_prop_name, DBUS_TYPE_STRING, name, cb, data);
+}
+
+/**
* Get property "Powered" value.
*
* If this property isn't found then 0 is returned.
}
/**
+ * Get property "Discoverable" 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 discoverable where to store the property value, must be a pointer
+ * to booleans (bool *).
+ *
+ * @return 1 on success, 0 otherwise.
+ * @see e_bluez_adapter_discoverable_set()
+ */
+bool
+e_bluez_adapter_discoverable_get(E_Bluez_Element *element, bool *discoverable)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(element, 0);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(discoverable, 0);
+
+ return e_bluez_element_property_get_stringshared
+ (element, e_bluez_prop_discoverable, NULL, discoverable);
+}
+
+/**
+ * Call method SetProperty("Discoverable", discoverable) at the given
+ * element on server.
+ *
+ * @param discoverable value to set.
+ * @param cb function to call when server replies or some error happens.
+ * @param data data to give to cb when it is called.
+ *
+ * @return 1 on success, 0 otherwise.
+ */
+bool
+e_bluez_adapter_discoverable_set(E_Bluez_Element *element, bool discoverable, E_DBus_Method_Return_Cb cb, const void *data)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(element, 0);
+ return e_bluez_element_property_set_full
+ (element, e_bluez_prop_discoverable, DBUS_TYPE_BOOLEAN,
+ &discoverable, cb, data);
+}
+
+/**
+ * Get property "DiscoverableTimeout" 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 adapter path to get property.
+ * @param discoverable timeout where to store the property value, must be a pointer
+ * to uint32 (unsigned int *).
+ *
+ * @return 1 on success, 0 otherwise.
+ * @see e_bluez_adapter_discoverable_timeout_set()
+ */
+bool
+e_bluez_adapter_discoverable_timeout_get(const E_Bluez_Element *element, unsigned int *timeout)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(element, 0);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(timeout, 0);
+ return e_bluez_element_property_get_stringshared
+ (element, e_bluez_prop_discoverabletimeout, NULL, timeout);
+}
+
+/**
+ * Call method SetProperty("DiscoverableTimeout", timeout) at the given element on server.
+ *
+ * This is a server call, not local, so it may fail and in that case
+ * no property is updated locally. If the value was set the event
+ * E_BLUEZ_EVENT_ELEMENT_UPDATED will be added to main loop.
+ *
+ * @param adapter path to set property.
+ * @param discoverable timeout value to set.
+ * @param cb function to call when server replies or some error happens.
+ * @param data data to give to cb when it is called.
+ *
+ * @return 1 on success, 0 otherwise.
+ * @see e_bluez_adapter_discoverable_timeout_get()
+ */
+bool
+e_bluez_adapter_discoverable_timeout_set(E_Bluez_Element *element, unsigned int timeout, E_DBus_Method_Return_Cb cb, const void *data)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(element, 0);
+ return e_bluez_element_property_set_full
+ (element, e_bluez_prop_discoverabletimeout, DBUS_TYPE_UINT32,
+ &timeout, cb, data);
+}
+/**
* Get property "Discovering" value.
*
* If this property isn't found then 0 is returned.