Hi Philippe,

On 12/06/2017 09:36 AM, Philippe De Swert wrote:
Now we can also dial favourites/quick contacts over bluetooth.

---
  src/voicecall.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++------
  1 file changed, 65 insertions(+), 7 deletions(-)

diff --git a/src/voicecall.c b/src/voicecall.c
index ed6ea83f..f35047f8 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -1607,10 +1607,11 @@ error:
                                        __ofono_error_failed(vc->pending));
  }
-static int voicecall_dial_shortcut(struct ofono_voicecall *vc, enum ofono_clir_option clir,
-                                       ofono_voicecall_cb_t cb, void *data)
+static int voicecall_dial_shortcut(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;
@@ -1618,9 +1619,6 @@ static int voicecall_dial_shortcut(struct ofono_voicecall 
*vc, enum ofono_clir_o
        if (ofono_modem_get_online(modem) == FALSE)
                return -ENETDOWN;
- if (vc->driver->dial_last == NULL)
-               return -ENOTSUP;
-
        if (voicecalls_have_incoming(vc))
                return -EBUSY;
@@ -1631,7 +1629,19 @@ static int voicecall_dial_shortcut(struct ofono_voicecall *vc, enum ofono_clir_o
        if (voicecalls_have_active(vc) && voicecalls_have_held(vc))
                return -EBUSY;
- vc->driver->dial_last(vc, clir, cb, vc);
+       /* when position is not given we dial the last called number */
+       if(position == NULL) {

not our coding style

+               if (vc->driver->dial_last == NULL)
+                       return -ENOTSUP;
+
+               vc->driver->dial_last(vc, clir, cb, vc);
+       } else {
+               memory_position = strtol(position, NULL, 10);

You need to make sure that strtol succeeds, it might be better to perform this checking in manager_dial_memory

+               if(vc->driver->dial_memory == NULL )
+                       return -ENOTSUP;
+
+               vc->driver->dial_memory(vc, memory_position, clir, cb, vc);
+       }
return 0;
  }
@@ -1656,7 +1666,7 @@ static DBusMessage *manager_dial_last(DBusConnection 
*conn,
vc->pending = dbus_message_ref(msg); - err = voicecall_dial_shortcut(vc, clir, manager_dial_shortcut_callback, vc);
+       err = voicecall_dial_shortcut(vc, NULL, clir, 
manager_dial_shortcut_callback, vc);
if (err >= 0)
                return NULL;
@@ -1678,6 +1688,50 @@ static DBusMessage *manager_dial_last(DBusConnection 
*conn,
        return __ofono_error_failed(msg);
  }
+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_shortcut(vc, memory_location, clir, 
manager_dial_shortcut_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 DBusMessage *manager_transfer(DBusConnection *conn,
                                        DBusMessage *msg, void *data)
  {
@@ -2236,6 +2290,10 @@ static const GDBusMethodTable manager_methods[] = {
                manager_dial) },
        { GDBUS_ASYNC_METHOD("DialLast",
                GDBUS_ARGS({ "hide_callerid", "s" }), NULL, manager_dial_last)},
+       { GDBUS_ASYNC_METHOD("DialMemory",
+               GDBUS_ARGS({ "memory_location", "s" },{ "hide_callerid", "s" }),

Why would memory location be a string? Why not just make it an unsigned int32 and make it easy?

+               NULL,
+               manager_dial_memory) },
        { GDBUS_ASYNC_METHOD("Transfer", NULL, NULL, manager_transfer) },
        { GDBUS_ASYNC_METHOD("SwapCalls",  NULL, NULL, manager_swap_calls) },
        { GDBUS_ASYNC_METHOD("ReleaseAndAnswer", NULL, NULL,


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

Reply via email to