couple of easy manager functions:
authorbarbieri <barbieri@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 30 Dec 2009 19:53:56 +0000 (19:53 +0000)
committerbarbieri <barbieri@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 30 Dec 2009 19:53:56 +0000 (19:53 +0000)
request_scan(type)
technology_enable(type)
technology_disable(type)

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/e_dbus@44811 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/bin/e_dbus_connman_test.c
src/bin/e_dbus_connman_test_api.c
src/lib/connman/E_Connman.h
src/lib/connman/e_connman.c
src/lib/connman/e_connman_element.c
src/lib/connman/e_connman_manager.c
src/lib/connman/e_connman_private.h

index 7bdebdb..de16f93 100644 (file)
@@ -377,6 +377,56 @@ _on_cmd_manager_set_offline_mode(char *cmd, char *args)
    return 1;
 }
 
+static int
+_on_cmd_manager_request_scan(char *cmd, char *args)
+{
+   if (args)
+     _tok(args);
+
+   if (!args)
+     args = "";
+
+   if (e_connman_manager_request_scan(args, NULL, NULL))
+     printf(":::Manager Request Scan for %s\n", args[0] ? args : "<all>");
+   else
+     fputs("ERROR: can't request scan on manager\n", stderr);
+   return 1;
+}
+
+static int
+_on_cmd_manager_technology_enable(char *cmd, char *args)
+{
+   if (!args)
+     {
+       fputs("ERROR: missing the technology type\n", stderr);
+       return 1;
+     }
+   _tok(args);
+
+   if (e_connman_manager_technology_enable(args, NULL, NULL))
+     printf(":::Manager Enable Technology %s\n", args);
+   else
+     fputs("ERROR: can't enable technology on manager\n", stderr);
+   return 1;
+}
+
+static int
+_on_cmd_manager_technology_disable(char *cmd, char *args)
+{
+   if (!args)
+     {
+       fputs("ERROR: missing the technology type\n", stderr);
+       return 1;
+     }
+   _tok(args);
+
+   if (e_connman_manager_technology_disable(args, NULL, NULL))
+     printf(":::Manager Disable Technology %s\n", args);
+   else
+     fputs("ERROR: can't disable technology on manager\n", stderr);
+   return 1;
+}
+
 /* Device Commands */
 static int
 _on_cmd_device_propose_scan(char *cmd, char *args)
@@ -1722,6 +1772,9 @@ _on_input(void *data, Ecore_Fd_Handler *fd_handler)
      {"manager_get_state", _on_cmd_manager_get_state},
      {"manager_get_offline_mode", _on_cmd_manager_get_offline_mode},
      {"manager_set_offline_mode", _on_cmd_manager_set_offline_mode},
+     {"manager_request_scan", _on_cmd_manager_request_scan},
+     {"manager_technology_enable", _on_cmd_manager_technology_enable},
+     {"manager_technology_disable", _on_cmd_manager_technology_disable},
      {"device_propose_scan", _on_cmd_device_propose_scan},
      {"device_get_address", _on_cmd_device_get_address},
      {"device_get_name", _on_cmd_device_get_name},
