da160a7170a431a349a9ce4c5bf2e2399733007e
[apps/home/call.git] / call-engine / voice-call-core.c
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
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
7  *
8  * http://www.tizenopensource.org/license
9  *
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.
15  */
16
17
18 #include "vc-core-util.h"
19 #include "vc-core-engine-types.h"
20 #include "vc-core-callagent.h"
21 #include "vc-core-engine.h"
22 #include "vc-core-error.h"
23 #include "voice-call-core.h"
24 #include "voice-call-dbus.h"
25 #include "voice-call-engine-msg.h"
26 #include "voice-call-service.h"
27
28 #include "voice-call-bt.h"
29 #include "vc-core-engine.h"
30
31 #include "voice-call-engine.h"
32
33 #define MO_REDIAL_COUNT_MAX 10
34 #define MO_REDIAL_TIMER_INTERVAL_FIRST  3000    /**< MO Redial Timer Interva; - 5 Secs*/
35 #define MO_REDIAL_TIMER_INTERVAL_SECOND         3000    /**< MO Redial Timer Interva; - 1 Minute*/
36 #define MO_REDIAL_TIMER_INTERVAL_THIRD  3000    /**< MO Redial Timer Interva; - 3 Minutes*/
37
38 #define MINUTE_MINDER_TIMEOUT_VALUE     60000
39
40 #define DTMF_PAUSE_TIMER_INTERVAL_FIRST         3000    /*3 Seconds */
41 #define DTMF_PAUSE_TIMER_INTERVAL_REST                  3000    /*3 Seconds */
42 #define DTMF_PAUSE_TIMER_INTERVAL_GCF_FIRST     800     /*0.8 Second */
43 #define DTMF_PAUSE_TIMER_INTERVAL_GCF_REST              3300    /*3 Seconds */
44
45 gboolean mo_redial_timer_cb(void *data);
46
47 #define SET_PATH_TIMER_VALUE    50
48 static  guint g_set_path_timer_handler = 0;
49 static gboolean __voicecall_core_set_path_timer_cb(gpointer puser_data);
50
51 /* For Debug Information, Call Engine Event name string constant */
52 char *gszcall_engine_event[VC_ENGINE_EVENT_MAX] = {
53         "VC_CALL_INCOM",
54         "VC_CALL_OUTGOING",
55         "VC_CALL_OUTGOING_ORIG",
56         "VC_CALL_OUTGOING_ALERT",
57         "VC_CALL_CONNECTED",
58         "VC_CALL_NORMAL_END",
59         "VC_CALL_INCOM_END",
60         "VC_CALL_INCOM_DROPPED",
61         "VC_CALL_REJECTED_END",
62         "VC_CALL_OUTGOING_END",         /* 10 */
63
64         "VC_CALL_OUTGOING_ABORTED",
65         "VC_CALL_DTMF_ACK",
66         "VC_CALL_AUTO_REDIAL_CHECK",
67         "VC_CALL_ANSWER_CNF",
68         "VC_CALL_SS_HELD",
69         "VC_CALL_SS_RETREIVED",
70         "VC_CALL_SS_SWAP",
71         "VC_CALL_SS_SETUP_CONF",
72         "VC_CALL_SS_SPLIT_CONF",
73         "VC_CALL_SS_TRANSFERRED",       /* 20 */
74
75         "VC_CALL_SS_CONNECT_LINE_IND",
76         "VC_CALL_IND_FORWARD",
77         "VC_CALL_IND_ACTIVATE",
78         "VC_CALL_IND_HOLD",
79         "VC_CALL_IND_TRANSFER",
80         "VC_CALL_IND_SETUPCONFERENCE",
81         "VC_CALL_IND_BARRING",
82         "VC_CALL_IND_WAITING",
83         "VC_CALL_IND_CUGINFO",
84         "VC_CALL_IND_SSNOTIFY", /* 30 */
85
86         "VC_CALL_IND_CALLINGNAMEINFO",
87         "VC_CALL_IND_REDIRECT_CNF",
88         "VC_CALL_IND_ACTIVATECCBS_CNF",
89         "VC_CALL_IND_ACTIVATECCBS_USERINFO",
90         "VC_CALL_IND_AOC",
91         "VC_ERROR_OCCURED",
92         "VC_ACTION_INCOM_FORCE",
93         "VC_ACTION_SAT_REQUEST",
94         "VC_ACTION_SAT_RESPONSE",
95         "VC_ACTION_CALL_END_HELD_RETREIVED",    /* 40 */
96
97         "VC_ACTION_NO_ACTIVE_TASK",
98         "VC_CALL_GET_VOLUME_RESP"
99 };
100
101 static void __voicecall_core_check_headset_earjack_status(call_vc_core_state_t *pcall_core);
102 static void __vc_core_set_auto_redial_count(call_vc_core_state_t *pcall_core, int auto_redial_count);
103 static gboolean __voicecall_core_callstatus_set_timer_cb(gpointer puser_data);
104
105 static int __voicecall_core_get_string_id_by_errorcode(int error_code);
106 static void __voicecall_core_mocall_reset_engine_state(voicecall_engine_t *pcall_engine);
107 static gboolean __voicecall_core_is_redial_cuase(int end_cause);
108
109 #ifdef  PDIAL_SEND_DTMF
110 static gboolean __voicecall_core_queue_dtmf_string(call_vc_core_state_t *pcall_core, char *dtmf_string, gboolean bsat_dtmf);
111 static gboolean __voicecall_core_handle_dtmf_ack(call_vc_core_state_t *pcall_core, gboolean success);
112 #endif
113
114 /**
115  * This function puts the currently active call on hold
116  *
117  * @return              Returns TRUE on success or FALSE on failure
118  * @param[in]           pcall_engine            Handle to voicecall engine
119  */
120 inline gboolean voicecall_core_hold_call(voicecall_engine_t *pcall_engine)
121 {
122
123         voicecall_error_t error_code = ERROR_VOICECALL_NONE;
124
125         PRINT_CURRENT_TIME("Call Hold Start at");
126         error_code = _vc_core_engine_hold_call(pcall_engine);
127
128         CALL_ENG_DEBUG(ENG_DEBUG, "Error Code : %d", error_code);
129         return (ERROR_VOICECALL_NONE == error_code || ERROR_VOICECALL_PREVIOUS_REQUEST_IN_PROGRESS == error_code) ? TRUE : FALSE;
130 }
131
132 /**
133  * This function retreives the currently held call
134  *
135  * @return              Returns TRUE on success or FALSE on failure
136  * @param[in]           pcall_engine            Handle to voicecall engine
137  */
138 inline gboolean voicecall_core_retrieve_call(voicecall_engine_t *pcall_engine)
139 {
140         voicecall_error_t error_code = ERROR_VOICECALL_NONE;
141
142         PRINT_CURRENT_TIME("Call Retrieve Start at");
143         error_code = _vc_core_engine_retrieve_call(pcall_engine);
144
145         CALL_ENG_DEBUG(ENG_DEBUG, "Error Code : %d", error_code);
146         return (ERROR_VOICECALL_NONE == error_code || ERROR_VOICECALL_PREVIOUS_REQUEST_IN_PROGRESS == error_code) ? TRUE : FALSE;
147 }
148
149 /**
150  * This function swaps the currently available active and held calls
151  *
152  * @return              Returns TRUE on success or FALSE on failure
153  * @param[in]           pcall_engine            Handle to voicecall engine
154  */
155 inline gboolean voicecall_core_swap_calls(voicecall_engine_t *pcall_engine)
156 {
157         voicecall_error_t error_code = ERROR_VOICECALL_NONE;
158
159         PRINT_CURRENT_TIME("Call Swap Start at");
160         error_code = _vc_core_engine_swap_calls(pcall_engine);
161
162         CALL_ENG_DEBUG(ENG_DEBUG, "Error Code : %d", error_code);
163         return (ERROR_VOICECALL_NONE == error_code || ERROR_VOICECALL_PREVIOUS_REQUEST_IN_PROGRESS == error_code) ? TRUE : FALSE;
164 }
165
166 /**
167  * This function clears the MO Call Details
168  *
169  * @return              Returns TRUE on success or FALSE on failure
170  * @param[in]           pcall_engine            Handle to voicecall engine
171  */
172 inline gboolean voicecall_core_clear_mo_call(voicecall_engine_t *pcall_engine)
173 {
174         return (ERROR_VOICECALL_NONE == _vc_core_engine_finalize_call(pcall_engine, VC_OUTGOING_CALL, -1)) ? TRUE : FALSE;
175 }
176
177 /**
178  * This function clears the Connected Call Details
179  *
180  * @return              Returns TRUE on success or FALSE on failure
181  * @param[in]           pcall_engine            Handle to voicecall engine
182  * @param[in]           call_handle             Handle of the Connected Call to be cleared
183  */
184 inline gboolean voicecall_core_clear_connected_call(voicecall_engine_t *pcall_engine, int call_handle)
185 {
186         return (ERROR_VOICECALL_NONE == _vc_core_engine_finalize_call(pcall_engine, VC_CONNECTED_CALL, call_handle)) ? TRUE : FALSE;
187 }
188
189 /**
190  * This function changes the voicecall engine's state
191  *
192  * @return              Returns TRUE on success or FALSE on failure
193  * @param[in]           pcall_engine            Handle to voicecall engine
194  * @param[in]           eng_state               Engine State to be changed
195  */
196 inline gboolean voicecall_core_change_engine_state(voicecall_engine_t *pcall_engine, int eng_state)
197 {
198         return (ERROR_VOICECALL_NONE == _vc_core_engine_change_engine_iostate(pcall_engine, eng_state)) ? TRUE : FALSE;
199 }
200
201 /**
202  * This function ends an Outgoing Call
203  *
204  * @return              Returns TRUE on success or FALSE on failure
205  * @param[in]           pcall_engine            Handle to voicecall engine
206  */
207 inline gboolean voicecall_core_end_mo_call(voicecall_engine_t *pcall_engine)
208 {
209         return (ERROR_VOICECALL_NONE == _vc_core_engine_end_call(pcall_engine, VC_END_OUTGOING_CALL)) ? TRUE : FALSE;
210 }
211
212 /**
213  * This function retreives the Voicecall Engine's State
214  *
215  * @return              Returns TRUE on success or FALSE on failure
216  * @param[in]           pcall_engine            Handle to voicecall engine
217  * @param[out]  io_state                        Voicecall Engine InOut State
218  */
219 inline gboolean voicecall_core_get_engine_state(voicecall_engine_t *pcall_engine, int *eng_state)
220 {
221         return (ERROR_VOICECALL_NONE == _vc_core_engine_status_get_engine_iostate(pcall_engine, eng_state)) ? TRUE : FALSE;
222 }
223
224 /**
225  * This function checks whether any call exists
226  *
227  * @return              Returns TRUE on success or FALSE on failure
228  * @param[in]           pcall_engine            Handle to voicecall engine
229  * @param[out]  active_calls            TRUE - If active call exists or FALSE If active call doesn't exists
230  * @param[out]  held_calls              TRUE - If held call exists or FALSE If held call doesn't exists
231  */
232 inline gboolean voicecall_core_is_call_exists(voicecall_engine_t *pcall_engine, gboolean * active_calls, gboolean * held_calls)
233 {
234         return (ERROR_VOICECALL_NONE == _vc_core_engine_status_isexists_any_call(pcall_engine, active_calls, held_calls)) ? TRUE : FALSE;
235 }
236
237 /**
238  * This function checks whether incoming call exists or not
239  *
240  * @return              Returns TRUE if incoming call exists or FALSE on failure
241  * @param[in]           pcall_engine            Handle to voicecall engine
242  */
243 inline gboolean voicecall_core_is_incoming_call_exists(voicecall_engine_t *pcall_engine)
244 {
245         gboolean bmtcall_exists = FALSE;
246
247         _vc_core_engine_status_isexists_call_bytype(pcall_engine, VC_INCOMING_CALL, &bmtcall_exists);
248         return bmtcall_exists;
249 }
250
251 /**
252  * This function checks whether outgoing call exists or not
253  *
254  * @return              Returns TRUE if outgoing call exists or FALSE on failure
255  * @param[in]           pcall_engine            Handle to voicecall engine
256  */
257 inline gboolean voicecall_core_is_outgoing_call_exists(voicecall_engine_t *pcall_engine)
258 {
259         gboolean bmocall_exists = FALSE;
260
261         _vc_core_engine_status_isexists_call_bytype(pcall_engine, VC_OUTGOING_CALL, &bmocall_exists);
262         return bmocall_exists;
263 }
264
265 /**
266  * This function checks whether any connexcted call exists or not
267  *
268  * @return              Returns TRUE if connected call exists or FALSE on failure
269  * @param[in]           pcall_engine            Handle to voicecall engine
270  */
271 inline gboolean voicecall_core_is_connected_call_exist(voicecall_engine_t *pcall_engine)
272 {
273         gboolean bcall_exists = FALSE;
274
275         _vc_core_engine_status_isexists_call_bytype(pcall_engine, VC_CONNECTED_CALL, &bcall_exists);
276         return bcall_exists;
277 }
278
279 /**
280  * This function checks whether any connexcted call exists or not in the given group
281  *
282  * @return              Returns TRUE if connected call exists or FALSE on failure
283  * @param[in]           pcall_engine            Handle to voicecall engine
284  * @param[in]           group_index             Group Index to be searhced
285  */
286 inline gboolean voicecall_core_is_connected_call_exist_in_group(voicecall_engine_t *pcall_engine, int group_index)
287 {
288         gboolean bcall_exists = FALSE;
289         voicecall_error_t error_code = ERROR_VOICECALL_NONE;
290
291         if (ERROR_VOICECALL_NONE != _vc_core_engine_group_isexists_connected_call_ingroup(pcall_engine, group_index, &bcall_exists)) {
292                 CALL_ENG_DEBUG(ENG_DEBUG, "Error_code %d", error_code);
293
294         }
295
296         return bcall_exists;
297 }
298
299 /**
300  * This function checks whether any call exists
301  *
302  * @return              Returns TRUE if connected call exists or FALSE on failure
303  * @param[in]           pcall_engine            Handle to voicecall engine
304  */
305 inline gboolean voicecall_core_is_any_call_exists(voicecall_engine_t *pcall_engine)
306 {
307         gboolean bcall_exists = FALSE;
308
309         _vc_core_engine_status_isexists_call_bytype(pcall_engine, VC_INCOMING_CALL, &bcall_exists);
310         CALL_ENG_DEBUG(ENG_DEBUG, "Incoming Call = [%d]", bcall_exists);
311
312         if (FALSE == bcall_exists) {
313                 _vc_core_engine_status_isexists_call_bytype(pcall_engine, VC_OUTGOING_CALL, &bcall_exists);
314         }
315         CALL_ENG_DEBUG(ENG_DEBUG, "Outgoing Call = [%d]", bcall_exists);
316
317         if (FALSE == bcall_exists) {
318                 _vc_core_engine_status_isexists_call_bytype(pcall_engine, VC_CONNECTED_CALL, &bcall_exists);
319         }
320         CALL_ENG_DEBUG(ENG_DEBUG, "Connected Call = [%d]", bcall_exists);
321
322         return bcall_exists;
323 }
324
325 /**
326  * This function retreives the totally number of availavle calls including connected, MO and MT Calls
327  *
328  * @return              Returns TRUE if success or FALSE on failure
329  * @param[in]           pcall_engine            Handle to voicecall engine
330  * @param[out]  ptotal_call_member      number of avialble calls
331  */
332 inline gboolean voicecall_core_get_total_call_member(voicecall_engine_t *pcall_engine, int *ptotal_call_member)
333 {
334         return (ERROR_VOICECALL_NONE == _vc_core_engine_status_get_call_member_count(pcall_engine, ptotal_call_member)) ? TRUE : FALSE;
335 }
336
337 /**
338  * This function checks whether voicecall engine's call agent is idle or not
339  *
340  * @return              Returns TRUE if call agent is idle or FALSE on failure
341  * @param[in]           pcall_engine            Handle to voicecall engine
342  */
343 inline gboolean voicecall_core_is_callagent_idle(voicecall_engine_t *pcall_engine)
344 {
345         gboolean bcallagent_idle = FALSE;
346
347         _vc_core_engine_status_is_engine_busy(pcall_engine, &bcallagent_idle);
348         CALL_ENG_DEBUG(ENG_DEBUG, "Call Agent Busy State : %d", bcallagent_idle);
349
350         return !bcallagent_idle;
351 }
352
353 /**
354 * This function checks the current call status and engine status
355 *
356 * @return               TRUE, if connected calls available and engine is in idle, FALSE otherwise
357  * @param[in]           pcall_engine            Handle to voicecall engine
358 */
359 inline gboolean voicecall_core_is_incall_request_possible(voicecall_engine_t *pcall_engine)
360 {
361         int eng_state = VC_INOUT_STATE_NONE;
362         int member_num_0 = 0;
363         int member_num_1 = 0;
364
365         _vc_core_engine_group_get_connected_member_count(pcall_engine, 0, &member_num_0);
366         _vc_core_engine_group_get_connected_member_count(pcall_engine, 1, &member_num_1);
367         voicecall_core_get_engine_state(pcall_engine, &eng_state);
368         if (!(voicecall_core_is_callagent_idle(pcall_engine) && ((member_num_1 + member_num_0) > 0)
369               && (eng_state == VC_INOUT_STATE_NONE))) {
370                 CALL_ENG_DEBUG(ENG_DEBUG, "Engine Busy, Cannot complete Request,mem_0:%d,mem_1:%d,eng_state:%d ", member_num_0, member_num_1, eng_state);
371                 return FALSE;
372         }
373
374         return TRUE;
375 }
376
377 /**
378  * This function changes the modem call audio path
379  *
380  * @return              TRUE sucess, FALSE otherwise
381  * @param[in]           pcall_engine            Handle to voicecall engine
382  * @param[in]           audio_path              audio path to be changed
383  */
384 inline gboolean voicecall_core_change_audio_path(voicecall_engine_t *pcall_engine, voicecall_audio_path_t audio_path)
385 {
386         return (ERROR_VOICECALL_NONE == _vc_core_engine_change_audio_path(pcall_engine, audio_path)) ? TRUE : FALSE;
387 }
388
389 /**
390  * This function sets the voice call audio volume for the given audio path type
391  *
392  * @return              returns TRUE in success , FALSE otherwise
393  * @param[in]           pcall_engine            Handle to voicecall engine
394  * @param[in]           tapi_snd_path           audio path for the volume to be set
395  * @param[in]           vol_level                       volume level
396  */
397 inline gboolean voicecall_core_set_audio_volume(voicecall_engine_t *pcall_engine, voicecall_audio_path_t tapi_snd_path, int vol_level)
398 {
399         return (ERROR_VOICECALL_NONE == _vc_core_engine_set_audio_volume(pcall_engine, tapi_snd_path, (voicecall_audio_volume_t) vol_level)) ? TRUE : FALSE;
400 }
401
402 /**
403  * This function retreives the voice call audio volume for the given audio path type
404  *
405  * @return              returns TRUE in success , FALSE otherwise
406  * @param[in]           pcall_engine                    Handle to voicecall engine
407  * @param[in]           audio_path_type         audio path for the volume to be retreived
408  */
409 inline gboolean voicecall_core_get_audio_volume(voicecall_engine_t *pcall_engine, voicecall_audio_path_t audio_path_type)
410 {
411         return (ERROR_VOICECALL_NONE == _vc_core_engine_get_audio_volume(pcall_engine, audio_path_type)) ? TRUE : FALSE;
412 }
413
414 /**
415  * This function set the voice call audio mute status
416  *
417  * @return              returns TRUE in success , FALSE otherwise
418  * @param[in]           pcall_engine                    Handle to voicecall engine
419  * @param[in]           bvoice_mute                     mute status
420  */
421 inline gboolean voicecall_core_set_audio_mute_status(voicecall_engine_t *pcall_engine, gboolean bvoice_mute)
422 {
423         return (ERROR_VOICECALL_NONE == _vc_core_engine_set_audio_mute(pcall_engine, bvoice_mute)) ? TRUE : FALSE;
424 }
425
426 /**
427  * This function retreives the first active call among the available active calls
428  *
429  * @return              Returns TRUE if success or FALSE on failure
430  * @param[in]           pcall_engine                    Handle to voicecall engine
431  * @param[out]  pcall_handle            call handle of the active call
432  */
433 inline gboolean voicecall_core_get_zuhause(voicecall_engine_t *pcall_engine, gboolean * bzuhause)
434 {
435         return (ERROR_VOICECALL_NONE == _vc_core_engine_status_is_zuhause_area(pcall_engine, bzuhause)) ? TRUE : FALSE;
436 }
437
438 /**
439  * This function retreives the Voicecall Engine's State
440  *
441  * @return              Returns TRUE on success or FALSE on failure
442  * @param[in]   pcall_engine    Handle to voicecall engine
443  * @param[in]   call_handle     Call handle of the call for which the call object is retrieved
444  * @param[out]  pcall_object    Pointer to the retrived call object info
445  */
446 inline gboolean voicecall_core_get_call_object(voicecall_engine_t *pcall_engine, int call_handle, call_vc_call_objectinfo_t * pcall_object)
447 {
448         return (ERROR_VOICECALL_NONE == _vc_core_engine_status_get_call_object(pcall_engine, call_handle, pcall_object)) ? TRUE : FALSE;
449 }
450
451 /**
452  * This function sends response to sat engine
453  *
454  * @return              Returns TRUE If transfer call can be made or FALSE if not
455  * @param[in]   pcall_engine    Handle to voicecall engine
456  * @param[in]           sat_rqst_resp_type sat rqst/resp type to be set by the client
457  * @param[in]           sat_response_type sat response type to be sent to sat
458  */
459 inline gboolean voicecall_core_send_sat_response(voicecall_engine_t *pcall_engine, voicecall_engine_sat_rqst_resp_type sat_rqst_resp_type, call_vc_sat_reponse_type_t sat_response_type)
460 {
461         voicecall_error_t error_code = 0;
462         error_code = _vc_core_engine_send_sat_response(pcall_engine, sat_rqst_resp_type, sat_response_type);
463         CALL_ENG_DEBUG(ENG_DEBUG, "error_code:[%d] ", error_code);
464         return (ERROR_VOICECALL_NONE == error_code) ? TRUE : FALSE;
465 }
466
467 /**
468  * This function retreives the number of active call members
469  *
470  * @return              Returns TRUE if success or FALSE on failure
471  * @param[in]           pcall_core              Handle to voicecall core
472  * @param[out]  pactive_member_num      number of active call members available
473  */
474 inline gboolean voicecall_core_get_active_call_member(call_vc_core_state_t *pcall_core, int *pactive_member_num)
475 {
476         *pactive_member_num = 0;
477         return (ERROR_VOICECALL_NONE == _vc_core_engine_status_get_call_member_info(pcall_core->pcall_engine, VC_ACTIVE_CALL, pactive_member_num)) ? TRUE : FALSE;
478 }
479
480 /**
481  * This function checks whether possible to make conference call
482  *
483  * @return              Returns TRUE If Conference call can be made or FALSE if not
484  * @param[in]           papp_document   Handle to Application Document
485  */
486 inline gboolean voicecall_core_is_conf_call_possible(call_vc_core_state_t *pcall_core)
487 {
488         gboolean bconf_call = FALSE;
489
490         _vc_core_engine_status_is_conf_call_possible(pcall_core->pcall_engine, &bconf_call);
491
492         return bconf_call;
493 }
494
495 /**
496  * This function checks whether possible to transfer call
497  *
498  * @return              Returns TRUE If transfer call can be made or FALSE if not
499  * @param[in]           pcall_core              Handle to voicecall core
500  */
501 inline gboolean voicecall_core_is_transfer_call_possible(call_vc_core_state_t *pcall_core)
502 {
503         gboolean btransfer_call = FALSE;
504
505         _vc_core_engine_status_is_transfer_call_possible(pcall_core->pcall_engine, &btransfer_call);
506
507         return btransfer_call;
508 }
509
510 /**
511  * This function checks whether the given code is a valid Supplementary Services Code
512  *
513  * @return              Returns TRUE on success or FALSE on failure
514  * @param[in]           pcall_core              Handle to voicecall core
515  * @param[in]           pszInput                        Number to be verified
516  */
517 inline gboolean voicecall_core_is_valid_sscode(call_vc_core_state_t *pcall_core, const char *pszInput)
518 {
519         gboolean bsscode = FALSE;
520
521         _vc_core_engine_status_isvalid_ss_code(pcall_core->pcall_engine, pszInput, &bsscode);
522
523         return bsscode;
524 }
525
526 #ifdef _CPHS_DEFINED_
527 /**
528  * This function gets the cphs status from the engine
529  *
530  * @return              TRUE if queried status is enabled, FALSE otherwise
531  * @param[in]           pcall_core              Handle to voicecall core
532  * @param[in]           csp_service             csp service to be queried
533  */
534 inline gboolean voicecall_core_get_cphs_csp_status(call_vc_core_state_t *pcall_core, voicecall_cphs_csp_service csp_service)
535 {
536         gboolean bcsp_status = FALSE;
537
538         _vc_core_engine_status_get_cphs_csp_status(pcall_core->pcall_engine, csp_service, &bcsp_status);
539         return bcsp_status;
540 }
541 #endif
542
543 /**
544  * This function informs the Voicecall Engine that current SS operation has been completed
545  *
546  * @return              Returns TRUE if all the calls are ended or FALSE on failure
547  * @param[in]           pcall_core              Handle to voicecall core
548  */
549 inline gboolean voicecall_core_set_check_ss_on_end(call_vc_core_state_t *pcall_core)
550 {
551         return (ERROR_VOICECALL_NONE == _vc_core_engine_status_set_end_flag(pcall_core->pcall_engine, VC_RETREIVE_CALL_ON_MOCALL_END)) ? TRUE : FALSE;
552 }
553
554 /**
555  * This function extracts vaild phone number
556  *
557  * @return              void
558  * @param[in]           
559  */
560 inline void voicecall_core_extract_phone_number(const char *source_tel_number, char *phone_number, const int buf_size)
561 {
562         _vc_core_engine_extract_phone_number(source_tel_number, phone_number, buf_size);
563 }
564
565 /************************
566 *  inline function END
567 **************************/
568 void voicecall_core_set_status(call_vc_core_state_t *pcall_core, call_vc_core_flags_t core_flags, gboolean bstatus)
569 {
570         CALL_ENG_DEBUG(ENG_DEBUG, "core flags:[0x%x], Set status:[%d] ", core_flags, bstatus);
571
572         if (CALL_VC_CORE_FLAG_NONE == core_flags) {
573                 /*Set the document flag to defaults */
574                 pcall_core->core_status = CALL_VC_CORE_FLAG_NONE;
575                 return;
576         }
577
578         if (TRUE == bstatus) {
579                 /*Set Flag */
580                 pcall_core->core_status |= core_flags;
581         } else {
582                 /*Remove bit field only if it is already set/ otherwise ignore it */
583                 if ((pcall_core->core_status & core_flags) == core_flags) {
584                         pcall_core->core_status = (pcall_core->core_status ^ core_flags);
585                 }
586         }
587
588         CALL_ENG_DEBUG(ENG_DEBUG, "After SET, core_status:[0x%x]", pcall_core->core_status);
589
590 }
591
592 gboolean voicecall_core_get_status(call_vc_core_state_t *pcall_core, call_vc_core_flags_t core_flags)
593 {
594         CALL_ENG_DEBUG(ENG_DEBUG, "core_flags:[0x%x]", core_flags);
595         CALL_ENG_DEBUG(ENG_DEBUG, "Before Get, core_status:[0x%x]", pcall_core->core_status);
596
597         if ((pcall_core->core_status & core_flags) == core_flags) {
598                 CALL_ENG_DEBUG(ENG_DEBUG, "Flag [0x%x] is available", core_flags);
599                 return TRUE;
600         }
601
602         CALL_ENG_DEBUG(ENG_DEBUG, "Flag [0x%x] is not available", core_flags);
603         return FALSE;
604 }
605
606 #ifdef VC_ENG_FDN_SUPPORT
607 gboolean voicecall_core_check_fdn_status(call_vc_core_state_t *pcall_core)
608 {
609         gboolean bfdn_enabled = FALSE;
610
611         /*Check the FDN Status of the number with the contact */
612         _vc_core_engine_status_isenabled_fdn(pcall_core->pcall_engine, &bfdn_enabled);
613         voicecall_core_set_status(pcall_core, CALL_VC_CORE_FLAG_FDN_SVC_ENABLED, bfdn_enabled);
614
615         if (TRUE == bfdn_enabled) {
616                 gboolean bct_exists = FALSE;
617
618                 CALL_ENG_DEBUG(ENG_DEBUG, "FDN mode enabled..");
619                 if (!bct_exists) {
620                         vc_engine_msg_box_type event_data;
621                         memset(&event_data, 0, sizeof(event_data));
622
623                         CALL_ENG_DEBUG(ENG_DEBUG, "FDN only...");
624                         _vc_core_engine_finalize_call(pcall_core->pcall_engine, VC_OUTGOING_CALL, -1);
625
626                         event_data.string_id = IDS_CALL_POP_FDNCALLONLY;
627                         vcall_engine_send_event_to_client(VC_ENGINE_MSG_MESSAGE_BOX_TO_UI, (void *)&event_data);
628                         return FALSE;
629                 }
630
631         } else {
632                 CALL_ENG_DEBUG(ENG_DEBUG, "FDN mode disabled..");
633         }
634
635         return TRUE;
636 }
637 #endif
638
639 static gboolean __voicecall_core_minute_minder(gpointer puser_data)
640 {
641         CALL_ENG_DEBUG(ENG_DEBUG, "..");
642         call_vc_core_state_t *pcall_core = (call_vc_core_state_t *)puser_data;
643
644         if ((voicecall_core_is_incoming_call_exists(pcall_core->pcall_engine) == FALSE)
645             && (voicecall_core_is_outgoing_call_exists(pcall_core->pcall_engine) == FALSE)
646             && (voicecall_core_is_connected_call_exist(pcall_core->pcall_engine) == TRUE)) {
647                 voicecall_snd_play_effect_tone(pcall_core->papp_snd, VOICE_CALL_SND_EFFECT_CALL_MINUTE_MINDER);
648         }
649
650         return TRUE;
651 }
652
653 static gboolean __voicecall_core_set_path_timer_cb(gpointer puser_data)
654 {
655         CALL_ENG_DEBUG(ENG_DEBUG, "..");
656         VOICECALL_RETURN_FALSE_IF_FAIL(puser_data != NULL);
657         call_vc_core_state_t *pcall_core = (call_vc_core_state_t *)puser_data;
658
659         voicecall_snd_change_path(pcall_core->papp_snd);
660
661         if (g_set_path_timer_handler > 0) {
662                 g_source_remove(g_set_path_timer_handler);
663                 g_set_path_timer_handler = 0;
664         }
665
666         return FALSE;
667 }
668
669 static gboolean __voicecall_core_handle_call_end_on_silent_reject(call_vc_core_state_t *pcall_core, int call_handle)
670 {
671         CALL_ENG_DEBUG(ENG_DEBUG, "call_handle = %d", call_handle);
672
673         if ((pcall_core->mtcall_silent_reject_handle == call_handle)) {
674                 if (FALSE == voicecall_core_is_connected_call_exist(pcall_core->pcall_engine)) {
675                         /*Connected calls need to be checked, Connected emergency calls may be avaialble */
676                         voicecall_snd_change_mm_path(pcall_core->papp_snd, VOICE_CALL_MM_RESET);
677                         voicecall_core_set_to_default(pcall_core);
678                 } else {
679                         CALL_ENG_DEBUG(ENG_ERR, "Connected calls available");
680                         _vc_core_engine_status_dump_call_details(pcall_core->pcall_engine);
681                 }
682                 pcall_core->mtcall_silent_reject_handle = -1;
683                 return TRUE;
684         }
685
686         return FALSE;
687 }
688
689 static gboolean __voicecall_core_silent_reject_mt(call_vc_core_state_t *pcall_core, int call_handle)
690 {
691         CALL_ENG_DEBUG(ENG_DEBUG, "call_handle = %d", call_handle);
692
693         voicecall_error_t error_code = ERROR_VOICECALL_NONE;
694
695         pcall_core->mtcall_silent_reject_handle = call_handle;
696
697         /*Reject the call */
698         error_code = _vc_core_engine_reject_call(pcall_core->pcall_engine, FALSE);
699
700         if (ERROR_VOICECALL_NONE != error_code) {
701                 CALL_ENG_DEBUG(ENG_ERR, "_vc_core_engine_reject_call Failed, error_code = %d", error_code);
702         }
703
704         return TRUE;
705 }
706
707 static void __voicecall_core_processing_mo_cancel(call_vc_core_state_t *pcall_core)
708 {
709         voicecall_engine_t *pcall_engine = pcall_core->pcall_engine;
710         int total_call_member;
711
712         CALL_ENG_DEBUG(ENG_DEBUG, "..");
713
714         if (TRUE == voicecall_snd_is_signal_playing(pcall_core->papp_snd)) {
715                 CALL_ENG_DEBUG(ENG_DEBUG, "Signal is playing, skipping cancel timer");
716                 return;
717         }
718         
719         vc_engine_outgoing_end_type event_data;
720
721         /* normal outgong end */
722         CALL_ENG_DEBUG(ENG_DEBUG, "It is normal outgong end case.");
723         CALL_ENG_DEBUG(ENG_DEBUG, "call_handle:[%d],end_cause_type:[%d]", pcall_core->mo_end_call_handle, pcall_core->mo_end_cause_type);
724
725         memset(&event_data, 0, sizeof(event_data));
726         event_data.call_handle = pcall_core->mo_end_call_handle;
727         event_data.end_cause_type = pcall_core->mo_end_cause_type;
728         vcall_engine_send_event_to_client(VC_ENGINE_MSG_OUTGOING_END_TO_UI, (void *)&event_data);
729
730         _vc_bt_send_response_to_bt(pcall_core, BT_AG_RES_CALL_END, pcall_core->mo_end_call_handle, NULL);
731
732         __vc_core_set_auto_redial_count(pcall_core, 0);
733         voicecall_core_clear_mo_call(pcall_engine);
734
735         __voicecall_core_mocall_reset_engine_state(pcall_engine);
736
737         /* __vcui_app_view_mo_finish_call() start */
738         voicecall_snd_stop_signal(pcall_core->papp_snd);
739
740         voicecall_core_get_total_call_member(pcall_engine, &total_call_member);
741         /* If No Connected Calls End the UI */
742         if (total_call_member == 0) {
743                 /*Reset voice call core to default values */
744                 voicecall_core_set_to_default(pcall_core);
745         } else {
746                 voicecall_snd_change_path(pcall_core->papp_snd);
747         }
748         /* __vcui_app_view_mo_finish_call() end */
749
750 }
751
752 static void __voicecall_core_mocall_signal_play_end_cb(gpointer pdata)
753 {
754         call_vc_core_state_t *pcall_core = (call_vc_core_state_t *)pdata;
755
756         CALL_ENG_DEBUG(ENG_DEBUG, "..");
757
758         if (FALSE == voicecall_core_is_connected_call_exist(pcall_core->pcall_engine)) {
759                 CALL_ENG_DEBUG(ENG_DEBUG, "No More calls, resetting path");
760                 voicecall_snd_change_mm_path(pcall_core->papp_snd, VOICE_CALL_MM_RESET);
761                 _vc_core_util_set_call_status(VCONFKEY_CALL_OFF);
762         }
763
764         if (TRUE == voicecall_core_is_outgoing_call_exists(pcall_core->pcall_engine)) {
765                 CALL_ENG_DEBUG(ENG_DEBUG, "Updating MO UI on signal end");
766                 __voicecall_core_processing_mo_cancel(pcall_core);
767         }
768 }
769
770 static voicecall_snd_signal_type_t __voicecall_core_get_signal_type_from_endcause(int end_cause)
771 {
772         int signal_type = 0;
773
774         CALL_ENG_DEBUG(ENG_DEBUG, "End end_cause_type: %d", end_cause);
775
776         switch (end_cause) {
777         case VC_ENDCAUSE_USER_BUSY:
778         case VC_ENDCAUSE_USER_DOESNOT_RESPOND:
779         case VC_ENDCAUSE_USER_UNAVAILABLE:
780         case VC_ENDCAUSE_NO_ANSWER:
781                 {
782                         signal_type = VOICE_CALL_SIGNAL_USER_BUSY_TONE;
783                 }
784                 break;
785         default:
786                 signal_type = VOICE_CALL_SIGNAL_NONE;
787                 break;
788         }
789
790         CALL_ENG_DEBUG(ENG_DEBUG, "Signal Type: %d", signal_type);
791
792         return signal_type;
793 }
794
795 static void __voicecall_core_handle_normal_end(call_vc_core_state_t *pcall_core, int call_handle, voice_call_end_cause_type_t end_cause)
796 {
797         int total_call_member = 0;
798         voicecall_engine_t *pcall_engine = pcall_core->pcall_engine;
799
800         /*Set the callstatus to OFF before processing the End Event Animation */
801         if (TRUE == voicecall_core_is_connected_call_exist(pcall_engine)) {
802                 _vc_core_util_set_call_status(VCONFKEY_CALL_VOICE_ACTIVE);
803         } else if ((TRUE == voicecall_core_is_incoming_call_exists(pcall_engine)) || (TRUE == voicecall_core_is_outgoing_call_exists(pcall_engine))) {
804                 _vc_core_util_set_call_status(VCONFKEY_CALL_VOICE_CONNECTING);
805         } else {
806                 /*Reset the Path. Actual path must be closed when modem path closed!! */
807                 voicecall_snd_change_mm_path(pcall_core->papp_snd, VOICE_CALL_MM_RESET);
808                 _vc_core_util_set_call_status(VCONFKEY_CALL_OFF);
809         }
810
811         if (FALSE == voicecall_snd_play_effect_tone(pcall_core->papp_snd, VOICE_CALL_SND_EFFECT_CALL_DISCONNECT)) {
812                 CALL_ENG_DEBUG(ENG_DEBUG, "Effect tone not played, check and play busy tone");
813         }
814
815 #ifdef _NEW_SND_
816         if ((FALSE == voicecall_core_is_connected_call_exist(pcall_engine)) 
817         && (TRUE == voicecall_core_is_incoming_call_exists(pcall_engine)) 
818         && (voicecall_snd_get_path_status(pcall_core->papp_snd) == VOICE_CALL_SND_PATH_SPEAKER)) {
819                 CALL_ENG_DEBUG(ENG_DEBUG, "Incoming Call: TRUE,Connected Call:FALSE, Speaker: TRUE. So change path to normal");
820                 voicecall_snd_set_path_status(pcall_core->papp_snd, VOICE_CALL_SND_PATH_RECEIVER);
821                 voicecall_snd_change_path(pcall_core->papp_snd);
822         }
823 #else
824         if ((FALSE == voicecall_core_is_connected_call_exist(pcall_engine)) 
825         && (TRUE == voicecall_core_is_incoming_call_exists(pcall_engine)) 
826         && (TRUE == voicecall_snd_get_status(pcall_core->papp_snd, VOICE_CALL_AUDIO_SPEAKER))) {
827                 CALL_ENG_DEBUG(ENG_DEBUG, "Incoming Call: TRUE,Connected Call:FALSE, Speaker: TRUE. So change path to normal");
828                 voicecall_snd_set_status(pcall_core->papp_snd, VOICE_CALL_AUDIO_SPEAKER, FALSE);
829                 voicecall_snd_change_path(pcall_core->papp_snd);
830         }
831 #endif
832
833         voicecall_core_clear_connected_call(pcall_engine, call_handle);
834
835         voicecall_core_get_total_call_member(pcall_engine, &total_call_member);
836         if (0 == total_call_member) {
837                 voicecall_core_set_to_default(pcall_core);
838         }
839
840 }
841
842 static gboolean __voicecall_core_handle_rejected_call_end(call_vc_core_state_t *pcall_core, int call_handle)
843 {
844         voicecall_engine_t *pcall_engine = pcall_core->pcall_engine;
845
846         voicecall_snd_stop_alert(pcall_core->papp_snd);
847
848         /*Send Incoming call End Event to Blue Tooth */
849         _vc_bt_send_response_to_bt(pcall_core, BT_AG_RES_CALL_END, call_handle, NULL);
850
851         if (FALSE == voicecall_core_is_connected_call_exist(pcall_engine)) {
852                 CALL_ENG_DEBUG(ENG_DEBUG, "No More Calls");
853                 voicecall_core_set_to_default(pcall_core);
854         } else {
855                 CALL_ENG_DEBUG(ENG_DEBUG, "Setting Path for Voicecall");
856                 /*Change Path to Call, when the incomging call is cancelled. */
857                 voicecall_snd_change_path(pcall_core->papp_snd);
858                 _vc_core_util_set_call_status(VCONFKEY_CALL_VOICE_ACTIVE);
859         }
860
861         CALL_ENG_DEBUG(ENG_DEBUG, "Reject Call End Processed");
862         return TRUE;
863 }
864
865 static void __voicecall_core_handle_outgoingcall_end(call_vc_core_state_t *pcall_core, int call_handle, voice_call_end_cause_type_t end_cause_type)
866 {
867         gboolean bsignal_play = FALSE;
868         voicecall_engine_t *pcall_engine = pcall_core->pcall_engine;
869
870         CALL_ENG_DEBUG(ENG_DEBUG, "call_handle=:%d,end_cause=%d", call_handle, end_cause_type);
871         pcall_core->mo_end_call_handle = call_handle;
872         pcall_core->mo_end_cause_type = end_cause_type;
873
874         if (FALSE == voicecall_core_is_connected_call_exist(pcall_engine)) {
875                 voicecall_snd_signal_type_t end_signal_type = VOICE_CALL_SIGNAL_NONE;
876                 /*Play Signal Tone only when the connected calls are not exists */
877                 end_signal_type = __voicecall_core_get_signal_type_from_endcause(end_cause_type);
878
879                 if (end_signal_type != VOICE_CALL_SIGNAL_NONE) {
880                         voicecall_snd_set_signal_type(pcall_core->papp_snd, end_signal_type);
881                         voicecall_snd_play_signal(pcall_core->papp_snd, __voicecall_core_mocall_signal_play_end_cb, pcall_core);
882                         bsignal_play = TRUE;
883
884                         /* signal tone play case : just end string updated */
885                         {
886                                 vc_engine_outgoing_end_signal_play_type event_data;
887
888                                 /* normal outgong end */
889                                 CALL_ENG_DEBUG(ENG_DEBUG, "It is normal outgong end case.");
890                                 CALL_ENG_DEBUG(ENG_DEBUG, "call_handle:[%d],end_cause_type:[%d]", call_handle, pcall_core->mo_end_cause_type);
891
892                                 memset(&event_data, 0, sizeof(event_data));
893                                 event_data.call_handle = call_handle;
894                                 event_data.end_cause_type = pcall_core->mo_end_cause_type;
895                                 vcall_engine_send_event_to_client(VC_ENGINE_MSG_OUTGOING_END_SIGNAL_PLAY_TO_UI, (void *)&event_data);
896                         }
897
898                 }
899         } else {
900                 CALL_ENG_DEBUG(ENG_DEBUG, "Connected call exists, not playing signal tone");
901         }
902         if (TRUE == voicecall_core_is_connected_call_exist(pcall_engine)) {
903                 /* Set phonestatus value */
904                 _vc_core_util_set_call_status(VCONFKEY_CALL_VOICE_ACTIVE);
905         } else if (FALSE == bsignal_play) {
906                 /*Reset the Path. Actual path must be closed when modem path closed!! */
907                 voicecall_snd_change_mm_path(pcall_core->papp_snd, VOICE_CALL_MM_RESET);
908                 _vc_core_util_set_call_status(VCONFKEY_CALL_OFF);
909         } else {
910                 /* othing to do. */
911         }
912         __voicecall_core_processing_mo_cancel(pcall_core);
913
914 }
915
916 static gboolean __voicecall_core_handle_incoming_call_end(call_vc_core_state_t *pcall_core, int call_handle)
917 {
918         voicecall_engine_t *pcall_engine = pcall_core->pcall_engine;
919
920         voicecall_snd_stop_alert(pcall_core->papp_snd);
921
922         /*Send Incoming call End Event to Blue Tooth */
923         _vc_bt_send_response_to_bt(pcall_core, BT_AG_RES_CALL_END, call_handle, NULL);
924
925         if (FALSE == voicecall_core_is_connected_call_exist(pcall_engine)) {
926                 CALL_ENG_DEBUG(ENG_DEBUG, "No More Calls");
927                 voicecall_core_set_to_default(pcall_core);
928         } else {
929                 CALL_ENG_DEBUG(ENG_DEBUG, "Setting Path for Voicecall");
930                 /*Change Path to Call, when the incomging call is cancelled. */
931                 voicecall_snd_change_path(pcall_core->papp_snd);
932                 _vc_core_util_set_call_status(VCONFKEY_CALL_VOICE_ACTIVE);
933         }
934
935         CALL_ENG_DEBUG(ENG_DEBUG, "Incoming Call End Processed");
936         return TRUE;
937 }
938
939 static gboolean voicecall_core_cb(int event, int param1, int param2, void *param3, void *puser_data)
940 {
941         CALL_ENG_DEBUG(ENG_WARN, " Engine Event: %s(%d)", gszcall_engine_event[event], event);
942
943         call_vc_core_state_t *pcall_core = (call_vc_core_state_t *)puser_data;
944         voicecall_engine_t *pcall_engine = pcall_core->pcall_engine;
945
946         CALL_VC_DUMP_CALLDETAILS(&pcall_engine->call_manager);
947
948         switch (event) {
949         case VC_CALL_INCOM:
950                 {
951                         int call_handle = param1;
952                         char tel_number[VC_PHONE_NUMBER_LENGTH_MAX];
953                         gboolean bauto_reject = FALSE;
954                         gboolean bauto_reject_unknown = FALSE;
955                         gboolean restricted = FALSE;
956                         gboolean bcalling_namemode = FALSE;
957                         gboolean brejected_number = FALSE;
958                         vc_engine_incoming_type event_data;
959
960                         memset(&event_data, 0, sizeof(event_data));
961
962                         CALL_ENG_DEBUG(ENG_DEBUG, "tel_number:[%s]", (char *)param3);
963                         _vc_core_util_strcpy(tel_number, sizeof(tel_number), (char *)param3);
964
965 #ifdef _NEW_SND_
966 #else
967                         __voicecall_core_check_headset_earjack_status(pcall_core);
968 #endif
969
970                         /*Changing the path to headset/phone will be decided by user accept action.
971                            This will apply for second incoming call, if the first call was accpeted by BT Headset
972                            and the path was changed to BT headset, then the path will be in headset for second call by default
973                            So reset the headset flag for second call so the path will not
974                            be automatically changed to headset, it will be decided by user action.
975                            If this requirement fits only for first incoming call then comment this fix. */
976                         /* vcui_app_snd_set_status(papp_document->papp_snd, VCUI_APP_AUDIO_HEADSET, FALSE); */
977
978                         /*Will be set based on user action */
979                         voicecall_core_set_status(pcall_core, CALL_VC_CORE_FLAG_ACCEPT_BY_BT, FALSE);
980
981                         if (_vc_core_util_check_video_call_status() == TRUE) {
982                                 if (TRUE == __voicecall_core_silent_reject_mt(pcall_core, call_handle)) {
983                                         CALL_ENG_DEBUG(ENG_DEBUG, "Call rejected due to silent reject");
984                                         return TRUE;
985                                 }
986                         }
987
988                         /* Check for Restricted Mode */
989                         _vc_core_engine_status_isrestricted_call(pcall_engine, call_handle, &restricted);
990                         _vc_core_engine_status_get_calling_namemode(pcall_engine, call_handle, &bcalling_namemode);
991                         if (TRUE == bcalling_namemode) {
992                                 call_vc_call_objectinfo_t call_object;
993
994                                 voicecall_core_get_call_object(pcall_engine, call_handle, &call_object);
995                                 CALL_ENG_DEBUG(ENG_DEBUG, "call_object.calling_name:[%s]", call_object.calling_name);
996
997                                 _vc_core_util_strcpy(event_data.call_name, sizeof(event_data.call_name), call_object.calling_name);
998                         } else if (TRUE == restricted) {
999                                 call_vc_call_objectinfo_t call_object;
1000
1001                                 voicecall_core_get_call_object(pcall_engine, call_handle, &call_object);
1002                                 CALL_ENG_DEBUG(ENG_DEBUG, "call_object.name_mode:[%s]", call_object.name_mode);
1003
1004                                 event_data.brestricted = TRUE;
1005                                 if (call_object.name_mode == CALL_VC_NAME_MODE_PAYPHONE) {
1006                                         event_data.bpayphone = TRUE;
1007                                 } else {
1008                                         event_data.bpayphone = FALSE;
1009
1010                                 }
1011                                 event_data.contact_index = -1;
1012                                 event_data.phone_type = -1;
1013                         }
1014
1015                         /* send to ui */
1016                         event_data.call_handle = call_handle;
1017                         event_data.brejected = brejected_number;
1018                         _vc_core_util_strcpy(event_data.call_num, sizeof(event_data.call_num), tel_number);
1019
1020                         vcall_engine_send_event_to_client(VC_ENGINE_MSG_INCOM_TO_UI, (void *)&event_data);
1021
1022                         _vc_core_util_set_sleep_status(CALL_VC_POWER_PROHIBIT_DIMMING);
1023
1024                         /* in case of rejected number, sound & callstatus is not processed */
1025                         if (!brejected_number) {
1026                                 gboolean benabledTestMode = FALSE;
1027                                 voicecall_snd_register_cm(pcall_core->papp_snd);
1028
1029                                 /*Send Incoming Call Event to Blue Tooth */
1030                                 _vc_bt_send_response_to_bt(pcall_core, BT_AG_RES_CALL_INCOM, call_handle, tel_number);
1031
1032                                 CALL_ENG_DEBUG(ENG_DEBUG, "Preparing Sound ");
1033                                 voicecall_snd_prepare_alert(pcall_core->papp_snd, call_handle);
1034                                 if (FALSE == voicecall_core_is_connected_call_exist(pcall_core->pcall_engine)) {
1035                                         CALL_ENG_DEBUG(ENG_DEBUG, "Changing MM Path just before playing the ring tone");
1036                                         voicecall_snd_change_mm_path(pcall_core->papp_snd, VOICE_CALL_MM_RING_TONE);
1037                                 } else {
1038                                         CALL_ENG_DEBUG(ENG_DEBUG, "2nd MT call alert.");
1039                                 }
1040                                 voicecall_snd_play_alert(pcall_core->papp_snd);
1041
1042                                 _vc_core_util_set_call_status(VCONFKEY_CALL_VOICE_CONNECTING);
1043                         }
1044
1045                 }
1046                 break;
1047
1048         case VC_CALL_OUTGOING:
1049                 {
1050                         int call_handle = param1;
1051                         vc_engine_common_with_handle_type event_data;
1052                         memset(&event_data, 0, sizeof(event_data));
1053
1054                         CALL_ENG_DEBUG(ENG_DEBUG, "MO Call Start: Call handle %d", call_handle);
1055                 }
1056                 break;
1057
1058         case VC_CALL_OUTGOING_ORIG:
1059                 {
1060                         int call_handle = param1;
1061                         vc_engine_outgoing_orig_type event_data;
1062                         call_vc_call_objectinfo_t callobject_info;
1063
1064                         memset(&event_data, 0, sizeof(event_data));
1065                         event_data.call_handle = call_handle;
1066                         if (pcall_core->call_setup_info.call_type == VC_CALL_ORIG_TYPE_EMERGENCY) {
1067                                 event_data.bemergency = TRUE;
1068                         } else {
1069                                 event_data.bemergency = FALSE;
1070                         }
1071
1072                         CALL_ENG_DEBUG(ENG_DEBUG, "Call Handle = %d, bemergency:[%d]", event_data.call_handle, event_data.bemergency);
1073                         vcall_engine_send_event_to_client(VC_ENGINE_MSG_OUTGOING_ORIG_TO_UI, (void *)&event_data);
1074                         _voicecall_dvc_proximity_sensor_init(pcall_core);
1075
1076                         g_set_path_timer_handler = g_timeout_add(SET_PATH_TIMER_VALUE, __voicecall_core_set_path_timer_cb, pcall_core);
1077
1078                         /*Send Event to Blue Tooth */
1079                         voicecall_core_get_call_object(pcall_engine, call_handle, &callobject_info);
1080                         _vc_bt_send_response_to_bt(pcall_core, BT_AG_RES_CALL_ORIG, call_handle, callobject_info.tel_number);
1081                 }
1082                 break;
1083
1084         case VC_CALL_OUTGOING_ALERT:
1085                 {
1086                         int call_handle = param1;
1087                         vc_engine_common_with_handle_type event_data;
1088
1089                         memset(&event_data, 0, sizeof(event_data));
1090
1091                         PRINT_CURRENT_TIME("Alert Indication received at ");
1092
1093                         event_data.call_handle = call_handle;
1094
1095                         vcall_engine_send_event_to_client(VC_ENGINE_MSG_OUTGOING_ALERT_TO_UI, (void *)&event_data);
1096
1097                         /*Play Connected Effect Tone */
1098                         CALL_ENG_KPI("voicecall_snd_play_effect_tone start");
1099                         if (FALSE == voicecall_snd_play_effect_tone(pcall_core->papp_snd, VOICE_CALL_SND_EFFECT_CALL_CONNECT)) {
1100                                 CALL_ENG_DEBUG(ENG_DEBUG, "voicecall_snd_play_effect_tone return value is FALSE");
1101                                 voicecall_snd_change_path(pcall_core->papp_snd);
1102                         }
1103                         CALL_ENG_KPI("voicecall_snd_play_effect_tone done");
1104
1105                         CALL_ENG_KPI("_vc_bt_send_response_to_bt start");
1106                         _vc_bt_send_response_to_bt(pcall_core, BT_AG_RES_CALL_REMOTE_RINGING, call_handle, NULL);
1107                         CALL_ENG_KPI("_vc_bt_send_response_to_bt done");
1108                 }
1109                 break;
1110
1111         case VC_CALL_ANSWER_CNF:
1112                 {
1113                         CALL_ENG_DEBUG(ENG_DEBUG, "Answer confirm");
1114                         if (_vc_core_cm_get_call_member_count(&(pcall_engine->call_manager)) == 1) {
1115                                 CALL_ENG_DEBUG(ENG_DEBUG, "single call state");
1116                                 voicecall_snd_change_path(pcall_core->papp_snd);
1117                         }
1118                 }
1119                 break;
1120
1121         case VC_CALL_CONNECTED:
1122                 {
1123                         int call_handle = param1;
1124                         vc_engine_connected_type event_data;
1125                         int bstatus = FALSE;
1126
1127                         memset(&event_data, 0, sizeof(event_data));
1128
1129                         CALL_ENG_DEBUG(ENG_DEBUG, "Connected Call Handle : %d", call_handle);
1130
1131                         event_data.call_handle = call_handle;
1132                         event_data.bt_status = (int)_vc_bt_get_bt_status();
1133
1134                         vcall_engine_send_event_to_client(VC_ENGINE_MSG_CONNECTED_TO_UI, (void *)&event_data);
1135                         _voicecall_dvc_proximity_sensor_init(pcall_core);
1136
1137                         voicecall_snd_change_path(pcall_core->papp_snd);
1138
1139                         /* Set phonestatus value */
1140                         _vc_core_util_set_call_status(VCONFKEY_CALL_VOICE_ACTIVE);
1141                         _vc_core_util_set_sleep_status(CALL_VC_POWER_GRANT_DIMMING);
1142
1143                         /* check minute minder */
1144                         if (vconf_get_bool(VCONFKEY_CISSAPPL_MINUTE_MINDER_BOOL, &bstatus)) {
1145                                 CALL_ENG_DEBUG(ENG_ERR, "vconf_get_bool failed.");
1146                         }
1147                         if (bstatus) {
1148                                 if (pcall_core->minute_minder_timer == 0) {
1149                                         pcall_core->minute_minder_timer = g_timeout_add(MINUTE_MINDER_TIMEOUT_VALUE, __voicecall_core_minute_minder, pcall_core);
1150                                 }
1151                         }
1152
1153                         /*Send Event to Blue Tooth */
1154                         _vc_bt_send_response_to_bt(pcall_core, BT_AG_RES_CALL_CONNECT, call_handle, NULL);
1155
1156                         /*Call is accepted, reset the flag */
1157                         voicecall_core_set_status(pcall_core, CALL_VC_CORE_FLAG_ACCEPT_BY_BT, FALSE);
1158
1159 #ifdef PDIAL_SEND_DTMF
1160                         g_idle_add(voicecall_core_send_phone_number_dtmf, (gpointer) call_handle);
1161 #endif
1162                 }
1163                 break;
1164
1165         case VC_CALL_NORMAL_END:
1166                 {
1167                         int call_handle = param1;
1168                         voice_call_end_cause_type_t end_cause = param2;
1169                         vc_engine_normal_end_type event_data;
1170                         int active_call_members = -1;
1171
1172                         memset(&event_data, 0, sizeof(event_data));
1173
1174                         CALL_ENG_DEBUG(ENG_DEBUG, "Normal End Call Handle : %d,End Cause=%d", call_handle, end_cause);
1175
1176                         event_data.call_handle = call_handle;
1177                         event_data.end_cause_type = end_cause;
1178
1179                         __voicecall_core_handle_normal_end(pcall_core, call_handle, end_cause);
1180
1181                         vcall_engine_send_event_to_client(VC_ENGINE_MSG_NORMAL_END_TO_UI, (void *)&event_data);
1182
1183                         /*Send Event to Blue Tooth */
1184                         _vc_bt_send_response_to_bt(pcall_core, BT_AG_RES_CALL_END, call_handle, NULL);
1185                 }
1186                 break;
1187
1188         case VC_CALL_INCOM_END:
1189                 {
1190                         int call_handle = param1;
1191                         vc_engine_common_with_handle_type event_data;
1192
1193                         memset(&event_data, 0, sizeof(event_data));
1194
1195                         CALL_ENG_DEBUG(ENG_DEBUG, "Incoming call End Call Handle: %d", call_handle);
1196
1197                         voicecall_core_set_status(pcall_core, CALL_VC_CORE_FLAG_ACCEPT_BY_BT, FALSE);
1198
1199                         if (TRUE == __voicecall_core_handle_call_end_on_silent_reject(pcall_core, call_handle)) {
1200                                 CALL_ENG_DEBUG(ENG_DEBUG, "Call end processed for silent reject:");
1201                                 return TRUE;
1202                         }
1203
1204                         event_data.call_handle = call_handle;
1205
1206                         __voicecall_core_handle_incoming_call_end(pcall_core, call_handle);
1207
1208                         _vc_core_util_set_sleep_status(CALL_VC_POWER_GRANT_DIMMING);
1209                         vcall_engine_send_event_to_client(VC_ENGINE_MSG_INCOM_END_TO_UI, (void *)&event_data);
1210                 }
1211                 break;
1212
1213         case VC_CALL_INCOM_DROPPED:
1214                 {
1215                         CALL_ENG_DEBUG(ENG_DEBUG, "Check it. Not used");
1216                 }
1217                 break;
1218
1219         case VC_CALL_REJECTED_END:
1220                 {
1221                         int call_handle = param1;
1222                         vc_engine_common_with_handle_type event_data;
1223
1224                         memset(&event_data, 0, sizeof(event_data));
1225
1226                         CALL_ENG_DEBUG(ENG_DEBUG, "Rejected call End Call Handle: %d", call_handle);
1227
1228                         event_data.call_handle = call_handle;
1229
1230                         voicecall_core_set_status(pcall_core, CALL_VC_CORE_FLAG_ACCEPT_BY_BT, FALSE);
1231
1232                         __voicecall_core_handle_rejected_call_end(pcall_core, call_handle);
1233
1234                         _vc_core_util_set_sleep_status(CALL_VC_POWER_GRANT_DIMMING);
1235                         vcall_engine_send_event_to_client(VC_ENGINE_MSG_REJECTED_END_TO_UI, (void *)&event_data);
1236                 }
1237                 break;
1238
1239         case VC_CALL_OUTGOING_END:
1240                 {
1241                         int call_handle = param1;
1242                         int end_cause_type = param2;
1243                         int bauto_redial = -1;
1244
1245                         CALL_ENG_DEBUG(ENG_DEBUG, "end cause type :[%d]", end_cause_type);
1246
1247                         if (vconf_get_bool(VCONFKEY_CISSAPPL_VOICE_AUTO_REDIAL_BOOL, &bauto_redial)) {
1248                                 CALL_ENG_DEBUG(ENG_ERR, "vconf_get_bool failed.");
1249                         }
1250
1251                         CALL_ENG_DEBUG(ENG_DEBUG, "bauto_redial:[%d]", bauto_redial);
1252
1253                         if ((TRUE == bauto_redial) && (FALSE == voicecall_core_is_connected_call_exist(pcall_engine))
1254                             && (FALSE == voicecall_core_get_status(pcall_core, CALL_VC_CORE_FLAG_MOCALL_END_BY_USER))
1255                             && (TRUE == __voicecall_core_is_redial_cuase(end_cause_type))) {
1256                                 /* auto redial */
1257                                 CALL_ENG_DEBUG(ENG_DEBUG, "It is auto redial case.");
1258
1259                                 _vc_core_util_set_call_status(VCONFKEY_CALL_OFF);
1260
1261                                 vc_engine_outgoing_end_type event_data;
1262
1263                                 memset(&event_data, 0, sizeof(event_data));
1264                                 event_data.call_handle = call_handle;
1265                                 event_data.end_cause_type = end_cause_type;
1266                                 event_data.bauto_redial = TRUE;
1267                                 vcall_engine_send_event_to_client(VC_ENGINE_MSG_OUTGOING_END_TO_UI, (void *)&event_data);
1268                         } else {
1269                                 __voicecall_core_handle_outgoingcall_end(pcall_core, call_handle, end_cause_type);
1270                         }
1271                         _vc_core_util_set_sleep_status(CALL_VC_POWER_GRANT_DIMMING);
1272                 }
1273                 break;
1274
1275         case VC_CALL_OUTGOING_ABORTED:
1276                 {
1277                         vc_engine_common_type event_data;
1278
1279                         memset(&event_data, 0, sizeof(event_data));
1280
1281                         vcall_engine_send_event_to_client(VC_ENGINE_MSG_OUTGOING_ABORTED_TO_UI, (void *)&event_data);
1282
1283                         _vc_core_util_set_sleep_status(CALL_VC_POWER_GRANT_DIMMING);
1284                 }
1285                 break;
1286
1287         case VC_CALL_DTMF_ACK:
1288                 {
1289                         gboolean bsuccess = param1;
1290                         CALL_ENG_DEBUG(ENG_DEBUG, "bsuccess:[%d]", bsuccess);
1291 #ifdef  PDIAL_SEND_DTMF
1292                         __voicecall_core_handle_dtmf_ack(pcall_core, bsuccess);
1293 #endif
1294                 }
1295                 break;
1296
1297         case VC_CALL_AUTO_REDIAL_CHECK:
1298                 {
1299                         CALL_ENG_DEBUG(ENG_DEBUG, "Check it. Not used");
1300                 }
1301                 break;
1302
1303         case VC_CALL_SS_HELD:
1304                 {
1305                         int io_state = -1;
1306                         int call_handle = param1;
1307                         vc_engine_common_type event_data;
1308                         PRINT_CURRENT_TIME("Call Hold Ends at");
1309
1310                         /*  held popup shold not be displayed on outgoing popup */
1311                         memset(&event_data, 0, sizeof(event_data));
1312
1313                         vcall_engine_send_event_to_client(VC_ENGINE_MSG_SS_HELD_TO_UI, (void *)&event_data);
1314
1315                         /*Send Event to Blue Tooth */
1316                         _vc_bt_send_response_to_bt(pcall_core, BT_AG_RES_CALL_HOLD, call_handle, NULL);
1317                 }
1318                 break;
1319
1320         case VC_CALL_SS_RETREIVED:
1321                 {
1322                         int call_handle = param1;
1323                         vc_engine_common_type event_data;
1324                         PRINT_CURRENT_TIME("Call Retrieve Ends at");
1325
1326                         /*  held popup shold not be displayed on outgoing popup */
1327                         memset(&event_data, 0, sizeof(event_data));
1328                         vcall_engine_send_event_to_client(VC_ENGINE_MSG_SS_RETREIVED_TO_UI, (void *)&event_data);
1329
1330                         /*Send Event to Blue Tooth */
1331                         _vc_bt_send_response_to_bt(pcall_core, BT_AG_RES_CALL_RETRIEVE, call_handle, NULL);
1332                 }
1333                 break;
1334
1335         case VC_CALL_SS_SWAP:
1336                 {
1337                         vc_engine_common_type event_data;
1338
1339                         int call_handle = param1;
1340                         PRINT_CURRENT_TIME("Call Swap Ends at");
1341
1342                         memset(&event_data, 0, sizeof(event_data));
1343
1344                         /* Show Call Swapped Message Box */
1345                         vcall_engine_send_event_to_client(VC_ENGINE_MSG_SS_SWAP_TO_UI, (void *)&event_data);
1346
1347                         _vc_bt_send_response_to_bt(pcall_core, BT_AG_RES_CALL_SWAPPED, call_handle, NULL);
1348                 }
1349                 break;
1350
1351         case VC_CALL_SS_SETUP_CONF:
1352                 {
1353                         vc_engine_common_type event_data;
1354
1355                         PRINT_CURRENT_TIME("Setup Conf Ends at");
1356
1357                         memset(&event_data, 0, sizeof(event_data));
1358
1359                         /* Show Call Joined Message Box */
1360                         vcall_engine_send_event_to_client(VC_ENGINE_MSG_SS_SETUP_CONF_TO_UI, (void *)&event_data);
1361
1362                         _vc_bt_send_response_to_bt(pcall_core, BT_AG_RES_CALL_JOINED, 0, NULL);
1363                 }
1364                 break;
1365
1366         case VC_CALL_SS_SPLIT_CONF:
1367                 {
1368                         vc_engine_common_with_handle_type event_data;
1369                         int call_handle = param1;
1370                         CALL_ENG_DEBUG(ENG_DEBUG, "The handle to be split is %d", call_handle);
1371
1372                         PRINT_CURRENT_TIME("Split Conf Ends at");
1373
1374                         memset(&event_data, 0, sizeof(event_data));
1375                         event_data.call_handle = call_handle;
1376
1377                         /* Show Private Call Message Box */
1378                         vcall_engine_send_event_to_client(VC_ENGINE_MSG_SS_SPLIT_CONF_TO_UI, (void *)&event_data);
1379                 }
1380                 break;
1381
1382         case VC_CALL_SS_TRANSFERRED:
1383                 {
1384                         vc_engine_common_type event_data;
1385
1386                         memset(&event_data, 0, sizeof(event_data));
1387
1388                         vcall_engine_send_event_to_client(VC_ENGINE_MSG_SS_TRANSFERRED_TO_UI, (void *)&event_data);
1389                 }
1390                 break;
1391
1392         case VC_CALL_SS_CONNECT_LINE_IND:
1393                 {
1394                         int call_handle = param1;
1395                         char *pconnected_number = (char *)param3;
1396                         vc_engine_msg_box_type event_data;
1397
1398                         CALL_ENG_DEBUG(ENG_DEBUG, "call_handle : [%d]", call_handle);
1399
1400                         /* check whether Call Info for recevice Call Handle exists or not. */
1401
1402                         if ((pconnected_number != NULL) && (strlen(pconnected_number) > 0)) {
1403                                 CALL_ENG_DEBUG(ENG_DEBUG, "connected line ind : [%s]", pconnected_number);
1404
1405                                 memset(&event_data, 0, sizeof(event_data));
1406
1407                                 event_data.string_id = IDS_CALL_POP_CALL_IS_DIVERTED;
1408                                 _vc_core_util_strcpy(event_data.diverted_num, sizeof(event_data.diverted_num), pconnected_number);
1409                         } else {
1410                                 CALL_ENG_DEBUG(ENG_DEBUG, "No conneccted info");
1411                         }
1412
1413                 }
1414                 break;
1415
1416         case VC_CALL_IND_FORWARD:
1417                 {
1418                         vc_engine_ind_forward_type event_data;
1419                         int fwd_type = param1;
1420
1421                         memset(&event_data, 0, sizeof(event_data));
1422                         event_data.fwd_type = fwd_type;
1423
1424                         vcall_engine_send_event_to_client(VC_ENGINE_MSG_IND_FORWARD_TO_UI, (void *)&event_data);
1425                 }
1426                 break;
1427
1428         case VC_CALL_IND_ACTIVATE:
1429                 {
1430                         vc_engine_common_type event_data;
1431
1432                         memset(&event_data, 0, sizeof(event_data));
1433
1434                         vcall_engine_send_event_to_client(VC_ENGINE_MSG_IND_ACTIVATE_TO_UI, (void *)&event_data);
1435                 }
1436                 break;
1437
1438         case VC_CALL_IND_HOLD:
1439                 {
1440                         vc_engine_common_type event_data;
1441                         int call_handle = param1;
1442
1443                         memset(&event_data, 0, sizeof(event_data));
1444
1445                         vcall_engine_send_event_to_client(VC_ENGINE_MSG_IND_HOLD_TO_UI, (void *)&event_data);
1446
1447                         /*Send Event to Blue Tooth */
1448                         _vc_bt_send_response_to_bt(pcall_core, BT_AG_RES_CALL_HOLD, call_handle, NULL);
1449                 }
1450                 break;
1451
1452         case VC_CALL_IND_TRANSFER:
1453                 {
1454                         CALL_ENG_DEBUG(ENG_DEBUG, "Not used.");
1455                 }
1456                 break;
1457
1458         case VC_CALL_IND_SETUPCONFERENCE:
1459                 {
1460                         CALL_ENG_DEBUG(ENG_DEBUG, "Not used.");
1461                 }
1462                 break;
1463
1464         case VC_CALL_IND_BARRING:
1465                 {
1466                         vc_engine_common_type event_data;
1467
1468                         memset(&event_data, 0, sizeof(event_data));
1469
1470                         vcall_engine_send_event_to_client(VC_ENGINE_MSG_IND_BARRING_TO_UI, (void *)&event_data);
1471                 }
1472                 break;
1473
1474         case VC_CALL_IND_WAITING:
1475                 {
1476                         vc_engine_common_type event_data;
1477
1478                         memset(&event_data, 0, sizeof(event_data));
1479
1480                         vcall_engine_send_event_to_client(VC_ENGINE_MSG_IND_WAITING_TO_UI, (void *)&event_data);
1481                 }
1482                 break;
1483
1484         case VC_CALL_IND_CUGINFO:
1485                 {
1486                         CALL_ENG_DEBUG(ENG_DEBUG, "Not used.");
1487                 }
1488                 break;
1489
1490         case VC_CALL_IND_SSNOTIFY:
1491                 {
1492                         vc_engine_ind_ssnotify_type event_data;
1493                         int ss_type = param1;
1494
1495                         memset(&event_data, 0, sizeof(event_data));
1496                         event_data.ss_type = ss_type;
1497
1498                         vcall_engine_send_event_to_client(VC_ENGINE_MSG_IND_SSNOTIFY_TO_UI, (void *)&event_data);
1499                 }
1500                 break;
1501
1502         case VC_CALL_IND_CALLINGNAMEINFO:
1503                 {
1504                         CALL_ENG_DEBUG(ENG_DEBUG, "Not used.");
1505                 }
1506                 break;
1507         case VC_CALL_IND_ACTIVATECCBS_CNF:
1508                 {
1509                         CALL_ENG_DEBUG(ENG_DEBUG, "Not used.");
1510                 }
1511                 break;
1512
1513         case VC_CALL_IND_ACTIVATECCBS_USERINFO:
1514                 {
1515                         CALL_ENG_DEBUG(ENG_DEBUG, "Not used.");
1516                 }
1517                 break;
1518
1519         case VC_CALL_IND_AOC:
1520                 {
1521                         CALL_ENG_DEBUG(ENG_DEBUG, "Not yet.");
1522                 }
1523                 break;
1524
1525         case VC_ERROR_OCCURED:
1526                 {
1527                         int error_code = param1;
1528
1529                         CALL_ENG_DEBUG(ENG_DEBUG, "error code:[%d]", error_code);
1530                         switch (error_code) {
1531                         case ERROR_VOICECALL_INVALID_DTMF_CHAR:
1532                         case ERROR_VOICECALL_DTMF_FAILED:
1533                                 {
1534                                         vc_engine_error_occured_type event_data;
1535
1536                                         memset(&event_data, 0, sizeof(event_data));
1537                                         event_data.error_code = error_code;
1538
1539                                         vcall_engine_send_event_to_client(VC_ENGINE_MSG_ERROR_OCCURED_TO_UI, (void *)&event_data);
1540                                 }
1541                                 break;
1542                         default:
1543                                 {
1544                                         vc_engine_msg_box_type event_data;
1545                                         int string_id = -1;
1546
1547                                         string_id = __voicecall_core_get_string_id_by_errorcode(error_code);
1548
1549                                         memset(&event_data, 0, sizeof(event_data));
1550                                         event_data.string_id = __voicecall_core_get_string_id_by_errorcode(error_code);
1551
1552                                         vcall_engine_send_event_to_client(VC_ENGINE_MSG_MESSAGE_BOX_TO_UI, (void *)&event_data);
1553                                 }
1554                                 break;
1555                         }
1556                 }
1557                 break;
1558
1559         case VC_ACTION_INCOM_FORCE:
1560                 {
1561                         int call_handle = param1;
1562                         vc_engine_common_with_handle_type event_data;
1563
1564                         CALL_ENG_DEBUG(ENG_DEBUG, "Call Handle = %d", call_handle);
1565
1566                         memset(&event_data, 0, sizeof(event_data));
1567                         event_data.call_handle = call_handle;
1568
1569                         vcall_engine_send_event_to_client(VC_ENGINE_MSG_ACTION_INCOM_FORCE_TO_UI, (void *)&event_data);
1570                 }
1571                 break;
1572
1573         case VC_ACTION_SAT_REQUEST:
1574                 {
1575                         if (SAT_RQST_SETUP_CALL == param1) {
1576                                 voicecall_sat_callinfo_t *psat_callinfo = (voicecall_sat_callinfo_t *) param3;
1577                                 vc_engine_outgoing_type event_data;
1578
1579                                 if (psat_callinfo == NULL) {
1580                                         CALL_ENG_DEBUG(ENG_ERR, "psat_callinfo is NULL..");
1581                                         assert(psat_callinfo != NULL);
1582                                 } else {
1583                                         CALL_ENG_DEBUG(ENG_DEBUG, "VC_ACTION_SAT_REQUEST is received by Voice call.");
1584                                         pcall_core->call_setup_info.call_setup_by = VC_CALL_SETUP_BY_SAT;
1585                                         pcall_core->call_setup_info.call_type = VC_CALL_ORIG_TYPE_SAT;
1586
1587                                         /*Phone Number */
1588                                         _vc_core_util_strcpy(pcall_core->call_setup_info.source_tel_number, VC_PHONE_NUMBER_LENGTH_MAX, psat_callinfo->call_number);
1589                                         _vc_core_engine_extract_phone_number(pcall_core->call_setup_info.source_tel_number, pcall_core->call_setup_info.tel_number, VC_PHONE_NUMBER_LENGTH_MAX);
1590
1591                                         /*Name */
1592                                         CALL_ENG_DEBUG(ENG_ERR, "psat_callinfo->disp_text:[%s]", psat_callinfo->disp_text);
1593
1594                                         memset(&event_data, 0, sizeof(event_data));
1595                                         _vc_core_util_strcpy(event_data.call_num, sizeof(event_data.call_num), pcall_core->call_setup_info.tel_number);
1596                                         event_data.contact_index = -1;
1597                                         event_data.phone_type = -1;
1598                                         _vc_core_util_strcpy(event_data.call_num, sizeof(event_data.call_num), psat_callinfo->disp_text);
1599
1600                                         vcall_engine_send_event_to_client(VC_ENGINE_MSG_OUTGOING_TO_UI, (void *)&event_data);
1601
1602                                         /*Get Icon Information */
1603                                         if (TRUE == psat_callinfo->bicon_present) {     /*bicon_present is TRUE when SAT icon info available and when GCF is enabled */
1604                                                 CALL_ENG_DEBUG(ENG_ERR, "SAT icon available.");
1605                                         }
1606
1607                                         /* Prepare and Make Call with the Give Information */
1608                                         if (FALSE == voicecall_core_setup_call(pcall_core, FALSE)) {
1609                                                 /*Send Response to SAT Engine */
1610                                                 voicecall_core_send_sat_response(pcall_core->pcall_engine, SAT_RQST_SETUP_CALL, CALL_VC_ME_UNABLE_TO_PROCESS_COMMAND);
1611                                         }
1612                                 }
1613                         } else if (SAT_RQST_SEND_DTMF == param1) {
1614                                 voicecall_sat_callinfo_t *psat_callinfo = (voicecall_sat_callinfo_t *) param3;
1615
1616                                 CALL_ENG_DEBUG(ENG_DEBUG, "SAT Send DTMF Number: %s, hidden: %d", psat_callinfo->call_number, psat_callinfo->bsat_hidden);
1617                                 __voicecall_core_queue_dtmf_string(pcall_core, psat_callinfo->call_number, TRUE);
1618                         } else {
1619                                 CALL_ENG_DEBUG(ENG_ERR, "Invalid SAT Request Type: %d", param2);
1620                         }
1621                 }
1622                 break;
1623
1624         case VC_ACTION_SAT_RESPONSE:
1625                 {
1626                         if (SAT_RESP_SETUP_CALL == param1) {
1627                                 voicecall_sat_callinfo_t *psat_call_info = (voicecall_sat_callinfo_t *) param3;
1628
1629                                 CALL_ENG_DEBUG(ENG_DEBUG, "sat_mo_call_ctrl_res = %d", psat_call_info->sat_mo_call_ctrl_res);
1630
1631                                 if (CALL_NOT_ALLOWED == psat_call_info->sat_mo_call_ctrl_res) {
1632                                         vc_engine_msg_box_type event_data;
1633
1634                                         memset(&event_data, 0, sizeof(event_data));
1635                                         event_data.string_id = IDS_CALL_POP_CALLNOTCALLOWED;
1636                                         vcall_engine_send_event_to_client(VC_ENGINE_MSG_MESSAGE_BOX_TO_UI, (void *)&event_data);
1637                                 } else if (CALL_ALLOWED_WITH_MOD == psat_call_info->sat_mo_call_ctrl_res) {
1638                                         CALL_ENG_DEBUG(ENG_DEBUG, "psat_call_info->call_number = [%s]", psat_call_info->call_number);
1639                                         CALL_ENG_DEBUG(ENG_DEBUG, "psat_call_info->disp_text = [%s]", psat_call_info->disp_text);
1640 #ifdef _OLD_SAT_
1641                                         mocall_index = vcui_app_doc_get_mocall_index(papp_document);
1642
1643                                         /*Update MO CALL Display Data with the SAT modified info */
1644                                         if (mocall_index != -1) {
1645                                                 vcui_app_call_display_data_t display_data;
1646                                                 vcui_app_call_display_data_t new_display_data;
1647                                                 vcui_app_view_mo_state_t *pmo_state = NULL;
1648
1649                                                 if (FALSE == vcui_app_cdm_get_display_object_byindex(&papp_document->call_display_manager, mocall_index, &display_data)) {
1650                                                         return TRUE;
1651                                                 }
1652
1653                                                 vcui_app_cdm_clear_display_object(&new_display_data);
1654
1655                                                 /*Copy all must parameters required for MO Call */
1656                                                 new_display_data.call_handle = display_data.call_handle;
1657                                                 new_display_data.call_index = display_data.call_index;
1658                                                 new_display_data.call_type = display_data.call_type;
1659                                                 new_display_data.start_time = display_data.start_time;
1660                                                 new_display_data.used = display_data.used;
1661
1662                                                 if (strlen(psat_call_info->call_number) > 0) {
1663                                                         vcui_app_util_strcpy(new_display_data.source_tel_number, sizeof(new_display_data.source_tel_number), psat_call_info->call_number);
1664                                                         _vc_core_engine_extract_phone_number(new_display_data.source_tel_number, new_display_data.tel_number, VC_PHONE_NUMBER_LENGTH_MAX);
1665                                                 }
1666
1667                                                 if (strlen(psat_call_info->disp_text) > 0) {
1668                                                         vcui_app_util_strcpy(new_display_data.name, sizeof(new_display_data.name), psat_call_info->disp_text);
1669                                                 }
1670
1671                                                 /* todo, Check whether contact search need to be done for the SAT modified number */
1672
1673                                                 /*Set the newly modified data to the CDM */
1674                                                 vcui_app_cdm_set_display_object(pdisplay_mgr, &new_display_data);
1675
1676                                                 /*Update the MO View */
1677                                                 pmo_state = (vcui_app_view_mo_state_t *) calloc(1, sizeof(vcui_app_view_mo_state_t));
1678                                                 pmo_state->mo_call_state = VCUI_MO_CALL_STATE_UPDATE;
1679
1680                                                 /* Update MO Call Screen View to update the connection status */
1681                                                 dv_view_manager_update_view(dv_document_get_view_manager(DV_DOCUMENT(papp_document)), VCUI_APP_VIEWID_MO_VIEW, VCUI_APP_UPD_MO_SET_STATE, pmo_state);
1682
1683                                         } else {
1684                                                 VCUI_DEBUG(VCUI_LOG_ERR, "Invalid Mo Call Index: %d", mocall_index);
1685                                         }
1686 #endif
1687                                 } else if (CALL_CHANGED_TO_SS == psat_call_info->sat_mo_call_ctrl_res) {
1688                                         /*Issue notification to Launch SS */
1689                                 }
1690                         }
1691                 }
1692                 break;
1693
1694         case VC_ACTION_CALL_END_HELD_RETREIVED:
1695                 {
1696                         int call_handle = param1;
1697                         vc_engine_common_with_handle_type event_data;
1698
1699                         CALL_ENG_DEBUG(ENG_DEBUG, "call handle:[%d]", call_handle);
1700
1701                         memset(&event_data, 0, sizeof(event_data));
1702
1703                         vcall_engine_send_event_to_client(VC_ENGINE_MSG_ACTION_CALL_END_HELD_RETREIVED_TO_UI, (void *)&event_data);
1704                 }
1705                 break;
1706
1707         case VC_ACTION_NO_ACTIVE_TASK:
1708                 {
1709                         CALL_ENG_DEBUG(ENG_DEBUG, "Not yet.");
1710                 }
1711                 break;
1712
1713         case VC_CALL_GET_VOLUME_RESP:
1714                 {
1715                         vc_engine_vol_resp_type event_data;
1716
1717                         CALL_ENG_DEBUG(ENG_DEBUG, "Current Voicecall (TAPI)Volume Type %d, Current Volume Level: %d", param1, param2);
1718
1719                         memset(&event_data, 0, sizeof(event_data));
1720                         event_data.vol_alert_type = VOICE_CALL_VOL_TYPE_VOICE;
1721                         event_data.vol_level = param2;
1722                         vcall_engine_send_event_to_client(VC_ENGINE_MSG_GET_VOLUME_RESP_TO_UI, (void *)&event_data);
1723                 }
1724                 break;
1725
1726         default:
1727                 CALL_ENG_DEBUG(ENG_DEBUG, " Engine Event ID : %d not handled", event);
1728                 break;
1729         }
1730
1731         CALL_VC_DUMP_CALLDETAILS(&pcall_engine->call_manager);
1732
1733         CALL_ENG_DEBUG(ENG_DEBUG, " Ended.");
1734
1735         return TRUE;
1736 }
1737
1738 /**
1739  * This function converts Error Code to string id.
1740  *
1741  * @return              string id
1742  * @param[in]           error_code              error code to be used to display the message content
1743  */
1744 static int __voicecall_core_get_string_id_by_errorcode(int error_code)
1745 {
1746         int string_id = -1;
1747         switch (error_code) {
1748         case ERROR_VOICECALL_DTMF_FAILED:
1749                 string_id = IDS_CALL_POP_DTMFSENDING_FAIL;
1750                 break;
1751
1752         case ERROR_VOICECALL_CALL_NOT_ALLOWED:
1753                 string_id = IDS_CALL_POP_CALLNOTCALLOWED;
1754                 break;
1755
1756         case ERROR_VOICECALL_CALL_IMPOSSIBLE_NOSIM_NOEMERGNUM:
1757                 string_id = IDS_CALL_POP_SOS_CALL_ONLY_IN_NO_SIM_MODE;
1758                 break;
1759
1760         case ERROR_VOICECALL_EMERGENCY_CALLS_ONLY:
1761                 string_id = IDS_CALL_POP_CALLING_EMERG_ONLY;
1762                 break;
1763
1764         case ERROR_VOICECALL_PHONE_NOT_INITIALIZED:
1765                 string_id = IDS_CALL_POP_PHONE_NOT_INITIALISED;
1766                 break;
1767
1768         case ERROR_VOICECALL_ANSWER_FAILED:
1769                 string_id = IDS_CALL_POP_CALLFAILED;
1770                 break;
1771
1772         case ERROR_VOICECALL_HOLD_REJECTED:
1773         case ERROR_VOICECALL_HOLD_FAILED:
1774                 string_id = IDS_CALL_POP_HOLD_FAILED;
1775                 break;
1776
1777         case ERROR_VOICECALL_ACTIVATE_REJECTED:
1778         case ERROR_VOICECALL_RETREIVE_FAILED:
1779                 string_id = IDS_CALL_POP_UNABLE_TO_RETRIEVE;
1780                 break;
1781
1782         case ERROR_VOICECALL_SWAP_REJECTED:
1783         case ERROR_VOICECALL_SWAP_FAILED:
1784                 string_id = IDS_CALL_POP_SWAP_FAILED;
1785                 break;
1786
1787         case ERROR_VOICECALL_SPLIT_CONF_FAILED:
1788                 string_id = IDS_CALL_POP_SPLIT_FAILED;
1789                 break;
1790
1791         case ERROR_VOICECALL_SETUP_CONF_FAILED:
1792                 string_id = IDS_CALL_POP_JOIN_FAILED;
1793                 break;
1794
1795         case ERROR_VOICECALL_TRANSFER_FAILED:
1796                 string_id = IDS_CALL_POP_TRANSFER_FAILED;
1797                 break;
1798
1799         case ERROR_VOICECALL_SWAP_NOT_SUPPORTED:
1800                 string_id = IDS_CALL_POP_SWAP_NOT_SUPPORTED;
1801                 break;
1802
1803         case ERROR_VOICECALL_HOLD_NOT_SUPPORTED:
1804                 string_id = IDS_CALL_POP_HOLD_NOT_SUPPORTED;
1805                 break;
1806
1807         case ERROR_VOICECALL_RETREIVE_NOT_SUPPORTED:
1808                 string_id = IDS_CALL_POP_UNHOLD_NOT_SUPPORTED;
1809                 break;
1810
1811         case ERROR_VOICECALL_SETUP_CONF_NOT_SUPPORTED:
1812                 string_id = IDS_CALL_POP_JOIN_NOT_SUPPORTED;
1813                 break;
1814
1815         case ERROR_VOICECALL_SPLIT_CONF_NOT_SUPPORTED:
1816                 string_id = IDS_CALL_POP_SPLIT_NOT_SUPPORTED;
1817                 break;
1818         case ERROR_VOICECALL_TRANSFER_NOT_SUPPORTED:
1819                 string_id = IDS_CALL_POP_TRANSFER_NOT_SUPPORTED;
1820                 break;
1821
1822         case ERROR_VOICECALL_INCOMPLETE:
1823                 string_id = IDS_CALL_POP_INCOMPLETE;
1824                 break;
1825
1826         case ERROR_VOICECALL_UNAVAILABLE:
1827                 string_id = IDS_CALL_POP_UNAVAILABLE;
1828                 break;
1829
1830         case ERROR_VOICECALL_TAPI_CAUSE_CALL_FAILED:
1831                 string_id = IDS_CALL_POP_CALLFAILED;
1832                 break;
1833
1834         case ERROR_VOICECALL_INVALID_CALL_TYPE:
1835         case ERROR_VOICECALL_INVALID_TELEPHONE_NUMBER:
1836                 string_id = IDS_CALL_POP_CAUSE_WRONG_NUMBER;
1837                 break;
1838
1839         default:
1840                 CALL_ENG_DEBUG(ENG_DEBUG, " Invalid Error Code: %x", error_code);
1841                 string_id = IDS_CALL_POP_CALLFAILED;
1842                 break;
1843         }
1844         return string_id;
1845 }
1846
1847 gboolean voicecall_core_set_to_default(call_vc_core_state_t *pcall_core)
1848 {
1849         CALL_ENG_DEBUG(ENG_DEBUG, "");
1850         if (pcall_core->pcall_engine == NULL)
1851                 return FALSE;
1852
1853         /*Set Engine states to default */
1854         _vc_core_engine_set_to_default_values(pcall_core->pcall_engine);
1855
1856         /*Initialize MO Call Setup Info */
1857         pcall_core->call_setup_info.mo_call_index = VC_TAPI_INVALID_CALLHANDLE;
1858         pcall_core->call_setup_info.call_setup_by = VC_CALL_SETUP_BY_NORMAL;
1859
1860         pcall_core->call_setup_info.mo_call_index = VC_TAPI_INVALID_CALLHANDLE;
1861         pcall_core->call_setup_info.call_setup_by = VC_CALL_SETUP_BY_NORMAL;
1862         memset(pcall_core->call_setup_info.tel_number, 0, sizeof(pcall_core->call_setup_info.tel_number));
1863
1864         pcall_core->mo_redial_timer = -1;
1865         __vc_core_set_auto_redial_count(pcall_core, 0);
1866
1867         _vc_core_util_set_call_status(VCONFKEY_CALL_OFF);
1868         voicecall_core_set_status(pcall_core, CALL_VC_CORE_FLAG_NONE, TRUE);
1869         _vc_core_util_set_sleep_status(CALL_VC_POWER_NORMAL_STATUS);
1870
1871         pcall_core->bt_connected = _vc_bt_get_bt_status();
1872         if (FALSE == pcall_core->bt_connected) {
1873 #ifdef _NEW_SND_
1874                 voicecall_snd_set_path_status(pcall_core->papp_snd, VOICE_CALL_SND_PATH_RECEIVER);                              
1875 #else
1876                 voicecall_snd_set_status(pcall_core->papp_snd, VOICE_CALL_AUDIO_HEADSET, pcall_core->bt_connected);
1877 #endif
1878         } else {
1879                 CALL_ENG_DEBUG(ENG_DEBUG, "BT connected, Not changing the sound status");
1880         }
1881
1882         /* sound reset */
1883         voicecall_snd_unregister_cm(pcall_core->papp_snd);
1884
1885         return TRUE;
1886 }
1887
1888 static void __voicecall_core_mocall_reset_engine_state(voicecall_engine_t *pcall_engine)
1889 {
1890         int eng_state = VC_INOUT_STATE_NONE;
1891
1892         voicecall_core_get_engine_state(pcall_engine, &eng_state);
1893
1894         CALL_ENG_DEBUG(ENG_DEBUG, "current engine state is: %d", eng_state);
1895
1896         if ((eng_state > VC_INOUT_STATE_OUTGOING_START) && (eng_state < VC_INOUT_STATE_OUTGOING_END)) {
1897                 voicecall_core_change_engine_state(pcall_engine, VC_INOUT_STATE_NONE);
1898         } else {
1899                 CALL_ENG_DEBUG(ENG_DEBUG, "Engine state is already changed, current engine state is: %d", eng_state);
1900                 CALL_VC_DUMP_CALLDETAILS(&pcall_engine->call_manager);
1901         }
1902 }
1903
1904 /**
1905  * This function initialize voicecall core
1906  *
1907  * @return              Returns TRUE on success or FALSE on failure
1908  * @param[in]           pcall_core              Handle to voicecall core
1909  * @param[in]           pcallback_func  callback function
1910  */
1911 int voicecall_core_init(call_vc_core_state_t *pcall_core)
1912 {
1913         voicecall_engine_t *pcall_engine = NULL;
1914
1915         if (ERROR_VOICECALL_NONE != _vc_core_engine_init(&pcall_engine, (voicecall_cb) voicecall_core_cb, pcall_core)) {
1916                 CALL_ENG_DEBUG(ENG_DEBUG, "Voicecall Engine Init Failed");
1917                 return FALSE;
1918         }
1919
1920         if (FALSE == voicecall_snd_init(pcall_core, &pcall_core->papp_snd)) {
1921                 CALL_ENG_DEBUG(ENG_DEBUG, "voicecall_snd_init() failed");
1922                 return FALSE;
1923         }
1924         /*Store Voicecall Engine Handle */
1925         pcall_core->pcall_engine = pcall_engine;
1926
1927         _vc_bt_status_init(pcall_core);
1928
1929         _voicecall_dvc_earjack_init(pcall_core);
1930  
1931         voicecall_core_set_status(pcall_core, CALL_VC_CORE_FLAG_NONE, TRUE);
1932         return TRUE;
1933 }
1934
1935 /**
1936  * This function prepares a voice call with the given data
1937  *
1938  * @return              Returns TRUE on success or FALSE on failure
1939  * @param[in]           pcall_core              Handle to voicecall core
1940  * @param[in]           bemergency              emergency call or not from dialer
1941  * @param[in]           
1942  */
1943 gboolean voicecall_core_setup_call(call_vc_core_state_t *pcall_core, gboolean bemergency)
1944 {
1945         voicecall_engine_t *pcall_engine = pcall_core->pcall_engine;
1946         voicecall_setup_info_t setupcall_info = { 0, };
1947         voicecall_error_t error_code = -1;
1948         gboolean bemergency_call = FALSE;
1949         int io_state;
1950         gboolean bmocall_exists = FALSE;
1951         gboolean bmtcall_exists = FALSE;
1952         int nw_status = 0;
1953
1954         CALL_ENG_DEBUG(ENG_DEBUG, "");
1955
1956         voicecall_core_set_status(pcall_core, CALL_VC_CORE_FLAG_SOS_CALL_ONLY, bemergency);
1957
1958         _vc_core_engine_status_isexists_call_bytype(pcall_engine, VC_OUTGOING_CALL, &bmocall_exists);
1959         if (TRUE == bmocall_exists) {
1960                 CALL_ENG_DEBUG(ENG_DEBUG, "MO call is in progress...");
1961                 voicecall_core_set_status(pcall_core, CALL_VC_CORE_FLAG_SETUPCALL_FAIL, TRUE);
1962                 return FALSE;
1963         }
1964
1965         /*Ignore the MO Call, if already an Incoming call is in progress, MT Call is given high priority */
1966         _vc_core_engine_status_isexists_call_bytype(pcall_engine, VC_INCOMING_CALL, &bmtcall_exists);
1967         if (TRUE == bmtcall_exists) {
1968                 CALL_ENG_DEBUG(ENG_DEBUG, "MT call is in progress");
1969                 voicecall_core_set_status(pcall_core, CALL_VC_CORE_FLAG_SETUPCALL_FAIL, TRUE);
1970                 return FALSE;
1971         }
1972
1973         if (TRUE == _vc_core_util_check_video_call_status()) {
1974                 CALL_ENG_DEBUG(ENG_DEBUG, "Voice call is not allowed during video call...");
1975                 voicecall_core_set_status(pcall_core, CALL_VC_CORE_FLAG_SETUPCALL_FAIL, TRUE);
1976                 vc_engine_msg_box_type event_data;
1977
1978                 memset(&event_data, 0, sizeof(event_data));
1979                 event_data.string_id = IDS_CALL_POP_VOICE_CALL_IS_NOT_ALLOWED_DURING_VIDEO_CALL;
1980                 vcall_engine_send_event_to_client(VC_ENGINE_MSG_MESSAGE_BOX_TO_UI, (void *)&event_data);
1981
1982                 return FALSE;
1983         }
1984
1985         if (TRUE == _vc_core_util_get_SAP_status()) {
1986                 CALL_ENG_DEBUG(ENG_DEBUG, "SAP is on");
1987                 voicecall_core_set_status(pcall_core, CALL_VC_CORE_FLAG_SETUPCALL_FAIL, TRUE);
1988                 vc_engine_msg_box_type event_data;
1989
1990                 memset(&event_data, 0, sizeof(event_data));
1991                 event_data.string_id = IDS_CALL_POP_UNAVAILABLE;
1992                 vcall_engine_send_event_to_client(VC_ENGINE_MSG_MESSAGE_BOX_TO_UI, (void *)&event_data);
1993
1994                 return FALSE;
1995         }
1996
1997         /*Prpare a call with the Voicecall Engine */
1998         setupcall_info.call_type = pcall_core->call_setup_info.call_type;
1999         _vc_core_util_strcpy(setupcall_info.source_tel_number, sizeof(setupcall_info.source_tel_number), pcall_core->call_setup_info.source_tel_number);
2000         _vc_core_util_strcpy(setupcall_info.tel_number, sizeof(setupcall_info.tel_number), pcall_core->call_setup_info.tel_number);
2001
2002         /*Get CUG Details */
2003         _vc_core_util_get_cug_info(&setupcall_info);
2004
2005         /*Get Identity Mode */
2006         _vc_core_util_get_identity_mode(&setupcall_info);
2007
2008         CALL_ENG_DEBUG(ENG_DEBUG, "identity_mode = [%d], tel_number = [%s]", setupcall_info.identity_mode, setupcall_info.tel_number);
2009
2010         error_code = _vc_core_engine_prepare_call(pcall_engine, &setupcall_info);
2011         if (ERROR_VOICECALL_NONE != error_code) {
2012                 CALL_ENG_DEBUG(ENG_DEBUG, "_vc_core_engine_prepare_call failed, error code: %d", error_code);
2013                 _vc_core_engine_finalize_call(pcall_engine, VC_OUTGOING_CALL, -1);
2014                 voicecall_core_set_status(pcall_core, CALL_VC_CORE_FLAG_SETUPCALL_FAIL, TRUE);
2015                 vc_engine_msg_box_type event_data;
2016
2017                 memset(&event_data, 0, sizeof(event_data));
2018                 event_data.string_id = __voicecall_core_get_string_id_by_errorcode(error_code);
2019                 vcall_engine_send_event_to_client(VC_ENGINE_MSG_MESSAGE_BOX_TO_UI, (void *)&event_data);
2020                 return FALSE;
2021         }
2022         pcall_core->call_setup_info.call_type = setupcall_info.call_type;
2023         CALL_ENG_DEBUG(ENG_DEBUG, "call_type:[%d]", pcall_core->call_setup_info.call_type);
2024
2025         pcall_core->call_setup_info.mo_call_index = setupcall_info.mo_call_index;
2026         if (TRUE == _vc_core_util_is_offline_mode()) {
2027                 _vc_core_engine_finalize_call(pcall_engine, VC_OUTGOING_CALL, -1);
2028                 voicecall_core_set_status(pcall_core, CALL_VC_CORE_FLAG_SETUPCALL_FAIL, TRUE);
2029
2030                 vc_engine_msg_box_type event_data;
2031
2032                 memset(&event_data, 0, sizeof(event_data));
2033                 event_data.string_id = IDS_CALL_POP_CHANGEOFFLINEMODETOCALL;
2034                 vcall_engine_send_event_to_client(VC_ENGINE_MSG_MESSAGE_BOX_TO_UI, (void *)&event_data);
2035                 return FALSE;
2036         }
2037
2038         /* Check for Following Conditions , only if not emergency Number */
2039         CALL_ENG_DEBUG(ENG_DEBUG, "mo_call_index = [%d]", setupcall_info.mo_call_index);
2040         error_code = _vc_core_engine_status_check_emergency_byindex(pcall_engine, setupcall_info.mo_call_index, &bemergency_call);
2041         if (ERROR_VOICECALL_NONE != error_code) {
2042                 CALL_ENG_DEBUG(ENG_DEBUG, "Emergency Check Error code: %d", error_code);
2043         }
2044
2045         /*Check PwLock */
2046         if (TRUE == _vc_core_util_is_pwlock()) {
2047                 CALL_ENG_DEBUG(ENG_DEBUG, "PwLock is enabled.");
2048                 if (bemergency_call == FALSE) {
2049                         CALL_ENG_DEBUG(ENG_DEBUG, "Only emergency call is possible.");
2050                         _vc_core_engine_finalize_call(pcall_engine, VC_OUTGOING_CALL, -1);
2051                         voicecall_core_set_status(pcall_core, CALL_VC_CORE_FLAG_SETUPCALL_FAIL, TRUE);
2052
2053                         vc_engine_msg_box_type event_data;
2054                         memset(&event_data, 0, sizeof(event_data));
2055                         event_data.string_id = IDS_CALL_POP_CALLING_EMERG_ONLY;
2056                         vcall_engine_send_event_to_client(VC_ENGINE_MSG_MESSAGE_BOX_TO_UI, (void *)&event_data);
2057
2058                         return FALSE;
2059                 }
2060         }
2061
2062         /*Check for the following cases, if the call is not emergency call */
2063         if (FALSE == bemergency_call) {
2064                 vc_engine_msg_box_type event_data;
2065
2066                 memset(&event_data, 0, sizeof(event_data));
2067                 /* Check for NW Status and Emergency Mode */
2068                 if (FALSE == _vc_core_util_get_nw_status(&nw_status)) {
2069                         CALL_ENG_DEBUG(ENG_DEBUG, "Can't get a network status...");
2070                         _vc_core_engine_finalize_call(pcall_engine, VC_OUTGOING_CALL, -1);
2071
2072                         event_data.string_id = IDS_CALL_POP_CALLNOTCALLOWED;
2073                         vcall_engine_send_event_to_client(VC_ENGINE_MSG_MESSAGE_BOX_TO_UI, (void *)&event_data);
2074
2075                         voicecall_core_set_status(pcall_core, CALL_VC_CORE_FLAG_SETUPCALL_FAIL, TRUE);
2076                         return FALSE;
2077                 } else {
2078                         if ((VCONFKEY_TELEPHONY_SVCTYPE_NONE == nw_status) || (VCONFKEY_TELEPHONY_SVCTYPE_NOSVC == nw_status) || (VCONFKEY_TELEPHONY_SVCTYPE_SEARCH == nw_status)) {
2079                                 CALL_ENG_DEBUG(ENG_DEBUG, "No Service: Call not Allowed");
2080                                 _vc_core_engine_finalize_call(pcall_engine, VC_OUTGOING_CALL, -1);
2081                                 event_data.string_id = IDS_CALL_POP_CALLNOTCALLOWED;
2082                                 vcall_engine_send_event_to_client(VC_ENGINE_MSG_MESSAGE_BOX_TO_UI, (void *)&event_data);
2083
2084                                 voicecall_core_set_status(pcall_core, CALL_VC_CORE_FLAG_SETUPCALL_FAIL, TRUE);
2085                                 return FALSE;
2086                         } else if ((VCONFKEY_TELEPHONY_SVCTYPE_EMERGENCY == nw_status)) {
2087                                 CALL_ENG_DEBUG(ENG_DEBUG, "Emergency mode: Emergency call only...");
2088                                 _vc_core_engine_finalize_call(pcall_engine, VC_OUTGOING_CALL, -1);
2089                                 event_data.string_id = IDS_CALL_POP_CALLING_EMERG_ONLY;
2090                                 vcall_engine_send_event_to_client(VC_ENGINE_MSG_MESSAGE_BOX_TO_UI, (void *)&event_data);
2091
2092                                 voicecall_core_set_status(pcall_core, CALL_VC_CORE_FLAG_SETUPCALL_FAIL, TRUE);
2093                                 return FALSE;
2094                         } else {
2095                                 /* ok. */
2096                         }
2097
2098                 }
2099
2100 #ifdef VC_ENG_FDN_SUPPORT
2101                 /*Check FDN Status */
2102                 if (setupcall_info.call_setup_by != VC_CALL_SETUP_BY_SAT) {
2103                         if (FALSE == voicecall_core_check_fdn_status(pcall_core)) {
2104                                 voicecall_core_set_status(pcall_core, CALL_VC_CORE_FLAG_SETUPCALL_FAIL, TRUE);
2105                                 return FALSE;
2106                         }
2107                 }
2108 #endif
2109
2110                 /*Check for voicemail number if it is not an emergency call */
2111         }
2112
2113         CALL_ENG_DEBUG(ENG_DEBUG, "MO Call Setup OVer");
2114
2115 #ifdef _NEW_SND_
2116         if(_vc_bt_get_bt_status() == TRUE){
2117                 voicecall_snd_set_path_status(pcall_core->papp_snd,VOICE_CALL_SND_PATH_BT);
2118         }
2119 #endif
2120
2121         voicecall_core_make_call(pcall_core);
2122
2123         return TRUE;
2124 }
2125
2126 /**
2127  * This function makes the actual voicecall prepared by the #voicecall_core_setup_call
2128  *
2129  * @return              Returns TRUE on success or FALSE on failure
2130  * @param[in]           pcall_core              Handle to voicecall core
2131  */
2132 gboolean voicecall_core_make_call(call_vc_core_state_t *pcall_core)
2133 {
2134         voicecall_engine_t *pcall_engine = pcall_core->pcall_engine;
2135
2136         voicecall_error_t error_code = ERROR_VOICECALL_NONE;
2137         int call_handle = -1;
2138
2139         CALL_ENG_DEBUG(ENG_DEBUG, "");
2140
2141         _vc_core_util_set_sleep_status(CALL_VC_POWER_PROHIBIT_DIMMING);
2142
2143         /*Make Actual Call with Voicecall Engine */
2144         error_code = _vc_core_engine_make_call(pcall_engine, pcall_core->call_setup_info.mo_call_index, &call_handle);
2145         if (ERROR_VOICECALL_NONE != error_code) {
2146                 vc_engine_msg_box_type event_data;
2147
2148                 memset(&event_data, 0, sizeof(event_data));
2149
2150                 _vc_core_engine_finalize_call(pcall_engine, VC_OUTGOING_CALL, -1);
2151
2152                 CALL_ENG_DEBUG(ENG_DEBUG, "_vc_core_engine_make_call Failed: Error_Code: %d..", error_code);
2153
2154                 switch (error_code) {
2155                 case ERROR_VOICECALL_TAPI_CAUSE_CALL_FAILED:
2156                         event_data.string_id = IDS_CALL_POP_CALLFAILED;
2157                         break;
2158
2159                 case ERROR_VOICECALL_CALL_IMPOSSIBLE_NOSIM_NOEMERGNUM:
2160                         event_data.string_id = IDS_CALL_POP_CALLFAILED;
2161                         break;
2162
2163                 default:
2164                         event_data.string_id = IDS_CALL_BODY_CALLENDED;
2165                         break;
2166                 }
2167                 vcall_engine_send_event_to_client(VC_ENGINE_MSG_MESSAGE_BOX_TO_UI, (void *)&event_data);
2168
2169                 _vc_core_util_set_sleep_status(CALL_VC_POWER_GRANT_DIMMING);
2170
2171                 return FALSE;
2172         }
2173
2174         CALL_ENG_DEBUG(ENG_DEBUG, "Call Handle After Setup Call %d.", call_handle);
2175
2176         voicecall_snd_register_cm(pcall_core->papp_snd);
2177
2178         /* Set phonestatus value */
2179         _vc_core_util_set_call_status(VCONFKEY_CALL_VOICE_CONNECTING);
2180
2181         return TRUE;
2182 }
2183
2184 /**
2185  * This function processed sat setup call
2186  *
2187  * @return              Returns TRUE on success or FALSE on failure
2188  * @param[in]           pcall_core              Handle to voicecall core
2189  * @param[in]           
2190 */
2191 gboolean voicecall_core_process_sat_setup_call(vcall_engine_sat_setup_call_info_t *sat_setup_call_info)
2192 {
2193         CALL_ENG_DEBUG(ENG_DEBUG, "");
2194         TelSatSetupCallIndCallData_t *SatSetupCallIndCallInfo = NULL;
2195
2196         SatSetupCallIndCallInfo = (TelSatSetupCallIndCallData_t *) calloc(1, sizeof(TelSatSetupCallIndCallData_t));
2197         if (NULL == SatSetupCallIndCallInfo)
2198                 return FALSE;
2199
2200         SatSetupCallIndCallInfo->commandId = sat_setup_call_info->command_id;
2201         SatSetupCallIndCallInfo->calltype = sat_setup_call_info->command_qualifier;
2202         SatSetupCallIndCallInfo->dispText.stringLen = strlen(sat_setup_call_info->disp_text);
2203         memcpy(SatSetupCallIndCallInfo->dispText.string, sat_setup_call_info->disp_text, strlen(sat_setup_call_info->disp_text));
2204
2205         SatSetupCallIndCallInfo->callNumber.stringLen = strlen(sat_setup_call_info->call_num);
2206         memcpy(SatSetupCallIndCallInfo->callNumber.string, sat_setup_call_info->call_num, strlen(sat_setup_call_info->call_num));
2207
2208         SatSetupCallIndCallInfo->duration = sat_setup_call_info->duration;
2209
2210         _vc_core_engine_handle_sat_events_cb(SatSetupCallIndCallInfo, NULL);
2211
2212         if (SatSetupCallIndCallInfo) {
2213                 free(SatSetupCallIndCallInfo);
2214                 SatSetupCallIndCallInfo = NULL;
2215         }
2216
2217         CALL_ENG_DEBUG(ENG_DEBUG, "End..");
2218
2219         return TRUE;
2220 }
2221
2222 /**
2223  * This function processed incoming call
2224  *
2225  * @return              Returns TRUE on success or FALSE on failure
2226  * @param[in]           pcall_core              Handle to voicecall core
2227  * @param[in]           
2228 */
2229 gboolean voicecall_core_process_incoming_call(call_vc_core_incoming_info_t *incoming_call_info)
2230 {
2231         CALL_ENG_DEBUG(ENG_DEBUG, "");
2232         TelCallIncomingCallInfo_t *IncomingCallInfo = NULL;
2233
2234         CALL_ENG_DEBUG(ENG_DEBUG, " number is : [%s]", incoming_call_info->call_num);
2235
2236         IncomingCallInfo = (TelCallIncomingCallInfo_t *) malloc(sizeof(TelCallIncomingCallInfo_t));
2237         if (NULL == IncomingCallInfo)
2238                 return FALSE;
2239         memset(IncomingCallInfo, 0, sizeof(IncomingCallInfo));
2240
2241         IncomingCallInfo->CallHandle = incoming_call_info->call_handle;
2242         IncomingCallInfo->CallType = incoming_call_info->call_type;
2243         IncomingCallInfo->CliPresentationIndicator = incoming_call_info->cli_presentation_indicator;
2244         _vc_core_util_strcpy(IncomingCallInfo->szCallingPartyNumber, sizeof(IncomingCallInfo->szCallingPartyNumber), incoming_call_info->call_num);
2245         IncomingCallInfo->CallingNameInfo.NameMode = incoming_call_info->calling_name_mode;
2246         _vc_core_util_strcpy(IncomingCallInfo->CallingNameInfo.szNameData, sizeof(IncomingCallInfo->CallingNameInfo.szNameData), incoming_call_info->calling_name);
2247         _vc_core_util_strcpy(IncomingCallInfo->RedirectInfo.szRedirectedNumber, sizeof(IncomingCallInfo->RedirectInfo.szRedirectedNumber), incoming_call_info->redirected_number);
2248         _vc_core_util_strcpy(IncomingCallInfo->RedirectInfo.szRedirectSubAddress, sizeof(IncomingCallInfo->RedirectInfo.szRedirectSubAddress), incoming_call_info->redirected_sub_address);
2249         IncomingCallInfo->CliCause = incoming_call_info->cli_cause;
2250         IncomingCallInfo->fwded = incoming_call_info->bfwded;
2251         IncomingCallInfo->ActiveLine = incoming_call_info->active_line;
2252
2253         _vc_core_engine_handle_incoming_tapi_events(IncomingCallInfo, NULL);
2254
2255         if (IncomingCallInfo) {
2256                 free(IncomingCallInfo);
2257                 IncomingCallInfo = NULL;
2258         }
2259
2260         CALL_ENG_DEBUG(ENG_DEBUG, "End..");
2261
2262         return TRUE;
2263 }
2264
2265 /**
2266  * This function answers an incoming call
2267  *
2268  * @return              Returns TRUE on success or FALSE on failure
2269  * @param[in]           pcall_core              Handle to voicecall core
2270  * @param[in]           
2271 */
2272 gboolean voicecall_core_answer_call(call_vc_core_state_t *pcall_core, gboolean auto_accept)
2273 {
2274         voicecall_engine_t *pcall_engine = pcall_core->pcall_engine;
2275
2276         gboolean active_calls = FALSE;
2277         gboolean held_calls = FALSE;
2278
2279         CALL_ENG_DEBUG(ENG_DEBUG, "");
2280
2281         /*First Stop the Incoming alert */
2282         voicecall_snd_stop_alert(pcall_core->papp_snd);
2283
2284         _vc_core_engine_status_isexists_any_call(pcall_engine, &active_calls, &held_calls);
2285         CALL_ENG_DEBUG(ENG_DEBUG, "active_calls=%d, held_calls=%d", active_calls, held_calls);
2286
2287         if (TRUE == active_calls && TRUE == held_calls) {
2288                 /* Both Active and held calls available, so show Accept Call Choice Box */
2289                 vc_engine_accept_choice_box_type event_data;
2290
2291                 memset(&event_data, 0, sizeof(event_data));
2292                 event_data.choice = VC_CALL_ACCEPT_2;
2293
2294                 vcall_engine_send_event_to_client(VC_ENGINE_MSG_ACCEPT_CHOICE_BOX_TO_UI, (void *)&event_data);
2295
2296                 return TRUE;
2297         } else if (TRUE == active_calls) {
2298                 /*If Auto Accpet is FALSE, show popup for manual accept */
2299                 if (FALSE == auto_accept) {
2300                         /* Active  calls available, so show Accept Call Choice Box */
2301                         vc_engine_accept_choice_box_type event_data;
2302
2303                         memset(&event_data, 0, sizeof(event_data));
2304                         event_data.choice = VC_CALL_ACCEPT_1;
2305
2306                         vcall_engine_send_event_to_client(VC_ENGINE_MSG_ACCEPT_CHOICE_BOX_TO_UI, (void *)&event_data);
2307                 } else {
2308                         voicecall_core_answer_call_bytype(pcall_core, VC_ANSWER_HOLD_ACTIVE_AND_ACCEPT);
2309                 }
2310                 return TRUE;
2311         } else if (TRUE == held_calls) {
2312                 /* vcui_app_view_mtcall_destroy(papp_document); */
2313         }
2314
2315         /* Normal Call Scenario */
2316         voicecall_core_answer_call_bytype(pcall_core, VC_ANSWER_NORMAL);
2317
2318         return TRUE;
2319 }
2320
2321 /**
2322  * This function answers an incoming call  according to the given type
2323  *
2324  * @return              Returns TRUE -if answer is sucess, FALSE - otherwise
2325  * @param[in]           pcall_core              Handle to voicecall core
2326  */
2327 gboolean voicecall_core_answer_call_bytype(call_vc_core_state_t *pcall_core, voicecall_answer_type_t answer_type)
2328 {
2329         voicecall_engine_t *pcall_engine = pcall_core->pcall_engine;
2330
2331         voicecall_error_t error_code = ERROR_VOICECALL_NONE;
2332
2333         CALL_ENG_DEBUG(ENG_DEBUG, "answer type: %d", answer_type);
2334
2335         /*First Stop the Incoming alert */
2336         voicecall_snd_stop_alert(pcall_core->papp_snd);
2337
2338         error_code = _vc_core_engine_answer_call(pcall_engine, answer_type);
2339
2340         if (ERROR_VOICECALL_NONE != error_code) {
2341                 CALL_ENG_DEBUG(ENG_ERR, "_vc_core_engine_answer_call Failed : %d", error_code);
2342                 return FALSE;
2343         }
2344
2345         return TRUE;
2346 }
2347
2348 /**
2349 * This function rejects an incoming call
2350 *
2351 * @return               Returns TRUE on success or FALSE on failure
2352 * @param[in]            pcall_core              Handle to voicecall core
2353 * @param[in]            bUDUB                   TRUE - set UDUB, FALSE - reject call
2354 */
2355 gboolean voicecall_core_reject_mt(call_vc_core_state_t *pcall_core, gboolean bUDUB)
2356 {
2357         voicecall_engine_t *pcall_engine = pcall_core->pcall_engine;
2358         voicecall_snd_mgr_t *papp_snd = pcall_core->papp_snd;
2359
2360         voicecall_error_t error_code = ERROR_VOICECALL_NONE;
2361
2362         CALL_ENG_DEBUG(ENG_DEBUG, "");
2363
2364         /*Incoming call rejected, reset the accept by flag */
2365         voicecall_core_set_status(pcall_core, CALL_VC_CORE_FLAG_ACCEPT_BY_BT, FALSE);
2366
2367         /* Stop Incmoing Call Alert */
2368         voicecall_snd_stop_alert(papp_snd);
2369
2370         CALL_ENG_DEBUG(ENG_DEBUG, "bUDUB = %d", bUDUB);
2371         error_code = _vc_core_engine_reject_call(pcall_engine, bUDUB);
2372
2373         if (ERROR_VOICECALL_NONE != error_code) {
2374                 CALL_ENG_DEBUG(ENG_ERR, "_vc_core_engine_reject_call Failed, error_code = %ud", error_code);
2375                 return FALSE;
2376         }
2377
2378         return TRUE;
2379
2380 }
2381
2382 /**
2383  * This function ends the call by state
2384  *
2385  * @return              Returns TRUE on success or FALSE on failure
2386  * @param[in]           pcall_core              Handle to voicecall core
2387  */
2388 gboolean voicecall_core_end_call(call_vc_core_state_t *pcall_core)
2389 {
2390         voicecall_engine_t *pcall_engine = pcall_core->pcall_engine;
2391
2392         CALL_ENG_DEBUG(ENG_DEBUG, "");
2393
2394         return (ERROR_VOICECALL_NONE == _vc_core_engine_end_call(pcall_engine, VC_END_ACTIVE_OR_HELD_CALLS)) ? TRUE : FALSE;
2395 }
2396
2397 /**
2398  * This function ends the call corresponding to the given call handle
2399  *
2400  * @return              Returns TRUE on success or FALSE on failure
2401  * @param[in]           pcall_core              Handle to voicecall core
2402  * @param[in]           call_handle             handle of the call to be ended
2403  */
2404 gboolean voicecall_core_end_call_by_handle(call_vc_core_state_t *pcall_core, int call_handle)
2405 {
2406         voicecall_engine_t *pcall_engine = pcall_core->pcall_engine;
2407
2408         CALL_ENG_DEBUG(ENG_DEBUG, "");
2409
2410         return (ERROR_VOICECALL_NONE == _vc_core_engine_end_call_byhandle(pcall_engine, call_handle)) ? TRUE : FALSE;
2411 }
2412
2413 /**
2414  * This function ends all available calls
2415  *
2416  * @return              Returns TRUE on success or FALSE on failure
2417  * @param[in]           pcall_core              Handle to voicecall core
2418  */
2419 gboolean voicecall_core_end_all_calls(call_vc_core_state_t *pcall_core)
2420 {
2421         voicecall_engine_t *pcall_engine = pcall_core->pcall_engine;
2422
2423         CALL_ENG_DEBUG(ENG_DEBUG, "");
2424
2425         return (ERROR_VOICECALL_NONE == _vc_core_engine_end_call(pcall_engine, VC_END_ALL_CALLS)) ? TRUE : FALSE;
2426 }
2427
2428 /**
2429  * This function ends all available active calls
2430  *
2431  * @return              Returns TRUE on success or FALSE on failure
2432  * @param[in]           pcall_core              Handle to voicecall core
2433  */
2434 gboolean voicecall_core_end_all_active_calls(call_vc_core_state_t *pcall_core)
2435 {
2436         voicecall_engine_t *pcall_engine = pcall_core->pcall_engine;
2437
2438         CALL_ENG_DEBUG(ENG_DEBUG, "");
2439
2440         return (ERROR_VOICECALL_NONE == _vc_core_engine_end_call(pcall_engine, VC_END_ALL_ACTIVE_CALLS)) ? TRUE : FALSE;
2441 }
2442
2443 /**
2444  * This function ends all available held calls
2445  *
2446  * @return              Returns TRUE on success or FALSE on failure
2447  * @param[in]           pcall_core              Handle to voicecall core
2448  */
2449 gboolean voicecall_core_end_all_held_calls(call_vc_core_state_t *pcall_core)
2450 {
2451         voicecall_engine_t *pcall_engine = pcall_core->pcall_engine;
2452
2453         CALL_ENG_DEBUG(ENG_DEBUG, "");
2454
2455         return (ERROR_VOICECALL_NONE == _vc_core_engine_end_call(pcall_engine, VC_END_ALL_HELD_CALLS)) ? TRUE : FALSE;
2456 }
2457
2458 /**
2459  * This function cancel outgoing call
2460  *
2461  * @return              Returns TRUE -if answer is sucess, FALSE - otherwise
2462  * @param[in]           pcall_core              Handle to voicecall core                
2463  */
2464 gboolean voicecall_core_cancel_call(call_vc_core_state_t *pcall_core)
2465 {
2466         int io_state = 0;
2467         voicecall_engine_t *pcall_engine = pcall_core->pcall_engine;
2468
2469         voicecall_call_type_bysetup_t call_setup_by = VC_CALL_SETUP_BY_NORMAL;
2470
2471         CALL_ENG_DEBUG(ENG_DEBUG, "");
2472
2473         /*Get Call Setup by Information */
2474         call_setup_by = pcall_core->call_setup_info.call_setup_by;
2475
2476         _vc_core_engine_status_get_engine_iostate(pcall_engine, &io_state);
2477
2478         switch (io_state) {
2479         case VC_INOUT_STATE_OUTGOING_WAIT_HOLD:
2480                 {
2481                         int call_handle = -1;
2482
2483                         if (VC_CALL_SETUP_BY_SAT == call_setup_by) {
2484                                 _vc_core_engine_send_sat_response(pcall_engine, SAT_RQST_SETUP_CALL, CALL_VC_ME_CLEAR_DOWN_BEFORE_CONN);
2485                         }
2486
2487                         /* Clear the MO Call, since the call is not dialed yet */
2488                         _vc_core_engine_status_get_call_handle_bytype(pcall_engine, VC_OUTGOING_CALL, &call_handle);
2489                         _vc_bt_send_response_to_bt(pcall_core, BT_AG_RES_CALL_END, call_handle, NULL);
2490
2491                         __vc_core_set_auto_redial_count(pcall_core, 0);
2492                         voicecall_core_clear_mo_call(pcall_engine);
2493
2494                         _vc_core_engine_change_engine_iostate(pcall_engine, VC_INOUT_STATE_OUTGOING_ABORTED);
2495                 }
2496                 return TRUE;
2497
2498         case VC_INOUT_STATE_OUTGOING_WAIT_ORIG:
2499         case VC_INOUT_STATE_OUTGOING_WAIT_ALERT:
2500         case VC_INOUT_STATE_OUTGOING_WAIT_CONNECTED:
2501                 {
2502                         /*To retrieve the held call automatically once the mo call is ended, if held is call is available */
2503                         _vc_core_engine_status_set_end_flag(pcall_engine, VC_RETREIVE_CALL_ON_MOCALL_END);
2504
2505                         /* release the call , since it is dialed and waiting for connecting */
2506                         if (FALSE == voicecall_core_end_mo_call(pcall_engine)) {
2507                                 CALL_ENG_DEBUG(ENG_DEBUG, "MO Call Release Failed");
2508                         } else {
2509                                 voicecall_core_set_status(pcall_core, CALL_VC_CORE_FLAG_MOCALL_END_BY_USER, TRUE);
2510                                 _vc_core_engine_change_engine_iostate(pcall_engine, VC_INOUT_STATE_OUTGOING_WAIT_RELEASE);
2511                         }
2512                 }
2513                 return TRUE;
2514
2515         case VC_INOUT_STATE_OUTGOING_WAIT_RELEASE:
2516                 {
2517                         /*Call already released */
2518                         CALL_ENG_DEBUG(ENG_DEBUG, "MO Call has been released already");
2519                 }
2520                 return TRUE;
2521
2522         case VC_INOUT_STATE_OUTGOING_SHOW_REDIALCAUSE:
2523         case VC_INOUT_STATE_OUTGOING_ABORTED:
2524         case VC_INOUT_STATE_OUTGOING_WAIT_REDIAL:
2525                 {
2526                         int call_handle = -1;
2527
2528                         if (VC_CALL_SETUP_BY_SAT == call_setup_by) {
2529                                 _vc_core_engine_send_sat_response(pcall_engine, SAT_RQST_SETUP_CALL, CALL_VC_NETWORK_UNABLE_TO_PROCESS_COMMAND);
2530                         }
2531
2532                         /*Stop Signal Play */
2533                         voicecall_snd_stop_signal(pcall_core->papp_snd);
2534
2535                         __voicecall_core_mocall_reset_engine_state(pcall_engine);
2536
2537                         _vc_core_engine_status_get_call_handle_bytype(pcall_engine, VC_OUTGOING_CALL, &call_handle);
2538                         _vc_bt_send_response_to_bt(pcall_core, BT_AG_RES_CALL_END, call_handle, NULL);
2539
2540                         __vc_core_set_auto_redial_count(pcall_core, 0);
2541                         voicecall_core_clear_mo_call(pcall_engine);
2542
2543                 }
2544                 return TRUE;
2545
2546         default:
2547                 CALL_ENG_DEBUG(ENG_DEBUG, "Action not defined for this IO State: %d", io_state);
2548                 break;
2549         }
2550
2551         return FALSE;
2552 }
2553
2554 /**
2555  * This function process hold/retrive/swap conntected call
2556  *
2557  * @return              Returns TRUE -if answer is sucess, FALSE - otherwise
2558  * @param[in]           pcall_core              Handle to voicecall core                
2559  */
2560 gboolean voicecall_core_process_hold_call(call_vc_core_state_t *pcall_core)
2561 {
2562         voicecall_engine_t *pcall_engine = pcall_core->pcall_engine;
2563
2564         gboolean active_calls = FALSE;
2565         gboolean held_calls = FALSE;
2566
2567         CALL_ENG_DEBUG(ENG_DEBUG, "");
2568
2569         if (TRUE == voicecall_core_get_status(pcall_core, CALL_VC_CORE_FLAG_SOS_CALL_ONLY)) {
2570                 CALL_ENG_DEBUG(ENG_DEBUG, "SOS Call... Ignore this button...");
2571                 return TRUE;
2572         }
2573
2574         if (FALSE == voicecall_core_is_incall_request_possible(pcall_engine)) {
2575                 return TRUE;
2576         }
2577
2578         voicecall_core_is_call_exists(pcall_engine, &active_calls, &held_calls);
2579         CALL_ENG_DEBUG(ENG_DEBUG, "active calls: %d, held calls: %d", active_calls, held_calls);
2580
2581         if (active_calls && held_calls) {
2582                 /*Both Calls available, swap the calls */
2583                 if (FALSE == voicecall_core_swap_calls(pcall_engine)) {
2584                         return FALSE;
2585                 }
2586         } else if (active_calls) {
2587                 /*Only activa call available, hold the call */
2588                 if (FALSE == voicecall_core_hold_call(pcall_engine)) {
2589                         return FALSE;
2590                 }
2591         } else if (held_calls) {
2592                 /*Only Held call available, retrieve the call */
2593                 if (FALSE == voicecall_core_retrieve_call(pcall_engine)) {
2594                         return FALSE;
2595                 }
2596         } else {
2597                 CALL_ENG_DEBUG(ENG_DEBUG, "no call exists!");
2598                 return FALSE;
2599         }
2600
2601         return TRUE;
2602 }
2603
2604 /**
2605  * This function sets up a conference call
2606  *
2607  * @return              Returns TRUE on success or FALSE on failure
2608  * @param[in]           pcall_core              Handle to voicecall core                
2609  */
2610 gboolean voicecall_core_setup_conference(call_vc_core_state_t *pcall_core)
2611 {
2612         voicecall_engine_t *pcall_engine = pcall_core->pcall_engine;
2613
2614         CALL_ENG_DEBUG(ENG_DEBUG, "");
2615
2616         PRINT_CURRENT_TIME("Setup Conf Start at");
2617         return (ERROR_VOICECALL_NONE == _vc_core_engine_setup_conference(pcall_engine)) ? TRUE : FALSE;
2618 }
2619
2620 /**
2621  * This function splits the call corressponding to the given call handle and makes a private call
2622  *
2623  * @return              Returns TRUE on success or FALSE on failure
2624  * @param[in]           pcall_core              Handle to voicecall core                
2625  * @param[in]           call_handle             Call to be splitted from the conference call
2626  */
2627 gboolean voicecall_core_make_private_call(call_vc_core_state_t *pcall_core, int call_handle)
2628 {
2629         voicecall_engine_t *pcall_engine = pcall_core->pcall_engine;
2630
2631         CALL_ENG_DEBUG(ENG_DEBUG, "");
2632
2633         PRINT_CURRENT_TIME("Split Conf Start at");
2634         return (ERROR_VOICECALL_NONE == _vc_core_engine_private_call(pcall_engine, call_handle)) ? TRUE : FALSE;
2635 }
2636
2637 /**
2638  * This function transfers the call from active call to the held call
2639  *
2640  * @return              Returns TRUE on success or FALSE on failure
2641  * @param[in]           pcall_core              Handle to voicecall core                
2642  */
2643 gboolean voicecall_core_transfer_calls(call_vc_core_state_t *pcall_core)
2644 {
2645         voicecall_engine_t *pcall_engine = pcall_core->pcall_engine;
2646
2647         CALL_ENG_DEBUG(ENG_DEBUG, "");
2648
2649         return (ERROR_VOICECALL_NONE == _vc_core_engine_transfer_calls(pcall_engine)) ? TRUE : FALSE;
2650 }
2651
2652 /**
2653  * This function sends a dtmf string
2654  *
2655  * @return              Returns TRUE on success or FALSE on failure
2656  * @param[in]           pcall_core              Handle to voicecall core                
2657  * @param[in]           dtmf_string             dtmf string to be sent
2658  */
2659 gboolean voicecall_core_send_dtmf(call_vc_core_state_t *pcall_core, char *dtmf_string)
2660 {
2661         voicecall_error_t error_code = ERROR_VOICECALL_NONE;
2662         CALL_ENG_DEBUG(ENG_DEBUG, "dtmf string: %s", dtmf_string);
2663
2664         pcall_core->bdtmf_queue = FALSE;
2665         error_code = _vc_core_engine_send_dtmf(pcall_core->pcall_engine, dtmf_string);
2666         return (ERROR_VOICECALL_NONE == error_code) ? TRUE : FALSE;
2667 }
2668
2669 /**
2670 * This function stops sound alert
2671 *
2672 * @return               Returns TRUE on success or FALSE on failure
2673 * @param[in]            pcall_core              Handle to voicecall core
2674 */
2675 gboolean voicecall_core_stop_alert(call_vc_core_state_t *pcall_core)
2676 {
2677         CALL_ENG_DEBUG(ENG_DEBUG, "");
2678
2679         /* Stop Incmoing Call Alert */
2680         voicecall_snd_stop_alert(pcall_core->papp_snd);
2681
2682         return TRUE;
2683 }
2684
2685 inline gboolean voicecall_core_get_mo_call_handle(call_vc_core_state_t *pcall_core, int *pcall_handle)
2686 {
2687         *pcall_handle = -1;
2688         return (ERROR_VOICECALL_NONE == _vc_core_engine_status_get_call_handle_bytype(pcall_core->pcall_engine, VC_OUTGOING_CALL, pcall_handle)) ? TRUE : FALSE;
2689 }
2690
2691 inline int voicecall_core_get_auto_redial_count(call_vc_core_state_t *pcall_core)
2692 {
2693         return pcall_core->auto_redial_count;
2694 }
2695
2696 void __vc_core_set_auto_redial_count(call_vc_core_state_t *pcall_core, int auto_redial_count)
2697 {
2698         pcall_core->auto_redial_count = auto_redial_count;
2699 }
2700
2701 gboolean voicecall_core_start_redial(call_vc_core_state_t *pcall_core, int manual_redial)
2702 {
2703         int auto_redial_status = FALSE;
2704         int redial_count = 1;
2705         int call_handle = -1;
2706         int total_call_member = 0;
2707
2708         CALL_ENG_DEBUG(ENG_DEBUG, "");
2709
2710         if (vconf_get_bool(VCONFKEY_CISSAPPL_VOICE_AUTO_REDIAL_BOOL, &auto_redial_status)) {
2711                 CALL_ENG_DEBUG(ENG_ERR, "vconf_get_bool failed.");
2712         }
2713
2714         CALL_ENG_DEBUG(ENG_DEBUG, "auto_redial_status:[%d]", auto_redial_status);
2715
2716         redial_count = voicecall_core_get_auto_redial_count(pcall_core);
2717
2718         redial_count++;
2719
2720         /*
2721            bmanual_redial == TRUE : Redial is made by User, No need to check the auto redial status and count
2722            auto_redial_status == 1: Auto Redial for GCF case, auto redial count must be checked
2723          */
2724         if ((1 == manual_redial) || ((auto_redial_status == 1) && (redial_count < MO_REDIAL_COUNT_MAX))) {
2725                 CALL_ENG_DEBUG(ENG_DEBUG, "redial_count = %d", redial_count);
2726
2727                 /*Start Redial Timer */
2728                 if (1 == redial_count) {
2729                         CALL_ENG_DEBUG(ENG_DEBUG, "MO_REDIAL_TIMER_INTERVAL_FIRST");
2730                         pcall_core->mo_redial_timer = g_timeout_add(MO_REDIAL_TIMER_INTERVAL_FIRST, mo_redial_timer_cb, pcall_core);
2731                 } else if ((redial_count > 1) && (redial_count < 5)) {
2732                         CALL_ENG_DEBUG(ENG_DEBUG, "MO_REDIAL_TIMER_INTERVAL_SECOND");
2733                         pcall_core->mo_redial_timer = g_timeout_add(MO_REDIAL_TIMER_INTERVAL_SECOND, mo_redial_timer_cb, pcall_core);
2734                 } else {
2735                         CALL_ENG_DEBUG(ENG_DEBUG, "MO_REDIAL_TIMER_INTERVAL_THIRD");
2736                         pcall_core->mo_redial_timer = g_timeout_add(MO_REDIAL_TIMER_INTERVAL_THIRD, mo_redial_timer_cb, pcall_core);
2737                 }
2738
2739                 voicecall_core_change_engine_state(pcall_core->pcall_engine, VC_INOUT_STATE_OUTGOING_WAIT_REDIAL);
2740         } else {
2741                 CALL_ENG_DEBUG(ENG_DEBUG, "You dont need to redial close the MO Call Things");
2742
2743                 voicecall_snd_change_mm_path(pcall_core->papp_snd, VOICE_CALL_MM_RESET);
2744
2745                 /* __vcui_app_view_mo_canceltimer_cb() */
2746                 _vc_core_engine_status_get_call_handle_bytype(pcall_core->pcall_engine, VC_OUTGOING_CALL, &call_handle);
2747                 _vc_bt_send_response_to_bt(pcall_core, BT_AG_RES_CALL_END, call_handle, NULL);
2748
2749                 __vc_core_set_auto_redial_count(pcall_core, 0);
2750                 voicecall_core_clear_mo_call(pcall_core->pcall_engine);
2751
2752                 __voicecall_core_mocall_reset_engine_state(pcall_core->pcall_engine);
2753
2754                 voicecall_core_get_total_call_member(pcall_core->pcall_engine, &total_call_member);
2755
2756                 voicecall_snd_stop_signal(pcall_core->papp_snd);
2757
2758                 /* If No Connected Calls End the UI */
2759                 if (total_call_member == 0) {
2760                         /*Reset voice call core to default values */
2761                         voicecall_core_set_to_default(pcall_core);
2762                 } else {
2763                         voicecall_snd_change_path(pcall_core->papp_snd);
2764                 }
2765
2766         }
2767
2768         return TRUE;
2769 }
2770
2771 inline gboolean voicecall_core_prepare_redial(call_vc_core_state_t *pcall_core, int call_handle)
2772 {
2773         voicecall_error_t error_code = ERROR_VOICECALL_NONE;
2774
2775         CALL_ENG_DEBUG(ENG_DEBUG, "");
2776
2777         error_code = _vc_core_engine_prepare_redial(pcall_core->pcall_engine, call_handle);
2778
2779         CALL_ENG_DEBUG(ENG_DEBUG, "_vc_core_engine_prepare_redial returned : %d", error_code);
2780
2781         return (ERROR_VOICECALL_NONE == error_code) ? TRUE : FALSE;
2782 }
2783
2784 gboolean mo_redial_timer_cb(void *data)
2785 {
2786         int call_handle = -1;
2787         int redial_count;
2788
2789         CALL_ENG_DEBUG(ENG_DEBUG, "mo_redial_timer_cb");
2790         call_vc_core_state_t *pcall_core = (call_vc_core_state_t *)data;
2791         voicecall_core_get_mo_call_handle(pcall_core, &call_handle);
2792         CALL_ENG_DEBUG(ENG_DEBUG, "call handle is %d", call_handle);
2793
2794         redial_count = voicecall_core_get_auto_redial_count(pcall_core);
2795         redial_count++;
2796         __vc_core_set_auto_redial_count(pcall_core, redial_count);
2797
2798         CALL_ENG_DEBUG(ENG_DEBUG, "redial_count:[%d]", redial_count);
2799
2800         voicecall_core_prepare_redial(pcall_core, call_handle);
2801         CALL_ENG_DEBUG(ENG_DEBUG, "voicecall_core_prepare_redial done.");
2802
2803         voicecall_core_make_call(pcall_core);
2804         return FALSE;
2805 }
2806
2807 gboolean voicecall_core_stop_redial(call_vc_core_state_t *pcall_core)
2808 {
2809         int call_handle = -1, total_call_member = -1;
2810
2811         CALL_ENG_DEBUG(ENG_DEBUG, "coming inside voicecall_core_stop_redial");
2812
2813         voicecall_snd_change_mm_path(pcall_core->papp_snd, VOICE_CALL_MM_RESET);
2814         _vc_core_util_set_call_status(VCONFKEY_CALL_OFF);
2815
2816         /*Cancel the Redial Timer */
2817         if (pcall_core->mo_redial_timer != -1) {
2818                 CALL_ENG_DEBUG(ENG_DEBUG, "mo_redial_timer removing..");
2819                 g_source_remove(pcall_core->mo_redial_timer);
2820                 pcall_core->mo_redial_timer = -1;
2821         }
2822
2823         /* __vcui_app_view_mo_canceltimer_cb() */
2824         _vc_core_engine_status_get_call_handle_bytype(pcall_core->pcall_engine, VC_OUTGOING_CALL, &call_handle);
2825         _vc_bt_send_response_to_bt(pcall_core, BT_AG_RES_CALL_END, call_handle, NULL);
2826
2827         __vc_core_set_auto_redial_count(pcall_core, 0);
2828         voicecall_core_clear_mo_call(pcall_core->pcall_engine);
2829
2830         __voicecall_core_mocall_reset_engine_state(pcall_core->pcall_engine);
2831
2832         voicecall_core_get_total_call_member(pcall_core->pcall_engine, &total_call_member);
2833
2834         voicecall_snd_stop_signal(pcall_core->papp_snd);
2835
2836         /* If No Connected Calls End the UI */
2837         if (total_call_member == 0) {
2838                 /*Reset voice call core to default values */
2839                 voicecall_core_set_to_default(pcall_core);
2840         } else {
2841                 voicecall_snd_change_path(pcall_core->papp_snd);
2842         }
2843         return TRUE;
2844
2845 }
2846
2847 static gboolean __voicecall_core_auto_answer_timer_cb(gpointer puser_data)
2848 {
2849         call_vc_core_state_t *pcall_core = (call_vc_core_state_t *)puser_data;
2850
2851         if (pcall_core->auto_answer_timer > 0) {
2852                 g_source_remove(pcall_core->auto_answer_timer);
2853                 pcall_core->auto_answer_timer = 0;
2854         }
2855
2856         /*Check for Incoming call and then answer the call */
2857         if (TRUE == voicecall_core_is_incoming_call_exists(pcall_core->pcall_engine)) {
2858                 CALL_ENG_DEBUG(ENG_DEBUG, "Call Answered");
2859                 voicecall_core_answer_call(pcall_core, TRUE);
2860         }
2861
2862         return FALSE;
2863 }
2864
2865 static gboolean __voicecall_core_callstatus_set_timer_cb(gpointer puser_data)
2866 {
2867         call_vc_core_state_t *pcall_core = (call_vc_core_state_t *)puser_data;
2868
2869         if (pcall_core->callstatus_timer > 0) {
2870                 g_source_remove(pcall_core->callstatus_timer);
2871                 pcall_core->callstatus_timer = 0;
2872         }
2873
2874         _vc_core_util_set_call_status(VCONFKEY_CALL_VOICE_CONNECTING);
2875
2876         return FALSE;
2877 }
2878
2879 static gboolean __voicecall_core_auto_answer_idle_cb(gpointer puser_data)
2880 {
2881         call_vc_core_state_t *pcall_core = (call_vc_core_state_t *)puser_data;
2882         int engine_state = 0;
2883         int auto_answer_time = 0, ret = -1;
2884         unsigned long auto_answer_time_interval = 0;
2885
2886         _vc_core_engine_status_get_engine_iostate(pcall_core->pcall_engine, &engine_state);
2887         CALL_ENG_DEBUG(ENG_DEBUG, "eng_state : %d", engine_state);
2888         if (engine_state != VC_INOUT_STATE_INCOME_BOX) {
2889                 CALL_ENG_DEBUG(ENG_DEBUG, "Engine State not in Income Box, Current State: %d", engine_state);
2890                 return FALSE;
2891         }
2892         /* Read the time interval from gconf and set the redial timer  */
2893         ret = vconf_get_int(VCONFKEY_CISSAPPL_ANSWERING_MODE_TIME_INT, &auto_answer_time);
2894         if (0 == ret) {
2895                 auto_answer_time_interval = auto_answer_time * 1000;
2896                 CALL_ENG_DEBUG(ENG_DEBUG, "The time interval is : %ld", auto_answer_time_interval);
2897         } else {
2898                 CALL_ENG_DEBUG(ENG_DEBUG, "vconf_get_int FAILED");
2899                 return FALSE;
2900         }
2901
2902         pcall_core->auto_answer_timer = g_timeout_add(auto_answer_time_interval, __voicecall_core_auto_answer_timer_cb, pcall_core);
2903         return FALSE;
2904 }
2905
2906 /**
2907 * This function checks BT headset and Earjack status
2908 *
2909 * @return               void
2910 * @param[in]            pcall_core              Handle to voicecall core
2911 */
2912 static void __voicecall_core_check_headset_earjack_status(call_vc_core_state_t *pcall_core)
2913 {
2914         gboolean bt_connected = FALSE;
2915
2916         bt_connected = _vc_bt_get_bt_status();
2917         CALL_ENG_DEBUG(ENG_DEBUG, "Bt connected =%d", bt_connected);
2918
2919         pcall_core->bt_connected = bt_connected;
2920 #ifdef _NEW_SND_
2921 #else
2922         voicecall_snd_set_status(pcall_core->papp_snd, VOICE_CALL_AUDIO_HEADSET, bt_connected);
2923 #endif
2924
2925         CALL_ENG_DEBUG(ENG_DEBUG, "Update the earjack status");
2926         _voicecall_dvc_get_earjack_status(pcall_core);
2927 }
2928
2929 /**
2930  * This function parses the in call supplementary services string and returns the in call ss to be used
2931  *
2932  * @return              Returns in call ss state #vcui_app_incall_ss_state_t
2933  * @param[in]           pcall_core              Handle to voicecall core
2934  * @param[in]           number                  number to be parsed
2935  */
2936 call_vc_core_incall_ss_state_t voicecall_core_parse_incall_ss_string(call_vc_core_state_t *pcall_core, char *number)
2937 {
2938         call_vc_core_incall_ss_state_t ss_value = CALL_VC_CORE_SS_USSD;
2939
2940         if (strlen(number) == 1) {
2941                 switch (number[0]) {
2942                 case '0':
2943                         ss_value = CALL_VC_CORE_SS_0;
2944                         break;
2945                 case '1':
2946                         ss_value = CALL_VC_CORE_SS_1;
2947                         break;
2948                 case '2':
2949                         ss_value = CALL_VC_CORE_SS_2;
2950                         break;
2951                 case '3':
2952                         ss_value = CALL_VC_CORE_SS_3;
2953                         break;
2954                 case '4':
2955                         ss_value = CALL_VC_CORE_SS_4;
2956                         break;
2957                 default:
2958                         ss_value = CALL_VC_CORE_SS_USSD;
2959                         break;
2960                 }
2961         } else if (strlen(number) == 2) {
2962                 if ((number[0] == '1') && (number[1] > '0') && (number[1] < '8')) {
2963                         pcall_core->selected_call_id_in_ss = atoi(number + 1);
2964                         ss_value = CALL_VC_CORE_SS_1X;
2965                 }
2966
2967                 if ((number[0] == '2') && (number[1] > '0') && (number[1] < '8')) {
2968                         pcall_core->selected_call_id_in_ss = atoi(number + 1);
2969                         ss_value = CALL_VC_CORE_SS_2X;
2970                 }
2971         }
2972         CALL_ENG_DEBUG(ENG_DEBUG, "ss parsed value: %d", ss_value);
2973         return ss_value;
2974 }
2975
2976 /**
2977  * This function starts the supplementary services while on call
2978  *
2979  * @return              Returns TRUE If transfer call can be made or FALSE if not
2980  * @param[in]           pcall_core              Handle to voicecall core
2981  * @param[in]           incall_ss_state         state of the In Call Supplementary Service
2982  */
2983 gboolean voicecall_core_start_incall_ss(call_vc_core_state_t *pcall_core, call_vc_core_incall_ss_state_t incall_ss_state)
2984 {
2985         gboolean active_calls = FALSE, held_calls = FALSE;
2986
2987         _vc_core_engine_status_isexists_any_call(pcall_core->pcall_engine, &active_calls, &held_calls);
2988
2989         CALL_ENG_DEBUG(ENG_DEBUG, "ss state = %d", incall_ss_state);
2990         vc_engine_msg_box_type event_data;
2991         memset(&event_data, 0, sizeof(event_data));
2992         event_data.string_id = IDS_CALL_POP_OPERATION_REFUSED;
2993
2994         /*Cancel DTMF Sending if any and close the dtmf ui */
2995         /* vcui_app_doc_cancel_dtmf_queue(papp_document); sathwick TBD */
2996
2997         switch (incall_ss_state) {
2998                 /* Releases all held calls or Set UDUB(User Determined User Busy) for a waiting call */
2999         case CALL_VC_CORE_SS_0:
3000                 {
3001                         /* if an incoming call is activated, reject the incoming all  */
3002                         if (TRUE == voicecall_core_is_incoming_call_exists(pcall_core->pcall_engine)) {
3003                                 voicecall_core_reject_mt(pcall_core, TRUE);
3004                                 return TRUE;
3005                         } else if (held_calls) {
3006                                 voicecall_core_end_all_held_calls(pcall_core);
3007                         } else {
3008                                 CALL_ENG_DEBUG(ENG_DEBUG, "There are no held calls to do the processing");
3009                                 vcall_engine_send_event_to_client(VC_ENGINE_MSG_MESSAGE_BOX_TO_UI, (void *)&event_data);
3010                                 CALL_ENG_DEBUG(ENG_DEBUG, "Need to show a popup to the user ");
3011                         }
3012                 }
3013                 break;
3014         case CALL_VC_CORE_SS_1:
3015                 {
3016                         if (voicecall_core_is_incoming_call_exists(pcall_core->pcall_engine)) {
3017                                 /* Accept incoming call */
3018                                 voicecall_core_answer_call_bytype(pcall_core, VC_ANSWER_RELEASE_ACTIVE_AND_ACCEPT);
3019                                 return TRUE;
3020                         } else if (voicecall_core_is_outgoing_call_exists(pcall_core->pcall_engine)) {
3021                                 /* This fucntion checks for held calls to be retreived on response of ending call */
3022                                 voicecall_core_set_check_ss_on_end(pcall_core);
3023                                 voicecall_core_end_mo_call(pcall_core->pcall_engine);
3024                         } else if (active_calls) {
3025                                 voicecall_core_end_all_active_calls(pcall_core);
3026                                 voicecall_core_set_check_ss_on_end(pcall_core);
3027                         } else if (held_calls) {
3028                                 _vc_core_engine_retrieve_call(pcall_core->pcall_engine);
3029                         } else {
3030
3031                                 CALL_ENG_DEBUG(ENG_DEBUG, "Need to show a popup to the user ");
3032                                 vcall_engine_send_event_to_client(VC_ENGINE_MSG_MESSAGE_BOX_TO_UI, (void *)&event_data);
3033                         }
3034                 }
3035                 break;
3036         case CALL_VC_CORE_SS_1X:
3037                 {
3038                         if (voicecall_core_is_incoming_call_exists(pcall_core->pcall_engine)) {
3039
3040                                 CALL_ENG_DEBUG(ENG_DEBUG, "Need to show a popup to the user ");
3041                                 vcall_engine_send_event_to_client(VC_ENGINE_MSG_MESSAGE_BOX_TO_UI, (void *)&event_data);
3042                         } else if (active_calls) {
3043
3044                                 if (!(ERROR_VOICECALL_NONE == _vc_core_engine_end_call_bycallId(pcall_core->pcall_engine, pcall_core->selected_call_id_in_ss))) {
3045
3046                                         CALL_ENG_DEBUG(ENG_DEBUG, "Need to show a popup to the user ");
3047                                         vcall_engine_send_event_to_client(VC_ENGINE_MSG_MESSAGE_BOX_TO_UI, (void *)&event_data);
3048                                 }
3049                         } else {
3050
3051                                 CALL_ENG_DEBUG(ENG_DEBUG, "Need to show a popup to the user ");
3052                                 vcall_engine_send_event_to_client(VC_ENGINE_MSG_MESSAGE_BOX_TO_UI, (void *)&event_data);
3053                         }
3054                 }
3055                 break;
3056         case CALL_VC_CORE_SS_2:
3057                 {
3058
3059                         if (voicecall_core_is_incoming_call_exists(pcall_core->pcall_engine)) {
3060                                 if (active_calls && held_calls) {
3061
3062                                         CALL_ENG_DEBUG(ENG_DEBUG, "Need to show a popup to the user ");
3063                                         vcall_engine_send_event_to_client(VC_ENGINE_MSG_MESSAGE_BOX_TO_UI, (void *)&event_data);
3064                                 } else {
3065 #ifdef _CPHS_DEFINED_           /* Not used currently */
3066                                         if (TRUE == active_calls && (voicecall_core_get_cphs_csp_status(pcall_core->pcall_engine, VC_CPHS_CSP_HOLD))) {
3067
3068                                                 CALL_ENG_DEBUG(ENG_DEBUG, "Need to show a popup to the user ");
3069                                                 vcall_engine_send_event_to_client(VC_ENGINE_MSG_MESSAGE_BOX_TO_UI, (void *)&event_data);
3070                                                 break;
3071                                         }
3072 #endif
3073                                         voicecall_core_answer_call(pcall_core, TRUE);
3074                                 }
3075                         } else if (voicecall_core_is_outgoing_call_exists(pcall_core->pcall_engine)) {
3076
3077                                 CALL_ENG_DEBUG(ENG_DEBUG, "Need to show a popup to the user ");
3078                                 vcall_engine_send_event_to_client(VC_ENGINE_MSG_MESSAGE_BOX_TO_UI, (void *)&event_data);
3079                         } else if (active_calls && held_calls) {
3080                                 _vc_core_engine_swap_calls(pcall_core->pcall_engine);
3081                         } else if (active_calls) {
3082                                 _vc_core_engine_hold_call(pcall_core->pcall_engine);
3083                         } else if (held_calls) {
3084                                 _vc_core_engine_retrieve_call(pcall_core->pcall_engine);
3085                         } else {
3086
3087                                 CALL_ENG_DEBUG(ENG_DEBUG, "Need to show a popup to the user ");
3088                                 vcall_engine_send_event_to_client(VC_ENGINE_MSG_MESSAGE_BOX_TO_UI, (void *)&event_data);
3089                         }
3090                 }
3091                 break;
3092         case CALL_VC_CORE_SS_2X:
3093                 {
3094                         if (voicecall_core_is_incoming_call_exists(pcall_core->pcall_engine) || voicecall_core_is_outgoing_call_exists(pcall_core->pcall_engine)) {
3095
3096                                 vcall_engine_send_event_to_client(VC_ENGINE_MSG_MESSAGE_BOX_TO_UI, (void *)&event_data);
3097                                 CALL_ENG_DEBUG(ENG_DEBUG, "Need to show a popup to the user ");
3098                         } else if (TRUE == active_calls && FALSE == held_calls) {
3099                                 int active_members = 0;
3100
3101                                 voicecall_core_get_active_call_member(pcall_core, &active_members);
3102
3103                                 if (!(active_members > 1 && (ERROR_VOICECALL_NONE == _vc_core_engine_private_call_by_callid(pcall_core->pcall_engine, pcall_core->selected_call_id_in_ss)))) {
3104
3105                                         CALL_ENG_DEBUG(ENG_DEBUG, "Need to show a popup to the user ");
3106                                         vcall_engine_send_event_to_client(VC_ENGINE_MSG_MESSAGE_BOX_TO_UI, (void *)&event_data);
3107                                 }
3108                         } else {
3109
3110                                 CALL_ENG_DEBUG(ENG_DEBUG, "Need to show a popup to the user ");
3111                                 vcall_engine_send_event_to_client(VC_ENGINE_MSG_MESSAGE_BOX_TO_UI, (void *)&event_data);
3112                         }
3113                 }
3114                 break;
3115         case CALL_VC_CORE_SS_3:
3116                 {
3117                         if (TRUE == voicecall_core_is_incoming_call_exists(pcall_core->pcall_engine)) {
3118
3119                                 CALL_ENG_DEBUG(ENG_DEBUG, "Need to show a popup to the user ");
3120                                 vcall_engine_send_event_to_client(VC_ENGINE_MSG_MESSAGE_BOX_TO_UI, (void *)&event_data);
3121                                 return TRUE;
3122                         }
3123
3124                         if (TRUE == voicecall_core_is_conf_call_possible(pcall_core)) {
3125                                 _vc_core_engine_setup_conference(pcall_core->pcall_engine);
3126                         } else {
3127
3128                                 CALL_ENG_DEBUG(ENG_DEBUG, "Need to show a popup to the user ");
3129                                 vcall_engine_send_event_to_client(VC_ENGINE_MSG_MESSAGE_BOX_TO_UI, (void *)&event_data);
3130                         }
3131                 }
3132                 break;
3133         case CALL_VC_CORE_SS_4:
3134                 if (TRUE == voicecall_core_is_transfer_call_possible(pcall_core)) {
3135                         if (FALSE == voicecall_core_transfer_calls(pcall_core)) {
3136
3137                                 CALL_ENG_DEBUG(ENG_DEBUG, "Need to show a popup to the user ");
3138                                 vcall_engine_send_event_to_client(VC_ENGINE_MSG_MESSAGE_BOX_TO_UI, (void *)&event_data);
3139                         }
3140                 } else {
3141
3142                         CALL_ENG_DEBUG(ENG_DEBUG, "Need to show a popup to the user ");
3143                         vcall_engine_send_event_to_client(VC_ENGINE_MSG_MESSAGE_BOX_TO_UI, (void *)&event_data);
3144                 }
3145                 /*
3146                 if ( !(vcui_app_doc_is_transfer_call_possible(papp_document) && TRUE == vcui_app_doc_transfer_calls(papp_document)) )
3147                 {
3148                         vcui_app_msgbox(papp_document, vcui_app_rsr_load_string(IDS_CALL_POP_OPERATION_REFUSED),GTK_MESSAGE_ALERT);
3149                 }
3150                 */
3151                 break;
3152         default:
3153                 CALL_ENG_DEBUG(ENG_DEBUG, "Invalid SS State");
3154                 CALL_ENG_DEBUG(ENG_DEBUG, "Need to show a popup to the user ");
3155                 vcall_engine_send_event_to_client(VC_ENGINE_MSG_MESSAGE_BOX_TO_UI, (void *)&event_data);
3156         }
3157         return TRUE;
3158 }
3159
3160 /**
3161  * This function processed the supplementary services while on call
3162  *
3163  * @return              Returns TRUE If transfer call can be made or FALSE if not
3164  * @param[in]           pcall_core              Handle to voicecall core
3165  * @param[in]           pdialled_number         dial number
3166  */
3167 void voicecall_core_process_incall_ss(call_vc_core_state_t *pcall_core, char *pdialled_number)
3168 {
3169         call_vc_core_incall_ss_state_t incall_ss_state = CALL_VC_CORE_SS_NONE;
3170
3171         CALL_ENG_DEBUG(ENG_DEBUG, " ..");
3172
3173         incall_ss_state = voicecall_core_parse_incall_ss_string(pcall_core, pdialled_number);
3174
3175         if (incall_ss_state != CALL_VC_CORE_SS_USSD) {
3176                 voicecall_core_start_incall_ss(pcall_core, incall_ss_state);
3177         } else {
3178
3179                 CALL_ENG_DEBUG(ENG_DEBUG, "Involves CISS functionality so need for us to handle and will be handled by CISS");
3180                 vc_engine_msg_box_type event_data;
3181                 memset(&event_data, 0, sizeof(event_data));
3182                 event_data.string_id = IDS_CALL_POP_OPERATION_REFUSED;
3183                 vcall_engine_send_event_to_client(VC_ENGINE_MSG_MESSAGE_BOX_TO_UI, (void *)&event_data);
3184         }
3185 }
3186
3187 #ifdef  PDIAL_SEND_DTMF
3188 gboolean voicecall_core_send_phone_number_dtmf(gpointer puser_data)
3189 {
3190         call_vc_core_state_t *pcall_core = (call_vc_core_state_t *)vcall_engine_get_core_state();
3191         int call_handle = (int)puser_data;
3192         char dtmf_number[VC_PHONE_NUMBER_LENGTH_MAX];
3193         call_vc_call_objectinfo_t obj_info = { 0, };
3194
3195         CALL_ENG_DEBUG(ENG_DEBUG, "inside ...");
3196
3197         if (TRUE == _vc_core_cm_get_call_object(&pcall_core->pcall_engine->call_manager, call_handle, &obj_info)) {
3198                 CALL_ENG_DEBUG(ENG_DEBUG, "Source telephone number - %s", obj_info.source_tel_number);
3199                 if (TRUE == _vc_core_util_extract_dtmf_number(obj_info.source_tel_number, dtmf_number, sizeof(dtmf_number))) {
3200                         CALL_ENG_DEBUG(ENG_DEBUG, "DTMF number - %s", dtmf_number);
3201                         if (VC_CALL_ORIG_TYPE_SAT == pcall_core->call_setup_info.call_type) {
3202                                 __voicecall_core_queue_dtmf_string(pcall_core, dtmf_number, TRUE);
3203                         } else {
3204                                 __voicecall_core_queue_dtmf_string(pcall_core, dtmf_number, FALSE);
3205                         }
3206                 }
3207         } else {
3208                 CALL_ENG_DEBUG(ENG_DEBUG, "Call Info not available for call handle: %d", call_handle);
3209         }
3210
3211         return FALSE;
3212 }
3213
3214 /**
3215  * This function cancels the dtmf queue
3216  *
3217  * @return              TRUE - sucess, FALSE otherwise
3218  * @param[in]           papp_document           Handle to Application Document
3219  */
3220 gboolean voicecall_core_cancel_dtmf_queue(call_vc_core_state_t *pcall_core)
3221 {
3222         voicecall_dtmf_info_t *pdtmf_info = (voicecall_dtmf_info_t *)&pcall_core->dtmf_info;
3223
3224         CALL_ENG_DEBUG(ENG_DEBUG, "Start:pcall_core(%p)", pcall_core);
3225
3226         if (FALSE == pdtmf_info->bdtmf_queue) {
3227                 return TRUE;
3228         }
3229
3230         /*Remove Pauser Timer */
3231         g_source_remove(pdtmf_info->dtmf_pause_timer);
3232         pdtmf_info->dtmf_pause_timer = -1;
3233
3234         /*Reset the Status Flags */
3235         pdtmf_info->bdtmf_queue = FALSE;
3236         pdtmf_info->dtmf_index = 0;
3237         memset(pdtmf_info->dtmf_number, 0, sizeof(pdtmf_info->dtmf_number));
3238         if (TRUE == pdtmf_info->bsat_dtmf) {
3239                 voicecall_core_send_sat_response(pcall_core->pcall_engine, SAT_RQST_SEND_DTMF, CALL_VC_ME_UNABLE_TO_PROCESS_COMMAND);
3240         }
3241         pdtmf_info->bsat_dtmf = FALSE;
3242         pdtmf_info->bsat_hidden = FALSE;
3243         CALL_ENG_DEBUG(ENG_DEBUG, "End");
3244         return TRUE;
3245 }
3246
3247 static gboolean __voicecall_core_dtmf_pause_timer_cb(gpointer puser_data)
3248 {
3249         call_vc_core_state_t *pcall_core = (call_vc_core_state_t *)puser_data;
3250
3251         __voicecall_core_handle_dtmf_ack(pcall_core, TRUE);
3252
3253         /*Always return FALSE, so that it won't be called again */
3254         return FALSE;
3255 }
3256
3257 gboolean __voicecall_core_send_dtmf_idle_cb(gpointer pdata)
3258 {
3259         call_vc_core_state_t *pcall_core = (call_vc_core_state_t *)pdata;
3260         voicecall_dtmf_info_t *pdtmf_info = (voicecall_dtmf_info_t *)&pcall_core->dtmf_info;
3261         voicecall_error_t vc_error;
3262         vc_engine_dtmf_ack_type event_data;
3263         char dtmf_string[2];
3264
3265         dtmf_string[0] = pdtmf_info->dtmf_number[pdtmf_info->dtmf_index];
3266         dtmf_string[1] = '\0';
3267
3268         CALL_ENG_DEBUG(ENG_DEBUG, "inside ...");
3269
3270         vc_error = _vc_core_engine_send_dtmf(pcall_core->pcall_engine, dtmf_string);
3271
3272         if (vc_error == ERROR_VOICECALL_INVALID_DTMF_CHAR) {
3273                 CALL_ENG_DEBUG(ENG_DEBUG, "ERROR_VOICECALL_INVALID_DTMF_CHAR");
3274         } else if (ERROR_VOICECALL_NONE != vc_error) {
3275                 voicecall_core_cancel_dtmf_queue(pcall_core);
3276                 memset(&event_data, 0, sizeof(event_data));
3277                 event_data.bstatus = FALSE;
3278                 event_data.string_id = -1;
3279                 vcall_engine_send_event_to_client(VC_ENGINE_MSG_DTMF_ACK_TO_UI, (void *)&event_data);
3280
3281                 if (TRUE == pdtmf_info->bsat_dtmf) {
3282                         voicecall_core_send_sat_response(pcall_core->pcall_engine, SAT_RQST_SEND_DTMF, CALL_VC_ME_UNABLE_TO_PROCESS_COMMAND);
3283                 }
3284
3285                 if (!((TRUE == pdtmf_info->bsat_dtmf) && (TRUE == pdtmf_info->bsat_hidden))) {
3286                         memset(&event_data, 0, sizeof(event_data));
3287                         event_data.bstatus = FALSE;
3288                         event_data.string_id = IDS_CALL_POP_DTMFSENDING_FAIL;
3289                         vcall_engine_send_event_to_client(VC_ENGINE_MSG_DTMF_ACK_TO_UI, (void *)&event_data);
3290                 }
3291         }
3292
3293         return FALSE;
3294 }
3295
3296 static gboolean __voicecall_core_handle_dtmf_ack(call_vc_core_state_t *pcall_core, gboolean success)
3297 {
3298         voicecall_dtmf_info_t *pdtmf_info = (voicecall_dtmf_info_t *)&pcall_core->dtmf_info;
3299         vc_engine_dtmf_ack_type event_data;
3300         CALL_ENG_DEBUG(ENG_DEBUG, "...");
3301
3302         if (FALSE == pdtmf_info->bdtmf_queue) {
3303                 CALL_ENG_DEBUG(ENG_DEBUG, "DTMF Queue Canceled, do nothing");
3304                 return TRUE;
3305         }
3306
3307         if (TRUE == success) {
3308                 char dtmf_string[2];
3309                 pdtmf_info->dtmf_index++;
3310
3311                 dtmf_string[0] = pdtmf_info->dtmf_number[pdtmf_info->dtmf_index];
3312                 dtmf_string[1] = '\0';
3313
3314                 CALL_ENG_DEBUG(ENG_DEBUG, "Current dtmf_index: %d,dtmf_max_length=%d", pdtmf_info->dtmf_index, pdtmf_info->dtmf_max_length);
3315                 CALL_ENG_DEBUG(ENG_DEBUG, "Current DTMF String: %s", &pdtmf_info->dtmf_number[pdtmf_info->dtmf_index]);
3316
3317                 /*Update the DTMF Sending UI only, if it is available */
3318                 memset(&event_data, 0, sizeof(event_data));
3319                 event_data.bstatus = TRUE;
3320                 event_data.string_id = IDS_CALL_POP_SENDING;
3321                 snprintf(event_data.display_string, sizeof(event_data.display_string), &pdtmf_info->dtmf_number[pdtmf_info->dtmf_index]);
3322                 vcall_engine_send_event_to_client(VC_ENGINE_MSG_DTMF_ACK_TO_UI, (void *)&event_data);
3323
3324                 /*Find the End of the queue */
3325                 if (pdtmf_info->dtmf_index >= pdtmf_info->dtmf_max_length) {
3326
3327                         CALL_ENG_DEBUG(ENG_DEBUG, "Updating DTMF Progress before destroying");
3328
3329                         if (!((TRUE == pdtmf_info->bsat_dtmf) && (TRUE == pdtmf_info->bsat_hidden))) {
3330                                 memset(&event_data, 0, sizeof(event_data));
3331                                 event_data.bstatus = FALSE;
3332                                 event_data.string_id = IDS_CALL_POP_DTMF_SENT;
3333                                 vcall_engine_send_event_to_client(VC_ENGINE_MSG_DTMF_ACK_TO_UI, (void *)&event_data);
3334                         }
3335
3336                         if (TRUE == pdtmf_info->bsat_dtmf) {
3337                                 voicecall_core_send_sat_response(pcall_core->pcall_engine, SAT_RQST_SEND_DTMF, CALL_VC_ME_RET_SUCCESS);
3338                         }
3339                 } else {
3340                         if (0 == strcasecmp(dtmf_string, "p")) {
3341                                 int dtmf_interval = 0;
3342
3343                                 if (FALSE == _vc_core_util_check_gcf_status()) {
3344                                         dtmf_interval = (pdtmf_info->dtmf_index == 0) ? DTMF_PAUSE_TIMER_INTERVAL_FIRST : DTMF_PAUSE_TIMER_INTERVAL_REST;
3345                                 } else {
3346 #ifdef GCONF_GCF_SAT_TEST
3347                                         int start_interval = DTMF_PAUSE_TIMER_INTERVAL_GCF_FIRST;
3348                                         int rest_interval = DTMF_PAUSE_TIMER_INTERVAL_GCF_REST;
3349                                         {
3350                                                 GConfClient *client = NULL;
3351                                                 client = gconf_client_get_default();
3352                                                 if (NULL == client) {
3353                                                         CALL_ENG_DEBUG(ENG_DEBUG, "gconf_client_get_default failed..");
3354                                                 } else {
3355
3356                                                         start_interval = gconf_client_get_int(client, PATH_DTMF_INTERVAL_GCF_FIRST, NULL);
3357
3358                                                         rest_interval = gconf_client_get_int(client, PATH_DTMF_INTERVAL_GCF_REST, NULL);
3359                                                         g_object_unref(client);
3360                                                 }
3361
3362                                         }
3363                                         CALL_ENG_DEBUG(ENG_DEBUG, "start_interval:%d, rest_interval = %d", start_interval, rest_interval);
3364                                         dtmf_interval = (pdtmf_info->dtmf_index == 0) ? start_interval : rest_interval;
3365 #else
3366                                         dtmf_interval = (pdtmf_info->dtmf_index == 0) ? DTMF_PAUSE_TIMER_INTERVAL_GCF_FIRST : DTMF_PAUSE_TIMER_INTERVAL_GCF_REST;
3367 #endif
3368                                         CALL_ENG_DEBUG(ENG_DEBUG, "dtmf_interval:%d", dtmf_interval);
3369                                 }
3370                                 pdtmf_info->dtmf_pause_timer = g_timeout_add(dtmf_interval, __voicecall_core_dtmf_pause_timer_cb, pcall_core);
3371                         } else {
3372                                 g_idle_add_full(G_PRIORITY_HIGH_IDLE + 25, __voicecall_core_send_dtmf_idle_cb, pcall_core, NULL);
3373                         }
3374                 }
3375         } else {
3376                 voicecall_core_cancel_dtmf_queue(pcall_core);
3377
3378                 memset(&event_data, 0, sizeof(event_data));
3379                 event_data.bstatus = FALSE;
3380                 event_data.string_id = IDS_CALL_POP_DTMFSENDING_FAIL;
3381                 vcall_engine_send_event_to_client(VC_ENGINE_MSG_DTMF_ACK_TO_UI, (void *)&event_data);
3382         }
3383
3384         return TRUE;
3385 }
3386
3387 /**
3388  * This function queues the dtmf digits one by one from the given dtmf string
3389  *
3390  * @return              TRUE - sucess, FALSE otherwise
3391  * @param[in]           papp_document           Handle to Application Document
3392  * @param[in]           dtmf_string                     dtmf string to be queued
3393  */
3394 static gboolean __voicecall_core_queue_dtmf_string(call_vc_core_state_t *pcall_core, char *dtmf_string, gboolean bsat_dtmf)
3395 {
3396         voicecall_dtmf_info_t *pdtmf_info = (voicecall_dtmf_info_t *)&pcall_core->dtmf_info;
3397         gboolean bhidden_mode = FALSE;
3398         char dtmf_digit[2];
3399         vc_engine_dtmf_ack_type event_data;
3400
3401         CALL_ENG_DEBUG(ENG_DEBUG, "bsat_dtmf = %d", bsat_dtmf);
3402
3403         if (TRUE == bsat_dtmf) {
3404                 /*Always get the status from the engine */
3405                 _vc_core_engine_get_sat_dtmf_hidden_mode(pcall_core->pcall_engine, &bhidden_mode);
3406                 CALL_ENG_DEBUG(ENG_DEBUG, "SAT Hidden Mode : %d", bhidden_mode);
3407         }
3408
3409         /*Check for the validity of the DTMF String */
3410         if (FALSE == _vc_core_util_isvalid_full_dtmf_number(dtmf_string)) {
3411                 if (TRUE == bsat_dtmf) {
3412                         voicecall_core_send_sat_response(pcall_core->pcall_engine, SAT_RQST_SEND_DTMF, CALL_VC_ME_UNABLE_TO_PROCESS_COMMAND);
3413                 }
3414
3415                 if (!((TRUE == bsat_dtmf) && (TRUE == bhidden_mode))) {
3416                         memset(&event_data, 0, sizeof(event_data));
3417                         event_data.bstatus = FALSE;
3418                         event_data.string_id = IDS_CALL_POP_INVALID_DTMF;
3419                         vcall_engine_send_event_to_client(VC_ENGINE_MSG_DTMF_ACK_TO_UI, (void *)&event_data);
3420                 }
3421                 return FALSE;
3422         }
3423
3424         /*Reset DTMF Values */
3425         pdtmf_info->bdtmf_queue = FALSE;
3426         pdtmf_info->dtmf_index = 0;
3427         pdtmf_info->bsat_dtmf = bsat_dtmf;
3428
3429         if (TRUE == bsat_dtmf) {
3430                 /*Initialize */
3431                 pdtmf_info->bsat_hidden = bhidden_mode;
3432         }
3433
3434         /* Check: It takes only 40 characters from the source, rest of the characters are ignored */
3435         memset(pdtmf_info->dtmf_number, 0, sizeof(pdtmf_info->dtmf_number));
3436         if (1 < sizeof(pdtmf_info->dtmf_number))
3437                 _vc_core_util_strcpy(pdtmf_info->dtmf_number, VC_PHONE_NUMBER_LENGTH_MAX, "P");
3438                 
3439         strncat(pdtmf_info->dtmf_number, dtmf_string, min((sizeof(pdtmf_info->dtmf_number) - 2), strlen(dtmf_string)));
3440
3441         pdtmf_info->dtmf_max_length = strlen(pdtmf_info->dtmf_number);
3442
3443         CALL_ENG_DEBUG(ENG_DEBUG, "Dtmf Number:%s ,dtmf_max_length:%d", pdtmf_info->dtmf_number, pdtmf_info->dtmf_max_length);
3444
3445         dtmf_digit[0] = pdtmf_info->dtmf_number[pdtmf_info->dtmf_index];
3446         dtmf_digit[1] = '\0';
3447
3448         /*Send DTMF */
3449         if (0 == strcasecmp(dtmf_digit, "p")) {
3450                 int dtmf_interval = 0;
3451
3452                 if (FALSE == _vc_core_util_check_gcf_status()) {
3453                         dtmf_interval = (pdtmf_info->dtmf_index == 0) ? DTMF_PAUSE_TIMER_INTERVAL_FIRST : DTMF_PAUSE_TIMER_INTERVAL_REST;
3454                 } else {
3455 #ifdef GCONF_GCF_SAT_TEST
3456                         int start_interval = DTMF_PAUSE_TIMER_INTERVAL_GCF_FIRST;
3457                         int rest_interval = DTMF_PAUSE_TIMER_INTERVAL_GCF_REST;
3458                         {
3459
3460                                 GConfClient *client = NULL;
3461                                 client = gconf_client_get_default();
3462                                 if (NULL == client) {
3463                                         CALL_ENG_DEBUG(ENG_DEBUG, "gconf_client_get_default failed..");
3464                                 } else {
3465
3466                                         start_interval = gconf_client_get_int(client, PATH_DTMF_INTERVAL_GCF_FIRST, NULL);
3467
3468                                         rest_interval = gconf_client_get_int(client, PATH_DTMF_INTERVAL_GCF_REST, NULL);
3469                                         g_object_unref(client);
3470                                 }
3471
3472                         }
3473                         CALL_ENG_DEBUG(ENG_DEBUG, "start_interval:%d, rest_interval = %d", start_interval, rest_interval);
3474                         dtmf_interval = (pdtmf_info->dtmf_index == 0) ? start_interval : rest_interval;
3475 #else
3476                         dtmf_interval = (pdtmf_info->dtmf_index == 0) ? DTMF_PAUSE_TIMER_INTERVAL_GCF_FIRST : DTMF_PAUSE_TIMER_INTERVAL_GCF_REST;
3477 #endif
3478                         CALL_ENG_DEBUG(ENG_DEBUG, "updated dtmf_interval:%d", dtmf_interval);
3479                 }
3480                 pdtmf_info->dtmf_pause_timer = g_timeout_add(dtmf_interval, __voicecall_core_dtmf_pause_timer_cb, pcall_core);
3481         } else if ((ERROR_VOICECALL_NONE != _vc_core_engine_send_dtmf(pcall_core->pcall_engine, dtmf_digit))) {
3482                 if (!((TRUE == pdtmf_info->bsat_dtmf) && (TRUE == pdtmf_info->bsat_hidden))) {
3483                         memset(&event_data, 0, sizeof(event_data));
3484                         event_data.bstatus = FALSE;
3485                         event_data.string_id = IDS_CALL_POP_DTMFSENDING_FAIL;
3486                         vcall_engine_send_event_to_client(VC_ENGINE_MSG_DTMF_ACK_TO_UI, (void *)&event_data);
3487                 }
3488                 if (TRUE == pdtmf_info->bsat_dtmf) {
3489                         voicecall_core_send_sat_response(pcall_core->pcall_engine, SAT_RQST_SEND_DTMF, CALL_VC_ME_UNABLE_TO_PROCESS_COMMAND);
3490                 }
3491                 return FALSE;
3492         }
3493         pdtmf_info->bdtmf_queue = TRUE;
3494
3495         /*Create Progressbar popup */
3496         if (!((TRUE == pdtmf_info->bsat_dtmf) && (TRUE == pdtmf_info->bsat_hidden))) {
3497                 memset(&event_data, 0, sizeof(event_data));
3498                 event_data.bstatus = TRUE;
3499                 event_data.string_id = IDS_CALL_POP_SENDING;
3500                 _vc_core_util_strcpy(event_data.display_string, VC_PHONE_NUMBER_LENGTH_MAX, pdtmf_info->dtmf_number);
3501                 vcall_engine_send_event_to_client(VC_ENGINE_MSG_DTMF_ACK_TO_UI, (void *)&event_data);
3502         } else {
3503                 CALL_ENG_DEBUG(ENG_DEBUG, "SAT DTMF Hidden Mode, not showing UI");
3504         }
3505         return TRUE;
3506 }
3507 #endif
3508
3509 gboolean voicecall_core_change_sound_path(call_vc_core_state_t *pcall_core, voicecall_snd_audio_type_t sound_path)
3510 {
3511         voicecall_snd_mgr_t *papp_snd = pcall_core->papp_snd;
3512         int ret = FALSE;
3513         int total_call_member = -1;
3514
3515         CALL_ENG_DEBUG(ENG_DEBUG, "sound_path:[%d]", sound_path);
3516
3517         voicecall_core_get_total_call_member(pcall_core->pcall_engine, &total_call_member);
3518         if (total_call_member == 0) {
3519                 CALL_ENG_DEBUG(ENG_DEBUG, "There are not active calls hence it should not work");
3520                 return FALSE;
3521         }
3522
3523         switch (sound_path) {
3524         case VOICE_CALL_AUDIO_SPEAKER:
3525                 {
3526 #ifdef _NEW_SND_
3527                         if (voicecall_snd_get_path_status(pcall_core->papp_snd) == VOICE_CALL_SND_PATH_BT) {
3528                                 /*_vc_bt_send_response_to_bt(pcall_core, BT_AG_RES_SWITCH_TO_PHONE, -1, NULL);*/
3529                                 _vc_bt_request_switch_headset_path(pcall_core, FALSE);
3530                         }
3531                         voicecall_snd_set_path_status(pcall_core->papp_snd, VOICE_CALL_SND_PATH_SPEAKER);                               
3532 #else
3533                         if (TRUE == voicecall_snd_get_status(papp_snd, VOICE_CALL_AUDIO_HEADSET)) {
3534                                 voicecall_snd_set_status(papp_snd, VOICE_CALL_AUDIO_HEADSET, FALSE);
3535                                 /*_vc_bt_send_response_to_bt(pcall_core, BT_AG_RES_SWITCH_TO_PHONE, -1, NULL);*/
3536                                 _vc_bt_request_switch_headset_path(pcall_core, FALSE);
3537                         }
3538
3539                         voicecall_snd_set_status(papp_snd, VOICE_CALL_AUDIO_SPEAKER, TRUE);
3540 #endif
3541                         ret = TRUE;
3542                 }
3543                 break;
3544
3545         case VOICE_CALL_AUDIO_HEADSET:
3546                 {
3547 #ifdef _NEW_SND_
3548                         voicecall_snd_set_path_status(pcall_core->papp_snd, VOICE_CALL_SND_PATH_BT);                            
3549 #else
3550                         voicecall_snd_set_status(papp_snd, VOICE_CALL_AUDIO_SPEAKER, FALSE);
3551                         voicecall_snd_set_status(papp_snd, VOICE_CALL_AUDIO_HEADSET, TRUE);
3552 #endif
3553 /*                      _vc_bt_send_response_to_bt(pcall_core, BT_AG_RES_SWITCH_TO_HEADSET, -1, NULL);*/
3554                         _vc_bt_request_switch_headset_path(pcall_core, TRUE);
3555
3556                         ret = TRUE;
3557                 }
3558                 break;
3559
3560         case VOICE_CALL_AUDIO_EARJACK:
3561                 {
3562 #ifdef _NEW_SND_
3563                         if (voicecall_snd_get_path_status(pcall_core->papp_snd) == VOICE_CALL_SND_PATH_BT) {
3564                                 /*_vc_bt_send_response_to_bt(pcall_core, BT_AG_RES_SWITCH_TO_PHONE, -1, NULL);*/
3565                                 _vc_bt_request_switch_headset_path(pcall_core, FALSE);
3566                         }
3567                         voicecall_snd_set_path_status(pcall_core->papp_snd, VOICE_CALL_SND_PATH_EARJACK);                               
3568 #else
3569                         voicecall_snd_set_status(papp_snd, VOICE_CALL_AUDIO_SPEAKER, FALSE);
3570
3571                         if (TRUE == voicecall_snd_get_status(papp_snd, VOICE_CALL_AUDIO_HEADSET)) {
3572                                 voicecall_snd_set_status(papp_snd, VOICE_CALL_AUDIO_HEADSET, FALSE);
3573                                 /*_vc_bt_send_response_to_bt(pcall_core, BT_AG_RES_SWITCH_TO_PHONE, -1, NULL);*/
3574                                 _vc_bt_request_switch_headset_path(pcall_core, FALSE);
3575                         }
3576 #endif
3577                         ret = TRUE;
3578                 }
3579                 break;
3580
3581         default:
3582                 {
3583                         CALL_ENG_DEBUG(ENG_DEBUG, "Unknown type!!");
3584                         ret = FALSE;
3585                 }
3586                 break;
3587         }
3588
3589         /* Change Audio Path according to the current status */
3590         voicecall_snd_change_path(papp_snd);
3591
3592         return ret;
3593 }
3594
3595 gboolean voicecall_core_get_sound_path(call_vc_core_state_t *pcall_core, int *sound_path)
3596 {
3597         voicecall_snd_mgr_t *papp_snd = pcall_core->papp_snd;
3598
3599         CALL_ENG_DEBUG(ENG_DEBUG, "..");
3600
3601 #ifdef _NEW_SND_
3602         switch (voicecall_snd_get_path_status(papp_snd))
3603         {
3604                 case VOICE_CALL_SND_PATH_SPEAKER:
3605                         {
3606                                 *sound_path = VOICE_CALL_AUDIO_SPEAKER;
3607                         }
3608                         break;
3609
3610                 case VOICE_CALL_SND_PATH_BT:
3611                         {
3612                                 *sound_path = VOICE_CALL_AUDIO_HEADSET;
3613                         }
3614                         break;
3615
3616                 case VOICE_CALL_SND_PATH_EARJACK:
3617                         {
3618                                 *sound_path = VOICE_CALL_AUDIO_EARJACK;
3619                         }
3620                         break;
3621
3622                 case VOICE_CALL_SND_PATH_RECEIVER:
3623                 default:
3624                         {
3625                                 *sound_path = VOICE_CALL_AUDIO_RECEIVER;
3626                         }
3627                         break;
3628
3629         }
3630 #else
3631         if (TRUE == voicecall_snd_get_status(papp_snd, VOICE_CALL_AUDIO_SPEAKER)) {
3632                 *sound_path = VOICE_CALL_AUDIO_SPEAKER;
3633         } else if (TRUE == voicecall_snd_get_status(papp_snd, VOICE_CALL_AUDIO_HEADSET)) {
3634                 *sound_path = VOICE_CALL_AUDIO_HEADSET;
3635         } else {
3636                 *sound_path = VOICE_CALL_AUDIO_EARJACK;
3637         }
3638 #endif
3639
3640         return TRUE;
3641 }
3642
3643 static gboolean __voicecall_core_is_redial_cuase(int end_cause)
3644 {
3645         CALL_ENG_DEBUG(ENG_DEBUG, "end_cause(%d)",end_cause);
3646
3647         switch (end_cause)
3648         {       
3649                 case VC_ENDCAUSE_CALL_BARRED:
3650                 case VC_ENDCAUSE_NO_SERVICE:
3651                 case VC_ENDCAUSE_USER_UNAVAILABLE:
3652                 case VC_ENDCAUSE_INVALID_NUMBER_FORMAT:
3653                 case VC_ENDCAUSE_NUMBER_CHANGED:
3654                 case VC_ENDCAUSE_NO_CREDIT:
3655                 case VC_ENDCAUSE_UNASSIGNED_NUMBER:
3656                         return FALSE;
3657
3658                 case VC_ENDCAUSE_CALL_ENDED:
3659                 case VC_ENDCAUSE_CALL_DISCONNECTED:
3660                 case VC_ENDCAUSE_NO_ANSWER:
3661                 case VC_ENDCAUSE_NW_BUSY:
3662                 case VC_ENDCAUSE_CALL_SERVICE_NOT_ALLOWED:
3663                 case VC_ENDCAUSE_NW_FAILED:
3664                 case VC_ENDCAUSE_REJECTED:
3665                 case VC_ENDCAUSE_USER_BUSY:
3666                 case VC_ENDCAUSE_WRONG_GROUP:
3667                 case VC_ENDCAUSE_CALL_NOT_ALLOWED:
3668                 case VC_ENDCAUSE_CALL_FAILED:
3669                 case VC_ENDCAUSE_NO_USER_RESPONDING:
3670                 case VC_ENDCAUSE_USER_ALERTING_NO_ANSWER:
3671                 case VC_ENDCAUSE_SERVICE_TEMP_UNAVAILABLE:
3672                 case VC_ENDCAUSE_USER_DOESNOT_RESPOND:
3673                 case VC_ENDCAUSE_IMEI_REJECTED:
3674                 case VC_ENDCAUSE_TAPI_ERROR:
3675                 default:
3676                         return TRUE;
3677         }
3678 }