update for beta universally
[framework/telephony/libslp-tapi.git] / src / test_apps / tapi_call_test.c
1 /*
2  * libslp-tapi
3  *
4  * Copyright (c) 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Kyeongchul Kim <kyeongchul.kim@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20
21 #include <stdlib.h>
22 #include <string.h>
23 #include <sys/time.h>
24 #include <pthread.h>     /* pthread functions and data structures */
25 #include <signal.h>
26 #include <stdio.h>
27 #include <errno.h>
28 #include "assert.h"
29 #include "glib.h"
30 #include "unistd.h"
31
32 #include "TelErr.h"
33 #include "ITapiPower.h"
34 #include "ITapiCall.h"
35 #include "TapiCommon.h"
36 #include "TelCall.h"
37 #include "vconf.h"
38
39 #ifndef false
40         #define false 0
41 #endif
42 #ifndef true
43         #define true  !0
44 #endif
45 #ifndef bool
46         #define bool  char
47 #endif
48
49 #define _CALL_TEST_KOREA_FMT_           4
50 #define _CALL_TEST_INDIA_FMT_           10
51
52 #define TEST_DEBUG(frmt, args...)       \
53         {do { fprintf(stderr, "[Call Test][%s:%04d] " frmt "\n", __func__, __LINE__, ##args); } while (FALSE) ;}
54
55 #define AUTO_LOG(frmt, args...)
56
57
58 #define MAX_BURST_DTMF_STRLEN           32
59
60 extern int EvtDeliveryHandle ;
61
62
63 typedef struct
64 {
65         TS_UINT handle;
66         TelTapiCallInfo_t       info;
67         TS_BOOL                 used;
68         int                             index;
69 } call_ctxt_t;
70
71 // same as tapi event
72 typedef struct
73 {
74         int group;
75         int type;
76         int ID;
77         int status;
78         void *dst;
79 }data_t;
80
81 int error_code;
82 static TelCallActiveLine_t              _glob_test_curr_line = 0x00;
83 //static TS_UINT                endHCall = -1;
84 static long     __call_test_auto_mo = 0;
85 static long     __call_test_auto_ans = 0;
86 static long      _timer_exp_count = 0;
87
88 call_ctxt_t             ctxt[TAPI_CONTEXT_CALL_SIZE_MAX];
89 TelCallStatus_t gcallStatus[TAPI_CONTEXT_CALL_SIZE_MAX];
90 TS_UINT incoming_handle= -1;
91 TS_UINT curr_handle= -1;
92 int requestID;
93
94 FILE *log_fd;
95
96 TelCallSetupParams_t _glob_setup_info;
97
98 struct sigaction sa;
99 struct itimerval timer;
100
101 /*      Success returns 0       */
102 extern pthread_t          __glob_tapi_keypad_thread;
103
104 //static int  _country_spc_num_ = 0;
105 char pre_string[16] = {0, };
106 int _auto_dtmf_send_count = 0;
107 int _auto_dtmf_cnf_count = 0;
108
109 static unsigned int *   CALL_subscription_id;
110
111 void __PrintCallType(char* str, TelCallType_t eCallType)
112 {
113         switch(eCallType)
114         {
115                 case TAPI_CALL_TYPE_VOICE:
116                         fprintf(stderr, "%s [TAPI_CALL_TYPE_VOICE]", str);
117                         break;
118                 case TAPI_CALL_TYPE_DATA:
119                         fprintf(stderr, "%s [TAPI_CALL_TYPE_DATA]", str);
120                         break;
121                 case TAPI_CALL_TYPE_E911:
122                         fprintf(stderr, "%s [TAPI_CALL_TYPE_E911]", str);
123                         break;
124                 default:
125                         fprintf(stderr, "%s Undefined Call Type:[0x%x]", str, eCallType);
126                         break;
127         }
128 }
129
130 void __PrintActiveCallState(char* str, TelCallActiveState_t eCallActiveState)
131 {
132         switch(eCallActiveState)
133         {
134                 case TAPI_CALL_CONNECT_IDLE:
135                         fprintf(stderr, "%s [TAPI_CALL_CONNECT_IDLE]", str);
136                         break;
137                 case TAPI_CALL_CONNECT_ACTIVE:
138                         fprintf(stderr, "%s [TAPI_CALL_CONNECT_ACTIVE]", str);
139                         break;
140                 case TAPI_CALL_CONNECT_HELD:
141                         fprintf(stderr, "%s [TAPI_CALL_CONNECT_HELD]", str);
142                         break;
143                 default:
144                         fprintf(stderr, "%s Undefined Call Active State", str);
145                         break;
146         }
147 }
148
149 void __PrintCallState(char* str, TelCallStates_t eCallState)
150 {
151         switch(eCallState)
152         {
153                 case TAPI_CALL_STATE_IDLE:
154                         fprintf(stderr, "%s [TAPI_CALL_STATE_IDLE]", str);
155                         break;
156                 case TAPI_CALL_STATE_ORIG:
157                         fprintf(stderr, "%s [TAPI_CALL_STATE_ORIG]", str);
158                         break;
159                 case TAPI_CALL_STATE_SETUPIND:
160                         fprintf(stderr, "%s [TAPI_CALL_STATE_SETUPIND]", str);
161                         break;
162                 case TAPI_CALL_STATE_CONNECTING:
163                         fprintf(stderr, "%s [TAPI_CALL_STATE_CONNECTING]", str);
164                         break;
165                 case TAPI_CALL_STATE_ALERT:
166                         fprintf(stderr, "%s [TAPI_CALL_STATE_ALERT]", str);
167                         break;
168                 case TAPI_CALL_STATE_INCOM:
169                         fprintf(stderr, "%s [TAPI_CALL_STATE_INCOM]", str);
170                         break;
171                 case TAPI_CALL_STATE_ANSWER:
172                         fprintf(stderr, "%s [TAPI_CALL_STATE_ANSWER]", str);
173                         break;
174                 case TAPI_CALL_STATE_CONV:
175                         fprintf(stderr, "%s [TAPI_CALL_STATE_CONV]", str);
176                         break;
177                 case TAPI_CALL_STATE_ENDING:
178                         fprintf(stderr, "%s [TAPI_CALL_STATE_ENDING]", str);
179                         break;
180                 case TAPI_CALL_STATE_INVALID:
181                         fprintf(stderr, "%s [TAPI_CALL_STATE_INVALID]", str);
182                         break;
183                 default:
184                         fprintf(stderr, "%s Undefined Call State", str);
185                         break;
186         }
187 }
188
189 void __PrintCallFwType(char* str, TelCallForwardType_t eCallFwType)
190 {
191         switch(eCallFwType)
192         {
193                 case TAPI_CALL_OUTGOING_FWDED:
194                         fprintf(stderr, "%s [TAPI_CALL_OUTGOING_FWDED]", str);
195                         break;
196                 case TAPI_CALL_INCOMMING_FWDED:
197                         fprintf(stderr, "%s [TAPI_CALL_INCOMMING_FWDED]", str);
198                         break;
199                 default:
200                         fprintf(stderr, "%s Undefined Call ForwardType", str);
201                         break;
202         }
203 }
204
205
206 int call_test_ret_first_free_index(void);
207
208
209
210 void timer_handler (int signum)
211 {
212         TEST_DEBUG("Timer Expired [%ld] times", ++_timer_exp_count);
213
214         /*      Free the current call context   */
215
216 }
217
218
219 void timer_reset()
220 {
221          /* Configure the timer to expire after 250 msec... */
222          timer.it_value.tv_sec = 60;
223          timer.it_value.tv_usec = 0;
224          /* ... and every 250 msec after that. */
225          timer.it_interval.tv_sec = 0;
226          timer.it_interval.tv_usec = 0;
227 }
228
229
230 void timer_start()
231 {
232          /* Start a virtual timer. It counts down whenever this process is
233            executing. */
234          setitimer (ITIMER_REAL, &timer, NULL);
235 }
236
237
238
239 void call_test_auto_hold(void)
240 {
241         TapiResult_t    api_err;
242
243         TEST_DEBUG("Request to Auto Hold call with Handle [%d]", curr_handle);
244
245         api_err = tel_hold_call(curr_handle, &requestID);
246
247         TEST_DEBUG("Tapi API Err Code [%x], Auto MO Count [%ld]", api_err, __call_test_auto_mo);
248         AUTO_LOG("API: tel_hold_call:-IN Handle [%d], Return [%d]", curr_handle, api_err);
249   }
250
251
252
253 void call_test_auto_act(void)
254 {
255         TapiResult_t    api_err;
256
257         TEST_DEBUG("Request to Auto Activate Call with Handle [%d]", curr_handle);
258
259         api_err = tel_retrieve_call(curr_handle, &requestID);
260
261         TEST_DEBUG("Tapi API Err Code [%x], Auto Count [%ld]", api_err, __call_test_auto_ans);
262         AUTO_LOG("API: tel_retrieve_call:-IN Handle [%d], Return [%d]", curr_handle, api_err);
263   }
264
265
266 void call_test_auto_ans(void)
267 {
268         TapiResult_t    api_err;
269
270         TEST_DEBUG("Request to Auto Ans call with Handle [%d]", incoming_handle);
271
272         __call_test_auto_ans++;
273
274         api_err = tel_answer_call(incoming_handle, TAPI_CALL_ANSWER_ACCEPT, &requestID);
275
276         TEST_DEBUG("Tapi API Err Code [%x], Auto Count [%ld]", api_err, __call_test_auto_ans);
277
278         AUTO_LOG("API: tel_answer_call:- IN Hanlde [%d] Return [%d]", incoming_handle, api_err);
279   }
280
281
282
283
284
285 void call_test_auto_mo(void)
286 {
287         int     free_id;
288         TapiResult_t    api_err;
289         int RequestId=0;
290
291         TEST_DEBUG("Request to Auto Setup call with Number ...%s", _glob_setup_info.szNumber);
292
293         __call_test_auto_mo++;
294
295         api_err = tel_exe_call_mo(&_glob_setup_info, &curr_handle, &RequestId);
296
297         TEST_DEBUG("After calling tel_exe_call_mo : Handle [%d]", curr_handle);
298
299         TEST_DEBUG("Tapi API Err Code [%x], Auto Count [%ld]", api_err, __call_test_auto_mo);
300
301         if(api_err == TAPI_API_SUCCESS)
302         {
303                 free_id = call_test_ret_first_free_index();
304
305                 if (free_id == -1)
306                 {
307                         TEST_DEBUG("No Free Context ...");
308                 }
309
310                 else
311                 {
312                         memcpy(&ctxt[free_id].info.callNumber, _glob_setup_info.szNumber, sizeof( _glob_setup_info.szNumber));
313                         ctxt[free_id].info.callState = TAPI_CALL_STATE_ORIG;
314                         ctxt[free_id].info.activeState = TAPI_CALL_CONNECT_IDLE;
315                         ctxt[free_id].info.isMobileOriginated = true;
316                         ctxt[free_id].handle = curr_handle;
317                 }
318
319                 AUTO_LOG("API: tel_exe_call_mo:- Return [%d], Handle [%d]", api_err, curr_handle);
320
321         }
322
323
324   }
325
326
327
328 void call_test_count_mo()
329 {
330         if (__call_test_auto_mo)
331                 call_test_auto_mo();
332         else
333                 TEST_DEBUG("Non Automated testing...");
334 }
335
336
337 void call_test_count_ans()
338 {
339         if (__call_test_auto_ans)
340                 call_test_auto_ans();
341         else
342                 TEST_DEBUG("Non Automated testing...");
343 }
344
345 void call_test_auto_dtmf()
346 {
347         int api_err = 0;
348         int RequestID;
349
350         api_err = tel_send_call_dtmf("9\0", &RequestID);
351     TEST_DEBUG(" Tapi return api_err value is [%x] ", api_err);
352     _auto_dtmf_send_count++;
353         AUTO_LOG("API: tel_send_call_dtmf: Send Count [%d]", _auto_dtmf_send_count);
354 }
355
356
357 TS_UINT  call_test_ret_handle_by_active_state(void)
358 {
359         int start = 0;
360         int max = TAPI_CONTEXT_CALL_SIZE_MAX;
361
362         for (start = 0; start < max; start++)
363         {
364                 if (ctxt[start].info.activeState == TAPI_CALL_CONNECT_ACTIVE)
365                 {
366                         TEST_DEBUG("Current Active Call Handle is [%d]", ctxt[start].handle);
367                         return ctxt[start].handle;
368                 }
369                 else
370                 {
371                         //
372                 }
373         }
374
375         if (start == max)
376         {
377                 TEST_DEBUG("Could not find Call with Active State")
378         }
379
380         return -1;
381
382 }
383
384
385
386
387 int call_test_ret_index_by_handle(TS_UINT handle)
388 {
389         int start = 0;
390         int max = TAPI_CONTEXT_CALL_SIZE_MAX;
391
392         for (start = 0; start < max; start++)
393         {
394                 if (ctxt[start].handle == handle)
395                 {
396                         return start;
397                 }
398                 else
399                 {
400                         //
401                 }
402         }
403
404         if (start == max)
405         {
406                 TEST_DEBUG("Could not find CTXT")
407         }
408
409         return -1;
410
411 }
412
413
414
415 int call_test_ret_first_free_index(void)
416 {
417         int start = 0;
418         int max = TAPI_CONTEXT_CALL_SIZE_MAX;
419
420         for (start = 0; start < max; start++)
421         {
422                 /*      by default they are free        */
423                 if (ctxt[start].used == false)
424                 {
425                         //TEST_DEBUG("Creating a Context with Index [%d]", start);
426
427                         ctxt[start].used = true;
428                         ctxt[start].index = start;
429
430                         return start;
431                 }
432                 else
433                 {
434                         //
435                 }
436         }
437
438         if (start == max)
439         {
440                 TEST_DEBUG("Could not find FREE CTXT")
441         }
442
443         return -1;
444
445 }
446
447
448 /*      Create a context and populate the data  */
449 void call_test_process_incom_ind(void *data)
450 {
451         int free_id = -1;
452         TelCallIncomingCallInfo_t       IncomingInfo = {0, };
453         int len;
454
455         free_id = call_test_ret_first_free_index();
456
457         if (free_id == -1)
458         {
459                 //
460         }
461         else
462         {
463                 memcpy(&IncomingInfo, data, sizeof(TelCallIncomingCallInfo_t));
464
465                 ctxt[free_id].handle = IncomingInfo.CallHandle;
466
467                 len = strlen(IncomingInfo.szCallingPartyNumber);
468
469                 memcpy(&ctxt[free_id].info.callNumber, IncomingInfo.szCallingPartyNumber, len);
470
471                 ctxt[free_id].info.callState = TAPI_CALL_STATE_INCOM;
472                 ctxt[free_id].info.callType = IncomingInfo.CallType;
473                 //ctxt[free_id].info.CliCause = IncomingInfo.CliCause;
474
475                 TEST_DEBUG("Incoming Call Information: call handle:[%d], Number [%s], Type [0x%x]",
476                         ctxt[free_id].handle, ctxt[free_id].info.callNumber, ctxt[free_id].info.callType);
477
478                 TEST_DEBUG("No CLI Cause [0x%x]",  IncomingInfo.CliCause);
479
480                 incoming_handle = ctxt[free_id].handle;
481
482                 AUTO_LOG("EVENT: INCOMING IND:- Hanlde [%d], Number [%s]",
483                         incoming_handle, ctxt[free_id].info.callNumber);
484
485                 /*      if the test is automated, then call ans api     */
486                 call_test_count_ans();
487
488         }
489
490 }
491
492 //static void  call_test_process_events (TelTapiEventClass_t eventClass, int eventType, void * param2)
493 static void  call_async_event_callback(TelTapiEvent_t   *event, void *data)
494 {
495         TS_UINT temp_handle = -1;
496         int     RequestId=0;
497
498         TEST_DEBUG("EVENT TYPE:[0x%x], STATUS:[0x%x]", event->EventType, event->Status);
499
500         int *userdata;
501         userdata = (int *)data;
502
503         switch(event->EventClass)
504         {
505                 case TAPI_EVENT_CLASS_CALL_VOICE:
506                         switch(event->EventType)
507                         {
508                                 case TAPI_EVENT_CALL_SWAP_CNF:
509                                 {
510                                                 TEST_DEBUG("TAPI_EVENT_CALL_SWAP_CNF");
511                                 }
512                                         break;
513
514                                 case TAPI_EVENT_CALL_ANSWER_CNF:
515                                 {
516                                                 TEST_DEBUG("TAPI_EVENT_CALL_ANSWER_CNF");
517                                 }
518                                         break;
519
520                                 case TAPI_EVENT_CALL_RELEASE_CNF:
521                                 {
522                                                 TEST_DEBUG("TAPI_EVENT_CALL_RELEASE_CNF");
523                                 }
524                                         break;
525
526                                 case TAPI_EVENT_CALL_RELEASE_ALL_CNF:
527                                 {
528                                                 TEST_DEBUG("TAPI_EVENT_CALL_RELEASE_ALL_CNF");
529                                 }
530                                         break;
531
532                                 case TAPI_EVENT_CALL_RELEASE_ALL_ACTIVE_CNF:
533                                 {
534                                                 TEST_DEBUG("TAPI_EVENT_CALL_RELEASE_ALL_ACTIVE_CNF");
535                                 }
536                                         break;
537
538                                 case TAPI_EVENT_CALL_RELEASE_ALL_HELD_CNF:
539                                 {
540                                                 TEST_DEBUG("TAPI_EVENT_CALL_RELEASE_ALL_HELD_CNF");
541                                 }
542                                         break;
543
544                                 case TAPI_EVENT_CALL_GET_PRIVACYMODE_CNF:
545                                 {
546                                         TEST_DEBUG("TAPI_EVENT_CALL_GET_PRIVACYMODE_CNF");
547                                         TelCallVoicePrivacyInfo_t vp_info={0,};
548                                         memcpy(&vp_info, event->pData, sizeof(TelCallVoicePrivacyInfo_t));
549                                         switch(vp_info.PrivacyType)
550                                         {
551                                                 case TAPI_CALL_PRIVACY_TYPE_MS:
552                                                         TEST_DEBUG("TAPI_CALL_PRIVACY_TYPE_MS");
553                                                         break;
554                                                 case TAPI_CALL_PRIVACY_TYPE_BS:
555                                                         TEST_DEBUG("TAPI_CALL_PRIVACY_TYPE_BS");
556                                                         break;
557                                                 case TAPI_CALL_PRIVACY_TYPE_CURRENT:
558                                                         TEST_DEBUG("TAPI_CALL_PRIVACY_TYPE_CURRENT");
559                                                         break;
560                                                 default:
561                                                         TEST_DEBUG("NONE");
562                                                         break;
563                                         }
564                                         switch(vp_info.PrivacyMode)
565                                         {
566                                                 case TAPI_CALL_PRIVACY_MODE_STANDARD:
567                                                         TEST_DEBUG("TAPI_CALL_PRIVACY_MODE_STANDARD");
568                                                         break;
569                                                 case TAPI_CALL_PRIVACY_MODE_ENHANCED:
570                                                         TEST_DEBUG("TAPI_CALL_PRIVACY_MODE_ENHANCED");
571                                                         break;
572                                                 default:
573                                                         TEST_DEBUG("NONE");
574                                                         break;
575                                         }
576                                 }
577                                         break;
578
579                                 case TAPI_EVENT_CALL_SET_PRIVACYMODE_CNF:
580                                 {
581                                         TEST_DEBUG("TAPI_EVENT_CALL_SET_PRIVACYMODE_CNF");
582                                 }
583                                         break;
584
585                                 case TAPI_EVENT_CALL_PRIVACYMODE_IND:
586                                 {
587                                         TEST_DEBUG("TAPI_EVENT_CALL_PRIVACYMODE_IND");
588                                         TelCallVoicePrivacyInfo_t vp_info={0,};
589                                         memcpy(&vp_info, event->pData, sizeof(TelCallVoicePrivacyInfo_t));
590                                         switch(vp_info.PrivacyType)
591                                         {
592                                                 case TAPI_CALL_PRIVACY_TYPE_MS:
593                                                         TEST_DEBUG("TAPI_CALL_PRIVACY_TYPE_MS");
594                                                         break;
595                                                 case TAPI_CALL_PRIVACY_TYPE_BS:
596                                                         TEST_DEBUG("TAPI_CALL_PRIVACY_TYPE_BS");
597                                                         break;
598                                                 case TAPI_CALL_PRIVACY_TYPE_CURRENT:
599                                                         TEST_DEBUG("TAPI_CALL_PRIVACY_TYPE_CURRENT");
600                                                         break;
601                                                 default:
602                                                         TEST_DEBUG("NONE");
603                                                         break;
604                                         }
605                                         switch(vp_info.PrivacyMode)
606                                         {
607                                                 case TAPI_CALL_PRIVACY_MODE_STANDARD:
608                                                         TEST_DEBUG("TAPI_CALL_PRIVACY_MODE_STANDARD");
609                                                         break;
610                                                 case TAPI_CALL_PRIVACY_MODE_ENHANCED:
611                                                         TEST_DEBUG("TAPI_CALL_PRIVACY_MODE_ENHANCED");
612                                                         break;
613                                                 default:
614                                                         TEST_DEBUG("NONE");
615                                                         break;
616                                         }
617                                 }
618                                         break;
619
620                                 case TAPI_EVENT_CALL_FLASHINFO_CNF:
621                                 {
622                                         TEST_DEBUG("TAPI_EVENT_CALL_FLASHINFO_CNF");
623                                 }
624                                         break;
625
626                                 case TAPI_EVENT_CALL_EXIT_EMERGENCYMODE_CNF:
627                                 {
628                                         TEST_DEBUG("TAPI_EVENT_CALL_EXIT_EMERGENCYMODE_CNF");
629                                 }
630                                         break;
631
632                                 case TAPI_EVENT_CALL_EMERGENCYMODE_IND:
633                                 {
634                                         TEST_DEBUG("TAPI_EVENT_CALL_EMERGENCYMODE_IND");
635                                         TelCallEmergecyMode_t mode= 0;
636                                         memcpy(&mode, event->pData, sizeof(TelCallEmergecyMode_t));
637                                         switch(mode)
638                                         {
639                                                 case TAPI_CALL_EMERGENCY_MODE_EXIT:
640                                                         TEST_DEBUG("TAPI_CALL_EMERGENCY_MODE_EXIT");
641                                                         break;
642                                                 case TAPI_CALL_EMERGENCY_MODE_ENTER:
643                                                         TEST_DEBUG("TAPI_CALL_EMERGENCY_MODE_ENTER");
644                                                         break;
645                                                 default:
646                                                         TEST_DEBUG("NONE");
647                                                         break;
648                                         }
649                                 }
650                                         break;
651
652                                 case TAPI_EVENT_CALL_TIME_CNF:
653                                 {
654                                         TEST_DEBUG("TAPI_EVENT_CALL_TIME_CNF");
655                                         TelCallTimeInfo_t calltime_info={0,};
656                                         memcpy(&calltime_info, event->pData, sizeof(TelCallTimeInfo_t));
657                                         TEST_DEBUG("req_type_mask = [0x%x]",calltime_info.req_type_mask);
658                                         TEST_DEBUG("TotalCallCnt = [%ld]",calltime_info.TotalCallCnt);
659                                         TEST_DEBUG("OutgoingCallCnt = [%ld]",calltime_info.OutgoingCallCnt);
660                                         TEST_DEBUG("IncomingCallCnt = [%ld]",calltime_info.IncomingCallCnt);
661                                         TEST_DEBUG("TotalCallTime = [%ld]",calltime_info.TotalCallTime);
662                                         TEST_DEBUG("OutgoingCallTime = [%ld]",calltime_info.OutgoingCallTime);
663                                         TEST_DEBUG("IncomingCallTime = [%ld]",calltime_info.IncomingCallTime);
664                                         TEST_DEBUG("LastCallTime = [%ld]",calltime_info.LastCallTime);
665                                 }
666                                         break;
667
668                                 case TAPI_EVENT_CALL_TIME_IND:
669                                 {
670                                         TEST_DEBUG("TAPI_EVENT_CALL_TIME_IND");
671                                         TelCallTimeInfo_t calltime_info={0,};
672                                         memcpy(&calltime_info, event->pData, sizeof(TelCallTimeInfo_t));
673                                         TEST_DEBUG("req_type_mask = [%d]",calltime_info.req_type_mask);
674                                         TEST_DEBUG("TotalCallCnt = [%ld]",calltime_info.TotalCallCnt);
675                                         TEST_DEBUG("OutgoingCallCnt = [%ld]",calltime_info.OutgoingCallCnt);
676                                         TEST_DEBUG("IncomingCallCnt = [%ld]",calltime_info.IncomingCallCnt);
677                                         TEST_DEBUG("TotalCallTime = [%ld]",calltime_info.TotalCallTime);
678                                         TEST_DEBUG("OutgoingCallTime = [%ld]",calltime_info.OutgoingCallTime);
679                                         TEST_DEBUG("IncomingCallTime = [%ld]",calltime_info.IncomingCallTime);
680                                         TEST_DEBUG("LastCallTime = [%ld]",calltime_info.LastCallTime);
681                                 }
682                                         break;
683
684                                 case TAPI_EVENT_CALL_OTA_PROGRESS_IND:
685                                 {
686                                         TEST_DEBUG("TAPI_EVENT_CALL_OTA_PROGRESS_IND");
687                                         TelCallOtaProgressInfo_t ota_info={0,};
688                                         memcpy(&ota_info, event->pData, sizeof(TelCallOtaProgressInfo_t));
689                                         switch(ota_info.OtaType)
690                                         {
691                                                 case TAPI_CALL_OTATYPE_OTASP:
692                                                 {
693                                                         TEST_DEBUG("TAPI_CALL_OTATYPE_OTASP");
694
695                                                         switch(ota_info.OtaspStatus)
696                                                         {
697                                                                 case TAPI_CALL_OTASP_OK_SPL_UNLOCKED:
698                                                                         TEST_DEBUG("TAPI_CALL_OTASP_OK_SPL_UNLOCKED");
699                                                                         break;
700                                                                 case TAPI_CALL_OTASP_OK_AKEY_EXCESS:
701                                                                         TEST_DEBUG("TAPI_CALL_OTASP_OK_AKEY_EXCESS");
702                                                                         break;
703                                                                 case TAPI_CALL_OTASP_OK_SSD_UPDATE:
704                                                                         TEST_DEBUG("TAPI_CALL_OTASP_OK_SSD_UPDATE");
705                                                                         break;
706                                                                 case TAPI_CALL_OTASP_OK_NAM_DWNLD:
707                                                                         TEST_DEBUG("TAPI_CALL_OTASP_OK_NAM_DWNLD");
708                                                                         break;
709                                                                 case TAPI_CALL_OTASP_OK_MDN_DWNLD:
710                                                                         TEST_DEBUG("TAPI_CALL_OTASP_OK_MDN_DWNLD");
711                                                                         break;
712                                                                 case TAPI_CALL_OTASP_OK_IMSI_DWNLD:
713                                                                         TEST_DEBUG("TAPI_CALL_OTASP_OK_IMSI_DWNLD");
714                                                                         break;
715                                                                 case TAPI_CALL_OTASP_OK_PRL_DWNLD:
716                                                                         TEST_DEBUG("TAPI_CALL_OTASP_OK_PRL_DWNLD");
717                                                                         break;
718                                                                 case TAPI_CALL_OTASP_OK_COMMIT:
719                                                                         TEST_DEBUG("TAPI_CALL_OTASP_OK_COMMIT");
720                                                                         break;
721                                                                 case TAPI_CALL_OTASP_OK_PROGRAMMING:
722                                                                         TEST_DEBUG("TAPI_CALL_OTASP_OK_PROGRAMMING");
723                                                                         break;
724                                                                 case TAPI_CALL_OTASP_SUCCESS:
725                                                                         TEST_DEBUG("TAPI_CALL_OTASP_SUCCESS");
726                                                                         break;
727                                                                 case TAPI_CALL_OTASP_UNSUCCESS:
728                                                                         TEST_DEBUG("TAPI_CALL_OTASP_UNSUCCESS");
729                                                                         break;
730                                                                 case TAPI_CALL_OTASP_OK_OTAPA_VERIFY:
731                                                                         TEST_DEBUG("TAPI_CALL_OTASP_OK_OTAPA_VERIFY");
732                                                                         break;
733                                                                 case TAPI_CALL_OTASP_PROGRESS:
734                                                                         TEST_DEBUG("TAPI_CALL_OTASP_PROGRESS");
735                                                                         break;
736                                                                 case TAPI_CALL_OTASP_FAILURES_EXCESS_SPC:
737                                                                         TEST_DEBUG("TAPI_CALL_OTASP_FAILURES_EXCESS_SPC");
738                                                                         break;
739                                                                 case TAPI_CALL_OTASP_LOCK_CODE_PW_SET:
740                                                                         TEST_DEBUG("TAPI_CALL_OTASP_LOCK_CODE_PW_SET");
741                                                                         break;
742                                                                 default:
743                                                                         TEST_DEBUG("NONE");
744                                                                         break;
745                                                         }
746
747                                                 }
748                                                         break;
749                                                 case TAPI_CALL_OTATYPE_OTAPA:
750                                                 {
751                                                         TEST_DEBUG("TAPI_CALL_OTATYPE_OTAPA");
752
753                                                         switch(ota_info.OtapaStatus)
754                                                         {
755                                                                 case TAPI_CALL_OTAPA_STOP:
756                                                                         TEST_DEBUG("TAPI_CALL_OTAPA_STOP");
757                                                                         break;
758                                                                 case TAPI_CALL_OTAPA_START:
759                                                                         TEST_DEBUG("TAPI_CALL_OTAPA_START");
760                                                                         break;
761                                                                 default:
762                                                                         TEST_DEBUG("NONE");
763                                                                         break;
764                                                         }
765
766                                                 }
767                                                         break;
768                                                 default:
769                                                         TEST_DEBUG("NONE");
770                                                         break;
771                                         }
772                                 }
773                                         break;
774
775                                 case TAPI_EVENT_CALL_SETUP_CNF:
776                                 {
777                                         TEST_DEBUG("TAPI_EVENT_CALL_SETUP_CNF");
778                                         int     free_id;
779
780                                         if(event->Status == 0)
781                                         {
782                                                 memcpy(&temp_handle, event->pData, sizeof(TS_UINT));
783                                                 TEST_DEBUG("Received Call Setup for call Handle [%d]", temp_handle);
784
785                                                 free_id = call_test_ret_first_free_index();
786
787                                                 if (free_id == -1)
788                                                 {
789                                                         TEST_DEBUG("No Free Context id ...");
790                                                 }
791
792                                                 else
793                                                 {
794                                                         memcpy(&ctxt[free_id].info.callNumber, _glob_setup_info.szNumber, sizeof( _glob_setup_info.szNumber));
795                                                         ctxt[free_id].info.callState = TAPI_CALL_STATE_SETUPIND;
796                                                         ctxt[free_id].info.activeState = TAPI_CALL_CONNECT_IDLE;
797                                                         ctxt[free_id].info.isMobileOriginated = true;
798                                                         ctxt[free_id].handle = temp_handle;
799
800                                                 }
801                                         }
802                                         else
803                                                 TEST_DEBUG("event->Status is not zero..");
804                                 }
805                                         break;
806
807                                 case TAPI_EVENT_CALL_ALERT_IND:
808                                 {
809                                         int     index;
810
811                                         TEST_DEBUG("TAPI_EVENT_CALL_ALERT_IND");
812                                         memcpy(&temp_handle, event->pData, sizeof(TS_UINT));
813                                         TEST_DEBUG("Received Alert for call Handle [%d]", temp_handle);
814
815                                         index = call_test_ret_index_by_handle(temp_handle);
816
817                                         ctxt[index].info.callState = TAPI_CALL_STATE_ALERT;
818
819                                         AUTO_LOG("EVENT: ALERT_IND:- Handle [%d]", temp_handle);
820                                 }
821                                         break;
822
823                                 case TAPI_EVENT_CALL_INCOM_IND:
824                                 {
825                                         TEST_DEBUG("\n$$$$$$$$$$$$$$    TAPI_EVENT_CALL_INCOM_IND       $$$$$$$$$$$$$$\n");
826                                         call_test_process_incom_ind(event->pData);
827                                 }
828                                         break;
829
830                                 case TAPI_EVENT_CALL_WAITING_IND:
831                                         TEST_DEBUG("TAPI_EVENT_CALL_WAITING_IND");
832                                         break;
833
834                                 case TAPI_EVENT_CALL_END_IND:
835                                 {
836                                         int     index;
837                                         TelCallEndInfo_t EndInfo = {0, };
838
839                                         TEST_DEBUG("TAPI_EVENT_CALL_END_IND");
840
841                                         memcpy(&EndInfo, event->pData, sizeof(TelCallEndInfo_t));
842
843                                         TEST_DEBUG("Call Handle [%d], End Reason [%x]",
844                                                 EndInfo.pCallHandle, EndInfo.CallEndCause);
845
846                                         index = call_test_ret_index_by_handle(EndInfo.pCallHandle);
847
848                                         /*      Free this context..     */
849                                         ctxt[index].used = false;
850
851                                         memset(&ctxt[index].info, 0, sizeof(TelTapiCallInfo_t));
852
853                                         AUTO_LOG("EVENT: END_IND:- Handle [%d] CauseX [%x]",
854                                                 EndInfo.pCallHandle, EndInfo.CallEndCause);
855
856                                         /*      Continue Auto MO Call   */
857                                         call_test_count_mo();
858                                 }
859
860                                 break;
861
862                                 case TAPI_EVENT_CALL_CONNECTED_IND:
863                                 {
864                                         int     index;
865                                         //TapiResult_t  api_err = TAPI_API_SUCCESS;
866
867                                         TEST_DEBUG("TAPI_EVENT_CALL_CONNECTED_IND");
868
869                                         /*      Stop the Timer..        */
870                                         //timer_reset();
871
872                                         memcpy(&temp_handle, event->pData, sizeof(TS_UINT));
873
874                                         TEST_DEBUG("Received Connected Event  for call Handle [%d]", temp_handle);
875
876                                         curr_handle =  temp_handle;
877
878                                         index = call_test_ret_index_by_handle(temp_handle);
879
880                                         ctxt[index].info.callState = TAPI_CALL_STATE_CONV;
881                                         ctxt[index].info.activeState = TAPI_CALL_CONNECT_ACTIVE;
882
883                                         AUTO_LOG("EVENT: CONNECTED_IND:- Handle [%d]", temp_handle);
884
885                                         /*      Hold the Call after 10 sec      */
886                                         if(__call_test_auto_mo)
887                                         {
888                                                 sleep(10);
889
890                                                 call_test_auto_hold();
891                                         }
892
893                                 }
894                                         break;
895
896
897                                 case TAPI_EVENT_CALL_RETRIEVE_CNF:
898                                 {
899                                         int             index;
900                                         TapiResult_t    api_err = TAPI_API_SUCCESS;
901
902                                         TEST_DEBUG("TAPI_EVENT_CALL_RETRIEVE_CNF");
903
904                                         memcpy(&temp_handle, event->pData, sizeof(TS_UINT));
905
906                                         TEST_DEBUG("Received Activate Cnf Event  for call Handle [%d]", temp_handle);
907
908                                         index = call_test_ret_index_by_handle(temp_handle);
909
910                                         ctxt[index].info.activeState = TAPI_CALL_CONNECT_ACTIVE;
911
912                                         AUTO_LOG("EVENT: RETRIEVE_CNF:- Handle [%d]", temp_handle);
913
914                                         if(__call_test_auto_mo)
915                                         {
916                                                 sleep(3);
917
918                                                 TEST_DEBUG("### Drop the Call with handle [%d]", incoming_handle);
919
920                                                 api_err = tel_release_call(temp_handle, &RequestId);
921
922                                                 TEST_DEBUG(" Tapi return api_err value is [%x] ", api_err);
923                                                 AUTO_LOG("API: tel_release_call:- Handle [%d], Return [%d]", temp_handle, api_err);
924                                         }
925
926                                 }
927                                         break;
928
929
930                                 case TAPI_EVENT_CALL_HOLD_CNF:
931                                 {
932                                         int     index;
933
934                                         TEST_DEBUG("TAPI_EVENT_CALL_HOLD_CNF");
935
936                                         memcpy(&temp_handle, event->pData, sizeof(TS_UINT));
937
938                                         TEST_DEBUG("Received Hold Cnf Event  for call Handle [%d]", temp_handle);
939
940                                         index = call_test_ret_index_by_handle(temp_handle);
941
942                                         ctxt[index].info.activeState = TAPI_CALL_CONNECT_HELD;
943
944                                         AUTO_LOG("EVENT: HOLD_CNF:- Handle [%d]", temp_handle);
945
946                                         if(__call_test_auto_mo)
947                                         {
948                                                 sleep(5);
949
950                                                 call_test_auto_act();
951                                         }
952
953                                 }
954                                         break;
955
956
957
958                                 case TAPI_EVENT_CALL_SETUPCONFERENCE_CNF:
959                                 {
960                                         int     index;
961
962                                         TEST_DEBUG("TAPI_EVENT_CALL_SETUPCONFERENCE_CNF");
963
964                                         memcpy(&temp_handle, event->pData, sizeof(TS_UINT));
965
966                                         TEST_DEBUG("Received Conf Setup Cnf Event  for call Handle [%d]", temp_handle);
967
968                                         index = call_test_ret_index_by_handle(temp_handle);
969
970                                         ctxt[index].info.conferenceState = TAPI_CALL_CONFERENCE_ACTIVE;
971                                         ctxt[index].info.activeState = TAPI_CALL_CONNECT_HELD;
972
973                                         AUTO_LOG("EVENT: SETUPCONFERENCE_CNF:- Handle [%d]", temp_handle);
974                                 }
975                                         break;
976
977
978
979                                 case TAPI_EVENT_CALL_SPLITCONFERENCE_CNF:
980                                 {
981                                         int     index;
982
983                                         TEST_DEBUG("TAPI_EVENT_CALL_SPLITCONFERENCE_CNF");
984
985                                         memcpy(&temp_handle, event->pData, sizeof(TS_UINT));
986
987
988                                         TEST_DEBUG("Received Conf Split Cnf Event  for call Handle [%d]", temp_handle);
989
990                                         index = call_test_ret_index_by_handle(temp_handle);
991
992                                         ctxt[index].info.conferenceState = TAPI_CALL_CONFERENCE_IDLE;
993                                         AUTO_LOG("EVENT: SPLITCONFERENCE_CNF:- Handle [%d]", temp_handle);
994                                 }
995                                         break;
996
997
998
999                                 case TAPI_EVENT_CALL_TRANSFER_CNF:
1000                                 {
1001                                         int     index;
1002
1003                                         TEST_DEBUG("TAPI_EVENT_CALL_TRANSFER_CNF");
1004
1005                                         memcpy(&temp_handle, event->pData, sizeof(TS_UINT));
1006
1007                                         TEST_DEBUG("Received Tansfer Cnf Event  for call Handle [%d]", temp_handle);
1008
1009                                         index = call_test_ret_index_by_handle(temp_handle);
1010
1011                                         ctxt[index].info.callState = TAPI_CALL_STATE_ENDING;
1012                                         AUTO_LOG("EVENT: TRANSFER_CNF:- Handle [%d]", temp_handle);
1013                                 }
1014                                         break;
1015
1016
1017                                 case TAPI_EVENT_CALL_FORWARD_IND:
1018                                 {
1019                                         int     index;
1020                                         TelCallForwardType_t    type;
1021
1022                                         TEST_DEBUG("TAPI_EVENT_CALL_FORWARD_IND");
1023
1024                                         memcpy(&temp_handle, event->pData, sizeof(TS_UINT));
1025
1026                                         memcpy(&type, event->pData+sizeof(TS_UINT), sizeof(TelCallForwardType_t ));
1027
1028                                         TEST_DEBUG("Received Fw Ind Event  for call Handle [%d]", temp_handle);
1029                                         __PrintCallFwType("CallFwType: ", type);
1030
1031                                         index = call_test_ret_index_by_handle(temp_handle);
1032                                         AUTO_LOG("EVENT: FORWARD_IND::- Handle [%d]", temp_handle);
1033                                 }
1034
1035                                         break;
1036
1037                                 case TAPI_EVENT_CALL_RETRIEVE_IND:
1038                                 {
1039                                         int     index;
1040
1041                                         TEST_DEBUG("TAPI_EVENT_CALL_RETRIEVE_IND");
1042
1043                                         memcpy(&temp_handle, event->pData, sizeof(TS_UINT));
1044
1045                                         TEST_DEBUG("Received Act Ind Event for call Handle [%d]", temp_handle);
1046
1047                                         index = call_test_ret_index_by_handle(temp_handle);
1048
1049                                         ctxt[index].info.activeState = TAPI_CALL_CONNECT_ACTIVE;
1050                                         AUTO_LOG("EVENT: RETRIEVE_IND:- Handle [%d]", temp_handle);
1051                                 }
1052                                         break;
1053
1054                                 case TAPI_EVENT_CALL_HOLD_IND:
1055                                 {
1056                                         int     index;
1057
1058                                         TEST_DEBUG("TAPI_EVENT_CALL_HOLD_IND");
1059
1060                                         memcpy(&temp_handle, event->pData, sizeof(TS_UINT));
1061
1062
1063                                         TEST_DEBUG("Received Held Ind Event  for call Handle [%d]", temp_handle);
1064
1065                                         index = call_test_ret_index_by_handle(temp_handle);
1066
1067                                         ctxt[index].info.activeState = TAPI_CALL_CONNECT_HELD;
1068                                         AUTO_LOG("EVENT: HOLD_IND:- Handle [%d]", temp_handle);
1069                                 }
1070                                         break;
1071
1072                                 case TAPI_EVENT_CALL_TRANSFER_IND:
1073                                 {
1074                                         int     index;
1075
1076                                         TEST_DEBUG("TAPI_EVENT_CALL_TRANSFER_IND");
1077
1078                                         memcpy(&temp_handle, event->pData, sizeof(TS_UINT));
1079
1080                                         TEST_DEBUG("Received Tansfer Ind Event  for call Handle [%d]", temp_handle);
1081
1082                                         index = call_test_ret_index_by_handle(temp_handle);
1083                                         AUTO_LOG("EVENT: TRANSFER_IND:- Handle [%d]", temp_handle);
1084                                 }
1085                                         break;
1086
1087                                 case TAPI_EVENT_CALL_SETUPCONFERENCE_IND:
1088                                 {
1089                                         int     index;
1090
1091                                         TEST_DEBUG("TAPI_EVENT_CALL_SETUPCONFERENCE_IND");
1092
1093                                         memcpy(&temp_handle, event->pData, sizeof(TS_UINT));
1094
1095                                         TEST_DEBUG("Received Conf Setup Ind Event  for call Handle [%d]", temp_handle);
1096
1097                                         index = call_test_ret_index_by_handle(temp_handle);
1098                                         AUTO_LOG("EVENT: SETUPCONFERENCE_IND:- Handle [%d]", temp_handle);
1099
1100                                 }
1101                                         break;
1102
1103                                 case TAPI_EVENT_CALL_BARRING_IND:
1104                                 {
1105                                         int     index;
1106
1107                                         TEST_DEBUG("TAPI_EVENT_CALL_BARRING_IND");
1108
1109                                         memcpy(&temp_handle, event->pData, sizeof(TS_UINT));
1110
1111                                         TEST_DEBUG("Received Barr Ind Event  for call Handle [%d]", temp_handle);
1112
1113                                         index = call_test_ret_index_by_handle(temp_handle);
1114                                         AUTO_LOG("EVENT: BARRING_IND:- Handle [%d]", temp_handle);
1115                                 }
1116                                         break;
1117
1118
1119
1120                                 case TAPI_EVENT_CALL_SEND_DTMF_CNF:
1121                                 {
1122                                         TEST_DEBUG("Received TAPI_EVENT_CALL_SEND_DTMF_CNF");
1123                                         AUTO_LOG("EVENT: DTMF_CNF: Cnf Count [%d]", _auto_dtmf_cnf_count++);
1124                                         if((_auto_dtmf_send_count > 0) && (_auto_dtmf_send_count < 100))
1125                                                 call_test_auto_dtmf();
1126                                 }
1127                                         break;
1128
1129                                 case TAPI_EVENT_CALL_SET_LINEID_CNF:
1130                                 {
1131                                         TEST_DEBUG("Received TAPI_EVENT_CALL_SET_LINEID_CNF");
1132                                         AUTO_LOG("EVENT: SET_LINEID_CNF:");
1133                                 }
1134                                         break;
1135
1136                                 case TAPI_EVENT_CALL_GET_LINEID_CNF:
1137                                 {
1138                                         TEST_DEBUG("Received TAPI_EVENT_CALL_GET_LINEID_CNF");
1139                                         AUTO_LOG("EVENT: GET_LINEID_CNF:");
1140                                 }
1141                                         break;
1142
1143
1144                                 case TAPI_EVENT_CALL_AOCINFO_IND:
1145                                 {
1146                                         TelCallAocInfo_t        info = {0, };
1147
1148                                         TEST_DEBUG("TAPI_EVENT_CALL_AOCINFO_IND");
1149                                         memcpy(&temp_handle, event->pData, sizeof(TS_UINT));
1150
1151                                         memcpy(&info, event->pData+sizeof(TS_UINT), sizeof(TelCallAocInfo_t));
1152
1153                                         TEST_DEBUG("Received AOC Info Ind Event for call Handle [%d], acm [%u], max acm [%u]",
1154                                                 temp_handle, info.ACM, info.MaxAcm);
1155                                         AUTO_LOG("EVENT: AOCINFO_IND:- Handle [%d]", temp_handle);
1156                                 }
1157                                         break;
1158
1159                                 case TAPI_EVENT_CALL_CONNECTEDNUMBERINFO_IND:
1160                                 {
1161                                         TelCallConnectedNumberInfo_t    info = {0, };
1162
1163                                         TEST_DEBUG("TAPI_EVENT_CALL_CONNECTEDNUMBERINFO_IND");
1164
1165                                         memcpy(&temp_handle, event->pData, sizeof(TS_UINT));
1166
1167                                         memcpy(&info, event->pData+sizeof(TS_UINT), sizeof(TelCallConnectedNumberInfo_t));
1168
1169                                         TEST_DEBUG("Received SS Info Ind Event for call Handle [%d],  cli cause [%d], name mode [%d]",
1170                                                 temp_handle, info.no_cli_cause, info.name_mode);
1171                                         AUTO_LOG("EVENT: CONNECTEDNUMBERINFO_IND:- Handle [%d]", temp_handle);
1172                                 }
1173                                         break;
1174
1175
1176                                 default:
1177                                         TEST_DEBUG("Undefined Event Type [%d] Received", event->EventType);
1178                                         AUTO_LOG("EVENT: UNDEFINED EVENT:-TYPE [%d]", event->EventType);
1179                                         break;
1180
1181                         }
1182
1183                         break;
1184
1185                 default:
1186                         TEST_DEBUG("*** Other TAPI EVENT received : class=%x type=%x ****",event->EventClass, event->EventType);
1187                         break;
1188
1189         }
1190         TEST_DEBUG("****************** End event *****************************");
1191
1192 }
1193
1194 int call_test_subscribe_tapi_events (void)
1195 {
1196         int i = 0;
1197         int ret_val = TRUE;
1198         int iNumOfCALLEvt = 0;
1199         TapiResult_t    api_err = TAPI_API_SUCCESS;
1200
1201
1202         int CALLEvtList[] =
1203         {
1204                 TAPI_EVENT_CALL_SETUP_CNF,  /**<0x0000, This event indicates the Call Setup request triggered */
1205                 TAPI_EVENT_CALL_ALERT_IND,                      /**<    This event indicates the Call is in Alerting stage*/
1206                 TAPI_EVENT_CALL_CONNECTING_IND, /**<    This event indicates the Call is in Connecting stage*/
1207                 TAPI_EVENT_CALL_CONNECTED_IND,  /**<    This event indicates the Call is Connected */
1208                 TAPI_EVENT_CALL_INCOM_IND    ,          /**<    This event indicates Incoming Call indication to Application*/
1209                 TAPI_EVENT_CALL_ANSWER_CNF,     /**<    Incoming call was answered*/
1210                 TAPI_EVENT_CALL_RETRIEVE_CNF,   /**<    This event indicates Call is retrieved from held state*/
1211                 TAPI_EVENT_CALL_RETRIEVE_IND,   /**<    This event indicates that other party has retrieved the call from hold*/
1212                 TAPI_EVENT_CALL_HOLD_IND,               /**<    This event indicates that other party is has put the call on hold*/
1213                 TAPI_EVENT_CALL_HOLD_CNF ,              /**<    This event indicates is call is put on hold*/
1214                 TAPI_EVENT_CALL_TRANSFER_CNF,   /**<    This event indicates is call is explicitly transferred*/
1215                 TAPI_EVENT_CALL_TRANSFER_IND,   /**<    Call Transfer Indication*/
1216                 TAPI_EVENT_CALL_SETUPCONFERENCE_CNF,            /**<    This event indicates that Call is joined in a conference*/
1217                 TAPI_EVENT_CALL_SETUPCONFERENCE_IND,            /**<    Conference setup indication*/
1218                 TAPI_EVENT_CALL_SPLITCONFERENCE_CNF,            /**<    This event indicates Call is split from conference*/
1219                 TAPI_EVENT_CALL_SEND_DTMF_CNF,  /**<    This event indicates the confirmation for sending DTMF Digits to the network*/
1220                 TAPI_EVENT_CALL_WAITING_IND,                    /**<    Call waiting indication*/
1221                 TAPI_EVENT_CALL_FORWARD_IND,            /**<    This event indication for Call is forwarded */
1222                 TAPI_EVENT_CALL_RELEASE_CNF,            /**<    This event is indicated when a specific call is released requested by the application*/
1223                 TAPI_EVENT_CALL_RELEASE_ALL_CNF,        /**<    This event is indicated when all the calls released requested by the application*/
1224                 TAPI_EVENT_CALL_RELEASE_ALL_ACTIVE_CNF, /**<    This event is indicated when all the active calls released requested by the application*/
1225                 TAPI_EVENT_CALL_RELEASE_ALL_HELD_CNF,           /**<    This event is indicated when all the held calls released requested by the application*/
1226                 TAPI_EVENT_CALL_END_IND,                         /**<   This event indicates the Call is Ended. This event can be solicited/unsolicited.*/
1227                 TAPI_EVENT_CALL_GET_LINEID_CNF, /**<    Error in Get Line ID    */
1228                 TAPI_EVENT_CALL_SET_LINEID_CNF, /**<            Error in Set Line Id            */
1229                 TAPI_EVENT_CALL_SWAP_CNF, /**< Call Swap Confirmation */
1230                 TAPI_EVENT_CALL_GET_PRIVACYMODE_CNF,    /**<    Get Privacy mode        */
1231                 TAPI_EVENT_CALL_SET_PRIVACYMODE_CNF, /**<               Set Privacy mode        */
1232                 TAPI_EVENT_CALL_PRIVACYMODE_IND,        /**<    Privacy mode Indication */
1233                 TAPI_EVENT_CALL_FLASHINFO_CNF, /**<             Flash info      */
1234                 TAPI_EVENT_CALL_EXIT_EMERGENCYMODE_CNF, /**<            Exit Emergency mode     cnf */
1235                 TAPI_EVENT_CALL_EMERGENCYMODE_IND, /**<          Emergency mode ind */
1236                 TAPI_EVENT_CALL_TIME_CNF, /**<           call time cnf */
1237                 TAPI_EVENT_CALL_TIME_IND, /**<           call time ind */
1238                 TAPI_EVENT_CALL_OTA_PROGRESS_IND, /**<           ota progress ind */
1239                 TAPI_EVENT_CALL_DISPLAY_INFO_IND, /**<           display info ind */
1240                 TAPI_EVENT_CALL_BARRING_IND,                    /**<    This event indicates the Call is Barred*/
1241                 TAPI_EVENT_CALL_FORWARDED_INFO_IND,     /**<    This event indicates the MT call is Forwarded*/
1242                 TAPI_EVENT_CALL_AOCINFO_IND,    /**<    This event indicates the AOC Information*/
1243                 TAPI_EVENT_CALL_CALLINGNAMEINFO_IND,    /**<    This event indicates the Calling Name Information*/
1244                 TAPI_EVENT_CALL_CONNECTEDNUMBERINFO_IND,        /**<    This event indicates the Connected Number Information*/
1245                 TAPI_EVENT_CALL_CLISUPRESSIONREJ_IND,   /**<    This event indicates the CLI Suppression Indication*/
1246                 TAPI_EVENT_CALL_DEFLECTED_IND,  /**<    This event indicates the Call is Deflected*/
1247                 TAPI_EVENT_CALL_UNCOND_FORWARDING_IND,  /**<    This event indicates the Call is unconditionally forwarded*/
1248                 TAPI_EVENT_CALL_COND_FORWARDING_IND,    /**<    This event indicates the Call is conditionally forwarded*/
1249                 TAPI_EVENT_CALL_CONNECTED_ECT_REMOTE_IND,       /**<    This event indicates the ECT remote connection  */
1250                 TAPI_EVENT_CALL_ON_HOLD_RELEASED_IND,   /**<    This event indicates the Call on hold is released*/
1251                 TAPI_EVENT_CALL_ALERT_ECT_REMOTE_IND,   /**<    This event indicates the ECT remote alert*/
1252                 TAPI_EVENT_CALL_SS_FORWARDED_MSG_RXED_IND,      /**<    This event indicates that the forwarded msg has been received*/
1253         };
1254
1255         iNumOfCALLEvt = sizeof(CALLEvtList)/sizeof(int);
1256         CALL_subscription_id = (unsigned int *) calloc (iNumOfCALLEvt, sizeof (unsigned int));
1257
1258
1259
1260         for( i=0 ; i< iNumOfCALLEvt; i++ )
1261         {
1262                 api_err = tel_register_event(CALLEvtList[i], &CALL_subscription_id[i],(TelAppCallback)&call_async_event_callback,NULL );
1263                 if(api_err != TAPI_API_SUCCESS)
1264                 {
1265                         TEST_DEBUG("isn't subscribed. event id is %d, api_err is %d\n", CALLEvtList[i],api_err);
1266                         ret_val = FALSE;
1267                         break;
1268                 }
1269         }
1270
1271         return ret_val;
1272
1273
1274
1275 #if 0
1276         char *videocallEvents[] = {
1277                         "Telephony.Call.Video.SetupCnf",
1278                         "Telephony.Call.Video.AlertInd",
1279                         "Telephony.Call.Video.ConnectedInd",
1280                         "Telephony.Call.Video.IncomingInd",
1281                         "Telephony.Call.Video.AnswerCnf",
1282                         "Telephony.Call.Video.ForwardInd",
1283                         "Telephony.Call.Video.ReleaseCnf",
1284                         "Telephony.Call.Video.EndInd",
1285                          "Telephony.Call.Video.BarringInd",
1286                          "Telephony.Call.Video.ForwardedInfoInd",
1287                          "Telephony.Call.Video.AocInfoInd",
1288                         "Telephony.Call.Video.ConnectedNumberInfoInd",
1289                         "Telephony.Call.Video.UncondforwardingActiveInd",
1290                          "Telephony.Call.Video.CondforwardingActiveInd",
1291                          "Telephony.Call.Video.ConnectedEctRemoteInd",
1292         };
1293
1294         for(count =0;count  <  (sizeof(videocallEvents)/sizeof(*videocallEvents)) ; count++)
1295         {
1296                 error_code = EvtSysEventSubscribe (
1297                                 EvtDeliveryHandle,
1298                                 videocallEvents[count],                         /* notification ID */
1299                                 NULL,                                           /*      filter expression       */
1300                                 (EvtSysEventCb)call_test_noti_cb,               /* notification handler */
1301                                 (void *)&sdata,                         /* local data */
1302                                 &subscription_id2                       /* subscription ID */
1303                                 );
1304                 if (error_code )
1305                 {
1306                         TEST_DEBUG( " EvtSysEventSubscribe(): error [%#X] for event [%s]", error_code , videocallEvents[count]);
1307                 }
1308         }
1309
1310
1311         return 0;
1312 #endif
1313 }
1314
1315
1316 int call_test_exit(void)
1317 {
1318         int result = 0;
1319         return result;
1320 }
1321
1322
1323
1324 int call_test_get_request(void)
1325 {
1326         //char ch;
1327         int ret;
1328         //char callId=0;
1329         //unsigned short len;
1330         char buf[256];
1331         char dtmfStr[16] = "1000103001";
1332         //char normal[16] = "+91";
1333         //unsigned short error;
1334         TapiResult_t            api_err = TAPI_API_SUCCESS;
1335         int index;
1336         int RequestID;
1337         _auto_dtmf_send_count = 0;
1338         _auto_dtmf_cnf_count = 0;
1339
1340         for(index=0; index<TAPI_CONTEXT_CALL_SIZE_MAX; index++)
1341         {
1342                 if(ctxt[index].used == true)
1343                 {
1344                         api_err = tel_get_call_status( ctxt[index].handle, &gcallStatus[index]);
1345
1346                         if(api_err != TAPI_API_SUCCESS)
1347                         {
1348                                 TEST_DEBUG("Get Call Status Failed: returnStatus value is [%x] for handle[%d] ", api_err, ctxt[index].handle);
1349                         }
1350                 }
1351         }
1352
1353
1354         printf("\n -----------------------------------------------------------------------------");
1355         printf("\n ############  For gsm/wcdma/cdma ############ ");
1356         printf("\n tel_exe_call_mo              :       mo <Number>");
1357         printf("\n tel_exe_call_mo (SOS)                                :       sos <Number>");
1358         printf("\n tel_answer_call (Accept)             :       ans");
1359         printf("\n tel_answer_call (Reject)                     :       rej");
1360         printf("\n tel_send_call_dtmf                           :       dtmf <String>");
1361         printf("\n tel_release_call                             :       drop <Call handle>");
1362         printf("\n tel_release_call_all                         :       rall");
1363         printf("\n tel_get_call_status  (SyncAPI)               :       status <Call handle>");
1364         printf("\n tel_get_call_duration (SyncAPI)              :       duration <Call handle>");
1365         printf("\n Get call state from NPS (SyncAPI)            :       state");
1366
1367         printf("\n ############  For only gsm/wcdma ############ ");
1368         printf("\n tel_answer_call(Hold&Accept)                 :       hna");
1369         printf("\n tel_answer_call(Replace)                     :       rep");
1370         printf("\n tel_hold_call                                :       hld <Call handle>");
1371         printf("\n tel_retrieve_call                            :       act <Call handle>");
1372         printf("\n tel_swap_call                :       swap <Active Call handle> <Held Call handle>");
1373         printf("\n tel_exe_call_explicit_transfer                       :       tran <Active Call handle>");
1374         printf("\n tel_join_call                                :       join <Active Call handle> <Held Call handle>");
1375         printf("\n tel_split_call                       :       split <Call handle>");
1376         printf("\n tel_release_call_all_active                  :       ract");
1377         printf("\n tel_release_call_all_held                    :       rhld");
1378         printf("\n tel_activate_call_ccbs (not supported)               :       ccbs <Call handle>");
1379         printf("\n tel_deflect_call (not supported)             :       defl <Number>");
1380         printf("\n tel_get_call_act_line                :       lineg");
1381         printf("\n tel_set_call_act_line                :       lines");
1382         printf("\n tel_get_call_conf_list(SyncAPI)              :       conflist <Call handle>");
1383
1384         printf("\n ############  For only cdma ############ ");
1385         printf("\n tel_exe_call_flash_info                              :       flash1  ");
1386         printf("\n tel_exe_call_flash_info (with Number)                :       flash2 <Number>");
1387         printf("\n tel_get_call_privacy_mode                    :       pmodeg <vp_type(1/2/3)>");
1388         printf("\n tel_set_call_privacy_mode            :       pmodes <vp_type(1/2/3)> <vp_mode(0/1)>");
1389         printf("\n tel_exit_call_emergency_mode                 :       xemer ");
1390         printf("\n tel_get_call_time                    :       time <mask(count 1, total time 2 last time 4)>");
1391
1392         printf("\n\n quit                                               :        quit ");
1393         printf("\n -----------------------------------------------------------------------------");
1394
1395
1396         printf("\n########################################################\n\n");
1397
1398         for(index=0; index<TAPI_CONTEXT_CALL_SIZE_MAX; index++)
1399         {
1400                 if(ctxt[index].used == true)
1401                 {
1402                         fprintf(stderr, " Index:[%d], handle: [%d], [%s], [%s],[%s],",
1403                                 index, ctxt[index].handle, gcallStatus[index].pNumber, (gcallStatus[index].bMoCall)?"MO":"MT", (gcallStatus[index].bConferenceState)?"Conference":"Single");
1404                         __PrintCallType(" ", gcallStatus[index].CallType);
1405                         __PrintCallState("\n Call State:", gcallStatus[index].CallState);
1406                         __PrintActiveCallState(" Active Call State:", gcallStatus[index].CallActiveState);
1407                         fprintf(stderr, "\n");
1408                 }
1409         }
1410         printf("\n########################################################\n");
1411
1412         ret = read(0, buf, sizeof(buf));
1413
1414         if (ret < 0) {
1415                 if (errno == EINTR)
1416                 perror("read(1)");
1417                 return -1;
1418         } else if (ret == 0) return ret;
1419
1420
1421
1422         TEST_DEBUG("Enter the API code: ");
1423
1424
1425         /******************************************************************************
1426         *
1427         *                                                               C A L L  A P I
1428         *
1429         *******************************************************************************/
1430
1431         if(strncmp(buf, "flash1", 6) == 0)
1432         {
1433                 TEST_DEBUG("###flash1 .... ");
1434
1435                 api_err = tel_exe_call_flash_info(NULL,&RequestID);
1436
1437                 TEST_DEBUG(" \n tel_exe_call_flash_info Tapi return returnStatus value is [%x]  RequestID : %d \n ", api_err, RequestID);
1438       }
1439
1440
1441         if(strncmp(buf, "flash2", 6) == 0)
1442         {
1443                 char            tempNum[TAPI_CALL_DIALDIGIT_LEN_MAX+1];
1444                 char    DialNum[TAPI_CALL_DIALDIGIT_LEN_MAX+1];
1445                 int             length = 0;
1446                 strncpy(tempNum, &buf[7], TAPI_CALL_DIALDIGIT_LEN_MAX);
1447                 length = strlen(tempNum);
1448                 strncpy(DialNum,tempNum, length-1);  // removing '/n' form the end of the string
1449                 TEST_DEBUG("### dial number :[%s]", DialNum);
1450
1451                 api_err = tel_exe_call_flash_info(DialNum, &RequestID);
1452
1453                 TEST_DEBUG(" Tapi return api_err value is [%x] ", api_err);
1454         }
1455
1456         if(strncmp(buf, "pmodeg", 6) == 0)
1457         {
1458                 char temp[2];
1459                 int  vp_type= -1;
1460
1461                 memset(temp, 0, 2);
1462                 memcpy(&temp, &buf[7], 1);
1463                 vp_type = atoi(temp);
1464
1465                 TEST_DEBUG("### tel_get_call_privacy_mode: vp_type [%d]", vp_type);
1466
1467                 api_err = tel_get_call_privacy_mode(vp_type,&RequestID);
1468
1469                 TEST_DEBUG(" Tapi return api_err value is [%x] ", api_err);
1470         }
1471
1472         if(strncmp(buf, "pmodes", 6) == 0)
1473         {
1474                 TEST_DEBUG("### tel_set_call_privacy_mode");
1475
1476                 char temp[2];
1477                 TelCallVoicePrivacyInfo_t vp_info = { 0, };
1478
1479                 memset(temp, 0, 2);
1480                 memcpy(&temp, &buf[7], 1);
1481                 vp_info.PrivacyType = atoi(temp);
1482
1483                 memset(temp, 0, 2);
1484                 memcpy(&temp, &buf[9], 1);
1485                 vp_info.PrivacyMode = atoi(temp);
1486
1487                 TEST_DEBUG("### tel_set_call_privacy_mode: vp_type [%d] vp_mode [%d]", vp_info.PrivacyType, vp_info.PrivacyMode);
1488
1489                 api_err = tel_set_call_privacy_mode(vp_info,&RequestID);
1490
1491                 TEST_DEBUG(" Tapi return api_err value is [%x] ", api_err);
1492         }
1493
1494         if(strncmp(buf, "xemer", 5) == 0)
1495         {
1496                 TEST_DEBUG("###tel_exit_call_emergency_mode");
1497
1498                 api_err = tel_exit_call_emergency_mode(&RequestID);
1499
1500                 TEST_DEBUG(" Tapi return api_err value is [%x] ", api_err);
1501       }
1502
1503         if(strncmp(buf, "time", 4) == 0)
1504         {
1505                 TEST_DEBUG("###tel_get_call_time");
1506                 char temp[2];
1507                 unsigned short mask= -1;
1508
1509                 memset(temp, 0, 2);
1510                 memcpy(&temp, &buf[5], 1);
1511                 mask = atoi(temp);
1512
1513                 TEST_DEBUG("###tel_get_call_time.. req mask type:[0x%x]",mask );
1514
1515                 api_err = tel_get_call_time(mask, &RequestID);
1516
1517                 TEST_DEBUG(" Tapi return api_err value is [%x] ", api_err);
1518
1519       }
1520 //######################################################################
1521         if(strncmp(buf, "sos", 3) == 0)
1522         {
1523 //              int     free_id;
1524                 char    tempNum[TAPI_CALL_DIALDIGIT_LEN_MAX+1];
1525                 int             length = 0;
1526
1527                 strncpy(tempNum, &buf[4], TAPI_CALL_DIALDIGIT_LEN_MAX);
1528                 length = strlen(tempNum);
1529
1530                 memset(&_glob_setup_info, 0, sizeof(_glob_setup_info));
1531
1532                 strncpy(_glob_setup_info.szNumber,tempNum, length-1);  // removing '/n' form the end of the string
1533
1534         _glob_setup_info.CallType=TAPI_CALL_TYPE_E911;
1535
1536                 TEST_DEBUG("Request to Setup call with Number [%s], type %d",   _glob_setup_info.szNumber, _glob_setup_info.CallType);
1537
1538                 api_err = tel_exe_call_mo(&_glob_setup_info, &curr_handle, &RequestID);
1539
1540                 TEST_DEBUG(" after calling tel_exe_call_mo : Handle [%d]", curr_handle);
1541
1542                 TEST_DEBUG(" Tapi return api_err value is [%x] ", api_err);
1543
1544 #if 0 // move to call setup cnf event
1545                 if(api_err == TAPI_API_SUCCESS)
1546                 {
1547                         free_id = call_test_ret_first_free_index();
1548
1549                         if (free_id == -1)
1550                         {
1551                                 TEST_DEBUG("No Free Context ...");
1552                         }
1553
1554                         else
1555                         {
1556                                 memcpy(&ctxt[free_id].info.callNumber, _glob_setup_info.szNumber, sizeof( _glob_setup_info.szNumber));
1557                                 ctxt[free_id].info.callState = TAPI_CALL_STATE_ORIG;
1558                                 ctxt[free_id].info.activeState = TAPI_CALL_CONNECT_IDLE;
1559                                 ctxt[free_id].info.isMobileOriginated = true;
1560                                 ctxt[free_id].handle = curr_handle;
1561
1562                         }
1563                 }
1564 #endif
1565
1566
1567       }
1568
1569 #if 0
1570         if(strncmp(buf, "automo", 6) == 0)
1571         {
1572                 char temp[16] = {0, };
1573
1574                 memcpy(temp, &buf[7], _country_spc_num_);
1575
1576
1577                 memset(&_glob_setup_info, 0, sizeof(_glob_setup_info));
1578
1579                 _glob_setup_info.CallType=TAPI_CALL_TYPE_VOICE;
1580                 strncpy(_glob_setup_info.szNumber, pre_string, sizeof(pre_string));
1581
1582                 strncat(_glob_setup_info.szNumber, temp, _country_spc_num_);
1583
1584                 _glob_setup_info.IdentityMode = TAPI_CALL_IDENTITY_SHOW;
1585
1586                 call_test_auto_mo();
1587
1588         }
1589
1590         if(strncmp(buf, "autoans", 7) == 0)
1591         {
1592                 call_test_auto_ans();
1593         }
1594
1595 #endif
1596         if(strncmp(buf, "vmo", 2) == 0)
1597         {
1598 //              int     free_id;
1599                 char    tempNum[TAPI_CALL_DIALDIGIT_LEN_MAX+1];
1600                 int             length = 0;
1601
1602                 strncpy(tempNum, &buf[4], TAPI_CALL_DIALDIGIT_LEN_MAX);
1603                 length = strlen(tempNum);
1604
1605                 memset(&_glob_setup_info, 0, sizeof(_glob_setup_info));
1606
1607                 strncpy(_glob_setup_info.szNumber,tempNum, length-1);  // removing '/n' form the end of the string
1608
1609                 _glob_setup_info.CallType=TAPI_CALL_TYPE_DATA;
1610
1611                 TEST_DEBUG("Request to Setup call with Number [%s], type %d",   _glob_setup_info.szNumber, _glob_setup_info.CallType);
1612
1613                 api_err = tel_exe_call_mo(&_glob_setup_info, &curr_handle, &RequestID);
1614
1615                 TEST_DEBUG(" after calling tel_exe_call_mo : Handle [%d]", curr_handle);
1616
1617                 TEST_DEBUG(" Tapi return api_err value is [%x] ", api_err);
1618 #if 0 // move to call setup cnf event
1619                 if(api_err == TAPI_API_SUCCESS)
1620                 {
1621                         free_id = call_test_ret_first_free_index();
1622
1623                         if (free_id == -1)
1624                         {
1625                                 TEST_DEBUG("No Free Context ...");
1626                         }
1627
1628                         else
1629                         {
1630                                 memcpy(&ctxt[free_id].info.callNumber, _glob_setup_info.szNumber, sizeof( _glob_setup_info.szNumber));
1631                                 ctxt[free_id].info.callState = TAPI_CALL_STATE_ORIG;
1632                                 ctxt[free_id].info.activeState = TAPI_CALL_CONNECT_IDLE;
1633                                 ctxt[free_id].info.isMobileOriginated = true;
1634                                 ctxt[free_id].handle = curr_handle;
1635
1636                         }
1637                 }
1638 #endif
1639
1640       }
1641
1642         if(strncmp(buf, "mo", 2) == 0)
1643         {
1644 //              int     free_id;
1645                 char    tempNum[TAPI_CALL_DIALDIGIT_LEN_MAX+1];
1646                 int             length = 0;
1647
1648                 strncpy(tempNum, &buf[3], TAPI_CALL_DIALDIGIT_LEN_MAX);
1649                 length = strlen(tempNum);
1650
1651                 memset(&_glob_setup_info, 0, sizeof(_glob_setup_info));
1652
1653                 strncpy(_glob_setup_info.szNumber,tempNum, length-1);  // removing '/n' form the end of the string
1654
1655                 _glob_setup_info.CallType=TAPI_CALL_TYPE_VOICE;
1656                 //_glob_setup_info.Ecc=TAPI_CALL_ECC_DEFAULT;
1657
1658                 TEST_DEBUG("Request to Setup call with Number [%s], type %d",   _glob_setup_info.szNumber, _glob_setup_info.CallType);
1659
1660                 api_err = tel_exe_call_mo(&_glob_setup_info, &curr_handle, &RequestID);
1661
1662                 TEST_DEBUG(" after calling tel_exe_call_mo : Handle [%d]", curr_handle);
1663
1664                 TEST_DEBUG(" Tapi return api_err value is [%x] ", api_err);
1665
1666 #if 0 // move to call setup cnf event
1667                 if(api_err == TAPI_API_SUCCESS)
1668                 {
1669                         free_id = call_test_ret_first_free_index();
1670
1671                         if (free_id == -1)
1672                         {
1673                                 TEST_DEBUG("No Free Context ...");
1674                         }
1675
1676                         else
1677                         {
1678                                 memcpy(&ctxt[free_id].info.callNumber, _glob_setup_info.szNumber, sizeof( _glob_setup_info.szNumber));
1679                                 ctxt[free_id].info.callState = TAPI_CALL_STATE_ORIG;
1680                                 ctxt[free_id].info.activeState = TAPI_CALL_CONNECT_IDLE;
1681                                 ctxt[free_id].info.isMobileOriginated = true;
1682                                 ctxt[free_id].handle = curr_handle;
1683
1684                         }
1685                 }
1686 #endif
1687
1688       }
1689
1690
1691         if( strncmp(buf, "ans", 3) == 0 )
1692         {
1693                 TEST_DEBUG("###answer incoming call");
1694
1695                 api_err = tel_answer_call(incoming_handle, TAPI_CALL_ANSWER_ACCEPT, &RequestID);
1696
1697                 TEST_DEBUG(" Tapi return api_err value is [%x] ", api_err);
1698       }
1699
1700         if( strncmp(buf, "hna", 3) == 0 )
1701         {
1702 //              TS_UINT active_handle = -1;
1703
1704 //              active_handle = call_test_ret_handle_by_active_state();
1705
1706 //              TEST_DEBUG("### hold active call [%d] and accept waiting call", active_handle);
1707
1708                 TEST_DEBUG("### hold active call and accept waiting call");
1709
1710                 api_err = tel_answer_call(incoming_handle, TAPI_CALL_ANSWER_HOLD_AND_ACCEPT, &RequestID);
1711
1712                 TEST_DEBUG(" Tapi return api_err value is [%x] ", api_err);
1713       }
1714
1715         if( strncmp(buf, "rep", 3) == 0 )
1716         {
1717 //              TS_UINT active_handle = -1;
1718
1719 //              active_handle = call_test_ret_handle_by_active_state();
1720
1721 //              TEST_DEBUG("### release active call [%d] and accept waiting call", active_handle);
1722
1723                 TEST_DEBUG("### release active call and accept waiting call");
1724
1725                 api_err = tel_answer_call(incoming_handle, TAPI_CALL_ANSWER_REPLACE, &RequestID);
1726
1727                 TEST_DEBUG(" Tapi return api_err value is [%x] ", api_err);
1728       }
1729
1730
1731         if( strncmp(buf, "rej", 3) == 0 )
1732         {
1733                 TEST_DEBUG("### reject waiting call ");
1734
1735                 api_err = tel_answer_call(incoming_handle, TAPI_CALL_ANSWER_REJECT, &RequestID);
1736
1737                 TEST_DEBUG(" Tapi return api_err value is [%x] ", api_err);
1738       }
1739
1740 //+++++++++++ Release
1741         if( strncmp(buf, "rall", 4) == 0 )
1742         {
1743                 TEST_DEBUG("### release all calls. ");
1744
1745                 api_err = tel_release_call_all(&RequestID);
1746
1747                 TEST_DEBUG(" Tapi return api_err value is [%x] ", api_err);
1748       }
1749
1750         if( strncmp(buf, "rall.e", 6) == 0 )
1751         {
1752                 TEST_DEBUG("### release all calls.with err option ");
1753
1754                 api_err = tel_release_call(curr_handle, &RequestID);
1755
1756                 TEST_DEBUG(" Tapi returned api_err value is [%x] ", api_err);
1757       }
1758
1759         if( strncmp(buf, "ract", 4) == 0 )
1760         {
1761                 TEST_DEBUG("### release all active calls. ");
1762
1763                 api_err = tel_release_call_all_active( &RequestID);
1764
1765                 TEST_DEBUG(" Tapi return api_err value is [%x] ", api_err);
1766       }
1767
1768         if( strncmp(buf, "rhld", 4) == 0 )
1769         {
1770                 TEST_DEBUG("### release all held calls. ");
1771
1772                 api_err = tel_release_call_all_held( &RequestID);
1773
1774                 TEST_DEBUG(" Tapi return api_err value is [%x] ", api_err);
1775       }
1776
1777         if( strncmp(buf, "drop", 4) == 0 )
1778         {
1779                 char temp[2];
1780                 TS_UINT handle= -1;
1781
1782                 memset(temp, 0, 2);
1783                 memcpy(&temp, &buf[5], 1);
1784                 handle = atoi(temp);
1785
1786                 TEST_DEBUG("### Drop the Call with handle [%d]", handle);
1787
1788                 api_err = tel_release_call(handle,  &RequestID);
1789
1790                 TEST_DEBUG(" Tapi return api_err value is [%x] ", api_err);
1791
1792       }
1793
1794
1795
1796         if( strncmp(buf, "hld", 3) == 0 )
1797         {
1798                 char temp[2];
1799                 TS_UINT handle= -1;
1800
1801                 memset(temp, 0, 2);
1802                 memcpy(&temp, &buf[4], 1);
1803                 handle = atoi(temp);
1804
1805                 TEST_DEBUG("### Hold the call No. %d !!", handle);
1806
1807                 api_err = tel_hold_call(handle, &RequestID);
1808
1809                 TEST_DEBUG(" Tapi return api_err value is [%x] ", api_err);
1810
1811         }
1812
1813
1814         if( strncmp(buf, "act", 3) == 0 )
1815         {
1816                 char temp[2];
1817                 TS_UINT handle= -1;
1818
1819                 memset(temp, 0, 2);
1820                 memcpy(&temp, &buf[4], 1);
1821                 handle = atoi(temp);
1822
1823                 TEST_DEBUG("### Activate the call No. %d !!", handle);
1824
1825                 api_err = tel_retrieve_call(handle, &RequestID);
1826
1827                 TEST_DEBUG(" Tapi return api_err value is [%x] ", api_err);
1828         }
1829
1830         if( strncmp(buf, "swap", 4) == 0 )
1831         {
1832                 char temp[2];
1833                 TS_UINT held_handle, active_handle = -1;
1834
1835                 memset(temp, 0, 2);
1836                 memcpy(&temp, &buf[5], 1);
1837                 active_handle = atoi(temp);
1838
1839                 memset(temp, 0, 2);
1840                 memcpy(&temp, &buf[7], 1);
1841                 held_handle = atoi(temp);
1842
1843                 TEST_DEBUG("### Swap! Active call No, [%d], Hold the call No. [%d]",
1844                         active_handle, held_handle);
1845
1846                 api_err = tel_swap_call(active_handle, held_handle, &RequestID);
1847
1848                 TEST_DEBUG(" Tapi return api_err value is [%x] ", api_err);
1849       }
1850
1851
1852         if( strncmp(buf, "join", 4) == 0 )
1853         {
1854                 char temp[2];
1855                 TS_UINT held_handle, active_handle = -1;
1856
1857                 memset(temp, 0, 2);
1858                 memcpy(&temp, &buf[5], 1);
1859                 active_handle = atoi(temp);
1860
1861                 memset(temp, 0, 2);
1862                 memcpy(&temp, &buf[7], 1);
1863                 held_handle = atoi(temp);
1864
1865                 TEST_DEBUG("Setup a Conference Call with Active & Held Handles [%d] [%d]",
1866                         active_handle, held_handle);
1867
1868                 api_err = tel_join_call(active_handle,  held_handle, &RequestID);
1869
1870                 TEST_DEBUG(" Tapi return api_err value is [%x] ", api_err);
1871
1872         }
1873
1874
1875         if( strncmp(buf, "split", 5) == 0 )
1876         {
1877                 char temp[2];
1878                 TS_UINT  handle = -1;
1879
1880                 memset(temp, 0, 2);
1881                 memcpy(temp, &buf[6], 1);
1882                 handle = atoi(temp);
1883
1884                 TEST_DEBUG("Split Call Handle [%d] from Conference call", handle);
1885
1886                 api_err = tel_split_call(handle, &RequestID);
1887
1888                 TEST_DEBUG(" Tapi return api_err value is [%x] ", api_err);
1889         }
1890
1891         if(strncmp(buf, "conflist", 8) == 0)
1892         {
1893                 unsigned int  callList[10];
1894                 int  noOfCalls;
1895                 char temp[2];
1896                 int i=0;
1897                 TS_UINT  handle = -1;
1898
1899                 memset(temp, 0, 2);
1900                 memcpy(temp, &buf[9], 1);
1901                 handle = atoi(temp);
1902
1903                 TEST_DEBUG("Get Conference List for call handle [%d]", handle);
1904
1905                 api_err = tel_get_call_conf_list(handle, callList, &noOfCalls);
1906
1907                 if(api_err == TAPI_API_SUCCESS)
1908                 {
1909                     TEST_DEBUG(" Get Conference List () - call handle : %d   No.of Calls %d",handle, noOfCalls );
1910
1911                     for(i=0;i<noOfCalls;i++)
1912                     {
1913                         TEST_DEBUG("Voice Test: Call Handle %d  : %d\n", i+1, callList[i]);
1914                     }
1915                 }
1916                 else
1917                 {
1918                     TEST_DEBUG("Voice Test: Get Conference List  Failed: returnStatus value is [%d]", api_err);
1919                 }
1920
1921         }
1922
1923
1924         if(strncmp(buf, "status", 6) == 0)
1925         {
1926                 TelCallStatus_t callStatus;
1927                 char temp[2];
1928                 TS_UINT  handle = -1;
1929
1930                 memset(temp, 0, 2);
1931                 memcpy(temp, &buf[7], 1);
1932                 handle = atoi(temp);
1933
1934                 TEST_DEBUG(" Get Call Status informaiton for call handle %d", handle);
1935
1936                 api_err = tel_get_call_status(handle, &callStatus);
1937
1938                 if(api_err == TAPI_API_SUCCESS)
1939                 {
1940                         fprintf(stderr, "\n\t CallNumber             : %s",callStatus.pNumber);
1941                         fprintf(stderr, "\n\t Is Mobile Originated   : %d(1:true, 0:false)", callStatus.bMoCall);
1942                         __PrintCallType("\n\t CallType               :", callStatus.CallType);
1943                         __PrintActiveCallState("\n\t CallActiveState        :", callStatus.CallActiveState);
1944                         __PrintCallState("\n\t CallState              :", callStatus.CallState);
1945                         fprintf(stderr, "\n\t isConferenceState : %d(1:true, 0:false)\n",callStatus.bConferenceState);
1946                 }
1947                 else
1948                 {
1949                     TEST_DEBUG("Get Call Status Failed: returnStatus value is [%x] ", api_err);
1950                 }
1951
1952         }
1953
1954         if( strncmp(buf, "duration", 8) == 0 )
1955         {
1956                 char temp[2];
1957                 unsigned int duration;
1958                 TS_UINT  handle = -1;
1959
1960                 memset(temp, 0, 2);
1961                 memcpy(temp, &buf[9], 1);
1962                 handle = atoi(temp);
1963
1964
1965                 TEST_DEBUG("### Get Duration for  the call handle. %d !!", handle);
1966
1967                 api_err = tel_get_call_duration(handle, &duration);
1968                 TEST_DEBUG("Call Duration for the Call handle [%d] is: [%d] sec  \n", handle, duration);
1969         }
1970
1971
1972         if(strncmp(buf, "tran", 4) == 0)
1973         {
1974                 char temp[2];
1975                 TS_UINT active_handle = -1;
1976
1977                 memset(temp, 0, 2);
1978                 memcpy(&temp, &buf[5], 1);
1979                 active_handle = atoi(temp);
1980
1981
1982                 TEST_DEBUG("Transfer calls with handles [%d]", active_handle);
1983
1984                 api_err = tel_exe_call_explicit_transfer(active_handle,  &RequestID);
1985
1986                 TEST_DEBUG(" Tapi return api_err value is [%x] ", api_err);
1987
1988       }
1989
1990         if(strncmp(buf, "dtmf", 4) == 0)
1991         {
1992                 char            tempStr[MAX_BURST_DTMF_STRLEN] ={0,};
1993                 char    str[MAX_BURST_DTMF_STRLEN] = {0,};
1994                 int             length = 0;
1995                 strncpy(tempStr, &buf[5], MAX_BURST_DTMF_STRLEN);
1996                 length = strlen(tempStr);
1997                 strncpy(str,tempStr, length-1);  // removing '/n' form the end of the string
1998                 TEST_DEBUG("### Send DTMF - [%s]", str);
1999
2000                 api_err = tel_send_call_dtmf(str, &RequestID);
2001
2002                 TEST_DEBUG(" Tapi return api_err value is [%x] ", api_err);
2003         }
2004         if(strncmp(buf, "clir", 4) == 0)
2005         {
2006 //              int     free_id;
2007                 char    tempNum[TAPI_CALL_DIALDIGIT_LEN_MAX+1];
2008                 int             length = 0;
2009
2010                 strncpy(tempNum, &buf[5], TAPI_CALL_DIALDIGIT_LEN_MAX);
2011                 length = strlen(tempNum);
2012
2013                 memset(&_glob_setup_info, 0, sizeof(_glob_setup_info));
2014
2015                 strncpy(_glob_setup_info.szNumber,tempNum, length-1);  // removing '/n' form the end of the string
2016
2017                 _glob_setup_info.CallType=TAPI_CALL_TYPE_VOICE;
2018
2019                 TEST_DEBUG("Request to Setup CLIR call with Number [%s], type %d",      _glob_setup_info.szNumber, _glob_setup_info.CallType);
2020
2021                 api_err = tel_exe_call_mo(&_glob_setup_info, &curr_handle, &RequestID);
2022
2023                 TEST_DEBUG(" after calling tel_exe_call_mo : Handle [%d]", curr_handle);
2024
2025                 TEST_DEBUG(" Tapi return api_err value is [%x] ", api_err);
2026
2027       }
2028
2029         if(strncmp(buf, "adtmf", 5) == 0)
2030         {
2031                 char DtmfString[10] = {0, };
2032                 unsigned char length;
2033
2034                  strcpy(DtmfString, "1234\0");
2035                  length = strlen(DtmfString);
2036
2037                  TEST_DEBUG("Send DTMF digits [%s], length %d", DtmfString, length);
2038
2039                 api_err = tel_send_call_dtmf(DtmfString, &RequestID);
2040                 TEST_DEBUG(" Tapi return api_err value is [%x] ", api_err);
2041                 _auto_dtmf_send_count++;
2042         }
2043
2044         if(strncmp(buf, "ds", 2) == 0)
2045         {
2046                 strncat(dtmfStr, &buf[3], 16);
2047                 strncpy(_glob_setup_info.szNumber, dtmfStr, TAPI_CALL_DIALDIGIT_LEN_MAX);
2048                 TEST_DEBUG("### make a call for DTMF test....%s", _glob_setup_info.szNumber);
2049
2050                 api_err=tel_exe_call_mo( &_glob_setup_info, &curr_handle,&RequestID);
2051
2052                 TEST_DEBUG(" Tapi return api_err value is [%x] ", api_err);
2053       }
2054
2055
2056         if(strncmp(buf, "lineg", 5) == 0)
2057         {
2058                 TEST_DEBUG("### Get Current Active Line.");
2059
2060                 api_err = tel_get_call_act_line(&RequestID);
2061
2062                 TEST_DEBUG(" Tapi return api_err value is [%x] ", api_err);
2063
2064                 TEST_DEBUG("### Current Active Line : %d", _glob_test_curr_line);
2065         }
2066
2067         if(strncmp(buf, "lines", 5) == 0)
2068         {
2069                 TEST_DEBUG("### Set Current Active Line.");
2070
2071                 if(_glob_test_curr_line == TAPI_CALL_ACTIVE_LINE1)
2072                         _glob_test_curr_line = TAPI_CALL_ACTIVE_LINE2;
2073
2074                 else
2075                         _glob_test_curr_line = TAPI_CALL_ACTIVE_LINE1;
2076
2077                 api_err = tel_set_call_act_line(_glob_test_curr_line,&RequestID);
2078
2079                 TEST_DEBUG(" Tapi return api_err value is [%x] ", api_err);
2080         }
2081
2082         if(strncmp(buf, "ccbs", 4) == 0)
2083         {
2084                 TEST_DEBUG("### Activate ccbs  call handle[%d]", curr_handle);
2085
2086                 api_err = tel_activate_call_ccbs(curr_handle,&RequestID);
2087
2088                 TEST_DEBUG(" Tapi return api_err value is [%x] ", api_err);
2089         }
2090
2091         if(strncmp(buf, "defl", 4) == 0)
2092         {
2093                 int             len1;
2094                 char    str[TAPI_CALL_DIALDIGIT_LEN_MAX] = {0, };
2095                 TelCallDeflectDstInfo_t dst;
2096
2097                 memset(&dst, 0, sizeof(dst));
2098
2099                 strncpy(str, &buf[5], TAPI_CALL_DIALDIGIT_LEN_MAX);
2100
2101                 len1 = strlen(str);
2102
2103                 strncpy((char*)dst.number, &str[0], (len1-1));
2104
2105                 TEST_DEBUG("Deflect Call Handle [%d] to [%s]", incoming_handle, dst.number);
2106
2107                 api_err = tel_deflect_call(incoming_handle,&dst, &RequestID);
2108
2109                 TEST_DEBUG(" Tapi return api_err value is [%x] ", api_err);
2110
2111         }
2112
2113         if(strncmp(buf, "quit", 4) == 0)
2114         {
2115                 TEST_DEBUG("quit..... ");
2116
2117                 return -1;
2118       }
2119
2120         /******************************************************************************
2121         *
2122         *                                       C O M M O N  A P I
2123         *
2124         *******************************************************************************/
2125
2126         if(strncmp(buf, "tapi", 4) == 0)
2127         {
2128         TS_BOOL status = FALSE;
2129
2130                 api_err = tel_check_service_ready(&status);
2131
2132                 TEST_DEBUG(" Current status of TAPI is:%d, api_err value is [%x]", status, api_err);
2133         }
2134
2135
2136         if(strncmp(buf, "state", 5) == 0)
2137         {
2138         unsigned char           call_state = 0;
2139         api_err = vconf_get_int(VCONFKEY_TELEPHONY_CALL_STATE, (int*)&call_state);
2140         TEST_DEBUG(" Current call state is:%s, api_err value is [%x]", call_state? "CONV" : "IDLE", api_err);
2141         }
2142
2143         if(strncmp(buf, "menu", 4) == 0)
2144         {
2145                 TEST_DEBUG("Finished Testing this module, Going back to Main Menu\n");
2146                 //call_test_exit();
2147                 return -1;
2148                 //exit(0);
2149         }
2150
2151         memset(buf, '\0', 256);
2152
2153     return ret;
2154
2155 }
2156
2157
2158 void call_test_loop(void)
2159 {
2160         int ret;
2161         fd_set readfds;
2162
2163         while (1)
2164         {
2165                 FD_ZERO(&readfds);
2166                 FD_SET(0, &readfds);
2167
2168                  ret = select(0 + 1, &readfds, NULL, NULL, NULL);
2169
2170                 if (ret)
2171                 {
2172                     if (FD_ISSET(0, &readfds))
2173                         {
2174                                   if(call_test_get_request()<0)
2175                                         break;
2176                           }
2177                 }
2178         }
2179
2180 }
2181
2182 void call_test_init(void)
2183 {
2184         int count;
2185
2186         TEST_DEBUG("Please press enter...\n");
2187
2188         for( count = 0; count < TAPI_CONTEXT_CALL_SIZE_MAX; count++)
2189         {
2190                 ctxt[count].handle = -1;
2191                 ctxt[count].used = false;
2192         }
2193
2194         memset(&_glob_setup_info, 0, sizeof(_glob_setup_info));
2195
2196         _glob_setup_info.CallType=TAPI_CALL_TYPE_VOICE;
2197         strncpy(_glob_setup_info.szNumber, pre_string, sizeof(pre_string));
2198
2199         call_test_loop();
2200
2201 }
2202