e_dbus/ofono: add functions to check element's interface.
authorbarbieri <barbieri@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 15 Mar 2010 20:45:09 +0000 (20:45 +0000)
committerbarbieri <barbieri@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 15 Mar 2010 20:45:09 +0000 (20:45 +0000)
By: João Paulo Rechi Vita <jprvita@profusion.mobi>

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

src/lib/ofono/E_Ofono.h
src/lib/ofono/e_ofono_element.c

index a79104e..5aab65d 100644 (file)
@@ -118,6 +118,10 @@ extern "C" {
   EAPI bool e_ofono_element_property_get_stringshared(const E_Ofono_Element *element, const char *name, int *type, void *value) EINA_ARG_NONNULL(1, 2, 4) EINA_WARN_UNUSED_RESULT;
   EAPI bool e_ofono_element_property_get(const E_Ofono_Element *element, const char *name, int *type, void *value) EINA_ARG_NONNULL(1, 2, 4) EINA_WARN_UNUSED_RESULT;
 
+  EAPI bool e_ofono_element_is_manager(const E_Ofono_Element *element) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+  EAPI bool e_ofono_element_is_modem(const E_Ofono_Element *element) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+  EAPI bool e_ofono_element_is_netreg(const E_Ofono_Element *element) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+
 #ifdef __cplusplus
 }
 #endif
index 6d8b35d..3c2f058 100644 (file)
@@ -2310,3 +2310,30 @@ e_ofono_elements_shutdown(void)
    eina_hash_free(elements);
    elements = NULL;
 }
+
+static inline bool
+_e_ofono_element_is(const E_Ofono_Element *element, const char *interface)
+{
+   return element->interface == interface;
+}
+
+bool
+e_ofono_element_is_manager(const E_Ofono_Element *element)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(element, 0);
+   return _e_ofono_element_is(element, e_ofono_iface_manager);
+}
+
+bool
+e_ofono_element_is_modem(const E_Ofono_Element *element)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(element, 0);
+   return _e_ofono_element_is(element, e_ofono_iface_modem);
+}
+
+bool
+e_ofono_element_is_netreg(const E_Ofono_Element *element)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(element, 0);
+   return _e_ofono_element_is(element, e_ofono_iface_netreg);
+}