return 1;
}
+/* Modem Commands */
+
+static int
+_on_cmd_modem_set_powered(char *cmd, char *args)
+{
+ char *next_args;
+ Eina_Bool powered;
+ E_Ofono_Element *element = _element_from_args("org.ofono.Modem", args, &next_args);
+
+ if (!element)
+ return 1;
+
+ if (!args)
+ {
+ fputs("ERROR: missing the powered value\n", stderr);
+ return 1;
+ }
+
+ powered = !!atol(next_args);
+
+ if (e_ofono_modem_powered_set
+ (element, powered, _method_success_check, "modem_set_powered"))
+ printf(":::Modem %s Powered set to %hhu\n", element->path, powered);
+ else
+ fputs("ERROR: can't set Modem Powered\n", stderr);
+ return 1;
+}
+
static int
_on_input(void *data, Ecore_Fd_Handler *fd_handler)
{
{"get_properties", _on_cmd_get_properties},
{"set_property", _on_cmd_property_set},
{"manager_get", _on_cmd_manager_get},
+ {"modem_set_powered", _on_cmd_modem_set_powered},
{NULL, NULL}
};
/* Manager Methods */
EAPI E_Ofono_Element *e_ofono_manager_get(void) EINA_WARN_UNUSED_RESULT;
+ /* Modem Methods */
+ EAPI bool e_ofono_modem_powered_get(E_Ofono_Element *element, Eina_Bool *powered);
+ EAPI bool e_ofono_modem_powered_set(E_Ofono_Element *element, Eina_Bool powered, E_DBus_Method_Return_Cb cb, const void *data);
+ EAPI bool e_ofono_modem_name_get(E_Ofono_Element *element, const char **name);
+
/* Low-Level API:
*
* Should just be used to work around problems until proper solution
e_ofono_private.h \
e_ofono.c \
e_ofono_element.c \
-e_ofono_manager.c
+e_ofono_manager.c \
+e_ofono_modem.c
libeofono_la_LIBADD = \
@EDBUS_LIBS@ @EVAS_LIBS@ \
const char *e_ofono_iface_manager = NULL;
const char *e_ofono_prop_modems = NULL;
+const char *e_ofono_iface_modem = NULL;
+const char *e_ofono_prop_name = NULL;
+const char *e_ofono_prop_powered = NULL;
+const char *e_ofono_prop_interfaces = NULL;
int _e_dbus_ofono_log_dom = -1;
e_ofono_iface_manager = eina_stringshare_add("org.ofono.Manager");
if (e_ofono_prop_modems == NULL)
e_ofono_prop_modems = eina_stringshare_add("Modems");
+ if (e_ofono_iface_modem == NULL)
+ e_ofono_iface_modem = eina_stringshare_add("org.ofono.Modem");
+ if (e_ofono_prop_name == NULL)
+ e_ofono_prop_name = eina_stringshare_add("Name");
+ if (e_ofono_prop_powered == NULL)
+ e_ofono_prop_powered = eina_stringshare_add("Powered");
+ if (e_ofono_prop_interfaces == NULL)
+ e_ofono_prop_interfaces = eina_stringshare_add("Interfaces");
e_ofono_conn = edbus_conn;
cb_name_owner_changed = e_dbus_signal_handler_add
_stringshare_del(&e_ofono_iface_manager);
_stringshare_del(&e_ofono_prop_modems);
+ _stringshare_del(&e_ofono_iface_modem);
+ _stringshare_del(&e_ofono_prop_name);
+ _stringshare_del(&e_ofono_prop_powered);
+ _stringshare_del(&e_ofono_prop_interfaces);
return 0;
}
switch (head)
{
+ case 'M':
+ if (strcmp(tail, "odems") == 0)
+ interface = e_ofono_iface_modem;
+ break;
default:
break;
}
{
INF("property value changed %s (%c)", key, t);
changed = 1;
+ if ((strcmp(key, "Interfaces") == 0) && value)
+ {
+ char *interface;
+ Eina_Array_Iterator iterator;
+ unsigned int i;
+ E_Ofono_Element *e;
+
+ EINA_ARRAY_ITER_NEXT(((E_Ofono_Array*)value)->array, i,
+ interface, iterator)
+ {
+ DBG("Found interface %s on %s", interface, element->path);
+ e = e_ofono_element_register(element->path, interface);
+ if ((e) && (!e_ofono_element_properties_sync(e)))
+ WRN("could not get properties of %s", e->path);
+ }
+ }
}
}
while (dbus_message_iter_next(&s_itr));
{
INF("property value changed %s (%c)", name, t);
changed = 1;
+ if ((strcmp(name, "Interfaces") == 0) && value)
+ {
+ char *interface;
+ Eina_Array_Iterator iterator;
+ unsigned int i;
+ E_Ofono_Element *e;
+
+ EINA_ARRAY_ITER_NEXT(((E_Ofono_Array*)value)->array, i,
+ interface, iterator)
+ {
+ DBG("Found interface %s on %s", interface, element->path);
+ e_ofono_element_register(element->path, interface);
+ e = e_ofono_element_register(element->path, interface);
+ if ((e) && (!e_ofono_element_properties_sync(e)))
+ WRN("could not get properties of %s", e->path);
+ }
+ }
}
if (changed)
_e_ofono_element_listeners_call(element);
--- /dev/null
+#include "e_ofono_private.h"
+
+/* TODO: add a getter for Interfaces property */
+
+/**
+ * Get property "Powered" value.
+ *
+ * @param powered where to store the property value, must be a pointer
+ * to bool (bool *), 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_ofono_modem_powered_get(E_Ofono_Element *element, Eina_Bool *powered)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(element, 0);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(powered, 0);
+
+ return e_ofono_element_property_get_stringshared
+ (element, e_ofono_prop_powered, NULL, powered);
+}
+
+/**
+ * Call method SetProperty("Powered", powered) at the given element on server.
+ *
+ *
+ * @param powered value 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.
+ */
+bool
+e_ofono_modem_powered_set(E_Ofono_Element *element, Eina_Bool powered, E_DBus_Method_Return_Cb cb, const void *data)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(element, 0);
+
+ return e_ofono_element_property_set_full
+ (element, e_ofono_prop_powered, DBUS_TYPE_BOOLEAN,
+ &powered, cb, data);
+}
+
+/**
+ * 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.
+ *
+ * @param address 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_ofono_modem_name_get(E_Ofono_Element *element, const char **name)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(element, 0);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(name, 0);
+
+ return e_ofono_element_property_get_stringshared
+ (element, e_ofono_prop_name, NULL, name);
+}
extern const char *e_ofono_iface_manager;
extern const char *e_ofono_prop_modems;
+ extern const char *e_ofono_iface_modem;
+ extern const char *e_ofono_prop_name;
+ extern const char *e_ofono_prop_powered;
+ extern const char *e_ofono_prop_interfaces;
extern int _e_dbus_ofono_log_dom;