index b2dd609..ac60e3c 100644 (file)
@@ -335,6 +335,7 @@ _test_element(E_Connman_Element *element, const struct test_desc *test_descs)
 static const struct test_desc test_desc_manager[] = {
   TEST_DESC_STRING_GET_GLOBAL(e_connman_manager_state_get, 0),
   TEST_DESC_BOOL_GET_GLOBAL(e_connman_manager_offline_mode_get, 0),
+  //TEST_DESC_STRING_SET_GLOBAL(e_connman_manager_request_scan, 0),
   //TEST_DESC_BOOL_SET_GLOBAL(e_connman_manager_offline_mode_set, 0),
   TEST_DESC_ELEMENTS_GET_GLOBAL(e_connman_manager_profiles_get, 0),
   TEST_DESC_ELEMENTS_GET_GLOBAL(e_connman_manager_devices_get, 0),
index ff41a2e..84b578a 100644 (file)
@@ -56,6 +56,9 @@ extern "C" {
        Eina_Inlist *property_set;
        Eina_Inlist *agent_register;
        Eina_Inlist *agent_unregister;
+       Eina_Inlist *request_scan;
+       Eina_Inlist *technology_enable;
+       Eina_Inlist *technology_disable;
        Eina_Inlist *device_propose_scan;
        Eina_Inlist *service_connect;
        Eina_Inlist *service_disconnect;
@@ -76,28 +79,31 @@ extern "C" {
   EAPI unsigned int e_connman_system_shutdown(void);
 
   /* Manager Methods */
-  EAPI E_Connman_Element *e_connman_manager_get(void) EINA_ARG_NONNULL(1) EINA_PURE EINA_WARN_UNUSED_RESULT;
+  EAPI E_Connman_Element *e_connman_manager_get(void) EINA_PURE EINA_WARN_UNUSED_RESULT;
 
-  EAPI bool e_connman_manager_agent_register(const char *object_path, E_DBus_Method_Return_Cb cb, const void *data);
-  EAPI bool e_connman_manager_agent_unregister(const char *object_path, E_DBus_Method_Return_Cb cb, const void *data);
+  EAPI bool e_connman_manager_agent_register(const char *object_path, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+  EAPI bool e_connman_manager_agent_unregister(const char *object_path, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
 
-  EAPI bool e_connman_manager_state_get(const char **state);
+  EAPI bool e_connman_manager_state_get(const char **state) EINA_PURE EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
 
-  EAPI bool e_connman_manager_offline_mode_get(bool *offline);
-  EAPI bool e_connman_manager_offline_mode_set(bool offline, E_DBus_Method_Return_Cb cb, const void *data);
+  EAPI bool e_connman_manager_offline_mode_get(bool *offline) EINA_PURE EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+  EAPI bool e_connman_manager_offline_mode_set(bool offline, E_DBus_Method_Return_Cb cb, const void *data) EINA_WARN_UNUSED_RESULT;
 
-  EAPI bool e_connman_manager_profiles_get(unsigned int *count, E_Connman_Element ***p_elements);
-  EAPI bool e_connman_manager_devices_get(unsigned int *count, E_Connman_Element ***p_elements);
-  EAPI bool e_connman_manager_services_get(unsigned int *count, E_Connman_Element ***p_elements);
+  EAPI bool e_connman_manager_profiles_get(unsigned int *count, E_Connman_Element ***p_elements) EINA_WARN_UNUSED_RESULT;
+  EAPI bool e_connman_manager_devices_get(unsigned int *count, E_Connman_Element ***p_elements) EINA_WARN_UNUSED_RESULT;
+  EAPI bool e_connman_manager_services_get(unsigned int *count, E_Connman_Element ***p_elements) EINA_WARN_UNUSED_RESULT;
+
+  EAPI bool e_connman_manager_request_scan(const char *type, E_DBus_Method_Return_Cb cb, const void *data) EINA_WARN_UNUSED_RESULT;
+
+  EAPI bool e_connman_manager_technology_default_get(const char **type) EINA_ARG_NONNULL(1) EINA_PURE EINA_WARN_UNUSED_RESULT;
+
+  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;
 
   // TODO: profile_create()
   // TODO: profile_remove()
   // TODO: profile_active_get()
   // TODO: profile_active_set()
-  // TODO: request_scan()
-  // TODO: technology_enable()
-  // TODO: technology_disable()
-  // TODO: technology_default_get()
   // TODO: technologies_available_get()
   // TODO: technologies_enabled_get()
   // TODO: technologies_connected_get()
index 45994a4..ef29ad6 100644 (file)
@@ -72,6 +72,7 @@ const char *e_connman_prop_apn = NULL;
 const char *e_connman_prop_mcc = NULL;
 const char *e_connman_prop_mnc = NULL;
 const char *e_connman_prop_roaming = NULL;
+const char *e_connman_prop_technology_default = NULL;
 
 
 int _e_dbus_connman_log_dom = -1;
@@ -366,6 +367,8 @@ e_connman_system_init(E_DBus_Connection *edbus_conn)
      e_connman_prop_mnc = eina_stringshare_add("MCN");
    if (e_connman_prop_roaming == NULL)
      e_connman_prop_roaming = eina_stringshare_add("Roaming");
+   if (e_connman_prop_technology_default == NULL)
+     e_connman_prop_technology_default = eina_stringshare_add("DefaultTechnology");
 
    e_connman_conn = edbus_conn;
    cb_name_owner_changed = e_dbus_signal_handler_add
@@ -462,6 +465,7 @@ e_connman_system_shutdown(void)
    _stringshare_del(&e_connman_prop_mcc);
    _stringshare_del(&e_connman_prop_mnc);
    _stringshare_del(&e_connman_prop_roaming);
+   _stringshare_del(&e_connman_prop_technology_default);
 
    if (pending_get_name_owner)
      {
index 63a7ecb..dc03e4e 100644 (file)
@@ -703,6 +703,8 @@ e_connman_element_free(E_Connman_Element *element)
    e_connman_element_pending_cancel_and_free(&element->_pending.agent_register);
    e_connman_element_pending_cancel_and_free(&element->_pending.agent_unregister);
    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.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);
index 52317f7..d10ffc8 100644 (file)
@@ -288,3 +288,121 @@ e_connman_manager_services_get(unsigned int *count, E_Connman_Element ***p_eleme
    return e_connman_element_objects_array_get_stringshared
      (element, e_connman_prop_services, count, p_elements);
 }
+
+/**
+ * Request to trigger a scan for given technology.
+ *
+ * Call method RequestScan(type) on server in order to
+ * find new services and networks for such technology type.
+ *
+ * The empty string for type means all technolgies.
+ *
+ * @param type technology type to scan. Empty or NULL for all technologies.
+ * @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_request_scan(const char *type, E_DBus_Method_Return_Cb cb, const void *data)
+{
+   const char name[] = "RequestScan";
+   E_Connman_Element *element;
+
+   if (!type)
+     type = "";
+
+   element = e_connman_manager_get();
+   if (!element)
+     return 0;
+
+   return e_connman_element_call_with_string
+     (element, name, type, NULL,
+      &element->_pending.request_scan, cb, data);
+}
+
+/**
+ * Enable specified type of technology.
+ *
+ * Call method EnableTechnology(type) on server.
+ *
+ * @param type technology type to enable.
+ * @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_technology_enable(const char *type, E_DBus_Method_Return_Cb cb, const void *data)
+{
+   const char name[] = "EnableTechnology";
+   E_Connman_Element *element;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(type, 0);
+
+   element = e_connman_manager_get();
+   if (!element)
+     return 0;
+
+   return e_connman_element_call_with_string
+     (element, name, type, NULL,
+      &element->_pending.technology_enable, cb, data);
+}
+
+/**
+ * Disable specified type of technology.
+ *
+ * Call method DisableTechnology(type) on server.
+ *
+ * @param type technology type to disable.
+ * @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_technology_disable(const char *type, E_DBus_Method_Return_Cb cb, const void *data)
+{
+   const char name[] = "DisableTechnology";
+   E_Connman_Element *element;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(type, 0);
+
+   element = e_connman_manager_get();
+   if (!element)
+     return 0;
+
+   return e_connman_element_call_with_string
+     (element, name, type, NULL,
+      &element->_pending.technology_disable, cb, data);
+}
+
+/**
+ * Get property "DefaultTechnology" 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.
+ *
+ *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
+ *        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_connman_manager_technology_default_get(const char **type)
+{
+   E_Connman_Element *element;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(type, 0);
+
+   element = e_connman_manager_get();
+   if (!element)
+     return 0;
+   return e_connman_element_property_get_stringshared
+     (element, e_connman_prop_technology_default, NULL, type);
+}
index 4f1af9f..2ea8f23 100644 (file)
@@ -63,6 +63,7 @@ extern const char *e_connman_prop_apn;
 extern const char *e_connman_prop_mcc;
 extern const char *e_connman_prop_mnc;
 extern const char *e_connman_prop_roaming;
+extern const char *e_connman_prop_technology_default;
 
 extern int _e_dbus_connman_log_dom;