Tizen 2.1 base
[platform/core/telephony/tel-plugin-atmodem.git] / src / s_ss.c
1 /*
2  * tel-plugin-atmodem
3  *
4  * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Hayoon Ko <hayoon.ko@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 <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24
25 #include <glib.h>
26
27 #include <tcore.h>
28 #include <hal.h>
29 #include <core_object.h>
30 #include <plugin.h>
31 #include <queue.h>
32 #include <co_call.h>
33 #include <co_ss.h>
34 #include <user_request.h>
35 #include <server.h>
36
37 #include "s_common.h"
38 #include "s_ss.h"
39 #include "util.h"
40
41 #include "atchannel.h"
42 #include "at_tok.h"
43
44 extern struct ATResponse *sp_response;
45 extern char *s_responsePrefix;
46 extern enum ATCommandType s_type;
47
48
49 gboolean gcf = FALSE;
50
51 enum  telephony_ss_opcode {
52   TIZEN_SS_OPCO_REG=0x01,         /* 0x01 : Registration */
53   TIZEN_SS_OPCO_DEREG,              /* 0x02 : De-registration( erase ) */
54   TIZEN_SS_OPCO_ACTIVATE,        /* 0x03 : Activation */
55   TIZEN_SS_OPCO_DEACTIVATE,    /* 0x04 : De-activation */
56   TIZEN_SS_OPCO_MAX
57 } ;
58
59
60 struct ss_confirm_info {
61         enum telephony_ss_class class;
62         int  flavor_type;
63         enum tcore_response_command resp;
64         void *data;
65         int  data_len;
66 };
67
68 #define TIZEN_NUM_TYPE_INTERNATIONAL  0x01
69 #define TIZEN_NUM_PLAN_ISDN  0x01
70
71
72 static gboolean _ss_request_message( CoreObject *o,
73                                                                          UserRequest *ur,
74                                                                          char *cmd,
75                                                                          unsigned int cmd_len,
76                                                                          void* on_resp,
77                                                                          void* user_data );
78 #if 0
79 static TReturn  _ss_general_response_result(const int result);
80 #endif
81
82 static TReturn _ss_barring_get( CoreObject *o,
83                                                                 UserRequest *ur,
84                                                                 enum telephony_ss_class class,
85                                                                 enum telephony_ss_barring_mode type,
86                                                                 enum tcore_response_command resp );
87
88 static TReturn _ss_forwarding_get(      CoreObject *o,
89                                                                         UserRequest *ur,
90                                                                         enum telephony_ss_class class,
91                                                                         enum telephony_ss_forwarding_mode type,
92                                                                         enum tcore_response_command resp );
93
94 static TReturn _ss_waiting_get( CoreObject *o,
95                                                                 UserRequest *ur,
96                                                                 enum telephony_ss_class class,
97                                                                 enum tcore_response_command resp );
98
99
100 static TReturn s_ss_barring_activate( CoreObject *o, UserRequest *ur );
101 static TReturn s_ss_barring_deactivate( CoreObject *o, UserRequest *ur );
102 static TReturn s_ss_barring_change_password( CoreObject *o, UserRequest *ur );
103 static TReturn s_ss_barring_get_status( CoreObject *o, UserRequest *ur );
104
105 static TReturn s_ss_forwarding_activate( CoreObject *o, UserRequest *ur );
106 static TReturn s_ss_forwarding_deactivate( CoreObject *o, UserRequest *ur );
107 static TReturn s_ss_forwarding_register( CoreObject *o, UserRequest *ur );
108 static TReturn s_ss_forwarding_deregister( CoreObject *o, UserRequest *ur );
109 static TReturn s_ss_forwarding_get_status( CoreObject *o, UserRequest *ur );
110
111 static TReturn s_ss_waiting_activate( CoreObject *o, UserRequest *ur );
112 static TReturn s_ss_waiting_deactivate( CoreObject *o, UserRequest *ur );
113 static TReturn s_ss_waiting_get_status( CoreObject *o, UserRequest *ur );
114
115 static TReturn s_ss_cli_activate( CoreObject *o, UserRequest *ur );
116 static TReturn s_ss_cli_deactivate( CoreObject *o, UserRequest *ur );
117 static TReturn s_ss_cli_get_status( CoreObject *o, UserRequest *ur );
118
119 static TReturn s_ss_send_ussd( CoreObject *o, UserRequest *ur );
120
121 static TReturn s_ss_set_aoc( CoreObject *o, UserRequest *ur );
122 static TReturn s_ss_get_aoc( CoreObject *o, UserRequest *ur );
123
124 static TReturn  s_ss_manage_call_0_send( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data );
125 static TReturn  s_ss_manage_call_1_send( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data );
126 static TReturn  s_ss_manage_call_1x_send( CoreObject* o, UserRequest* ur, const int id, ConfirmCallback cb, void* user_data );
127 static TReturn  s_ss_manage_call_2_send( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data );
128 static TReturn  s_ss_manage_call_2x_send( CoreObject* o, UserRequest* ur, const int id, ConfirmCallback cb, void* user_data );
129 static TReturn  s_ss_manage_call_3_send( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data );
130 static TReturn  s_ss_manage_call_4_send( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data );
131 static TReturn  s_ss_manage_call_4dn_send( CoreObject* o, UserRequest* ur, const char* number, ConfirmCallback cb, void* user_data );
132 /*
133 static TReturn  s_ss_manage_call_5_send( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data );
134 static TReturn  s_ss_manage_call_6_send( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data );
135 */
136
137 static void on_confirmation_call_control_ss_message_send( TcorePending *p, gboolean result, void *user_data );
138
139 static void             on_confirmation_ss_message_send( TcorePending *p, gboolean result, void *user_data );
140
141
142 static gboolean on_notification_ss_info( CoreObject *o, const void *data, void *user_data );
143
144 static void             _ss_ussd_response( UserRequest *ur, const char* ussd_str, enum telephony_ss_ussd_type type, enum telephony_ss_ussd_status status );
145 static void             _ss_ussd_notification( TcorePlugin *p, const char* ussd_str, enum telephony_ss_ussd_status status );
146 static gboolean on_notification_ss_ussd( CoreObject *o, const void *data, void *user_data );
147
148
149 static gboolean _ss_request_message( CoreObject *o,
150                                                                          UserRequest *ur,
151                                                                          char *cmd,
152                                                                          unsigned int cmd_len,
153                                                                          void* on_resp,
154                                                                          void* user_data )
155 {
156         TcorePending *pending = 0;
157         TcorePlugin *p = 0;
158         TcoreHal *h = 0;
159         UserRequest *ur2 = 0;
160
161         ur2 = tcore_user_request_ref( ur );
162
163         pending = tcore_pending_new(o, ID_RESERVED_AT);
164         tcore_pending_set_request_data(pending, cmd_len, cmd);
165         tcore_pending_set_timeout(pending, 0);
166
167         if ( on_resp )
168                 tcore_pending_set_response_callback(pending, on_resp, user_data);
169
170         tcore_pending_set_send_callback(pending, on_confirmation_ss_message_send, 0);
171
172         if ( !ur2 ) {
173                 dbg("[ check ] ur is 0, is this internal request??");
174         } else {
175                 tcore_pending_link_user_request(pending, ur2);
176         }
177
178         p = tcore_object_ref_plugin(o);
179         h = tcore_object_get_hal(o);
180         tcore_hal_send_request(h, pending);
181
182         return TRUE;
183 }
184
185 #if 0
186 static TReturn _ss_general_response_result(const int ret)
187 {
188         if (ret == 0x8000 || ret == 0x8100) {
189                 return TCORE_RETURN_SUCCESS;
190         }
191
192         return TCORE_RETURN_3GPP_ERROR + ret;
193 }
194 #endif
195
196 static void _ss_ussd_response( UserRequest *ur, const char* ussd_str, enum telephony_ss_ussd_type type, enum telephony_ss_ussd_status status )
197 {
198         struct tresp_ss_ussd resp;
199
200         if ( !ur ) {
201                 dbg("[ error ] ur : (NULL)");
202                 return ;
203         }
204
205         resp.type = type;
206         resp.status = status;
207         resp.err = SS_ERROR_NONE;
208
209         if ( ussd_str ) {
210
211                 int len = strlen( ussd_str );
212
213                 if ( len < MAX_SS_USSD_LEN ) {
214                         memcpy( resp.str, ussd_str, len );
215                         resp.str[ len ] = '\0';
216                 } else {
217                         memcpy( resp.str, ussd_str, MAX_SS_USSD_LEN );
218                         resp.str[ MAX_SS_USSD_LEN - 1 ] = '\0';
219                 }
220
221                 dbg("resp.str : %s", resp.str);
222
223         } else {
224
225                 memset( resp.str, '\0', MAX_SS_USSD_LEN );
226
227         }
228
229         tcore_user_request_send_response(ur, TRESP_SS_SEND_USSD, sizeof(struct tresp_ss_ussd), &resp);
230 }
231
232 static void _ss_ussd_notification( TcorePlugin *p, const char* ussd_str, enum telephony_ss_ussd_status status )
233 {
234         CoreObject *o = 0;
235         struct tnoti_ss_ussd noti;
236
237         if ( !p ) {
238                 dbg("[ error ] p : (NULL)");
239                 return ;
240         }
241
242         noti.status = status;
243
244         if ( ussd_str ) {
245
246                 int len = strlen( ussd_str );
247
248                 if ( len < MAX_SS_USSD_LEN ) {
249                         memcpy( noti.str, ussd_str, len );
250                         noti.str[ len ] = '\0';
251                 } else {
252                         memcpy( noti.str, ussd_str, MAX_SS_USSD_LEN );
253                         noti.str[ MAX_SS_USSD_LEN - 1 ] = '\0';
254                 }
255
256         } else {
257
258                 memset( noti.str, '\0', MAX_SS_USSD_LEN );
259
260         }
261
262         o = tcore_plugin_ref_core_object(p, "ss");
263
264         tcore_server_send_notification( tcore_plugin_ref_server(p),
265                         o,
266                         TNOTI_SS_USSD,
267                         sizeof(struct tnoti_ss_ussd),
268                         (void*)&noti    );
269
270 }
271
272 static gboolean on_notification_ss_ussd( CoreObject *o, const void *data, void *user_data )
273 {
274         enum telephony_ss_ussd_status status;
275         UssdSession *ussd_session = 0;
276         char *ussd_str = 0, *cmd = 0, *tmp_str=0;
277         TcorePlugin *p = 0;
278         int err =0, m=0, dcs=0;
279
280         p = tcore_object_ref_plugin(o);
281
282         ussd_session = tcore_ss_ussd_get_session(o);
283
284         cmd = (char*)data;
285
286         // parse ussd status
287         at_tok_start(&cmd);
288         err = at_tok_nextint(&cmd, &m);
289         dbg("m: %d", m);
290
291         switch(m){
292                 case 0:
293                         status = SS_USSD_NO_ACTION_REQUIRE;
294                         break;
295
296                 case 1:
297                         status = SS_USSD_ACTION_REQUIRE;
298                         break;
299
300                 case 2:
301                         status = SS_USSD_TERMINATED_BY_NET;
302                         break;
303
304                 case 3:
305                         status = SS_USSD_OTHER_CLIENT;
306                         break;
307
308                 case 4:
309                         status = SS_USSD_NOT_SUPPORT;
310                         break;
311
312                 case 5:
313                         status = SS_USSD_TIME_OUT;
314                         break;
315
316                 default:
317                         dbg("unsupported m : %d", m);
318                         status = SS_USSD_MAX;
319                         break;
320         }
321
322         if(at_tok_hasmore(&cmd))
323         {
324                 err = at_tok_nextstr(&cmd, &tmp_str);
325                 err = at_tok_nextint(&cmd, &dcs);
326
327                 dbg("ussdstr: %s, dcs :%d", tmp_str, dcs);
328         }
329
330         switch ( tcore_util_get_cbs_coding_scheme(dcs) ) {
331                 case TCORE_DCS_TYPE_7_BIT:
332                 case TCORE_DCS_TYPE_UNSPECIFIED: {
333                         ussd_str = (char *)tcore_util_unpack_gsm7bit((const unsigned char *)tmp_str, strlen(tmp_str));
334                 } break;
335
336                 case TCORE_DCS_TYPE_UCS2:
337                 case TCORE_DCS_TYPE_8_BIT: {
338                         if ( strlen(tmp_str)  > 0 ) {
339                                 ussd_str = g_new0( char, strlen(tmp_str)  + 1);
340                                 memcpy( ussd_str,tmp_str, strlen(tmp_str) );
341                                 ussd_str[ strlen(tmp_str) ] = '\0';
342                         }
343                 } break;
344                 default: {
345                         dbg("[ error ] unknown dcs type. ussd_session : %x", ussd_session);
346                         if ( ussd_session ) {
347
348                                 UserRequest *ur = 0;
349                                 enum telephony_ss_ussd_type type;
350
351                                 tcore_ss_ussd_get_session_data( ussd_session, (void**)&ur );
352                                 if ( !ur ) {
353                                         dbg("[ error ] ur : (0)");
354                                         return TRUE;
355                                 }
356
357                                 type = (enum telephony_ss_ussd_type)tcore_ss_ussd_get_session_type( ussd_session );
358
359                                 _ss_ussd_response( ur, ussd_str, type, status );
360                         }
361                         return TRUE;
362                 }
363         }
364
365         switch ( status ) {
366         case SS_USSD_NO_ACTION_REQUIRE:
367         case SS_USSD_ACTION_REQUIRE:
368         case SS_USSD_OTHER_CLIENT:
369         case SS_USSD_NOT_SUPPORT:
370         case SS_USSD_TIME_OUT: {
371
372         //      UserRequest *ur = 0;
373
374                 if ( ussd_session ) {
375
376                         UserRequest *ur = 0;
377                         enum telephony_ss_ussd_type type;
378
379                         tcore_ss_ussd_get_session_data( ussd_session, (void**)&ur );
380                         if ( !ur ) {
381                                 dbg("[ error ] ur : (0)");
382                                 return TRUE;
383                         }
384
385                         type = (enum telephony_ss_ussd_type)tcore_ss_ussd_get_session_type( ussd_session );
386
387                         _ss_ussd_response( ur, (const char*)ussd_str, type, status );
388
389                         g_free( ussd_str );
390
391                 } else {
392
393                         tcore_ss_ussd_create_session( o, TCORE_SS_USSD_TYPE_NETWORK_INITIATED, 0, 0 );
394
395                         _ss_ussd_notification( p, (const char*)ussd_str, status );
396
397                         g_free( ussd_str );
398                 }
399
400         } break;
401         case SS_USSD_TERMINATED_BY_NET: {
402
403                 if ( ussd_session ) {
404                         UserRequest *ur = 0;
405
406                         tcore_ss_ussd_get_session_data( ussd_session, (void**)&ur );
407
408                         if ( ur )
409                                 tcore_user_request_unref( ur );
410
411                         tcore_ss_ussd_destroy_session( ussd_session );
412                 }
413
414         } break;
415         default:
416         break;
417         }
418
419         return TRUE;
420 }
421
422 static gboolean on_notification_ss_info( CoreObject *o, const void *data, void *user_data )
423 {
424         TcorePlugin *p  = 0;
425         CoreObject *co = 0;
426         char* cmd = 0, *number = 0;
427         int code2 =0, err=0, index=0, ton=0;
428
429
430         p       = tcore_object_ref_plugin( o );
431         co      = tcore_plugin_ref_core_object( p, "call" );
432         if (!co) {
433                 dbg("[ error ] plugin_ref_core_object : call");
434                 return TRUE;
435         }
436
437         cmd = (char*)data;
438         at_tok_start(&cmd);
439
440         err = at_tok_nextint(&cmd, &code2);
441         dbg("code2 : %d",code2);
442
443         if(at_tok_hasmore(&cmd))
444                 err = at_tok_nextint(&cmd, &index); //cug index - skip
445         if(at_tok_hasmore(&cmd)){
446                 err = at_tok_nextstr(&cmd, &number);
447                 dbg("number : %s",number);
448                 err = at_tok_nextint(&cmd, &ton);
449         }
450
451         switch(code2){
452                 case 0:  //this is a forwarded call (MT call setup)
453                         tcore_call_information_mt_forwarded_call( co, number );
454                         break;
455
456                 case 2: //call has been put on hold (during a voice call)
457                         tcore_call_information_held( co, number );
458                         break;
459
460                 case 3: //call has been retrieved (during a voice call)
461                         tcore_call_information_active( co, number );
462                         break;
463
464                 case 4: //multiparty call entered (during a voice call)
465                         tcore_call_information_joined( co, number );
466                         break;
467
468                 case 5: //call on hold has been released
469                         tcore_call_information_released_on_hold( co, number );
470                         break;
471
472                 case 6: //forward check SS message received (can be received whenever)
473                         tcore_call_information_cf_check_ss_message( co, number );
474                         break;
475
476                 case 7: //call is being connected (alerting) with the remote party in alerting state in explicit call transfer operation (during a voice call)
477                         tcore_call_information_transfer_alert( co, number );
478                         break;
479
480                 case 8: //call has been connected with the other remote party in explicit call transfer operation (also number and subaddress parameters may be present) (during a voice call or MT call setup)
481                         tcore_call_information_transfered( co, number );
482                         break;
483
484                 case 9: //this is a deflected call (MT call setup):
485                         tcore_call_information_mt_deflected_call( co, number );
486                         break;
487
488                 default:
489                         dbg("unsupported cmd2 : %d",code2);
490                         break;
491         }
492
493         return TRUE;
494 }
495
496 static void on_confirmation_ss_message_send( TcorePending *p, gboolean result, void *user_data )
497 {
498         UserRequest* ur = NULL;
499         struct ATReqMetaInfo* metainfo = NULL;
500         unsigned int info_len =0;
501         dbg("on_confirmation_ss_message_send - msg out from queue. alloc ATRsp buffer & write rspPrefix if needed\n");
502
503         ReleaseResponse(); // release leftover
504 //alloc new sp_response
505         sp_response = at_response_new();
506
507
508         ur = tcore_pending_ref_user_request(p);
509         metainfo = (struct ATReqMetaInfo*)tcore_user_request_ref_metainfo(ur,&info_len);
510
511         if((metainfo->type == SINGLELINE)||
512                 (metainfo->type == MULTILINE))
513         {
514                 //cp rsp prefix
515                 s_responsePrefix = strdup(metainfo->responsePrefix);
516                 dbg("duplicating responsePrefix : %s\n", s_responsePrefix);
517         }
518         else
519         {
520                 s_responsePrefix = NULL;
521         }
522
523 //set atcmd type into s_type
524         s_type = metainfo->type;
525 }
526
527 static void on_confirmation_call_control_ss_message_send( TcorePending *p, gboolean result, void *user_data )
528 {
529         UserRequest* ur = NULL;
530         struct ATReqMetaInfo* metainfo = NULL;
531         unsigned int info_len =0;
532         dbg("on_confirmation_call_control_ss_message_send - msg out from queue. alloc ATRsp buffer & write rspPrefix if needed\n");
533
534         ReleaseResponse(); // release leftover
535 //alloc new sp_response
536         sp_response = at_response_new();
537
538
539         ur = tcore_pending_ref_user_request(p);
540         metainfo = (struct ATReqMetaInfo*)tcore_user_request_ref_metainfo(ur,&info_len);
541
542         if((metainfo->type == SINGLELINE)||
543                         (metainfo->type == MULTILINE))
544         {
545                 //cp rsp prefix
546                 s_responsePrefix = strdup(metainfo->responsePrefix);
547                 dbg("duplicating responsePrefix : %s\n", s_responsePrefix);
548         }
549         else
550         {
551                 s_responsePrefix = NULL;
552         }
553
554         //set atcmd type into s_type
555         s_type = metainfo->type;
556 }
557
558 static void on_response_ss_barring_set( TcorePending *p, int data_len, const void *data, void *user_data )
559 {
560         struct ss_confirm_info *info = 0;
561         enum telephony_ss_class class;
562
563         CoreObject* o = 0;
564         UserRequest *ur;
565         struct tresp_ss_barring resp;
566         UserRequest *ur_dup=0;
567
568         o  = tcore_pending_ref_core_object(p);
569         ur = tcore_pending_ref_user_request(p);
570
571         printResponse();
572
573         info = (struct ss_confirm_info*)user_data;
574         class = info->class;
575
576
577         if(sp_response->success > 0){
578                 resp.err = SS_ERROR_NONE;
579         }
580         else{
581                 resp.record_num = 0;
582                 resp.err = SS_ERROR_SYSTEMFAILURE;
583         }
584
585         dbg("on_response_ss_barring_set - rsp.err : %d, ur : %x", resp.err, ur);
586
587
588         if(sp_response->success > 0)
589         {
590                 ReleaseResponse();
591
592                 if ( info->class == SS_CLASS_VOICE )
593                         class = SS_CLASS_ALL_TELE_BEARER;
594
595                 ur_dup = tcore_user_request_ref(ur);
596
597                 if ( info->flavor_type == SS_BARR_MODE_AB ||
598                          info->flavor_type == SS_BARR_MODE_AOB )
599                         _ss_barring_get( o, ur_dup, class, SS_BARR_MODE_BAOC, info->resp );
600                 else if ( info->flavor_type == SS_BARR_MODE_AIB )
601                         _ss_barring_get( o, ur_dup, class, SS_BARR_MODE_BAIC, info->resp );
602                 else
603                         _ss_barring_get( o, ur_dup, class, info->flavor_type, info->resp );
604
605         }
606         else
607         {
608                 ReleaseResponse();
609
610                 if ( ur )
611                         tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_barring), &resp);
612                 else
613                         dbg("[ error ] ur is 0");
614
615         }
616
617         g_free(user_data);
618
619
620 }
621
622 static void on_response_ss_barring_change_pwd( TcorePending *p, int data_len, const void *data, void *user_data )
623 {
624         struct ss_confirm_info *info = 0;
625         UserRequest *ur;
626         struct tresp_ss_general resp;
627
628         ur = tcore_pending_ref_user_request(p);
629
630         info = (struct ss_confirm_info*)user_data;
631
632         printResponse();
633
634         if(sp_response->success > 0){
635                 resp.err = SS_ERROR_NONE;
636         }
637         else{
638                 resp.err = SS_ERROR_SYSTEMFAILURE;
639         }
640
641         ReleaseResponse();
642
643         dbg("on_response_ss_barring_change_pwd: rsp.err : %d, usr : %x", resp.err, ur);
644
645         if ( ur )
646                 tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_general), &resp);
647         else
648                 dbg("[ error ] ur is 0");
649
650         g_free(user_data);
651 }
652
653
654 static void on_response_ss_barring_get( TcorePending *p, int data_len, const void *data, void *user_data )
655 {
656         CoreObject*             o = 0;
657         UserRequest*    ur = 0;
658         struct ATLine *p_cur;
659         int status=0, classx =0, err=0;
660
661         struct ss_confirm_info* info = 0;
662         struct tresp_ss_barring resp;
663         int countRecords=0, countValidRecords =0;
664
665         o  = tcore_pending_ref_core_object(p);
666         ur = tcore_pending_ref_user_request(p);
667
668         printResponse();
669
670         info = (struct ss_confirm_info*)user_data;
671
672         /* count the calls */
673         for (countRecords = 0, p_cur = sp_response->p_intermediates
674                         ; p_cur != NULL
675                         ; p_cur = p_cur->p_next
676                 ) {
677                 countRecords++;
678         }
679         dbg("total records : %d",countRecords);
680
681
682         resp.record_num = countRecords;
683
684         if ( resp.record_num > 0 ) {
685 //              int i = 0;
686
687                 resp.record = g_new0( struct barring_info, resp.record_num );
688
689                 for (countValidRecords = 0, p_cur = sp_response->p_intermediates
690                                 ; p_cur != NULL
691                                 ; p_cur = p_cur->p_next)
692                 {
693                         err = at_tok_start(&(p_cur->line));
694                         if (err < 0){
695                                 dbg("start line error. skip this line");
696                                 goto error;
697                         }
698                         err = at_tok_nextint(&(p_cur->line), &status);// status
699                         if (err < 0) {
700                                 dbg("status error. skip this line");
701                                 goto error;
702                         }
703
704                         if(status == 1){
705                                 resp.record[countValidRecords].status = SS_STATUS_ACTIVATE;
706                         }
707                         else    {
708                                 resp.record[countValidRecords].status = SS_STATUS_DEACTIVATE;
709                         }
710
711                         err = at_tok_nextint(&(p_cur->line), &classx); //class
712                         if (err < 0) {
713                                 dbg("class error. classx not exist - set to requested one : %d", info->class);
714                                 switch(info->class){
715                                         case SS_CLASS_ALL_TELE:
716                                                 classx =7;
717                                                 break;
718                                         case SS_CLASS_VOICE:
719                                                 classx =1;
720                                                 break;
721                                         case SS_CLASS_ALL_DATA_TELE:
722                                                 classx =2;
723                                                 break;
724                                         case SS_CLASS_FAX:
725                                                 classx =4;
726                                                 break;
727                                         case SS_CLASS_SMS:
728                                                 classx = 8;
729                                                 break;
730                                         case SS_CLASS_ALL_CS_SYNC:
731                                                 classx = 16;
732                                                 break;
733
734                                         default:
735                                                 classx =7;
736                                                 dbg("unsupported class %d. set to default : 7", info->class);
737                                                 break;
738                                 }
739                         }
740
741                         switch(classx){
742                                 case 1:
743                                         resp.record[countValidRecords].class = SS_CLASS_VOICE;
744                                         break;
745                                 case 2:
746                                         resp.record[countValidRecords].class = SS_CLASS_ALL_DATA_TELE;
747                                         break;
748                                 case 4:
749                                         resp.record[countValidRecords].class = SS_CLASS_FAX;
750                                         break;
751                                 case 7:
752                                         resp.record[countValidRecords].class = SS_CLASS_ALL_TELE;
753                                         break;
754                                 case 8:
755                                         resp.record[countValidRecords].class = SS_CLASS_SMS;
756                                         break;
757                                 case 16:
758                                         resp.record[countValidRecords].class = SS_CLASS_ALL_CS_SYNC;
759                                         break;
760                                 case 32:
761                                         resp.record[countValidRecords].class = SS_CLASS_ALL_CS_ASYNC;
762                                         break;
763                                 default:
764                                         dbg("unspoorted class : [%d]\n", classx );
765                                         goto error;
766                                         break;
767                         }
768
769                         resp.record[countValidRecords].mode = (enum telephony_ss_barring_mode)(info->flavor_type);
770
771                         countValidRecords++;
772                         continue;
773 error:
774                         dbg("invalid field found. coutinue");
775                         continue;
776                 }
777
778                 dbg("valid count :%d",countValidRecords);
779                 resp.record_num = countValidRecords;
780                 resp.err = SS_ERROR_NONE;
781
782         }
783         else
784         {
785                 dbg("no active status - return to user")
786         }
787
788         if(sp_response->success > 0){
789                 resp.err = SS_ERROR_NONE;
790         }
791         else{
792                 resp.err = SS_ERROR_SYSTEMFAILURE;
793         }
794
795         dbg("on_response_ss_barring_get- rsp.err : %d, ur : %x", resp.err, ur);
796
797         ReleaseResponse();
798
799         if ( ur )
800                 tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_barring), &resp);
801         else
802                 dbg("[ error ] ur is 0");
803
804         g_free( user_data );
805
806 }
807
808 static void on_response_ss_forwarding_set( TcorePending *p, int data_len, const void *data, void *user_data )
809 {
810         CoreObject*             o = 0;
811         UserRequest*    ur = 0, *dup_ur=0;
812         struct ss_confirm_info *info = 0;
813         struct tresp_ss_general resp;
814
815         o  = tcore_pending_ref_core_object(p);
816         ur = tcore_pending_ref_user_request(p);
817
818         info = (struct ss_confirm_info*)user_data;
819
820         printResponse();
821
822         if(sp_response->success > 0){
823                 resp.err = SS_ERROR_NONE;
824         }else{
825                 resp.err = SS_ERROR_SYSTEMFAILURE;
826         }
827
828         dbg("[ check ] class : 0x%x", info->class );
829         dbg("[ check ] flavor_type : 0x%x", info->flavor_type );
830
831         dbg("on_response_ss_forwarding_set - rsp.err : %d, ur : %x", resp.err, ur);
832
833         if ( sp_response->success > 0) {
834
835         ReleaseResponse();
836
837                 if ( info->flavor_type == SS_CF_MODE_CF_ALL ||
838                          info->flavor_type == SS_CF_MODE_CFC ) {
839
840                         if ( ur )
841                                 tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_general), &resp);
842                         else
843                                 dbg("[ error ] ur is 0");
844
845                 } else {
846                         dup_ur = tcore_user_request_ref(ur);
847                         _ss_forwarding_get( o, dup_ur, info->class, info->flavor_type, info->resp );
848                 }
849
850         } else {
851                 ReleaseResponse();
852
853                 if ( ur )
854                         tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_general), &resp);
855                 else
856                         dbg("[ error ] ur is 0");
857
858         }
859         g_free(user_data);
860 }
861
862 static void on_response_ss_forwarding_get( TcorePending *p, int data_len, const void *data, void *user_data )
863 {
864         CoreObject*             o = 0;
865         UserRequest*    ur = 0;
866         struct ATLine *p_cur;
867         int status=0, classx =0, err=0, ton =0, time=0;
868         char* num, *subaddr;
869
870         struct ss_confirm_info* info = 0;
871         struct tresp_ss_forwarding resp;
872         int countRecords=0, countValidRecords =0;
873
874         o  = tcore_pending_ref_core_object(p);
875         ur = tcore_pending_ref_user_request(p);
876
877         printResponse();
878
879         info = (struct ss_confirm_info*)user_data;
880
881         /* count the calls */
882         for (countRecords = 0, p_cur = sp_response->p_intermediates
883                         ; p_cur != NULL
884                         ; p_cur = p_cur->p_next
885                 ) {
886                 countRecords++;
887         }
888         dbg("total records : %d",countRecords);
889
890
891         resp.record_num = countRecords;
892
893         if ( resp.record_num > 0 ) {
894                 //              int i = 0;
895
896                 resp.record = g_new0( struct forwarding_info, resp.record_num );
897
898                 for (countValidRecords = 0, p_cur = sp_response->p_intermediates
899                                 ; p_cur != NULL
900                                 ; p_cur = p_cur->p_next)
901                 {
902                         err = at_tok_start(&(p_cur->line));
903                         if (err < 0){
904                                 dbg("start line error. skip this line");
905                                 goto error;
906                         }
907                         err = at_tok_nextint(&(p_cur->line), &status);// status
908                         if (err < 0) {
909                                 dbg("status error. skip this line");
910                                 goto error;
911                         }
912
913                         if(status == 1){
914                                 resp.record[countValidRecords].status = SS_STATUS_ACTIVATE;
915                         }
916                         else    {
917                                 resp.record[countValidRecords].status = SS_STATUS_DEACTIVATE;
918                         }
919
920                         err = at_tok_nextint(&(p_cur->line), &classx); //class
921                         if (err < 0) {
922                                 dbg("class error. skip this line");
923                                 goto error;
924                         }
925
926                         switch(classx){
927                                 case 1:
928                                         resp.record[countValidRecords].class = SS_CLASS_VOICE;
929                                         break;
930                                 case 2:
931                                         resp.record[countValidRecords].class = SS_CLASS_ALL_DATA_TELE;
932                                         break;
933                                 case 4:
934                                         resp.record[countValidRecords].class = SS_CLASS_FAX;
935                                         break;
936                                 case 7:
937                                         resp.record[countValidRecords].class = SS_CLASS_ALL_TELE;
938                                         break;
939                                 case 8:
940                                         resp.record[countValidRecords].class = SS_CLASS_SMS;
941                                         break;
942                                 case 16:
943                                         resp.record[countValidRecords].class = SS_CLASS_ALL_CS_SYNC;
944                                         break;
945                                 case 32:
946                                         resp.record[countValidRecords].class = SS_CLASS_ALL_CS_ASYNC;
947                                         break;
948                                 default:
949                                         dbg("unspoorted class : [%d]\n", classx );
950                                         goto error;
951                                         break;
952                         }
953
954                         if(at_tok_hasmore(&(p_cur->line)) ==1){ //more data present
955                                 err = at_tok_nextstr(&(p_cur->line), &num); //number
956                                 memcpy((resp.record[countValidRecords].number), num, strlen(num));
957                                 resp.record[countValidRecords].number_present = TRUE;
958
959                                 err = at_tok_nextint(&(p_cur->line), &ton); // type of  number - skip
960                                 resp.record[countValidRecords].number_type = ton;
961
962                                 if(at_tok_hasmore(&(p_cur->line)) ==1){
963                                         err = at_tok_nextstr(&(p_cur->line), &subaddr); //subaddr - skip
964                                         err  =at_tok_nextint(&(p_cur->line), &ton); //ton of subaddr - skip
965
966                                         if(at_tok_hasmore(&(p_cur->line)) ==1){
967                                                 err = at_tok_nextint(&(p_cur->line), &time); //time
968                                                 resp.record[countValidRecords].time = (enum telephony_ss_forwarding_no_reply_time)time;
969                                         }
970
971                                 }
972
973                         }
974
975                         resp.record[countValidRecords].mode = (enum telephony_ss_forwarding_mode)(info->flavor_type);
976
977                         countValidRecords++;
978                         continue;
979 error:
980                         dbg("invalid field found. coutinue");
981                         continue;
982                 }
983
984                 dbg("valid count :%d",countValidRecords);
985                 resp.record_num = countValidRecords;
986                 resp.err = SS_ERROR_NONE;
987
988         }
989         else
990         {
991                 dbg("no active status - return to user")
992         }
993
994         if(sp_response->success > 0){
995                 resp.err = SS_ERROR_NONE;
996         }
997         else{
998                 resp.err = SS_ERROR_SYSTEMFAILURE;
999         }
1000
1001         ReleaseResponse();
1002         dbg("on_response_ss_forwarding_get - rsp.err : %d, ur : %x", resp.err, ur);
1003
1004         if ( ur )
1005                 tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_forwarding), &resp);
1006         else
1007                 dbg("[ error ] ur is 0");
1008
1009         g_free( user_data );
1010
1011 }
1012
1013 static void on_response_ss_waiting_set( TcorePending *p, int data_len, const void *data, void *user_data )
1014 {
1015         CoreObject*             o = 0;
1016         UserRequest*    ur = 0;
1017         struct ss_confirm_info *info = 0;
1018         struct tresp_ss_general resp;
1019
1020         o  = tcore_pending_ref_core_object(p);
1021         ur = tcore_pending_ref_user_request(p);
1022
1023         info = (struct ss_confirm_info*)user_data;
1024
1025         if(sp_response->success > 0){
1026                 resp.err = SS_ERROR_NONE;
1027         }else{
1028                 resp.err = SS_ERROR_SYSTEMFAILURE;
1029         }
1030
1031         ReleaseResponse();
1032
1033         dbg("on_response_ss_waiting_set - rsp.err : %d, ur : %x, class : %d", resp.err, ur, info->class );
1034
1035         if ( resp.err == SS_ERROR_NONE ) {
1036
1037                 _ss_waiting_get( o, ur, info->class, info->resp );
1038
1039         } else {
1040
1041                 if ( ur )
1042                         tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_general), &resp);
1043                 else
1044                         dbg("[ error ] ur is 0");
1045
1046         }
1047         g_free( user_data );
1048 }
1049
1050 static void on_response_ss_waiting_get( TcorePending *p, int data_len, const void *data, void *user_data )
1051 {
1052         CoreObject*             o = 0;
1053         UserRequest*    ur = 0;
1054         struct ATLine *p_cur;
1055         int status=0, classx =0, err=0;
1056
1057         struct ss_confirm_info* info = 0;
1058         struct tresp_ss_waiting resp;
1059         int countRecords=0, countValidRecords =0;
1060
1061         o  = tcore_pending_ref_core_object(p);
1062         ur = tcore_pending_ref_user_request(p);
1063
1064         printResponse();
1065
1066         info = (struct ss_confirm_info*)user_data;
1067
1068         /* count the calls */
1069         for (countRecords = 0, p_cur = sp_response->p_intermediates
1070                         ; p_cur != NULL
1071                         ; p_cur = p_cur->p_next
1072                 ) {
1073                 countRecords++;
1074         }
1075         dbg("total records : %d",countRecords);
1076
1077
1078         resp.record_num = countRecords;
1079
1080         if ( resp.record_num > 0 ) {
1081                 //              int i = 0;
1082
1083                 resp.record = g_new0( struct waiting_info, resp.record_num );
1084
1085                 for (countValidRecords = 0, p_cur = sp_response->p_intermediates
1086                                 ; p_cur != NULL
1087                                 ; p_cur = p_cur->p_next)
1088                 {
1089                         err = at_tok_start(&(p_cur->line));
1090                         if (err < 0){
1091                                 dbg("start line error. skip this line");
1092                                 goto error;
1093                         }
1094
1095                         err = at_tok_nextint(&(p_cur->line), &status);// status
1096                         if (err < 0) {
1097                                 dbg("status error. skip this line");
1098                                 goto error;
1099                         }
1100
1101                         if(status == 1){
1102                                 resp.record[countValidRecords].status = SS_STATUS_ACTIVATE;
1103                         }
1104                         else    {
1105                                 resp.record[countValidRecords].status = SS_STATUS_DEACTIVATE;
1106                         }
1107
1108                         err = at_tok_nextint(&(p_cur->line), &classx); //class
1109                         if (err < 0) {
1110                                 dbg("class error. skip this line");
1111                                 goto error;
1112                         }
1113
1114                         switch(classx){
1115                                 case 1:
1116                                         resp.record[countValidRecords].class = SS_CLASS_VOICE;
1117                                         break;
1118                                 case 2:
1119                                         resp.record[countValidRecords].class = SS_CLASS_ALL_DATA_TELE;
1120                                         break;
1121                                 case 4:
1122                                         resp.record[countValidRecords].class = SS_CLASS_FAX;
1123                                         break;
1124                                 case 7:
1125                                         resp.record[countValidRecords].class = SS_CLASS_ALL_TELE;
1126                                         break;
1127                                 case 8:
1128                                         resp.record[countValidRecords].class = SS_CLASS_SMS;
1129                                         break;
1130                                 case 16:
1131                                         resp.record[countValidRecords].class = SS_CLASS_ALL_CS_SYNC;
1132                                         break;
1133                                 case 32:
1134                                         resp.record[countValidRecords].class = SS_CLASS_ALL_CS_ASYNC;
1135                                         break;
1136                                 default:
1137                                         dbg("unspoorted class : [%d]\n", classx );
1138                                         goto error;
1139                                         break;
1140                         }
1141
1142                         countValidRecords++;
1143                         continue;
1144 error:
1145                         dbg("invalid field found. coutinue");
1146                         continue;
1147                 }
1148
1149                 dbg("valid count :%d",countValidRecords);
1150                 resp.record_num = countValidRecords;
1151                 resp.err = SS_ERROR_NONE;
1152         }
1153         else
1154         {
1155                 dbg("no active status - return to user")
1156         }
1157
1158         if(sp_response->success > 0){
1159                 resp.err = SS_ERROR_NONE;
1160         }
1161         else{
1162                 resp.err = SS_ERROR_SYSTEMFAILURE;
1163         }
1164
1165         dbg("on_response_ss_waiting_get - rsp.err : %d, ur : %x", resp.err, ur);
1166
1167         ReleaseResponse();
1168
1169         if ( ur )
1170                 tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_waiting), &resp);
1171         else
1172                 dbg("[ error ] ur is 0");
1173
1174         g_free( user_data );
1175
1176 }
1177
1178 static void on_confirmation_ss_ussd( TcorePending *p, int data_len, const void *data, void *user_data )
1179 {
1180         struct ss_confirm_info *info = 0;
1181
1182         struct tresp_ss_ussd resp;
1183         CoreObject*             o = 0;
1184         UserRequest*    ur = 0;
1185
1186         o  = tcore_pending_ref_core_object(p);
1187         ur = tcore_pending_ref_user_request(p);
1188
1189
1190         printResponse();
1191
1192         info = (struct ss_confirm_info*)user_data;
1193
1194         if(sp_response->success > 0){
1195                 resp.err = SS_ERROR_NONE;
1196         }
1197         else{
1198                 resp.err = SS_ERROR_SYSTEMFAILURE;
1199         }
1200
1201         dbg("on_confirmation_ss_ussd - rsp.err : %d, ur : %x", resp.err, ur);
1202
1203
1204         if (sp_response->success > 0) {
1205
1206                 UssdSession *ussd_s = 0;
1207                 enum tcore_ss_ussd_type type = 0;
1208
1209                 ussd_s = tcore_ss_ussd_get_session( o );
1210
1211                 if ( ussd_s )
1212                         type = tcore_ss_ussd_get_session_type( ussd_s );
1213                 else
1214                         dbg("[ error ] ussd_s : (0)");
1215
1216                 resp.type = (enum telephony_ss_ussd_type)type;
1217
1218                 if ( type == TCORE_SS_USSD_TYPE_USER_INITIATED ) {
1219                         UserRequest *ur2 = 0;
1220
1221                         tcore_ss_ussd_get_session_data( ussd_s, (void**)&ur2 );
1222                         if ( ur2 )
1223                                 tcore_user_request_unref( ur2 );
1224
1225                         tcore_ss_ussd_destroy_session( ussd_s );
1226                 }
1227
1228                 if ( ur )
1229                         tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_ussd), &resp);
1230                 else
1231                         dbg("[ error ] ur : (0)");
1232
1233                 ReleaseResponse();
1234         }
1235
1236         g_free( user_data );
1237
1238 }
1239
1240
1241 static struct tcore_ss_operations ss_ops = {
1242         .barring_activate               = s_ss_barring_activate,
1243         .barring_deactivate             = s_ss_barring_deactivate,
1244         .barring_change_password= s_ss_barring_change_password,
1245         .barring_get_status             = s_ss_barring_get_status,
1246         .forwarding_activate    = s_ss_forwarding_activate,
1247         .forwarding_deactivate  = s_ss_forwarding_deactivate,
1248         .forwarding_register    = s_ss_forwarding_register,
1249         .forwarding_deregister  = s_ss_forwarding_deregister,
1250         .forwarding_get_status  = s_ss_forwarding_get_status,
1251         .waiting_activate               = s_ss_waiting_activate,
1252         .waiting_deactivate             = s_ss_waiting_deactivate,
1253         .waiting_get_status             = s_ss_waiting_get_status,
1254         .cli_activate                   = s_ss_cli_activate,
1255         .cli_deactivate                 = s_ss_cli_deactivate,
1256         .cli_get_status                 = s_ss_cli_get_status,
1257         .send_ussd                              = s_ss_send_ussd,
1258         .set_aoc                                = s_ss_set_aoc,
1259         .get_aoc                                = s_ss_get_aoc,
1260 };
1261
1262
1263 static TReturn _ss_barring_set( CoreObject *o, UserRequest *ur, enum telephony_ss_opcode op )
1264 {
1265         struct treq_ss_barring *barring = 0;
1266         TcorePlugin *p = 0;
1267         struct ss_confirm_info *user_data = 0;
1268         gboolean ret = FALSE;
1269         char passwd[MAX_SS_BARRING_PASSWORD_LEN+1];
1270
1271         struct ATReqMetaInfo metainfo;
1272         int info_len =0;
1273         char* cmd_str = NULL;
1274         int opco;
1275         int classx;
1276         char* facility = NULL;
1277
1278
1279         barring = (struct treq_ss_barring*)tcore_user_request_ref_data( ur, 0 );
1280         p               = tcore_object_ref_plugin( o );
1281
1282         memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
1283         metainfo.type = NO_RESULT;
1284         metainfo.responsePrefix[0] ='\0';
1285         info_len = sizeof(struct ATReqMetaInfo);
1286
1287         tcore_user_request_set_metainfo(ur, info_len, &metainfo);
1288
1289
1290         switch(op){
1291                 case TIZEN_SS_OPCO_ACTIVATE:
1292                         opco = 1;
1293                 break;
1294                 case TIZEN_SS_OPCO_DEACTIVATE:
1295                         opco = 0;
1296                 break;
1297                 default:
1298                         dbg("unsupported opco : %d", op);
1299                 return TCORE_RETURN_FAILURE;
1300         }
1301
1302
1303         switch(barring->mode){
1304                 case SS_BARR_MODE_BAOC:
1305                         facility = "AO";
1306                 break;
1307                 case SS_BARR_MODE_BOIC:
1308                         facility = "OI";
1309                 break;
1310                 case SS_BARR_MODE_BOIC_NOT_HC:
1311                         facility = "OX";
1312                 break;
1313                 case SS_BARR_MODE_BAIC:
1314                         facility = "AI";
1315                 break;
1316                 case SS_BARR_MODE_BIC_ROAM:
1317                         facility = "IR";
1318                 break;
1319                 case SS_BARR_MODE_AB:
1320                         facility = "AB";
1321                 break;
1322                 case SS_BARR_MODE_AOB:
1323                         facility = "AG";
1324                 break;
1325                 case SS_BARR_MODE_AIB:
1326                         facility = "AC";
1327                 break;
1328                 case SS_BARR_MODE_BIC_NOT_SIM:
1329                         facility = "NS";
1330                 break;
1331                 default:
1332                         dbg("unspported mode %d", barring->mode);
1333                 return TCORE_RETURN_FAILURE;
1334         }
1335
1336         switch(barring->class)
1337         {
1338                 case SS_CLASS_ALL_TELE:
1339                         classx =7;
1340                 break;
1341                 case SS_CLASS_VOICE:
1342                         classx =1;
1343                 break;
1344                 case SS_CLASS_ALL_DATA_TELE:
1345                         classx =2;
1346                 break;
1347                 case SS_CLASS_FAX:
1348                         classx =4;
1349                 break;
1350                 case SS_CLASS_SMS:
1351                         classx = 8;
1352                 break;
1353                 case SS_CLASS_ALL_CS_SYNC:
1354                         classx = 16;
1355                 break;
1356
1357                 default:
1358                         classx =7;
1359                         dbg("unsupported class %d. set to default : 7", barring->class);
1360                 break;
1361         }
1362
1363         // null-ended pwd handling added - unexpected  0x11 value observed in req string
1364         memcpy(passwd, barring->password, MAX_SS_BARRING_PASSWORD_LEN);
1365         passwd[MAX_SS_BARRING_PASSWORD_LEN]='\0';
1366
1367
1368         cmd_str = g_strdup_printf("AT+CLCK=\"%s\",%d,\"%s\",%d%s", facility, opco, passwd, classx,"\r");
1369         dbg("request command : %s", cmd_str);
1370
1371         user_data = g_new0( struct ss_confirm_info, 1 );
1372
1373         if ( op == TIZEN_SS_OPCO_ACTIVATE) {
1374                 user_data->resp = TRESP_SS_BARRING_ACTIVATE;
1375
1376         } else if ( op == TIZEN_SS_OPCO_DEACTIVATE) {
1377                 user_data->resp = TRESP_SS_BARRING_DEACTIVATE;
1378
1379         } else {
1380                 dbg("[ error ] wrong ss opco ( 0x%x )", op );
1381                 return TCORE_RETURN_FAILURE;
1382         }
1383
1384         user_data->flavor_type = (int)(barring->mode);
1385         user_data->class = barring->class;
1386
1387         ret = _ss_request_message( o, ur, cmd_str, strlen(cmd_str), on_response_ss_barring_set, user_data );
1388
1389         g_free(cmd_str);
1390
1391         if ( !ret )
1392                 return TCORE_RETURN_FAILURE;
1393
1394         return TCORE_RETURN_SUCCESS;
1395 }
1396
1397 static TReturn _ss_barring_get( CoreObject *o,
1398                                                                 UserRequest *ur,
1399                                                                 enum telephony_ss_class class,
1400                                                                 enum telephony_ss_barring_mode mode,
1401                                                                 enum tcore_response_command resp )
1402 {
1403         TcorePlugin *p = 0;
1404         struct ss_confirm_info *user_data = 0;
1405         gboolean ret = FALSE;
1406
1407         struct ATReqMetaInfo metainfo;
1408         int info_len =0;
1409         char* cmd_str = NULL;
1410         int opco, classx;
1411         char* facility = NULL;
1412
1413         p       = tcore_object_ref_plugin( o );
1414
1415         memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
1416         metainfo.type = MULTILINE;
1417         memcpy(metainfo.responsePrefix,"+CLCK:",strlen("+CLCK:"));
1418         info_len = sizeof(struct ATReqMetaInfo);
1419
1420         tcore_user_request_set_metainfo(ur, info_len, &metainfo);
1421
1422         //query status - opco is fixed to 2
1423         opco = 2;
1424
1425         //barring mode
1426         switch(mode){
1427                 case SS_BARR_MODE_BAOC:
1428                         facility = "AO";
1429                 break;
1430                 case SS_BARR_MODE_BOIC:
1431                         facility = "OI";
1432                 break;
1433                 case SS_BARR_MODE_BOIC_NOT_HC:
1434                         facility = "OX";
1435                 break;
1436                 case SS_BARR_MODE_BAIC:
1437                         facility = "AI";
1438                 break;
1439                 case SS_BARR_MODE_BIC_ROAM:
1440                         facility = "IR";
1441                 break;
1442                 case SS_BARR_MODE_AB:
1443                         facility = "AB";
1444                 break;
1445                 case SS_BARR_MODE_AOB:
1446                         facility = "AG";
1447                 break;
1448                 case SS_BARR_MODE_AIB:
1449                         facility = "AC";
1450                 break;
1451                 case SS_BARR_MODE_BIC_NOT_SIM:
1452                         facility = "NS";
1453                 break;
1454                 default:
1455                         dbg("unspported mode %d", mode);
1456                 return TCORE_RETURN_FAILURE;
1457         }
1458
1459         switch(class)
1460         {
1461                 case SS_CLASS_ALL_TELE:
1462                         classx =7;
1463                 break;
1464                 case SS_CLASS_VOICE:
1465                         classx =1;
1466                 break;
1467                 case SS_CLASS_ALL_DATA_TELE:
1468                         classx =2;
1469                 break;
1470                 case SS_CLASS_FAX:
1471                         classx =4;
1472                 break;
1473                 case SS_CLASS_SMS:
1474                         classx = 8;
1475                 break;
1476                 case SS_CLASS_ALL_CS_SYNC:
1477                         classx = 16;
1478                 break;
1479
1480                 default:
1481                         classx =7;
1482                         dbg("unsupported class %d. set to default : 7", class);
1483                 break;
1484         }
1485
1486
1487         if(classx ==7)
1488         cmd_str = g_strdup_printf("AT+CLCK=\"%s\",%d%s", facility, opco,"\r");
1489         else
1490                 cmd_str = g_strdup_printf("AT+CLCK=\"%s\",%d,,%d%s", facility, opco,classx,"\r");
1491
1492         dbg("request command : %s", cmd_str);
1493
1494         user_data = g_new0( struct ss_confirm_info, 1 );
1495         user_data->resp = resp;
1496
1497         user_data->flavor_type = (int)(mode);
1498         user_data->class = class;
1499
1500         ret = _ss_request_message( o, ur, cmd_str, strlen(cmd_str), on_response_ss_barring_get, user_data );
1501
1502         g_free(cmd_str);
1503
1504         if ( !ret )
1505                 return TCORE_RETURN_FAILURE;
1506
1507         return TCORE_RETURN_SUCCESS;
1508 }
1509
1510 static TReturn s_ss_barring_activate( CoreObject *o, UserRequest *ur )
1511 {
1512         return _ss_barring_set( o, ur, TIZEN_SS_OPCO_ACTIVATE );
1513 }
1514
1515 static TReturn s_ss_barring_deactivate( CoreObject *o, UserRequest *ur )
1516 {
1517         return _ss_barring_set( o, ur, TIZEN_SS_OPCO_DEACTIVATE );
1518 }
1519
1520 static TReturn s_ss_barring_change_password( CoreObject *o, UserRequest *ur )
1521 {
1522         TcorePlugin *p = 0;
1523         struct treq_ss_barring_change_password *barring = 0;
1524
1525         struct ss_confirm_info *user_data = 0;
1526
1527         gboolean ret = FALSE;
1528
1529 //      struct ATReqMetaInfo metainfo;
1530 //      int info_len =0;
1531         char* cmd_str = NULL;
1532
1533         p               = tcore_object_ref_plugin( o );
1534         barring = (struct treq_ss_barring_change_password*)tcore_user_request_ref_data( ur, 0 );
1535
1536
1537         cmd_str = g_strdup_printf("AT+CPWD=\"%s\",\"%s\",\"%s\"%s", "AB", barring->password_old, barring->password_new,"\r");
1538         dbg("request command : %s", cmd_str);
1539
1540
1541         user_data = g_new0( struct ss_confirm_info, 1 );
1542         user_data->resp = TRESP_SS_BARRING_CHANGE_PASSWORD;
1543
1544         ret = _ss_request_message( o, ur, cmd_str, strlen(cmd_str), on_response_ss_barring_change_pwd, user_data );
1545
1546         g_free(cmd_str);
1547         if ( !ret )
1548                 return TCORE_RETURN_FAILURE;
1549
1550         return TCORE_RETURN_SUCCESS;
1551 }
1552
1553 static TReturn s_ss_barring_get_status( CoreObject *o, UserRequest *ur )
1554 {
1555         struct treq_ss_barring *barring = 0;
1556         barring = (struct treq_ss_barring*)tcore_user_request_ref_data( ur, 0 );
1557
1558         return _ss_barring_get( o, ur, barring->class, barring->mode, TRESP_SS_BARRING_GET_STATUS );
1559 }
1560
1561 static TReturn _ss_forwarding_set( CoreObject *o, UserRequest *ur, enum telephony_ss_opcode op )
1562 {
1563         TcorePlugin *p = 0;
1564         struct treq_ss_forwarding *forwarding = 0;
1565
1566         struct ss_confirm_info *user_data = 0;
1567
1568         gboolean ret = FALSE;
1569         int len = 0;
1570
1571         struct ATReqMetaInfo metainfo;
1572         int info_len =0;
1573         char* cmd_str = NULL;
1574         char* tmp_str = NULL;
1575         int reason=0,mode=0,num_type=0, classx=0,time=0;
1576         gboolean valid_num = FALSE;
1577
1578         dbg("_ss_forwarding_set with opco %d ", op);
1579
1580
1581         forwarding = (struct treq_ss_forwarding*) tcore_user_request_ref_data( ur, 0 );
1582         p               = tcore_object_ref_plugin( o );
1583
1584         memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
1585         metainfo.type = NO_RESULT;
1586         metainfo.responsePrefix[0] ='\0';
1587         info_len = sizeof(struct ATReqMetaInfo);
1588
1589         tcore_user_request_set_metainfo(ur, info_len, &metainfo);
1590
1591         switch(forwarding->mode)
1592         {
1593                 case SS_CF_MODE_CFU:
1594                         reason =0;
1595                         break;
1596                 case SS_CF_MODE_CFB:
1597                         reason =1;
1598                         break;
1599                 case SS_CF_MODE_CFNRy:
1600                         reason =2;
1601                         break;
1602                 case SS_CF_MODE_CFNRc:
1603                         reason =3;
1604                         break;
1605                 case SS_CF_MODE_CF_ALL:
1606                         reason = 4;
1607                 break;
1608                 case SS_CF_MODE_CFC:
1609                         reason = 5;
1610                 break;
1611
1612                 default:
1613                         dbg("unsupported reason : %d");
1614                         break;
1615         }
1616
1617         switch(op){
1618                 case TIZEN_SS_OPCO_DEACTIVATE:
1619                         mode = 0;
1620                 break;
1621                 case TIZEN_SS_OPCO_ACTIVATE:
1622                         mode = 1;
1623                 break;
1624                 case TIZEN_SS_OPCO_REG:
1625                         mode = 3;
1626                 break;
1627                 case TIZEN_SS_OPCO_DEREG:
1628                         mode = 4;
1629                 break;
1630
1631                 default:
1632                         dbg("unsupported opco : %d", op);
1633                         return TCORE_RETURN_FAILURE;
1634         }
1635
1636
1637 // class
1638         switch(forwarding->class)
1639         {
1640                 case SS_CLASS_ALL_TELE:
1641                         classx =7;
1642                 break;
1643                 case SS_CLASS_VOICE:
1644                         classx =1;
1645                 break;
1646                 case SS_CLASS_ALL_DATA_TELE:
1647                         classx =2;
1648                 break;
1649                 case SS_CLASS_FAX:
1650                         classx =4;
1651                 break;
1652                 case SS_CLASS_SMS:
1653                         classx = 8;
1654                 break;
1655                 case SS_CLASS_ALL_CS_SYNC:
1656                         classx = 16;
1657                 break;
1658
1659                 default:
1660                         classx =7;
1661                         dbg("unsupported class %d. set to default : 7", forwarding->class);
1662                 break;
1663         }
1664
1665 //number
1666         len = strlen(forwarding->number);
1667         if ( len > 0 ){
1668                 valid_num = TRUE;
1669                 if ( forwarding->number[0] == '+' )
1670                         num_type = ((TIZEN_NUM_TYPE_INTERNATIONAL << 4)|TIZEN_NUM_PLAN_ISDN);
1671                 else
1672                         num_type = 0;
1673         }
1674         user_data = g_new0( struct ss_confirm_info, 1 );
1675
1676         switch ( op ) {
1677                 case TIZEN_SS_OPCO_REG:
1678                         user_data->resp = TRESP_SS_FORWARDING_REGISTER;
1679                         break;
1680                 case TIZEN_SS_OPCO_DEREG:
1681                         user_data->resp = TRESP_SS_FORWARDING_DEREGISTER;
1682                         break;
1683                 case TIZEN_SS_OPCO_ACTIVATE:
1684                         user_data->resp = TRESP_SS_FORWARDING_ACTIVATE;
1685                         break;
1686                 case TIZEN_SS_OPCO_DEACTIVATE:
1687                         user_data->resp = TRESP_SS_FORWARDING_DEACTIVATE;
1688                         break;
1689                 default:
1690                         dbg("[ error ] unknown op ( 0x%x )", op );
1691                         break;
1692         }
1693
1694         if(op == TIZEN_SS_OPCO_REG)
1695                 tmp_str = g_strdup_printf("AT+CCFC=%d,%d,\"%s\",%d,%d", reason, mode, forwarding->number, num_type, classx);
1696         else// other opcode does not need num field
1697                 tmp_str = g_strdup_printf("AT+CCFC=%d,%d,,,%d", reason, mode, classx);
1698
1699         if(forwarding->mode == SS_CF_MODE_CFNRy){
1700                 //add time info to 'no reply' case
1701                 time = (int)(forwarding->time);
1702                 cmd_str = g_strdup_printf("%s,,,%d%s", tmp_str,time,"\r");
1703         }
1704         else    {
1705                 cmd_str = g_strdup_printf("%s%s", tmp_str,"\r");
1706         }
1707
1708         dbg("request command : %s", cmd_str);
1709
1710         user_data->flavor_type = forwarding->mode;
1711         user_data->class = forwarding->class;
1712
1713         ret = _ss_request_message( o, ur, cmd_str, strlen(cmd_str), on_response_ss_forwarding_set, user_data );
1714         g_free(tmp_str);
1715         g_free(cmd_str);
1716
1717         if ( !ret )
1718                 return TCORE_RETURN_FAILURE;
1719
1720         return TCORE_RETURN_SUCCESS;
1721 }
1722
1723 static TReturn _ss_forwarding_get(      CoreObject *o,
1724                                                                         UserRequest *ur,
1725                                                                         enum telephony_ss_class class,
1726                                                                         enum telephony_ss_forwarding_mode type,
1727                                                                         enum tcore_response_command resp )
1728 {
1729         TcorePlugin *p = 0;
1730         struct ss_confirm_info *user_data = 0;
1731
1732         gboolean ret = FALSE;
1733 //      int len = 0;
1734
1735         struct ATReqMetaInfo metainfo;
1736         int info_len=0, reason=0, mode=0, classx =0;
1737         char* cmd_str = NULL;
1738
1739         p       = tcore_object_ref_plugin( o );
1740
1741         memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
1742         metainfo.type = MULTILINE;
1743         memcpy(metainfo.responsePrefix,"+CCFC:",strlen("+CCFC:"));
1744         info_len = sizeof(struct ATReqMetaInfo);
1745
1746         tcore_user_request_set_metainfo(ur, info_len, &metainfo);
1747
1748         switch(type)
1749         {
1750                 case SS_CF_MODE_CFU:
1751                         reason =0;
1752                 break;
1753                 case SS_CF_MODE_CFB:
1754                         reason =1;
1755                 break;
1756                 case SS_CF_MODE_CFNRy:
1757                         reason =2;
1758                 break;
1759                 case SS_CF_MODE_CFNRc:
1760                         reason =3;
1761                 break;
1762                 case SS_CF_MODE_CF_ALL:
1763                         reason = 4;
1764                 break;
1765                 case SS_CF_MODE_CFC:
1766                         reason = 5;
1767                 break;
1768
1769                 default:
1770                         dbg("unsupported reason : %d");
1771                 break;
1772         }
1773
1774         switch(class)
1775         {
1776                 case SS_CLASS_ALL_TELE:
1777                         classx =7;
1778                 break;
1779                 case SS_CLASS_VOICE:
1780                         classx =1;
1781                 break;
1782                 case SS_CLASS_ALL_DATA_TELE:
1783                         classx =2;
1784                 break;
1785                 case SS_CLASS_FAX:
1786                         classx =4;
1787                 break;
1788                 case SS_CLASS_SMS:
1789                         classx = 8;
1790                 break;
1791                 case SS_CLASS_ALL_CS_SYNC:
1792                         classx = 16;
1793                 break;
1794                 default:
1795                         classx =7;
1796                         dbg("unsupported class %d. set to default : 7", class);
1797                 break;
1798         }
1799
1800         //query status - mode set to 2
1801         mode =2;
1802
1803         user_data = g_new0( struct ss_confirm_info, 1 );
1804         user_data->resp = resp;
1805
1806         user_data->class = class;
1807         user_data->flavor_type = type;
1808
1809         if(classx ==7)
1810                 cmd_str = g_strdup_printf("AT+CCFC=%d,%d%s", reason, mode,"\r");
1811         else
1812                 cmd_str = g_strdup_printf("AT+CCFC=%d,%d,,,%d%s", reason, mode,classx,"\r");
1813
1814         dbg("request command : %s", cmd_str);
1815         ret = _ss_request_message( o, ur, cmd_str, strlen(cmd_str), on_response_ss_forwarding_get, user_data );
1816         g_free(cmd_str);
1817
1818         if ( !ret )
1819                 return TCORE_RETURN_FAILURE;
1820
1821         return TCORE_RETURN_SUCCESS;
1822 }
1823
1824 static TReturn s_ss_forwarding_activate( CoreObject *o, UserRequest *ur )
1825 {
1826         return _ss_forwarding_set( o, ur, TIZEN_SS_OPCO_ACTIVATE );
1827 }
1828
1829 static TReturn s_ss_forwarding_deactivate( CoreObject *o, UserRequest *ur )
1830 {
1831         return _ss_forwarding_set( o, ur, TIZEN_SS_OPCO_DEACTIVATE );
1832 }
1833
1834 static TReturn s_ss_forwarding_register( CoreObject *o, UserRequest *ur )
1835 {
1836         return _ss_forwarding_set( o, ur, TIZEN_SS_OPCO_REG );
1837 }
1838
1839 static TReturn s_ss_forwarding_deregister( CoreObject *o, UserRequest *ur )
1840 {
1841         return _ss_forwarding_set( o, ur, TIZEN_SS_OPCO_DEREG );
1842 }
1843
1844 static TReturn s_ss_forwarding_get_status( CoreObject *o, UserRequest *ur )
1845 {
1846         struct treq_ss_forwarding *forwarding = 0;
1847         forwarding = (struct treq_ss_forwarding*)tcore_user_request_ref_data( ur, 0 );
1848
1849         return _ss_forwarding_get( o, ur, forwarding->class, forwarding->mode, TRESP_SS_FORWARDING_GET_STATUS );
1850 }
1851
1852 static TReturn _ss_waiting_set( CoreObject *o, UserRequest *ur, enum telephony_ss_opcode opco )
1853 {
1854         TcorePlugin *p = 0;
1855         struct treq_ss_waiting *waiting = 0;
1856
1857         struct ss_confirm_info *user_data = 0;
1858
1859         gboolean ret = FALSE;
1860         int mode=0, classx=0;
1861         char* cmd_str;
1862         struct ATReqMetaInfo metainfo;
1863
1864 //set metainfo
1865         memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
1866         metainfo.type = NO_RESULT;
1867         metainfo.responsePrefix[0] ='\0';
1868
1869         tcore_user_request_set_metainfo(ur, sizeof(struct ATReqMetaInfo), &metainfo);
1870
1871         p       = tcore_object_ref_plugin( o );
1872
1873         waiting = (struct treq_ss_waiting*) tcore_user_request_ref_data( ur, 0 );
1874
1875         user_data = g_new0( struct ss_confirm_info, 1 );
1876
1877         if ( opco == TIZEN_SS_OPCO_ACTIVATE ){
1878                 user_data->resp = TRESP_SS_WAITING_ACTIVATE;
1879                 mode = 1;//enable
1880         }
1881         else if ( opco == TIZEN_SS_OPCO_DEACTIVATE ){
1882                 user_data->resp = TRESP_SS_WAITING_DEACTIVATE;
1883                 mode =0; //diable
1884         }
1885         else
1886                 dbg("[ error ] unknown ss mode (0x%x)", opco);
1887
1888         switch(waiting->class)
1889         {
1890                 case SS_CLASS_ALL_TELE:
1891                         classx =7;
1892                         break;
1893                 case SS_CLASS_VOICE:
1894                         classx =1;
1895                         break;
1896                 case SS_CLASS_ALL_DATA_TELE:
1897                         classx =2;
1898                         break;
1899                 case SS_CLASS_FAX:
1900                         classx =4;
1901                         break;
1902                 case SS_CLASS_SMS:
1903                         classx = 8;
1904                         break;
1905
1906                 default:
1907                         classx =7;
1908                         dbg("unsupported class %d. set to default : 7", waiting->class);
1909                         break;
1910         }
1911
1912
1913 user_data->class = waiting->class;
1914         user_data->flavor_type = (int)opco;
1915
1916         cmd_str = g_strdup_printf("AT+CCWA=1,%d,%d%s", mode, classx,"\r"); //always enable +CCWA: unsolicited cmd
1917         dbg("request command : %s",cmd_str);
1918
1919         ret = _ss_request_message( o, ur, cmd_str, strlen(cmd_str), on_response_ss_waiting_set, user_data );
1920
1921         g_free(cmd_str);
1922         if ( !ret )
1923                 return TCORE_RETURN_FAILURE;
1924
1925         return TCORE_RETURN_SUCCESS;
1926 }
1927
1928 static TReturn _ss_waiting_get( CoreObject *o,
1929                                                                 UserRequest *ur,
1930                                                                 enum telephony_ss_class class,
1931                                                                 enum tcore_response_command resp )
1932 {
1933         TcorePlugin *p = 0;
1934
1935         struct ss_confirm_info *user_data = 0;
1936
1937         gboolean ret = FALSE;
1938         int classx, info_len=0;//mode,
1939         char* cmd_str;
1940         struct ATReqMetaInfo metainfo;
1941
1942 //set metainfo
1943         memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
1944         metainfo.type = MULTILINE;
1945         memcpy(metainfo.responsePrefix,"+CCWA:",strlen("+CCWA:"));
1946         info_len = sizeof(struct ATReqMetaInfo);
1947
1948         tcore_user_request_set_metainfo(ur, sizeof(struct ATReqMetaInfo), &metainfo);
1949
1950         p       = tcore_object_ref_plugin( o );
1951
1952         switch(class)
1953         {
1954                 case SS_CLASS_ALL_TELE:
1955                         classx =7;
1956                 break;
1957                 case SS_CLASS_VOICE:
1958                         classx =1;
1959                 break;
1960                 case SS_CLASS_ALL_DATA_TELE:
1961                         classx =2;
1962                 break;
1963                 case SS_CLASS_FAX:
1964                         classx =4;
1965                 break;
1966                 case SS_CLASS_SMS:
1967                         classx = 8;
1968                 break;
1969
1970                 default:
1971                         classx =7;
1972                         dbg("unsupported class %d. set to default : 7", class);
1973                 break;
1974         }
1975
1976         dbg("allocating user data");
1977         user_data = g_new0( struct ss_confirm_info, 1 );
1978         user_data->resp = resp;
1979         user_data->class = class;
1980
1981         cmd_str = g_strdup_printf("AT+CCWA=1,2,%d%s", classx,"\r"); //always enable +CCWA: unsolicited cmd , mode is fixed to 2(query status)
1982         dbg("request cmd : %s", cmd_str);
1983
1984         ret = _ss_request_message( o, ur, cmd_str, strlen(cmd_str), on_response_ss_waiting_get, user_data );
1985
1986         g_free(cmd_str);
1987
1988         if ( !ret )
1989                 return TCORE_RETURN_FAILURE;
1990
1991         return TCORE_RETURN_SUCCESS;
1992 }
1993
1994 static TReturn s_ss_waiting_activate( CoreObject *o, UserRequest *ur )
1995 {
1996         return _ss_waiting_set( o, ur, TIZEN_SS_OPCO_ACTIVATE );
1997 }
1998
1999 static TReturn s_ss_waiting_deactivate( CoreObject *o, UserRequest *ur )
2000 {
2001         return _ss_waiting_set( o, ur, TIZEN_SS_OPCO_DEACTIVATE );
2002 }
2003
2004 static TReturn s_ss_waiting_get_status( CoreObject *o, UserRequest *ur )
2005 {
2006         struct treq_ss_waiting *waiting = 0;
2007         waiting = (struct treq_ss_waiting*)tcore_user_request_ref_data( ur, 0 );
2008
2009         return _ss_waiting_get( o, ur, waiting->class, TRESP_SS_WAITING_GET_STATUS );
2010 }
2011
2012 static TReturn s_ss_cli_activate( CoreObject *o, UserRequest *ur )
2013 {
2014         return TCORE_RETURN_SUCCESS;
2015 }
2016
2017 static TReturn s_ss_cli_deactivate( CoreObject *o, UserRequest *ur )
2018 {
2019         return TCORE_RETURN_SUCCESS;
2020 }
2021
2022 static TReturn s_ss_cli_get_status( CoreObject *o, UserRequest *ur )
2023 {
2024         TcorePlugin *p = 0;
2025
2026         struct treq_ss_cli *cli = 0;
2027         gboolean ret = FALSE;
2028         char *cmd_prefix = NULL, *rsp_prefix = NULL, *cmd_str = NULL;
2029         struct ATReqMetaInfo metainfo;
2030         enum  telephony_ss_cli_type *user_data = 0;
2031
2032         int info_len =0;
2033
2034         p = tcore_object_ref_plugin(o);
2035
2036         cli = (struct treq_ss_cli*)tcore_user_request_ref_data( ur, 0 );
2037
2038         switch(cli->type){
2039                 case SS_CLI_TYPE_CLIP:
2040                         cmd_prefix = "+CLIP";
2041                         rsp_prefix = "+CLIP:";
2042                 break;
2043
2044                 case SS_CLI_TYPE_CLIR:
2045                         cmd_prefix = "+CLIR";
2046                         rsp_prefix = "+CLIR:";
2047                 break;
2048
2049                 case SS_CLI_TYPE_COLP:
2050                         cmd_prefix = "+COLP";
2051                         rsp_prefix = "+COLP:";
2052                 break;
2053
2054                 case SS_CLI_TYPE_CDIP:
2055                         cmd_prefix = "+CDIP";
2056                         rsp_prefix = "+CDIP:";
2057                 break;
2058
2059                 default:
2060                         dbg("unsupported cli_type : %d", cli->type);
2061                         return TCORE_RETURN_FAILURE;
2062                 break;
2063         }
2064
2065         dbg("cmd_prefix : %s",cmd_prefix);
2066
2067 //set metaInfo
2068         memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
2069         metainfo.type = SINGLELINE;
2070         memcpy(metainfo.responsePrefix,rsp_prefix,strlen(rsp_prefix));
2071         info_len = sizeof(struct ATReqMetaInfo);
2072
2073         tcore_user_request_set_metainfo(ur, sizeof(struct ATReqMetaInfo), &metainfo);
2074
2075         //make cmd string
2076
2077         cmd_str = g_strdup_printf("AT%s?%s", cmd_prefix, "\r");
2078         dbg("request cmd : %s", cmd_str);
2079
2080         // make userinfo for callback
2081         user_data = g_new0( enum telephony_ss_cli_type, 1 );
2082         *user_data = cli->type;
2083
2084         ret = _ss_request_message( o, ur, cmd_str, strlen(cmd_str), on_response_ss_waiting_get, user_data );
2085
2086         g_free(cmd_str);
2087
2088         if ( !ret )
2089                 return TCORE_RETURN_FAILURE;
2090
2091         return TCORE_RETURN_SUCCESS;
2092 }
2093
2094 static TReturn s_ss_send_ussd( CoreObject *o, UserRequest *ur )
2095 {
2096         TcorePlugin *p = 0;
2097         UssdSession *ussd_s = 0;
2098
2099         struct treq_ss_ussd *ussd = 0;
2100         struct ss_confirm_info *user_data = 0;
2101
2102         gboolean ret = FALSE;
2103         char* cmd_str;
2104         struct ATReqMetaInfo metainfo;
2105
2106         //set metainfo
2107         memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
2108         metainfo.type = NO_RESULT;
2109         metainfo.responsePrefix[0] ='\0';
2110         tcore_user_request_set_metainfo(ur, sizeof(struct ATReqMetaInfo), &metainfo);
2111
2112         p = tcore_object_ref_plugin(o);
2113         ussd = (struct treq_ss_ussd*)tcore_user_request_ref_data( ur, 0 );
2114
2115         cmd_str = g_strdup_printf("AT+CUSD=1,\"%s\",%d%s", ussd->str, 0x0f,"\r"); //always enable +CUSD: unsolicited cmd. set to dcs to 0x0f. only supports HEX type
2116         dbg("request command : %s",cmd_str);
2117
2118
2119         user_data = g_new0( struct ss_confirm_info, 1 );
2120         user_data->resp = TRESP_SS_SEND_USSD;
2121
2122         ussd_s = tcore_ss_ussd_get_session( o );
2123         if ( !ussd_s ) {
2124                 tcore_ss_ussd_create_session( o, (enum tcore_ss_ussd_type)ussd->type, (void*)tcore_user_request_ref(ur), 0 );
2125         } else {
2126
2127                 if ( ussd->type == SS_USSD_TYPE_USER_INITIATED ) {
2128                         dbg("[ error ] ussd session is already exist");
2129
2130                         g_free( user_data );
2131                         return TCORE_RETURN_FAILURE;
2132                 }
2133
2134                 tcore_ss_ussd_set_session_type( ussd_s, (enum tcore_ss_ussd_type)ussd->type);
2135         }
2136
2137         ret = _ss_request_message( o, ur, cmd_str, strlen(cmd_str), on_confirmation_ss_ussd, user_data );
2138
2139         if ( !ret )
2140                 return TCORE_RETURN_FAILURE;
2141
2142
2143         return TCORE_RETURN_SUCCESS;
2144 }
2145
2146 static TReturn s_ss_set_aoc( CoreObject *o, UserRequest *ur )
2147 {
2148         dbg("[ error ] unsupported function");
2149         return TCORE_RETURN_SUCCESS;
2150 }
2151
2152 static TReturn s_ss_get_aoc( CoreObject *o, UserRequest *ur )
2153 {
2154         dbg("[ error ] unsupported function");
2155         return TCORE_RETURN_SUCCESS;
2156 }
2157
2158 static struct tcore_call_control_operations call_ops = {
2159         .answer_hold_and_accept = s_ss_manage_call_2_send,
2160         .answer_replace                 = s_ss_manage_call_1_send,
2161         .answer_reject                  = s_ss_manage_call_0_send,
2162         .end_specific                   = s_ss_manage_call_1x_send,
2163         .end_all_active                 = s_ss_manage_call_1_send,
2164         .end_all_held                   = s_ss_manage_call_0_send,
2165         .active                                 = s_ss_manage_call_2_send,
2166         .hold                                   = s_ss_manage_call_2_send,
2167         .swap                                   = s_ss_manage_call_2_send,
2168         .join                                   = s_ss_manage_call_3_send,
2169         .split                                  = s_ss_manage_call_2x_send,
2170         .transfer                               = s_ss_manage_call_4_send,
2171         .deflect                                = s_ss_manage_call_4dn_send,
2172 };
2173
2174 static TReturn s_ss_manage_call_0_send( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data )
2175 {
2176         TcorePlugin *p = NULL;
2177         TcoreHal *h = NULL;
2178         TcorePending *pending = NULL;
2179         char*                                           cmd_str = NULL;
2180         struct ATReqMetaInfo metainfo;
2181         int info_len =0;
2182
2183         p = tcore_object_ref_plugin(o);
2184         h = tcore_object_get_hal(o);
2185
2186         memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
2187         metainfo.type = NO_RESULT;
2188         metainfo.responsePrefix[0] ='\0';
2189         info_len = sizeof(struct ATReqMetaInfo);
2190
2191         tcore_user_request_set_metainfo(ur, info_len, &metainfo);
2192
2193         cmd_str = g_strdup_printf("%s%s", "AT+CHLD=0", "\r");
2194         dbg("cmd : %s, prefix(if any) : %s, cmd_len : %d",cmd_str, "N/A", strlen(cmd_str));
2195
2196         pending = tcore_pending_new(o, ID_RESERVED_AT);
2197         tcore_pending_set_request_data(pending, strlen(cmd_str), cmd_str);
2198         g_free(cmd_str);
2199         tcore_pending_set_timeout(pending, 0);
2200         tcore_pending_set_response_callback(pending, (TcorePendingResponseCallback)cb, user_data);
2201         tcore_pending_link_user_request(pending, ur);
2202         tcore_pending_set_priority(pending, TCORE_PENDING_PRIORITY_DEFAULT);
2203
2204         tcore_pending_set_send_callback(pending, on_confirmation_call_control_ss_message_send, NULL);
2205
2206
2207         tcore_hal_send_request(h, pending);
2208
2209         return TCORE_RETURN_SUCCESS;
2210 }
2211
2212 static TReturn s_ss_manage_call_1_send( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data )
2213 {
2214         TcorePlugin *p = NULL;
2215         TcoreHal *h = NULL;
2216         TcorePending *pending = NULL;
2217         char*                                           cmd_str = NULL;
2218         struct ATReqMetaInfo metainfo;
2219         int info_len =0;
2220
2221         p = tcore_object_ref_plugin(o);
2222         h = tcore_object_get_hal(o);
2223
2224         memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
2225         metainfo.type = NO_RESULT;
2226         metainfo.responsePrefix[0] ='\0';
2227         info_len = sizeof(struct ATReqMetaInfo);
2228
2229         tcore_user_request_set_metainfo(ur, info_len, &metainfo);
2230
2231         cmd_str = g_strdup_printf("%s%s", "AT+CHLD=1", "\r");
2232         dbg("cmd : %s, prefix(if any) : %s, cmd_len : %d",cmd_str, "N/A", strlen(cmd_str));
2233
2234         pending = tcore_pending_new(o, ID_RESERVED_AT);
2235         tcore_pending_set_request_data(pending, strlen(cmd_str), cmd_str);
2236         g_free(cmd_str);
2237         tcore_pending_set_timeout(pending, 0);
2238         tcore_pending_set_response_callback(pending, (TcorePendingResponseCallback)cb, user_data);
2239         tcore_pending_link_user_request(pending, ur);
2240         tcore_pending_set_priority(pending, TCORE_PENDING_PRIORITY_DEFAULT);
2241
2242         tcore_pending_set_send_callback(pending, on_confirmation_call_control_ss_message_send, NULL);
2243
2244
2245         tcore_hal_send_request(h, pending);
2246
2247         return TCORE_RETURN_SUCCESS;
2248 }
2249
2250 static TReturn s_ss_manage_call_1x_send( CoreObject* o, UserRequest* ur, const int id, ConfirmCallback cb, void* user_data )
2251 {
2252         TcorePlugin *p = NULL;
2253         TcoreHal *h = NULL;
2254         TcorePending *pending = NULL;
2255         char*                                           cmd_str = NULL;
2256         struct ATReqMetaInfo metainfo;
2257         int info_len =0;
2258
2259         p = tcore_object_ref_plugin(o);
2260         h = tcore_object_get_hal(o);
2261
2262         memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
2263         metainfo.type = NO_RESULT;
2264         metainfo.responsePrefix[0] ='\0';
2265         info_len = sizeof(struct ATReqMetaInfo);
2266
2267         tcore_user_request_set_metainfo(ur, info_len, &metainfo);
2268
2269         cmd_str = g_strdup_printf("%s%d%s", "AT+CHLD=1", id,"\r");
2270         dbg("cmd : %s, prefix(if any) : %s, cmd_len : %d",cmd_str, "N/A", strlen(cmd_str));
2271
2272         pending = tcore_pending_new(o, ID_RESERVED_AT);
2273         tcore_pending_set_request_data(pending, strlen(cmd_str), cmd_str);
2274         g_free(cmd_str);
2275         tcore_pending_set_timeout(pending, 0);
2276         tcore_pending_set_response_callback(pending, (TcorePendingResponseCallback)cb, user_data);
2277         tcore_pending_link_user_request(pending, ur);
2278         tcore_pending_set_priority(pending, TCORE_PENDING_PRIORITY_DEFAULT);
2279
2280         tcore_pending_set_send_callback(pending, on_confirmation_call_control_ss_message_send, NULL);
2281
2282
2283         tcore_hal_send_request(h, pending);
2284
2285         return TCORE_RETURN_SUCCESS;
2286 }
2287
2288 static TReturn s_ss_manage_call_2_send( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data )
2289 {
2290         TcorePlugin *p = NULL;
2291         TcoreHal *h = NULL;
2292         TcorePending *pending = NULL;
2293         char*                                           cmd_str = NULL;
2294         struct ATReqMetaInfo metainfo;
2295         int info_len =0;
2296
2297         p = tcore_object_ref_plugin(o);
2298         h = tcore_object_get_hal(o);
2299
2300         memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
2301         metainfo.type = NO_RESULT;
2302         metainfo.responsePrefix[0] ='\0';
2303         info_len = sizeof(struct ATReqMetaInfo);
2304
2305         tcore_user_request_set_metainfo(ur, info_len, &metainfo);
2306
2307         cmd_str = g_strdup_printf("%s%s", "AT+CHLD=2", "\r");
2308         dbg("cmd : %s, prefix(if any) : %s, cmd_len : %d",cmd_str, "N/A", strlen(cmd_str));
2309
2310         pending = tcore_pending_new(o, ID_RESERVED_AT);
2311         tcore_pending_set_request_data(pending, strlen(cmd_str), cmd_str);
2312         g_free(cmd_str);
2313         tcore_pending_set_timeout(pending, 0);
2314         tcore_pending_set_response_callback(pending, (TcorePendingResponseCallback)cb, user_data);
2315         tcore_pending_link_user_request(pending, ur);
2316         tcore_pending_set_priority(pending, TCORE_PENDING_PRIORITY_DEFAULT);
2317
2318         tcore_pending_set_send_callback(pending, on_confirmation_call_control_ss_message_send, NULL);
2319
2320
2321         tcore_hal_send_request(h, pending);
2322
2323         return TCORE_RETURN_SUCCESS;
2324 }
2325
2326 static TReturn s_ss_manage_call_2x_send( CoreObject* o, UserRequest* ur, const int id, ConfirmCallback cb, void* user_data )
2327 {
2328         TcorePlugin *p = NULL;
2329         TcoreHal *h = NULL;
2330         TcorePending *pending = NULL;
2331         char*                                           cmd_str = NULL;
2332         struct ATReqMetaInfo metainfo;
2333         int info_len =0;
2334
2335         p = tcore_object_ref_plugin(o);
2336         h = tcore_object_get_hal(o);
2337
2338         memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
2339         metainfo.type = NO_RESULT;
2340         metainfo.responsePrefix[0] ='\0';
2341         info_len = sizeof(struct ATReqMetaInfo);
2342
2343         tcore_user_request_set_metainfo(ur, info_len, &metainfo);
2344
2345         cmd_str = g_strdup_printf("%s%d%s", "AT+CHLD=2", id,"\r");
2346         dbg("cmd : %s, prefix(if any) : %s, cmd_len : %d",cmd_str, "N/A", strlen(cmd_str));
2347
2348         pending = tcore_pending_new(o, ID_RESERVED_AT);
2349         tcore_pending_set_request_data(pending, strlen(cmd_str), cmd_str);
2350         g_free(cmd_str);
2351         tcore_pending_set_timeout(pending, 0);
2352         tcore_pending_set_response_callback(pending, (TcorePendingResponseCallback)cb, user_data);
2353         tcore_pending_link_user_request(pending, ur);
2354         tcore_pending_set_priority(pending, TCORE_PENDING_PRIORITY_DEFAULT);
2355
2356         tcore_pending_set_send_callback(pending, on_confirmation_call_control_ss_message_send, NULL);
2357
2358
2359         tcore_hal_send_request(h, pending);
2360
2361         return TCORE_RETURN_SUCCESS;
2362 }
2363
2364 static TReturn s_ss_manage_call_3_send( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data )
2365 {
2366 //      gboolean ret = FALSE;
2367         TcorePlugin *p = NULL;
2368         TcoreHal *h = NULL;
2369         TcorePending *pending = NULL;
2370         char* cmd_str = NULL;
2371         struct ATReqMetaInfo metainfo;
2372         int info_len =0;
2373
2374         GSList *l = 0;
2375         CallObject *co = 0;
2376         int id = 0;
2377
2378         l = tcore_call_object_find_by_status( o, CALL_STATUS_ACTIVE );
2379         if ( !l || !l->data ) {
2380                 dbg("[ error ] there is no call status [ call_active ]");
2381                 return TCORE_RETURN_FAILURE;
2382         }
2383
2384         co = l->data;
2385         id = tcore_call_object_get_id( co );
2386         dbg("active call id : [ %d ]");
2387
2388         p = tcore_object_ref_plugin(o);
2389         h = tcore_object_get_hal(o);
2390
2391         memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
2392         metainfo.type = NO_RESULT;
2393         metainfo.responsePrefix[0] ='\0';
2394         info_len = sizeof(struct ATReqMetaInfo);
2395
2396         tcore_user_request_set_metainfo(ur, info_len, &metainfo);
2397
2398         cmd_str = g_strdup_printf("%s%s", "AT+CHLD=3","\r");
2399
2400         dbg("cmd : %s, prefix(if any) : %s, cmd_len : %d",cmd_str, "N/A", strlen(cmd_str));
2401
2402         pending = tcore_pending_new(o, ID_RESERVED_AT);
2403         tcore_pending_set_request_data(pending, strlen(cmd_str), cmd_str);
2404         g_free(cmd_str);
2405         tcore_pending_set_timeout(pending, 0);
2406         tcore_pending_set_response_callback(pending, (TcorePendingResponseCallback)cb, user_data);
2407         tcore_pending_link_user_request(pending, ur);
2408         tcore_pending_set_priority(pending, TCORE_PENDING_PRIORITY_DEFAULT);
2409
2410         tcore_pending_set_send_callback(pending, on_confirmation_call_control_ss_message_send, NULL);
2411
2412
2413         tcore_hal_send_request(h, pending);
2414
2415         return TCORE_RETURN_SUCCESS;
2416 }
2417
2418 static TReturn s_ss_manage_call_4_send( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data )
2419 {
2420         TcorePlugin *p = NULL;
2421         TcoreHal *h = NULL;
2422         TcorePending *pending = NULL;
2423         char*                                           cmd_str = NULL;
2424         struct ATReqMetaInfo metainfo;
2425         int info_len =0;
2426
2427         p = tcore_object_ref_plugin(o);
2428         h = tcore_object_get_hal(o);
2429
2430         memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
2431         metainfo.type = NO_RESULT;
2432         metainfo.responsePrefix[0] ='\0';
2433         info_len = sizeof(struct ATReqMetaInfo);
2434
2435         tcore_user_request_set_metainfo(ur, info_len, &metainfo);
2436
2437
2438         cmd_str = g_strdup_printf("%s%s", "AT+CHLD=4", "\r");
2439
2440         dbg("cmd : %s, prefix(if any) : %s, cmd_len : %d",cmd_str, "N/A", strlen(cmd_str));
2441
2442         pending = tcore_pending_new(o, ID_RESERVED_AT);
2443         tcore_pending_set_request_data(pending, strlen(cmd_str), cmd_str);
2444         g_free(cmd_str);
2445         tcore_pending_set_timeout(pending, 0);
2446         tcore_pending_set_response_callback(pending, (TcorePendingResponseCallback)cb, user_data);
2447         tcore_pending_link_user_request(pending, ur);
2448         tcore_pending_set_priority(pending, TCORE_PENDING_PRIORITY_DEFAULT);
2449
2450         tcore_pending_set_send_callback(pending, on_confirmation_call_control_ss_message_send, NULL);
2451
2452
2453         tcore_hal_send_request(h, pending);
2454
2455         return TCORE_RETURN_SUCCESS;
2456 }
2457
2458 static TReturn s_ss_manage_call_4dn_send( CoreObject* o, UserRequest* ur, const char* number, ConfirmCallback cb, void* user_data )
2459 {
2460         TcorePlugin *p = NULL;
2461         TcoreHal *h = NULL;
2462         TcorePending *pending = NULL;
2463         char*                                           cmd_str = NULL;
2464         struct ATReqMetaInfo metainfo;
2465         int info_len =0;
2466
2467         p = tcore_object_ref_plugin(o);
2468         h = tcore_object_get_hal(o);
2469
2470         memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
2471         metainfo.type = NO_RESULT;
2472         metainfo.responsePrefix[0] ='\0';
2473         info_len = sizeof(struct ATReqMetaInfo);
2474
2475         tcore_user_request_set_metainfo(ur, info_len, &metainfo);
2476
2477
2478         cmd_str = g_strdup_printf("%s%s%s", "AT+CHLD=4", number,"\r");
2479
2480         dbg("cmd : %s, prefix(if any) : %s, cmd_len : %d",cmd_str, "N/A", strlen(cmd_str));
2481
2482         pending = tcore_pending_new(o, ID_RESERVED_AT);
2483         tcore_pending_set_request_data(pending, strlen(cmd_str), cmd_str);
2484         g_free(cmd_str);
2485         tcore_pending_set_timeout(pending, 0);
2486         tcore_pending_set_response_callback(pending, (TcorePendingResponseCallback)cb, user_data);
2487         tcore_pending_link_user_request(pending, ur);
2488         tcore_pending_set_priority(pending, TCORE_PENDING_PRIORITY_DEFAULT);
2489
2490         tcore_pending_set_send_callback(pending, on_confirmation_call_control_ss_message_send, NULL);
2491
2492
2493         tcore_hal_send_request(h, pending);
2494
2495         return TCORE_RETURN_SUCCESS;
2496 }
2497
2498 #if 0
2499 static TReturn s_ss_manage_call_5_send( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data )
2500 {
2501         TcorePlugin *p = NULL;
2502         TcoreHal *h = NULL;
2503         TcorePending *pending = NULL;
2504         char*                                           cmd_str = NULL;
2505         struct ATReqMetaInfo metainfo;
2506         int info_len =0;
2507
2508         p = tcore_object_ref_plugin(o);
2509         h = tcore_object_get_hal(o);
2510
2511         memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
2512         metainfo.type = NO_RESULT;
2513         metainfo.responsePrefix[0] ='\0';
2514         info_len = sizeof(struct ATReqMetaInfo);
2515
2516         tcore_user_request_set_metainfo(ur, info_len, &metainfo);
2517
2518
2519         cmd_str = g_strdup_printf("%s%s", "AT+CHLD=5", "\r");
2520
2521         dbg("cmd : %s, prefix(if any) : %s, cmd_len : %d",cmd_str, "N/A", strlen(cmd_str));
2522
2523         pending = tcore_pending_new(o, ID_RESERVED_AT);
2524         tcore_pending_set_request_data(pending, strlen(cmd_str), cmd_str);
2525         g_free(cmd_str);
2526         tcore_pending_set_timeout(pending, 0);
2527         tcore_pending_set_response_callback(pending, (TcorePendingResponseCallback)cb, user_data);
2528         tcore_pending_link_user_request(pending, ur);
2529         tcore_pending_set_priority(pending, TCORE_PENDING_PRIORITY_DEFAULT);
2530
2531         tcore_pending_set_send_callback(pending, on_confirmation_call_control_ss_message_send, NULL);
2532
2533
2534         tcore_hal_send_request(h, pending);
2535
2536         return TCORE_RETURN_SUCCESS;
2537 }
2538
2539 static TReturn s_ss_manage_call_6_send( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data )
2540 {
2541         TcorePlugin *p = NULL;
2542         TcoreHal *h = NULL;
2543         TcorePending *pending = NULL;
2544         char*                                           cmd_str = NULL;
2545         struct ATReqMetaInfo metainfo;
2546         int info_len =0;
2547
2548         p = tcore_object_ref_plugin(o);
2549         h = tcore_object_get_hal(o);
2550
2551         memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
2552         metainfo.type = NO_RESULT;
2553         metainfo.responsePrefix[0] ='\0';
2554         info_len = sizeof(struct ATReqMetaInfo);
2555
2556         tcore_user_request_set_metainfo(ur, info_len, &metainfo);
2557
2558
2559         cmd_str= g_strdup_printf("%s%s", "AT+CHLD=6", "\r");
2560
2561         dbg("cmd : %s, prefix(if any) : %s, cmd_len : %d",cmd_str, "N/A", strlen(cmd_str));
2562
2563         pending = tcore_pending_new(o, ID_RESERVED_AT);
2564         tcore_pending_set_request_data(pending, strlen(cmd_str), cmd_str);
2565         g_free(cmd_str);
2566         tcore_pending_set_timeout(pending, 0);
2567         tcore_pending_set_response_callback(pending, (TcorePendingResponseCallback)cb, user_data);
2568         tcore_pending_link_user_request(pending, ur);
2569         tcore_pending_set_priority(pending, TCORE_PENDING_PRIORITY_DEFAULT);
2570
2571         tcore_pending_set_send_callback(pending, on_confirmation_call_control_ss_message_send, NULL);
2572
2573
2574         tcore_hal_send_request(h, pending);
2575
2576         return TCORE_RETURN_SUCCESS;
2577 }
2578 #endif
2579
2580
2581 gboolean s_ss_init(TcorePlugin *p, TcoreHal *h)
2582 {
2583         CoreObject *so = 0, *co = 0;
2584         struct property_call_info *data = 0;
2585
2586         dbg("s_ss_init()");
2587
2588         so = tcore_ss_new(p, "ss", &ss_ops, h);
2589         if (!so) {
2590                 dbg("[ error ] ss_new()");
2591                 return FALSE;
2592         }
2593
2594         co = tcore_plugin_ref_core_object(p, "call");
2595         if (!co) {
2596                 dbg("[ error ] plugin_ref_core_object");
2597                 return FALSE;
2598         }
2599
2600         tcore_call_control_set_operations( co, &call_ops );
2601
2602         tcore_object_add_callback( so, EVENT_SS_INFO, on_notification_ss_info, 0 );
2603         tcore_object_add_callback( so, EVENT_SS_USSD, on_notification_ss_ussd, 0 );
2604
2605         data = calloc( sizeof(struct property_call_info *), 1);
2606         tcore_plugin_link_property(p, "SS", data);
2607
2608         return TRUE;
2609 }
2610
2611 void s_ss_exit( TcorePlugin *p )
2612 {
2613         CoreObject *o;
2614 //      TcoreHal *h;
2615         struct property_network_info *data;
2616
2617         o = tcore_plugin_ref_core_object(p, "ss");
2618
2619         data = tcore_plugin_ref_property(p, "SS");
2620         if (data)
2621                 free(data);
2622
2623         tcore_ss_free(o);
2624 }