Add getters for Technology interface
authorbarbieri <barbieri@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 4 Feb 2010 14:52:30 +0000 (14:52 +0000)
committerbarbieri <barbieri@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 4 Feb 2010 14:52:30 +0000 (14:52 +0000)
Technology has only readonly properties. Implement their getters.

By: Lucas De Marchi <lucas.demarchi@profusion.mobi>

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

src/lib/connman/E_Connman.h
src/lib/connman/Makefile.am
src/lib/connman/e_connman_technology.c [new file with mode: 0644]

index 37848bb..7e49d60 100644 (file)
@@ -206,6 +206,13 @@ extern "C" {
   EAPI bool e_connman_service_ipv4_configure_dhcp(E_Connman_Element *service, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
   EAPI bool e_connman_service_ipv4_configure_manual(E_Connman_Element *service, const char *address, const char *netmask, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
 
+  /* Technologies methods */
+  EAPI E_Connman_Element *e_connman_technology_get(const char *path) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+
+  EAPI bool e_connman_technology_state_get(const E_Connman_Element *technology, const char **state) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
+  EAPI bool e_connman_technology_name_get(const E_Connman_Element *technology, const char **state) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
+  EAPI bool e_connman_technology_type_get(const E_Connman_Element *technology, const char **state) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
+  EAPI bool e_connman_technology_devices_get(const E_Connman_Element *technology, unsigned int *count, E_Connman_Element ***t_elements) EINA_ARG_NONNULL(1, 2, 3) EINA_WARN_UNUSED_RESULT;
 
   // TODO: ethernet_speed_get (not in connman yet)
   // TODO: ethernet_duplex_get (not in connman yet)
index 3a2527b..b972e30 100644 (file)
@@ -18,7 +18,8 @@ e_connman_element.c \
 e_connman_manager.c \
 e_connman_network.c \
 e_connman_profile.c \
-e_connman_service.c
+e_connman_service.c \
+e_connman_technology.c
 
 libeconnman_la_LIBADD = \
 @EDBUS_LIBS@ @EVAS_LIBS@ \
diff --git a/src/lib/connman/e_connman_technology.c b/src/lib/connman/e_connman_technology.c
new file mode 100644 (file)
index 0000000..223d3ec
--- /dev/null
@@ -0,0 +1,132 @@
+#include "e_connman_private.h"
+
+E_Connman_Element *
+e_connman_technology_get(const char *path)
+{
+   E_Connman_Element *technology;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
+
+   technology = e_connman_element_get(path);
+   if (!technology)
+     return NULL;
+
+   if (!e_connman_element_is_technology(technology))
+     {
+       WRN("path '%s' is not a technology!", path);
+       return NULL;
+     }
+
+   return technology;
+}
+
+/**
+ * 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.
+ *
+ * Name of this technology.
+ *
+ * @param technology path to get property
+ * @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 sucess, 0 otherwise
+ */
+bool
+e_connman_technology_name_get(const E_Connman_Element *technology, const char **name)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(technology, 0);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(name, 0);
+   return e_connman_element_property_get_stringshared
+     (technology, e_connman_prop_name, NULL, name);
+}
+
+/**
+ * Get property "Type" 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 technology type (for example "ethernet" etc.)
+ *
+ * This information should only be used to determine
+ * advanced properties or showing the correct icon
+ * to the user.
+ *
+ * @param technology path to get property.
+ * @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_technology_type_get(const E_Connman_Element *technology, const char **type)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(technology, 0);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(type, 0);
+   return e_connman_element_property_get_stringshared
+     (technology, e_connman_prop_type, NULL, type);
+}
+
+/**
+ * Get property "State" 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 technology state information.
+ *
+ * Valid states are "offline", "available", "enabled",
+ * and "connected".
+ *
+ * @param technology path to get property.
+ * @param state 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_technology_state_get(const E_Connman_Element *technology, const char **state)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(technology, 0);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(state, 0);
+   return e_connman_element_property_get_stringshared
+     (technology, e_connman_prop_state, NULL, state);
+}
+
+/**
+ * Get array of device elements.
+ * 
+ * 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 technology path to get property.
+ * @param count return the number of elements in array.
+ * @param t_elements array with all elements, these are not referenced
+ *        and in no particular order, just set if return is 1.  The
+ *        array itself is allocated using malloc() and should be freed
+ *        after usage is done.
+ *
+ * @return 1 on success, 0 otherwise.
+ */
+bool
+e_connman_technology_devices_get(const E_Connman_Element *technology, unsigned int *count, E_Connman_Element ***t_elements)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(technology, 0);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(count, 0);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(t_elements, 0);
+   return e_connman_element_objects_array_get_stringshared
+     (technology, e_connman_prop_services, count, t_elements);
+}