Add a new method dial_memory to the voicecall manager interface
---
 src/voicecall.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 106 insertions(+)

diff --git a/src/voicecall.c b/src/voicecall.c
index cef36a29..7405840b 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -28,6 +28,7 @@
 #include <time.h>
 #include <errno.h>
 #include <stdint.h>
+#include <stdlib.h>
 
 #include <glib.h>
 #include <gdbus.h>
@@ -1577,6 +1578,107 @@ static DBusMessage *manager_dial(DBusConnection *conn,
        return __ofono_error_failed(msg);
 }
 
+static void manager_dial_memory_callback(const struct ofono_error *error, void 
*data)
+{
+       struct ofono_voicecall *vc = data;
+       DBusMessage *reply;
+       struct voicecall *v;
+
+       v = synthesize_outgoing_call(vc, NULL);
+
+       if (v) {
+               const char *path = voicecall_build_path(vc, v->call);
+
+               reply = dbus_message_new_method_return(vc->pending);
+
+               dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, &path,
+                                               DBUS_TYPE_INVALID);
+       } else {
+               reply = __ofono_error_failed(vc->pending);
+       }
+
+       __ofono_dbus_pending_reply(&vc->pending, reply);
+
+       voicecalls_emit_call_added(vc, v);
+}
+
+static int voicecall_dial_memory(struct ofono_voicecall *vc, const char 
*position,
+                                       enum ofono_clir_option clir,
+                                       ofono_voicecall_cb_t cb, void *data)
+{
+       struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom);
+       long int memory_position;
+
+       if (g_slist_length(vc->call_list) >= MAX_VOICE_CALLS)
+               return -EPERM;
+
+       if (ofono_modem_get_online(modem) == FALSE)
+               return -ENETDOWN;
+
+       if (vc->driver->dial == NULL)
+               return -ENOTSUP;
+
+       if (voicecalls_have_incoming(vc))
+               return -EBUSY;
+
+       /* We can't have two dialing/alerting calls, reject outright */
+       if (voicecalls_num_connecting(vc) > 0)
+               return -EBUSY;
+
+       if (voicecalls_have_active(vc) && voicecalls_have_held(vc))
+               return -EBUSY;
+
+       memory_position = strtol(position, NULL, 10);
+
+       vc->driver->dial_memory(vc, memory_position, clir, cb, vc);
+
+       return 0;
+}
+
+static DBusMessage *manager_dial_memory(DBusConnection *conn,
+                                       DBusMessage *msg, void *data)
+{
+       struct ofono_voicecall *vc = data;
+       const char *memory_location;
+       const char *clirstr;
+       enum ofono_clir_option clir;
+       int err;
+
+       if (vc->pending || vc->dial_req || vc->pending_em)
+               return __ofono_error_busy(msg);
+
+       if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &memory_location,
+                                       DBUS_TYPE_STRING, &clirstr,
+                                       DBUS_TYPE_INVALID) == FALSE)
+               return __ofono_error_invalid_args(msg);
+
+       if (clir_string_to_clir(clirstr, &clir) == FALSE)
+               return __ofono_error_invalid_format(msg);
+
+       vc->pending = dbus_message_ref(msg);
+
+       err = voicecall_dial_memory(vc, memory_location, clir, 
manager_dial_memory_callback, vc);
+
+       if (err >= 0)
+               return NULL;
+
+       vc->pending = NULL;
+       dbus_message_unref(msg);
+
+       switch (err) {
+       case -EINVAL:
+               return __ofono_error_invalid_format(msg);
+
+       case -ENETDOWN:
+               return __ofono_error_not_available(msg);
+
+       case -ENOTSUP:
+               return __ofono_error_not_implemented(msg);
+       }
+
+       return __ofono_error_failed(msg);
+}
+
 static void manager_dial_last_callback(const struct ofono_error *error, void 
*data)
 {
        struct ofono_voicecall *vc = data;
@@ -2219,6 +2321,10 @@ static const GDBusMethodTable manager_methods[] = {
                GDBUS_ARGS({ "number", "s" }, { "hide_callerid", "s" }),
                GDBUS_ARGS({ "path", "o" }),
                manager_dial) },
+       { GDBUS_ASYNC_METHOD("DialMemory",
+               GDBUS_ARGS({ "memory_location", "s" },{ "hide_callerid", "s" }),
+               NULL,
+               manager_dial_memory) },
        { GDBUS_ASYNC_METHOD("DialLast", NULL, NULL, manager_dial_last)},
        { GDBUS_ASYNC_METHOD("Transfer", NULL, NULL, manager_transfer) },
        { GDBUS_ASYNC_METHOD("SwapCalls",  NULL, NULL, manager_swap_calls) },
-- 
2.14.2

_______________________________________________
ofono mailing list
[email protected]
https://lists.ofono.org/mailman/listinfo/ofono

Reply via email to