return 1;
}
+/* SMS Commands */
+
+static int
+_on_cmd_sms_sca_set(char *cmd, char *args)
+{
+ char *next_args, *sca;
+ E_Ofono_Element *element = _element_from_args("org.ofono.SmsManager", args,
+ &next_args);
+
+ if (!element)
+ return 1;
+
+ if (!args)
+ {
+ fputs("ERROR: missing service center address\n", stderr);
+ return 1;
+ }
+
+ sca = next_args;
+ if (e_ofono_sms_sca_set(element, sca, _method_success_check,
+ "sms_sca_set"))
+ printf(":::Service Center Address on modem %s set to %s\n",
+ element->path, sca);
+ else
+ fputs("ERROR: couldn't change Service Center Address\n", stderr);
+
+ return 1;
+}
+
+static int
+_on_cmd_sms_send_message(char *cmd, char *args)
+{
+ char *next_args, *number, *message;
+ E_Ofono_Element *element = _element_from_args("org.ofono.SmsManager", args,
+ &next_args);
+
+ if (!element)
+ return 1;
+
+ number = next_args;
+ if (!number)
+ {
+ fputs("ERROR: missing recipient number and message text.\n", stderr);
+ return 1;
+ }
+
+ message = _tok(number);
+ if (!message)
+ {
+ fputs("ERROR: missing message text.\n", stderr);
+ return 1;
+ }
+
+ if (!e_ofono_sms_send_message(element, number, message,
+ _method_success_check, "sms_send_message"))
+ fputs("ERROR: error setting property.\n", stderr);
+
+ return 1;
+}
+
static int
_on_input(void *data, Ecore_Fd_Handler *fd_handler)
{
{"manager_get", _on_cmd_manager_get},
{"manager_modems_get", _on_cmd_manager_modems_get},
{"modem_set_powered", _on_cmd_modem_set_powered},
+ {"sms_sca_set", _on_cmd_sms_sca_set},
+ {"sms_send_message", _on_cmd_sms_send_message},
{NULL, NULL}
};
struct {
Eina_Inlist *properties_get;
Eina_Inlist *property_set;
- Eina_Inlist *agent_register;
- Eina_Inlist *agent_unregister;
+ Eina_Inlist *send_sms;
} _pending;
struct {
Ecore_Idler *changed;
EAPI Eina_Bool e_ofono_netreg_operator_get(const E_Ofono_Element *element, const char **op) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
EAPI Eina_Bool e_ofono_netreg_strength_get(const E_Ofono_Element *element, uint8_t *strength) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
+ /* SMS Methods */
+ EAPI Eina_Bool e_ofono_sms_sca_get(const E_Ofono_Element *element, const char **sca) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
+ EAPI Eina_Bool e_ofono_sms_sca_set(E_Ofono_Element *element, const char *sca, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
+ EAPI Eina_Bool e_ofono_sms_send_message(const E_Ofono_Element *element, const char *number, const char *message, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1, 2, 3) EINA_WARN_UNUSED_RESULT;
+
/* Low-Level API:
*
* Should just be used to work around problems until proper solution
e_ofono_element.c \
e_ofono_manager.c \
e_ofono_modem.c \
-e_ofono_network_reg.c
+e_ofono_network_reg.c \
+e_ofono_sms.c
libeofono_la_LIBADD = \
@EDBUS_LIBS@ @EVAS_LIBS@ \
const char *e_ofono_prop_status = NULL;
const char *e_ofono_prop_operator = NULL;
const char *e_ofono_prop_strength = NULL;
+const char *e_ofono_iface_sms = NULL;
+const char *e_ofono_prop_sca = NULL;
+const char *e_ofono_method_send_sms = NULL;
int _e_dbus_ofono_log_dom = -1;
e_ofono_prop_operator = eina_stringshare_add("Operator");
if (e_ofono_prop_strength == NULL)
e_ofono_prop_strength = eina_stringshare_add("Strength");
+ if (e_ofono_iface_sms == NULL)
+ e_ofono_iface_sms = eina_stringshare_add("org.ofono.SmsManager");
+ if (e_ofono_prop_sca == NULL)
+ e_ofono_prop_sca = eina_stringshare_add("ServiceCenterAddress");
+ if (e_ofono_method_send_sms == NULL)
+ e_ofono_method_send_sms = eina_stringshare_add("SendMessage");
e_ofono_conn = edbus_conn;
cb_name_owner_changed = e_dbus_signal_handler_add
_stringshare_del(&e_ofono_prop_status);
_stringshare_del(&e_ofono_prop_operator);
_stringshare_del(&e_ofono_prop_strength);
+ _stringshare_del(&e_ofono_iface_sms);
+ _stringshare_del(&e_ofono_prop_sca);
+ _stringshare_del(&e_ofono_method_send_sms);
return 0;
}
e_ofono_element_pending_cancel_and_free(&element->_pending.properties_get);
e_ofono_element_pending_cancel_and_free(&element->_pending.property_set);
- e_ofono_element_pending_cancel_and_free(&element->_pending.agent_register);
- e_ofono_element_pending_cancel_and_free(&element->_pending.agent_unregister);
+ e_ofono_element_pending_cancel_and_free(&element->_pending.send_sms);
e_ofono_element_extra_properties_free(element);
eina_stringshare_del(element->interface);
extern const char *e_ofono_prop_status;
extern const char *e_ofono_prop_operator;
extern const char *e_ofono_prop_strength;
+ extern const char *e_ofono_iface_sms;
+ extern const char *e_ofono_prop_sca;
+ extern const char *e_ofono_method_send_sms;
extern int _e_dbus_ofono_log_dom;
--- /dev/null
+#include "e_ofono_private.h"
+
+/**
+ * Get property "ServiceCenterAddress" value.
+ *
+ * @param sca 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 @c EINA_TRUE on success, @c EINA_FALSE otherwise.
+ */
+Eina_Bool
+e_ofono_sms_sca_get(const E_Ofono_Element *element, const char **sca)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(element, 0);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(sca, 0);
+
+ return e_ofono_element_property_get_stringshared
+ (element, e_ofono_prop_sca, NULL, sca);
+}
+
+/**
+ * Call method SetProperty("ServiceCenterAddress", powered) at the given
+ * element on server.
+ *
+ *
+ * @param sca 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 @c EINA_TRUE on success, @c EINA_FALSE otherwise.
+ */
+Eina_Bool
+e_ofono_sms_sca_set(E_Ofono_Element *element, const char *sca, 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_sca, DBUS_TYPE_STRING, sca, cb, data);
+}
+
+/**
+ * Send SMS message.
+ *
+ * Call method SendMessage(number, text) to send a new SMS message.
+ *
+ * @param number the destination of the message
+ * @param message text of message body
+ * @param cb function to call when server replies or some error happens.
+ * @param data data to give to cb when it is called.
+ *
+ * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
+ */
+Eina_Bool
+e_ofono_sms_send_message(const E_Ofono_Element *element, const char *number, const char *message, E_DBus_Method_Return_Cb cb, const void *data)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(element, 0);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(number, 0);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(message, 0);
+
+ DBusMessage *m;
+ DBusMessageIter i;
+
+ if (!(m = dbus_message_new_method_call(e_ofono_system_bus_name_get(),
+ element->path, element->interface,
+ e_ofono_method_send_sms)))
+ return EINA_FALSE;
+
+ dbus_message_iter_init_append(m, &i);
+ dbus_message_iter_append_basic(&i, DBUS_TYPE_STRING, &number);
+ dbus_message_iter_append_basic(&i, DBUS_TYPE_STRING, &message);
+
+ return e_ofono_element_message_send(element, e_ofono_method_send_sms,
+ e_ofono_iface_sms, NULL, m,
+ &element->_pending.send_sms, cb, data);
+}