2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.tizenopensource.org/license
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include "vc-core-tapi-rqst.h"
20 #include "vc-core-util.h"
21 #include "vc-core-engine-types.h"
23 static int gcall_vc_callmember_count = 0;
24 static gboolean gcall_vc_callend_wait = FALSE;
26 #ifdef _CALL_LONG_DTMF
27 static char gsz_dtmf_buffer[TAPI_CALL_DIALDIGIT_LEN_MAX + 1];
28 static int gdtmf_headindex = 0;
29 static int gdtmf_tailindex = 0;
30 static call_vc_dtmf_bufferstate_t gdtmf_buffer_state = CALL_VC_DTMF_BUF_NONE;
31 static gboolean glong_dtmf_mode = FALSE;
34 /*Local Function Declerations */
36 * This function splits the given call from the conference call , if available
39 * @return Returns TRUE on success or FALSE on failure
40 * @param[in] call_handle handle of the call to be splitted
42 static gboolean __call_vc_split_member(call_vc_handle call_handle);
45 * This function prepares for a call setup
47 * @return Returns TRUE on success and FALSE on failure
48 * @param[in] pcall_agent Pointer to the call agent state
50 gboolean _vc_core_tapi_rqst_prepare_setup_call(call_vc_callagent_state_t *pcall_agent)
52 call_vc_call_objectinfo_t callobject_info = { 0 };
54 VOICECALL_RETURN_FALSE_IF_FAIL(pcall_agent != NULL);
56 CALL_ENG_DEBUG(ENG_DEBUG, "IO State =%d, Agent State: %d", pcall_agent->io_state, pcall_agent->callagent_state);
58 _vc_core_cm_clear_call_object(&callobject_info);
59 if ((_vc_core_cm_get_outgoing_call_info(&pcall_agent->call_manager, &callobject_info) == FALSE) || (strlen(callobject_info.tel_number) == 0) || (pcall_agent->callagent_state != CALL_VC_CA_STATE_NORMAL)) {
60 CALL_ENG_DEBUG(ENG_DEBUG, "MO Call Not Possible: Number: %s", callobject_info.tel_number);
62 } else if (_vc_core_cm_isexists_active_call(&pcall_agent->call_manager) && _vc_core_cm_isexists_held_call(&pcall_agent->call_manager)) {
63 /*Emergency calls should be established, even when active or hold calls exists */
64 if (TRUE == callobject_info.bemergency_number) {
65 _vc_core_ca_change_agent_state(pcall_agent, CALL_VC_CA_STATE_WAIT_RELEASE_ALL_CALLS_TO_SETUP);
66 _vc_core_tapi_rqst_release_all_calls(pcall_agent);
69 CALL_ENG_DEBUG(ENG_DEBUG, "Active&Held call exist!");
72 } else if (_vc_core_cm_isexists_active_call(&pcall_agent->call_manager)) {
73 CALL_ENG_DEBUG(ENG_DEBUG, "There is active call when trying new call...");
75 /* Change the In Out State accordingly after Hold Call */
76 if (_vc_core_tapi_rqst_hold_call(pcall_agent) == FALSE) {
77 _vc_core_ca_change_inout_state(pcall_agent, VC_INOUT_STATE_NONE);
80 _vc_core_ca_change_inout_state(pcall_agent, VC_INOUT_STATE_OUTGOING_WAIT_HOLD);
81 _vc_core_ca_change_agent_state(pcall_agent, CALL_VC_CA_STATE_WAIT_HOLD);
85 if (_vc_core_tapi_rqst_setup_call(pcall_agent) == FALSE) {
86 _vc_core_ca_change_inout_state(pcall_agent, VC_INOUT_STATE_NONE);
87 CALL_ENG_DEBUG(ENG_DEBUG, "_vc_core_tapi_rqst_prepare_setup_call:Fail to _vc_core_tapi_rqst_setup_call");
90 /* Wait for the TAPI_EVENT_CALL_ORIG */
91 _vc_core_ca_change_inout_state(pcall_agent, VC_INOUT_STATE_OUTGOING_WAIT_ORIG);
100 * This function sets up an outgoing call
102 * @return Returns TRUE on success and FALSE on failure
103 * @param[in] pcall_agent Pointer to the call agent state
105 gboolean _vc_core_tapi_rqst_setup_call(call_vc_callagent_state_t *pcall_agent)
107 call_vc_handle call_handle = VC_TAPI_INVALID_CALLHANDLE;
108 TelCallSetupParams_t setupCallInfo;
109 /* TelCallCugInfo_t pCugInfo = {0,};*/
110 call_vc_call_objectinfo_t callobject_info = { 0 };
111 /* TelCallIdentityMode_t identityMode = TAPI_CALL_IDENTITY_DEFAULT;*/
112 TapiResult_t tapi_err = TAPI_API_SUCCESS;
113 int ReqId = VC_RQSTID_DEFAULT;
117 VOICECALL_RETURN_FALSE_IF_FAIL(pcall_agent != NULL);
119 memset(&setupCallInfo, 0, sizeof(TelCallSetupParams_t));
121 /* Get the Outgoing Call Info */
122 _vc_core_cm_clear_call_object(&callobject_info);
123 if (_vc_core_cm_get_outgoing_call_info(&pcall_agent->call_manager, &callobject_info) == FALSE) {
124 CALL_ENG_DEBUG(ENG_DEBUG, "Outgoing call info does not exist!");
127 /* set setupCallInfo structure for call setup */
128 if (callobject_info.bemergency_number == TRUE) {
129 CALL_ENG_DEBUG(ENG_DEBUG, "Emergency call!");
130 setupCallInfo.CallType = TAPI_CALL_TYPE_E911;
131 /*setupCallInfo.Ecc = callobject_info.ecc_category;
132 CALL_ENG_DEBUG(ENG_DEBUG,"Emergency call, ecc_category:[%d]!", callobject_info.ecc_category);*/
134 CALL_ENG_DEBUG(ENG_DEBUG, "Normal call!");
135 setupCallInfo.CallType = TAPI_CALL_TYPE_VOICE;
138 /*Set the Call Object MO Flag as TRUE */
139 callobject_info.mo = TRUE;
142 if (_vc_core_util_extract_call_number_without_cli(callobject_info.source_tel_number, setupCallInfo.szNumber, sizeof(setupCallInfo.szNumber)) == FALSE) {
143 CALL_ENG_DEBUG(ENG_DEBUG, "No proper number = %s", callobject_info.source_tel_number);
146 CALL_ENG_DEBUG(ENG_DEBUG, "tapi callnum=[%s]", setupCallInfo.szNumber);
151 setupCallInfo.pCugInfo = &pCugInfo;
152 if (FALSE == callobject_info.cug_info.bcug_used) {
153 setupCallInfo.pCugInfo->bCugFlag = FALSE;
155 setupCallInfo.pCugInfo->bCugFlag = TRUE;
156 /*if the index is 0, use pref cug, so no cug index */
157 if (0 == callobject_info.cug_info.cug_index) {
158 setupCallInfo.pCugInfo->Option = TAPI_CALL_CUG_NO_INFO;
159 setupCallInfo.pCugInfo->Index = 0;
161 if ((FALSE == callobject_info.cug_info.bpref_cug) && (FALSE == callobject_info.cug_info.boa_cug)) {
162 setupCallInfo.pCugInfo->Option = TAPI_CALL_CUG_SUPRESS_OA_AND_CUG;
163 } else if (FALSE == callobject_info.cug_info.bpref_cug) {
164 setupCallInfo.pCugInfo->Option = TAPI_CALL_CUG_SUPRESS_PRF_CUG;
165 } else if (FALSE == callobject_info.cug_info.boa_cug) {
166 setupCallInfo.pCugInfo->Option = TAPI_CALL_CUG_SUPRESS_OA;
168 setupCallInfo.pCugInfo->Option = TAPI_CALL_CUG_NO_INFO;
170 setupCallInfo.pCugInfo->Index = callobject_info.cug_info.cug_index;
175 #ifdef _CPHS_DEFINED_
176 if (TRUE == _vc_core_svcall_cphs_csp_get_status(pcall_agent, VC_CPHS_CSP_ALS)) {
177 if (callobject_info.setupBy == VC_CALL_SETUP_BY_MAILBOX) {
178 if (callobject_info.alsLine == VC_CALL_CPHS_ALS_LINE1) {
179 tel_set_call_act_line(TAPI_CALL_ACTIVE_LINE1, &ReqId);
180 } else if (callobject_info.alsLine == VC_CALL_CPHS_ALS_LINE2) {
181 tel_set_call_act_line(TAPI_CALL_ACTIVE_LINE2, &ReqId);
183 CALL_ENG_DEBUG(ENG_DEBUG, "callobject_info.alsLine invalid value=%d", callobject_info.alsLine);
184 tel_set_call_act_line(TAPI_CALL_ACTIVE_LINE1, &ReqId);
187 /*read the line information from the dynamic flags */
188 voice_call_cphs_alsline_t als_line;
189 callobject_info.alsLine = _vc_core_svcall_get_cphs_als_active_line(pcall_agent);
190 tel_set_call_act_line(callobject_info.alsLine);
191 _vc_core_cm_set_outgoing_call_info(&pcall_agent->call_manager, &callobject_info);
194 CALL_ENG_DEBUG(ENG_DEBUG, "ACtive Line Set is TAPI_ACTIVE_LINE1");
195 tel_set_call_act_line(TAPI_CALL_ACTIVE_LINE1, &ReqId);
199 CALL_ENG_DEBUG(ENG_DEBUG, "call_type = %d", setupCallInfo.CallType);
201 CALL_ENG_DEBUG(ENG_DEBUG, "Call Type by Source: %d", callobject_info.call_type);
202 if (VC_CALL_ORIG_TYPE_SAT == callobject_info.call_type) {
203 /*setupCallInfo.bRequestedBySAT = TRUE;*/
205 /*setupCallInfo.bRequestedBySAT = FALSE;*/
207 /*CALL_ENG_DEBUG(ENG_DEBUG,"Call Initiated by SAT: %d",setupCallInfo.bRequestedBySAT);*/
209 CALL_ENG_KPI("tel_exe_call_mo start");
210 /*This Function originates MO Call set-up, This is asynchronous function */
211 tapi_err = tel_exe_call_mo(&setupCallInfo, (TS_UINT *) &call_handle, &ReqId);
212 CALL_ENG_KPI("tel_exe_call_mo done");
214 CALL_ENG_DEBUG(ENG_DEBUG, "ReqId is = %d", ReqId);
216 if (TAPI_API_SUCCESS != tapi_err) {
217 CALL_ENG_DEBUG(ENG_DEBUG, "tapi_call_setup failed: Error Code: %d", tapi_err);
220 CALL_ENG_DEBUG(ENG_DEBUG, "call_handle = %d", call_handle);
222 /* Set the Call Handle to the CallbObject for future reference */
223 callobject_info.call_handle = call_handle;
225 _vc_core_cm_change_call_state(&callobject_info, VC_CALL_STATE_OUTGOING);
226 callobject_info.call_id = _vc_core_cm_get_new_callId(&pcall_agent->call_manager);
228 _vc_core_cm_set_outgoing_call_info(&pcall_agent->call_manager, &callobject_info);
230 CALL_VC_DUMP_CALLDETAILS(&pcall_agent->call_manager);
236 * This function answers the call
238 * @return Returns TRUE on success and FALSE on failure
239 * @param[in] pcall_agent Pointer to the call agent state
240 * @param[in] answer_type call answer type #voicecall_answer_type_t
241 * @param[out] error_code Error code
243 gboolean _vc_core_tapi_rqst_answer_call(call_vc_callagent_state_t *pcall_agent, voicecall_answer_type_t answer_type, int *error_code)
245 call_vc_handle call_handle = VC_TAPI_INVALID_CALLHANDLE;
246 /*Encapsulates Errors and Warnings from TAPI Library */
247 TapiResult_t tapi_err = TAPI_API_SUCCESS;
248 int ReqId = VC_RQSTID_DEFAULT;
249 VOICECALL_RETURN_FALSE_IF_FAIL(pcall_agent != NULL);
250 VOICECALL_RETURN_FALSE_IF_FAIL(error_code != NULL);
252 CALL_ENG_DEBUG(ENG_DEBUG, "..");
254 if ((VC_INOUT_STATE_INCOME_WAIT_CONNECTED == pcall_agent->io_state)
255 || (VC_INOUT_STATE_INCOME_WAIT_HOLD_CONNECTED == pcall_agent->io_state)
256 || (VC_INOUT_STATE_INCOME_WAIT_RELEASE_ACTIVE_CONNECTED == pcall_agent->io_state))
257 /*||(VC_INOUT_STATE_INCOME_WAIT_RELEASE_HOLDCALL == pcall_agent->io_state))*/
259 CALL_ENG_DEBUG(ENG_DEBUG, "Answer Call Request Already Made");
260 *error_code = ERROR_VOICECALL_PREVIOUS_REQUEST_IN_PROGRESS;
265 Process the answer call request only when the state is in income and it is not ended.
266 This must be checked as both incoming event and incoming end event from tapi are added to g_idle_add
267 so any change in state should be noted before accepting the call
269 if ((VC_INOUT_STATE_INCOME_BOX != pcall_agent->io_state) || (VC_INOUT_STATE_INCOME_END == pcall_agent->io_state)) {
270 CALL_ENG_DEBUG(ENG_DEBUG, "IO State not in VC_INOUT_STATE_INCOME_BOX, Current state: %d", pcall_agent->io_state);
271 *error_code = ERROR_VOICECALL_PREVIOUS_REQUEST_IN_PROGRESS;
275 _vc_core_cm_clear_endcall_member(&pcall_agent->call_manager);
276 call_handle = _vc_core_cm_get_incoming_call_handle(&pcall_agent->call_manager);
278 CALL_ENG_DEBUG(ENG_DEBUG, "answer_type = %d,Incoming call Handle: %d", answer_type, call_handle);
279 if (VC_TAPI_INVALID_CALLHANDLE == call_handle) {
280 *error_code = ERROR_VOICECALL_CALL_INFO_NOT_AVAILABLE;
284 switch (answer_type) {
285 case VC_ANSWER_NORMAL:
287 /*Answer a call by accepting or rejecting a call */
288 tapi_err = tel_answer_call(call_handle, TAPI_CALL_ANSWER_ACCEPT, &ReqId);
289 if (TAPI_API_SUCCESS == tapi_err) {
290 _vc_core_ca_change_inout_state(pcall_agent, VC_INOUT_STATE_INCOME_WAIT_CONNECTED);
294 case VC_ANSWER_HOLD_ACTIVE_AND_ACCEPT:
296 /*Answer a call by accepting or rejecting a call */
297 tapi_err = tel_answer_call(call_handle, TAPI_CALL_ANSWER_HOLD_AND_ACCEPT, &ReqId);
298 if (TAPI_API_SUCCESS == tapi_err) {
299 _vc_core_ca_change_inout_state(pcall_agent, VC_INOUT_STATE_INCOME_WAIT_HOLD_CONNECTED);
300 _vc_core_ca_change_agent_state(pcall_agent, CALL_VC_CA_STATE_WAIT_HOLD);
304 case VC_ANSWER_RELEASE_ACTIVE_AND_ACCEPT:
306 /*Answer a call by accepting or rejecting a call */
307 tapi_err = tel_answer_call(call_handle, TAPI_CALL_ANSWER_REPLACE, &ReqId);
308 if (TAPI_API_SUCCESS == tapi_err) {
309 _vc_core_ca_change_inout_state(pcall_agent, VC_INOUT_STATE_INCOME_WAIT_RELEASE_ACTIVE_CONNECTED);
313 case VC_ANSWER_RELEASE_HOLD_AND_ACCEPT:
315 /* first end held call and then accept incoming */
316 if (TRUE == _vc_core_tapi_rqst_release_held_calls(pcall_agent)) {
317 CALL_ENG_DEBUG(ENG_DEBUG, "_vc_core_tapi_rqst_release_held_calls returns TRUE");
318 _vc_core_ca_change_inout_state(pcall_agent, VC_INOUT_STATE_INCOME_WAIT_RELEASE_HOLDCALL);
319 _vc_core_ca_change_agent_state(pcall_agent, CALL_VC_CA_STATE_WAIT_RELEASE_ALL_HOLDCALL);
324 #ifdef RELEASE_ALL_AND_ACCEPT_SUPPORT
325 case VC_ANSWER_RELEASE_ALL_AND_ACCEPT:
327 /* first (end held call) and then ( release accept and accept ) */
328 if (TRUE == _vc_core_tapi_rqst_release_held_calls(pcall_agent)) {
329 CALL_ENG_DEBUG(ENG_DEBUG, "_vc_core_tapi_rqst_release_held_calls returns TRUE");
330 _vc_core_ca_change_inout_state(pcall_agent, VC_INOUT_STATE_INCOME_WAIT_RELEASE_HOLDCALL_FOR_ALL_RELEASE);
331 _vc_core_ca_change_agent_state(pcall_agent, CALL_VC_CA_STATE_WAIT_RELEASE_ALL_HOLDCALL);
339 *error_code = ERROR_VOICECALL_NOT_SUPPORTED;
344 if (TAPI_API_SUCCESS != tapi_err) {
345 _vc_core_ca_change_inout_state(pcall_agent, VC_INOUT_STATE_NONE);
346 CALL_ENG_DEBUG(ENG_DEBUG, "tel_answer_call failed ,Error Code:%d", tapi_err);
347 *error_code = ERROR_VOICECALL_ANSWER_FAILED;
348 CALL_ENG_DEBUG(ENG_DEBUG, "tel_answer_call failed ,Engine Error Code:%d", *error_code);
356 * This function checks and prepares to accept a call
358 * @return Returns TRUE on success and FALSE on failure
359 * @param[in] pcall_agent Pointer to the call agent state
361 gboolean _vc_core_tapi_rqst_response_call(call_vc_callagent_state_t *pcall_agent)
363 gboolean active_call, held_call, incoming_call;
364 call_vc_handle call_handle = VC_TAPI_INVALID_CALLHANDLE;
366 VOICECALL_RETURN_FALSE_IF_FAIL(pcall_agent != NULL);
368 active_call = _vc_core_cm_isexists_active_call(&pcall_agent->call_manager);
369 held_call = _vc_core_cm_isexists_held_call(&pcall_agent->call_manager);
370 incoming_call = _vc_core_cm_isexists_incoming_call(&pcall_agent->call_manager);
372 if (active_call && held_call) {
373 CALL_ENG_DEBUG(ENG_DEBUG, "Show EndCallChoice Box");
375 } else if (active_call) {
376 CALL_ENG_DEBUG(ENG_DEBUG, "Case of bActiceCall...");
377 /* if there are active call, after hold call can accept mtc */
378 /* set the flag and return */
379 /*Although TapiHold failed, keep on going( because , when active call is ended, TapiHold failed then ansercall is possible... only when Tapihold succeed, state is changed to WAIT_HOLD*/
380 if (_vc_core_tapi_rqst_hold_call(pcall_agent) == TRUE) {
381 _vc_core_ca_change_inout_state(pcall_agent, VC_INOUT_STATE_INCOME_WAIT_HOLD);
382 _vc_core_ca_change_agent_state(pcall_agent, CALL_VC_CA_STATE_WAIT_HOLD);
385 } else if (incoming_call == FALSE) {
386 CALL_ENG_DEBUG(ENG_DEBUG, "No Call Available");
390 CALL_ENG_DEBUG(ENG_DEBUG, "Calling tapi_call_respond_recall(call_handle = %d, TRUE) ...", call_handle);
396 * This function releases active calls
398 * @return Returns TRUE on success and FALSE on failure
399 * @param[in] pcall_agent Pointer to the call agent state
401 gboolean _vc_core_tapi_rqst_release_active_calls(call_vc_callagent_state_t *pcall_agent)
403 call_vc_handle call_handle = VC_TAPI_INVALID_CALLHANDLE;
404 int pReqId = VC_RQSTID_DEFAULT;
405 TapiResult_t tapi_err = TAPI_API_SUCCESS;
408 call_vc_call_objectinfo_t callobject_info = { 0 };
410 VOICECALL_RETURN_FALSE_IF_FAIL(pcall_agent != NULL);
411 CALL_ENG_DEBUG(ENG_DEBUG, "..");
413 nPos = _vc_core_cm_get_first_active_call_handle(&pcall_agent->call_manager, &call_handle);
415 if (call_handle != -1) {
416 CALL_ENG_DEBUG(ENG_DEBUG, "First Active call_handle = %d", call_handle);
417 #ifdef SINGLE_CALL_END
418 if (_vc_core_cm_get_call_member_count(&pcall_agent->call_manager) == 1) {
419 CALL_ENG_DEBUG(ENG_DEBUG, "End Single call..");
421 /* Use ReleaseAll api in case single call is ended - this is caused by modem limitation */
422 tapi_err = tel_release_call_all(&pReqId);
426 tapi_err = tel_release_call_all_active(&pReqId);
429 if (TAPI_API_SUCCESS != tapi_err) {
430 CALL_ENG_DEBUG(ENG_DEBUG, "Release All Active Failed call_handle=%d Error Code:%d...", call_handle, tapi_err);
433 CALL_ENG_DEBUG(ENG_DEBUG, "pReqId = %d", pReqId);
435 _vc_core_cm_get_call_object(&pcall_agent->call_manager, call_handle, &callobject_info);
436 _vc_core_cm_change_call_state(&callobject_info, VC_CALL_STATE_RELEASE_WAIT);
437 _vc_core_cm_set_call_object(&pcall_agent->call_manager, &callobject_info);
439 nPos = _vc_core_cm_get_next_active_call_handle(&pcall_agent->call_manager, &call_handle, nPos);
445 CALL_ENG_DEBUG(ENG_DEBUG, "No Active calls available");
449 gcall_vc_callmember_count = 0;
451 nPos = _vc_core_cm_get_first_active_call_handle(&pcall_agent->call_manager, &call_handle);
453 _vc_core_cm_clear_call_object(&callobject_info);
455 _vc_core_cm_get_call_object(&pcall_agent->call_manager, call_handle, &callobject_info);
457 if (callobject_info.state == VC_CALL_STATE_CONNECTED) {
458 #ifdef SINGLE_CALL_END
459 if (_vc_core_cm_get_call_member_count(&pcall_agent->call_manager) == 1) {
460 CALL_ENG_DEBUG(ENG_DEBUG, "End Single call..");
462 /* Use ReleaseAll api in case single call is ended - this is caused by modem limitation */
463 tapi_err = tel_release_call_all(&pReqId);
467 /*Releases the call identified by Call Handle irrespective of call is hold or active state */
468 tapi_err = tel_release_call(call_handle, &pReqId);
471 if (TAPI_API_SUCCESS != tapi_err) {
472 CALL_ENG_DEBUG(ENG_DEBUG, "tapi_call_relese Failed call_handle=%d Error Code:%d...", call_handle, tapi_err);
475 _vc_core_cm_change_call_state(&callobject_info, VC_CALL_STATE_RELEASE_WAIT);
476 _vc_core_cm_set_call_object(&pcall_agent->call_manager, &callobject_info);
480 nPos = _vc_core_cm_get_next_active_call_handle(&pcall_agent->call_manager, &call_handle, nPos);
483 gcall_vc_callmember_count = nCount;
484 if (gcall_vc_callmember_count > 0) {
485 gcall_vc_callend_wait = TRUE;
488 CALL_ENG_DEBUG(ENG_DEBUG, "There is no active call to release..");
495 * This function releases held calls
497 * @return Returns TRUE on success and FALSE on failure
498 * @param[in] pcall_agent Pointer to the call agent state
500 gboolean _vc_core_tapi_rqst_release_held_calls(call_vc_callagent_state_t *pcall_agent)
503 call_vc_handle call_handle = VC_TAPI_INVALID_CALLHANDLE;
504 call_vc_call_objectinfo_t callobject_info = { 0 };
506 int pReqId = VC_RQSTID_DEFAULT;
507 TapiResult_t tapi_err = TAPI_API_SUCCESS;
509 VOICECALL_RETURN_FALSE_IF_FAIL(pcall_agent != NULL);
510 CALL_ENG_DEBUG(ENG_DEBUG, "..");
512 nPos = _vc_core_cm_get_first_held_call_handle(&pcall_agent->call_manager, &call_handle);
514 if (call_handle != -1) {
515 CALL_ENG_DEBUG(ENG_DEBUG, "First Held call_handle = %d", call_handle);
516 #ifdef SINGLE_CALL_END
517 if (_vc_core_cm_get_call_member_count(&pcall_agent->call_manager) == 1) {
518 CALL_ENG_DEBUG(ENG_DEBUG, "End Single call..");
520 /* Use ReleaseAll api in case single call is ended - this is caused by modem limitation */
521 tapi_err = tel_release_call_all(&pReqId);
525 tapi_err = tel_release_call_all_held(&pReqId);
528 if (TAPI_API_SUCCESS != tapi_err) {
529 CALL_ENG_DEBUG(ENG_DEBUG, "Release All Held Failed call_handle=%d Error Code:%d...", call_handle, tapi_err);
532 CALL_ENG_DEBUG(ENG_DEBUG, "pReqId = %d", pReqId);
534 _vc_core_cm_get_call_object(&pcall_agent->call_manager, call_handle, &callobject_info);
535 _vc_core_cm_change_call_state(&callobject_info, VC_CALL_STATE_RELEASE_WAIT);
536 _vc_core_cm_set_call_object(&pcall_agent->call_manager, &callobject_info);
538 nPos = _vc_core_cm_get_next_held_call_handle(&pcall_agent->call_manager, &call_handle, nPos);
544 CALL_ENG_DEBUG(ENG_DEBUG, "No Held calls available");
548 gcall_vc_callmember_count = 0;
550 nPos = _vc_core_cm_get_first_held_call_handle(&pcall_agent->call_manager, &call_handle);
552 _vc_core_cm_clear_call_object(&callobject_info);
554 _vc_core_cm_get_call_object(&pcall_agent->call_manager, call_handle, &callobject_info);
556 if (callobject_info.state == VC_CALL_STATE_CONNECTED) {
557 #ifdef SINGLE_CALL_END
558 if (_vc_core_cm_get_call_member_count(&pcall_agent->call_manager) == 1) {
559 CALL_ENG_DEBUG(ENG_DEBUG, "End Single call..");
561 /* Use ReleaseAll api in case single call is ended - this is caused by modem limitation */
562 tapi_err = tel_release_call_all(&pReqId);
566 /*Releases the call identified by Call Handle irrespective of call is hold or active state */
567 tapi_err = tel_release_call(call_handle, &pReqId);
570 if (TAPI_API_SUCCESS != tapi_err) {
571 CALL_ENG_DEBUG(ENG_DEBUG, "tapi_call_relese Failed call_handle=%d Error Code:%d...", call_handle, tapi_err);
574 _vc_core_cm_change_call_state(&callobject_info, VC_CALL_STATE_RELEASE_WAIT);
575 _vc_core_cm_set_call_object(&pcall_agent->call_manager, &callobject_info);
579 nPos = _vc_core_cm_get_next_held_call_handle(&pcall_agent->call_manager, &call_handle, nPos);
582 gcall_vc_callmember_count = nCount;
583 if (gcall_vc_callmember_count > 0) {
584 gcall_vc_callend_wait = TRUE;
587 CALL_ENG_DEBUG(ENG_DEBUG, "There is no held call to release..");
594 * This function releases all calls
596 * @return Returns TRUE on success and FALSE on failure
597 * @param[in] pcall_agent Pointer to the call agent state
599 gboolean _vc_core_tapi_rqst_release_all_calls(call_vc_callagent_state_t *pcall_agent)
601 call_vc_handle call_handle = VC_TAPI_INVALID_CALLHANDLE;
602 int pReqId = VC_RQSTID_DEFAULT;
603 TapiResult_t tapi_err = TAPI_API_SUCCESS;
605 VOICECALL_RETURN_FALSE_IF_FAIL(pcall_agent != NULL);
607 CALL_ENG_DEBUG(ENG_DEBUG, "..");
609 _vc_core_cm_get_first_active_call_handle(&pcall_agent->call_manager, &call_handle);
610 CALL_ENG_DEBUG(ENG_DEBUG, "call_handle:[%d]..", call_handle);
612 if (VC_TAPI_INVALID_CALLHANDLE == call_handle) {
613 _vc_core_cm_get_first_held_call_handle(&pcall_agent->call_manager, &call_handle);
616 if (VC_TAPI_INVALID_CALLHANDLE == call_handle) {
617 CALL_ENG_DEBUG(ENG_DEBUG, "invalid call handle");
621 /*Releases All calls irrespective of call is in hold or active state */
622 tapi_err = tel_release_call_all(&pReqId);
623 if (TAPI_API_SUCCESS != tapi_err) {
624 CALL_ENG_DEBUG(ENG_DEBUG, "tel_release_call_all failed: Error _Code: %d", tapi_err);
632 * This function releases the incoming call
634 * @return Returns TRUE on success and FALSE on failure
635 * @param[in] pcall_agent Pointer to the call agent state
637 gboolean _vc_core_tapi_rqst_release_incoming_call(call_vc_callagent_state_t *pcall_agent)
639 call_vc_handle call_handle = VC_TAPI_INVALID_CALLHANDLE;
640 int pReqId = VC_RQSTID_DEFAULT;
641 TapiResult_t tapi_err = TAPI_API_SUCCESS;
643 VOICECALL_RETURN_FALSE_IF_FAIL(pcall_agent != NULL);
645 call_handle = _vc_core_cm_get_incoming_call_handle(&pcall_agent->call_manager);
646 if (VC_TAPI_INVALID_CALLHANDLE == call_handle)
649 #ifdef SINGLE_CALL_END
650 if (_vc_core_cm_get_call_member_count(&pcall_agent->call_manager) == 1) {
651 CALL_ENG_DEBUG(ENG_DEBUG, "End Single call..");
653 /* Use ReleaseAll api in case single call is ended - this is caused by modem limitation */
654 tapi_err = tel_release_call_all(&pReqId);
658 /*Releases the call identified by Call Handle irrespective of call is hold or active state */
659 tapi_err = tel_release_call(call_handle, &pReqId);
662 if (TAPI_API_SUCCESS != tapi_err) {
663 CALL_ENG_DEBUG(ENG_DEBUG, "tel_release_call() call_handle=%d Failed, Error Code: %d...", call_handle, tapi_err);
667 _vc_core_cm_change_call_object_state(&pcall_agent->call_manager, call_handle, VC_CALL_STATE_REJECTED);
674 * This function releases outgoing call
676 * @return Returns TRUE on success and FALSE on failure
677 * @param[in] pcall_agent Pointer to the call agent state
679 gboolean _vc_core_tapi_rqst_release_outgoing_call(call_vc_callagent_state_t *pcall_agent)
682 call_vc_handle call_handle = VC_TAPI_INVALID_CALLHANDLE;
683 int pReqId = VC_RQSTID_DEFAULT;
684 TapiResult_t tapi_err = TAPI_API_SUCCESS;
686 VOICECALL_RETURN_FALSE_IF_FAIL(pcall_agent != NULL);
688 call_handle = _vc_core_cm_get_outgoing_call_handle(&pcall_agent->call_manager);
690 if (VC_TAPI_INVALID_CALLHANDLE == call_handle)
693 #ifdef SINGLE_CALL_END
694 if (_vc_core_cm_get_call_member_count(&pcall_agent->call_manager) == 1) {
695 CALL_ENG_DEBUG(ENG_DEBUG, "End Single call..");
697 /* Use ReleaseAll api in case single call is ended - this is caused by modem limitation */
698 tapi_err = tel_release_call_all(&pReqId);
702 /*Releases the call identified by Call Handle irrespective of call is hold or active state */
703 tapi_err = tel_release_call(call_handle, &pReqId);
706 if (TAPI_API_SUCCESS != tapi_err) {
707 CALL_ENG_DEBUG(ENG_DEBUG, "tel_release_call Failed call_handle=%d Error Code:%d", call_handle, tapi_err);
711 _vc_core_cm_change_call_object_state(&pcall_agent->call_manager, call_handle, VC_CALL_STATE_CANCELLED);
717 * This function holds a call
719 * @return Returns TRUE on success and FALSE on failure
720 * @param[in] pcall_agent Pointer to the call agent structure
722 gboolean _vc_core_tapi_rqst_hold_call(call_vc_callagent_state_t *pcall_agent)
724 call_vc_handle call_handle = VC_TAPI_INVALID_CALLHANDLE;
725 TapiResult_t tapi_err = TAPI_API_SUCCESS;
726 int ReqId = VC_RQSTID_DEFAULT;
728 VOICECALL_RETURN_FALSE_IF_FAIL(pcall_agent != NULL);
730 /*Get the current active call handle and hold it*/
731 _vc_core_cm_get_first_active_call_handle(&pcall_agent->call_manager, &call_handle);
732 if (call_handle == VC_TAPI_INVALID_CALLHANDLE) {
733 CALL_ENG_DEBUG(ENG_DEBUG, "ERROR: No active call available");
737 CALL_ENG_DEBUG(ENG_DEBUG, "calling tapi_call_hold, Current active call = %d...", call_handle);
740 /*Puts the given call on hold */
741 tapi_err = tel_hold_call(call_handle, &ReqId);
742 if (TAPI_API_SUCCESS != tapi_err) {
743 CALL_ENG_DEBUG(ENG_DEBUG, "tel_hold_call() Failed Error Code: %d", tapi_err);
751 * This function retrieves a call from hold
753 * @return Returns TRUE on success and FALSE on failure
754 * @param[in] pcall_agent Pointer to the call agent structure
756 gboolean _vc_core_tapi_rqst_retrieve_call(call_vc_callagent_state_t *pcall_agent)
758 call_vc_handle call_handle = VC_TAPI_INVALID_CALLHANDLE;
759 TapiResult_t tapi_err = TAPI_API_SUCCESS;
760 int ReqId = VC_RQSTID_DEFAULT;
762 CALL_ENG_DEBUG(ENG_DEBUG, "...");
763 VOICECALL_RETURN_FALSE_IF_FAIL(pcall_agent != NULL);
765 _vc_core_cm_get_first_held_call_handle(&pcall_agent->call_manager, &call_handle);
766 if (call_handle == VC_TAPI_INVALID_CALLHANDLE) {
767 CALL_ENG_DEBUG(ENG_DEBUG, "No Hold Call Error...");
771 CALL_ENG_DEBUG(ENG_DEBUG, "Cur held call_handle = %d.", call_handle);
772 /* activate the call */
773 /*This function retrieves the held call */
774 tapi_err = tel_retrieve_call(call_handle, &ReqId);
775 if (TAPI_API_SUCCESS != tapi_err) {
776 CALL_ENG_DEBUG(ENG_DEBUG, "tel_retrieve_call() Failed, Error Code: %d", tapi_err);
784 * This function swaps held and active calls
786 * @return Returns TRUE on success and FALSE on failure
787 * @param[in] pcall_agent Pointer to the call agent structure
789 gboolean _vc_core_tapi_rqst_swap_calls(call_vc_callagent_state_t *pcall_agent)
791 call_vc_handle active_call = VC_TAPI_INVALID_CALLHANDLE, held_call = VC_TAPI_INVALID_CALLHANDLE;
792 TapiResult_t tapi_err = TAPI_API_SUCCESS;
793 int ReqId = VC_RQSTID_DEFAULT;
795 CALL_ENG_DEBUG(ENG_DEBUG, "..");
796 VOICECALL_RETURN_FALSE_IF_FAIL(pcall_agent != NULL);
798 _vc_core_cm_get_first_active_call_handle(&pcall_agent->call_manager, &active_call);
799 if (active_call == VC_TAPI_INVALID_CALLHANDLE) {
800 CALL_ENG_DEBUG(ENG_DEBUG, "No Active Call...");
804 _vc_core_cm_get_first_held_call_handle(&pcall_agent->call_manager, &held_call);
805 if (held_call == VC_TAPI_INVALID_CALLHANDLE) {
806 CALL_ENG_DEBUG(ENG_DEBUG, "_vc_core_tapi_rqst_swap_calls: No Hold Call...");
810 CALL_ENG_DEBUG(ENG_DEBUG, "Current Active call = %d, Hold call :%d", active_call, held_call);
812 tapi_err = tel_swap_call(active_call, held_call, &ReqId);
813 if (TAPI_API_SUCCESS != tapi_err) {
814 CALL_ENG_DEBUG(ENG_DEBUG, "tel_swap_call() Failed, Error Code: %d", tapi_err);
822 * This function joins two calls
824 * @return Returns TRUE on success and FALSE on failure
825 * @param[in] pcall_agent Pointer to the call agent structure
827 gboolean _vc_core_tapi_rqst_join_calls(call_vc_callagent_state_t *pcall_agent)
829 call_vc_handle active_call = VC_TAPI_INVALID_CALLHANDLE, held_call = VC_TAPI_INVALID_CALLHANDLE;
830 TapiResult_t tapi_err = TAPI_API_SUCCESS;
831 int ReqId = VC_RQSTID_DEFAULT;
833 VOICECALL_RETURN_FALSE_IF_FAIL(pcall_agent != NULL);
835 _vc_core_cm_get_first_active_call_handle(&pcall_agent->call_manager, &active_call);
836 if (active_call == VC_TAPI_INVALID_CALLHANDLE) {
837 CALL_ENG_DEBUG(ENG_DEBUG, "No Active Call");
841 _vc_core_cm_get_first_held_call_handle(&pcall_agent->call_manager, &held_call);
842 if (held_call == VC_TAPI_INVALID_CALLHANDLE) {
843 CALL_ENG_DEBUG(ENG_DEBUG, "No Hold Call");
847 CALL_ENG_DEBUG(ENG_DEBUG, "Current Active call = %d, Hold call :%d", active_call, held_call);
848 /*This functions joins given two calls */
849 tapi_err = tel_join_call(active_call, held_call, &ReqId);
850 if (TAPI_API_SUCCESS != tapi_err) {
851 CALL_ENG_DEBUG(ENG_DEBUG, "tel_join_call() Failed, Error Code: %d", tapi_err);
859 * This function splits the members of a call given its call handle
861 * @return Returns TRUE on success and FALSE on failure
862 * @param[in] pcall_agent Pointer to the call agent structure
863 * @param[in] call_handle Call handle for a call the members of which has to be split
865 gboolean _vc_core_tapi_rqst_private_call(call_vc_callagent_state_t *pcall_agent, call_vc_handle call_handle)
868 if (TRUE == __call_vc_split_member(call_handle)) {
869 _vc_core_ca_change_agent_state(pcall_agent, CALL_VC_CA_STATE_WAIT_SPLIT);
872 _vc_core_ca_change_agent_state(pcall_agent, CALL_VC_CA_STATE_NORMAL);
877 static gboolean __call_vc_split_member(call_vc_handle call_handle)
879 TapiResult_t tapi_err = TAPI_API_SUCCESS;
880 int ReqId = VC_RQSTID_DEFAULT;
882 CALL_ENG_DEBUG(ENG_DEBUG, "...");
883 VOICECALL_RETURN_FALSE_IF_FAIL(call_handle != VC_TAPI_INVALID_CALLHANDLE);
885 CALL_ENG_DEBUG(ENG_DEBUG, "call_handle to be splited : %d", call_handle);
887 /*Splits a private call from multiparty call. */
888 tapi_err = tel_split_call(call_handle, &ReqId);
889 if (TAPI_API_SUCCESS != tapi_err) {
890 CALL_ENG_DEBUG(ENG_DEBUG, "tel_split_call() Failed, Error Code: %d", tapi_err);
898 * This function transfers call
900 * @return Returns TRUE on success and FALSE on failure
901 * @param[in] pcall_agent Pointer to the call agent structure
903 gboolean _vc_core_tapi_rqst_transfer_call(call_vc_callagent_state_t *pcall_agent)
905 call_vc_handle active_call = VC_TAPI_INVALID_CALLHANDLE;
906 TapiResult_t tapi_err = TAPI_API_SUCCESS;
907 int ReqId = VC_RQSTID_DEFAULT;
909 VOICECALL_RETURN_FALSE_IF_FAIL(pcall_agent != NULL);
911 _vc_core_cm_get_first_active_call_handle(&pcall_agent->call_manager, &active_call);
912 if (active_call == VC_TAPI_INVALID_CALLHANDLE) {
913 CALL_ENG_DEBUG(ENG_DEBUG, "No Active Call...");
915 active_call = _vc_core_cm_get_outgoing_call_handle(&pcall_agent->call_manager);
916 if (VC_TAPI_INVALID_CALLHANDLE == active_call) {
917 CALL_ENG_DEBUG(ENG_DEBUG, "No Outgoing Call...");
920 CALL_ENG_DEBUG(ENG_DEBUG, "Outgoing call exist..!!");
922 CALL_ENG_DEBUG(ENG_DEBUG, "active_call = %d ", active_call);
924 /*An explicit call transfer by connecting the two parties where in one party being
925 active (active state) and another party being held (held state) */
926 tapi_err = tel_exe_call_explicit_transfer(active_call, &ReqId);
927 if (TAPI_API_SUCCESS != tapi_err) {
928 CALL_ENG_DEBUG(ENG_DEBUG, "tel_exe_call_explicit_transfer() Failed, Error Code: %d", tapi_err);
936 * This function sends the given string as dtmf
938 * @return Returns TRUE on success and FALSE on failure
939 * @param[in] pcall_agent Pointer to the call agent structure
940 * @param[in] dtmf_string dtmf string
942 gboolean _vc_core_tapi_rqst_start_dtmf(call_vc_callagent_state_t *pcall_agent, char *dtmf_string)
944 call_vc_handle call_handle = VC_TAPI_INVALID_CALLHANDLE;
945 TapiResult_t tapi_err = TAPI_API_SUCCESS;
946 int ReqId = VC_RQSTID_DEFAULT;
948 VOICECALL_RETURN_FALSE_IF_FAIL(pcall_agent != NULL);
950 CALL_ENG_DEBUG(ENG_DEBUG, "Start DTMF!! string = %s", dtmf_string);
952 _vc_core_cm_get_first_active_call_handle(&pcall_agent->call_manager, &call_handle);
954 if (call_handle == VC_TAPI_INVALID_CALLHANDLE) {
955 CALL_ENG_DEBUG(ENG_DEBUG, "No Active Call Handle..");
959 CALL_ENG_DEBUG(ENG_DEBUG, "string = %s", dtmf_string);
962 /*This function sends one or more DTMF digits during call */
963 tapi_err = tel_send_call_dtmf(dtmf_string, &ReqId);
965 if (TAPI_API_SUCCESS != tapi_err) {
966 CALL_ENG_DEBUG(ENG_DEBUG, "tapi_call_dtmf Failed, Error Code: %d", tapi_err);
970 CALL_ENG_DEBUG(ENG_DEBUG, " Ended...");
976 #ifdef _SEND_UUSINFO_
978 * This function sends user to user information
980 * @return Returns TRUE on success and FALSE on failure
981 * @param[in] pcall_agent Pointer to the call agent state
982 * @param[in] call_handle The call handle for which the information has to be sent
983 * @param[in] pszUusData User data
985 gboolean call_vc_send_uusinfo(call_vc_callagent_state_t *pcall_agent, call_vc_handle call_handle, char *pszUusData)
987 TelCallUusInfo_t uusInfo;
990 VOICECALL_RETURN_FALSE_IF_FAIL(pcall_agent != NULL);
992 memset(&uusInfo, 0, sizeof(TelCallUusInfo_t));
994 uusInfo.bMoreDataPresent = FALSE; /*more_data_present = FALSE;*/
995 uusInfo.ProtocolType = TAPI_CALL_UUS_PROTO_SPECIFIC;
996 uusInfo.UusType = TAPI_CALL_UUS_1;
997 uusInfo.UusDataLen = strlen(pszUusData);
999 _vc_core_util_strcpy((char *)uusInfo.UusData, sizeof(uusInfo.UusData), pszUusData);
1001 nPos = _vc_core_cm_get_first_active_call_handle(&pcall_agent->call_manager, &call_handle);
1002 while (nPos != -1) {
1003 /*TAPI API not available to send user info */
1004 /*tapi doen't supprot this api.*/
1005 /******************************************************************************************
1006 tapi_err = tapi_call_send_user_info(call_handle, &uusInfo);
1007 if (TAPI_API_SUCCESS != tapi_err) {
1008 CALL_ENG_DEBUG(ENG_DEBUG, "tapi_call_send_user_info() Failed,Error Code: %d", tapi_err);
1011 ******************************************************************************************/
1012 nPos = _vc_core_cm_get_next_active_call_handle(&pcall_agent->call_manager, &call_handle, nPos);
1020 * This function releases the call associate with the given call handle
1022 * @return Returns TRUE on success and FALSE on failure
1023 * @param[in] pcall_agent Pointer to the call agent state
1024 * @param[in] call_handle handle of the call to be ended
1026 gboolean _vc_core_tapi_rqst_end_call_by_callhandle(call_vc_callagent_state_t *pcall_agent, call_vc_handle call_handle)
1028 call_vc_call_objectinfo_t callobject_info;
1029 int pReqId = VC_RQSTID_DEFAULT;
1030 TapiResult_t tapi_err = TAPI_API_SUCCESS;
1032 VOICECALL_RETURN_FALSE_IF_FAIL(pcall_agent != NULL);
1034 if (FALSE == _vc_core_cm_get_call_object(&pcall_agent->call_manager, call_handle, &callobject_info)) {
1035 CALL_ENG_DEBUG(ENG_DEBUG, "Call Object not available for call handle: %d", call_handle);
1040 if (VC_CALL_STATE_CONNECTED == callobject_info.state) {
1041 #ifdef SINGLE_CALL_END
1042 if (_vc_core_cm_get_call_member_count(&pcall_agent->call_manager) == 1) {
1043 CALL_ENG_DEBUG(ENG_DEBUG, "End Single call..");
1045 /* Use ReleaseAll api in case single call is ended - this is caused by modem limitation */
1046 tapi_err = tel_release_call_all(&pReqId);
1050 /*Releases the call identified by Call Handle irrespective of call is hold or active state */
1051 tapi_err = tel_release_call(call_handle, &pReqId);
1054 if (TAPI_API_SUCCESS != tapi_err) {
1055 CALL_ENG_DEBUG(ENG_DEBUG, "tapi_call_release Failed Call Handle: %d, Error Code: %d", call_handle, tapi_err);
1059 _vc_core_cm_change_call_state(&callobject_info, VC_CALL_STATE_RELEASE_WAIT);
1060 _vc_core_cm_set_call_object(&pcall_agent->call_manager, &callobject_info);
1068 * This function ends a call
1070 * @return Returns TRUE on success and FALSE on failure
1071 * @param[in] pcall_agent Pointer to the call agent state
1073 gboolean _vc_core_tapi_rqst_end_call(call_vc_callagent_state_t *pcall_agent)
1075 gboolean ret_val = FALSE;
1077 VOICECALL_RETURN_FALSE_IF_FAIL(pcall_agent != NULL);
1079 CALL_ENG_DEBUG(ENG_DEBUG, "..");
1081 switch (pcall_agent->callagent_state) {
1082 case CALL_VC_CA_STATE_NORMAL:
1083 case CALL_VC_CA_STATE_WAIT_HOLD:
1084 case CALL_VC_CA_STATE_WAIT_UNHOLD:
1087 if (_vc_core_cm_isexists_active_call(&pcall_agent->call_manager)) {
1088 ret_val = _vc_core_tapi_rqst_release_active_calls(pcall_agent);
1089 if (TRUE == ret_val) {
1090 _vc_core_ca_change_agent_state(pcall_agent, CALL_VC_CA_STATE_WAIT_RELEASE_ALL_ACTIVECALL);
1092 } else if (_vc_core_cm_isexists_held_call(&pcall_agent->call_manager)) {
1093 ret_val = _vc_core_tapi_rqst_release_held_calls(pcall_agent);
1094 if (TRUE == ret_val) {
1095 _vc_core_ca_change_agent_state(pcall_agent, CALL_VC_CA_STATE_WAIT_RELEASE_ALL_HOLDCALL);
1098 _vc_core_cm_clear_endcall_member(&pcall_agent->call_manager);
1103 CALL_ENG_DEBUG(ENG_DEBUG, "No Action defined for current call agent state: %d", pcall_agent->callagent_state);
1111 * This function rejects a mobile terminated call
1113 * @return Returns TRUE on success and FALSE on failure
1114 * @param[in] pcall_agent Pointer to the call agent state
1115 * @param[in] budub TRUE - User Determined User Busy, FALSE - otherwise
1116 * @param[out] error_code Error code
1118 gboolean _vc_core_tapi_rqst_reject_mt_call(call_vc_callagent_state_t *pcall_agent, gboolean budub, int *error_code)
1120 call_vc_handle call_handle = VC_TAPI_INVALID_CALLHANDLE;
1121 TapiResult_t tapi_err = TAPI_API_SUCCESS;
1122 int pReqId = VC_RQSTID_DEFAULT;
1124 VOICECALL_RETURN_FALSE_IF_FAIL(pcall_agent != NULL);
1126 CALL_ENG_DEBUG(ENG_DEBUG, "budub = %d", budub);
1127 if (_vc_core_cm_isexists_incoming_call(&pcall_agent->call_manager) == FALSE) {
1128 CALL_ENG_DEBUG(ENG_DEBUG, "Incoming call does not exist");
1129 *error_code = ERROR_VOICECALL_NO_INCOMING_CALL_EXIST;
1133 if (pcall_agent->io_state == VC_INOUT_STATE_INCOME_WAIT_RELEASE) {
1134 CALL_ENG_DEBUG(ENG_DEBUG, " io_state is already VC_INOUT_STATE_INCOME_WAIT_RELEASE");
1135 /*return TRUE since call release has been already done and it is waiting for the release*/
1139 if (pcall_agent->io_state == VC_INOUT_STATE_NONE) {
1140 CALL_ENG_DEBUG(ENG_DEBUG, "return FALSE io_state=%d", pcall_agent->io_state);
1141 *error_code = ERROR_VOICECALL_ENGINE_STATE_NONE;
1145 call_handle = _vc_core_cm_get_incoming_call_handle(&pcall_agent->call_manager);
1147 if (TRUE == budub) {
1148 /*Reject the Call for User Busy Scenario */
1149 tapi_err = tel_answer_call(call_handle, TAPI_CALL_ANSWER_REJECT, &pReqId);
1151 if (TAPI_API_SUCCESS != tapi_err) {
1152 CALL_ENG_DEBUG(ENG_DEBUG, " tel_answer_call failed: %d", tapi_err);
1153 _vc_core_ca_change_inout_state(pcall_agent, VC_INOUT_STATE_NONE);
1154 *error_code = ERROR_VOICECALL_TAPI_ERROR;
1158 /*Release the call to end it normally */
1159 if (FALSE == _vc_core_tapi_rqst_release_incoming_call(pcall_agent)) {
1160 CALL_ENG_DEBUG(ENG_ERR, "Release Incoming Call Failed");
1161 _vc_core_ca_change_inout_state(pcall_agent, VC_INOUT_STATE_NONE);
1162 *error_code = ERROR_VOICECALL_TAPI_ERROR;
1167 _vc_core_ca_change_inout_state(pcall_agent, VC_INOUT_STATE_INCOME_WAIT_RELEASE);