summaryrefslogtreecommitdiffstats
path: root/call.c
diff options
context:
space:
mode:
Diffstat (limited to 'call.c')
-rw-r--r--call.c205
1 files changed, 111 insertions, 94 deletions
diff --git a/call.c b/call.c
index ee164bd..4a71e34 100644
--- a/call.c
+++ b/call.c
@@ -1,11 +1,100 @@
+/**
+ * This file is part of samsung-ril.
+ *
+ * Copyright (C) 2010-2011 Joerie de Gram <j.de.gram@gmail.com>
+ * Copyright (C) 2011 Paul Kocialkowski <contact@oaulk.fr>
+ *
+ * samsung-ril is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * samsung-ril is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with samsung-ril. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
#define LOG_TAG "RIL-CALL"
#include <utils/Log.h>
#include "samsung-ril.h"
-extern const struct RIL_Env *rilenv;
-extern struct radio_state radio;
-extern struct ipc_client *ipc_client;
+/**
+ * In: RIL_UNSOL_CALL_RING
+ * Ring indication for an incoming call (eg, RING or CRING event).
+ */
+void ipc_call_incoming(struct ipc_message_info *info)
+{
+ RIL_onUnsolicitedResponse(RIL_UNSOL_CALL_RING, NULL, 0);
+
+ /* FIXME: Do we really need to send this? */
+ RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED, NULL, 0);
+}
+
+/**
+ * In: IPC_CALL_STATUS
+ * Indicates that a call's status has changed
+ *
+ * RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED
+ * Indicate when call state has changed
+ */
+void ipc_call_status(struct ipc_message_info *info)
+{
+ RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED, NULL, 0);
+}
+
+/**
+ * In: RIL_REQUEST_DIAL
+ * Initiate voice call
+ *
+ * Out: IPC_CALL_OUTGOING
+ */
+void ril_request_dial(RIL_Token t, void *data, size_t datalen)
+{
+ const RIL_Dial *dial = (const RIL_Dial*)data;
+ struct ipc_call_outgoing call;
+ int clir;
+
+ if(strlen(dial->address) > sizeof(call.number)) {
+ printf("Outgoing call number too long\n");
+ return;
+ }
+
+ /* FIXME: separate method? */
+ switch(dial->clir) {
+ case 0:
+ clir = IPC_CALL_IDENTITY_DEFAULT;
+ break;
+ case 1:
+ clir = IPC_CALL_IDENTITY_SHOW;
+ break;
+ case 2:
+ clir = IPC_CALL_IDENTITY_HIDE;
+ break;
+ default:
+ clir = IPC_CALL_IDENTITY_DEFAULT;
+ break;
+ }
+
+ memset(&call, 0x00, sizeof(call));
+
+ call.type = IPC_CALL_TYPE_VOICE;
+ call.identity = clir;
+ call.prefix = IPC_CALL_PREFIX_NONE;
+
+ call.length = strlen(dial->address);
+ memcpy(call.number, dial->address, strlen(dial->address));
+
+ ipc_fmt_send(IPC_CALL_OUTGOING, IPC_TYPE_EXEC, (unsigned char *) &call, sizeof(call), reqGetId(t));
+
+ /* FIXME: This should actually be sent based on the response from baseband */
+ RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);
+}
unsigned char call_list_entry_state_ipc2ril(unsigned char call_state)
{
@@ -35,9 +124,9 @@ unsigned char call_list_entry_state_ipc2ril(unsigned char call_state)
* Out: IPC_CALL_LIST GET
* Requests a list of active calls
*/
-void requestGetCurrentCalls(RIL_Token t)
+void ril_request_get_current_calls(RIL_Token t)
{
- ipc_client_send_get(IPC_CALL_LIST, getRequestId(t));
+ ipc_fmt_send_get(IPC_CALL_LIST, reqGetId(t));
}
/**
@@ -47,25 +136,25 @@ void requestGetCurrentCalls(RIL_Token t)
* Out: RIL_REQUEST_GET_CURRENT_CALLS
* Requests current call list
*/
-void respondCallList(RIL_Token t, void *data, int length)
+void ipc_call_list(struct ipc_message_info *info)
{
struct ipc_call_list_entry *entry;
unsigned char num_entries;
char *number, *number_ril;
int i;
- num_entries = *((unsigned char*)data);
- entry = (struct ipc_call_list_entry*)((char*)data+1);
+ num_entries = *((unsigned char *) info->data);
+ entry = (struct ipc_call_list_entry *) ((char *) info->data + 1);
- RIL_Call **calls = (RIL_Call**)malloc(num_entries * sizeof(RIL_Call*));
+ RIL_Call **calls = (RIL_Call **) malloc(num_entries * sizeof(RIL_Call *));
for(i = 0; i < num_entries; i++) {
- RIL_Call *call = (RIL_Call*)malloc(sizeof(RIL_Call));
+ RIL_Call *call = (RIL_Call *) malloc(sizeof(RIL_Call));
/* Number is located after call list entry */
- number = ((char*)entry) + sizeof(*entry);
+ number = ((char *) entry) + sizeof(*entry);
- number_ril = (char*)malloc(entry->number_len + 1);
+ number_ril = (char *) malloc(entry->number_len + 1);
memset(number_ril, 0, (entry->number_len + 1));
memcpy(number_ril, number, entry->number_len);
@@ -86,10 +175,10 @@ void respondCallList(RIL_Token t, void *data, int length)
calls[i] = call;
/* Next entry after current number */
- entry = (struct ipc_call_list_entry*)(number + entry->number_len);
+ entry = (struct ipc_call_list_entry *) (number + entry->number_len);
}
- RIL_onRequestComplete(t, RIL_E_SUCCESS, calls, (num_entries * sizeof(RIL_Call*)));
+ RIL_onRequestComplete(reqGetToken(info->aseq), RIL_E_SUCCESS, calls, (num_entries * sizeof(RIL_Call *)));
for(i = 0; i < num_entries; i++) {
free(calls[i]);
@@ -104,9 +193,9 @@ void respondCallList(RIL_Token t, void *data, int length)
*
* Out: IPC_CALL_RELEASE EXEC
*/
-void requestHangup(RIL_Token t)
+void ril_request_hangup(RIL_Token t)
{
- ipc_client_send_exec(IPC_CALL_RELEASE, getRequestId(t));
+ ipc_fmt_send_exec(IPC_CALL_RELEASE, reqGetId(t));
/* FIXME: This should actually be sent based on the response from baseband */
RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);
@@ -121,9 +210,9 @@ void requestHangup(RIL_Token t)
*
* Out: IPC_CALL_ANSWER
*/
-void requestAnswer(RIL_Token t)
+void ril_request_answer(RIL_Token t)
{
- ipc_client_send_exec(IPC_CALL_ANSWER, getRequestId(t));
+ ipc_fmt_send_exec(IPC_CALL_ANSWER, reqGetId(t));
/* FIXME: This should actually be sent based on the response from baseband */
RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);
@@ -132,79 +221,7 @@ void requestAnswer(RIL_Token t)
RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED, NULL, 0);
}
-/**
- * In: RIL_REQUEST_DIAL
- * Initiate voice call
- *
- * Out: IPC_CALL_OUTGOING
- */
-void requestDial(RIL_Token t, void *data, size_t datalen)
-{
- const RIL_Dial *dial = (const RIL_Dial*)data;
- struct ipc_call_outgoing call;
- int clir;
-
- if(strlen(dial->address) > sizeof(call.number)) {
- printf("Outgoing call number too long\n");
- return;
- }
-
- /* FIXME: separate method? */
- switch(dial->clir) {
- case 0:
- clir = IPC_CALL_IDENTITY_DEFAULT;
- break;
- case 1:
- clir = IPC_CALL_IDENTITY_SHOW;
- break;
- case 2:
- clir = IPC_CALL_IDENTITY_HIDE;
- break;
- default:
- clir = IPC_CALL_IDENTITY_DEFAULT;
- break;
- }
-
- memset(&call, 0x00, sizeof(call));
-
- call.type = IPC_CALL_TYPE_VOICE;
- call.identity = clir;
- call.prefix = IPC_CALL_PREFIX_NONE;
-
- call.length = strlen(dial->address);
- memcpy(call.number, dial->address, strlen(dial->address));
-
- ipc_client_send(ipc_client, IPC_CALL_OUTGOING, IPC_TYPE_EXEC, (unsigned char*)&call, sizeof(call), getRequestId(t));
-
- /* FIXME: This should actually be sent based on the response from baseband */
- RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);
-}
-
-/**
- * In: RIL_UNSOL_CALL_RING
- * Ring indication for an incoming call (eg, RING or CRING event).
- */
-void respondCallIncoming(RIL_Token t, void *data, int length)
-{
- RIL_onUnsolicitedResponse(RIL_UNSOL_CALL_RING, NULL, 0);
-
- /* FIXME: Do we really need to send this? */
- RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED, NULL, 0);
-}
-
-/**
- * In: IPC_CALL_STATUS
- * Indicates that a call's status has changed
- *
- * RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED
- * Indicate when call state has changed
- */
-void respondCallStatus(RIL_Token t, void *data, int length)
-{
- RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED, NULL, 0);
-}
-
-void requestDtmfStart(RIL_Token t, void *data, int length)
+void ril_request_dtmf_start(RIL_Token t, void *data, int length)
{
//TODO: Check if there is already a DTMF going on and cancel it if so
@@ -212,18 +229,18 @@ void requestDtmfStart(RIL_Token t, void *data, int length)
cont_dtmf.state = IPC_CALL_DTMF_STATE_START;
cont_dtmf.tone = ((char *)data)[0];
- ipc_client_send(ipc_client, IPC_CALL_CONT_DTMF, IPC_TYPE_SET, (unsigned char*)&cont_dtmf, sizeof(cont_dtmf), getRequestId(t));
+ ipc_fmt_send(IPC_CALL_CONT_DTMF, IPC_TYPE_SET, (unsigned char*)&cont_dtmf, sizeof(cont_dtmf), reqGetId(t));
RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);
}
-void requestDtmfStop(RIL_Token t)
+void ril_request_dtmf_stop(RIL_Token t)
{
struct ipc_call_cont_dtmf cont_dtmf;
cont_dtmf.state = IPC_CALL_DTMF_STATE_STOP;
cont_dtmf.tone = 0;
- ipc_client_send(ipc_client, IPC_CALL_CONT_DTMF, IPC_TYPE_SET, (unsigned char*)&cont_dtmf, sizeof(cont_dtmf), getRequestId(t));
+ ipc_fmt_send(IPC_CALL_CONT_DTMF, IPC_TYPE_SET, (unsigned char*)&cont_dtmf, sizeof(cont_dtmf), reqGetId(t));
RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);
}