summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2008-10-17 14:28:53 +0300
committerJohan Hedberg <johan.hedberg@nokia.com>2008-12-08 16:10:55 +0200
commit6841e56241fb0d328036b8a9d9bea29fa453bfe8 (patch)
treeac6b30ae6539e249a2d2fdbde3f6383a67b0bfd2 /audio
parent3330b71328a13747171a35737b026c762e3808a9 (diff)
Implement telephony_list_current_calls_req properly
Diffstat (limited to 'audio')
-rw-r--r--audio/telephony-maemo.c63
1 files changed, 55 insertions, 8 deletions
diff --git a/audio/telephony-maemo.c b/audio/telephony-maemo.c
index c27c6cf9..037a39e0 100644
--- a/audio/telephony-maemo.c
+++ b/audio/telephony-maemo.c
@@ -77,7 +77,6 @@ static DBusConnection *connection = NULL;
static GSList *calls = NULL;
static char *subscriber_number = NULL;
-static char *active_call_number = NULL;
static int active_call_status = 0;
static int active_call_dir = 0;
@@ -299,16 +298,64 @@ void telephony_subscriber_number_req(void *telephony_device)
telephony_subscriber_number_rsp(telephony_device, CME_ERROR_NONE);
}
+static int csd_status_to_hfp(int csd_status)
+{
+ switch (csd_status) {
+ case CSD_CALL_STATUS_IDLE:
+ case CSD_CALL_STATUS_MO_RELEASE:
+ case CSD_CALL_STATUS_MT_RELEASE:
+ case CSD_CALL_STATUS_TERMINATED:
+ return -1;
+ case CSD_CALL_STATUS_CREATE:
+ /* Is PROCEEDING == DIALING correct? */
+ case CSD_CALL_STATUS_PROCEEDING:
+ return CALL_STATUS_DIALING;
+ case CSD_CALL_STATUS_COMING:
+ return CALL_STATUS_INCOMING;
+ case CSD_CALL_STATUS_MO_ALERTING:
+ return CALL_STATUS_INCOMING;
+ case CSD_CALL_STATUS_MT_ALERTING:
+ return CALL_STATUS_ALERTING;
+ case CSD_CALL_STATUS_ANSWERED:
+ case CSD_CALL_STATUS_ACTIVE:
+ case CSD_CALL_STATUS_RETRIEVE_INITIATED:
+ case CSD_CALL_STATUS_RECONNECT_PENDING:
+ case CSD_CALL_STATUS_SWAP_INITIATED:
+ return CALL_STATUS_ACTIVE;
+ case CSD_CALL_STATUS_HOLD_INITIATED:
+ case CSD_CALL_STATUS_HOLD:
+ return CALL_STATUS_HELD;
+ default:
+ return -1;
+ }
+}
+
void telephony_list_current_calls_req(void *telephony_device)
{
+ GSList *l;
+ int i;
+
debug("telephony-maemo: list current calls request");
- if (active_call_number)
- telephony_list_current_call_ind(1, active_call_dir,
- active_call_status,
- CALL_MODE_VOICE,
- CALL_MULTIPARTY_NO,
- active_call_number,
- 0);
+
+ for (l = calls, i = 1; l != NULL; l = l->next, i++) {
+ struct csd_call *call = l->data;
+ int status, direction, multiparty;
+
+ status = csd_status_to_hfp(call->status);
+ if (status < 0)
+ continue;
+
+ direction = call->originating ?
+ CALL_DIR_OUTGOING : CALL_DIR_INCOMING;
+
+ multiparty = call->conference ?
+ CALL_MULTIPARTY_YES : CALL_MULTIPARTY_NO;
+
+ telephony_list_current_call_ind(i, direction, status,
+ CALL_MODE_VOICE, multiparty,
+ call->number, 0);
+ }
+
telephony_list_current_calls_rsp(telephony_device, CME_ERROR_NONE);
}