Call: Added get current calls support
authorPaul Kocialkowski <contact@paulk.fr>
Mon, 30 Jul 2012 11:08:04 +0000 (13:08 +0200)
committerPaul Kocialkowski <contact@paulk.fr>
Mon, 30 Jul 2012 11:08:04 +0000 (13:08 +0200)
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
call.c [new file with mode: 0644]

diff --git a/call.c b/call.c
new file mode 100644 (file)
index 0000000..00e2be7
--- /dev/null
+++ b/call.c
@@ -0,0 +1,65 @@
+/*
+ * This file is part of hayes-ril.
+ *
+ * Copyright (C) 2012 Paul Kocialkowski <contact@paulk.fr>
+ *
+ * Parts of this code are based on htcgeneric-ril, reference-ril:
+ * Copyright 2006-2011, htcgeneric-ril contributors
+ * Copyright 2006, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "RIL-CALL"
+#include <utils/Log.h>
+#include <telephony/ril.h>
+
+#include <hayes-ril.h>
+
+int at_clcc_expect(struct at_response *response, void *data, RIL_Token t)
+{
+       RIL_Call **calls = NULL;
+       int calls_count = 0;
+       int i;
+
+       if(response->status == AT_STATUS_UNDEF)
+               return AT_RESPONSE_UNHANDELD_REASON_STATUS;
+
+       LOGD("GOT AT CLCC response");
+
+       if(at_status_error(response->status)) {
+               RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
+       }
+
+       // TODO: count calls
+       for(i=0 ; i < response->data_count ; i++) {
+               LOGD("CLCC data: %s", response->data[i]);
+       }
+
+       calls = calloc(1, sizeof(RIL_Call) * calls_count);
+
+       // TODO: copy calls
+
+       RIL_onRequestComplete(t, RIL_E_SUCCESS, calls, sizeof(RIL_Call) * calls_count);
+
+       return AT_RESPONSE_HANDLED_OK;
+}
+
+void ril_request_get_current_calls(RIL_Token t, void *data, size_t length)
+{
+       if(ril_globals.radio_state == RADIO_STATE_OFF) {
+               RIL_onRequestComplete(t, RIL_E_RADIO_NOT_AVAILABLE, NULL, 0);
+               return;
+       }
+       at_send_expect_to_func("AT+CLCC", NULL, NULL, t, at_clcc_expect);
+}