more easy properties for network, fix typo with "Strength".
authorbarbieri <barbieri@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 30 Dec 2009 19:02:35 +0000 (19:02 +0000)
committerbarbieri <barbieri@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 30 Dec 2009 19:02:35 +0000 (19:02 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/e_dbus@44807 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_network.c
src/lib/connman/e_connman_private.h
src/lib/connman/e_connman_service.c

index 4799270..c1f14ee 100644 (file)
@@ -846,6 +846,29 @@ _on_cmd_network_get_strength(char *cmd, char *args)
 }
 
 static int
+_on_cmd_network_get_frequency(char *cmd, char *args)
+{
+   char *path;
+   unsigned short frequency;
+   E_Connman_Element *e;
+
+   if (!args)
+     {
+       fputs("ERROR: missing the network path\n", stderr);
+       return 1;
+     }
+   _tok(args);
+   path = args;
+
+   e = e_connman_network_get(path);
+   if (e_connman_network_frequency_get(e, &frequency))
+     printf(":::Network %s Frequency = %#04hx (%d)\n", path, frequency, frequency);
+   else
+     fputs("ERROR: can't get network frequency\n", stderr);
+   return 1;
+}
+
+static int
 _on_cmd_network_get_device(char *cmd, char *args)
 {
    E_Connman_Element *e, *device;
@@ -962,6 +985,51 @@ _on_cmd_network_get_wifi_passphrase(char *cmd, char *args)
    return 1;
 }
 
+static int
+_on_cmd_network_get_wifi_channel(char *cmd, char *args)
+{
+   char *path;
+   E_Connman_Element *e;
+   unsigned short wifi_channel;
+
+   if (!args)
+     {
+       fputs("ERROR: missing the network path\n", stderr);
+       return 1;
+     }
+   _tok(args);
+   path = args;
+
+   e = e_connman_network_get(path);
+   if (e_connman_network_wifi_channel_get(e, &wifi_channel))
+     printf(":::Network %s Wifi Channel = %#02hx (%d)\n", path, wifi_channel, wifi_channel);
+   else
+     fputs("ERROR: can't get network wifi channel\n", stderr);
+   return 1;
+}
+
+static int
+_on_cmd_network_get_wifi_eap(char *cmd, char *args)
+{
+   const char *wifi_eap, *path;
+   E_Connman_Element *e;
+
+   if (!args)
+     {
+       fputs("ERROR: missing the network path\n", stderr);
+       return 1;
+     }
+   _tok(args);
+   path = args;
+
+   e = e_connman_network_get(path);
+   if (e_connman_network_wifi_eap_get(e, &wifi_eap))
+     printf(":::Network %s Wifi EAP = \"%s\"\n", path, wifi_eap);
+   else
+     fputs("ERROR: can't get network wifi eap\n", stderr);
+   return 1;
+}
+
 /* Services Commands */
 static int
 _on_cmd_service_connect(char *cmd, char *args)
@@ -1645,11 +1713,14 @@ _on_input(void *data, Ecore_Fd_Handler *fd_handler)
      {"network_get_name", _on_cmd_network_get_name},
      {"network_get_connected", _on_cmd_network_get_connected},
      {"network_get_strength", _on_cmd_network_get_strength},
+     {"network_get_frequency", _on_cmd_network_get_frequency},
      {"network_get_device", _on_cmd_network_get_device},
      {"network_get_wifi_ssid", _on_cmd_network_get_wifi_ssid},
      {"network_get_wifi_mode", _on_cmd_network_get_wifi_mode},
      {"network_get_wifi_security", _on_cmd_network_get_wifi_security},
      {"network_get_wifi_passphrase", _on_cmd_network_get_wifi_passphrase},
+     {"network_get_wifi_channel", _on_cmd_network_get_wifi_channel},
+     {"network_get_wifi_eap", _on_cmd_network_get_wifi_eap},
      {"service_connect", _on_cmd_service_connect},
      {"service_disconnect", _on_cmd_service_disconnect},
      {"service_remove", _on_cmd_service_remove},
