summaryrefslogtreecommitdiff
path: root/src/voicecall.c
diff options
context:
space:
mode:
authorPhilippe De Swert <philippedeswert@gmail.com>2018-02-12 20:37:16 +0200
committerDenis Kenzior <denkenz@gmail.com>2018-02-13 13:05:53 -0600
commit2de1aff6bd8c588f0a465abbbdcbc17d266cfa1e (patch)
tree893be407ad6441d0b2c9cd4270ebfc7f8c2923ad /src/voicecall.c
parentdb7d9bb9dd96afe567921572d8d30adc64903b3a (diff)
downloadofono-2de1aff6bd8c588f0a465abbbdcbc17d266cfa1e.tar.gz
voicecall: Add memory location dialing
Implement functionality to allow to dial favourites/quick contacts over bluetooth.
Diffstat (limited to 'src/voicecall.c')
-rw-r--r--src/voicecall.c63
1 files changed, 56 insertions, 7 deletions
diff --git a/src/voicecall.c b/src/voicecall.c
index eae4b904..e4f6a4c0 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -1606,8 +1606,8 @@ error:
__ofono_error_failed(vc->pending));
}
-static int voicecall_dial_hfp(struct ofono_voicecall *vc,
- ofono_voicecall_cb_t cb, void *data)
+static int voicecall_dial_hfp(struct ofono_voicecall *vc, unsigned int position,
+ ofono_voicecall_cb_t cb, void *data)
{
struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom);
@@ -1617,9 +1617,6 @@ static int voicecall_dial_hfp(struct ofono_voicecall *vc,
if (ofono_modem_get_online(modem) == FALSE)
return -ENETDOWN;
- if (vc->driver->dial_last == NULL)
- return -ENOTSUP;
-
if (voicecalls_have_incoming(vc))
return -EBUSY;
@@ -1630,7 +1627,18 @@ static int voicecall_dial_hfp(struct ofono_voicecall *vc,
if (voicecalls_have_active(vc) && voicecalls_have_held(vc))
return -EBUSY;
- vc->driver->dial_last(vc, cb, vc);
+ /* when position is not given we dial the last called number */
+ if (position == 0) {
+ if (vc->driver->dial_last == NULL)
+ return -ENOTSUP;
+
+ vc->driver->dial_last(vc, cb, vc);
+ } else {
+ if (vc->driver->dial_memory == NULL )
+ return -ENOTSUP;
+
+ vc->driver->dial_memory(vc, position, cb, vc);
+ }
return 0;
}
@@ -1646,7 +1654,7 @@ static DBusMessage *manager_dial_last(DBusConnection *conn,
vc->pending = dbus_message_ref(msg);
- err = voicecall_dial_hfp(vc, manager_dial_hfp_callback, vc);
+ err = voicecall_dial_hfp(vc, 0, manager_dial_hfp_callback, vc);
if (err >= 0)
return NULL;
@@ -1668,6 +1676,44 @@ 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;
+ int memory_location;
+ 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_UINT32, &memory_location,
+ DBUS_TYPE_INVALID) == FALSE)
+ return __ofono_error_invalid_args(msg);
+
+ vc->pending = dbus_message_ref(msg);
+
+ err = voicecall_dial_hfp(vc, memory_location,
+ manager_dial_hfp_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)
{
@@ -2225,6 +2271,9 @@ static const GDBusMethodTable manager_methods[] = {
GDBUS_ARGS({ "path", "o" }),
manager_dial) },
{ GDBUS_ASYNC_METHOD("DialLast", NULL, NULL, manager_dial_last)},
+ { GDBUS_ASYNC_METHOD("DialMemory",
+ GDBUS_ARGS({"memory_location", "u" }), 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,