4 * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
\r
6 * Contact: sharanayya mathapati <sharan.m@samsung.com>
\r
8 * Licensed under the Apache License, Version 2.0 (the "License");
\r
9 * you may not use this file except in compliance with the License.
\r
10 * You may obtain a copy of the License at
\r
12 * http://www.apache.org/licenses/LICENSE-2.0
\r
14 * Unless required by applicable law or agreed to in writing, software
\r
15 * distributed under the License is distributed on an "AS IS" BASIS,
\r
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
17 * See the License for the specific language governing permissions and
\r
18 * limitations under the License.
\r
29 #include <core_object.h>
\r
32 #include <co_call.h>
\r
34 #include <user_request.h>
\r
39 #include "s_common.h"
\r
42 #define NUM_TYPE_INTERNATIONAL 0x01
\r
43 #define NUM_PLAN_ISDN 0x01
\r
45 //To avoid sending multiple response to application
\r
46 static gboolean UssdResp = FALSE;
\r
48 enum telephony_ss_opcode
\r
50 SS_OPCO_REG=0x01, /* 0x01 : Registration */
\r
51 SS_OPCO_DEREG, /* 0x02 : De-registration(erase) */
\r
52 SS_OPCO_ACTIVATE, /* 0x03 : Activation */
\r
53 SS_OPCO_DEACTIVATE, /* 0x04 : De-activation */
\r
57 struct ss_confirm_info
\r
59 enum telephony_ss_class class;
\r
61 enum tcore_response_command resp;
\r
66 static gboolean _ss_request_message(TcorePending *pending,
\r
72 static TReturn _ss_barring_get(CoreObject *o,
\r
74 enum telephony_ss_class class,
\r
75 enum telephony_ss_barring_mode type,
\r
76 enum tcore_response_command resp);
\r
78 static TReturn _ss_forwarding_get(CoreObject *o,
\r
80 enum telephony_ss_class class,
\r
81 enum telephony_ss_forwarding_mode type,
\r
82 enum tcore_response_command resp);
\r
84 static TReturn _ss_waiting_get(CoreObject *o,
\r
86 enum telephony_ss_class class,
\r
87 enum tcore_response_command resp);
\r
89 static TReturn s_ss_barring_activate(CoreObject *o, UserRequest *ur);
\r
90 static TReturn s_ss_barring_deactivate(CoreObject *o, UserRequest *ur);
\r
91 static TReturn s_ss_barring_change_password(CoreObject *o, UserRequest *ur);
\r
92 static TReturn s_ss_barring_get_status(CoreObject *o, UserRequest *ur);
\r
94 static TReturn s_ss_forwarding_activate(CoreObject *o, UserRequest *ur);
\r
95 static TReturn s_ss_forwarding_deactivate(CoreObject *o, UserRequest *ur);
\r
96 static TReturn s_ss_forwarding_register(CoreObject *o, UserRequest *ur);
\r
97 static TReturn s_ss_forwarding_deregister(CoreObject *o, UserRequest *ur);
\r
98 static TReturn s_ss_forwarding_get_status(CoreObject *o, UserRequest *ur);
\r
100 static TReturn s_ss_waiting_activate(CoreObject *o, UserRequest *ur);
\r
101 static TReturn s_ss_waiting_deactivate(CoreObject *o, UserRequest *ur);
\r
102 static TReturn s_ss_waiting_get_status(CoreObject *o, UserRequest *ur);
\r
104 static TReturn s_ss_cli_activate(CoreObject *o, UserRequest *ur);
\r
105 static TReturn s_ss_cli_deactivate(CoreObject *o, UserRequest *ur);
\r
106 static TReturn s_ss_cli_get_status(CoreObject *o, UserRequest *ur);
\r
108 static TReturn s_ss_send_ussd(CoreObject *o, UserRequest *ur);
\r
110 static TReturn s_ss_set_aoc(CoreObject *o, UserRequest *ur);
\r
111 static TReturn s_ss_get_aoc(CoreObject *o, UserRequest *ur);
\r
113 static TReturn s_ss_manage_call_0_send(CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data);
\r
114 static TReturn s_ss_manage_call_1_send(CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data);
\r
115 static TReturn s_ss_manage_call_1x_send(CoreObject* o, UserRequest* ur, const int id, ConfirmCallback cb, void* user_data);
\r
116 static TReturn s_ss_manage_call_2_send(CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data);
\r
117 static TReturn s_ss_manage_call_2x_send(CoreObject* o, UserRequest* ur, const int id, ConfirmCallback cb, void* user_data);
\r
118 static TReturn s_ss_manage_call_3_send(CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data);
\r
119 static TReturn s_ss_manage_call_4_send(CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data);
\r
120 static TReturn s_ss_manage_call_4dn_send(CoreObject* o, UserRequest* ur, const char* number, ConfirmCallback cb, void* user_data);
\r
122 static void on_confirmation_ss_message_send(TcorePending *p, gboolean result, void *user_data);
\r
124 static void _ss_ussd_response(UserRequest *ur, const char* ussd_str, enum telephony_ss_ussd_type type, enum telephony_ss_ussd_status status);
\r
125 static void _ss_ussd_notification(TcorePlugin *p, const char* ussd_str, enum telephony_ss_ussd_status status);
\r
127 static gboolean on_notification_ss_info(CoreObject *o, const void *data, void *user_data);
\r
128 static gboolean on_notification_ss_ussd(CoreObject *o, const void *data, void *user_data);
\r
131 static gboolean _ss_request_message(TcorePending *pending,
\r
137 TcoreHal *hal = NULL;
\r
142 tcore_pending_set_response_callback(pending, on_resp, user_data);
\r
144 tcore_pending_set_send_callback(pending, on_confirmation_ss_message_send, NULL);
\r
146 tcore_pending_link_user_request(pending, ur);
\r
149 err("User Request is NULL, is this internal request??");
\r
152 hal = tcore_object_get_hal(o);
\r
154 // Send request to HAL
\r
155 ret = tcore_hal_send_request(hal, pending);
\r
156 if(TCORE_RETURN_SUCCESS != ret) {
\r
157 err("Request send failed");
\r
165 static void _ss_ussd_response(UserRequest *ur, const char* ussd_str, enum telephony_ss_ussd_type type, enum telephony_ss_ussd_status status)
\r
167 struct tresp_ss_ussd resp;
\r
171 memset (&resp, 0x0, sizeof(struct tresp_ss_ussd));
\r
173 resp.status = status;
\r
175 dbg("ussd_str = %s resp.type - %d resp.status - %d",ussd_str ,resp.type,resp.status);
\r
178 int len = strlen(ussd_str);
\r
179 if (len < MAX_SS_USSD_LEN) {
\r
180 memcpy(resp.str, ussd_str, len);
\r
181 resp.str[len] = '\0';
\r
184 memcpy(resp.str, ussd_str, MAX_SS_USSD_LEN);
\r
185 resp.str[MAX_SS_USSD_LEN - 1] = '\0';
\r
187 dbg("Response string: %s", resp.str);
\r
190 dbg("USSD string is not present");
\r
191 memset(resp.str, '\0', MAX_SS_USSD_LEN);
\r
194 // Send response to TAPI
\r
195 tcore_user_request_send_response(ur, TRESP_SS_SEND_USSD, sizeof(struct tresp_ss_ussd), &resp);
\r
198 err("User request is NULL");
\r
205 static void _ss_ussd_notification(TcorePlugin *p, const char* ussd_str, enum telephony_ss_ussd_status status)
\r
207 CoreObject *core_obj = 0;
\r
208 struct tnoti_ss_ussd noti;
\r
210 dbg("function enter");
\r
212 dbg("[ error ] p : (NULL)");
\r
215 noti.status = status;
\r
218 int len = strlen(ussd_str);
\r
219 if (len < MAX_SS_USSD_LEN) {
\r
220 memcpy(noti.str, ussd_str, len);
\r
221 noti.str[ len ] = '\0';
\r
224 memcpy(noti.str, ussd_str, MAX_SS_USSD_LEN);
\r
225 noti.str[ MAX_SS_USSD_LEN - 1 ] = '\0';
\r
230 memset(noti.str, '\0', MAX_SS_USSD_LEN);
\r
232 dbg("noti.str - %s", noti.str);
\r
234 core_obj = tcore_plugin_ref_core_object(p, "ss");
\r
235 tcore_server_send_notification(tcore_plugin_ref_server(p),
\r
238 sizeof(struct tnoti_ss_ussd),
\r
243 static gboolean on_notification_ss_ussd(CoreObject *o, const void *data, void *user_data)
\r
245 enum telephony_ss_ussd_status status;
\r
246 UssdSession *ussd_session = 0;
\r
247 char *ussd_str = 0, *cmd = 0;
\r
248 TcorePlugin *plugin = 0;
\r
249 int m = -1, dcs = 0;
\r
250 char *ussdnoti= NULL, *str = NULL, *dcs_str = NULL;
\r
251 GSList *tokens = NULL;
\r
252 GSList *lines = NULL;
\r
253 char *ussd_string = NULL;
\r
256 plugin = tcore_object_ref_plugin(o);
\r
257 ussd_session = tcore_ss_ussd_get_session(o);
\r
259 dbg("function enter");
\r
260 lines = (GSList*)data;
\r
261 if (1 != g_slist_length(lines)) {
\r
262 dbg("unsolicited msg but multiple line");
\r
265 cmd = (char*)(lines->data);
\r
266 // parse ussd status
\r
267 tokens = tcore_at_tok_new(cmd);
\r
270 ussdnoti = g_slist_nth_data(tokens, 0);
\r
272 dbg("+CUSD<m> is missing from %CUSD Notification");
\r
277 m = atoi(ussdnoti);
\r
278 dbg("USSD status %d",m);
\r
279 //parse [ <str>, <dcs>]
\r
280 ussd_string = g_slist_nth_data(tokens, 1);
\r
283 /* Strike off starting & ending quotes. 1 extra character for NULL termination */
\r
284 str = malloc(strlen(ussd_string) - 1);
\r
285 dbg("length of Ussd Stirng - %d", strlen(ussd_string));
\r
287 memset(str, 0x00, strlen(ussd_string) - 1);
\r
290 dbg("malloc failed")
\r
293 len = strlen(ussd_string)-1;
\r
295 strncpy(str, ussd_string, len);
\r
297 dbg("USSD String - %s len = %d",str,strlen(str));
\r
299 if((dcs_str = g_slist_nth_data(tokens, 2))) {
\r
300 dcs = atoi(dcs_str);
\r
301 dbg("USSD dcs %d",dcs);
\r
308 status = SS_USSD_NO_ACTION_REQUIRE;
\r
312 status = SS_USSD_ACTION_REQUIRE;
\r
316 status = SS_USSD_TERMINATED_BY_NET;
\r
320 status = SS_USSD_OTHER_CLIENT;
\r
324 status = SS_USSD_NOT_SUPPORT;
\r
328 status = SS_USSD_TIME_OUT;
\r
332 dbg("unsupported m : %d", m);
\r
333 status = SS_USSD_MAX;
\r
337 switch (tcore_util_get_cbs_coding_scheme(dcs)) {
\r
339 case TCORE_DCS_TYPE_7_BIT:
\r
340 case TCORE_DCS_TYPE_UNSPECIFIED:
\r
341 //ussd_str = tcore_util_unpack_gsm7bit(str, strlen(str));
\r
344 case TCORE_DCS_TYPE_UCS2:
\r
345 case TCORE_DCS_TYPE_8_BIT:
\r
346 if ( (str != NULL ) && (strlen(str) > 0))
\r
348 ussd_str = g_new0(char, strlen(str) + 1);
\r
349 if(ussd_str != NULL){
\r
350 memcpy(ussd_str,str, strlen(str));
\r
351 ussd_str[ strlen(str) ] = '\0';
\r
356 dbg("[ error ] unknown dcs type. ussd_session : %x", ussd_session);
\r
357 if (ussd_session) {
\r
359 UserRequest *ur = 0;
\r
360 enum telephony_ss_ussd_type type;
\r
362 tcore_ss_ussd_get_session_data(ussd_session, (void**)&ur);
\r
365 dbg("[ error ] ur : (0)");
\r
369 type = (enum telephony_ss_ussd_type)tcore_ss_ussd_get_session_type(ussd_session);
\r
370 dbg("ussd type - %d", type);
\r
372 _ss_ussd_response(ur, ussd_str, type, status);
\r
379 case SS_USSD_NO_ACTION_REQUIRE:
\r
380 case SS_USSD_ACTION_REQUIRE:
\r
381 case SS_USSD_OTHER_CLIENT:
\r
382 case SS_USSD_NOT_SUPPORT:
\r
383 case SS_USSD_TIME_OUT:
\r
385 if (ussd_session) {
\r
387 UserRequest *ur = 0;
\r
388 enum telephony_ss_ussd_type type;
\r
390 tcore_ss_ussd_get_session_data(ussd_session, (void**)&ur);
\r
392 dbg("[ error ] ur : (0)");
\r
395 type = (enum telephony_ss_ussd_type)tcore_ss_ussd_get_session_type(ussd_session);
\r
396 dbg("ussd type - %d", type);
\r
397 _ss_ussd_response(ur, (const char*)ussd_str, type, status);
\r
402 tcore_ss_ussd_create_session(o, TCORE_SS_USSD_TYPE_NETWORK_INITIATED, 0, 0);
\r
403 _ss_ussd_notification(plugin, (const char*)ussd_str, status);
\r
410 case SS_USSD_TERMINATED_BY_NET:
\r
413 UserRequest *ur = 0;
\r
414 tcore_ss_ussd_get_session_data(ussd_session, (void**)&ur);
\r
416 tcore_user_request_unref(ur);
\r
418 tcore_ss_ussd_destroy_session(ussd_session);
\r
429 tcore_at_tok_free(tokens);
\r
437 static gboolean on_notification_ss_info(CoreObject *o, const void *data, void *user_data)
\r
439 TcorePlugin *plugin = 0;
\r
440 CoreObject *co = 0;
\r
441 char* cmd = 0, *number = 0, *pos;
\r
442 int code1 = -1, code2 = -1, index = 0, ton = 0;
\r
443 char *str_code1, *str_code2, *str_ton ,*str_index;
\r
444 GSList *tokens = NULL;
\r
446 gboolean cssu = FALSE,cssi = FALSE;
\r
447 GSList *lines = NULL;
\r
449 dbg("function enter");
\r
451 plugin = tcore_object_ref_plugin(o);
\r
452 co = tcore_plugin_ref_core_object(plugin, "call");
\r
455 dbg("[ error ] plugin_ref_core_object : call");
\r
459 lines = (GSList*)data;
\r
460 if (1 != g_slist_length(lines)) {
\r
461 dbg("unsolicited msg but multiple line");
\r
465 cmd = (char*)(lines->data);
\r
466 pos = strchr(cmd, ':');
\r
468 dbg("[ error ] not valid SS- notification ");
\r
471 buf = calloc(pos - cmd + 2, 1);
\r
472 memcpy(buf, cmd, pos - cmd);
\r
473 dbg("buf is %s", buf);
\r
475 if(!strcmp(buf,"+CSSU")){
\r
477 dbg("SS - +CSSU indication");
\r
480 else if(!strcmp(buf,"+CSSI")) {
\r
482 dbg("SS - +CSSI indication");
\r
487 //handle %CSSU notification
\r
490 tokens = tcore_at_tok_new(cmd);
\r
492 str_code2 = g_slist_nth_data(tokens, 0);
\r
494 dbg("Code2 is missing from %CSSU indiaction");
\r
498 code2 = atoi(str_code2);
\r
499 //parse [ <index>, <number> <type>]
\r
500 if ((str_index = g_slist_nth_data(tokens, 1))) {
\r
501 index = atoi(str_index);
\r
504 if ((resp = g_slist_nth_data(tokens, 2))) {
505 // Strike off double quotes
506 number = util_removeQuotes(resp);
507 str_ton = g_slist_nth_data(tokens, 3);
\r
510 ton = atoi(str_ton);
\r
515 dbg("CSSU - code2 = %d index = %d number = %s type = %d", code2, index, number, ton);
\r
518 case 0: //this is a forwarded call (MT call setup)
\r
519 tcore_call_information_mt_forwarded_call(co, number);
\r
522 case 2: //call has been put on hold (during a voice call)
\r
523 tcore_call_information_held(co, number);
\r
526 case 3: //call has been retrieved (during a voice call)
\r
527 tcore_call_information_active(co, number);
\r
530 case 4: //multiparty call entered (during a voice call)
\r
531 tcore_call_information_joined(co, number);
\r
534 case 5: //call on hold has been released
\r
535 tcore_call_information_released_on_hold(co, number);
\r
538 case 6: //forward check SS message received (can be received whenever)
\r
539 tcore_call_information_cf_check_ss_message(co, number);
\r
542 case 7: //call is being connected (alerting) with the remote party in alerting state in explicit call transfer operation (during a voice call)
\r
543 tcore_call_information_transfer_alert(co, number);
\r
546 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)
\r
547 tcore_call_information_transfered(co, number);
\r
550 case 9: //this is a deflected call (MT call setup):
\r
551 tcore_call_information_mt_deflected_call(co, number);
\r
555 dbg("CSSU - unsupported code2 : %d",code2);
\r
559 //handle %CSSI notification
\r
563 tokens = tcore_at_tok_new(cmd);
\r
565 str_code1 = g_slist_nth_data(tokens, 0);
\r
567 dbg("Code1 is missing from %CSSI indiaction");
\r
570 code1 = atoi(str_code1);
\r
571 //parse [ <index> ]
\r
572 if ((str_index = g_slist_nth_data(tokens, 1))) {
\r
573 index = atoi(str_index);
\r
578 dbg("CSSI - code1 - %d index - %d ", code1, index);
\r
582 case 0: //Unconditional CF is active
\r
583 tcore_call_information_mo_cfu(co);
\r
586 case 1: //some of the conditional call forwarding are active
\r
587 tcore_call_information_mo_cfc(co);
\r
590 case 2: // outgoing call is forwarded
\r
591 tcore_call_information_mo_forwarded(co);
\r
594 case 3: // this call is waiting
\r
595 tcore_call_information_mo_waiting(co);
\r
598 case 5: // outgoing call is barred
\r
599 tcore_call_information_mo_barred_outgoing(co);
\r
602 case 6: // incoming call is barred
\r
603 tcore_call_information_mo_barred_incoming(co);
\r
606 case 7: // CLIR suppression rejected
\r
607 tcore_call_information_mo_clir_suppression_reject(co);
\r
610 case 8: // outgoing call is deflected
\r
611 tcore_call_information_mo_deflected(co);
\r
615 dbg("unsupported cmd : %d",code1);
\r
621 tcore_at_tok_free(tokens);
\r
627 static void on_confirmation_ss_message_send(TcorePending *p, gboolean result, void *user_data)
\r
631 if (result == FALSE) {
\r
640 static void on_response_ss_barring_set(TcorePending *p, int data_len, const void *data, void *user_data)
\r
643 struct ss_confirm_info *info = 0;
\r
644 enum telephony_ss_class class;
\r
647 struct tresp_ss_general resp;
\r
648 UserRequest *ur_dup=0;
\r
649 GSList *tokens=NULL;
\r
652 const TcoreATResponse* response;
\r
654 dbg("function enter");
\r
656 o = tcore_pending_ref_core_object(p);
\r
657 ur = tcore_pending_ref_user_request(p);
\r
659 info = (struct ss_confirm_info*)user_data;
\r
660 class = info->class;
\r
662 if (response->success > 0){
\r
663 dbg("RESPONSE OK");
\r
664 resp.err = TCORE_RETURN_SUCCESS;
\r
668 dbg("RESPONSE NOT OK");
\r
669 line = (const char*)response->final_response;
\r
670 tokens = tcore_at_tok_new(line);
\r
672 if (g_slist_length(tokens) < 1) {
\r
674 dbg("err cause not specified or string corrupted");
\r
675 resp.err = TCORE_RETURN_3GPP_ERROR;
\r
678 err = atoi(g_slist_nth_data(tokens, 0));
\r
679 // TODO: CMEE error mapping is required.
\r
680 resp.err = TCORE_RETURN_3GPP_ERROR;
\r
682 tcore_at_tok_free(tokens);
\r
685 dbg("on_response_ss_barring_set - rsp.err : %d, ur : %x flavor_type = %d", resp.err, ur , info->flavor_type);
\r
686 dbg("[ check ] class : 0x%x", info->class);
\r
688 if (response->success > 0) {
\r
690 if (info->class == SS_CLASS_VOICE) {
\r
692 class = SS_CLASS_ALL_TELE_BEARER;
\r
695 ur_dup = tcore_user_request_ref(ur);
\r
697 if (info->flavor_type == SS_BARR_MODE_AB || info->flavor_type == SS_BARR_MODE_AOB) {
\r
698 _ss_barring_get(o, ur_dup, class, SS_BARR_MODE_BAOC, info->resp);
\r
700 else if (info->flavor_type == SS_BARR_MODE_AIB) {
\r
701 _ss_barring_get(o, ur_dup, class, SS_BARR_MODE_BAIC, info->resp);
\r
704 _ss_barring_get(o, ur_dup, class, info->flavor_type, info->resp);
\r
709 tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_general), &resp);
\r
712 dbg("[ error ] ur is 0");
\r
717 static void on_response_ss_barring_change_pwd(TcorePending *p, int data_len, const void *data, void *user_data)
\r
719 const TcoreATResponse* response = data;
\r
720 struct ss_confirm_info *info = 0;
\r
722 struct tresp_ss_general resp;
\r
724 GSList *tokens=NULL;
\r
727 dbg("function enter");
\r
728 ur = tcore_pending_ref_user_request(p);
\r
729 info = (struct ss_confirm_info*)user_data;
\r
731 if (response->success > 0){
\r
732 dbg("RESPONSE OK");
\r
733 resp.err = TCORE_RETURN_SUCCESS;
\r
736 dbg("RESPONSE NOT OK");
\r
738 line = (const char*)response->final_response;
\r
739 tokens = tcore_at_tok_new(line);
\r
741 if (g_slist_length(tokens) < 1) {
\r
743 dbg("err cause not specified or string corrupted");
\r
744 resp.err = TCORE_RETURN_3GPP_ERROR;
\r
748 err = atoi(g_slist_nth_data(tokens, 0));
\r
749 // TODO: CMEE error mapping is required.
\r
750 resp.err = TCORE_RETURN_3GPP_ERROR;
\r
752 tcore_at_tok_free(tokens);
\r
755 dbg("on_response_ss_barring_change_pwd: rsp.err : %d, usr : %x", resp.err, ur);
\r
757 tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_general), &resp);
\r
760 dbg("[ error ] ur is 0");
\r
766 static void on_response_ss_forwarding_set(TcorePending *p, int data_len, const void *data, void *user_data)
\r
769 UserRequest* ur = 0, *dup_ur=0;
\r
770 struct ss_confirm_info *info = 0;
\r
771 struct tresp_ss_general resp;
\r
772 GSList *tokens=NULL;
\r
775 const TcoreATResponse* response;
\r
777 dbg("function enter");
\r
780 o = tcore_pending_ref_core_object(p);
\r
781 ur = tcore_pending_ref_user_request(p);
\r
783 info = (struct ss_confirm_info*)user_data;
\r
785 if (response->success > 0) {
\r
787 dbg("RESPONSE OK");
\r
788 resp.err = TCORE_RETURN_SUCCESS;
\r
792 dbg("RESPONSE NOT OK");
\r
794 line = (const char*)response->final_response;
\r
795 tokens = tcore_at_tok_new(line);
\r
797 if (g_slist_length(tokens) < 1) {
\r
798 dbg("err cause not specified or string corrupted");
\r
799 resp.err = TCORE_RETURN_3GPP_ERROR;
\r
802 err = atoi(g_slist_nth_data(tokens, 0));
\r
803 /// TODO: CMEE error mapping is required.
\r
804 resp.err = TCORE_RETURN_3GPP_ERROR;
\r
807 tcore_at_tok_free(tokens);
\r
810 dbg("[ check ] class : 0x%x", info->class);
\r
811 dbg("[ check ] flavor_type : 0x%x", info->flavor_type);
\r
813 dbg("on_response_ss_forwarding_set - rsp.err : %d, ur : %x", resp.err, ur);
\r
815 if (response->success > 0) {
\r
817 if (info->flavor_type == SS_CF_MODE_CF_ALL ||
\r
818 info->flavor_type == SS_CF_MODE_CFC) {
\r
822 tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_general), &resp);
\r
826 dbg("[ error ] ur is 0");
\r
830 dup_ur = tcore_user_request_ref(ur);
\r
831 _ss_forwarding_get(o, dup_ur, info->class, info->flavor_type, info->resp);
\r
837 tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_general), &resp);
\r
840 dbg("[ error ] ur is 0");
\r
847 static void on_response_ss_waiting_set(TcorePending *p, int data_len, const void *data, void *user_data)
\r
849 CoreObject* core_obj = 0;
\r
850 UserRequest* ur = 0;
\r
851 UserRequest* ur_dup = 0;
\r
852 struct ss_confirm_info *info = 0;
\r
853 struct tresp_ss_general resp;
\r
854 GSList *tokens = NULL;
\r
857 const TcoreATResponse* response;
\r
859 dbg("function enter");
\r
861 core_obj = tcore_pending_ref_core_object(p);
\r
862 ur = tcore_pending_ref_user_request(p);
\r
864 info = (struct ss_confirm_info*)user_data;
\r
866 if(response->success > 0){
\r
867 dbg("RESPONSE OK");
\r
868 resp.err = TCORE_RETURN_SUCCESS;
\r
872 dbg("RESPONSE NOT OK");
\r
874 line = (const char*)response->final_response;
\r
875 tokens = tcore_at_tok_new(line);
\r
877 if (g_slist_length(tokens) < 1) {
\r
879 dbg("err cause not specified or string corrupted");
\r
880 resp.err = TCORE_RETURN_3GPP_ERROR;
\r
884 err = atoi(g_slist_nth_data(tokens, 0));
\r
885 /// TODO: CMEE error mapping is required.
\r
886 resp.err = TCORE_RETURN_3GPP_ERROR;
\r
888 tcore_at_tok_free(tokens);
\r
891 dbg("on_response_ss_waiting_set - rsp.err : %d, ur : %x, class : %d", resp.err, ur, info->class);
\r
893 if(resp.err == TCORE_RETURN_SUCCESS) {
\r
895 ur_dup = tcore_user_request_ref(ur);
\r
896 dbg("Get waiting call status");
\r
897 _ss_waiting_get(core_obj, ur_dup, info->class, info->resp);
\r
903 tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_general), &resp);
\r
907 dbg("[ error ] ur is 0");
\r
914 static void on_confirmation_ss_ussd(TcorePending *p, int data_len, const void *data, void *user_data)
\r
916 CoreObject* core_obj = 0;
\r
917 struct ss_confirm_info *info = 0;
\r
918 struct tresp_ss_ussd resp;
\r
919 UserRequest* ur = NULL , *ussd_ur= NULL;
\r
920 GSList *tokens = NULL;
\r
923 UssdSession *ussd_s = NULL;
\r
924 enum tcore_ss_ussd_type type = TCORE_SS_USSD_TYPE_MAX;
\r
925 const TcoreATResponse* response;
\r
927 dbg("function enter");
\r
929 ur = tcore_pending_ref_user_request(p);
\r
930 info = (struct ss_confirm_info*)user_data;
\r
932 memset(resp.str, 0x00, MAX_SS_USSD_LEN);
\r
934 core_obj = tcore_pending_ref_core_object(p);
\r
935 ussd_s = tcore_ss_ussd_get_session(core_obj);
\r
938 type = tcore_ss_ussd_get_session_type(ussd_s);
\r
940 dbg("[ error ] ussd_s : (0)");
\r
942 resp.type = (enum telephony_ss_ussd_type)type;
\r
943 resp.status = SS_USSD_MAX; //hardcoded value.
\r
945 if(response->success > 0) {
\r
947 dbg("RESPONSE OK");
\r
948 resp.err = TCORE_RETURN_SUCCESS;
\r
952 dbg("RESPONSE NOT OK");
\r
954 line = (const char*)response->final_response;
\r
955 tokens = tcore_at_tok_new(line);
\r
957 if (g_slist_length(tokens) < 1) {
\r
959 dbg("err cause not specified or string corrupted");
\r
960 resp.err = TCORE_RETURN_3GPP_ERROR;
\r
964 err = atoi(g_slist_nth_data(tokens, 0));
\r
965 // TODO: CMEE error mapping is required.
\r
966 resp.err = TCORE_RETURN_3GPP_ERROR;
\r
968 tcore_at_tok_free(tokens);
\r
971 dbg("on_confirmation_ss_ussd - rsp.err : %d, ur : %x", resp.err, ur);
\r
973 if(response->success > 0) {
\r
975 if(type == TCORE_SS_USSD_TYPE_USER_INITIATED) {
\r
976 dbg("ussd type %d",resp.type);
\r
979 tcore_ss_ussd_get_session_data(ussd_s, (void**)&ussd_ur);
\r
981 tcore_user_request_free(ussd_ur);
\r
987 tcore_ss_ussd_destroy_session(ussd_s);
\r
991 if(UssdResp == FALSE){ // to avoid sending multiple response to application.
\r
992 tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_ussd), &resp);
\r
997 dbg("[ error ] ur : (0)");
\r
1003 static void on_response_ss_barring_get(TcorePending *p, int data_len, const void *data, void *user_data)
\r
1006 UserRequest* ur = 0;
\r
1007 int status = 0, classx = 0, err = 0;
\r
1009 struct ss_confirm_info* info = 0;
\r
1010 struct tresp_ss_barring resp;
\r
1011 int countRecords = 0, countValidRecords = 0;
\r
1012 GSList *tokens = NULL;
\r
1015 char *stat = NULL;
\r
1016 const TcoreATResponse *response;
\r
1018 dbg("function enter");
\r
1021 ur = tcore_pending_ref_user_request(p);
\r
1022 info = (struct ss_confirm_info*)user_data;
\r
1024 if(response->lines) {
\r
1025 respdata = (GSList *)response->lines;
\r
1026 countRecords = g_slist_length(respdata);
\r
1027 dbg("total records : %d",countRecords);
\r
1033 dbg("no active status - return to user")
\r
1035 resp.record_num = countRecords;
\r
1037 if(resp.record_num > 0) {
\r
1039 resp.record = g_new0(struct barring_info, resp.record_num);
\r
1040 for (countValidRecords = 0; respdata != NULL ; respdata = respdata->next) {
\r
1042 line = (const char*)(respdata->data);
\r
1043 tokens = tcore_at_tok_new(line);
\r
1046 stat = g_slist_nth_data(tokens, 0);
\r
1049 dbg("Stat is missing");
\r
1053 status = atoi(stat);
\r
1056 resp.record[countValidRecords].status = SS_STATUS_ACTIVATE;
\r
1060 resp.record[countValidRecords].status = SS_STATUS_DEACTIVATE;
\r
1062 dbg("call barring status - %d",status);
\r
1065 classx_str = g_slist_nth_data(tokens, 1);
\r
1067 if (!classx_str) {
\r
1069 dbg("class error. classx not exist - set to requested one : %d", info->class);
\r
1070 switch(info->class) {
\r
1072 case SS_CLASS_ALL_TELE:
\r
1075 case SS_CLASS_VOICE:
\r
1078 case SS_CLASS_ALL_DATA_TELE:
\r
1081 case SS_CLASS_FAX:
\r
1084 case SS_CLASS_SMS:
\r
1087 case SS_CLASS_ALL_CS_SYNC:
\r
1093 dbg("unsupported class %d. set to default : 7", info->class);
\r
1098 classx = atoi(classx_str);
\r
1099 dbg("call barring classx - %d",classx);
\r
1105 resp.record[countValidRecords].class = SS_CLASS_VOICE;
\r
1108 resp.record[countValidRecords].class = SS_CLASS_ALL_DATA_TELE;
\r
1111 resp.record[countValidRecords].class = SS_CLASS_FAX;
\r
1114 resp.record[countValidRecords].class = SS_CLASS_ALL_TELE;
\r
1117 resp.record[countValidRecords].class = SS_CLASS_SMS;
\r
1120 resp.record[countValidRecords].class = SS_CLASS_ALL_CS_SYNC;
\r
1123 resp.record[countValidRecords].class = SS_CLASS_ALL_CS_ASYNC;
\r
1126 dbg("unspoorted class : [%d]\n", classx);
\r
1130 resp.record[countValidRecords].mode = (enum telephony_ss_barring_mode)(info->flavor_type);
\r
1131 countValidRecords++;
\r
1132 tcore_at_tok_free(tokens);
\r
1136 dbg("invalid field found. coutinue");
\r
1137 tcore_at_tok_free(tokens);
\r
1141 dbg("valid count :%d",countValidRecords);
\r
1142 resp.record_num = countValidRecords;
\r
1143 resp.err = TCORE_RETURN_SUCCESS;
\r
1147 dbg("no active status - return to user")
\r
1150 if(response->success > 0) {
\r
1152 dbg("RESPONSE OK");
\r
1153 resp.err = TCORE_RETURN_SUCCESS;
\r
1157 dbg("RESPONSE NOT OK");
\r
1158 resp.err = TCORE_RETURN_FAILURE;
\r
1160 line = (const char*)response->final_response;
\r
1161 tokens = tcore_at_tok_new(line);
\r
1163 if (g_slist_length(tokens) < 1) {
\r
1165 dbg("err cause not specified or string corrupted");
\r
1166 resp.err = TCORE_RETURN_3GPP_ERROR;
\r
1170 err = atoi(g_slist_nth_data(tokens, 0));
\r
1171 // TODO: CMEE error mapping is required.
\r
1172 resp.err = TCORE_RETURN_3GPP_ERROR;
\r
1174 tcore_at_tok_free(tokens);
\r
1177 dbg("on_response_ss_barring_get- rsp.err : %d, ur : %x", resp.err, ur);
\r
1180 tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_barring), &resp);
\r
1182 dbg("[ error ] ur is 0");
\r
1184 if (resp.record) {
\r
1186 g_free(resp.record);
\r
1187 resp.record = NULL;
\r
1190 g_free(user_data);
\r
1194 static void on_response_ss_forwarding_get(TcorePending *p, int data_len, const void *data, void *user_data)
\r
1196 UserRequest* ur = 0;
\r
1197 int classx = 0, err = 0, time = 0;
\r
1199 struct ss_confirm_info* info = 0;
\r
1200 struct tresp_ss_forwarding resp;
\r
1201 int countRecords = 0, countValidRecords = 0;
\r
1203 GSList *respdata = NULL ,*tokens = NULL ;
\r
1205 char *classx_str ,*status, *ton, *time_str;
\r
1206 const TcoreATResponse *response;
\r
1208 dbg("function enter");
\r
1211 ur = tcore_pending_ref_user_request(p);
\r
1212 info = (struct ss_confirm_info*)user_data;
\r
1213 if(response->lines) {
\r
1215 respdata = (GSList*)response->lines;
\r
1216 countRecords = g_slist_length(respdata);
\r
1217 dbg("total records : %d",countRecords);
\r
1222 dbg("no active status - return to user")
\r
1224 resp.record_num = countRecords;
\r
1226 if (resp.record_num > 0) {
\r
1228 resp.record = g_new0(struct forwarding_info, resp.record_num);
\r
1230 for (countValidRecords = 0; respdata != NULL ; respdata = respdata->next) {
\r
1232 line = (const char*)(respdata->data);
\r
1233 tokens = tcore_at_tok_new(line);
\r
1236 status = g_slist_nth_data(tokens, 0);
\r
1239 dbg("start line error. skip this line");
\r
1244 if(atoi(status)== 1) {
\r
1245 resp.record[countValidRecords].status = SS_STATUS_ACTIVATE;
\r
1248 resp.record[countValidRecords].status = SS_STATUS_DEACTIVATE;
\r
1253 classx_str = g_slist_nth_data(tokens, 1);
\r
1254 if (!classx_str) {
\r
1255 dbg("class error. skip this line");
\r
1260 switch(atoi(classx_str)) {
\r
1262 resp.record[countValidRecords].class = SS_CLASS_VOICE;
\r
1265 resp.record[countValidRecords].class = SS_CLASS_ALL_DATA_TELE;
\r
1268 resp.record[countValidRecords].class = SS_CLASS_FAX;
\r
1271 resp.record[countValidRecords].class = SS_CLASS_ALL_TELE;
\r
1274 resp.record[countValidRecords].class = SS_CLASS_SMS;
\r
1277 resp.record[countValidRecords].class = SS_CLASS_ALL_CS_SYNC;
\r
1280 resp.record[countValidRecords].class = SS_CLASS_ALL_CS_ASYNC;
\r
1283 dbg("unspoorted class : [%d]\n", classx);
\r
1289 //parse <numer> <type>
\r
1290 num = g_slist_nth_data(tokens, 2);
\r
1293 dbg("number - %s", num);
\r
1294 memcpy((resp.record[countValidRecords].number), num, strlen(num));
\r
1295 resp.record[countValidRecords].number_present = TRUE;
\r
1297 ton = g_slist_nth_data(tokens, 3);
\r
1299 resp.record[countValidRecords].number_type = atoi(ton);
\r
1300 dbg("number type - %d", resp.record[countValidRecords].number_type);
\r
1304 //skip <subaddr> <satype>
\r
1306 time_str = g_slist_nth_data(tokens, 6);
\r
1309 time = atoi(time_str);
\r
1310 resp.record[countValidRecords].time = (enum telephony_ss_forwarding_no_reply_time)time;
\r
1311 dbg("time - %d", time);
\r
1314 resp.record[countValidRecords].mode = (enum telephony_ss_forwarding_mode)(info->flavor_type);
\r
1315 dbg("flavor_type - %d", (enum telephony_ss_forwarding_mode)(info->flavor_type));
\r
1317 countValidRecords++;
\r
1318 tcore_at_tok_free(tokens);
\r
1321 dbg("invalid field found. coutinue");
\r
1322 tcore_at_tok_free(tokens);
\r
1325 dbg("valid count :%d",countValidRecords);
\r
1326 resp.record_num = countValidRecords;
\r
1327 resp.err = TCORE_RETURN_SUCCESS;
\r
1331 dbg("no active status - return to user")
\r
1334 if(response->success > 0) {
\r
1336 dbg("RESPONSE OK");
\r
1337 resp.err = TCORE_RETURN_SUCCESS;
\r
1341 dbg("RESPONSE NOT OK");
\r
1342 line = (const char*)response->final_response;
\r
1343 tokens = tcore_at_tok_new(line);
\r
1345 if (g_slist_length(tokens) < 1) {
\r
1347 dbg("err cause not specified or string corrupted");
\r
1348 resp.err = TCORE_RETURN_3GPP_ERROR;
\r
1352 err = atoi(g_slist_nth_data(tokens, 0));
\r
1353 /* TODO: CMEE error mapping is required. */
\r
1354 resp.err = TCORE_RETURN_3GPP_ERROR;
\r
1356 tcore_at_tok_free(tokens);
\r
1359 dbg("on_response_ss_forwarding_get- rsp.err : %d, ur : %x", resp.err, ur);
\r
1361 tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_forwarding), &resp);
\r
1363 dbg("[ error ] ur is 0");
\r
1365 if (resp.record) {
\r
1366 g_free(resp.record);
\r
1367 resp.record = NULL;
\r
1369 g_free(user_data);
\r
1373 static void on_response_ss_waiting_get(TcorePending *p, int data_len, const void *data, void *user_data)
\r
1376 UserRequest* ur = 0;
\r
1377 GSList *respdata, *tokens = NULL;
\r
1378 int classx = 0, err = 0;
\r
1379 struct ss_confirm_info* info = 0;
\r
1380 struct tresp_ss_waiting resp;
\r
1381 int countRecords = 0, countValidRecords = 0;
\r
1383 char *classx_str ,*status;
\r
1384 const TcoreATResponse *response;
\r
1386 dbg("function enter")
\r
1388 ur = tcore_pending_ref_user_request(p);
\r
1389 info = (struct ss_confirm_info*)user_data;
\r
1391 if(response->lines) {
\r
1393 respdata = (GSList*)response->lines;
\r
1394 countRecords = g_slist_length(respdata);
\r
1395 dbg("total records : %d",countRecords);
\r
1400 dbg("no active status - return to user")
\r
1402 resp.record_num = countRecords;
\r
1404 if (resp.record_num > 0) {
\r
1406 resp.record = g_new0(struct waiting_info, resp.record_num);
\r
1408 for (countValidRecords = 0; respdata != NULL ; respdata = respdata->next) {
\r
1410 line = (const char*)(respdata->data);
\r
1411 tokens = tcore_at_tok_new(line);
\r
1414 status = g_slist_nth_data(tokens, 0);
\r
1416 dbg("Missing stat in responce ");
\r
1421 if(atoi(status) == 1) {
\r
1422 resp.record[countValidRecords].status = SS_STATUS_ACTIVATE;
\r
1425 resp.record[countValidRecords].status = SS_STATUS_DEACTIVATE;
\r
1428 dbg("status = %d", resp.record[countValidRecords].status);
\r
1431 classx_str = g_slist_nth_data(tokens, 1);
\r
1432 if (!classx_str) {
\r
1433 dbg("error - class is missing");
\r
1438 switch(atoi(classx_str)) {
\r
1440 resp.record[countValidRecords].class = SS_CLASS_VOICE;
\r
1443 resp.record[countValidRecords].class = SS_CLASS_ALL_DATA_TELE;
\r
1446 resp.record[countValidRecords].class = SS_CLASS_FAX;
\r
1449 resp.record[countValidRecords].class = SS_CLASS_ALL_TELE;
\r
1452 resp.record[countValidRecords].class = SS_CLASS_SMS;
\r
1455 resp.record[countValidRecords].class = SS_CLASS_ALL_CS_SYNC;
\r
1458 resp.record[countValidRecords].class = SS_CLASS_ALL_CS_ASYNC;
\r
1461 dbg("unspoorted class : [%d]\n", classx);
\r
1465 dbg("class info %d",resp.record[countValidRecords].class);
\r
1468 countValidRecords++;
\r
1469 tcore_at_tok_free(tokens);
\r
1472 dbg("invalid field found. coutinue");
\r
1473 tcore_at_tok_free(tokens);
\r
1477 dbg("valid count :%d",countValidRecords);
\r
1478 resp.record_num = countValidRecords;
\r
1479 resp.err = TCORE_RETURN_SUCCESS;
\r
1482 dbg("no active status - return to user")
\r
1485 if(response->success > 0) {
\r
1486 dbg("RESPONSE OK");
\r
1487 resp.err = TCORE_RETURN_SUCCESS;
\r
1491 dbg("RESPONSE NOT OK");
\r
1492 line = (const char*)response->final_response;
\r
1493 tokens = tcore_at_tok_new(line);
\r
1495 if (g_slist_length(tokens) < 1) {
\r
1497 dbg("err cause not specified or string corrupted");
\r
1498 resp.err = TCORE_RETURN_3GPP_ERROR;
\r
1502 err = atoi(g_slist_nth_data(tokens, 0));
\r
1503 // TODO: CMEE error mapping is required.
\r
1504 resp.err = TCORE_RETURN_3GPP_ERROR;
\r
1506 tcore_at_tok_free(tokens);
\r
1509 dbg("on_response_ss_waiting_get - rsp.err : %d, ur : %x", resp.err, ur);
\r
1511 tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_waiting), &resp);
\r
1513 dbg("[ error ] ur is 0");
\r
1515 if (resp.record) {
\r
1516 g_free(resp.record);
\r
1517 resp.record = NULL;
\r
1519 g_free(user_data);
\r
1523 static void on_response_ss_cli_get(TcorePending *p, int data_len, const void *data, void *user_data)
\r
1525 UserRequest* ur = 0;
\r
1526 struct tresp_ss_cli resp;
\r
1527 enum telephony_ss_cli_type *p_type = NULL;
\r
1528 char *line = NULL, *status;
\r
1530 int cli_adj,stat ;
\r
1531 GSList *tokens = NULL ;
\r
1532 const TcoreATResponse *response;
\r
1534 dbg("function enter")
\r
1536 ur = tcore_pending_ref_user_request(p);
\r
1537 p_type = (enum telephony_ss_cli_type*)(user_data);
\r
1539 if (response->success > 0) {
\r
1541 line = (char*) (((GSList*)response->lines)->data);
\r
1542 tokens = tcore_at_tok_new(line);
\r
1544 if(*p_type == SS_CLI_TYPE_CLIR){
\r
1547 dbg("CLI type is CLIR")
\r
1549 status = g_slist_nth_data(tokens, 0);
\r
1552 dbg("Call line identification adjustment missing <n>");
\r
1556 cli_adj = atoi(status);
\r
1557 dbg("CLIR response value of <n> - %d",cli_adj);
\r
1559 if(cli_adj == 0) {
\r
1562 status = g_slist_nth_data(tokens, 1);
\r
1564 dbg("status is missing<m>");
\r
1566 stat = atoi(status);
\r
1567 dbg("CLIR response value of <m> - %d",stat);
\r
1569 if(stat == 1 || stat == 3) {
\r
1570 resp.status = TRUE;
\r
1573 resp.status = FALSE;
\r
1576 else if (cli_adj == 1) {
\r
1577 resp.status = TRUE;
\r
1580 resp.status = FALSE;
\r
1582 dbg("resp.status - %d",resp.status);
\r
1584 tcore_at_tok_free(tokens);
\r
1588 status = g_slist_nth_data(tokens, 0);
\r
1590 dbg("Stat is missing");
\r
1593 stat = atoi(status);
\r
1595 resp.status = TRUE;
\r
1597 resp.status = FALSE ;
\r
1599 dbg("resp.status - %d",resp.status);
\r
1601 tcore_at_tok_free(tokens);
\r
1605 if (response->success > 0) {
\r
1606 dbg("RESPONSE OK");
\r
1607 resp.err = TCORE_RETURN_SUCCESS;
\r
1611 dbg("RESPONSE NOT OK");
\r
1613 line = (char*)response->final_response;
\r
1614 tokens = tcore_at_tok_new(line);
\r
1616 if (g_slist_length(tokens) < 1) {
\r
1617 dbg("err cause not specified or string corrupted");
\r
1618 resp.err = TCORE_RETURN_3GPP_ERROR;
\r
1621 err = atoi(g_slist_nth_data(tokens, 0));
\r
1622 // TODO: CMEE error mapping is required.
\r
1623 resp.err = TCORE_RETURN_3GPP_ERROR;
\r
1625 tcore_at_tok_free(tokens);
\r
1628 resp.type = *p_type;
\r
1629 dbg("check - resp.type = %d ", resp.type);
\r
1631 tcore_user_request_send_response(ur, TRESP_SS_CLI_GET_STATUS, sizeof(struct tresp_ss_cli), &resp);
\r
1633 dbg("[ error ] ur : (0)");
\r
1635 g_free(user_data);
\r
1638 static struct tcore_ss_operations ss_ops = {
\r
1639 .barring_activate = s_ss_barring_activate,
\r
1640 .barring_deactivate = s_ss_barring_deactivate,
\r
1641 .barring_change_password= s_ss_barring_change_password,
\r
1642 .barring_get_status = s_ss_barring_get_status,
\r
1643 .forwarding_activate = s_ss_forwarding_activate,
\r
1644 .forwarding_deactivate = s_ss_forwarding_deactivate,
\r
1645 .forwarding_register = s_ss_forwarding_register,
\r
1646 .forwarding_deregister = s_ss_forwarding_deregister,
\r
1647 .forwarding_get_status = s_ss_forwarding_get_status,
\r
1648 .waiting_activate = s_ss_waiting_activate,
\r
1649 .waiting_deactivate = s_ss_waiting_deactivate,
\r
1650 .waiting_get_status = s_ss_waiting_get_status,
\r
1651 .cli_activate = s_ss_cli_activate,
\r
1652 .cli_deactivate = s_ss_cli_deactivate,
\r
1653 .cli_get_status = s_ss_cli_get_status,
\r
1654 .send_ussd = s_ss_send_ussd,
\r
1655 .set_aoc = s_ss_set_aoc,
\r
1656 .get_aoc = s_ss_get_aoc,
\r
1660 static TReturn _ss_barring_set(CoreObject *o, UserRequest *ur, enum telephony_ss_opcode op)
\r
1662 struct treq_ss_barring *barring = 0;
\r
1663 struct ss_confirm_info *user_data = 0;
\r
1664 char *cmd_str = NULL;
\r
1666 TcorePending *pending = NULL;
\r
1667 TcoreATRequest *req;
\r
1668 char passwd[MAX_SS_BARRING_PASSWORD_LEN+1];
\r
1671 char* facility = NULL;
\r
1672 gboolean ret = FALSE;
\r
1674 dbg("function enter");
\r
1675 barring = (struct treq_ss_barring*)tcore_user_request_ref_data(ur, 0);
\r
1678 case SS_OPCO_ACTIVATE:
\r
1681 case SS_OPCO_DEACTIVATE:
\r
1685 dbg("unsupported opco : %d", op);
\r
1686 return TCORE_RETURN_FAILURE;
\r
1688 dbg("opco - %d",opco);
\r
1690 switch(barring->mode){
\r
1691 case SS_BARR_MODE_BAOC:
\r
1694 case SS_BARR_MODE_BOIC:
\r
1697 case SS_BARR_MODE_BOIC_NOT_HC:
\r
1700 case SS_BARR_MODE_BAIC:
\r
1703 case SS_BARR_MODE_BIC_ROAM:
\r
1706 case SS_BARR_MODE_AB:
\r
1709 case SS_BARR_MODE_AOB:
\r
1712 case SS_BARR_MODE_AIB:
\r
1715 case SS_BARR_MODE_BIC_NOT_SIM:
\r
1716 // facility = "NS";
\r
1718 dbg("unspported mode %d", barring->mode);
\r
1719 return TCORE_RETURN_FAILURE;
\r
1722 dbg("facility - %s",facility);
\r
1724 switch(barring->class) {
\r
1725 case SS_CLASS_ALL_TELE:
\r
1728 case SS_CLASS_VOICE:
\r
1731 case SS_CLASS_ALL_DATA_TELE:
\r
1734 case SS_CLASS_FAX:
\r
1737 case SS_CLASS_SMS:
\r
1740 case SS_CLASS_ALL_CS_SYNC:
\r
1746 dbg("unsupported class %d. set to default : 7", barring->class);
\r
1750 dbg("classx - %d",classx);
\r
1752 // null-ended pwd handling added - unexpected 0x11 value observed in req string
\r
1753 memcpy(passwd, barring->password, MAX_SS_BARRING_PASSWORD_LEN);
\r
1754 passwd[MAX_SS_BARRING_PASSWORD_LEN]='\0';
\r
1755 dbg("passwd - %s",passwd);
\r
1757 hal = tcore_object_get_hal(o);
\r
1758 pending = tcore_pending_new(o, 0);
\r
1760 cmd_str = g_strdup_printf("AT+CLCK=\"%s\",%d,\"%s\",%d", facility, opco, passwd, classx);
\r
1761 dbg("request command : %s", cmd_str);
\r
1763 req = tcore_at_request_new(cmd_str, NULL, TCORE_AT_NO_RESULT);
\r
1764 dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
\r
1766 tcore_pending_set_request_data(pending, 0, req);
\r
1768 user_data = g_new0(struct ss_confirm_info, 1);
\r
1769 if (op == SS_OPCO_ACTIVATE) {
\r
1770 user_data->resp = TRESP_SS_BARRING_ACTIVATE;
\r
1773 else if (op == SS_OPCO_DEACTIVATE){
\r
1774 user_data->resp = TRESP_SS_BARRING_DEACTIVATE;
\r
1778 dbg("[ error ] wrong ss opco (0x%x)", op);
\r
1779 return TCORE_RETURN_FAILURE;
\r
1781 user_data->flavor_type = (int)(barring->mode);
\r
1782 user_data->class = barring->class;
\r
1784 ret = _ss_request_message(pending, o, ur, on_response_ss_barring_set, user_data);
\r
1789 dbg("AT request sent failed ")
\r
1790 return TCORE_RETURN_FAILURE;
\r
1792 return TCORE_RETURN_SUCCESS;
\r
1795 static TReturn _ss_barring_get(CoreObject *o,
\r
1797 enum telephony_ss_class class,
\r
1798 enum telephony_ss_barring_mode mode,
\r
1799 enum tcore_response_command resp)
\r
1802 struct ss_confirm_info *user_data = 0;
\r
1803 gboolean ret = FALSE;
\r
1804 char* cmd_str = NULL;
\r
1806 char* facility = NULL;
\r
1808 TcorePending *pending = NULL;
\r
1809 TcoreATRequest *req;
\r
1811 dbg("function enter");
\r
1813 //query status - opco is fixed to 2
\r
1818 case SS_BARR_MODE_BAOC:
\r
1821 case SS_BARR_MODE_BOIC:
\r
1824 case SS_BARR_MODE_BOIC_NOT_HC:
\r
1827 case SS_BARR_MODE_BAIC:
\r
1830 case SS_BARR_MODE_BIC_ROAM:
\r
1833 case SS_BARR_MODE_AB:
\r
1836 case SS_BARR_MODE_AOB:
\r
1839 case SS_BARR_MODE_AIB:
\r
1842 case SS_BARR_MODE_BIC_NOT_SIM:
\r
1844 dbg("unspported mode %d", mode);
\r
1845 return TCORE_RETURN_FAILURE;
\r
1848 dbg("facility - %s", facility);
\r
1852 case SS_CLASS_ALL_TELE:
\r
1855 case SS_CLASS_VOICE:
\r
1858 case SS_CLASS_ALL_DATA_TELE:
\r
1861 case SS_CLASS_FAX:
\r
1864 case SS_CLASS_SMS:
\r
1867 case SS_CLASS_ALL_CS_SYNC:
\r
1873 dbg("unsupported class %d. set to default : 7", class);
\r
1876 dbg("class - %d", classx);
\r
1879 cmd_str = g_strdup_printf("AT+CLCK=\"%s\",%d", facility, opco);
\r
1881 cmd_str = g_strdup_printf("AT+CLCK=\"%s\",%d,,%d", facility, opco,classx);
\r
1883 dbg("request command : %s", cmd_str);
\r
1885 hal = tcore_object_get_hal(o);
\r
1886 pending = tcore_pending_new(o, 0);
\r
1887 req = tcore_at_request_new(cmd_str, "+CLCK", TCORE_AT_MULTILINE);
\r
1888 dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
\r
1890 tcore_pending_set_request_data(pending, 0, req);
\r
1892 user_data = g_new0(struct ss_confirm_info, 1);
\r
1893 user_data->resp = resp;
\r
1894 user_data->flavor_type = (int)(mode);
\r
1895 user_data->class = class;
\r
1897 ret = _ss_request_message(pending, o, ur, on_response_ss_barring_get, user_data);
\r
1901 dbg("AT request sent failed ")
\r
1902 return TCORE_RETURN_FAILURE;
\r
1905 return TCORE_RETURN_SUCCESS;
\r
1908 static TReturn s_ss_barring_activate(CoreObject *o, UserRequest *ur)
\r
1910 return _ss_barring_set(o, ur, SS_OPCO_ACTIVATE);
\r
1913 static TReturn s_ss_barring_deactivate(CoreObject *o, UserRequest *ur)
\r
1915 return _ss_barring_set(o, ur, SS_OPCO_DEACTIVATE);
\r
1918 static TReturn s_ss_barring_change_password(CoreObject *o, UserRequest *ur)
\r
1921 TcorePending *pending = NULL;
\r
1922 TcoreATRequest *req;
\r
1923 struct treq_ss_barring_change_password *barring = 0;
\r
1924 struct ss_confirm_info *user_data = 0;
\r
1925 char* cmd_str = NULL;
\r
1926 gboolean ret = FALSE;
\r
1928 dbg("function enter");
\r
1929 barring = (struct treq_ss_barring_change_password*)tcore_user_request_ref_data(ur, 0);
\r
1931 cmd_str = g_strdup_printf("AT+CPWD=\"%s\",\"%s\",\"%s\"", "AB", barring->password_old, barring->password_new);
\r
1932 dbg("request command : %s", cmd_str);
\r
1934 hal = tcore_object_get_hal(o);
\r
1935 pending = tcore_pending_new(o, 0);
\r
1936 req = tcore_at_request_new(cmd_str, NULL, TCORE_AT_NO_RESULT);
\r
1937 dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
\r
1939 tcore_pending_set_request_data(pending, 0, req);
\r
1941 user_data = g_new0(struct ss_confirm_info, 1);
\r
1942 user_data->resp = TRESP_SS_BARRING_CHANGE_PASSWORD;
\r
1944 ret = _ss_request_message(pending, o, ur, on_response_ss_barring_change_pwd, user_data);
\r
1947 dbg("AT request sent failed ")
\r
1948 return TCORE_RETURN_FAILURE;
\r
1950 return TCORE_RETURN_SUCCESS;
\r
1953 static TReturn s_ss_barring_get_status(CoreObject *o, UserRequest *ur)
\r
1955 struct treq_ss_barring *barring = 0;
\r
1956 barring = (struct treq_ss_barring*)tcore_user_request_ref_data(ur, 0);
\r
1958 return _ss_barring_get(o, ur, barring->class, barring->mode, TRESP_SS_BARRING_GET_STATUS);
\r
1961 static TReturn _ss_forwarding_set(CoreObject *o, UserRequest *ur, enum telephony_ss_opcode op)
\r
1963 struct treq_ss_forwarding *forwarding = 0;
\r
1964 struct ss_confirm_info *user_data = 0;
\r
1965 gboolean ret = FALSE;
\r
1967 char* cmd_str = NULL;
\r
1968 char* tmp_str = NULL;
\r
1969 int reason=0, mode = 0, num_type = 0, classx = 0,time = 0;
\r
1970 gboolean valid_num = FALSE;
\r
1972 TcorePending *pending = NULL;
\r
1973 TcoreATRequest *req;
\r
1975 dbg("_ss_forwarding_set with opco %d ", op);
\r
1977 forwarding = (struct treq_ss_forwarding*) tcore_user_request_ref_data(ur, 0);
\r
1978 switch(forwarding->mode) {
\r
1980 case SS_CF_MODE_CFU:
\r
1983 case SS_CF_MODE_CFB:
\r
1986 case SS_CF_MODE_CFNRy:
\r
1989 case SS_CF_MODE_CFNRc:
\r
1992 case SS_CF_MODE_CF_ALL:
\r
1995 case SS_CF_MODE_CFC:
\r
2000 dbg("unsupported reason : %d");
\r
2001 return TCORE_RETURN_FAILURE;
\r
2005 dbg("reason = %d", reason);
\r
2007 case SS_OPCO_DEACTIVATE:
\r
2010 case SS_OPCO_ACTIVATE:
\r
2016 case SS_OPCO_DEREG:
\r
2021 dbg("unsupported opco : %d", op);
\r
2022 return TCORE_RETURN_FAILURE;
\r
2025 dbg("mode = %d", mode);
\r
2028 switch(forwarding->class) {
\r
2029 case SS_CLASS_ALL_TELE:
\r
2032 case SS_CLASS_VOICE:
\r
2035 case SS_CLASS_ALL_DATA_TELE:
\r
2038 case SS_CLASS_FAX:
\r
2041 case SS_CLASS_SMS:
\r
2044 case SS_CLASS_ALL_CS_SYNC:
\r
2050 dbg("unsupported class %d. set to default : 7", forwarding->class);
\r
2053 dbg("classx = %d", classx);
\r
2056 len = strlen(forwarding->number);
\r
2059 if (forwarding->number[0] == '+')
\r
2060 num_type = ((NUM_TYPE_INTERNATIONAL << 4)| NUM_PLAN_ISDN);
\r
2064 dbg("number = %s", forwarding->number);
\r
2066 user_data = g_new0(struct ss_confirm_info, 1);
\r
2070 user_data->resp = TRESP_SS_FORWARDING_REGISTER;
\r
2072 case SS_OPCO_DEREG:
\r
2073 user_data->resp = TRESP_SS_FORWARDING_DEREGISTER;
\r
2075 case SS_OPCO_ACTIVATE:
\r
2076 user_data->resp = TRESP_SS_FORWARDING_ACTIVATE;
\r
2078 case SS_OPCO_DEACTIVATE:
\r
2079 user_data->resp = TRESP_SS_FORWARDING_DEACTIVATE;
\r
2082 dbg("[ error ] unknown op (0x%x)", op);
\r
2086 if(forwarding->number[0] == '+')
\r
2091 if(op == SS_OPCO_REG)
\r
2092 tmp_str = g_strdup_printf("AT+CCFC=%d,%d,\"%s\",%d,%d", reason, mode, forwarding->number, num_type, classx);
\r
2093 else// other opcode does not need num field
\r
2094 tmp_str = g_strdup_printf("AT+CCFC=%d,%d,,,%d", reason, mode, classx);
\r
2096 if(forwarding->mode == SS_CF_MODE_CFNRy) {
\r
2097 //add time info to 'no reply' case
\r
2098 time = (int)(forwarding->time);
\r
2099 cmd_str = g_strdup_printf("%s,,,%d", tmp_str,time);
\r
2102 cmd_str = g_strdup_printf("%s", tmp_str);
\r
2105 dbg("request command : %s", cmd_str);
\r
2106 hal = tcore_object_get_hal(o);
\r
2107 pending = tcore_pending_new(o, 0);
\r
2108 req = tcore_at_request_new(cmd_str, NULL, TCORE_AT_NO_RESULT);
\r
2109 dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
\r
2111 tcore_pending_set_request_data(pending, 0, req);
\r
2113 user_data->flavor_type = forwarding->mode;
\r
2114 user_data->class = forwarding->class;
\r
2116 ret = _ss_request_message(pending, o, ur, on_response_ss_forwarding_set, user_data);
\r
2122 dbg("AT request sent failed ")
\r
2123 return TCORE_RETURN_FAILURE;
\r
2126 return TCORE_RETURN_SUCCESS;
\r
2129 static TReturn _ss_forwarding_get(CoreObject *o,
\r
2131 enum telephony_ss_class class,
\r
2132 enum telephony_ss_forwarding_mode type,
\r
2133 enum tcore_response_command resp)
\r
2136 struct ss_confirm_info *user_data = 0;
\r
2137 gboolean ret = FALSE;
\r
2138 char* cmd_str = NULL;
\r
2139 int reason = 0, mode = 0, classx = 0;
\r
2141 TcorePending *pending = NULL;
\r
2142 TcoreATRequest *req;
\r
2144 dbg("function enter");
\r
2147 case SS_CF_MODE_CFU:
\r
2150 case SS_CF_MODE_CFB:
\r
2153 case SS_CF_MODE_CFNRy:
\r
2156 case SS_CF_MODE_CFNRc:
\r
2159 case SS_CF_MODE_CF_ALL:
\r
2162 case SS_CF_MODE_CFC:
\r
2167 dbg("unsupported reason : %d");
\r
2170 dbg("reason = %d", reason);
\r
2173 case SS_CLASS_ALL_TELE:
\r
2176 case SS_CLASS_VOICE:
\r
2179 case SS_CLASS_ALL_DATA_TELE:
\r
2182 case SS_CLASS_FAX:
\r
2185 case SS_CLASS_SMS:
\r
2188 case SS_CLASS_ALL_CS_SYNC:
\r
2193 dbg("unsupported class %d. set to default : 7", class);
\r
2197 dbg("classx = %d", classx);
\r
2199 //query status - mode set to 2
\r
2201 user_data = g_new0(struct ss_confirm_info, 1);
\r
2202 user_data->resp = resp;
\r
2203 user_data->class = class;
\r
2204 user_data->flavor_type = type;
\r
2207 cmd_str = g_strdup_printf("AT+CCFC=%d,%d", reason, mode);
\r
2209 cmd_str = g_strdup_printf("AT+CCFC=%d,%d,,,%d", reason, mode,classx);
\r
2211 dbg("request command : %s", cmd_str);
\r
2213 hal = tcore_object_get_hal(o);
\r
2214 pending = tcore_pending_new(o, 0);
\r
2215 req = tcore_at_request_new(cmd_str, "+CCFC", TCORE_AT_MULTILINE);
\r
2216 dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
\r
2218 tcore_pending_set_request_data(pending, 0, req);
\r
2220 ret = _ss_request_message(pending, o, ur, on_response_ss_forwarding_get, user_data);
\r
2224 dbg("AT request sent failed ")
\r
2225 return TCORE_RETURN_FAILURE;
\r
2228 return TCORE_RETURN_SUCCESS;
\r
2231 static TReturn s_ss_forwarding_activate(CoreObject *o, UserRequest *ur)
\r
2233 return _ss_forwarding_set(o, ur, SS_OPCO_ACTIVATE);
\r
2236 static TReturn s_ss_forwarding_deactivate(CoreObject *o, UserRequest *ur)
\r
2238 return _ss_forwarding_set(o, ur, SS_OPCO_DEACTIVATE);
\r
2241 static TReturn s_ss_forwarding_register(CoreObject *o, UserRequest *ur)
\r
2243 return _ss_forwarding_set(o, ur, SS_OPCO_REG);
\r
2246 static TReturn s_ss_forwarding_deregister(CoreObject *o, UserRequest *ur)
\r
2248 return _ss_forwarding_set(o, ur, SS_OPCO_DEREG);
\r
2251 static TReturn s_ss_forwarding_get_status(CoreObject *o, UserRequest *ur)
\r
2253 struct treq_ss_forwarding *forwarding = 0;
\r
2254 forwarding = (struct treq_ss_forwarding*)tcore_user_request_ref_data(ur, 0);
\r
2256 return _ss_forwarding_get(o, ur, forwarding->class, forwarding->mode, TRESP_SS_FORWARDING_GET_STATUS);
\r
2260 static TReturn _ss_waiting_set(CoreObject *o, UserRequest *ur, enum telephony_ss_opcode opco)
\r
2262 struct treq_ss_waiting *waiting = 0;
\r
2263 struct ss_confirm_info *user_data = 0;
\r
2264 gboolean ret = FALSE;
\r
2265 int mode = 0, classx = 0;
\r
2268 TcorePending *pending = NULL;
\r
2269 TcoreATRequest *req;
\r
2271 dbg("function enter ");
\r
2272 waiting = (struct treq_ss_waiting*) tcore_user_request_ref_data(ur, 0);
\r
2273 user_data = g_new0(struct ss_confirm_info, 1);
\r
2275 if(opco == SS_OPCO_ACTIVATE) {
\r
2276 user_data->resp = TRESP_SS_WAITING_ACTIVATE;
\r
2279 else if (opco == SS_OPCO_DEACTIVATE) {
\r
2280 user_data->resp = TRESP_SS_WAITING_DEACTIVATE;
\r
2281 mode =0; //disable
\r
2284 dbg("[ error ] unknown ss mode (0x%x)", opco);
\r
2286 switch(waiting->class) {
\r
2287 case SS_CLASS_ALL_TELE:
\r
2290 case SS_CLASS_VOICE:
\r
2293 case SS_CLASS_ALL_DATA_TELE:
\r
2296 case SS_CLASS_FAX:
\r
2299 case SS_CLASS_SMS:
\r
2305 dbg("unsupported class %d. set to default : 1", waiting->class);
\r
2308 dbg("mode = %d classxx- %d", mode , classx);
\r
2310 user_data->class = waiting->class;
\r
2311 user_data->flavor_type = (int)opco;
\r
2313 cmd_str = g_strdup_printf("AT+CCWA=1,%d,%d", mode, classx); //always enable +CCWA: unsolicited cmd
\r
2314 dbg("request command : %s",cmd_str);
\r
2316 hal = tcore_object_get_hal(o);
\r
2317 pending = tcore_pending_new(o, 0);
\r
2318 req = tcore_at_request_new(cmd_str, NULL, TCORE_AT_NO_RESULT);
\r
2319 dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
\r
2321 tcore_pending_set_request_data(pending, 0, req);
\r
2323 ret = _ss_request_message(pending, o, ur, on_response_ss_waiting_set, user_data);
\r
2326 dbg("AT request sent failed ")
\r
2327 return TCORE_RETURN_FAILURE;
\r
2329 return TCORE_RETURN_SUCCESS;
\r
2332 static TReturn _ss_waiting_get(CoreObject *o,
\r
2334 enum telephony_ss_class class,
\r
2335 enum tcore_response_command resp)
\r
2339 struct ss_confirm_info *user_data = 0;
\r
2340 gboolean ret = FALSE;
\r
2341 int classx; //mode,
\r
2344 TcorePending *pending = NULL;
\r
2345 TcoreATRequest *req;
\r
2347 dbg("function enter")
\r
2349 case SS_CLASS_ALL_TELE:
\r
2352 case SS_CLASS_VOICE:
\r
2355 case SS_CLASS_ALL_DATA_TELE:
\r
2358 case SS_CLASS_FAX:
\r
2361 case SS_CLASS_SMS:
\r
2367 dbg("unsupported class %d. set to default : 7", class);
\r
2370 dbg("classx - %d", classx);
\r
2372 dbg("allocating user data");
\r
2373 user_data = g_new0(struct ss_confirm_info, 1);
\r
2374 user_data->resp = resp;
\r
2375 user_data->class = class;
\r
2377 cmd_str = g_strdup_printf("AT+CCWA=1,2,%d", classx); //always enable +CCWA: unsolicited cmd , mode is fixed to 2(query status)
\r
2378 dbg("request cmd : %s", cmd_str);
\r
2380 hal = tcore_object_get_hal(o);
\r
2381 pending = tcore_pending_new(o, 0);
\r
2382 req = tcore_at_request_new(cmd_str, "+CCWA", TCORE_AT_MULTILINE);
\r
2383 dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
\r
2385 tcore_pending_set_request_data(pending, 0, req);
\r
2387 ret = _ss_request_message(pending, o, ur, on_response_ss_waiting_get, user_data);
\r
2390 dbg("AT request sent failed ")
\r
2391 return TCORE_RETURN_FAILURE;
\r
2393 return TCORE_RETURN_SUCCESS;
\r
2396 static TReturn s_ss_waiting_activate(CoreObject *o, UserRequest *ur)
\r
2398 return _ss_waiting_set(o, ur, SS_OPCO_ACTIVATE);
\r
2401 static TReturn s_ss_waiting_deactivate(CoreObject *o, UserRequest *ur)
\r
2403 return _ss_waiting_set(o, ur, SS_OPCO_DEACTIVATE);
\r
2406 static TReturn s_ss_waiting_get_status(CoreObject *o, UserRequest *ur)
\r
2408 struct treq_ss_waiting *waiting = 0;
\r
2409 waiting = (struct treq_ss_waiting*)tcore_user_request_ref_data(ur, 0);
\r
2411 return _ss_waiting_get(o, ur, waiting->class, TRESP_SS_WAITING_GET_STATUS);
\r
2414 static TReturn s_ss_cli_activate(CoreObject *o, UserRequest *ur)
\r
2416 return TCORE_RETURN_SUCCESS;
\r
2419 static TReturn s_ss_cli_deactivate(CoreObject *o, UserRequest *ur)
\r
2421 return TCORE_RETURN_SUCCESS;
\r
2424 static TReturn s_ss_cli_get_status(CoreObject *o, UserRequest *ur)
\r
2427 struct treq_ss_cli *cli = 0;
\r
2428 gboolean ret = FALSE;
\r
2429 char *cmd_prefix = NULL, *rsp_prefix = NULL, *cmd_str = NULL;
\r
2430 enum telephony_ss_cli_type *user_data = 0;
\r
2432 TcorePending *pending = NULL;
\r
2433 TcoreATRequest *req;
\r
2435 cli = (struct treq_ss_cli*)tcore_user_request_ref_data(ur, 0);
\r
2436 switch(cli->type) {
\r
2437 case SS_CLI_TYPE_CLIP:
\r
2438 cmd_prefix = "+CLIP";
\r
2439 rsp_prefix = "+CLIP";
\r
2442 case SS_CLI_TYPE_CLIR:
\r
2443 cmd_prefix = "+CLIR";
\r
2444 rsp_prefix = "+CLIR";
\r
2447 case SS_CLI_TYPE_COLP:
\r
2448 cmd_prefix = "+COLP";
\r
2449 rsp_prefix = "+COLP";
\r
2452 case SS_CLI_TYPE_COLR:
\r
2453 cmd_prefix = "+COLR";
\r
2454 rsp_prefix = "+COLR";
\r
2457 case SS_CLI_TYPE_CNAP:
\r
2458 cmd_prefix = "+CNAP";
\r
2459 rsp_prefix = "+CNAP";
\r
2462 case SS_CLI_TYPE_CDIP:
\r
2464 dbg("unsupported cli_type : %d", cli->type);
\r
2465 return TCORE_RETURN_FAILURE;
\r
2468 dbg("cmd_prefix : %s",cmd_prefix);
\r
2470 cmd_str = g_strdup_printf("AT%s?", cmd_prefix);
\r
2471 dbg("request cmd : %s", cmd_str);
\r
2473 user_data = g_new0(enum telephony_ss_cli_type, 1);
\r
2474 *user_data = cli->type;
\r
2476 hal = tcore_object_get_hal(o);
\r
2477 pending = tcore_pending_new(o, 0);
\r
2479 req = tcore_at_request_new(cmd_str, rsp_prefix, TCORE_AT_SINGLELINE);
\r
2480 dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
\r
2481 tcore_pending_set_request_data(pending, 0, req);
\r
2483 ret = _ss_request_message(pending, o, ur, on_response_ss_cli_get, user_data);
\r
2486 dbg("AT request sent failed ")
\r
2487 return TCORE_RETURN_FAILURE;
\r
2489 return TCORE_RETURN_SUCCESS;
\r
2492 static TReturn s_ss_send_ussd(CoreObject *o, UserRequest *ur)
\r
2494 UssdSession *ussd_s = 0;
\r
2495 struct treq_ss_ussd *ussd = 0;
\r
2496 struct ss_confirm_info *user_data = 0;
\r
2497 gboolean ret = FALSE;
\r
2500 TcorePending *pending = NULL;
\r
2501 TcoreATRequest *req;
\r
2503 dbg("function enter");
\r
2504 ussd = (struct treq_ss_ussd*)tcore_user_request_ref_data(ur, 0);
\r
2505 cmd_str = g_strdup_printf("AT+CUSD=1,\"%s\",%d", ussd->str, 0x0f); //always enable +CUSD: unsolicited cmd. set to dcs to 0x0f. only supports HEX type
\r
2506 dbg("request command : %s",cmd_str);
\r
2508 user_data = g_new0(struct ss_confirm_info, 1);
\r
2509 user_data->resp = TRESP_SS_SEND_USSD;
\r
2510 ussd_s = tcore_ss_ussd_get_session(o);
\r
2512 dbg("USSD session does not exist");
\r
2513 tcore_ss_ussd_create_session(o, (enum tcore_ss_ussd_type)ussd->type, (void*)tcore_user_request_ref(ur), 0);
\r
2517 if(ussd->type == SS_USSD_TYPE_USER_INITIATED) {
\r
2519 dbg("[ error ] ussd session is already exist");
\r
2520 g_free(user_data);
\r
2521 return TCORE_RETURN_FAILURE;
\r
2524 tcore_ss_ussd_set_session_type(ussd_s, (enum tcore_ss_ussd_type)ussd->type);
\r
2527 hal = tcore_object_get_hal(o);
\r
2528 pending = tcore_pending_new(o, 0);
\r
2529 req = tcore_at_request_new(cmd_str, NULL, TCORE_AT_NO_RESULT);
\r
2530 dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
\r
2532 tcore_pending_set_request_data(pending, 0, req);
\r
2534 ret = _ss_request_message(pending, o, ur, on_confirmation_ss_ussd, user_data);
\r
2539 dbg("AT request sent failed ")
\r
2540 return TCORE_RETURN_FAILURE;
\r
2542 return TCORE_RETURN_SUCCESS;
\r
2545 static TReturn s_ss_set_aoc(CoreObject *o, UserRequest *ur)
\r
2547 dbg("[ error ] unsupported function");
\r
2548 return TCORE_RETURN_SUCCESS;
\r
2551 static TReturn s_ss_get_aoc(CoreObject *o, UserRequest *ur)
\r
2553 dbg("[ error ] unsupported function");
\r
2554 return TCORE_RETURN_SUCCESS;
\r
2558 static struct tcore_call_control_operations call_ops = {
\r
2559 .answer_hold_and_accept = s_ss_manage_call_2_send,
\r
2560 .answer_replace = s_ss_manage_call_1_send,
\r
2561 .answer_reject = s_ss_manage_call_0_send,
\r
2562 .end_specific = s_ss_manage_call_1x_send,
\r
2563 .end_all_active = s_ss_manage_call_1_send,
\r
2564 .end_all_held = s_ss_manage_call_0_send,
\r
2565 .active = s_ss_manage_call_2_send,
\r
2566 .hold = s_ss_manage_call_2_send,
\r
2567 .swap = s_ss_manage_call_2_send,
\r
2568 .join = s_ss_manage_call_3_send,
\r
2569 .split = s_ss_manage_call_2x_send,
\r
2570 .transfer = s_ss_manage_call_4_send,
\r
2571 .deflect = s_ss_manage_call_4dn_send,
\r
2574 static TReturn s_ss_manage_call_send(CoreObject* o, UserRequest* ur, const char* cmd, ConfirmCallback cb, void* user_data)
\r
2576 TcorePending *pending = NULL;
\r
2577 TcoreATRequest *req;
\r
2578 gboolean ret = FALSE;
\r
2580 pending = tcore_pending_new(o, 0);
\r
2581 req = tcore_at_request_new(cmd, NULL, TCORE_AT_NO_RESULT);
\r
2582 dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
\r
2583 tcore_pending_set_request_data(pending, 0, req);
\r
2585 ret = _ss_request_message(pending, o, ur, (TcorePendingResponseCallback)cb, user_data);
\r
2587 dbg("AT request sent failed ")
\r
2588 return TCORE_RETURN_FAILURE;
\r
2590 return TCORE_RETURN_SUCCESS;
\r
2593 static TReturn s_ss_manage_call_0_send(CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data)
\r
2595 char* cmd_str = NULL;
\r
2596 gboolean ret = FALSE;
\r
2598 dbg("function enter");
\r
2599 cmd_str = g_strdup_printf("%s", "AT+CHLD=0");
\r
2600 dbg("cmd : %s, prefix(if any) : %s, cmd_len : %d",cmd_str, "N/A", strlen(cmd_str));
\r
2602 ret = s_ss_manage_call_send(o, ur, cmd_str, cb, user_data);
\r
2607 static TReturn s_ss_manage_call_1_send(CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data)
\r
2609 char* cmd_str = NULL;
\r
2610 gboolean ret = FALSE;
\r
2612 dbg("function enter");
\r
2613 cmd_str = g_strdup_printf("%s", "AT+CHLD=1");
\r
2614 dbg("cmd : %s, prefix(if any) : %s, cmd_len : %d",cmd_str, "N/A", strlen(cmd_str));
\r
2616 ret = s_ss_manage_call_send(o, ur, cmd_str, cb, user_data);
\r
2621 static TReturn s_ss_manage_call_1x_send(CoreObject* o, UserRequest* ur, const int id, ConfirmCallback cb, void* user_data)
\r
2623 char* cmd_str = NULL;
\r
2624 gboolean ret = FALSE;
\r
2626 dbg("function enter");
\r
2627 cmd_str = g_strdup_printf("%s%d", "AT+CHLD=1", id);
\r
2628 dbg("cmd : %s, prefix(if any) : %s, cmd_len : %d",cmd_str, "N/A", strlen(cmd_str));
\r
2630 ret = s_ss_manage_call_send(o, ur, cmd_str, cb, user_data);
\r
2635 static TReturn s_ss_manage_call_2_send(CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data)
\r
2637 char* cmd_str = NULL;
\r
2638 gboolean ret = FALSE;
\r
2640 dbg("function enter");
\r
2641 cmd_str = g_strdup_printf("%s", "AT+CHLD=2");
\r
2642 dbg("cmd : %s, prefix(if any) : %s, cmd_len : %d",cmd_str, "N/A", strlen(cmd_str));
\r
2644 ret = s_ss_manage_call_send(o, ur, cmd_str, cb, user_data);
\r
2650 static TReturn s_ss_manage_call_2x_send(CoreObject* o, UserRequest* ur, const int id, ConfirmCallback cb, void* user_data)
\r
2652 char* cmd_str = NULL;
\r
2653 gboolean ret = FALSE;
\r
2655 dbg("function enter");
\r
2656 cmd_str = g_strdup_printf("%s%d", "AT+CHLD=2", id);
\r
2657 dbg("cmd : %s, prefix(if any) : %s, cmd_len : %d",cmd_str, "N/A", strlen(cmd_str));
\r
2659 ret = s_ss_manage_call_send(o, ur, cmd_str, cb, user_data);
\r
2664 static TReturn s_ss_manage_call_3_send(CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data)
\r
2666 char* cmd_str = NULL;
\r
2667 gboolean ret = FALSE;
\r
2669 dbg("function enter");
\r
2670 cmd_str = g_strdup_printf("%s", "AT+CHLD=3");
\r
2672 ret = s_ss_manage_call_send(o, ur, cmd_str, cb, user_data);
\r
2678 static TReturn s_ss_manage_call_4_send(CoreObject* o, UserRequest* ur, ConfirmCallback cb, void* user_data)
\r
2680 char* cmd_str = NULL;
\r
2681 gboolean ret = FALSE;
\r
2683 dbg("function enter");
\r
2684 cmd_str = g_strdup_printf("%s", "AT+CHLD=4");
\r
2686 ret = s_ss_manage_call_send(o, ur, cmd_str, cb, user_data);
\r
2691 static TReturn s_ss_manage_call_4dn_send(CoreObject* o, UserRequest* ur, const char* number, ConfirmCallback cb, void* user_data)
\r
2694 char* cmd_str = NULL;
\r
2695 gboolean ret = FALSE;
\r
2697 dbg("function enter");
\r
2698 cmd_str = g_strdup_printf("%s%s", "AT+CHLD=4", number);
\r
2700 ret = s_ss_manage_call_send(o, ur, cmd_str, cb, user_data);
\r
2706 gboolean s_ss_init(TcorePlugin *p, TcoreHal *h)
\r
2708 CoreObject *so = 0, *co = 0;
\r
2709 struct property_call_info *data = 0;
\r
2711 so = tcore_ss_new(p, "ss", &ss_ops, h);
\r
2713 dbg("[ error ] ss_new()");
\r
2717 co = tcore_plugin_ref_core_object(p, "call");
\r
2719 dbg("[ error ] plugin_ref_core_object");
\r
2723 tcore_call_control_set_operations(co, &call_ops);
\r
2725 tcore_object_add_callback(so, "+CSSU", on_notification_ss_info, 0);
\r
2726 tcore_object_add_callback(so, "+CSSI", on_notification_ss_info, 0);
\r
2727 tcore_object_add_callback(so, "+CUSD", on_notification_ss_ussd, 0);
\r
2729 data = calloc(sizeof(struct property_call_info *), 1);
\r
2730 tcore_plugin_link_property(p, "SS", data);
\r
2735 void s_ss_exit(TcorePlugin *p)
\r
2738 struct property_network_info *data;
\r
2740 o = tcore_plugin_ref_core_object(p, "ss");
\r
2742 data = tcore_plugin_ref_property(p, "SS");
\r