Revert manifest to default one
[profile/ivi/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 = FALSE;
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_general 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 = TCORE_RETURN_SUCCESS;
579         }
580         else{
581                 resp.err = TCORE_RETURN_FAILURE;
582         }
583
584         dbg("on_response_ss_barring_set - rsp.err : %d, ur : %x", resp.err, ur);
585
586
587         if(sp_response->success > 0)
588         {
589                 ReleaseResponse();
590
591                 if ( info->class == SS_CLASS_VOICE )
592                         class = SS_CLASS_ALL_TELE_BEARER;
593
594                 ur_dup = tcore_user_request_ref(ur);
595
596                 if ( info->flavor_type == SS_BARR_MODE_AB ||
597                          info->flavor_type == SS_BARR_MODE_AOB )
598                         _ss_barring_get( o, ur_dup, class, SS_BARR_MODE_BAOC, info->resp );
599                 else if ( info->flavor_type == SS_BARR_MODE_AIB )
600                         _ss_barring_get( o, ur_dup, class, SS_BARR_MODE_BAIC, info->resp );
601                 else
602                         _ss_barring_get( o, ur_dup, class, info->flavor_type, info->resp );
603
604         }
605         else
606         {
607                 ReleaseResponse();
608
609                 if ( ur )
610                         tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_general), &resp);
611                 else
612                         dbg("[ error ] ur is 0");
613
614         }
615
616         g_free(user_data);
617
618
619 }
620
621 static void on_response_ss_barring_change_pwd( TcorePending *p, int data_len, const void *data, void *user_data )
622 {
623         struct ss_confirm_info *info = 0;
624         UserRequest *ur;
625         struct tresp_ss_general resp;
626
627         ur = tcore_pending_ref_user_request(p);
628
629         info = (struct ss_confirm_info*)user_data;
630
631         printResponse();
632
633         if(sp_response->success > 0){
634                 resp.err = TCORE_RETURN_SUCCESS;
635         }
636         else{
637                 resp.err = TCORE_RETURN_FAILURE;
638         }
639
640         ReleaseResponse();
641
642         dbg("on_response_ss_barring_change_pwd: rsp.err : %d, usr : %x", resp.err, ur);
643
644         if ( ur )
645                 tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_general), &resp);
646         else
647                 dbg("[ error ] ur is 0");
648
649         g_free(user_data);
650 }
651
652
653 static void on_response_ss_barring_get( TcorePending *p, int data_len, const void *data, void *user_data )
654 {
655         CoreObject*             o = 0;
656         UserRequest*    ur = 0;
657         struct ATLine *p_cur;
658         int status=0, classx =0, err=0;
659
660         struct ss_confirm_info* info = 0;
661         struct tresp_ss_barring resp;
662         int countRecords=0, countValidRecords =0;
663
664         o  = tcore_pending_ref_core_object(p);
665         ur = tcore_pending_ref_user_request(p);
666
667         printResponse();
668
669         info = (struct ss_confirm_info*)user_data;
670
671         /* count the calls */
672         for (countRecords = 0, p_cur = sp_response->p_intermediates
673                         ; p_cur != NULL
674                         ; p_cur = p_cur->p_next
675                 ) {
676                 countRecords++;
677         }
678         dbg("total records : %d",countRecords);
679
680
681         resp.record_num = countRecords;
682
683         if ( resp.record_num > 0 ) {
684 //              int i = 0;
685
686                 resp.record = g_new0( struct barring_info, resp.record_num );
687
688                 for (countValidRecords = 0, p_cur = sp_response->p_intermediates
689                                 ; p_cur != NULL
690                                 ; p_cur = p_cur->p_next)
691                 {
692                         err = at_tok_start(&(p_cur->line));
693                         if (err < 0){
694                                 dbg("start line error. skip this line");
695                                 goto error;
696                         }
697                         err = at_tok_nextint(&(p_cur->line), &status);// status
698                         if (err < 0) {
699                                 dbg("status error. skip this line");
700                                 goto error;
701                         }
702
703                         if(status == 1){
704                                 resp.record[countValidRecords].status = SS_STATUS_ACTIVATE;
705                         }
706                         else    {
707                                 resp.record[countValidRecords].status = SS_STATUS_DEACTIVATE;
708                         }
709
710                         err = at_tok_nextint(&(p_cur->line), &classx); //class
711                         if (err < 0) {
712                                 dbg("class error. classx not exist - set to requested one : %d", info->class);
713                                 switch(info->class){
714                                         case SS_CLASS_ALL_TELE:
715                                                 classx =7;
716                                                 break;
717                                         case SS_CLASS_VOICE:
718                                                 classx =1;
719                                                 break;
720                                         case SS_CLASS_ALL_DATA_TELE:
721                                                 classx =2;
722                                                 break;
723                                         case SS_CLASS_FAX:
724                                                 classx =4;
725                                                 break;
726                                         case SS_CLASS_SMS:
727                                                 classx = 8;
728                                                 break;
729                                         case SS_CLASS_ALL_CS_SYNC:
730                                                 classx = 16;
731                                                 break;
732
733                                         default:
734                                                 classx =7;
735                                                 dbg("unsupported class %d. set to default : 7", info->class);
736                                                 break;
737                                 }
738                         }
739
740                         switch(classx){
741                                 case 1:
742                                         resp.record[countValidRecords].class = SS_CLASS_VOICE;
743                                         break;
744                                 case 2:
745                                         resp.record[countValidRecords].class = SS_CLASS_ALL_DATA_TELE;
746                                         break;
747                                 case 4:
748                                         resp.record[countValidRecords].class = SS_CLASS_FAX;
749                                         break;
750                                 case 7:
751                                         resp.record[countValidRecords].class = SS_CLASS_ALL_TELE;
752                                         break;
753                                 case 8:
754                                         resp.record[countValidRecords].class = SS_CLASS_SMS;
755                                         break;
756                                 case 16:
757                                         resp.record[countValidRecords].class = SS_CLASS_ALL_CS_SYNC;
758                                         break;
759                                 case 32:
760                                         resp.record[countValidRecords].class = SS_CLASS_ALL_CS_ASYNC;
761                                         break;
762                                 default:
763                                         dbg("unspoorted class : [%d]\n", classx );
764                                         goto error;
765                                         break;
766                         }
767
768                         resp.record[countValidRecords].mode = (enum telephony_ss_barring_mode)(info->flavor_type);
769
770                         countValidRecords++;
771                         continue;
772 error:
773                         dbg("invalid field found. coutinue");
774                         continue;
775                 }
776
777                 dbg("valid count :%d",countValidRecords);
778                 resp.record_num = countValidRecords;
779                 resp.err = TCORE_RETURN_SUCCESS;
780
781         }
782         else
783         {
784                 dbg("no active status - return to user")
785         }
786
787         if(sp_response->success > 0){
788                 resp.err = TCORE_RETURN_SUCCESS;
789         }
790         else{
791                 resp.err = TCORE_RETURN_FAILURE;
792         }
793
794         dbg("on_response_ss_barring_get- rsp.err : %d, ur : %x", resp.err, ur);
795
796         ReleaseResponse();
797
798         if ( ur )
799                 tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_barring), &resp);
800         else
801                 dbg("[ error ] ur is 0");
802
803         g_free( user_data );
804
805 }
806
807 static void on_response_ss_forwarding_set( TcorePending *p, int data_len, const void *data, void *user_data )
808 {
809         CoreObject*             o = 0;
810         UserRequest*    ur = 0, *dup_ur=0;
811         struct ss_confirm_info *info = 0;
812         struct tresp_ss_general resp;
813
814         o  = tcore_pending_ref_core_object(p);
815         ur = tcore_pending_ref_user_request(p);
816
817         info = (struct ss_confirm_info*)user_data;
818
819         printResponse();
820
821         if(sp_response->success > 0){
822                 resp.err = TCORE_RETURN_SUCCESS;
823         }else{
824                 resp.err = TCORE_RETURN_FAILURE;
825         }
826
827         dbg("[ check ] class : 0x%x", info->class );
828         dbg("[ check ] flavor_type : 0x%x", info->flavor_type );
829
830         dbg("on_response_ss_forwarding_set - rsp.err : %d, ur : %x", resp.err, ur);
831
832         if ( sp_response->success > 0) {
833
834         ReleaseResponse();
835
836                 if ( info->flavor_type == SS_CF_MODE_CF_ALL ||
837                          info->flavor_type == SS_CF_MODE_CFC ) {
838
839                         if ( ur )
840                                 tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_general), &resp);
841                         else
842                                 dbg("[ error ] ur is 0");
843
844                 } else {
845                         dup_ur = tcore_user_request_ref(ur);
846                         _ss_forwarding_get( o, dup_ur, info->class, info->flavor_type, info->resp );
847                 }
848
849         } else {
850                 ReleaseResponse();
851
852                 if ( ur )
853                         tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_general), &resp);
854                 else
855                         dbg("[ error ] ur is 0");
856
857         }
858         g_free(user_data);
859 }
860
861 static void on_response_ss_forwarding_get( TcorePending *p, int data_len, const void *data, void *user_data )
862 {
863         CoreObject*             o = 0;
864         UserRequest*    ur = 0;
865         struct ATLine *p_cur;
866         int status=0, classx =0, err=0, ton =0, time=0;
867         char* num, *subaddr;
868
869         struct ss_confirm_info* info = 0;
870         struct tresp_ss_forwarding resp;
871         int countRecords=0, countValidRecords =0;
872
873         o  = tcore_pending_ref_core_object(p);
874         ur = tcore_pending_ref_user_request(p);
875
876         printResponse();
877
878         info = (struct ss_confirm_info*)user_data;
879
880         /* count the calls */
881         for (countRecords = 0, p_cur = sp_response->p_intermediates
882                         ; p_cur != NULL
883                         ; p_cur = p_cur->p_next
884                 ) {
885                 countRecords++;
886         }
887         dbg("total records : %d",countRecords);
888
889
890         resp.record_num = countRecords;
891
892         if ( resp.record_num > 0 ) {
893                 //              int i = 0;
894
895                 resp.record = g_new0( struct forwarding_info, resp.record_num );
896
897                 for (countValidRecords = 0, p_cur = sp_response->p_intermediates
898                                 ; p_cur != NULL
899                                 ; p_cur = p_cur->p_next)
900                 {
901                         err = at_tok_start(&(p_cur->line));
902                         if (err < 0){
903                                 dbg("start line error. skip this line");
904                                 goto error;
905                         }
906                         err = at_tok_nextint(&(p_cur->line), &status);// status
907                         if (err < 0) {
908                                 dbg("status error. skip this line");
909                                 goto error;
910                         }
911
912                         if(status == 1){
913                                 resp.record[countValidRecords].status = SS_STATUS_ACTIVATE;
914                         }
915                         else    {
916                                 resp.record[countValidRecords].status = SS_STATUS_DEACTIVATE;
917                         }
918
919                         err = at_tok_nextint(&(p_cur->line), &classx); //class
920                         if (err < 0) {
921                                 dbg("class error. skip this line");
922                                 goto error;
923                         }
924
925                         switch(classx){
926                                 case 1:
927                                         resp.record[countValidRecords].class = SS_CLASS_VOICE;
928                                         break;
929                                 case 2:
930                                         resp.record[countValidRecords].class = SS_CLASS_ALL_DATA_TELE;
931                                         break;
932                                 case 4:
933                                         resp.record[countValidRecords].class = SS_CLASS_FAX;
934                                         break;
935                                 case 7:
936                                         resp.record[countValidRecords].class = SS_CLASS_ALL_TELE;
937                                         break;
938                                 case 8:
939                                         resp.record[countValidRecords].class = SS_CLASS_SMS;
940                                         break;
941                                 case 16:
942                                         resp.record[countValidRecords].class = SS_CLASS_ALL_CS_SYNC;
943                                         break;
944                                 case 32:
945                                         resp.record[countValidRecords].class = SS_CLASS_ALL_CS_ASYNC;
946                                         break;
947                                 default:
948                                         dbg("unspoorted class : [%d]\n", classx );
949                                         goto error;
950                                         break;
951                         }
952
953                         if(at_tok_hasmore(&(p_cur->line)) ==1){ //more data present
954                                 err = at_tok_nextstr(&(p_cur->line), &num); //number
955                                 memcpy((resp.record[countValidRecords].number), num, strlen(num));
956                                 resp.record[countValidRecords].number_present = TRUE;
957
958                                 err = at_tok_nextint(&(p_cur->line), &ton); // type of  number - skip
959                                 resp.record[countValidRecords].number_type = ton;
960
961                                 if(at_tok_hasmore(&(p_cur->line)) ==1){
962                                         err = at_tok_nextstr(&(p_cur->line), &subaddr); //subaddr - skip
963                                         err  =at_tok_nextint(&(p_cur->line), &ton); //ton of subaddr - skip
964
965                                         if(at_tok_hasmore(&(p_cur->line)) ==1){
966                                                 err = at_tok_nextint(&(p_cur->line), &time); //time
967                                                 resp.record[countValidRecords].time = (enum telephony_ss_forwarding_no_reply_time)time;
968                                         }
969
970                                 }
971
972                         }
973
974                         resp.record[countValidRecords].mode = (enum telephony_ss_barring_mode)(info->flavor_type);
975
976                         countValidRecords++;
977                         continue;
978 error:
979                         dbg("invalid field found. coutinue");
980                         continue;
981                 }
982
983                 dbg("valid count :%d",countValidRecords);
984                 resp.record_num = countValidRecords;
985                 resp.err = TCORE_RETURN_SUCCESS;
986
987         }
988         else
989         {
990                 dbg("no active status - return to user")
991         }
992
993         if(sp_response->success > 0){
994                 resp.err = TCORE_RETURN_SUCCESS;
995         }
996         else{
997                 resp.err = TCORE_RETURN_FAILURE;
998         }
999
1000         ReleaseResponse();
1001         dbg("on_response_ss_forwarding_get - rsp.err : %d, ur : %x", resp.err, ur);
1002
1003         if ( ur )
1004                 tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_forwarding), &resp);
1005         else
1006                 dbg("[ error ] ur is 0");
1007
1008         g_free( user_data );
1009
1010 }
1011
1012 static void on_response_ss_waiting_set( TcorePending *p, int data_len, const void *data, void *user_data )
1013 {
1014         CoreObject*             o = 0;
1015         UserRequest*    ur = 0;
1016         struct ss_confirm_info *info = 0;
1017         struct tresp_ss_general resp;
1018
1019         o  = tcore_pending_ref_core_object(p);
1020         ur = tcore_pending_ref_user_request(p);
1021
1022         info = (struct ss_confirm_info*)user_data;
1023
1024         if(sp_response->success > 0){
1025                 resp.err = TCORE_RETURN_SUCCESS;
1026         }else{
1027                 resp.err = TCORE_RETURN_FAILURE;
1028         }
1029
1030         ReleaseResponse();
1031
1032         dbg("on_response_ss_waiting_set - rsp.err : %d, ur : %x, class : %d", resp.err, ur, info->class );
1033
1034         if ( resp.err == TCORE_RETURN_SUCCESS ) {
1035
1036                 _ss_waiting_get( o, ur, info->class, info->resp );
1037
1038         } else {
1039
1040                 if ( ur )
1041                         tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_general), &resp);
1042                 else
1043                         dbg("[ error ] ur is 0");
1044
1045         }
1046         g_free( user_data );
1047 }
1048
1049 static void on_response_ss_waiting_get( TcorePending *p, int data_len, const void *data, void *user_data )
1050 {
1051         CoreObject*             o = 0;
1052         UserRequest*    ur = 0;
1053         struct ATLine *p_cur;
1054         int status=0, classx =0, err=0;
1055
1056         struct ss_confirm_info* info = 0;
1057         struct tresp_ss_waiting resp;
1058         int countRecords=0, countValidRecords =0;
1059
1060         o  = tcore_pending_ref_core_object(p);
1061         ur = tcore_pending_ref_user_request(p);
1062
1063         printResponse();
1064
1065         info = (struct ss_confirm_info*)user_data;
1066
1067         /* count the calls */
1068         for (countRecords = 0, p_cur = sp_response->p_intermediates
1069                         ; p_cur != NULL
1070                         ; p_cur = p_cur->p_next
1071                 ) {
1072                 countRecords++;
1073         }
1074         dbg("total records : %d",countRecords);
1075
1076
1077         resp.record_num = countRecords;
1078
1079         if ( resp.record_num > 0 ) {
1080                 //              int i = 0;
1081
1082                 resp.record = g_new0( struct waiting_info, resp.record_num );
1083
1084                 for (countValidRecords = 0, p_cur = sp_response->p_intermediates
1085                                 ; p_cur != NULL
1086                                 ; p_cur = p_cur->p_next)
1087                 {
1088                         err = at_tok_start(&(p_cur->line));
1089                         if (err < 0){
1090                                 dbg("start line error. skip this line");
1091                                 goto error;
1092                         }
1093
1094                         err = at_tok_nextint(&(p_cur->line), &status);// status
1095                         if (err < 0) {
1096                                 dbg("status error. skip this line");
1097                                 goto error;
1098                         }
1099
1100                         if(status == 1){
1101                                 resp.record[countValidRecords].status = SS_STATUS_ACTIVATE;
1102                         }
1103                         else    {
1104                                 resp.record[countValidRecords].status = SS_STATUS_DEACTIVATE;
1105                         }
1106
1107                         err = at_tok_nextint(&(p_cur->line), &classx); //class
1108                         if (err < 0) {
1109                                 dbg("class error. skip this line");
1110                                 goto error;
1111                         }
1112
1113                         switch(classx){
1114                                 case 1:
1115                                         resp.record[countValidRecords].class = SS_CLASS_VOICE;
1116                                         break;
1117                                 case 2:
1118                                         resp.record[countValidRecords].class = SS_CLASS_ALL_DATA_TELE;
1119                                         break;
1120                                 case 4:
1121                                         resp.record[countValidRecords].class = SS_CLASS_FAX;
1122                                         break;
1123                                 case 7:
1124                                         resp.record[countValidRecords].class = SS_CLASS_ALL_TELE;
1125                                         break;
1126                                 case 8:
1127                                         resp.record[countValidRecords].class = SS_CLASS_SMS;
1128                                         break;
1129                                 case 16:
1130                                         resp.record[countValidRecords].class = SS_CLASS_ALL_CS_SYNC;
1131                                         break;
1132                                 case 32:
1133                                         resp.record[countValidRecords].class = SS_CLASS_ALL_CS_ASYNC;
1134                                         break;
1135                                 default:
1136                                         dbg("unspoorted class : [%d]\n", classx );
1137                                         goto error;
1138                                         break;
1139                         }
1140
1141                         countValidRecords++;
1142                         continue;
1143 error:
1144                         dbg("invalid field found. coutinue");
1145                         continue;
1146                 }
1147
1148                 dbg("valid count :%d",countValidRecords);
1149                 resp.record_num = countValidRecords;
1150                 resp.err = TCORE_RETURN_SUCCESS;
1151         }
1152         else
1153         {
1154                 dbg("no active status - return to user")
1155         }
1156
1157         if(sp_response->success > 0){
1158                 resp.err = TCORE_RETURN_SUCCESS;
1159         }
1160         else{
1161                 resp.err = TCORE_RETURN_FAILURE;
1162         }
1163
1164         dbg("on_response_ss_waiting_get - rsp.err : %d, ur : %x", resp.err, ur);
1165
1166         ReleaseResponse();
1167
1168         if ( ur )
1169                 tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_waiting), &resp);
1170         else
1171                 dbg("[ error ] ur is 0");
1172
1173         g_free( user_data );
1174
1175 }
1176
1177 static void on_confirmation_ss_ussd( TcorePending *p, int data_len, const void *data, void *user_data )
1178 {
1179         struct ss_confirm_info *info = 0;
1180
1181         struct tresp_ss_ussd resp;
1182         CoreObject*             o = 0;
1183         UserRequest*    ur = 0;
1184
1185         o  = tcore_pending_ref_core_object(p);
1186         ur = tcore_pending_ref_user_request(p);
1187
1188
1189         printResponse();
1190
1191         info = (struct ss_confirm_info*)user_data;
1192
1193         if(sp_response->success > 0){
1194                 resp.err = TCORE_RETURN_SUCCESS;
1195         }
1196         else{
1197                 resp.err = TCORE_RETURN_FAILURE;
1198         }
1199
1200         dbg("on_confirmation_ss_ussd - rsp.err : %d, ur : %x", resp.err, ur);
1201
1202
1203         if (sp_response->success > 0) {
1204
1205                 UssdSession *ussd_s = 0;
1206                 enum tcore_ss_ussd_type type = 0;
1207
1208                 ussd_s = tcore_ss_ussd_get_session( o );
1209
1210                 if ( ussd_s )
1211                         type = tcore_ss_ussd_get_session_type( ussd_s );
1212                 else
1213                         dbg("[ error ] ussd_s : (0)");
1214
1215                 resp.type = (enum telephony_ss_ussd_type)type;
1216
1217                 if ( type == TCORE_SS_USSD_TYPE_USER_INITIATED ) {
1218                         UserRequest *ur2 = 0;
1219
1220                         tcore_ss_ussd_get_session_data( ussd_s, (void**)&ur2 );
1221                         if ( ur2 )
1222                                 tcore_user_request_unref( ur2 );
1223
1224                         tcore_ss_ussd_destroy_session( ussd_s );
1225                 }
1226
1227                 if ( ur )
1228                         tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_ussd), &resp);
1229                 else
1230                         dbg("[ error ] ur : (0)");
1231
1232                 ReleaseResponse();
1233         }
1234
1235         g_free( user_data );
1236
1237 }
1238
1239
1240 static struct tcore_ss_operations ss_ops = {
1241         .barring_activate               = s_ss_barring_activate,
1242         .barring_deactivate             = s_ss_barring_deactivate,
1243         .barring_change_password= s_ss_barring_change_password,
1244         .barring_get_status             = s_ss_barring_get_status,
1245         .forwarding_activate    = s_ss_forwarding_activate,
1246         .forwarding_deactivate  = s_ss_forwarding_deactivate,
1247         .forwarding_register    = s_ss_forwarding_register,
1248         .forwarding_deregister  = s_ss_forwarding_deregister,
1249         .forwarding_get_status  = s_ss_forwarding_get_status,
1250         .waiting_activate               = s_ss_waiting_activate,
1251         .waiting_deactivate             = s_ss_waiting_deactivate,
1252         .waiting_get_status             = s_ss_waiting_get_status,
1253         .cli_activate                   = s_ss_cli_activate,
1254         .cli_deactivate                 = s_ss_cli_deactivate,
1255         .cli_get_status                 = s_ss_cli_get_status,
1256         .send_ussd                              = s_ss_send_ussd,
1257         .set_aoc                                = s_ss_set_aoc,
1258         .get_aoc                                = s_ss_get_aoc,
1259 };
1260
1261
1262 static TReturn _ss_barring_set( CoreObject *o, UserRequest *ur, enum telephony_ss_opcode op )
1263 {
1264         struct treq_ss_barring *barring = 0;
1265         TcorePlugin *p = 0;
1266         struct ss_confirm_info *user_data = 0;
1267         gboolean ret = FALSE;
1268         char passwd[MAX_SS_BARRING_PASSWORD_LEN+1];
1269
1270         struct ATReqMetaInfo metainfo;
1271         int info_len =0;
1272         char* cmd_str = NULL;
1273         int opco;
1274         int classx;
1275         char* facility = NULL;
1276
1277
1278         barring = (struct treq_ss_barring*)tcore_user_request_ref_data( ur, 0 );
1279         p               = tcore_object_ref_plugin( o );
1280
1281         memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
1282         metainfo.type = NO_RESULT;
1283         metainfo.responsePrefix[0] ='\0';
1284         info_len = sizeof(struct ATReqMetaInfo);
1285
1286         tcore_user_request_set_metainfo(ur, info_len, &metainfo);
1287
1288
1289         switch(op){
1290                 case TIZEN_SS_OPCO_ACTIVATE:
1291                         opco = 1;
1292                 break;
1293                 case TIZEN_SS_OPCO_DEACTIVATE:
1294                         opco = 0;
1295                 break;
1296                 default:
1297                         dbg("unsupported opco : %d", op);
1298                 return TCORE_RETURN_FAILURE;
1299         }
1300
1301
1302         switch(barring->mode){
1303                 case SS_BARR_MODE_BAOC:
1304                         facility = "AO";
1305                 break;
1306                 case SS_BARR_MODE_BOIC:
1307                         facility = "OI";
1308                 break;
1309                 case SS_BARR_MODE_BOIC_NOT_HC:
1310                         facility = "OX";
1311                 break;
1312                 case SS_BARR_MODE_BAIC:
1313                         facility = "AI";
1314                 break;
1315                 case SS_BARR_MODE_BIC_ROAM:
1316                         facility = "IR";
1317                 break;
1318                 case SS_BARR_MODE_AB:
1319                         facility = "AB";
1320                 break;
1321                 case SS_BARR_MODE_AOB:
1322                         facility = "AG";
1323                 break;
1324                 case SS_BARR_MODE_AIB:
1325                         facility = "AC";
1326                 break;
1327                 case SS_BARR_MODE_BIC_NOT_SIM:
1328                         facility = "NS";
1329                 break;
1330                 default:
1331                         dbg("unspported mode %d", barring->mode);
1332                 return TCORE_RETURN_FAILURE;
1333         }
1334
1335         switch(barring->class)
1336         {
1337                 case SS_CLASS_ALL_TELE:
1338                         classx =7;
1339                 break;
1340                 case SS_CLASS_VOICE:
1341                         classx =1;
1342                 break;
1343                 case SS_CLASS_ALL_DATA_TELE:
1344                         classx =2;
1345                 break;
1346                 case SS_CLASS_FAX:
1347                         classx =4;
1348                 break;
1349                 case SS_CLASS_SMS:
1350                         classx = 8;
1351                 break;
1352                 case SS_CLASS_ALL_CS_SYNC:
1353                         classx = 16;
1354                 break;
1355
1356                 default:
1357                         classx =7;
1358                         dbg("unsupported class %d. set to default : 7", barring->class);
1359                 break;
1360         }
1361
1362         // null-ended pwd handling added - unexpected  0x11 value observed in req string
1363         memcpy(passwd, barring->password, MAX_SS_BARRING_PASSWORD_LEN);
1364         passwd[MAX_SS_BARRING_PASSWORD_LEN]='\0';
1365
1366
1367         cmd_str = g_strdup_printf("AT+CLCK=\"%s\",%d,\"%s\",%d%s", facility, opco, passwd, classx,"\r");
1368         dbg("request command : %s", cmd_str);
1369
1370         user_data = g_new0( struct ss_confirm_info, 1 );
1371
1372         if ( op == TIZEN_SS_OPCO_ACTIVATE) {
1373                 user_data->resp = TRESP_SS_BARRING_ACTIVATE;
1374
1375         } else if ( op == TIZEN_SS_OPCO_DEACTIVATE) {
1376                 user_data->resp = TRESP_SS_BARRING_DEACTIVATE;
1377
1378         } else {
1379                 dbg("[ error ] wrong ss opco ( 0x%x )", op );
1380                 return TCORE_RETURN_FAILURE;
1381         }
1382
1383         user_data->flavor_type = (int)(barring->mode);
1384         user_data->class = barring->class;
1385
1386         ret = _ss_request_message( o, ur, cmd_str, strlen(cmd_str), on_response_ss_barring_set, user_data );
1387
1388         g_free(cmd_str);
1389
1390         if ( !ret )
1391                 return TCORE_RETURN_FAILURE;
1392
1393         return TCORE_RETURN_SUCCESS;
1394 }
1395
1396 static TReturn _ss_barring_get( CoreObject *o,
1397                                                                 UserRequest *ur,
1398                                                                 enum telephony_ss_class class,
1399                                                                 enum telephony_ss_barring_mode mode,
1400                                                                 enum tcore_response_command resp )
1401 {
1402         TcorePlugin *p = 0;
1403         struct ss_confirm_info *user_data = 0;
1404         gboolean ret = FALSE;
1405
1406         struct ATReqMetaInfo metainfo;
1407         int info_len =0;
1408         char* cmd_str = NULL;
1409         int opco, classx;
1410         char* facility = NULL;
1411
1412         p       = tcore_object_ref_plugin( o );
1413
1414         memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
1415         metainfo.type = MULTILINE;
1416         memcpy(metainfo.responsePrefix,"+CLCK:",strlen("+CLCK:"));
1417         info_len = sizeof(struct ATReqMetaInfo);
1418
1419         tcore_user_request_set_metainfo(ur, info_len, &metainfo);
1420
1421         //query status - opco is fixed to 2
1422         opco = 2;
1423
1424         //barring mode
1425         switch(mode){
1426                 case SS_BARR_MODE_BAOC:
1427                         facility = "AO";
1428                 break;
1429                 case SS_BARR_MODE_BOIC:
1430                         facility = "OI";
1431                 break;
1432                 case SS_BARR_MODE_BOIC_NOT_HC:
1433                         facility = "OX";
1434                 break;
1435                 case SS_BARR_MODE_BAIC:
1436                         facility = "AI";
1437                 break;
1438                 case SS_BARR_MODE_BIC_ROAM:
1439                         facility = "IR";
1440                 break;
1441                 case SS_BARR_MODE_AB:
1442                         facility = "AB";
1443                 break;
1444                 case SS_BARR_MODE_AOB:
1445                         facility = "AG";
1446                 break;
1447                 case SS_BARR_MODE_AIB:
1448                         facility = "AC";
1449                 break;
1450                 case SS_BARR_MODE_BIC_NOT_SIM:
1451                         facility = "NS";
1452                 break;
1453                 default:
1454                         dbg("unspported mode %d", mode);
1455                 return TCORE_RETURN_FAILURE;
1456         }
1457
1458         switch(class)
1459         {
1460                 case SS_CLASS_ALL_TELE:
1461                         classx =7;
1462                 break;
1463                 case SS_CLASS_VOICE:
1464                         classx =1;
1465                 break;
1466                 case SS_CLASS_ALL_DATA_TELE:
1467                         classx =2;
1468                 break;
1469                 case SS_CLASS_FAX:
1470                         classx =4;
1471                 break;
1472                 case SS_CLASS_SMS:
1473                         classx = 8;
1474                 break;
1475                 case SS_CLASS_ALL_CS_SYNC:
1476                         classx = 16;
1477                 break;
1478
1479                 default:
1480                         classx =7;
1481                         dbg("unsupported class %d. set to default : 7", class);
1482                 break;
1483         }
1484
1485
1486         if(classx ==7)
1487         cmd_str = g_strdup_printf("AT+CLCK=\"%s\",%d%s", facility, opco,"\r");
1488         else
1489                 cmd_str = g_strdup_printf("AT+CLCK=\"%s\",%d,,%d%s", facility, opco,classx,"\r");
1490
1491         dbg("request command : %s", cmd_str);
1492
1493         user_data = g_new0( struct ss_confirm_info, 1 );
1494         user_data->resp = resp;
1495
1496         user_data->flavor_type = (int)(mode);
1497         user_data->class = class;
1498
1499         ret = _ss_request_message( o, ur, cmd_str, strlen(cmd_str), on_response_ss_barring_get, user_data );
1500
1501         g_free(cmd_str);
1502
1503         if ( !ret )
1504                 return TCORE_RETURN_FAILURE;
1505
1506         return TCORE_RETURN_SUCCESS;
1507 }
1508
1509 static TReturn s_ss_barring_activate( CoreObject *o, UserRequest *ur )
1510 {
1511         return _ss_barring_set( o, ur, TIZEN_SS_OPCO_ACTIVATE );
1512 }
1513
1514 static TReturn s_ss_barring_deactivate( CoreObject *o, UserRequest *ur )
1515 {
1516         return _ss_barring_set( o, ur, TIZEN_SS_OPCO_DEACTIVATE );
1517 }
1518
1519 static TReturn s_ss_barring_change_password( CoreObject *o, UserRequest *ur )
1520 {
1521         TcorePlugin *p = 0;
1522         struct treq_ss_barring_change_password *barring = 0;
1523
1524         struct ss_confirm_info *user_data = 0;
1525
1526         gboolean ret = FALSE;
1527
1528 //      struct ATReqMetaInfo metainfo;
1529 //      int info_len =0;
1530         char* cmd_str = NULL;
1531
1532         p               = tcore_object_ref_plugin( o );
1533         barring = (struct treq_ss_barring_change_password*)tcore_user_request_ref_data( ur, 0 );
1534
1535
1536         cmd_str = g_strdup_printf("AT+CPWD=\"%s\",\"%s\",\"%s\"%s", "AB", barring->password_old, barring->password_new,"\r");
1537         dbg("request command : %s", cmd_str);
1538
1539
1540         user_data = g_new0( struct ss_confirm_info, 1 );
1541         user_data->resp = TRESP_SS_BARRING_CHANGE_PASSWORD;
1542
1543         ret = _ss_request_message( o, ur, cmd_str, strlen(cmd_str), on_response_ss_barring_change_pwd, user_data );
1544
1545         g_free(cmd_str);
1546         if ( !ret )
1547                 return TCORE_RETURN_FAILURE;
1548
1549         return TCORE_RETURN_SUCCESS;
1550 }
1551
1552 static TReturn s_ss_barring_get_status( CoreObject *o, UserRequest *ur )
1553 {
1554         struct treq_ss_barring *barring = 0;
1555         barring = (struct treq_ss_barring*)tcore_user_request_ref_data( ur, 0 );
1556
1557         return _ss_barring_get( o, ur, barring->class, barring->mode, TRESP_SS_BARRING_GET_STATUS );
1558 }
1559
1560 static TReturn _ss_forwarding_set( CoreObject *o, UserRequest *ur, enum telephony_ss_opcode op )
1561 {
1562         TcorePlugin *p = 0;
1563         struct treq_ss_forwarding *forwarding = 0;
1564
1565         struct ss_confirm_info *user_data = 0;
1566
1567         gboolean ret = FALSE;
1568         int len = 0;
1569
1570         struct ATReqMetaInfo metainfo;
1571         int info_len =0;
1572         char* cmd_str = NULL;
1573         char* tmp_str = NULL;
1574         int reason=0,mode=0,num_type=0, classx=0,time=0;
1575         gboolean valid_num = FALSE;
1576
1577         dbg("_ss_forwarding_set with opco %d ", op);
1578
1579
1580         forwarding = (struct treq_ss_forwarding*) tcore_user_request_ref_data( ur, 0 );
1581         p               = tcore_object_ref_plugin( o );
1582
1583         memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
1584         metainfo.type = NO_RESULT;
1585         metainfo.responsePrefix[0] ='\0';
1586         info_len = sizeof(struct ATReqMetaInfo);
1587
1588         tcore_user_request_set_metainfo(ur, info_len, &metainfo);
1589
1590         switch(forwarding->mode)
1591         {
1592                 case SS_CF_MODE_CFU:
1593                         reason =0;
1594                         break;
1595                 case SS_CF_MODE_CFB:
1596                         reason =1;
1597                         break;
1598                 case SS_CF_MODE_CFNRy:
1599                         reason =2;
1600                         break;
1601                 case SS_CF_MODE_CFNRc:
1602                         reason =3;
1603                         break;
1604                 case SS_CF_MODE_CF_ALL:
1605                         reason = 4;
1606                 break;
1607                 case SS_CF_MODE_CFC:
1608                         reason = 5;
1609                 break;
1610
1611                 default:
1612                         dbg("unsupported reason : %d");
1613                         break;
1614         }
1615
1616         switch(op){
1617                 case TIZEN_SS_OPCO_DEACTIVATE:
1618                         mode = 0;
1619                 break;
1620                 case TIZEN_SS_OPCO_ACTIVATE:
1621                         mode = 1;
1622                 break;
1623                 case TIZEN_SS_OPCO_REG:
1624                         mode = 3;
1625                 break;
1626                 case TIZEN_SS_OPCO_DEREG:
1627                         mode = 4;
1628                 break;
1629
1630                 default:
1631                         dbg("unsupported opco : %d", op);
1632                         return TCORE_RETURN_FAILURE;
1633         }
1634
1635
1636 // class
1637         switch(forwarding->class)
1638         {
1639                 case SS_CLASS_ALL_TELE:
1640                         classx =7;
1641                 break;
1642                 case SS_CLASS_VOICE:
1643                         classx =1;
1644                 break;
1645                 case SS_CLASS_ALL_DATA_TELE:
1646                         classx =2;
1647                 break;
1648                 case SS_CLASS_FAX:
1649                         classx =4;
1650                 break;
1651                 case SS_CLASS_SMS:
1652                         classx = 8;
1653                 break;
1654                 case SS_CLASS_ALL_CS_SYNC:
1655                         classx = 16;
1656                 break;
1657
1658                 default:
1659                         classx =7;
1660                         dbg("unsupported class %d. set to default : 7", forwarding->class);
1661                 break;
1662         }
1663
1664 //number
1665         len = strlen(forwarding->number);
1666         if ( len > 0 ){
1667                 valid_num = TRUE;
1668                 if ( forwarding->number[0] == '+' )
1669                         num_type = ((TIZEN_NUM_TYPE_INTERNATIONAL << 4)|TIZEN_NUM_PLAN_ISDN);
1670                 else
1671                         num_type = 0;
1672         }
1673         user_data = g_new0( struct ss_confirm_info, 1 );
1674
1675         switch ( op ) {
1676                 case TIZEN_SS_OPCO_REG:
1677                         user_data->resp = TRESP_SS_FORWARDING_REGISTER;
1678                         break;
1679                 case TIZEN_SS_OPCO_DEREG:
1680                         user_data->resp = TRESP_SS_FORWARDING_DEREGISTER;
1681                         break;
1682                 case TIZEN_SS_OPCO_ACTIVATE:
1683                         user_data->resp = TRESP_SS_FORWARDING_ACTIVATE;
1684                         break;
1685                 case TIZEN_SS_OPCO_DEACTIVATE:
1686                         user_data->resp = TRESP_SS_FORWARDING_DEACTIVATE;
1687                         break;
1688                 default:
1689                         dbg("[ error ] unknown op ( 0x%x )", op );
1690                         break;
1691         }
1692
1693         if(op == TIZEN_SS_OPCO_REG)
1694                 tmp_str = g_strdup_printf("AT+CCFC=%d,%d,\"%s\",%d,%d", reason, mode, forwarding->number, num_type, classx);
1695         else// other opcode does not need num field
1696                 tmp_str = g_strdup_printf("AT+CCFC=%d,%d,,,%d", reason, mode, classx);
1697
1698         if(forwarding->mode == SS_CF_MODE_CFNRy){
1699                 //add time info to 'no reply' case
1700                 time = (int)(forwarding->time);
1701                 cmd_str = g_strdup_printf("%s,,,%d%s", tmp_str,time,"\r");
1702         }
1703         else    {
1704                 cmd_str = g_strdup_printf("%s%s", tmp_str,"\r");
1705         }
1706
1707         dbg("request command : %s", cmd_str);
1708
1709         user_data->flavor_type = forwarding->mode;
1710         user_data->class = forwarding->class;
1711
1712         ret = _ss_request_message( o, ur, cmd_str, strlen(cmd_str), on_response_ss_forwarding_set, user_data );
1713         g_free(tmp_str);
1714         g_free(cmd_str);
1715
1716         if ( !ret )
1717                 return TCORE_RETURN_FAILURE;
1718
1719         return TCORE_RETURN_SUCCESS;
1720 }
1721
1722 static TReturn _ss_forwarding_get(      CoreObject *o,
1723                                                                         UserRequest *ur,
1724                                                                         enum telephony_ss_class class,
1725                                                                         enum telephony_ss_forwarding_mode type,
1726                                                                         enum tcore_response_command resp )
1727 {
1728         TcorePlugin *p = 0;
1729         struct ss_confirm_info *user_data = 0;
1730
1731         gboolean ret = FALSE;
1732 //      int len = 0;
1733
1734         struct ATReqMetaInfo metainfo;
1735         int info_len=0, reason=0, mode=0, classx =0;
1736         char* cmd_str = NULL;
1737
1738         p       = tcore_object_ref_plugin( o );
1739
1740         memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
1741         metainfo.type = MULTILINE;
1742         memcpy(metainfo.responsePrefix,"+CCFC:",strlen("+CCFC:"));
1743         info_len = sizeof(struct ATReqMetaInfo);
1744
1745         tcore_user_request_set_metainfo(ur, info_len, &metainfo);
1746
1747         switch(type)
1748         {
1749                 case SS_CF_MODE_CFU:
1750                         reason =0;
1751                 break;
1752                 case SS_CF_MODE_CFB:
1753                         reason =1;
1754                 break;
1755                 case SS_CF_MODE_CFNRy:
1756                         reason =2;
1757                 break;
1758                 case SS_CF_MODE_CFNRc:
1759                         reason =3;
1760                 break;
1761                 case SS_CF_MODE_CF_ALL:
1762                         reason = 4;
1763                 break;
1764                 case SS_CF_MODE_CFC:
1765                         reason = 5;
1766                 break;
1767
1768                 default:
1769                         dbg("unsupported reason : %d");
1770                 break;
1771         }
1772
1773         switch(class)
1774         {
1775                 case SS_CLASS_ALL_TELE:
1776                         classx =7;
1777                 break;
1778                 case SS_CLASS_VOICE:
1779                         classx =1;
1780                 break;
1781                 case SS_CLASS_ALL_DATA_TELE:
1782                         classx =2;
1783                 break;
1784                 case SS_CLASS_FAX:
1785                         classx =4;
1786                 break;
1787                 case SS_CLASS_SMS:
1788                         classx = 8;
1789                 break;
1790                 case SS_CLASS_ALL_CS_SYNC:
1791                         classx = 16;
1792                 break;
1793                 default:
1794                         classx =7;
1795                         dbg("unsupported class %d. set to default : 7", class);
1796                 break;
1797         }
1798
1799         //query status - mode set to 2
1800         mode =2;
1801
1802         user_data = g_new0( struct ss_confirm_info, 1 );
1803         user_data->resp = resp;
1804
1805         user_data->class = class;
1806         user_data->flavor_type = type;
1807
1808         if(classx ==7)
1809                 cmd_str = g_strdup_printf("AT+CCFC=%d,%d%s", reason, mode,"\r");
1810         else
1811                 cmd_str = g_strdup_printf("AT+CCFC=%d,%d,,,%d%s", reason, mode,classx,"\r");
1812
1813         dbg("request command : %s", cmd_str);
1814         ret = _ss_request_message( o, ur, cmd_str, strlen(cmd_str), on_response_ss_forwarding_get, user_data );
1815         g_free(cmd_str);
1816
1817         if ( !ret )
1818                 return TCORE_RETURN_FAILURE;
1819
1820         return TCORE_RETURN_SUCCESS;
1821 }
1822
1823 static TReturn s_ss_forwarding_activate( CoreObject *o, UserRequest *ur )
1824 {
1825         return _ss_forwarding_set( o, ur, TIZEN_SS_OPCO_ACTIVATE );
1826 }
1827
1828 static TReturn s_ss_forwarding_deactivate( CoreObject *o, UserRequest *ur )
1829 {
1830         return _ss_forwarding_set( o, ur, TIZEN_SS_OPCO_DEACTIVATE );
1831 }
1832
1833 static TReturn s_ss_forwarding_register( CoreObject *o, UserRequest *ur )
1834 {
1835         return _ss_forwarding_set( o, ur, TIZEN_SS_OPCO_REG );
1836 }
1837
1838 static TReturn s_ss_forwarding_deregister( CoreObject *o, UserRequest *ur )
1839 {
1840         return _ss_forwarding_set( o, ur, TIZEN_SS_OPCO_DEREG );
1841 }
1842
1843 static TReturn s_ss_forwarding_get_status( CoreObject *o, UserRequest *ur )
1844 {
1845         struct treq_ss_forwarding *forwarding = 0;
1846         forwarding = (struct treq_ss_forwarding*)tcore_user_request_ref_data( ur, 0 );
1847
1848         return _ss_forwarding_get( o, ur, forwarding->class, forwarding->mode, TRESP_SS_FORWARDING_GET_STATUS );
1849 }
1850
1851 static TReturn _ss_waiting_set( CoreObject *o, UserRequest *ur, enum telephony_ss_opcode opco )
1852 {
1853         TcorePlugin *p = 0;
1854         struct treq_ss_waiting *waiting = 0;
1855
1856         struct ss_confirm_info *user_data = 0;
1857
1858         gboolean ret = FALSE;
1859         int mode=0, classx=0;
1860         char* cmd_str;
1861         struct ATReqMetaInfo metainfo;
1862
1863 //set metainfo
1864         memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
1865         metainfo.type = NO_RESULT;
1866         metainfo.responsePrefix[0] ='\0';
1867
1868         tcore_user_request_set_metainfo(ur, sizeof(struct ATReqMetaInfo), &metainfo);
1869
1870         p       = tcore_object_ref_plugin( o );
1871
1872         waiting = (struct treq_ss_waiting*) tcore_user_request_ref_data( ur, 0 );
1873
1874         user_data = g_new0( struct ss_confirm_info, 1 );
1875
1876         if ( opco == TIZEN_SS_OPCO_ACTIVATE ){
1877                 user_data->resp = TRESP_SS_WAITING_ACTIVATE;
1878                 mode = 1;//enable
1879         }
1880         else if ( opco == TIZEN_SS_OPCO_DEACTIVATE ){
1881                 user_data->resp = TRESP_SS_WAITING_DEACTIVATE;
1882                 mode =0; //diable
1883         }
1884         else
1885                 dbg("[ error ] unknown ss mode (0x%x)", opco);
1886
1887         switch(waiting->class)
1888         {
1889                 case SS_CLASS_ALL_TELE:
1890                         classx =7;
1891                         break;
1892                 case SS_CLASS_VOICE:
1893                         classx =1;
1894                         break;
1895                 case SS_CLASS_ALL_DATA_TELE:
1896                         classx =2;
1897                         break;
1898                 case SS_CLASS_FAX:
1899                         classx =4;
1900                         break;
1901                 case SS_CLASS_SMS:
1902                         classx = 8;
1903                         break;
1904
1905                 default:
1906                         classx =7;
1907                         dbg("unsupported class %d. set to default : 7", waiting->class);
1908                         break;
1909         }
1910
1911
1912 user_data->class = waiting->class;
1913         user_data->flavor_type = (int)opco;
1914
1915         cmd_str = g_strdup_printf("AT+CCWA=1,%d,%d%s", mode, classx,"\r"); //always enable +CCWA: unsolicited cmd
1916         dbg("request command : %s",cmd_str);
1917
1918         ret = _ss_request_message( o, ur, cmd_str, strlen(cmd_str), on_response_ss_waiting_set, user_data );
1919
1920         g_free(cmd_str);
1921         if ( !ret )
1922                 return TCORE_RETURN_FAILURE;
1923
1924         return TCORE_RETURN_SUCCESS;
1925 }
1926
1927 static TReturn _ss_waiting_get( CoreObject *o,
1928                                                                 UserRequest *ur,
1929                                                                 enum telephony_ss_class class,
1930                                                                 enum tcore_response_command resp )
1931 {
1932         TcorePlugin *p = 0;
1933
1934         struct ss_confirm_info *user_data = 0;
1935
1936         gboolean ret = FALSE;
1937         int classx, info_len=0;//mode,
1938         char* cmd_str;
1939         struct ATReqMetaInfo metainfo;
1940
1941 //set metainfo
1942         memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
1943         metainfo.type = MULTILINE;
1944         memcpy(metainfo.responsePrefix,"+CCWA:",strlen("+CCWA:"));
1945         info_len = sizeof(struct ATReqMetaInfo);
1946
1947         tcore_user_request_set_metainfo(ur, sizeof(struct ATReqMetaInfo), &metainfo);
1948
1949         p       = tcore_object_ref_plugin( o );
1950
1951         switch(class)
1952         {
1953                 case SS_CLASS_ALL_TELE:
1954                         classx =7;
1955                 break;
1956                 case SS_CLASS_VOICE:
1957                         classx =1;
1958                 break;
1959                 case SS_CLASS_ALL_DATA_TELE:
1960                         classx =2;
1961                 break;
1962                 case SS_CLASS_FAX:
1963                         classx =4;
1964                 break;
1965                 case SS_CLASS_SMS:
1966                         classx = 8;
1967                 break;
1968
1969                 default:
1970                         classx =7;
1971                         dbg("unsupported class %d. set to default : 7", class);
1972                 break;
1973         }
1974
1975         dbg("allocating user data");
1976         user_data = g_new0( struct ss_confirm_info, 1 );
1977         user_data->resp = resp;
1978         user_data->class = class;
1979
1980         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)
1981         dbg("request cmd : %s", cmd_str);
1982
1983         ret = _ss_request_message( o, ur, cmd_str, strlen(cmd_str), on_response_ss_waiting_get, user_data );
1984
1985         g_free(cmd_str);
1986
1987         if ( !ret )
1988                 return TCORE_RETURN_FAILURE;
1989
1990         return TCORE_RETURN_SUCCESS;
1991 }
1992
1993 static TReturn s_ss_waiting_activate( CoreObject *o, UserRequest *ur )
1994 {
1995         return _ss_waiting_set( o, ur, TIZEN_SS_OPCO_ACTIVATE );
1996 }
1997
1998 static TReturn s_ss_waiting_deactivate( CoreObject *o, UserRequest *ur )
1999 {
2000         return _ss_waiting_set( o, ur, TIZEN_SS_OPCO_DEACTIVATE );
2001 }
2002
2003 static TReturn s_ss_waiting_get_status( CoreObject *o, UserRequest *ur )
2004 {
2005         struct treq_ss_waiting *waiting = 0;
2006         waiting = (struct treq_ss_waiting*)tcore_user_request_ref_data( ur, 0 );
2007
2008         return _ss_waiting_get( o, ur, waiting->class, TRESP_SS_WAITING_GET_STATUS );
2009 }
2010
2011 static TReturn s_ss_cli_activate( CoreObject *o, UserRequest *ur )
2012 {
2013         return TCORE_RETURN_SUCCESS;
2014 }
2015
2016 static TReturn s_ss_cli_deactivate( CoreObject *o, UserRequest *ur )
2017 {
2018         return TCORE_RETURN_SUCCESS;
2019 }
2020
2021 static TReturn s_ss_cli_get_status( CoreObject *o, UserRequest *ur )
2022 {
2023         TcorePlugin *p = 0;
2024
2025         struct treq_ss_cli *cli = 0;
2026         gboolean ret = FALSE;
2027         char *cmd_prefix = NULL, *rsp_prefix = NULL, *cmd_str = NULL;
2028         struct ATReqMetaInfo metainfo;
2029         enum  telephony_ss_cli_type *user_data = 0;
2030
2031         int info_len =0;
2032
2033         p = tcore_object_ref_plugin(o);
2034
2035         cli = (struct treq_ss_cli*)tcore_user_request_ref_data( ur, 0 );
2036
2037         switch(cli->type){
2038                 case SS_CLI_TYPE_CLIP:
2039                         cmd_prefix = "+CLIP";
2040                         rsp_prefix = "+CLIP:";
2041                 break;
2042
2043                 case SS_CLI_TYPE_CLIR:
2044                         cmd_prefix = "+CLIR";
2045                         rsp_prefix = "+CLIR:";
2046                 break;
2047
2048                 case SS_CLI_TYPE_COLP:
2049                         cmd_prefix = "+COLP";
2050                         rsp_prefix = "+COLP:";
2051                 break;
2052
2053                 case SS_CLI_TYPE_CDIP:
2054                         cmd_prefix = "+CDIP";
2055                         rsp_prefix = "+CDIP:";
2056                 break;
2057
2058                 default:
2059                         dbg("unsupported cli_type : %d", cli->type);
2060                         return TCORE_RETURN_FAILURE;
2061                 break;
2062         }
2063
2064         dbg("cmd_prefix : %s",cmd_prefix);
2065
2066 //set metaInfo
2067         memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
2068         metainfo.type = SINGLELINE;
2069         memcpy(metainfo.responsePrefix,rsp_prefix,strlen(rsp_prefix));
2070         info_len = sizeof(struct ATReqMetaInfo);
2071
2072         tcore_user_request_set_metainfo(ur, sizeof(struct ATReqMetaInfo), &metainfo);
2073
2074         //make cmd string
2075
2076         cmd_str = g_strdup_printf("AT%s?%s", cmd_prefix, "\r");
2077         dbg("request cmd : %s", cmd_str);
2078
2079         // make userinfo for callback
2080         user_data = g_new0( enum telephony_ss_cli_type, 1 );
2081         *user_data = cli->type;
2082
2083         ret = _ss_request_message( o, ur, cmd_str, strlen(cmd_str), on_response_ss_waiting_get, user_data );
2084
2085         g_free(cmd_str);
2086
2087         if ( !ret )
2088                 return TCORE_RETURN_FAILURE;
2089
2090         return TCORE_RETURN_SUCCESS;
2091 }
2092
2093 static TReturn s_ss_send_ussd( CoreObject *o, UserRequest *ur )
2094 {
2095         TcorePlugin *p = 0;
2096         UssdSession *ussd_s = 0;
2097
2098         struct treq_ss_ussd *ussd = 0;
2099         struct ss_confirm_info *user_data = 0;
2100
2101         gboolean ret = FALSE;
2102         char* cmd_str;
2103         struct ATReqMetaInfo metainfo;
2104
2105         //set metainfo
2106         memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
2107         metainfo.type = NO_RESULT;
2108         metainfo.responsePrefix[0] ='\0';
2109         tcore_user_request_set_metainfo(ur, sizeof(struct ATReqMetaInfo), &metainfo);
2110
2111         p = tcore_object_ref_plugin(o);
2112         ussd = (struct treq_ss_ussd*)tcore_user_request_ref_data( ur, 0 );
2113
2114         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
2115         dbg("request command : %s",cmd_str);
2116
2117
2118         user_data = g_new0( struct ss_confirm_info, 1 );
2119         user_data->resp = TRESP_SS_SEND_USSD;
2120
2121         ussd_s = tcore_ss_ussd_get_session( o );
2122         if ( !ussd_s ) {
2123                 tcore_ss_ussd_create_session( o, (enum tcore_ss_ussd_type)ussd->type, (void*)tcore_user_request_ref(ur), 0 );
2124         } else {
2125
2126                 if ( ussd->type == SS_USSD_TYPE_USER_INITIATED ) {
2127                         dbg("[ error ] ussd session is already exist");
2128
2129                         g_free( user_data );
2130                         return TCORE_RETURN_FAILURE;
2131                 }
2132
2133                 tcore_ss_ussd_set_session_type( ussd_s, (enum tcore_ss_ussd_type)ussd->type);
2134         }
2135
2136         ret = _ss_request_message( o, ur, cmd_str, strlen(cmd_str), on_confirmation_ss_ussd, user_data );
2137
2138         if ( !ret )
2139                 return TCORE_RETURN_FAILURE;
2140
2141
2142         return TCORE_RETURN_SUCCESS;
2143 }
2144
2145 static TReturn s_ss_set_aoc( CoreObject *o, UserRequest *ur )
2146 {
2147         dbg("[ error ] unsupported function");
2148         return TCORE_RETURN_SUCCESS;
2149 }
2150
2151 static TReturn s_ss_get_aoc( CoreObject *o, UserRequest *ur )
2152 {
2153         dbg("[ error ] unsupported function");
2154         return TCORE_RETURN_SUCCESS;
2155 }
2156
2157 static struct tcore_call_control_operations call_ops = {
2158         .answer_hold_and_accept = s_ss_manage_call_2_send,
2159         .answer_replace                 = s_ss_manage_call_1_send,
2160         .answer_reject                  = s_ss_manage_call_0_send,
2161         .end_specific                   = s_ss_manage_call_1x_send,
2162         .end_all_active                 = s_ss_manage_call_1_send,
2163         .end_all_held                   = s_ss_manage_call_0_send,
2164         .active                                 = s_ss_manage_call_2_send,
2165         .hold                                   = s_ss_manage_call_2_send,
2166         .swap                                   = s_ss_manage_call_2_send,
2167         .join                                   = s_ss_manage_call_3_send,
2168         .split                                  = s_ss_manage_call_2x_send,
2169         .transfer                               = s_ss_manage_call_4_send,
2170         .deflect                                = s_ss_manage_call_4dn_send,
2171 };
2172
2173 static TReturn s_ss_manage_call_0_send( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data )
2174 {
2175         TcorePlugin *p = NULL;
2176         TcoreHal *h = NULL;
2177         TcorePending *pending = NULL;
2178         char*                                           cmd_str = NULL;
2179         struct ATReqMetaInfo metainfo;
2180         int info_len =0;
2181
2182         p = tcore_object_ref_plugin(o);
2183         h = tcore_object_get_hal(o);
2184
2185         memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
2186         metainfo.type = NO_RESULT;
2187         metainfo.responsePrefix[0] ='\0';
2188         info_len = sizeof(struct ATReqMetaInfo);
2189
2190         tcore_user_request_set_metainfo(ur, info_len, &metainfo);
2191
2192         cmd_str = g_strdup_printf("%s%s", "AT+CHLD=0", "\r");
2193         dbg("cmd : %s, prefix(if any) : %s, cmd_len : %d",cmd_str, "N/A", strlen(cmd_str));
2194
2195         pending = tcore_pending_new(o, ID_RESERVED_AT);
2196         tcore_pending_set_request_data(pending, strlen(cmd_str), cmd_str);
2197         g_free(cmd_str);
2198         tcore_pending_set_timeout(pending, 0);
2199         tcore_pending_set_response_callback(pending, (TcorePendingResponseCallback)cb, user_data);
2200         tcore_pending_link_user_request(pending, ur);
2201         tcore_pending_set_priority(pending, TCORE_PENDING_PRIORITY_DEFAULT);
2202
2203         tcore_pending_set_send_callback(pending, on_confirmation_call_control_ss_message_send, NULL);
2204
2205
2206         tcore_hal_send_request(h, pending);
2207
2208         return TCORE_RETURN_SUCCESS;
2209 }
2210
2211 static TReturn s_ss_manage_call_1_send( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data )
2212 {
2213         TcorePlugin *p = NULL;
2214         TcoreHal *h = NULL;
2215         TcorePending *pending = NULL;
2216         char*                                           cmd_str = NULL;
2217         struct ATReqMetaInfo metainfo;
2218         int info_len =0;
2219
2220         p = tcore_object_ref_plugin(o);
2221         h = tcore_object_get_hal(o);
2222
2223         memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
2224         metainfo.type = NO_RESULT;
2225         metainfo.responsePrefix[0] ='\0';
2226         info_len = sizeof(struct ATReqMetaInfo);
2227
2228         tcore_user_request_set_metainfo(ur, info_len, &metainfo);
2229
2230         cmd_str = g_strdup_printf("%s%s", "AT+CHLD=1", "\r");
2231         dbg("cmd : %s, prefix(if any) : %s, cmd_len : %d",cmd_str, "N/A", strlen(cmd_str));
2232
2233         pending = tcore_pending_new(o, ID_RESERVED_AT);
2234         tcore_pending_set_request_data(pending, strlen(cmd_str), cmd_str);
2235         g_free(cmd_str);
2236         tcore_pending_set_timeout(pending, 0);
2237         tcore_pending_set_response_callback(pending, (TcorePendingResponseCallback)cb, user_data);
2238         tcore_pending_link_user_request(pending, ur);
2239         tcore_pending_set_priority(pending, TCORE_PENDING_PRIORITY_DEFAULT);
2240
2241         tcore_pending_set_send_callback(pending, on_confirmation_call_control_ss_message_send, NULL);
2242
2243
2244         tcore_hal_send_request(h, pending);
2245
2246         return TCORE_RETURN_SUCCESS;
2247 }
2248
2249 static TReturn s_ss_manage_call_1x_send( CoreObject* o, UserRequest* ur, const int id, ConfirmCallback cb, void* user_data )
2250 {
2251         TcorePlugin *p = NULL;
2252         TcoreHal *h = NULL;
2253         TcorePending *pending = NULL;
2254         char*                                           cmd_str = NULL;
2255         struct ATReqMetaInfo metainfo;
2256         int info_len =0;
2257
2258         p = tcore_object_ref_plugin(o);
2259         h = tcore_object_get_hal(o);
2260
2261         memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
2262         metainfo.type = NO_RESULT;
2263         metainfo.responsePrefix[0] ='\0';
2264         info_len = sizeof(struct ATReqMetaInfo);
2265
2266         tcore_user_request_set_metainfo(ur, info_len, &metainfo);
2267
2268         cmd_str = g_strdup_printf("%s%d%s", "AT+CHLD=1", id,"\r");
2269         dbg("cmd : %s, prefix(if any) : %s, cmd_len : %d",cmd_str, "N/A", strlen(cmd_str));
2270
2271         pending = tcore_pending_new(o, ID_RESERVED_AT);
2272         tcore_pending_set_request_data(pending, strlen(cmd_str), cmd_str);
2273         g_free(cmd_str);
2274         tcore_pending_set_timeout(pending, 0);
2275         tcore_pending_set_response_callback(pending, (TcorePendingResponseCallback)cb, user_data);
2276         tcore_pending_link_user_request(pending, ur);
2277         tcore_pending_set_priority(pending, TCORE_PENDING_PRIORITY_DEFAULT);
2278
2279         tcore_pending_set_send_callback(pending, on_confirmation_call_control_ss_message_send, NULL);
2280
2281
2282         tcore_hal_send_request(h, pending);
2283
2284         return TCORE_RETURN_SUCCESS;
2285 }
2286
2287 static TReturn s_ss_manage_call_2_send( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data )
2288 {
2289         TcorePlugin *p = NULL;
2290         TcoreHal *h = NULL;
2291         TcorePending *pending = NULL;
2292         char*                                           cmd_str = NULL;
2293         struct ATReqMetaInfo metainfo;
2294         int info_len =0;
2295
2296         p = tcore_object_ref_plugin(o);
2297         h = tcore_object_get_hal(o);
2298
2299         memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
2300         metainfo.type = NO_RESULT;
2301         metainfo.responsePrefix[0] ='\0';
2302         info_len = sizeof(struct ATReqMetaInfo);
2303
2304         tcore_user_request_set_metainfo(ur, info_len, &metainfo);
2305
2306         cmd_str = g_strdup_printf("%s%s", "AT+CHLD=2", "\r");
2307         dbg("cmd : %s, prefix(if any) : %s, cmd_len : %d",cmd_str, "N/A", strlen(cmd_str));
2308
2309         pending = tcore_pending_new(o, ID_RESERVED_AT);
2310         tcore_pending_set_request_data(pending, strlen(cmd_str), cmd_str);
2311         g_free(cmd_str);
2312         tcore_pending_set_timeout(pending, 0);
2313         tcore_pending_set_response_callback(pending, (TcorePendingResponseCallback)cb, user_data);
2314         tcore_pending_link_user_request(pending, ur);
2315         tcore_pending_set_priority(pending, TCORE_PENDING_PRIORITY_DEFAULT);
2316
2317         tcore_pending_set_send_callback(pending, on_confirmation_call_control_ss_message_send, NULL);
2318
2319
2320         tcore_hal_send_request(h, pending);
2321
2322         return TCORE_RETURN_SUCCESS;
2323 }
2324
2325 static TReturn s_ss_manage_call_2x_send( CoreObject* o, UserRequest* ur, const int id, ConfirmCallback cb, void* user_data )
2326 {
2327         TcorePlugin *p = NULL;
2328         TcoreHal *h = NULL;
2329         TcorePending *pending = NULL;
2330         char*                                           cmd_str = NULL;
2331         struct ATReqMetaInfo metainfo;
2332         int info_len =0;
2333
2334         p = tcore_object_ref_plugin(o);
2335         h = tcore_object_get_hal(o);
2336
2337         memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
2338         metainfo.type = NO_RESULT;
2339         metainfo.responsePrefix[0] ='\0';
2340         info_len = sizeof(struct ATReqMetaInfo);
2341
2342         tcore_user_request_set_metainfo(ur, info_len, &metainfo);
2343
2344         cmd_str = g_strdup_printf("%s%d%s", "AT+CHLD=2", id,"\r");
2345         dbg("cmd : %s, prefix(if any) : %s, cmd_len : %d",cmd_str, "N/A", strlen(cmd_str));
2346
2347         pending = tcore_pending_new(o, ID_RESERVED_AT);
2348         tcore_pending_set_request_data(pending, strlen(cmd_str), cmd_str);
2349         g_free(cmd_str);
2350         tcore_pending_set_timeout(pending, 0);
2351         tcore_pending_set_response_callback(pending, (TcorePendingResponseCallback)cb, user_data);
2352         tcore_pending_link_user_request(pending, ur);
2353         tcore_pending_set_priority(pending, TCORE_PENDING_PRIORITY_DEFAULT);
2354
2355         tcore_pending_set_send_callback(pending, on_confirmation_call_control_ss_message_send, NULL);
2356
2357
2358         tcore_hal_send_request(h, pending);
2359
2360         return TCORE_RETURN_SUCCESS;
2361 }
2362
2363 static TReturn s_ss_manage_call_3_send( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data )
2364 {
2365 //      gboolean ret = FALSE;
2366         TcorePlugin *p = NULL;
2367         TcoreHal *h = NULL;
2368         TcorePending *pending = NULL;
2369         char* cmd_str = NULL;
2370         struct ATReqMetaInfo metainfo;
2371         int info_len =0;
2372
2373         GSList *l = 0;
2374         CallObject *co = 0;
2375         int id = 0;
2376
2377         l = tcore_call_object_find_by_status( o, CALL_STATUS_ACTIVE );
2378         if ( !l || !l->data ) {
2379                 dbg("[ error ] there is no call status [ call_active ]");
2380                 return TCORE_RETURN_FAILURE;
2381         }
2382
2383         co = l->data;
2384         id = tcore_call_object_get_id( co );
2385         dbg("active call id : [ %d ]");
2386
2387         p = tcore_object_ref_plugin(o);
2388         h = tcore_object_get_hal(o);
2389
2390         memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
2391         metainfo.type = NO_RESULT;
2392         metainfo.responsePrefix[0] ='\0';
2393         info_len = sizeof(struct ATReqMetaInfo);
2394
2395         tcore_user_request_set_metainfo(ur, info_len, &metainfo);
2396
2397         cmd_str = g_strdup_printf("%s%s", "AT+CHLD=3","\r");
2398
2399         dbg("cmd : %s, prefix(if any) : %s, cmd_len : %d",cmd_str, "N/A", strlen(cmd_str));
2400
2401         pending = tcore_pending_new(o, ID_RESERVED_AT);
2402         tcore_pending_set_request_data(pending, strlen(cmd_str), cmd_str);
2403         g_free(cmd_str);
2404         tcore_pending_set_timeout(pending, 0);
2405         tcore_pending_set_response_callback(pending, (TcorePendingResponseCallback)cb, user_data);
2406         tcore_pending_link_user_request(pending, ur);
2407         tcore_pending_set_priority(pending, TCORE_PENDING_PRIORITY_DEFAULT);
2408
2409         tcore_pending_set_send_callback(pending, on_confirmation_call_control_ss_message_send, NULL);
2410
2411
2412         tcore_hal_send_request(h, pending);
2413
2414         return TCORE_RETURN_SUCCESS;
2415 }
2416
2417 static TReturn s_ss_manage_call_4_send( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data )
2418 {
2419         TcorePlugin *p = NULL;
2420         TcoreHal *h = NULL;
2421         TcorePending *pending = NULL;
2422         char*                                           cmd_str = NULL;
2423         struct ATReqMetaInfo metainfo;
2424         int info_len =0;
2425
2426         p = tcore_object_ref_plugin(o);
2427         h = tcore_object_get_hal(o);
2428
2429         memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
2430         metainfo.type = NO_RESULT;
2431         metainfo.responsePrefix[0] ='\0';
2432         info_len = sizeof(struct ATReqMetaInfo);
2433
2434         tcore_user_request_set_metainfo(ur, info_len, &metainfo);
2435
2436
2437         cmd_str = g_strdup_printf("%s%s", "AT+CHLD=4", "\r");
2438
2439         dbg("cmd : %s, prefix(if any) : %s, cmd_len : %d",cmd_str, "N/A", strlen(cmd_str));
2440
2441         pending = tcore_pending_new(o, ID_RESERVED_AT);
2442         tcore_pending_set_request_data(pending, strlen(cmd_str), cmd_str);
2443         g_free(cmd_str);
2444         tcore_pending_set_timeout(pending, 0);
2445         tcore_pending_set_response_callback(pending, (TcorePendingResponseCallback)cb, user_data);
2446         tcore_pending_link_user_request(pending, ur);
2447         tcore_pending_set_priority(pending, TCORE_PENDING_PRIORITY_DEFAULT);
2448
2449         tcore_pending_set_send_callback(pending, on_confirmation_call_control_ss_message_send, NULL);
2450
2451
2452         tcore_hal_send_request(h, pending);
2453
2454         return TCORE_RETURN_SUCCESS;
2455 }
2456
2457 static TReturn s_ss_manage_call_4dn_send( CoreObject* o, UserRequest* ur, const char* number, ConfirmCallback cb, void* user_data )
2458 {
2459         TcorePlugin *p = NULL;
2460         TcoreHal *h = NULL;
2461         TcorePending *pending = NULL;
2462         char*                                           cmd_str = NULL;
2463         struct ATReqMetaInfo metainfo;
2464         int info_len =0;
2465
2466         p = tcore_object_ref_plugin(o);
2467         h = tcore_object_get_hal(o);
2468
2469         memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
2470         metainfo.type = NO_RESULT;
2471         metainfo.responsePrefix[0] ='\0';
2472         info_len = sizeof(struct ATReqMetaInfo);
2473
2474         tcore_user_request_set_metainfo(ur, info_len, &metainfo);
2475
2476
2477         cmd_str = g_strdup_printf("%s%s%s", "AT+CHLD=4", number,"\r");
2478
2479         dbg("cmd : %s, prefix(if any) : %s, cmd_len : %d",cmd_str, "N/A", strlen(cmd_str));
2480
2481         pending = tcore_pending_new(o, ID_RESERVED_AT);
2482         tcore_pending_set_request_data(pending, strlen(cmd_str), cmd_str);
2483         g_free(cmd_str);
2484         tcore_pending_set_timeout(pending, 0);
2485         tcore_pending_set_response_callback(pending, (TcorePendingResponseCallback)cb, user_data);
2486         tcore_pending_link_user_request(pending, ur);
2487         tcore_pending_set_priority(pending, TCORE_PENDING_PRIORITY_DEFAULT);
2488
2489         tcore_pending_set_send_callback(pending, on_confirmation_call_control_ss_message_send, NULL);
2490
2491
2492         tcore_hal_send_request(h, pending);
2493
2494         return TCORE_RETURN_SUCCESS;
2495 }
2496
2497 #if 0
2498 static TReturn s_ss_manage_call_5_send( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data )
2499 {
2500         TcorePlugin *p = NULL;
2501         TcoreHal *h = NULL;
2502         TcorePending *pending = NULL;
2503         char*                                           cmd_str = NULL;
2504         struct ATReqMetaInfo metainfo;
2505         int info_len =0;
2506
2507         p = tcore_object_ref_plugin(o);
2508         h = tcore_object_get_hal(o);
2509
2510         memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
2511         metainfo.type = NO_RESULT;
2512         metainfo.responsePrefix[0] ='\0';
2513         info_len = sizeof(struct ATReqMetaInfo);
2514
2515         tcore_user_request_set_metainfo(ur, info_len, &metainfo);
2516
2517
2518         cmd_str = g_strdup_printf("%s%s", "AT+CHLD=5", "\r");
2519
2520         dbg("cmd : %s, prefix(if any) : %s, cmd_len : %d",cmd_str, "N/A", strlen(cmd_str));
2521
2522         pending = tcore_pending_new(o, ID_RESERVED_AT);
2523         tcore_pending_set_request_data(pending, strlen(cmd_str), cmd_str);
2524         g_free(cmd_str);
2525         tcore_pending_set_timeout(pending, 0);
2526         tcore_pending_set_response_callback(pending, (TcorePendingResponseCallback)cb, user_data);
2527         tcore_pending_link_user_request(pending, ur);
2528         tcore_pending_set_priority(pending, TCORE_PENDING_PRIORITY_DEFAULT);
2529
2530         tcore_pending_set_send_callback(pending, on_confirmation_call_control_ss_message_send, NULL);
2531
2532
2533         tcore_hal_send_request(h, pending);
2534
2535         return TCORE_RETURN_SUCCESS;
2536 }
2537
2538 static TReturn s_ss_manage_call_6_send( CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data )
2539 {
2540         TcorePlugin *p = NULL;
2541         TcoreHal *h = NULL;
2542         TcorePending *pending = NULL;
2543         char*                                           cmd_str = NULL;
2544         struct ATReqMetaInfo metainfo;
2545         int info_len =0;
2546
2547         p = tcore_object_ref_plugin(o);
2548         h = tcore_object_get_hal(o);
2549
2550         memset(&metainfo, 0, sizeof(struct ATReqMetaInfo));
2551         metainfo.type = NO_RESULT;
2552         metainfo.responsePrefix[0] ='\0';
2553         info_len = sizeof(struct ATReqMetaInfo);
2554
2555         tcore_user_request_set_metainfo(ur, info_len, &metainfo);
2556
2557
2558         cmd_str= g_strdup_printf("%s%s", "AT+CHLD=6", "\r");
2559
2560         dbg("cmd : %s, prefix(if any) : %s, cmd_len : %d",cmd_str, "N/A", strlen(cmd_str));
2561
2562         pending = tcore_pending_new(o, ID_RESERVED_AT);
2563         tcore_pending_set_request_data(pending, strlen(cmd_str), cmd_str);
2564         g_free(cmd_str);
2565         tcore_pending_set_timeout(pending, 0);
2566         tcore_pending_set_response_callback(pending, (TcorePendingResponseCallback)cb, user_data);
2567         tcore_pending_link_user_request(pending, ur);
2568         tcore_pending_set_priority(pending, TCORE_PENDING_PRIORITY_DEFAULT);
2569
2570         tcore_pending_set_send_callback(pending, on_confirmation_call_control_ss_message_send, NULL);
2571
2572
2573         tcore_hal_send_request(h, pending);
2574
2575         return TCORE_RETURN_SUCCESS;
2576 }
2577 #endif
2578
2579
2580 gboolean s_ss_init(TcorePlugin *p, TcoreHal *h)
2581 {
2582         CoreObject *so = 0, *co = 0;
2583         struct property_call_info *data = 0;
2584
2585         dbg("s_ss_init()");
2586
2587         so = tcore_ss_new(p, "ss", &ss_ops, h);
2588         if (!so) {
2589                 dbg("[ error ] ss_new()");
2590                 return FALSE;
2591         }
2592
2593         co = tcore_plugin_ref_core_object(p, "call");
2594         if (!co) {
2595                 dbg("[ error ] plugin_ref_core_object");
2596                 return FALSE;
2597         }
2598
2599         tcore_call_control_set_operations( co, &call_ops );
2600
2601         tcore_object_add_callback( so, EVENT_SS_INFO, on_notification_ss_info, 0 );
2602         tcore_object_add_callback( so, EVENT_SS_USSD, on_notification_ss_ussd, 0 );
2603
2604         data = calloc( sizeof(struct property_call_info *), 1);
2605         tcore_plugin_link_property(p, "SS", data);
2606
2607         return TRUE;
2608 }
2609
2610 void s_ss_exit( TcorePlugin *p )
2611 {
2612         CoreObject *o;
2613 //      TcoreHal *h;
2614         struct property_network_info *data;
2615
2616         o = tcore_plugin_ref_core_object(p, "ss");
2617
2618         data = tcore_plugin_ref_property(p, "SS");
2619         if (data)
2620                 free(data);
2621
2622         tcore_ss_free(o);
2623 }