update for beta universally
[framework/telephony/libslp-tapi.git] / src / test_apps / tapi_ss_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
22 #include <stdlib.h>
23 #include <signal.h>
24 #include <stdio.h>
25 #include <errno.h>
26 #include <pthread.h>
27 #include "assert.h"
28 #include "glib.h"
29
30 #include "TelErr.h"
31 #include "TelUtility_ext.h"
32 #include "ITapiMisc.h"
33 #include "ITapiSs.h"
34 #include "TapiCommon.h"
35 #include "ITapiSim.h"
36
37
38 #define TEST_DEBUG(frmt, args...)       \
39         {do { fprintf(stderr, "[SS Test][%s:%04d] " frmt "\n", __func__, __LINE__, ##args); } while (FALSE) ;}
40
41
42 #ifndef bool
43         #define bool  char
44 #endif
45
46 // same as tapievent
47 typedef struct
48 {
49         int group;
50         int type;
51         int ID;
52         int status;
53         void *dst;
54 }data_t;
55
56 static unsigned int *   SS_subscription_id;
57
58 extern int EvtDeliveryHandle ;
59
60
61 int ss_strlen2(register const char * s ) {
62         int count = 0 ;
63         while( *s++ ) count ++ ;
64         return count ;
65 } // end strlen()
66
67
68 int ss_fgets(register char * digit, int n)
69 {
70         if( ! fgets( digit , n , stdin ) )  return -1 ;
71
72         if( *(digit + (n = ss_strlen2(digit)-1)) ^ '\n' )  {
73                 n = 0 ;
74                 while( getchar() ^ '\n' ) n -- ;
75                 if( n ) return 1 ;
76
77                 return 0;
78         }
79         else
80                 *( digit + n ) = 0 ;
81         return 0 ;
82 }
83
84 static int _PrintTeleCommService(TelSsTeleService_t telservice)
85 {
86         switch(telservice)
87         {
88                 case TAPI_SS_TS_ALL_TELESERVICES:
89                         TEST_DEBUG("TeleService: TAPI_SS_TS_ALL_TELESERVICES ");
90                         break;
91                 case TAPI_SS_TS_ALL_SPEECH:
92                         TEST_DEBUG("TeleService: TAPI_SS_TS_ALL_SPEECH ");
93                         break;
94                 case TAPI_SS_TS_ALL_DATA_TELESERVICES:
95                         TEST_DEBUG("TeleService: TAPI_SS_TS_ALL_DATA_TELESERVICES ");
96                         break;
97                 case TAPI_SS_TS_FACS:
98                         TEST_DEBUG("TeleService: TAPI_SS_TS_FACS ");
99                         break;
100                 case TAPI_SS_TS_SMS:
101                         TEST_DEBUG("TeleService: TAPI_SS_TS_SMS ");
102                         break;
103                 case TAPI_SS_TS_ALL_TELESERVICES_EXCEPT_SMS:
104                         TEST_DEBUG("TeleService: TAPI_SS_TS_ALL_TELESERVICES_EXCEPT_SMS ");
105                         break;
106                 case TAPI_SS_TS_ALL_PLMN_SPEC_TELE:
107                         TEST_DEBUG("TeleService: TAPI_SS_TS_ALL_PLMN_SPEC_TELE ");
108                         break;
109                 case TAPI_SS_BS_ALL_BEARER_SERVICES:
110                         TEST_DEBUG("TeleService: TAPI_SS_BS_ALL_BEARER_SERVICES ");
111                         break;
112                 case TAPI_SS_BS_ALL_ASYNCHRONOUS:
113                         TEST_DEBUG("TeleService: TAPI_SS_BS_ALL_ASYNCHRONOUS ");
114                         break;
115                 case TAPI_SS_BS_ALL_SYNCHRONOUS:
116                         TEST_DEBUG("TeleService: TAPI_SS_BS_ALL_SYNCHRONOUS ");
117                         break;
118                 case TAPI_SS_BS_DATA_CIRCUIT_SYNC:
119                         TEST_DEBUG("TeleService: TAPI_SS_BS_DATA_CIRCUIT_SYNC ");
120                         break;
121                 case TAPI_SS_TS_ALL_DATA:
122                         TEST_DEBUG("TeleService: TAPI_SS_TS_ALL_DATA ");
123                         break;
124                 case TAPI_SS_ALL_TELE_BEARER:
125                         TEST_DEBUG("TeleService: TAPI_SS_ALL_TELE_BEARER ");
126                         break;
127                 default:
128                         TEST_DEBUG("TeleService: %d ", telservice);
129                         break;
130         }
131
132         return 0;
133 }
134 static int _PrintBarringType(TelSsCallBarType_t BarType)
135 {
136         switch(BarType)
137         {
138                 case TAPI_CALL_BARRING_ALL:
139                         TEST_DEBUG("BarringType: TAPI_CALL_BARRING_ALL ");
140                         break;
141                 case TAPI_CALL_BARRING_OUTGOING:
142                         TEST_DEBUG("BarringType: TAPI_CALL_BARRING_OUTGOING ");
143                         break;
144                 case TAPI_CALL_BARRING_ALL_OUTGOING_CALLS:
145                         TEST_DEBUG("BarringType: TAPI_CALL_BARRING_ALL_OUTGOING_CALLS ");
146                         break;
147                 case TAPI_CALL_BARRING_ALL_OUTGOING_INTERN_CALL:
148                         TEST_DEBUG("BarringType: TAPI_CALL_BARRING_ALL_OUTGOING_INTERN_CALL ");
149                         break;
150                 case TAPI_CALL_BARRING_ALL_OUTGOING_INTERN_CALL_EXCEPT:
151                         TEST_DEBUG("BarringType: TAPI_CALL_BARRING_ALL_OUTGOING_INTERN_CALL_EXCEPT ");
152                         break;
153                 case TAPI_CALL_BARRING_INCOMING:
154                         TEST_DEBUG("BarringType: TAPI_CALL_BARRING_INCOMING ");
155                         break;
156                 case TAPI_CALL_BARRING_ALL_INCOMING_CALLS:
157                         TEST_DEBUG("BarringType: TAPI_CALL_BARRING_ALL_INCOMING_CALLS ");
158                         break;
159                 case TAPI_CALL_BARRING_ALL_INCOMING_CALLS_ROAMING:
160                         TEST_DEBUG("BarringType: TAPI_CALL_BARRING_ALL_INCOMING_CALLS_ROAMING ");
161                         break;
162                 case TAPI_CALL_BARRING_ALL_INCOMING_CALLS_INSIM:
163                         TEST_DEBUG("BarringType: TAPI_CALL_BARRING_ALL_INCOMING_CALLS_INSIM ");
164                         break;
165                 default:
166                         TEST_DEBUG("BarringType: None [%d] ", BarType);
167                         break;
168         }
169
170         return 0;
171 }
172
173 static int _PrintSsStatus(TelSsStatus_t Status)
174 {
175         switch(Status)
176         {
177                 case TAPI_SS_STATUS_ACTIVE:
178                         TEST_DEBUG("SS Status: TAPI_SS_STATUS_ACTIVE ");
179                         break;
180                 case TAPI_SS_STATUS_REGISTERED:
181                         TEST_DEBUG("SS Status: TAPI_SS_STATUS_REGISTERED (for CF) ");
182                         break;
183                 default:
184                         TEST_DEBUG("SS Status: Not Active ");
185                         break;
186         }
187
188         return 0;
189 }
190
191 static int _PrintSsCliType(TelSsLineIdentificationType_t CliType)
192 {
193         switch(CliType)
194         {
195                 case TAPI_CALLING_LINE_IDENTITY_PRESENTATION:
196                         TEST_DEBUG("Type: TAPI_CALLING_LINE_IDENTITY_PRESENTATION ");
197                         break;
198                 case TAPI_CALLING_LINE_IDENTITY_RESTRICTION:
199                         TEST_DEBUG("Type: TAPI_CALLING_LINE_IDENTITY_RESTRICTION ");
200                         break;
201                 case TAPI_CONNECTED_LINE_IDENTITY_PRESENTATION:
202                         TEST_DEBUG("Type: TAPI_CONNECTED_LINE_IDENTITY_PRESENTATION ");
203                         break;
204                 case TAPI_CONNECTED_LINE_IDENTITY_RESTRICTION:
205                         TEST_DEBUG("Type: TAPI_CONNECTED_LINE_IDENTITY_RESTRICTION ");
206                         break;
207                 case TAPI_CALLED_LINE_IDENTITY_PRESENTATION:
208                         TEST_DEBUG("Type: TAPI_CALLED_LINE_IDENTITY_PRESENTATION ");
209                         break;
210                 case TAPI_CALLING_NAME_PRESENTATION:
211                         TEST_DEBUG("Type: TAPI_CALLING_NAME_PRESENTATION ");
212                         break;
213                 default:
214                         TEST_DEBUG("Type: None [%d] ", CliType);
215                         break;
216         }
217
218         return 0;
219 }
220
221 static int _PrintSsCliStatus(TelSsCliStatus_t CliStatus)
222 {
223         switch(CliStatus)
224         {
225                 case TAPI_CLI_STATUS_NOT_PROVISONED:
226                         TEST_DEBUG("CliStatus: TAPI_CLI_STATUS_NOT_PROVISONED ");
227                         break;
228                 case TAPI_CLI_STATUS_PROVISIONED:
229                         TEST_DEBUG("CliStatus: TAPI_CLI_STATUS_PROVISIONED ");
230                         break;
231                 case TAPI_CLI_STATUS_ACTIVATED:
232                         TEST_DEBUG("CliStatus: TAPI_CLI_STATUS_ACTIVATED ");
233                         break;
234                 case TAPI_CLI_STATUS_UNKOWN:
235                         TEST_DEBUG("CliStatus: TAPI_CLI_STATUS_UNKOWN ");
236                         break;
237                 case TAPI_CLI_STATUS_TEMP_RESTRICTED:
238                         TEST_DEBUG("CliStatus: TAPI_CLI_STATUS_TEMP_RESTRICTED ");
239                         break;
240                 case TAPI_CLI_STATUS_TEMP_ALLOWED:
241                         TEST_DEBUG("CliStatus: TAPI_CLI_STATUS_TEMP_ALLOWED ");
242                         break;
243                 default:
244                         TEST_DEBUG("CliStatus: None [%d] ", CliStatus);
245                         break;
246         }
247
248         return 0;
249 }
250
251 static int _PrintSsUssdRecord(TelSsUssdMsgIndInfo_t ussd_record)
252 {
253         switch(ussd_record.IndType)
254         {
255                 case TAPI_USSD_IND_NOTIFY:
256                         TEST_DEBUG("UssdIndType: TAPI_USSD_IND_NOTIFY ");
257                         break;
258                 case TAPI_USSD_IND_NO_ACTION_REQUIRE:
259                         TEST_DEBUG("UssdIndType: TAPI_USSD_IND_NO_ACTION_REQUIRE ");
260                         break;
261                 case TAPI_USSD_IND_ACTION_REQUIRE:
262                         TEST_DEBUG("UssdIndType: TAPI_USSD_IND_ACTION_REQUIRE ");
263                         break;
264                 case TAPI_USSD_IND_TERMINATED_BY_NET:
265                         TEST_DEBUG("UssdIndType: TAPI_USSD_IND_TERMINATED_BY_NET ");
266                         break;
267                 case TAPI_USSD_IND_OTHER_CLIENT:
268                         TEST_DEBUG("UssdIndType: TAPI_USSD_IND_OTHER_CLIENT ");
269                         break;
270                 case TAPI_USSD_IND_NOT_SUPPORT:
271                         TEST_DEBUG("UssdIndType: TAPI_USSD_IND_NOT_SUPPORT ");
272                         break;
273                 case TAPI_USSD_IND_TIME_OUT:
274                         TEST_DEBUG("UssdIndType: TAPI_USSD_IND_TIME_OUT ");
275                         break;
276                 default:
277                         TEST_DEBUG("UssdIndType: None [%d] ", ussd_record.IndType);
278                         break;
279         }
280
281         TEST_DEBUG("RequestedBySAT:[%d]",ussd_record.UssdInfo.RequestedBySAT);
282         TEST_DEBUG("DCS         : [0x%x]",ussd_record.UssdInfo.Dcs);
283         TEST_DEBUG("ussd length : [%d] ", ussd_record.UssdInfo.UssdStringLength);
284         TEST_DEBUG("ussd string : [\n%s\n] ", ussd_record.UssdInfo.szUssdString);
285
286         return 0;
287 }
288
289 static int _PrintCFNoReplyWaitTime(TelSsNoReplyTime_t time)
290 {
291         switch(time)
292         {
293                 case TAPI_SS_CF_NO_REPLY_TIME_5_SECS:
294                         TEST_DEBUG("CF reply time : TAPI_SS_CF_NO_REPLY_TIME_5_SECS ");
295                         break;
296                 case TAPI_SS_CF_NO_REPLY_TIME_10_SECS:
297                         TEST_DEBUG("CF reply time : TAPI_SS_CF_NO_REPLY_TIME_10_SECS ");
298                         break;
299                 case TAPI_SS_CF_NO_REPLY_TIME_15_SECS:
300                         TEST_DEBUG("CF reply time : TAPI_SS_CF_NO_REPLY_TIME_15_SECS ");
301                         break;
302                 case TAPI_SS_CF_NO_REPLY_TIME_20_SECS:
303                         TEST_DEBUG("CF reply time : TAPI_SS_CF_NO_REPLY_TIME_20_SECS ");
304                         break;
305                 case TAPI_SS_CF_NO_REPLY_TIME_25_SECS:
306                         TEST_DEBUG("CF reply time : TAPI_SS_CF_NO_REPLY_TIME_25_SECS ");
307                         break;
308                 case TAPI_SS_CF_NO_REPLY_TIME_30_SECS:
309                         TEST_DEBUG("CF reply time : TAPI_SS_CF_NO_REPLY_TIME_30_SECS ");
310                         break;
311                 default:
312                         TEST_DEBUG("CF reply time: None [%d] ", time);
313                         break;
314         }
315         return 0;
316 }
317
318 static int _PrintCFCondition(TelSsForwardWhen_t cond)
319 {
320         switch(cond)
321         {
322                 case TAPI_SS_FORWARD_WHEN_UNCONDITIONAL_EV:
323                         TEST_DEBUG("CF condition : TAPI_SS_FORWARD_WHEN_UNCONDITIONAL_EV ");
324                         break;
325                 case TAPI_SS_FORWARD_WHEN_BUSY_EV:
326                         TEST_DEBUG("CF condition : TAPI_SS_FORWARD_WHEN_BUSY_EV ");
327                         break;
328                 case TAPI_SS_FORWARD_WHEN_NO_ANSWER_EV:
329                         TEST_DEBUG("CF condition : TAPI_SS_FORWARD_WHEN_NO_ANSWER_EV ");
330                         break;
331                 case TAPI_SS_FORWARD_WHEN_NOT_REACHABLE_EV:
332                         TEST_DEBUG("CF condition : TAPI_SS_FORWARD_WHEN_NOT_REACHABLE_EV ");
333                         break;
334                 case TAPI_SS_FORWARD_WHEN_ALL_FORWARDING_EV:
335                         TEST_DEBUG("CF condition : TAPI_SS_FORWARD_WHEN_ALL_FORWARDING_EV ");
336                         break;
337                 case TAPI_SS_FORWARD_WHEN_ALL_CONDITIONAL_EV:
338                         TEST_DEBUG("CF condition : TAPI_SS_FORWARD_WHEN_ALL_CONDITIONAL_EV ");
339                         break;
340                 default:
341                         TEST_DEBUG("CF condition : None [%d] ", cond);
342                         break;
343         }
344         return 0;
345 }
346
347 //static int  ss_async_event_callback(TelTapiEventClass_t eventClass, int eventType, int  param1,void * param2)
348 static int  ss_async_event_callback(TelTapiEvent_t      *event)
349 {
350         TEST_DEBUG("EVENT TYPE:[0x%x], STATUS:[0x%x]", event->EventType, event->Status);
351
352         int i = 0;
353
354         switch(event->EventClass)
355         {
356                 case TAPI_EVENT_CLASS_SS:
357                 {
358                         switch(event->EventType)
359                         {
360                                 case TAPI_EVENT_SS_REL_COMP_MSG_NOTIFY:
361                                 {
362                                         TelSsRelCompMsgInfo_t      rel_comp_msg;
363                                         memcpy(&rel_comp_msg, (TelSsRelCompMsgInfo_t *)event->pData, sizeof(TelSsRelCompMsgInfo_t));
364                                         TEST_DEBUG("####  Received Event :TAPI_EVENT_SS_REL_COMP_MSG_NOTIFY  ##### ");
365                                 }
366                                         break;
367
368                                 case TAPI_EVENT_SS_WAITING_CNF:
369                                 {
370                                         TelSsInfo_t SsInfo = {0,};
371                                         TEST_DEBUG("####  Received Event :TAPI_EVENT_SS_WAITING_CNF  ##### ");
372
373                                         if (event->pData!=NULL)
374                                         {
375                                                 memcpy(&SsInfo, (TelSsInfo_t*)event->pData, sizeof(TelSsInfo_t));
376
377                                                 TEST_DEBUG("Number of records %d ",SsInfo.NumberOfRecords);
378                                                 for(i=0;i<SsInfo.NumberOfRecords;i++)
379                                                 {
380                                                         TEST_DEBUG("Index:[%d]",i);
381                                                         _PrintSsStatus(SsInfo.SsRecord.WaitingRecord.rec_class[i].Status);
382                                                         _PrintTeleCommService(SsInfo.SsRecord.WaitingRecord.rec_class[i].TeleCommService);
383                                                 }
384                                         }
385                                 }
386
387                                         break;
388
389                                 case TAPI_EVENT_SS_WAITING_QUERYSTATUS_CNF:
390                                 {
391                                         TelSsInfo_t SsInfo = {0,};
392                                         TEST_DEBUG("####  Received Event :TAPI_EVENT_SS_WAITING_QUERYSTATUS_CNF  ##### ");
393
394                                         if (event->pData!=NULL)
395                                         {
396                                                 memcpy(&SsInfo, (TelSsInfo_t*)event->pData, sizeof(TelSsInfo_t));
397
398                                                 TEST_DEBUG("Number of records %d ",SsInfo.NumberOfRecords);
399                                                 for(i=0;i<SsInfo.NumberOfRecords;i++)
400                                                 {
401                                                         TEST_DEBUG("Index:[%d]",i);
402                                                         _PrintSsStatus(SsInfo.SsRecord.WaitingRecord.rec_class[i].Status);
403                                                         _PrintTeleCommService(SsInfo.SsRecord.WaitingRecord.rec_class[i].TeleCommService);
404                                                 }
405                                         }
406                                 }
407                                         break;
408                                 case TAPI_EVENT_SS_BARRING_CNF:
409                                 {
410                                         TEST_DEBUG("####  Received Event :TAPI_EVENT_SS_BARRING_CNF  ##### ");
411                                         TelSsInfo_t SsInfo = {0,};
412
413                                         if (event->pData!=NULL)
414                                         {
415                                                 memcpy(&SsInfo, (TelSsInfo_t*)event->pData, sizeof(TelSsInfo_t));
416
417                                                 TEST_DEBUG("Number of records %d ",SsInfo.NumberOfRecords);
418                                                 for(i=0;i<SsInfo.NumberOfRecords;i++)
419                                                 {
420                                                         TEST_DEBUG("index:[%d] ",i);
421                                                         _PrintSsStatus(SsInfo.SsRecord.BarringRecord.rec_class[i].Status);
422                                                         _PrintTeleCommService(SsInfo.SsRecord.BarringRecord.rec_class[i].TeleCommService);
423                                                         _PrintBarringType(SsInfo.SsRecord.BarringRecord.rec_class[i].Flavour);
424
425                                                 }
426                                         }
427                                 }
428                                         break;
429
430                                 case TAPI_EVENT_SS_BARRING_QUERYSTATUS_CNF:
431                                 {
432                                         TEST_DEBUG("####  Received Event :TAPI_EVENT_SS_BARRING_QUERYSTATUS_CNF  ##### ");
433                                         TelSsInfo_t SsInfo = {0,};
434
435                                         if (event->pData!=NULL)
436                                         {
437                                                 memcpy(&SsInfo, (TelSsInfo_t*)event->pData, sizeof(TelSsInfo_t));
438
439                                                 TEST_DEBUG("Number of records %d ",SsInfo.NumberOfRecords);
440                                                 for(i=0;i<SsInfo.NumberOfRecords;i++)
441                                                 {
442                                                         TEST_DEBUG("index:[%d] ",i);
443                                                         _PrintSsStatus(SsInfo.SsRecord.BarringRecord.rec_class[i].Status);
444                                                         _PrintTeleCommService(SsInfo.SsRecord.BarringRecord.rec_class[i].TeleCommService);
445                                                         _PrintBarringType(SsInfo.SsRecord.BarringRecord.rec_class[i].Flavour);
446                                                 }
447
448                                         }
449
450                                 }
451                                         break;
452
453                                 case TAPI_EVENT_SS_FORWARD_CNF:
454                                 {
455                                         TEST_DEBUG("####  Received Event :TAPI_EVENT_SS_FORWARD_CNF  ##### ");
456                                         TelSsInfo_t SsInfo = {0,};
457
458                                         if (event->pData!=NULL)
459                                         {
460                                                 memcpy(&SsInfo, (TelSsInfo_t*)event->pData, sizeof(TelSsInfo_t));
461
462                                                 TEST_DEBUG("Number of records %d ",SsInfo.NumberOfRecords);
463                                                 for(i=0;i<SsInfo.NumberOfRecords;i++)
464                                                 {
465                                                         TEST_DEBUG("index:[%d] ",i);
466                                                         _PrintSsStatus(SsInfo.SsRecord.ForwardingRecord.rec_class[i].Status);
467                                                         _PrintTeleCommService(SsInfo.SsRecord.ForwardingRecord.rec_class[i].TeleCommService);
468                                                         _PrintCFNoReplyWaitTime(SsInfo.SsRecord.ForwardingRecord.rec_class[i].NoReplyWaitTime);
469                                                         _PrintCFCondition(SsInfo.SsRecord.ForwardingRecord.rec_class[i].ForwardCondition);
470                                                         TEST_DEBUG("bCFNumPresent:[%d] ",SsInfo.SsRecord.ForwardingRecord.rec_class[i].bCallForwardingNumberPresent);
471                                                         TEST_DEBUG("bCFNum:[%s] ",SsInfo.SsRecord.ForwardingRecord.rec_class[i].szCallForwardingNumber);
472                                                 }
473                                         }
474                                 }
475                                         break;
476
477                                 case TAPI_EVENT_SS_FORWARD_QUERYSTATUS_CNF:
478                                 {
479                                         TEST_DEBUG("####  Received Event :TAPI_EVENT_SS_FORWARD_QUERYSTATUS_CNF  ##### ");
480                                         TelSsInfo_t SsInfo = {0,};
481
482                                         if (event->pData!=NULL)
483                                         {
484                                                 memcpy(&SsInfo, (TelSsInfo_t*)event->pData, sizeof(TelSsInfo_t));
485
486                                                 TEST_DEBUG("Number of records %d ",SsInfo.NumberOfRecords);
487
488                                                 for(i=0;i<SsInfo.NumberOfRecords;i++)
489                                                 {
490                                                         TEST_DEBUG("index:[%d] ",i);
491                                                         _PrintSsStatus(SsInfo.SsRecord.ForwardingRecord.rec_class[i].Status);
492                                                         _PrintTeleCommService(SsInfo.SsRecord.ForwardingRecord.rec_class[i].TeleCommService);
493                                                         _PrintCFNoReplyWaitTime(SsInfo.SsRecord.ForwardingRecord.rec_class[i].NoReplyWaitTime);
494                                                         _PrintCFCondition(SsInfo.SsRecord.ForwardingRecord.rec_class[i].ForwardCondition);
495                                                         TEST_DEBUG("bCFNumPresent:[%d] ",SsInfo.SsRecord.ForwardingRecord.rec_class[i].bCallForwardingNumberPresent);
496                                                         TEST_DEBUG("bCFNum:[%s] ",SsInfo.SsRecord.ForwardingRecord.rec_class[i].szCallForwardingNumber);
497                                                 }
498                                         }
499                                 }
500                                         break;
501
502                                 case TAPI_EVENT_SS_BARRING_CHANGEPASS_CNF:
503                                 {
504                                         TEST_DEBUG("####  Received Event : TAPI_EVENT_SS_BARRING_CHANGEPASS_CNF  ##### ");
505                                 }
506                                         break;
507
508                                 case TAPI_EVENT_SS_CLI_QUERYSTATUS_CNF:
509                                 {
510                                         TelSsInfo_t SsInfo = {0,};
511
512                                         TEST_DEBUG("####  Received Event : TAPI_EVENT_SS_CLI_QUERYSTATUS_CNF #### ");
513
514                                         if (event->pData!=NULL)
515                                         {
516                                                 memcpy(&SsInfo, (TelSsInfo_t*)event->pData, sizeof(TelSsInfo_t));
517                                                  _PrintSsCliType(SsInfo.SsRecord.CliRecord.IdentificationType);
518                                                 _PrintSsCliStatus(SsInfo.SsRecord.CliRecord.CliStatus);
519                                         }
520
521                                 }
522                                         break;
523
524                                 case TAPI_EVENT_SS_USSD_CNF:
525                                 {
526                                         TelSsUssdMsgIndInfo_t      ussd_record;
527                                         TEST_DEBUG("####  Received Event : TAPI_EVENT_SS_USSD_CNF #### ");
528
529                                         if (event->pData != NULL)
530                                         {
531                                                 memcpy(&ussd_record, (TelSsUssdMsgIndInfo_t *)event->pData, sizeof(TelSsUssdMsgInfo_t));
532                                                 _PrintSsUssdRecord(ussd_record);
533                                         }
534                                         else
535                                         {
536                                                 TEST_DEBUG("NULL param");
537                                         }
538
539                                 }
540                                         break;
541                                 //Indication with ACTION_REQUIRE
542                                 case TAPI_EVENT_SS_USSD_IND:
543                                 {
544                                         TelSsUssdMsgIndInfo_t      ussd_record;
545                                         TEST_DEBUG("####  Received Event : TAPI_EVENT_SS_USSD_IND  ##### ");
546
547                                         if (event->pData != NULL)
548                                         {
549                                                 memcpy(&ussd_record, (TelSsUssdMsgInfo_t *)event->pData, sizeof(TelSsUssdMsgInfo_t));
550                                                 _PrintSsUssdRecord(ussd_record);
551                                         }
552                                         else
553                                         {
554                                                 TEST_DEBUG("NULL param");
555                                         }
556
557                                 }
558                                 break;
559
560
561                                 case TAPI_EVENT_SS_AOC_RSP:
562                                 {
563                                         TelCallAocInfo_t aoc_info;
564                                         TEST_DEBUG("####  Received Event : SS -- TAPI_EVENT_SS_AOC_RSP---#### ");
565                                         if(event->Status != 0)
566                                         {
567                                                 memcpy(&aoc_info, (TelCallAocInfo_t*)event->pData, sizeof(TelCallAocInfo_t));
568
569                                                 TEST_DEBUG("############# AOC TYPE :%d",aoc_info.AocType);
570                                                 TEST_DEBUG("Printing ### ACM : [%ld]  MAX_ACM :[%ld] CCM:[%0.4f] Char type:[%d] ",aoc_info.ACM,aoc_info.MaxAcm,aoc_info.CCM,aoc_info.CharTypeOfCurrency);
571                                                 TEST_DEBUG("Currency : %c %c %c ",aoc_info.szCurrency[0], aoc_info.szCurrency[1], aoc_info.szCurrency[2]);
572                                         }
573
574                                 }
575                                         break;
576                                 case TAPI_EVENT_SS_SET_AOC_CNF:
577                                         TEST_DEBUG("####  Received Event : SS -- TAPI_EVENT_SS_SET_AOC_CNF---#### ");
578                                         break;
579                                 case TAPI_EVENT_SS_BARRING_TYPE_IND:
580                                 {
581                                         TelSsCallBarType_t BarringType;
582                                         TEST_DEBUG("####  Received Event : SS -- TAPI_EVENT_SS_BARRING_TYPE_IND---#### ");
583
584                                         memcpy(&BarringType, (TelSsCallBarType_t*)event->pData, sizeof(TelSsCallBarType_t));
585                                         TEST_DEBUG("########### BarringType received is [%x]",BarringType);
586                                 }
587                                         break;
588
589                                 default:
590                                         break;
591                         }
592                 }
593                         break;
594
595                 default:
596                         break;
597         }
598         TEST_DEBUG("###################################################################");
599
600         return 1;
601
602 }
603
604
605
606 int ss_read_key_input(void)
607 {
608         int ret2;
609         char buf[256];
610         int request_id =0;
611         TapiResult_t ret = TAPI_API_SUCCESS;
612
613         ret2 = read(0, buf, sizeof(buf));
614          if (ret2 < 0) {
615           if (errno == EINTR)
616           perror("read(1)");
617           return -1;
618          } else if (ret2 == 0) return ret2;
619
620
621         printf("\n########## SS TEST Application #########\n");
622         printf("########## Supplementary Services  - Options ############\n");
623
624         printf("Call Waiting [1] Call Barring  [2] Call Forwarding [3] \n");
625         printf("Query Status [a]    Activate [b]   Deactivate [c]  Registration [d]  Deregistration [e]\n");
626         printf("Change Call barring Password  Enter - [cbp]\n");
627         printf("Interrogate  the Status of Line Identity Services like CLIP, CLIR etc - Enter [cli]\n");
628         printf("Send USSD String  - Enter [ussd]\n");
629         printf("Test AOC  - First - SimOpen and Enter PIN2 ---[simopen] [pin2]\n");
630         printf("Read AOC Information - Enter [raoc] \n");
631         printf("Set Maximum Cost limit- [5e], Set Price/Unit Currency-[5f], Reset Cost Limit-[5g]\n");
632         printf("quit - [quit]\n");
633
634         printf("##########################################\n");
635         printf("SS Enter key   : %s", buf);
636
637         /* Call waiting */
638         if(strncmp(buf, "1a", 2) == 0 )
639         {
640                 char cwType[1];
641                 TelSsWaitingInfo_t cwInfo = {0,};
642                 TEST_DEBUG("### Interrogate the status of Call Waiting  #### ");
643
644                 TEST_DEBUG("Select the Call Waiting Type ");
645                 TEST_DEBUG(" voice-[0], data circuit sync-[6], all tele bearer-[7]");
646                 ss_fgets(cwType,2);
647
648                 cwInfo.CallType = atoi(cwType);
649
650                 TEST_DEBUG("SS CallType:[%d]",cwInfo.CallType);
651
652                 ret = tel_get_ss_waiting_status(cwInfo.CallType,&request_id);
653
654                 TEST_DEBUG("Tapi return api_err value is [0x%x]  RequestID:[%d]", ret,request_id);
655         }
656
657         if(strncmp(buf, "1b", 2) == 0 )
658         {
659                 char cwType[1];
660                 TEST_DEBUG("### Activate Call Waiting  #### ");
661                 TelSsWaitingInfo_t cwInfo = {0,};
662
663                 TEST_DEBUG("Select the Call Waiting Type ");
664                 TEST_DEBUG(" voice-[0], data circuit sync-[6], all tele bearer-[7]");
665                 ss_fgets(cwType,2);
666
667                 cwInfo.CallType = atoi(cwType);
668                 cwInfo.Mode = TAPI_SS_CW_ACTIVATE;
669
670                 TEST_DEBUG("SS CallType:[%d]",cwInfo.CallType);
671                 ret = tel_set_ss_waiting(&cwInfo,&request_id);
672
673                 TEST_DEBUG("Tapi return api_err value is [0x%x]  RequestID:[%d]", ret,request_id);
674         }
675
676         if(strncmp(buf, "1c", 2) == 0 )
677         {
678                 char cwType[1];
679                 TEST_DEBUG("### DeActivate Call Waiting  #### ");
680                 TelSsWaitingInfo_t cwInfo = {0,};
681
682                 TEST_DEBUG("Select the Call Waiting Type ");
683                 TEST_DEBUG(" voice-[0], data circuit sync-[6], all tele bearer-[7]");
684                 ss_fgets(cwType,2);
685
686                 cwInfo.CallType = atoi(cwType);
687                 cwInfo.Mode = TAPI_SS_CW_DEACTIVATE;
688
689                 TEST_DEBUG("SS CallType:[%d]",cwInfo.CallType);
690                 ret = tel_set_ss_waiting(&cwInfo,&request_id);
691
692                 TEST_DEBUG("Tapi return api_err value is [0x%x]  RequestID:[%d]", ret,request_id);
693
694         }
695
696         /* Call barring */
697         if(strncmp(buf, "2a", 2) == 0)
698         {
699                 TelSsCallBarringInfo_t  cb_req = {0,};
700                 char cbType[1];
701                 char cba_fla[10];
702                 TEST_DEBUG("####        Interrogate Status of Call barring for Voice Calls              ####");
703
704                 TEST_DEBUG("Enter Call Barring Flavor type(BAOC -2, BAIC-6) ");
705                 TEST_DEBUG(" All Barring -[0] Out Going calls - [1] All outgoing calls [2] ");
706                 TEST_DEBUG(" Outgoing Intl calls -[3] All ougoing intl calls except home[4] - Barring incoming [5]  All Incoming calls [6]");
707                 TEST_DEBUG(" All incoming calls in roaming -[7] All incoming calls in Sim [2] ");
708                 ss_fgets(cba_fla,5);
709                 cb_req.Type = atoi(cba_fla);
710
711                 TEST_DEBUG("Select the SS Call Type ");
712                 TEST_DEBUG(" voice-[0], data circuit sync-[6], all tele bearer-[7]");
713                 ss_fgets(cbType,2);
714                 cb_req.CallType = atoi(cbType);
715
716                 TEST_DEBUG("CB type:[%d], SS CallType:[%d]", cb_req.Type, cb_req.CallType);
717
718                 ret = tel_get_ss_barring_status(cb_req.Type, cb_req.CallType,&request_id);
719
720                 TEST_DEBUG("Tapi return api_err value is [0x%x]  RequestID:[%d]", ret,request_id);
721           }
722
723         if(strncmp(buf, "2b",2) == 0)
724         {
725                 TelSsCallBarringInfo_t  cb_req = {0,};
726                 char cbType[1];
727                 char cba_fla[10];
728                 char new_pwd[10];
729
730                 TEST_DEBUG("####        Activate the Call Barring for Voice calls.      ####");
731
732                 TEST_DEBUG("Enter Call Barring Flavor type(BAOC -2, BAIC-6) ");
733                 TEST_DEBUG(" All Barring -[0] Out Going calls - [1] All outgoing calls [2] ");
734                 TEST_DEBUG(" Outgoing Intl calls -[3] All ougoing intl calls except home[4] - Barring incoming [5]  All Incoming calls [6]");
735                 TEST_DEBUG(" All incoming calls in roaming -[7] All incoming calls in Sim [8] ");
736
737                 ss_fgets(cba_fla,5);
738                 cb_req.Type = atoi(cba_fla);
739                 TEST_DEBUG(" Enter Call Barring  Password - size minimum 4 bytes");
740                 ss_fgets(new_pwd,5);
741                 memcpy(&cb_req.szPassword,&new_pwd,4);
742                 cb_req.Mode =  TAPI_SS_CALL_BAR_ACTIVATE;
743
744                 TEST_DEBUG("Select the SS Call Type ");
745                 TEST_DEBUG(" voice-[0], data circuit sync-[6], all tele bearer-[7]");
746                 ss_fgets(cbType,2);
747                 cb_req.CallType = atoi(cbType);
748
749                 TEST_DEBUG("CB type:[%d], SS CallType:[%d]", cb_req.Type, cb_req.CallType);
750
751                 ret = tel_set_ss_barring(&cb_req,&request_id);
752
753                 TEST_DEBUG("Tapi return api_err value is [0x%x]  RequestID:[%d]", ret,request_id);
754         }
755
756         if(strncmp(buf, "2c", 2) == 0)
757         {
758                 TelSsCallBarringInfo_t  cb_req = {0,};
759                 char cbType[1];
760
761                 char cba_fla[10];
762                 char new_pwd[10];
763                 TEST_DEBUG("Enter Call Barring Flavor type(BAOC -2, BAIC-6) ");
764                 TEST_DEBUG(" All Barring -[0] Out Going calls - [1] All outgoing calls [2] ");
765                 TEST_DEBUG(" Outgoing Intl calls -[3] All ougoing intl calls except home[4] - Barring incoming [5]  All Incoming calls [6]");
766                 TEST_DEBUG(" All incoming calls in roaming -[7] All incoming calls in Sim [8] ");
767
768                 ss_fgets(cba_fla,5);
769                 cb_req.Type = atoi(cba_fla);
770
771                 TEST_DEBUG(" Enter Call Barring  Password - size minimum 4 bytes");
772                 ss_fgets(new_pwd,5);
773                 memcpy(&cb_req.szPassword,&new_pwd,4);
774
775                 TEST_DEBUG("Select the SS Call Type ");
776                 TEST_DEBUG(" voice-[0], data circuit sync-[6], all tele bearer-[7]");
777                 ss_fgets(cbType,2);
778                 cb_req.CallType = atoi(cbType);
779
780                 cb_req.Mode =  TAPI_SS_CALL_BAR_DEACTIVATE;
781
782                 TEST_DEBUG("CB type:[%d], SS CallType:[%d]", cb_req.Type, cb_req.CallType);
783
784                 ret = tel_set_ss_barring(&cb_req,&request_id);
785                 TEST_DEBUG("Tapi return api_err value is [0x%x]  RequestID:[%d]", ret, request_id);
786         }
787
788
789         if(strncmp(buf, "3a", 2) == 0)
790         {
791                 char flavor[1];
792                 char cfType[1];
793
794                 TelSsForwardInfo_t  cfReq ={0,};
795
796
797                 TEST_DEBUG("### Interrogate the Status of Call forwarding .");
798                 TEST_DEBUG("Select the Call Forwarding Flavor ");
799                 TEST_DEBUG(" CF-Unconditional -[0]  CF-Busy [1]  CF-No Reply [2]  CF-Not reachable [3] CF -All forwarding[4] All Cond CF [5]  ");
800                 ss_fgets(flavor,2);
801                 cfReq.Condition = atoi(flavor);
802
803                 TEST_DEBUG("Select the Call Forwarding Type ");
804                 TEST_DEBUG("voice -[0] data -[3] fax-[4] all_tele and bearer -[5] ");
805                 ss_fgets(cfType,2);
806                 cfReq.Type = atoi(cfType);
807
808                 TEST_DEBUG("CF Flavor:[%d], SS CF CallType:[%d]", cfReq.Condition, cfReq.Type);
809
810                 ret = tel_get_ss_forward_status(cfReq.Type,  cfReq.Condition,&request_id);
811
812                 TEST_DEBUG("Tapi return api_err value is [0x%x]  RequestID:[%d]", ret,request_id);
813
814         }
815         if(strncmp(buf, "3b", 2) == 0)
816         {
817
818                 char cf_number[20];
819                 unsigned char len;
820                 char flavor[1];
821                 char cfType[1];
822
823                 TelSsForwardInfo_t  cfActReq ={0,};
824
825                 TEST_DEBUG("#### Call Forwarding Activation #### ");
826                 TEST_DEBUG("Enter the Call forwarding number ");
827                 ss_fgets(cf_number,15);
828                 len = strlen(cf_number);
829                 TEST_DEBUG("Length of CF number :%d ",len);
830                 memcpy(&(cfActReq.szPhoneNumber),cf_number,len);
831
832                 TEST_DEBUG("Select the Call Forwarding Flavor ");
833                 TEST_DEBUG(" CF-Unconditional -[0]  CF-Busy [1]  CF-No Reply [2]  CF-Not reachable [3] CF -All forwarding[4] All Cond CF [5] ");
834                 ss_fgets(flavor,2);
835                 cfActReq.Condition = atoi(flavor);
836                 TEST_DEBUG("********** flavor=%x ",cfActReq.Condition);
837
838                 TEST_DEBUG("Select the Call Forwarding Type ");
839                 TEST_DEBUG("voice -[0] data -[3] fax-[4] all_tele and bearer -[5] ");
840                 ss_fgets(cfType,2);
841                 cfActReq.Type = atoi(cfType);
842
843                 cfActReq.NoReplyConditionTimer = TAPI_SS_CF_NO_REPLY_TIME_10_SECS;
844                 cfActReq.Mode=  TAPI_CALL_FORWARD_MODE_ENABLE_EV;
845
846                 TEST_DEBUG("CF Flavor:[%d], SS CF CallType:[%d]", cfActReq.Condition, cfActReq.Type);
847
848                 ret = tel_set_ss_forward(&cfActReq,&request_id);
849
850                 TEST_DEBUG("Tapi return api_err value is [0x%x]  RequestID:[%d]", ret,request_id);
851
852         }
853         if(strncmp(buf, "3c", 2) == 0)
854         {
855                 char cf_number[20];
856                 unsigned char len;
857                 char flavor[1];
858                 char cfType[1];
859                 TelSsForwardInfo_t  cfActReq ={0,};
860
861                 TEST_DEBUG("#### Call Forwarding DEActivation #### ");
862                 TEST_DEBUG("Enter the Call forwarding number ");
863                 ss_fgets(cf_number,15);
864                 len = strlen(cf_number);
865                 TEST_DEBUG("Length of CF number :%d ",len);
866                 memcpy(&(cfActReq.szPhoneNumber),cf_number,len);
867
868                 TEST_DEBUG("Select the Call Forwarding Flavor ");
869                 TEST_DEBUG(" CF-Unconditional -[0]  CF-Busy [1]  CF-No Reply [2]  CF-Not reachable [3] CF -All forwarding[4] All Cond CF [5] ");
870
871                 ss_fgets(flavor,2);
872                 cfActReq.Condition = atoi(flavor);
873                 TEST_DEBUG("********** flavor=%x ",cfActReq.Condition);
874
875                 TEST_DEBUG("Select the Call Forwarding Type ");
876                 TEST_DEBUG("voice -[0] data -[3] fax-[4] all_tele and bearer -[5] ");
877                 ss_fgets(cfType,2);
878                 cfActReq.Type = atoi(cfType);
879
880                 cfActReq .NoReplyConditionTimer = TAPI_SS_CF_NO_REPLY_TIME_10_SECS;
881                 cfActReq.Mode=  TAPI_CALL_FORWARD_MODE_DISABLE_EV;
882
883                 TEST_DEBUG("CF Flavor:[%d], SS CF CallType:[%d]", cfActReq.Condition, cfActReq.Type);
884
885                 ret = tel_set_ss_forward(&cfActReq,&request_id);
886                 TEST_DEBUG("Tapi return api_err value is [0x%x]  RequestID:[%d]", ret,request_id);
887
888         }
889         if(strncmp(buf, "3d", 2) == 0)
890         {
891
892                 char cf_number[20];
893                 unsigned char len;
894                 char flavor[1];
895                 char cfType[1];
896
897                 TelSsForwardInfo_t  cfActReq ={0,};
898
899                 TEST_DEBUG("#### Call Forwarding Registration #### ");
900                 TEST_DEBUG("Enter the Call forwarding number ");
901                 ss_fgets(cf_number,15);
902                 len = strlen(cf_number);
903                 TEST_DEBUG("Length of CF number :%d ",len);
904                 memcpy(&(cfActReq.szPhoneNumber),cf_number,len);
905
906                 TEST_DEBUG("Select the Call Forwarding Flavor ");
907                 TEST_DEBUG(" CF-Unconditional -[0]  CF-Busy [1]  CF-No Reply [2]  CF-Not reachable [3] CF -All forwarding[4] All Cond CF [5] ");
908                 ss_fgets(flavor,2);
909
910                 cfActReq.Condition = atoi(flavor);
911                 TEST_DEBUG("********** flavor=%x ",cfActReq.Condition);
912
913
914                 TEST_DEBUG("Select the Call Forwarding Type ");
915                 TEST_DEBUG("voice -[0] data -[3] fax-[4] all_tele and bearer -[5] ");
916                 ss_fgets(cfType,2);
917
918                 cfActReq.Type = atoi(cfType);
919
920                 cfActReq.NoReplyConditionTimer = TAPI_SS_CF_NO_REPLY_TIME_10_SECS;
921                 cfActReq.Mode=  TAPI_CALL_FORWARD_MODE_REGISTRATION_EV;
922
923                 TEST_DEBUG("CF Flavor:[%d], SS CF CallType:[%d]", cfActReq.Condition, cfActReq.Type);
924
925                 ret = tel_set_ss_forward(&cfActReq,&request_id);
926                 TEST_DEBUG("Tapi return api_err value is [0x%x]  RequestID:[%d]", ret,request_id);
927
928
929         }
930         if(strncmp(buf, "3e", 2) == 0)
931         {
932                 char cf_number[20];
933                 unsigned char len;
934                 char flavor[1];
935                 char cfType[1];
936                 TelSsForwardInfo_t  cfActReq ={0,};
937
938                 TEST_DEBUG("#### Call Forwarding Deregistration #### ");
939                 TEST_DEBUG("Enter the Call forwarding number ");
940                 ss_fgets(cf_number,15);
941                 len = strlen(cf_number);
942                 TEST_DEBUG("Length of CF number :%d ",len);
943                 memcpy(&(cfActReq.szPhoneNumber),cf_number,len);
944
945                 TEST_DEBUG("Select the Call Forwarding Flavor ");
946                 TEST_DEBUG(" CF-Unconditional -[0]  CF-Busy [1]  CF-No Reply [2]  CF-Not reachable [3] CF -All CF [4] All Cond CF [5]  ");
947                 ss_fgets(flavor,2);
948                 cfActReq.Condition = atoi(flavor);
949                 TEST_DEBUG("********** flavor=%x ",cfActReq.Condition);
950
951                 TEST_DEBUG("Select the Call Forwarding Type ");
952                 TEST_DEBUG("voice -[0] data -[3] fax-[4] all_tele and bearer -[5] ");
953                 ss_fgets(cfType,2);
954
955                 cfActReq.Type = atoi(cfType);
956
957                 cfActReq.NoReplyConditionTimer = TAPI_SS_CF_NO_REPLY_TIME_10_SECS;
958                 cfActReq.Mode=  TAPI_CALL_FORWARD_MODE_ERASURE_EV;
959
960                 TEST_DEBUG("CF Flavor:[%d], SS CF CallType:[%d]", cfActReq.Condition, cfActReq.Type);
961
962                 ret = tel_set_ss_forward(&cfActReq,&request_id);
963                 TEST_DEBUG("Tapi return api_err value is [0x%x]  RequestID:[%d]", ret,request_id);
964         }
965
966
967         /* Change Call barring password */
968         if(strncmp(buf, "cbp",3) == 0)
969         {
970                 char old_pwd[10];
971                 char new_pwd[10];
972                 char new_pwd_again[10];
973
974                 memset(old_pwd, 0, 10);
975                 memset(new_pwd, 0, 10);
976                 memset(new_pwd_again, 0, 10);
977
978                 TEST_DEBUG("####        Change the Call Barring Password        ####");
979                 TEST_DEBUG(" Enter Call Barring Old Password - size minimum 4 bytes");
980                 ss_fgets(old_pwd,5);
981
982                 TEST_DEBUG(" Enter Call Barring New Password - size minimum 4 bytes");
983                 ss_fgets(new_pwd,5);
984
985                 TEST_DEBUG(" Enter Call Barring New Password Again - size minimum 4 bytes");
986                 ss_fgets(new_pwd_again,5);
987
988                 ret = tel_change_ss_barring_password(old_pwd, new_pwd, new_pwd_again,&request_id);
989                 TEST_DEBUG("Tapi return api_err value is [0x%x]  RequestID:[%d]", ret,request_id);
990         }
991
992         /* CLI */
993         if(strncmp(buf, "cli", 3) == 0)
994         {
995                 char cli_type[1];
996                 TEST_DEBUG("####        Interrogate the Status of CLI Services (except CDIP) ####");
997                 TEST_DEBUG(" CLIP -[1] CLIR -[2] COLP -[3] COLR-[4] CDIP-[5] CNAP -[6] ");
998                 ss_fgets(cli_type,2);
999
1000                 TEST_DEBUG("CLI type:[%d]", atoi(cli_type));
1001
1002                 ret = tel_get_ss_cli_status(atoi(cli_type),&request_id);
1003                 TEST_DEBUG("Tapi return api_err value is [0x%x]  RequestID:[%d]", ret,request_id);
1004         }
1005         /* USSD */
1006         if(strncmp(buf, "ussd", 4) == 0)
1007         {
1008
1009                 char ussdString[TAPI_SS_USSD_DATA_SIZE_MAX];
1010                 int  ret;
1011
1012                 memset(ussdString, 0, TAPI_SS_USSD_DATA_SIZE_MAX);
1013                 strcpy(ussdString , "*124#");
1014
1015                 TEST_DEBUG("ussd string:[%s],ussd len:[%d]", ussdString, strlen(ussdString));
1016                 ret= tel_send_ss_ussd_request(ussdString,&request_id);
1017                 TEST_DEBUG(" API RETURN VAL:[%d]",ret);
1018
1019         }
1020
1021     /* Read AOC */
1022     if(strncmp(buf, "raoc", 4) == 0)
1023         {
1024                 char aoc_type[1];
1025                 TEST_DEBUG("Read AOC Information - Select AOC type");
1026                 TEST_DEBUG("ACM Accumulated Call meter -[1]  CCM -[2]  Cost Limit MAX ACM -[4]  Price per unit currency PUC [8]");
1027
1028                 ss_fgets(aoc_type,2);
1029                 TEST_DEBUG("Aoc Type :%d",atoi(aoc_type));
1030
1031                 ret = tel_get_ss_aoc_info(atoi(aoc_type),&request_id);
1032
1033                 TEST_DEBUG("Tapi return api_err value is [0x%x]  RequestID:[%d]", ret);
1034         }
1035
1036         /* SIM OPEN */
1037         if(strncmp(buf, "simopen", 7) == 0)
1038         {
1039                 int i = 0;
1040                 TelSimStatusData_t SimOpenData = {0,};
1041
1042                 TEST_DEBUG("********************************************");
1043
1044                 TEST_DEBUG("open sim");
1045         }
1046
1047         /* Enter PIN2 */
1048         if(strncmp(buf, "pin2", 4) == 0)
1049         {
1050                 /* nothing */
1051         }
1052
1053         if(strncmp(buf, "5e", 2) == 0)
1054         {
1055                 TEST_DEBUG("########### Setting Maximum Cost Limit -  MAX_ACM Value..############# ");
1056                 TelCallAocInfo_t pAocSetInfo = {0,};
1057                 char maxacm_val[10];
1058                 TEST_DEBUG("Enter the MAX ACM value ");
1059                 ss_fgets(maxacm_val,5);
1060
1061                 pAocSetInfo.AocType = TAPI_SS_AOC_TYPE_MAXACM;
1062
1063                 pAocSetInfo.MaxAcm =atoi(maxacm_val);
1064
1065                 ret = tel_set_ss_aoc_info(&pAocSetInfo, &request_id);
1066
1067                 TEST_DEBUG("Tapi return api_err value is [0x%x]  RequestID:[%d]", ret, request_id);
1068         }
1069         if(strncmp(buf, "5f", 2) == 0)
1070         {
1071                 TEST_DEBUG("########### Setting Price/Unit Currency - PPUC Value.############# ");
1072                 TelCallAocInfo_t *pAocSetInfo;
1073                 char ppu_curr[10];
1074
1075                 TEST_DEBUG("Enter price per unit currency Characters ");
1076                 ss_fgets(ppu_curr,3);
1077                 pAocSetInfo = calloc(1,sizeof(TelCallAocInfo_t));
1078
1079                 pAocSetInfo->AocType = TAPI_SS_AOC_TYPE_PUC;
1080
1081
1082                 pAocSetInfo->PPM = 0x02;
1083
1084                 pAocSetInfo->CharTypeOfCurrency = 0x02;
1085                 pAocSetInfo->szCurrency[0] = ppu_curr[0];
1086                 pAocSetInfo->szCurrency[1] = ppu_curr[1];
1087                 pAocSetInfo->szCurrency[2] = ppu_curr[2];
1088
1089                 TEST_DEBUG("Set  AOC Request");
1090
1091                 ret = tel_set_ss_aoc_info(pAocSetInfo,&request_id);
1092                 TEST_DEBUG("Tapi return api_err value is [0x%x]  RequestID:[%d]", ret, request_id);
1093
1094                 free(pAocSetInfo);
1095
1096         }
1097         if(strncmp(buf, "5g", 2) == 0)
1098         {
1099                 TEST_DEBUG("################## Resetting Total Cost   MAX ACM..################ ");;
1100                 TelCallAocInfo_t  *pAocSetInfo;
1101                 pAocSetInfo = calloc(1,sizeof(TelCallAocInfo_t));
1102
1103                 pAocSetInfo->AocType = TAPI_SS_AOC_TYPE_RESET;
1104
1105                 ret = tel_set_ss_aoc_info(pAocSetInfo,&request_id);
1106                 TEST_DEBUG("Tapi return api_err value is [0x%x]  RequestID:[%d]", ret, request_id);
1107
1108                 free(pAocSetInfo);
1109         }
1110
1111         if(strncmp(buf, "quit", 4) == 0)
1112         {
1113                 TEST_DEBUG("Finished Testing this module, Going back to Main Menu");
1114                 return -1;
1115         }
1116
1117         memset(buf, '\0', 256);
1118         return 0;
1119 }
1120
1121
1122 /*****************************************************************/
1123
1124 void ss_select_loop(void)
1125 {
1126         int ret;
1127         fd_set readfds;
1128
1129     while (1) {
1130         FD_ZERO(&readfds);
1131         FD_SET(0, &readfds);
1132
1133
1134          ret = select(0 + 1, &readfds, NULL, NULL, NULL);
1135         if (ret) {
1136
1137             if (FD_ISSET(0, &readfds)) {
1138                   if(ss_read_key_input()<0)
1139                         break;
1140             }
1141         }
1142     }
1143 }
1144
1145 int ss_test_subscribe_tapi_events(void)
1146 {
1147         int i = 0;
1148         int ret_val = TRUE;
1149         int iNumOfSSEvt = 0;
1150         TapiResult_t    api_err = TAPI_API_SUCCESS;
1151
1152
1153         int SSEvtList[] =
1154         {
1155                 TAPI_EVENT_SS_BARRING_CNF,   /**<0x0400,        This confirmation event is sent when Barring activation/deactivation is requested*/
1156                 TAPI_EVENT_SS_BARRING_CHANGEPASS_CNF,   /**<    This event is returned as Barring password change confirmation*/
1157                 TAPI_EVENT_SS_BARRING_QUERYSTATUS_CNF,   /**<   This event is returned  as Barring status query confirmation*/
1158                 TAPI_EVENT_SS_FORWARD_CNF,   /**<       This event is returned as confirmation for Forward Activation/Deactivation/Registration/Erasure */
1159                 TAPI_EVENT_SS_FORWARD_QUERYSTATUS_CNF,   /**<   This event is returned as confirmation for Forward Status query confirmation*/
1160                 TAPI_EVENT_SS_WAITING_CNF,   /**<       This event is returned as confirmation for Call waiting activation/deactivation*/
1161                 TAPI_EVENT_SS_WAITING_QUERYSTATUS_CNF,   /**<   This event is returned as Call waiting status query confirmation*/
1162                 TAPI_EVENT_SS_USSD_CNF,   /**<  This event is returned as USSD send confirmation*/
1163                 TAPI_EVENT_SS_USSD_CANCEL_CNF,  /**<    This event is returned as USSD cancel confirmation      >**/
1164                 TAPI_EVENT_SS_USSD_IND,   /**<  This is an unsolicited USSD indication*/
1165                 TAPI_EVENT_SS_CLI_QUERYSTATUS_CNF,   /**<       This event is indicated to the Application for CLI service interrogation*/
1166                 TAPI_EVENT_SS_REL_COMP_MSG_NOTIFY, /**< This event is indicated to the Application when tapi receives Release complete message notification for any SS transactions*/
1167                 TAPI_EVENT_SS_AOC_RSP,                          /**<This event is used to send the aoc information */
1168                 TAPI_EVENT_SS_SET_AOC_CNF,                      /**<This event is used to send the confirmation for setting aoc values */
1169                 TAPI_EVENT_SS_BARRING_TYPE_IND,         /**<This event is used to send the barring type while making an MO call */
1170         };
1171
1172         iNumOfSSEvt = sizeof(SSEvtList)/sizeof(int);
1173         TAPI_CALLOC(SS_subscription_id, iNumOfSSEvt, unsigned int)
1174
1175
1176         for( i=0 ; i< iNumOfSSEvt; i++ )
1177         {
1178                 api_err = tel_register_event(SSEvtList[i], &SS_subscription_id[i],(TelAppCallback)&ss_async_event_callback,NULL);
1179                 if(api_err != TAPI_API_SUCCESS)
1180                 {
1181                         TEST_DEBUG("isn't subscribed. event id is %d, api_err is %d\n", SSEvtList[i],api_err);
1182                         ret_val = FALSE;
1183                         break;
1184                 }
1185         }
1186
1187         return ret_val;
1188
1189 }