index 6b1c2ac..52c367c 100644 (file)
@@ -369,11 +369,14 @@ static const struct test_desc test_desc_network[] = {
   TEST_DESC_STRING_GET(e_connman_network_name_get, 0),
   TEST_DESC_BOOL_GET(e_connman_network_connected_get, 0),
   TEST_DESC_UCHAR_GET(e_connman_network_strength_get, 1),
+  TEST_DESC_USHORT_GET(e_connman_network_frequency_get, 1),
   TEST_DESC_ELEMENT_GET(e_connman_network_device_get, 0),
   TEST_DESC_UCHAR_ARRAY_GET(e_connman_network_wifi_ssid_get, 1),
   TEST_DESC_STRING_GET(e_connman_network_wifi_mode_get, 1),
   TEST_DESC_STRING_GET(e_connman_network_wifi_security_get, 1),
   TEST_DESC_STRING_GET(e_connman_network_wifi_passphrase_get, 1),
+  TEST_DESC_USHORT_GET(e_connman_network_wifi_channel_get, 1),
+  TEST_DESC_STRING_GET(e_connman_network_wifi_eap_get, 1),
   TEST_DESC_SENTINEL
 };
 
index 186ec7d..0d7d355 100644 (file)
@@ -270,6 +270,8 @@ extern "C" {
 
   EAPI bool e_connman_network_strength_get(const E_Connman_Element *network, unsigned char *strength) EINA_ARG_NONNULL(1, 2) EINA_PURE EINA_WARN_UNUSED_RESULT;
 
+  EAPI bool e_connman_network_frequency_get(const E_Connman_Element *network, unsigned short *frequency) EINA_ARG_NONNULL(1, 2) EINA_PURE EINA_WARN_UNUSED_RESULT;
+
   EAPI bool e_connman_network_device_get(const E_Connman_Element *network, E_Connman_Element **element) EINA_ARG_NONNULL(1, 2) EINA_PURE EINA_WARN_UNUSED_RESULT;
 
   EAPI bool e_connman_network_wifi_ssid_get(const E_Connman_Element *network, unsigned int *count, unsigned char **wifi_ssid) EINA_ARG_NONNULL(1, 2, 3) EINA_PURE EINA_WARN_UNUSED_RESULT;
@@ -278,10 +280,13 @@ extern "C" {
 
   EAPI bool e_connman_network_wifi_security_get(const E_Connman_Element *network, const char **wifi_security) EINA_ARG_NONNULL(1, 2) EINA_PURE EINA_WARN_UNUSED_RESULT;
 
-  EAPI bool e_connman_network_wifi_passphrase_get(const E_Connman_Element *network, const char **wifi_passphare) EINA_ARG_NONNULL(1, 2) EINA_PURE EINA_WARN_UNUSED_RESULT;
+  EAPI bool e_connman_network_wifi_passphrase_get(const E_Connman_Element *network, const char **wifi_passphrase) EINA_ARG_NONNULL(1, 2) EINA_PURE EINA_WARN_UNUSED_RESULT;
+
+  EAPI bool e_connman_network_wifi_channel_get(const E_Connman_Element *network, unsigned short *wifi_channel) EINA_ARG_NONNULL(1, 2) EINA_PURE EINA_WARN_UNUSED_RESULT;
+
+  EAPI bool e_connman_network_wifi_eap_get(const E_Connman_Element *network, const char **wifi_eap) EINA_ARG_NONNULL(1, 2) EINA_PURE EINA_WARN_UNUSED_RESULT;
+
 
-  // TODO: wifi_channel_get (missing in their docs)
-  // TODO: wifi_eap_get (missing in their docs, only if ieee8021x)
   // TODO: frequency_get (missing in their docs)
 
 #ifdef __cplusplus
index 16619cb..45994a4 100644 (file)
@@ -50,12 +50,15 @@ const char *e_connman_prop_remember = NULL;
 const char *e_connman_prop_scan_interval = NULL;
 const char *e_connman_prop_scanning = NULL;
 const char *e_connman_prop_state = NULL;
-const char *e_connman_prop_strengh = NULL;
+const char *e_connman_prop_strength = NULL;
+const char *e_connman_prop_frequency = NULL;
 const char *e_connman_prop_type = NULL;
 const char *e_connman_prop_wifi_mode = NULL;
 const char *e_connman_prop_wifi_passphrase = NULL;
 const char *e_connman_prop_wifi_security = NULL;
 const char *e_connman_prop_wifi_ssid = NULL;
+const char *e_connman_prop_wifi_channel = NULL;
+const char *e_connman_prop_wifi_eap = NULL;
 const char *e_connman_prop_error = NULL;
 const char *e_connman_prop_mode = NULL;
 const char *e_connman_prop_security = NULL;
@@ -319,8 +322,10 @@ e_connman_system_init(E_DBus_Connection *edbus_conn)
      e_connman_prop_scanning = eina_stringshare_add("Scanning");
    if (e_connman_prop_state == NULL)
      e_connman_prop_state = eina_stringshare_add("State");
-   if (e_connman_prop_strengh == NULL)
-     e_connman_prop_strengh = eina_stringshare_add("Strength");
+   if (e_connman_prop_strength == NULL)
+     e_connman_prop_strength = eina_stringshare_add("Strength");
+   if (e_connman_prop_frequency == NULL)
+     e_connman_prop_frequency = eina_stringshare_add("Frequency");
    if (e_connman_prop_type == NULL)
      e_connman_prop_type = eina_stringshare_add("Type");
    if (e_connman_prop_wifi_mode == NULL)
@@ -331,6 +336,10 @@ e_connman_system_init(E_DBus_Connection *edbus_conn)
      e_connman_prop_wifi_security = eina_stringshare_add("WiFi.Security");
    if (e_connman_prop_wifi_ssid == NULL)
      e_connman_prop_wifi_ssid = eina_stringshare_add("WiFi.SSID");
+   if (e_connman_prop_wifi_channel == NULL)
+     e_connman_prop_wifi_channel = eina_stringshare_add("WiFi.Channel");
+   if (e_connman_prop_wifi_eap == NULL)
+     e_connman_prop_wifi_eap = eina_stringshare_add("WiFi.EAP");
    if (e_connman_prop_error == NULL)
      e_connman_prop_error = eina_stringshare_add("Error");
    if (e_connman_prop_mode == NULL)
@@ -431,12 +440,15 @@ e_connman_system_shutdown(void)
    _stringshare_del(&e_connman_prop_scan_interval);
    _stringshare_del(&e_connman_prop_scanning);
    _stringshare_del(&e_connman_prop_state);
-   _stringshare_del(&e_connman_prop_strengh);
+   _stringshare_del(&e_connman_prop_strength);
+   _stringshare_del(&e_connman_prop_frequency);
    _stringshare_del(&e_connman_prop_type);
    _stringshare_del(&e_connman_prop_wifi_mode);
    _stringshare_del(&e_connman_prop_wifi_passphrase);
    _stringshare_del(&e_connman_prop_wifi_security);
    _stringshare_del(&e_connman_prop_wifi_ssid);
+   _stringshare_del(&e_connman_prop_wifi_channel);
+   _stringshare_del(&e_connman_prop_wifi_eap);
    _stringshare_del(&e_connman_prop_error);
    _stringshare_del(&e_connman_prop_mode);
    _stringshare_del(&e_connman_prop_security);
index de17c3f..6e8c87d 100644 (file)
@@ -123,7 +123,31 @@ e_connman_network_strength_get(const E_Connman_Element *network, unsigned char *
    EINA_SAFETY_ON_NULL_RETURN_VAL(network, 0);
    EINA_SAFETY_ON_NULL_RETURN_VAL(strength, 0);
    return e_connman_element_property_get_stringshared
-     (network, e_connman_prop_strengh, NULL, strength);
+     (network, e_connman_prop_strength, NULL, strength);
+}
+
+/**
+ * Get property "Frequency" 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.
+ *
+ * Indicates the frequency of the network.
+ *
+ * @param network path to get property.
+ * @param frequency where to store the property value, must be a pointer
+ *        to uint16 (unsigned short*).
+ *
+ * @return 1 on success, 0 otherwise.
+ */
+bool
+e_connman_network_frequency_get(const E_Connman_Element *network, unsigned short *frequency)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(network, 0);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(frequency, 0);
+   return e_connman_element_property_get_stringshared
+     (network, e_connman_prop_frequency, NULL, frequency);
 }
 
 /**
@@ -276,3 +300,56 @@ e_connman_network_wifi_passphrase_get(const E_Connman_Element *network, const ch
    return e_connman_element_property_get_stringshared
      (network, e_connman_prop_wifi_passphrase, NULL, wifi_passphrase);
 }
+
+/**
+ * Get property "WiFi.Channel" 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.
+ *
+ * Indicates the channel this network is.
+ *
+ * @param network path to get property.
+ * @param channel where to store the property value, must be a pointer
+ *        to uint16 (unsigned short*).
+ *
+ * @return 1 on success, 0 otherwise.
+ */
+bool
+e_connman_network_wifi_channel_get(const E_Connman_Element *network, unsigned short *wifi_channel)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(network, 0);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(wifi_channel, 0);
+   return e_connman_element_property_get_stringshared
+     (network, e_connman_prop_wifi_channel, NULL, wifi_channel);
+}
+
+/**
+ * Get property "WiFi.EAP" 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.
+ *
+ * This property is only available if WiFi.Security is "ieee8021x".
+ *
+ * For systems using PolicyKit, the access to this value
+ * will be protected by the security policy.
+ *
+ * @param network path to get property.
+ * @param wifi_eap 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_network_wifi_eap_get(const E_Connman_Element *network, const char **wifi_eap)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(network, 0);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(wifi_eap, 0);
+   return e_connman_element_property_get_stringshared
+     (network, e_connman_prop_wifi_eap, NULL, wifi_eap);
+}
index 3f65931..4f1af9f 100644 (file)
@@ -41,12 +41,15 @@ extern const char *e_connman_prop_remember;
 extern const char *e_connman_prop_scan_interval;
 extern const char *e_connman_prop_scanning;
 extern const char *e_connman_prop_state;
-extern const char *e_connman_prop_strengh;
+extern const char *e_connman_prop_strength;
+extern const char *e_connman_prop_frequency;
 extern const char *e_connman_prop_type;
 extern const char *e_connman_prop_wifi_mode;
 extern const char *e_connman_prop_wifi_passphrase;
 extern const char *e_connman_prop_wifi_security;
 extern const char *e_connman_prop_wifi_ssid;
+extern const char *e_connman_prop_wifi_channel;
+extern const char *e_connman_prop_wifi_eap;
 extern const char *e_connman_prop_error;
 extern const char *e_connman_prop_mode;
 extern const char *e_connman_prop_security;
index 4ffea8c..f820465 100644 (file)
@@ -517,7 +517,7 @@ e_connman_service_strength_get(const E_Connman_Element *service, unsigned char *
    EINA_SAFETY_ON_NULL_RETURN_VAL(service, 0);
    EINA_SAFETY_ON_NULL_RETURN_VAL(strength, 0);
    return e_connman_element_property_get_stringshared
-     (service, e_connman_prop_strengh, NULL, strength);
+     (service, e_connman_prop_strength, NULL, strength);
 }
 
 /**