return 1;
}
+static int
+_on_cmd_manager_profile_remove(char *cmd, char *args)
+{
+ E_Connman_Element *e;
+
+ if (!args)
+ {
+ fputs("ERROR: missing the profile path\n", stderr);
+ return 1;
+ }
+ _tok(args);
+
+ e = e_connman_profile_get(args);
+ if (e_connman_manager_profile_remove(e, NULL, NULL))
+ printf(":::Manager Remove Profile %s\n", args);
+ else
+ fputs("ERROR: can't remove profile from manager\n", stderr);
+ return 1;
+}
+
+static int
+_on_cmd_manager_profile_get_active(char *cmd, char *args)
+{
+ E_Connman_Element *e;
+
+ if (!e_connman_manager_profile_active_get(&e))
+ fputs("ERROR: can't active_get profile from manager\n", stderr);
+ else
+ e_connman_element_print(stderr, e);
+ return 1;
+}
+
+static int
+_on_cmd_manager_profile_set_active(char *cmd, char *args)
+{
+ E_Connman_Element *e;
+
+ if (!args)
+ {
+ fputs("ERROR: missing the profile path\n", stderr);
+ return 1;
+ }
+ _tok(args);
+
+ e = e_connman_profile_get(args);
+ if (e_connman_manager_profile_active_set(e, NULL, NULL))
+ printf(":::Manager Active Profile set to %s\n", args);
+ else
+ fputs("ERROR: can't set active profile\n", stderr);
+ return 1;
+}
+
/* Device Commands */
static int
_on_cmd_device_propose_scan(char *cmd, char *args)
e = e_connman_profile_get(path);
if (e_connman_profile_name_set(e, next_args, NULL, NULL))
- printf(":::Profile %s Name set to %hhu\n", path, next_args);
+ printf(":::Profile %s Name set to %s\n", path, next_args);
else
fputs("ERROR: can't set profile name\n", stderr);
return 1;
{"manager_request_scan", _on_cmd_manager_request_scan},
{"manager_technology_enable", _on_cmd_manager_technology_enable},
{"manager_technology_disable", _on_cmd_manager_technology_disable},
+ {"manager_profile_remove", _on_cmd_manager_profile_remove},
+ {"manager_profile_get_active", _on_cmd_manager_profile_get_active},
+ {"manager_profile_set_active", _on_cmd_manager_profile_set_active},
{"device_propose_scan", _on_cmd_device_propose_scan},
{"device_get_address", _on_cmd_device_get_address},
{"device_get_name", _on_cmd_device_get_name},
}
static bool
+_test_element_get_global(const char *name, bool (*func)(E_Connman_Element **value))
+{
+ E_Connman_Element *value;
+ bool ret;
+
+ INF("BEGIN: testing element get %s\n", name);
+ ret = func(&value);
+ if (ret)
+ INF("SUCCESS: testing element get %s: %p\n", name, value);
+ else
+ WRN("FAILURE: testing element get %s\n", name);
+
+ return ret;
+}
+
+static bool
_test_elements_get_global(const char *name, bool (*func)(unsigned int *count, E_Connman_Element ***elements))
{
E_Connman_Element **value;
TEST_DESC_TYPE_UCHAR_ARRAY_GET,
TEST_DESC_TYPE_ELEMENT_GET,
TEST_DESC_TYPE_ELEMENTS_GET,
+ TEST_DESC_TYPE_ELEMENT_GET_GLOBAL,
TEST_DESC_TYPE_ELEMENTS_GET_GLOBAL,
TEST_DESC_TYPE_STRING_GET_GLOBAL,
TEST_DESC_TYPE_BOOL_GET_GLOBAL,
bool (*uchar_array_get)(const E_Connman_Element *element, unsigned int *count, unsigned char **value);
bool (*element_get)(const E_Connman_Element *element, E_Connman_Element **value);
bool (*elements_get)(const E_Connman_Element *element, unsigned int *count, E_Connman_Element ***elements);
+ bool (*element_get_global)(E_Connman_Element **element);
bool (*elements_get_global)(unsigned int *count, E_Connman_Element ***elements);
bool (*string_get_global)(const char **value);
bool (*bool_get_global)(bool *value);
{#_func, TEST_DESC_TYPE_ELEMENT_GET, .func.element_get=_func, may_fail}
#define TEST_DESC_ELEMENTS_GET(_func, may_fail) \
{#_func, TEST_DESC_TYPE_ELEMENTS_GET, .func.elements_get=_func, may_fail}
+#define TEST_DESC_ELEMENT_GET_GLOBAL(_func, may_fail) \
+ {#_func, TEST_DESC_TYPE_ELEMENT_GET_GLOBAL, .func.element_get_global=_func, may_fail}
#define TEST_DESC_ELEMENTS_GET_GLOBAL(_func, may_fail) \
{#_func, TEST_DESC_TYPE_ELEMENTS_GET_GLOBAL, .func.elements_get_global=_func, may_fail}
#define TEST_DESC_STRING_GET_GLOBAL(_func, may_fail) \
r = _test_elements_get
(element, itr->name, itr->func.elements_get);
break;
+ case TEST_DESC_TYPE_ELEMENT_GET_GLOBAL:
+ r = _test_element_get_global
+ (itr->name, itr->func.element_get_global);
+ break;
case TEST_DESC_TYPE_ELEMENTS_GET_GLOBAL:
r = _test_elements_get_global
(itr->name, itr->func.elements_get_global);
TEST_DESC_ELEMENTS_GET_GLOBAL(e_connman_manager_profiles_get, 0),
TEST_DESC_ELEMENTS_GET_GLOBAL(e_connman_manager_devices_get, 0),
TEST_DESC_ELEMENTS_GET_GLOBAL(e_connman_manager_services_get, 1),
+ TEST_DESC_STRING_GET_GLOBAL(e_connman_manager_technology_default_get, 0),
+ TEST_DESC_ELEMENT_GET_GLOBAL(e_connman_manager_profile_active_get, 0),
TEST_DESC_SENTINEL
};
Eina_Inlist *request_scan;
Eina_Inlist *technology_enable;
Eina_Inlist *technology_disable;
+ Eina_Inlist *profile_remove;
Eina_Inlist *device_propose_scan;
Eina_Inlist *service_connect;
Eina_Inlist *service_disconnect;
EAPI bool e_connman_manager_technology_enable(const char *type, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
EAPI bool e_connman_manager_technology_disable(const char *type, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+ EAPI bool e_connman_manager_profile_remove(const E_Connman_Element *profile, E_DBus_Method_Return_Cb cb, const void *data) EINA_WARN_UNUSED_RESULT;
+
+ EAPI bool e_connman_manager_profile_active_get(E_Connman_Element **profile) EINA_ARG_NONNULL(1) EINA_PURE EINA_WARN_UNUSED_RESULT;
+ EAPI bool e_connman_manager_profile_active_set(const E_Connman_Element *profile, E_DBus_Method_Return_Cb cb, const void *data) EINA_WARN_UNUSED_RESULT;
+
+
// TODO: profile_create()
- // TODO: profile_remove()
- // TODO: profile_active_get()
- // TODO: profile_active_set()
// TODO: technologies_available_get()
// TODO: technologies_enabled_get()
// TODO: technologies_connected_get()
const char *e_connman_prop_powered = NULL;
const char *e_connman_prop_priority = NULL;
const char *e_connman_prop_profiles = NULL;
+const char *e_connman_prop_profile_active = NULL;
const char *e_connman_prop_services = NULL;
const char *e_connman_prop_remember = NULL;
const char *e_connman_prop_scan_interval = NULL;
e_connman_prop_priority = eina_stringshare_add("Priority");
if (e_connman_prop_profiles == NULL)
e_connman_prop_profiles = eina_stringshare_add("Profiles");
+ if (e_connman_prop_profile_active == NULL)
+ e_connman_prop_profile_active = eina_stringshare_add("ActiveProfile");
if (e_connman_prop_services == NULL)
e_connman_prop_services = eina_stringshare_add("Services");
if (e_connman_prop_remember == NULL)
_stringshare_del(&e_connman_prop_powered);
_stringshare_del(&e_connman_prop_priority);
_stringshare_del(&e_connman_prop_profiles);
+ _stringshare_del(&e_connman_prop_profile_active);
_stringshare_del(&e_connman_prop_services);
_stringshare_del(&e_connman_prop_remember);
_stringshare_del(&e_connman_prop_scan_interval);
e_connman_element_pending_cancel_and_free(&element->_pending.request_scan);
e_connman_element_pending_cancel_and_free(&element->_pending.technology_enable);
e_connman_element_pending_cancel_and_free(&element->_pending.technology_disable);
+ e_connman_element_pending_cancel_and_free(&element->_pending.profile_remove);
e_connman_element_pending_cancel_and_free(&element->_pending.device_propose_scan);
e_connman_element_pending_cancel_and_free(&element->_pending.service_connect);
e_connman_element_pending_cancel_and_free(&element->_pending.service_disconnect);
* If zero is returned, then this call failed and parameter-returned
* values shall be considered invalid.
*
- *The current connected technology which holds the default route.
+ * The current connected technology which holds the default route.
*
* @param type where to store the property value, must be a pointer
* to string (const char **), it will not be allocated or
return e_connman_element_property_get_stringshared
(element, e_connman_prop_technology_default, NULL, type);
}
+
+/**
+ * Remove specified profile.
+ *
+ * Call method RemoveProfile(profile) on server.
+ *
+ * It is not possible to remove the current active profile. To remove
+ * the active profile a different one must be selected via
+ * ActiveProfile property first.
+ *
+ * At minimum one profile must be available all the time.
+ *
+ * @param profile element to remove, must be of type profile.
+ * @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_connman_manager_profile_remove(const E_Connman_Element *profile, E_DBus_Method_Return_Cb cb, const void *data)
+{
+ E_Connman_Element *element;
+ const char name[] = "RemoveProfile";
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(profile, 0);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(profile->path, 0);
+
+ if (!e_connman_element_is_profile(profile))
+ return 0;
+
+ element = e_connman_manager_get();
+ if (!element)
+ return 0;
+
+ return e_connman_element_call_with_path
+ (element, name, profile->path, NULL,
+ &element->_pending.profile_remove, cb, data);
+}
+
+/**
+ * Get property "ActiveProfile" 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 element where to store the element, just changed if return is 1
+ *
+ * @return 1 on success, 0 otherwise.
+ *
+ * @see e_connman_manager_profile_active_set()
+ */
+bool
+e_connman_manager_profile_active_get(E_Connman_Element **profile)
+{
+ E_Connman_Element *element;
+ char *profile_path;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(profile, 0);
+
+ element = e_connman_manager_get();
+ if (!element)
+ return 0;
+ if (!e_connman_element_property_get_stringshared
+ (element, e_connman_prop_profile_active, NULL, &profile_path))
+ return 0;
+ *profile = e_connman_element_get(profile_path);
+ return 1;
+}
+
+/**
+ * Call method SetProperty("ActiveProfile", profile) 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_CONNMAN_EVENT_ELEMENT_UPDATED will be added to main loop.
+ *
+ * @param profile object 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_connman_manager_profile_active_get()
+ */
+bool
+e_connman_manager_profile_active_set(const E_Connman_Element *profile, E_DBus_Method_Return_Cb cb, const void *data)
+{
+ E_Connman_Element *element;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(profile, 0);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(profile->path, 0);
+
+ if (!e_connman_element_is_profile(profile))
+ return 0;
+
+ element = e_connman_manager_get();
+ if (!element)
+ return 0;
+ return e_connman_element_property_set_full
+ (element, e_connman_prop_profile_active, DBUS_TYPE_OBJECT_PATH,
+ profile->path, cb, data);
+}
extern const char *e_connman_prop_powered;
extern const char *e_connman_prop_priority;
extern const char *e_connman_prop_profiles;
+extern const char *e_connman_prop_profile_active;
extern const char *e_connman_prop_services;
extern const char *e_connman_prop_remember;
extern const char *e_connman_prop_scan_interval;