/*
* tel-plugin-imc
*
- * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved.
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: sharanayya mathapati <sharan.m@samsung.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* limitations under the License.
*/
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-
#include <glib.h>
#include <tcore.h>
-#include <server.h>
-#include <plugin.h>
-#include <core_object.h>
#include <hal.h>
+#include <core_object.h>
+#include <plugin.h>
#include <queue.h>
-#include <storage.h>
-#include <at.h>
-
+#include <co_call.h>
#include <co_ss.h>
+#include <user_request.h>
+#include <util.h>
+#include <server.h>
+#include <at.h>
-#include "imc_ss.h"
#include "imc_common.h"
+#include "imc_ss.h"
-/* AT+CUSD = [<n> [, <str> [, <dcs>]]]
- * where,
- * <n>
- * 0 Disable
- * 1 Enable
- * 2 Cancel the session
- *
- * <str>
- * Ussd string
- *
- * <dcs>
- * Decoding format
- */
-static gboolean on_notification_imc_ss_ussd(CoreObject *co, const void *event_data,
- void *user_data)
+#define NUM_TYPE_INTERNATIONAL 0x01
+#define NUM_PLAN_ISDN 0x01
+
+// To avoid sending multiple response to application
+static gboolean UssdResp = FALSE;
+
+enum telephony_ss_opcode {
+ SS_OPCO_REG = 0x01, /* 0x01 : Registration */
+ SS_OPCO_DEREG, /* 0x02 : De-registration(erase) */
+ SS_OPCO_ACTIVATE, /* 0x03 : Activation */
+ SS_OPCO_DEACTIVATE, /* 0x04 : De-activation */
+ SS_OPCO_MAX
+};
+
+struct ss_confirm_info {
+ enum telephony_ss_class class;
+ int flavor_type;
+ enum tcore_response_command resp;
+ void *data;
+ int data_len;
+};
+
+static gboolean _ss_request_message(TcorePending *pending, CoreObject *o, UserRequest *ur, void *on_resp, void *user_data);
+
+static TReturn _ss_barring_get(CoreObject *o, UserRequest *ur, enum telephony_ss_class class, enum telephony_ss_barring_mode type, enum tcore_response_command resp);
+
+static TReturn _ss_forwarding_get(CoreObject *o, UserRequest *ur, enum telephony_ss_class class, enum telephony_ss_forwarding_mode type, enum tcore_response_command resp);
+
+static TReturn _ss_waiting_get(CoreObject *o, UserRequest *ur, enum telephony_ss_class class, enum tcore_response_command resp);
+
+static TReturn imc_ss_barring_activate(CoreObject *o, UserRequest *ur);
+static TReturn imc_ss_barring_deactivate(CoreObject *o, UserRequest *ur);
+static TReturn imc_ss_barring_change_password(CoreObject *o, UserRequest *ur);
+static TReturn imc_ss_barring_get_status(CoreObject *o, UserRequest *ur);
+
+static TReturn imc_ss_forwarding_activate(CoreObject *o, UserRequest *ur);
+static TReturn imc_ss_forwarding_deactivate(CoreObject *o, UserRequest *ur);
+static TReturn imc_ss_forwarding_register(CoreObject *o, UserRequest *ur);
+static TReturn imc_ss_forwarding_deregister(CoreObject *o, UserRequest *ur);
+static TReturn imc_ss_forwarding_get_status(CoreObject *o, UserRequest *ur);
+
+static TReturn imc_ss_waiting_activate(CoreObject *o, UserRequest *ur);
+static TReturn imc_ss_waiting_deactivate(CoreObject *o, UserRequest *ur);
+static TReturn imc_ss_waiting_get_status(CoreObject *o, UserRequest *ur);
+
+static TReturn imc_ss_cli_activate(CoreObject *o, UserRequest *ur);
+static TReturn imc_ss_cli_deactivate(CoreObject *o, UserRequest *ur);
+static TReturn imc_ss_cli_get_status(CoreObject *o, UserRequest *ur);
+
+static TReturn imc_ss_send_ussd(CoreObject *o, UserRequest *ur);
+
+static TReturn imc_ss_set_aoc(CoreObject *o, UserRequest *ur);
+static TReturn imc_ss_get_aoc(CoreObject *o, UserRequest *ur);
+
+static TReturn imc_ss_manage_call_0_send(CoreObject *o, UserRequest *ur, ConfirmCallback cb, void *user_data);
+static TReturn imc_ss_manage_call_1_send(CoreObject *o, UserRequest *ur, ConfirmCallback cb, void *user_data);
+static TReturn imc_ss_manage_call_1x_send(CoreObject *o, UserRequest *ur, const int id, ConfirmCallback cb, void *user_data);
+static TReturn imc_ss_manage_call_2_send(CoreObject *o, UserRequest *ur, ConfirmCallback cb, void *user_data);
+static TReturn imc_ss_manage_call_2x_send(CoreObject *o, UserRequest *ur, const int id, ConfirmCallback cb, void *user_data);
+static TReturn imc_ss_manage_call_3_send(CoreObject *o, UserRequest *ur, ConfirmCallback cb, void *user_data);
+static TReturn imc_ss_manage_call_4_send(CoreObject *o, UserRequest *ur, ConfirmCallback cb, void *user_data);
+static TReturn imc_ss_manage_call_4dn_send(CoreObject *o, UserRequest *ur, const char *number, ConfirmCallback cb, void *user_data);
+
+static void on_confirmation_ss_message_send(TcorePending *p, gboolean result, void *user_data);
+
+static void _ss_ussd_response(UserRequest *ur, const char *ussd_str, enum telephony_ss_ussd_type type, enum telephony_ss_ussd_status status);
+static void _ss_ussd_notification(TcorePlugin *p, const char *ussd_str, enum telephony_ss_ussd_status status);
+
+static gboolean on_notification_ss_info(CoreObject *o, const void *data, void *user_data);
+static gboolean on_notification_ss_ussd(CoreObject *o, const void *data, void *user_data);
+
+
+static gboolean _ss_request_message(TcorePending *pending,
+ CoreObject *o,
+ UserRequest *ur,
+ void *on_resp,
+ void *user_data)
+{
+ TcoreHal *hal = NULL;
+ TReturn ret;
+ dbg("Entry");
+
+ if (on_resp) {
+ tcore_pending_set_response_callback(pending, on_resp, user_data);
+ }
+ tcore_pending_set_send_callback(pending, on_confirmation_ss_message_send, NULL);
+ if (ur) {
+ tcore_pending_link_user_request(pending, ur);
+ } else {
+ err("User Request is NULL, is this internal request??");
+ }
+
+ hal = tcore_object_get_hal(o);
+
+ // Send request to HAL
+ ret = tcore_hal_send_request(hal, pending);
+ if (TCORE_RETURN_SUCCESS != ret) {
+ err("Request send failed");
+ return FALSE;
+ }
+
+ dbg("Exit");
+ return TRUE;
+}
+
+static void _ss_ussd_response(UserRequest *ur, const char *ussd_str, enum telephony_ss_ussd_type type, enum telephony_ss_ussd_status status)
+{
+ struct tresp_ss_ussd resp;
+ dbg("Entry");
+
+ if (ur) {
+ memset(&resp, 0x0, sizeof(struct tresp_ss_ussd));
+ resp.type = type;
+ resp.status = status;
+ resp.err = SS_ERROR_NONE;
+ dbg("ussd_str = %s resp.type - %d resp.status - %d", ussd_str, resp.type, resp.status);
+
+ if (ussd_str) {
+ int len = strlen(ussd_str);
+ if (len < MAX_SS_USSD_LEN) {
+ memcpy(resp.str, ussd_str, len);
+ resp.str[len] = '\0';
+ } else {
+ memcpy(resp.str, ussd_str, MAX_SS_USSD_LEN);
+ resp.str[MAX_SS_USSD_LEN - 1] = '\0';
+ }
+ dbg("Response string: %s", resp.str);
+ } else {
+ dbg("USSD string is not present");
+ memset(resp.str, '\0', MAX_SS_USSD_LEN);
+ }
+ UssdResp = TRUE;
+ // Send response to TAPI
+ tcore_user_request_send_response(ur, TRESP_SS_SEND_USSD, sizeof(struct tresp_ss_ussd), &resp);
+ } else {
+ err("User request is NULL");
+ }
+
+ dbg("Exit");
+ return;
+}
+
+static void _ss_ussd_notification(TcorePlugin *p, const char *ussd_str, enum telephony_ss_ussd_status status)
+{
+ CoreObject *core_obj = 0;
+ struct tnoti_ss_ussd noti;
+
+ dbg("function enter");
+ if (!p) {
+ dbg("[ error ] p : (NULL)");
+ return;
+ }
+ noti.status = status;
+ if (ussd_str) {
+ int len = strlen(ussd_str);
+ if (len < MAX_SS_USSD_LEN) {
+ memcpy(noti.str, ussd_str, len);
+ noti.str[len] = '\0';
+ } else {
+ memcpy(noti.str, ussd_str, MAX_SS_USSD_LEN);
+ noti.str[MAX_SS_USSD_LEN - 1] = '\0';
+ }
+ } else {
+ memset(noti.str, '\0', MAX_SS_USSD_LEN);
+ }
+ dbg("noti.str - %s", noti.str);
+
+ core_obj = tcore_plugin_ref_core_object(p, CORE_OBJECT_TYPE_SS);
+ tcore_server_send_notification(tcore_plugin_ref_server(p),
+ core_obj,
+ TNOTI_SS_USSD,
+ sizeof(struct tnoti_ss_ussd),
+ (void *) ¬i);
+}
+
+static gboolean on_notification_ss_ussd(CoreObject *o, const void *data, void *user_data)
{
- gchar *cmd = 0;
- gchar *resp_str = NULL;
- guchar *dcs_str = NULL;
- TelUtilAlphabetFormat dcs = TEL_UTIL_ALPHABET_FORMAT_SMS_DEFAULT;
- gushort len;
+ enum telephony_ss_ussd_status status;
+ UssdSession *ussd_session = 0;
+ char *ussd_str = 0, *cmd = 0;
+ TcorePlugin *plugin = 0;
+ int m = -1, dcs = 0;
+ char *ussdnoti = NULL, *str = NULL, *dcs_str = NULL;
GSList *tokens = NULL;
GSList *lines = NULL;
- int ussd_status = 0;
- TelSsUssdNoti ussd_noti = {0,};
+ char *ussd_string = NULL;
+ unsigned int len;
- lines = (GSList *) event_data;
+ plugin = tcore_object_ref_plugin(o);
+ ussd_session = tcore_ss_ussd_get_session(o);
- if (g_slist_length(lines) != 1) {
- dbg("Unsolicited message but multiple lines");
+ dbg("function enter");
+ lines = (GSList *) data;
+ if (1 != g_slist_length(lines)) {
+ dbg("unsolicited msg but multiple line");
return TRUE;
}
-
cmd = (char *) (lines->data);
+ // parse ussd status
tokens = tcore_at_tok_new(cmd);
- /* Parse USSD status */
- resp_str = g_slist_nth_data(tokens, 0);
- if (NULL == resp_str) {
- err("status missing from +CUSD Notification");
+ // parse <m>
+ ussdnoti = g_slist_nth_data(tokens, 0);
+ if (!ussdnoti) {
+ dbg("+CUSD<m> is missing from %CUSD Notification");
+ } else {
+ m = atoi(ussdnoti);
+ dbg("USSD status %d", m);
+ // parse [ <str>, <dcs>]
+ ussd_string = g_slist_nth_data(tokens, 1);
+ if (ussd_string) {
+ /* Strike off starting & ending quotes. 1 extra character for NULL termination */
+ str = malloc(strlen(ussd_string) - 1);
+ dbg("length of Ussd Stirng - %d", strlen(ussd_string));
+ if (str) {
+ memset(str, 0x00, strlen(ussd_string) - 1);
+ } else {
+ dbg("malloc failed");
+ if (NULL != tokens) {
+ tcore_at_tok_free(tokens);
+ }
+ return FALSE;
+ }
+ len = strlen(ussd_string) - 1;
+ ++ussd_string;
+ strncpy(str, ussd_string, len);
+
+ dbg("USSD String - %s len = %d", str, strlen(str));
+ }
+ if ((dcs_str = g_slist_nth_data(tokens, 2))) {
+ dcs = atoi(dcs_str);
+ dbg("USSD dcs %d", dcs);
+ }
+ }
+
+ switch (m) {
+ case 0:
+ status = SS_USSD_NO_ACTION_REQUIRE;
+ break;
+
+ case 1:
+ status = SS_USSD_ACTION_REQUIRE;
+ break;
+
+ case 2:
+ status = SS_USSD_TERMINATED_BY_NET;
+ break;
+
+ case 3:
+ status = SS_USSD_OTHER_CLIENT;
+ break;
+
+ case 4:
+ status = SS_USSD_NOT_SUPPORT;
+ break;
+
+ case 5:
+ status = SS_USSD_TIME_OUT;
+ break;
+
+ default:
+ dbg("unsupported m : %d", m);
+ status = SS_USSD_MAX;
+ break;
+ }
+
+ switch (tcore_util_get_cbs_coding_scheme(dcs)) {
+ case TCORE_DCS_TYPE_7_BIT:
+ case TCORE_DCS_TYPE_UNSPECIFIED:
+ // ussd_str = tcore_util_unpack_gsm7bit(str, strlen(str));
+ // break;
+
+ case TCORE_DCS_TYPE_UCS2:
+ case TCORE_DCS_TYPE_8_BIT:
+ if ((str != NULL) && (strlen(str) > 0)) {
+ ussd_str = g_new0(char, strlen(str) + 1);
+ if (ussd_str != NULL) {
+ memcpy(ussd_str, str, strlen(str));
+ ussd_str[strlen(str)] = '\0';
+ }
+ }
+ break;
+
+ default:
+ dbg("[ error ] unknown dcs type. ussd_session : %x", ussd_session);
+ if (ussd_session) {
+ UserRequest *ur = 0;
+ enum telephony_ss_ussd_type type;
+
+ tcore_ss_ussd_get_session_data(ussd_session, (void **) &ur);
+ if (!ur) {
+ dbg("[ error ] ur : (0)");
+ goto CATCH;
+ }
+
+ type = (enum telephony_ss_ussd_type) tcore_ss_ussd_get_session_type(ussd_session);
+ dbg("ussd type - %d", type);
+
+ _ss_ussd_response(ur, ussd_str, type, status);
+ }
+
+CATCH:
+ if (NULL != tokens) {
+ tcore_at_tok_free(tokens);
+ }
+
+ if (NULL != str) {
+ free(str);
+ }
+ return FALSE;
+ }
+
+ switch (status) {
+ case SS_USSD_NO_ACTION_REQUIRE:
+ case SS_USSD_ACTION_REQUIRE:
+ case SS_USSD_OTHER_CLIENT:
+ case SS_USSD_NOT_SUPPORT:
+ case SS_USSD_TIME_OUT:
+ {
+ if (ussd_session) {
+ UserRequest *ur = 0;
+ enum telephony_ss_ussd_type type;
+
+ tcore_ss_ussd_get_session_data(ussd_session, (void **) &ur);
+ if (!ur) {
+ dbg("[ error ] ur : (0)");
+ if (NULL != tokens) {
+ tcore_at_tok_free(tokens);
+ }
+
+ if (NULL != str) {
+ free(str);
+ }
+
+ if (ussd_str) {
+ g_free(ussd_str);
+ }
+ return FALSE;
+ }
+ type = (enum telephony_ss_ussd_type) tcore_ss_ussd_get_session_type(ussd_session);
+ dbg("ussd type - %d", type);
+ _ss_ussd_response(ur, (const char *) ussd_str, type, status);
+ if (ussd_str)
+ g_free(ussd_str);
+ } else {
+ tcore_ss_ussd_create_session(o, TCORE_SS_USSD_TYPE_NETWORK_INITIATED, 0, 0);
+ _ss_ussd_notification(plugin, (const char *) ussd_str, status);
+
+ if (ussd_str)
+ g_free(ussd_str);
+ }
+ }
+ break;
+
+ case SS_USSD_TERMINATED_BY_NET:
+ {
+ if (ussd_session) {
+ UserRequest *ur = 0;
+ tcore_ss_ussd_get_session_data(ussd_session, (void **) &ur);
+ if (ur) {
+ tcore_user_request_unref(ur);
+ }
+ tcore_ss_ussd_destroy_session(ussd_session);
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ if (NULL != tokens) {
tcore_at_tok_free(tokens);
+ }
+
+ if (NULL != str) {
+ free(str);
+ }
+
+ dbg("Exit");
+ return TRUE;
+}
+
+static gboolean on_notification_ss_info(CoreObject *o, const void *data, void *user_data)
+{
+ TcorePlugin *plugin = 0;
+ CoreObject *co = 0;
+ char *cmd = 0, *number = 0, *pos;
+ int code1 = -1, code2 = -1, index = 0, ton = 0;
+ char *str_code1, *str_code2, *str_ton, *str_index;
+ GSList *tokens = NULL;
+ char *buf;
+ gboolean cssu = FALSE, cssi = FALSE;
+ GSList *lines = NULL;
+ char *resp = NULL;
+ dbg("function enter");
+
+ plugin = tcore_object_ref_plugin(o);
+ co = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_CALL);
+ if (!co) {
+ dbg("[ error ] plugin_ref_core_object : call");
+ return FALSE;
+ }
+
+ lines = (GSList *) data;
+ if (1 != g_slist_length(lines)) {
+ dbg("unsolicited msg but multiple line");
+ goto OUT;
+ }
+
+ cmd = (char *) (lines->data);
+ pos = strchr(cmd, ':');
+ if (!pos) {
+ dbg("[ error ] not valid SS- notification ");
return TRUE;
+ }
+ buf = calloc(pos - cmd + 2, 1);
+ memcpy(buf, cmd, pos - cmd);
+ dbg("buf is %s", buf);
+
+ if (!strcmp(buf, "+CSSU")) {
+ dbg("SS - +CSSU indication");
+ cssu = TRUE;
+ } else if (!strcmp(buf, "+CSSI")) {
+ dbg("SS - +CSSI indication");
+ cssi = TRUE;
+ }
+ free(buf);
+
+ // handle %CSSU notification
+ if (cssu) {
+ tokens = tcore_at_tok_new(cmd);
+ // parse <code2>
+ str_code2 = g_slist_nth_data(tokens, 0);
+ if (!str_code2) {
+ dbg("Code2 is missing from %CSSU indiaction");
+ } else {
+ code2 = atoi(str_code2);
+ // parse [ <index>, <number> <type>]
+ if ((str_index = g_slist_nth_data(tokens, 1))) {
+ index = atoi(str_index);
+ }
+
+ if ((resp = g_slist_nth_data(tokens, 2))) {
+ // Strike off double quotes
+ number = util_removeQuotes(resp);
+ str_ton = g_slist_nth_data(tokens, 3);
+
+ if (str_ton) {
+ ton = atoi(str_ton);
+ }
+ }
+ }
+
+ dbg("CSSU - code2 = %d index = %d number = %s type = %d", code2, index, number, ton);
+ switch (code2) {
+ case 0: // this is a forwarded call (MT call setup)
+ tcore_call_information_mt_forwarded_call(co, number);
+ break;
+
+ case 2: // call has been put on hold (during a voice call)
+ tcore_call_information_held(co, number);
+ break;
+
+ case 3: // call has been retrieved (during a voice call)
+ tcore_call_information_active(co, number);
+ break;
+
+ case 4: // multiparty call entered (during a voice call)
+ tcore_call_information_joined(co, number);
+ break;
+
+ case 5: // call on hold has been released
+ tcore_call_information_released_on_hold(co, number);
+ break;
+
+ case 6: // forward check SS message received (can be received whenever)
+ tcore_call_information_cf_check_ss_message(co, number);
+ break;
+
+ case 7: // call is being connected (alerting) with the remote party in alerting state in explicit call transfer operation (during a voice call)
+ tcore_call_information_transfer_alert(co, number);
+ break;
+
+ 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)
+ tcore_call_information_transfered(co, number);
+ break;
+
+ case 9: // this is a deflected call (MT call setup):
+ tcore_call_information_mt_deflected_call(co, number);
+ break;
+
+ default:
+ dbg("CSSU - unsupported code2 : %d", code2);
+ break;
+ }
+ }
+ // handle %CSSI notification
+
+ if (cssi) {
+ tokens = tcore_at_tok_new(cmd);
+ // parse <code1>
+ str_code1 = g_slist_nth_data(tokens, 0);
+ if (!str_code1) {
+ dbg("Code1 is missing from %CSSI indiaction");
+ } else {
+ code1 = atoi(str_code1);
+ // parse [ <index> ]
+ if ((str_index = g_slist_nth_data(tokens, 1))) {
+ index = atoi(str_index);
+ }
+ }
+
+ dbg("CSSI - code1 - %d index - %d ", code1, index);
+
+ switch (code1) {
+ case 0: // Unconditional CF is active
+ tcore_call_information_mo_cfu(co);
+ break;
+
+ case 1: // some of the conditional call forwarding are active
+ tcore_call_information_mo_cfc(co);
+ break;
+
+ case 2: // outgoing call is forwarded
+ tcore_call_information_mo_forwarded(co);
+ break;
+
+ case 3: // this call is waiting
+ tcore_call_information_mo_waiting(co);
+ break;
+
+ case 5: // outgoing call is barred
+ tcore_call_information_mo_barred_outgoing(co);
+ break;
+
+ case 6: // incoming call is barred
+ tcore_call_information_mo_barred_incoming(co);
+ break;
+
+ case 7: // CLIR suppression rejected
+ tcore_call_information_mo_clir_suppression_reject(co);
+ break;
+
+ case 8: // outgoing call is deflected
+ tcore_call_information_mo_deflected(co);
+ break;
+
+ default:
+ dbg("unsupported cmd : %d", code1);
+ break;
+ }
+ }
+OUT:
+ if (NULL != tokens) {
+ tcore_at_tok_free(tokens);
+ }
+
+ g_free(number);
+ return TRUE;
+}
+
+static void on_confirmation_ss_message_send(TcorePending *p, gboolean result, void *user_data)
+{
+ dbg("");
+
+ if (result == FALSE) {
+ // Fail
+ dbg("FAIL");
+ } else {
+ dbg("SEND OK");
+ }
+}
+
+static void on_response_ss_barring_set(TcorePending *p, int data_len, const void *data, void *user_data)
+{
+ struct ss_confirm_info *info = 0;
+ enum telephony_ss_class class;
+ CoreObject *o = 0;
+ UserRequest *ur;
+ struct tresp_ss_barring resp = {0, };
+ UserRequest *ur_dup = 0;
+ GSList *tokens = NULL;
+ const char *line;
+ int error;
+ const TcoreATResponse *response;
+
+ dbg("function enter");
+ response = data;
+ o = tcore_pending_ref_core_object(p);
+ ur = tcore_pending_ref_user_request(p);
+
+ info = (struct ss_confirm_info *)user_data;
+ class = info->class;
+
+ if (response->success > 0) {
+ dbg("RESPONSE OK");
+ resp.err = SS_ERROR_NONE;
+ } else {
+ dbg("RESPONSE NOT OK");
+ line = (const char *)response->final_response;
+ tokens = tcore_at_tok_new(line);
+
+ if (g_slist_length(tokens) < 1) {
+ dbg("err cause not specified or string corrupted");
+ resp.err = SS_ERROR_SYSTEMFAILURE;
+ } else {
+ error = atoi(g_slist_nth_data(tokens, 0));
+ err("Error: [%d]", error);
+ /* TODO: CMEE error mapping is required. */
+ resp.err = SS_ERROR_SYSTEMFAILURE;
+ }
+ tcore_at_tok_free(tokens);
+ }
+
+ dbg("on_response_ss_barring_set - rsp.err : %d, ur : %x flavor_type = %d", resp.err, ur, info->flavor_type);
+ dbg("[ check ] class : 0x%x", info->class);
+
+ if (response->success > 0) {
+ if (info->class == SS_CLASS_VOICE) {
+ class = SS_CLASS_ALL_TELE_BEARER;
+ }
+
+ ur_dup = tcore_user_request_ref(ur);
+
+ if (info->flavor_type == SS_BARR_MODE_AB || info->flavor_type == SS_BARR_MODE_AOB) {
+ _ss_barring_get(o, ur_dup, class, SS_BARR_MODE_BAOC, info->resp);
+ } else if (info->flavor_type == SS_BARR_MODE_AIB) {
+ _ss_barring_get(o, ur_dup, class, SS_BARR_MODE_BAIC, info->resp);
+ } else {
+ _ss_barring_get(o, ur_dup, class, info->flavor_type, info->resp);
+ }
+ } else {
+ if (ur) {
+ tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_barring), &resp);
+ } else {
+ dbg("[ error ] ur is 0");
+ }
+ }
+ g_free(user_data);
+}
+
+static void on_response_ss_barring_change_pwd(TcorePending *p, int data_len, const void *data, void *user_data)
+{
+ const TcoreATResponse *response = data;
+ struct ss_confirm_info *info = 0;
+ UserRequest *ur;
+ struct tresp_ss_general resp;
+ int error;
+ GSList *tokens = NULL;
+ const char *line;
+
+ dbg("function enter");
+ ur = tcore_pending_ref_user_request(p);
+ info = (struct ss_confirm_info *) user_data;
+
+ if (response->success > 0) {
+ dbg("RESPONSE OK");
+ resp.err = SS_ERROR_NONE;
+ } else {
+ dbg("RESPONSE NOT OK");
+
+ line = (const char *) response->final_response;
+ tokens = tcore_at_tok_new(line);
+
+ if (g_slist_length(tokens) < 1) {
+ dbg("err cause not specified or string corrupted");
+ resp.err = SS_ERROR_SYSTEMFAILURE;
+ } else {
+ error = atoi(g_slist_nth_data(tokens, 0));
+ err("Error: [%d]", error);
+ // TODO: CMEE error mapping is required.
+ resp.err = SS_ERROR_SYSTEMFAILURE;
+ }
+ tcore_at_tok_free(tokens);
+ }
+
+ dbg("on_response_ss_barring_change_pwd: rsp.err : %d, usr : %x", resp.err, ur);
+ if (ur) {
+ tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_general), &resp);
+ } else {
+ dbg("[ error ] ur is 0");
+ }
+
+ g_free(user_data);
+}
+
+static void on_response_ss_forwarding_set(TcorePending *p, int data_len, const void *data, void *user_data)
+{
+ CoreObject *o = 0;
+ UserRequest *ur = 0, *dup_ur = 0;
+ struct ss_confirm_info *info = 0;
+ struct tresp_ss_forwarding resp = {0,};
+ GSList *tokens = NULL;
+ const char *line;
+ int error;
+ const TcoreATResponse *response;
+
+ dbg("function enter");
+
+ response = data;
+ o = tcore_pending_ref_core_object(p);
+ ur = tcore_pending_ref_user_request(p);
+
+ info = (struct ss_confirm_info *) user_data;
+
+ if (response->success > 0) {
+ dbg("RESPONSE OK");
+ resp.err = SS_ERROR_NONE;
+ } else {
+ dbg("RESPONSE NOT OK");
+
+ /* Extract Error */
+ line = (const char *) response->final_response;
+ tokens = tcore_at_tok_new(line);
+
+ if (g_slist_length(tokens) < 1) {
+ dbg("Error cause not specified or string corrupted");
+ resp.err = SS_ERROR_SYSTEMFAILURE;
+ } else {
+ error = atoi(g_slist_nth_data(tokens, 0));
+ err("Error: [%d]", error);
+ // / TODO: CMEE error mapping is required.
+ resp.err = SS_ERROR_SYSTEMFAILURE;
+ }
+
+ tcore_at_tok_free(tokens);
+ }
+
+ dbg("[ check ] class : 0x%x", info->class);
+ dbg("[ check ] flavor_type : 0x%x", info->flavor_type);
+
+ dbg("on_response_ss_forwarding_set - rsp.err : %d, ur : %x", resp.err, ur);
+
+ if (response->success > 0) {
+ if (info->flavor_type == SS_CF_MODE_CF_ALL ||
+ info->flavor_type == SS_CF_MODE_CFC) {
+ if (ur) {
+ tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_forwarding), &resp);
+ } else {
+ dbg("[ error ] ur is 0");
+ }
+ } else {
+ dup_ur = tcore_user_request_ref(ur);
+ _ss_forwarding_get(o, dup_ur, info->class, info->flavor_type, info->resp);
+ }
+ } else {
+ if (ur) {
+ tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_forwarding), &resp);
+ } else {
+ dbg("[ error ] ur is 0");
+ }
+ }
+ g_free(user_data);
+}
+
+static void on_response_ss_waiting_set(TcorePending *p, int data_len, const void *data, void *user_data)
+{
+ CoreObject *core_obj = 0;
+ UserRequest *ur = 0;
+ UserRequest *ur_dup = 0;
+ struct ss_confirm_info *info = 0;
+ struct tresp_ss_waiting resp = {0,};
+ GSList *tokens = NULL;
+ const char *line;
+ int error;
+ const TcoreATResponse *response;
+
+ dbg("function enter");
+ response = data;
+ core_obj = tcore_pending_ref_core_object(p);
+ ur = tcore_pending_ref_user_request(p);
+
+ info = (struct ss_confirm_info *)user_data;
+
+ if (response->success > 0) {
+ dbg("RESPONSE OK");
+ resp.err = SS_ERROR_NONE;
+ } else {
+ dbg("RESPONSE NOT OK");
+
+ /* Extract Error */
+ line = (const char *) response->final_response;
+ tokens = tcore_at_tok_new(line);
+
+ if (g_slist_length(tokens) < 1) {
+ dbg("Error cause not specified or string corrupted");
+ resp.err = SS_ERROR_SYSTEMFAILURE;
+ } else {
+ error = atoi(g_slist_nth_data(tokens, 0));
+ err("Error: [%d]", error);
+ /* TODO: CMEE error mapping is required. */
+ resp.err = SS_ERROR_SYSTEMFAILURE;
+ }
+
+ /* Free tokens */
+ tcore_at_tok_free(tokens);
+ }
+
+ dbg("Call Waiting - Error: [%d], UR: [0x%x] class: [0x%2x]", resp.err, ur, info->class);
+ if (resp.err == SS_ERROR_NONE) {
+ ur_dup = tcore_user_request_ref(ur);
+
+ dbg("Get Call Waiting status");
+ _ss_waiting_get(core_obj, ur_dup, info->class, info->resp);
+ } else {
+ if (ur) {
+ tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_waiting), &resp);
+ } else {
+ err("User request is NULL");
+ }
+ }
+ g_free(user_data);
+}
+
+
+static void on_confirmation_ss_ussd(TcorePending *p, int data_len, const void *data, void *user_data)
+{
+ CoreObject *core_obj = 0;
+ struct ss_confirm_info *info = 0;
+ struct tresp_ss_ussd resp;
+ UserRequest *ur = NULL, *ussd_ur = NULL;
+ GSList *tokens = NULL;
+ const char *line;
+ int error;
+ UssdSession *ussd_s = NULL;
+ enum tcore_ss_ussd_type type = TCORE_SS_USSD_TYPE_MAX;
+ const TcoreATResponse *response;
+
+ dbg("function enter");
+ response = data;
+ ur = tcore_pending_ref_user_request(p);
+ info = (struct ss_confirm_info *) user_data;
+
+ memset(resp.str, 0x00, MAX_SS_USSD_LEN);
+
+ core_obj = tcore_pending_ref_core_object(p);
+ ussd_s = tcore_ss_ussd_get_session(core_obj);
+
+ if (ussd_s)
+ type = tcore_ss_ussd_get_session_type(ussd_s);
+ else
+ dbg("[ error ] ussd_s : (0)");
+
+ resp.type = (enum telephony_ss_ussd_type) type;
+ resp.status = SS_USSD_MAX; // hardcoded value.
+
+ if (response->success > 0) {
+ dbg("RESPONSE OK");
+ resp.err = SS_ERROR_NONE;
+ } else {
+ dbg("RESPONSE NOT OK");
+
+ line = (const char *) response->final_response;
+ tokens = tcore_at_tok_new(line);
+
+ if (g_slist_length(tokens) < 1) {
+ dbg("err cause not specified or string corrupted");
+ resp.err = SS_ERROR_SYSTEMFAILURE;
+ } else {
+ error = atoi(g_slist_nth_data(tokens, 0));
+ err("Error: [%d]", error);
+ // TODO: CMEE error mapping is required.
+ resp.err = SS_ERROR_SYSTEMFAILURE;
+ }
+ tcore_at_tok_free(tokens);
+ }
+
+ dbg("on_confirmation_ss_ussd - rsp.err : %d, ur : %x", resp.err, ur);
+
+ if (response->success > 0) {
+ if (type == TCORE_SS_USSD_TYPE_USER_INITIATED) {
+ dbg("ussd type %d", resp.type);
+
+ if (ussd_s) {
+ tcore_ss_ussd_get_session_data(ussd_s, (void **) &ussd_ur);
+ if (ussd_ur)
+ tcore_user_request_free(ussd_ur);
+ }
+ }
+ }
+
+ if (ussd_s)
+ tcore_ss_ussd_destroy_session(ussd_s);
+
+ if (ur) {
+ if (UssdResp == FALSE) { // to avoid sending multiple response to application.
+ tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_ussd), &resp);
+ }
+ UssdResp = FALSE;
+ } else
+ dbg("[ error ] ur : (0)");
+
+ g_free(user_data);
+}
+
+static void on_response_ss_barring_get(TcorePending *p, int data_len, const void *data, void *user_data)
+{
+ UserRequest *ur = 0;
+ int status = 0, classx = 0, ss_err = 0;
+ GSList *respdata;
+ struct ss_confirm_info *info = 0;
+ struct tresp_ss_barring resp;
+ int countRecords = 0, countValidRecords = 0;
+ GSList *tokens = NULL;
+ const char *line;
+ char *classx_str;
+ char *stat = NULL;
+ const TcoreATResponse *response;
+
+ dbg("function enter");
+
+ response = data;
+ ur = tcore_pending_ref_user_request(p);
+ info = (struct ss_confirm_info *) user_data;
+
+ if (response->lines) {
+ respdata = (GSList *) response->lines;
+ countRecords = g_slist_length(respdata);
+ dbg("total records : %d", countRecords);
} else {
- ussd_status = atoi(resp_str);
- dbg("USSD status[%d]", ussd_status);
+ countRecords = 0;
+ dbg("no active status - return to user");
+ }
+ resp.record_num = countRecords;
+ resp.record = 0;
+ if (resp.record_num > 0) {
+ resp.record = g_new0(struct barring_info, resp.record_num);
+ for (countValidRecords = 0; respdata != NULL; respdata = respdata->next) {
+ line = (const char *) (respdata->data);
+ tokens = tcore_at_tok_new(line);
+
+ // parse <status>
+ stat = g_slist_nth_data(tokens, 0);
+ if (!stat) {
+ dbg("Stat is missing");
+ goto error;
+ }
+
+ status = atoi(stat);
+ if (status == 1) {
+ resp.record[countValidRecords].status = SS_STATUS_ACTIVATE;
+ } else {
+ resp.record[countValidRecords].status = SS_STATUS_DEACTIVATE;
+ }
+ dbg("call barring status - %d", status);
+
+ // Parse <class>
+ classx_str = g_slist_nth_data(tokens, 1);
+
+ if (!classx_str) {
+ dbg("class error. classx not exist - set to requested one : %d", info->class);
+ switch (info->class) {
+ case SS_CLASS_ALL_TELE:
+ classx = 7;
+ break;
+
+ case SS_CLASS_VOICE:
+ classx = 1;
+ break;
+
+ case SS_CLASS_ALL_DATA_TELE:
+ classx = 2;
+ break;
+
+ case SS_CLASS_FAX:
+ classx = 4;
+ break;
+
+ case SS_CLASS_SMS:
+ classx = 8;
+ break;
+
+ case SS_CLASS_ALL_CS_SYNC:
+ classx = 16;
+ break;
+
+ default:
+ classx = 7;
+ dbg("unsupported class %d. set to default : 7", info->class);
+ break;
+ }
+ } else {
+ classx = atoi(classx_str);
+ dbg("call barring classx - %d", classx);
+ }
+
+ switch (classx) {
+ case 1:
+ resp.record[countValidRecords].class = SS_CLASS_VOICE;
+ break;
+
+ case 2:
+ resp.record[countValidRecords].class = SS_CLASS_ALL_DATA_TELE;
+ break;
- if (ussd_status < TEL_SS_USSD_STATUS_NO_ACTION_REQUIRED ||
- ussd_status > TEL_SS_USSD_STATUS_TIME_OUT) {
- err("invalid USSD status");
+ case 4:
+ resp.record[countValidRecords].class = SS_CLASS_FAX;
+ break;
+
+ case 7:
+ resp.record[countValidRecords].class = SS_CLASS_ALL_TELE;
+ break;
+
+ case 8:
+ resp.record[countValidRecords].class = SS_CLASS_SMS;
+ break;
+
+ case 16:
+ resp.record[countValidRecords].class = SS_CLASS_ALL_CS_SYNC;
+ break;
+
+ case 32:
+ resp.record[countValidRecords].class = SS_CLASS_ALL_CS_ASYNC;
+ break;
+
+ default:
+ dbg("unspoorted class : [%d]\n", classx);
+ goto error;
+ break;
+ }
+ resp.record[countValidRecords].mode = (enum telephony_ss_barring_mode) (info->flavor_type);
+ countValidRecords++;
+ tcore_at_tok_free(tokens);
+ continue;
+
+error:
+ dbg("invalid field found. coutinue");
tcore_at_tok_free(tokens);
- return TRUE;
+ continue;
+ }
+
+ dbg("valid count :%d", countValidRecords);
+ resp.record_num = countValidRecords;
+ resp.err = SS_ERROR_NONE;
+ } else {
+ dbg("no active status - return to user");
+ }
+
+ if (response->success > 0) {
+ dbg("RESPONSE OK");
+ resp.err = SS_ERROR_NONE;
+ } else {
+ dbg("RESPONSE NOT OK");
+ resp.err = TCORE_RETURN_FAILURE;
+ resp.record = 0;
+ resp.record_num = 0;
+
+ line = (const char *) response->final_response;
+ tokens = tcore_at_tok_new(line);
+
+ if (g_slist_length(tokens) < 1) {
+ dbg("err cause not specified or string corrupted");
+ resp.err = SS_ERROR_SYSTEMFAILURE;
+ } else {
+ ss_err = atoi(g_slist_nth_data(tokens, 0));
+ err("Error: [%d]", ss_err);
+ // TODO: CMEE error mapping is required.
+ resp.err = SS_ERROR_SYSTEMFAILURE;
}
+ tcore_at_tok_free(tokens);
+ }
+
+ dbg("on_response_ss_barring_get- rsp.err : %d, ur : %x", resp.err, ur);
+
+ if (ur)
+ tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_barring), &resp);
+ else
+ dbg("[ error ] ur is 0");
+
+ if (resp.record) {
+ g_free(resp.record);
+ resp.record = NULL;
+ }
+
+ g_free(user_data);
+}
+
+static void on_response_ss_forwarding_get(TcorePending *p, int data_len, const void *data, void *user_data)
+{
+ UserRequest *ur = 0;
+ int classx = 0, ss_err = 0, time = 0;
+ char *num;
+ struct ss_confirm_info *info = 0;
+ struct tresp_ss_forwarding resp;
+ int countRecords = 0, countValidRecords = 0;
+
+ GSList *respdata = NULL, *tokens = NULL;
+ const char *line;
+ char *classx_str, *status, *ton, *time_str;
+ const TcoreATResponse *response;
+
+ dbg("function enter");
+ response = data;
+
+ ur = tcore_pending_ref_user_request(p);
+ info = (struct ss_confirm_info *) user_data;
+ if (response->lines) {
+ respdata = (GSList *) response->lines;
+ countRecords = g_slist_length(respdata);
+ dbg("total records : %d", countRecords);
+ } else {
+ countRecords = 0;
+ dbg("no active status - return to user");
+ }
+ resp.record_num = countRecords;
+ resp.record = 0;
+ if (resp.record_num > 0) {
+ resp.record = g_new0(struct forwarding_info, resp.record_num);
+
+ for (countValidRecords = 0; respdata != NULL; respdata = respdata->next) {
+ line = (const char *) (respdata->data);
+ tokens = tcore_at_tok_new(line);
+
+ // parse <status>
+ status = g_slist_nth_data(tokens, 0);
+ if (!status) {
+ dbg("start line error. skip this line");
+ goto error;
+ } else {
+ if (atoi(status) == 1) {
+ resp.record[countValidRecords].status = SS_STATUS_ACTIVATE;
+ } else {
+ resp.record[countValidRecords].status = SS_STATUS_DEACTIVATE;
+ }
+ }
+
+ // Parse <class>
+ classx_str = g_slist_nth_data(tokens, 1);
+ if (!classx_str) {
+ dbg("class error. skip this line");
+ goto error;
+ } else {
+ switch (atoi(classx_str)) {
+ case 1:
+ resp.record[countValidRecords].class = SS_CLASS_VOICE;
+ break;
+
+ case 2:
+ resp.record[countValidRecords].class = SS_CLASS_ALL_DATA_TELE;
+ break;
+
+ case 4:
+ resp.record[countValidRecords].class = SS_CLASS_FAX;
+ break;
+
+ case 7:
+ resp.record[countValidRecords].class = SS_CLASS_ALL_TELE;
+ break;
+
+ case 8:
+ resp.record[countValidRecords].class = SS_CLASS_SMS;
+ break;
+
+ case 16:
+ resp.record[countValidRecords].class = SS_CLASS_ALL_CS_SYNC;
+ break;
+
+ case 32:
+ resp.record[countValidRecords].class = SS_CLASS_ALL_CS_ASYNC;
+ break;
+
+ default:
+ dbg("unspoorted class : [%d]\n", classx);
+ goto error;
+ break;
+ }
+ }
+
+ // parse <numer> <type>
+ num = g_slist_nth_data(tokens, 2);
+ if (num) {
+ dbg("number - %s", num);
+ memcpy((resp.record[countValidRecords].number), num, strlen(num));
+ resp.record[countValidRecords].number_present = TRUE;
+
+ ton = g_slist_nth_data(tokens, 3);
+ if (ton) {
+ resp.record[countValidRecords].ton = atoi(ton);
+ dbg("number type - %d", resp.record[countValidRecords].ton);
+ }
+ }
- /*
- * When network terminated the USSD session, no need to
- * send notification to application
- */
- if (ussd_status == TEL_SS_USSD_STATUS_TERMINATED_BY_NETWORK) {
- /* destroy USSD session if any */
- UssdSession *ussd_session;
- ussd_session = tcore_ss_ussd_get_session(co);
+ // skip <subaddr> <satype>
+ // parse <time>
+ time_str = g_slist_nth_data(tokens, 6);
+ if (time_str) {
+ time = atoi(time_str);
+ resp.record[countValidRecords].time = (enum telephony_ss_forwarding_no_reply_time) time;
+ dbg("time - %d", time);
+ }
- if (ussd_session)
- tcore_ss_ussd_destroy_session(ussd_session);
+ resp.record[countValidRecords].mode = (enum telephony_ss_forwarding_mode) (info->flavor_type);
+ dbg("flavor_type - %d", (enum telephony_ss_forwarding_mode) (info->flavor_type));
+ countValidRecords++;
+ tcore_at_tok_free(tokens);
+ continue;
+error:
+ dbg("invalid field found. coutinue");
tcore_at_tok_free(tokens);
- return TRUE;
+ continue;
}
+ dbg("valid count :%d", countValidRecords);
+ resp.record_num = countValidRecords;
+ resp.err = SS_ERROR_NONE;
+ } else {
+ dbg("no active status - return to user");
+ }
- /* Parse USSD string */
- resp_str = g_slist_nth_data(tokens, 1);
+ if (response->success > 0) {
+ dbg("RESPONSE OK");
+ resp.err = SS_ERROR_NONE;
+ } else {
+ dbg("RESPONSE NOT OK");
+ resp.record = 0;
+ resp.record_num = 0;
+ line = (const char *) response->final_response;
+ tokens = tcore_at_tok_new(line);
- resp_str = tcore_at_tok_extract(resp_str);
- if (resp_str) {
- len = strlen((gchar *)resp_str);
- dbg("USSD String: [%s], len: [%d]", resp_str, len);
+ if (g_slist_length(tokens) < 1) {
+ dbg("err cause not specified or string corrupted");
+ resp.err = SS_ERROR_SYSTEMFAILURE;
} else {
- dbg("Ussd string missing from +CUSD Notification");
+ ss_err = atoi(g_slist_nth_data(tokens, 0));
+ err("Error: [%d]", ss_err);
+ /* TODO: CMEE error mapping is required. */
+ resp.err = SS_ERROR_SYSTEMFAILURE;
+ }
+ tcore_at_tok_free(tokens);
+ }
+
+ dbg("on_response_ss_forwarding_get- rsp.err : %d, ur : %x", resp.err, ur);
+ if (ur)
+ tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_forwarding), &resp);
+ else
+ dbg("[ error ] ur is 0");
+
+ if (resp.record) {
+ g_free(resp.record);
+ resp.record = NULL;
+ }
+ g_free(user_data);
+}
+
+static void on_response_ss_waiting_get(TcorePending *p, int data_len, const void *data, void *user_data)
+{
+ UserRequest *ur = 0;
+ GSList *respdata, *tokens = NULL;
+ int classx = 0, ss_err = 0;
+ struct ss_confirm_info *info = 0;
+ struct tresp_ss_waiting resp;
+ int countRecords = 0, countValidRecords = 0;
+ const char *line;
+ char *classx_str, *status;
+ const TcoreATResponse *response;
+
+ dbg("function enter");
+ response = data;
+ ur = tcore_pending_ref_user_request(p);
+ info = (struct ss_confirm_info *) user_data;
+
+ if (response->lines) {
+ respdata = (GSList *) response->lines;
+ countRecords = g_slist_length(respdata);
+ dbg("total records : %d", countRecords);
+ } else {
+ countRecords = 0;
+ dbg("no active status - return to user");
+ }
+ resp.record_num = countRecords;
+ resp.record = 0;
+
+ if (resp.record_num > 0) {
+ resp.record = g_new0(struct waiting_info, resp.record_num);
+
+ for (countValidRecords = 0; respdata != NULL; respdata = respdata->next) {
+ line = (const char *) (respdata->data);
+ tokens = tcore_at_tok_new(line);
+
+ // parse <status>
+ status = g_slist_nth_data(tokens, 0);
+ if (!status) {
+ dbg("Missing stat in responce ");
+ goto error;
+ } else {
+ if (atoi(status) == 1) {
+ resp.record[countValidRecords].status = SS_STATUS_ACTIVATE;
+ } else {
+ resp.record[countValidRecords].status = SS_STATUS_DEACTIVATE;
+ }
+ }
+ dbg("status = %d", resp.record[countValidRecords].status);
+
+ // Parse <class>
+ classx_str = g_slist_nth_data(tokens, 1);
+ if (!classx_str) {
+ dbg("error - class is missing");
+ goto error;
+ } else {
+ switch (atoi(classx_str)) {
+ case 1:
+ resp.record[countValidRecords].class = SS_CLASS_VOICE;
+ break;
+
+ case 2:
+ resp.record[countValidRecords].class = SS_CLASS_ALL_DATA_TELE;
+ break;
+
+ case 4:
+ resp.record[countValidRecords].class = SS_CLASS_FAX;
+ break;
+
+ case 7:
+ resp.record[countValidRecords].class = SS_CLASS_ALL_TELE;
+ break;
+
+ case 8:
+ resp.record[countValidRecords].class = SS_CLASS_SMS;
+ break;
+
+ case 16:
+ resp.record[countValidRecords].class = SS_CLASS_ALL_CS_SYNC;
+ break;
+
+ case 32:
+ resp.record[countValidRecords].class = SS_CLASS_ALL_CS_ASYNC;
+ break;
+
+ default:
+ dbg("unspoorted class : [%d]\n", classx);
+ goto error;
+ break;
+ }
+ dbg("class info %d", resp.record[countValidRecords].class);
+ }
+
+ countValidRecords++;
tcore_at_tok_free(tokens);
- return TRUE;
+ continue;
+error:
+ dbg("invalid field found. coutinue");
+ tcore_at_tok_free(tokens);
+ continue;
}
- dcs_str = g_slist_nth_data(tokens, 2);
+ dbg("valid count :%d", countValidRecords);
+ resp.record_num = countValidRecords;
+ resp.err = SS_ERROR_NONE;
+ } else {
+ dbg("no active status - return to user");
}
- if (dcs_str) {
- dcs = tcore_util_get_cbs_coding_scheme(atoi((gchar *)dcs_str));
+ if (response->success > 0) {
+ dbg("RESPONSE OK");
+ resp.err = SS_ERROR_NONE;
} else {
- warn("No dcs string. Using default dcs value");
+ dbg("RESPONSE NOT OK");
+ resp.record = 0;
+ resp.record_num = 0;
+ line = (const char *) response->final_response;
+ tokens = tcore_at_tok_new(line);
+
+ if (g_slist_length(tokens) < 1) {
+ dbg("err cause not specified or string corrupted");
+ resp.err = SS_ERROR_SYSTEMFAILURE;
+ } else {
+ ss_err = atoi(g_slist_nth_data(tokens, 0));
+ err("Error: [%d]", ss_err);
+ // TODO: CMEE error mapping is required.
+ resp.err = SS_ERROR_SYSTEMFAILURE;
+ }
+ tcore_at_tok_free(tokens);
+ }
+
+ dbg("on_response_ss_waiting_get - rsp.err : %d, ur : %x", resp.err, ur);
+ if (ur)
+ tcore_user_request_send_response(ur, info->resp, sizeof(struct tresp_ss_waiting), &resp);
+ else
+ dbg("[ error ] ur is 0");
+
+ if (resp.record) {
+ g_free(resp.record);
+ resp.record = NULL;
}
+ g_free(user_data);
+}
- ussd_noti.str = tcore_malloc0(len + 1);
- if ((tcore_util_convert_str_to_utf8(ussd_noti.str, &len, dcs,
- (const guchar *)resp_str, len + 1)) == FALSE) {
- /* In case of unhandled dcs type(Reserved),
- * copy ussd string to ussd_noti.str
- */
- memcpy(ussd_noti.str, resp_str, len);
+static void on_response_ss_cli_get(TcorePending *p, int data_len, const void *data, void *user_data)
+{
+ UserRequest *ur = 0;
+ struct tresp_ss_cli resp;
+ enum telephony_ss_cli_type *p_type = NULL;
+ char *line = NULL, *status;
+ int error = FALSE;
+ int cli_adj, stat;
+ GSList *tokens = NULL;
+ const TcoreATResponse *response;
+
+ dbg("function enter");
+ response = data;
+ ur = tcore_pending_ref_user_request(p);
+ p_type = (enum telephony_ss_cli_type *) (user_data);
+
+ if (response->success > 0) {
+ line = (char *) (((GSList *) response->lines)->data);
+ tokens = tcore_at_tok_new(line);
+
+ if (*p_type == SS_CLI_TYPE_CLIR) {
+ // +CLIR: <n> <m>
+ dbg("CLI type is CLIR");
+ // parse <n>
+ status = g_slist_nth_data(tokens, 0);
+
+ if (!status) {
+ dbg("Call line identification adjustment missing <n>");
+ } else {
+ cli_adj = atoi(status);
+ dbg("CLIR response value of <n> - %d", cli_adj);
+
+ if (cli_adj == 0) {
+ // parse <m>
+ status = g_slist_nth_data(tokens, 1);
+ if (!status) {
+ dbg("status is missing<m>");
+ }
+ stat = atoi(status);
+ dbg("CLIR response value of <m> - %d", stat);
+
+ if (stat == 1 || stat == 3) {
+ resp.status = TRUE;
+ } else {
+ resp.status = FALSE;
+ }
+ } else if (cli_adj == 1) {
+ resp.status = TRUE;
+ } else {
+ resp.status = FALSE;
+ }
+ dbg("resp.status - %d", resp.status);
+ }
+ tcore_at_tok_free(tokens);
+ } else {
+ // parse <n>
+ status = g_slist_nth_data(tokens, 0);
+ if (!status) {
+ dbg("Stat is missing");
+ } else {
+ stat = atoi(status);
+ if (stat == 1)
+ resp.status = TRUE;
+ else
+ resp.status = FALSE;
+
+ dbg("resp.status - %d", resp.status);
+ }
+ tcore_at_tok_free(tokens);
+ }
}
- dbg("ussd_noti.str[%s]", ussd_noti.str);
+ if (response->success > 0) {
+ dbg("RESPONSE OK");
+ resp.err = SS_ERROR_NONE;
+ } else {
+ dbg("RESPONSE NOT OK");
+
+ line = (char *) response->final_response;
+ tokens = tcore_at_tok_new(line);
+
+ if (g_slist_length(tokens) < 1) {
+ dbg("err cause not specified or string corrupted");
+ resp.err = SS_ERROR_SYSTEMFAILURE;
+ } else {
+ error = atoi(g_slist_nth_data(tokens, 0));
+ err("Error: [%d]", error);
+ // TODO: CMEE error mapping is required.
+ resp.err = SS_ERROR_SYSTEMFAILURE;
+ }
+ tcore_at_tok_free(tokens);
+ }
- ussd_noti.status = ussd_status;
+ resp.type = *p_type;
+ dbg("check - resp.type = %d ", resp.type);
+ if (ur)
+ tcore_user_request_send_response(ur, TRESP_SS_CLI_GET_STATUS, sizeof(struct tresp_ss_cli), &resp);
+ else
+ dbg("[ error ] ur : (0)");
- tcore_object_send_notification(co,
- TCORE_NOTIFICATION_SS_USSD,
- sizeof(TelSsUssdNoti), (void *)&ussd_noti);
+ g_free(user_data);
+}
- tcore_at_tok_free(tokens);
- tcore_free(resp_str);
- tcore_free(ussd_noti.str);
+static struct tcore_ss_operations ss_ops = {
+ .barring_activate = imc_ss_barring_activate,
+ .barring_deactivate = imc_ss_barring_deactivate,
+ .barring_change_password = imc_ss_barring_change_password,
+ .barring_get_status = imc_ss_barring_get_status,
+ .forwarding_activate = imc_ss_forwarding_activate,
+ .forwarding_deactivate = imc_ss_forwarding_deactivate,
+ .forwarding_register = imc_ss_forwarding_register,
+ .forwarding_deregister = imc_ss_forwarding_deregister,
+ .forwarding_get_status = imc_ss_forwarding_get_status,
+ .waiting_activate = imc_ss_waiting_activate,
+ .waiting_deactivate = imc_ss_waiting_deactivate,
+ .waiting_get_status = imc_ss_waiting_get_status,
+ .cli_activate = imc_ss_cli_activate,
+ .cli_deactivate = imc_ss_cli_deactivate,
+ .cli_get_status = imc_ss_cli_get_status,
+ .send_ussd = imc_ss_send_ussd,
+ .set_aoc = imc_ss_set_aoc,
+ .get_aoc = imc_ss_get_aoc,
+};
- return TRUE;
-}
-static TelSsResult __imc_ss_convert_cme_error_tel_ss_result(const TcoreAtResponse *at_resp)
+static TReturn _ss_barring_set(CoreObject *o, UserRequest *ur, enum telephony_ss_opcode op)
{
- TelSsResult result = TEL_SS_RESULT_FAILURE;
- const gchar *line;
- GSList *tokens = NULL;
- dbg("Entry");
-
- if (!at_resp || !at_resp->lines) {
- err("Invalid response data");
- return result;
- }
+ struct treq_ss_barring *barring = 0;
+ struct ss_confirm_info *user_data = 0;
+ char *cmd_str = NULL;
+ TcorePending *pending = NULL;
+ TcoreATRequest *req;
+ char passwd[MAX_SS_BARRING_PASSWORD_LEN + 1];
+ int opco;
+ int classx;
+ char *facility = NULL;
+ gboolean ret = FALSE;
+
+ dbg("function enter");
+ barring = (struct treq_ss_barring *) tcore_user_request_ref_data(ur, 0);
+
+ switch (op) {
+ case SS_OPCO_ACTIVATE:
+ opco = 1;
+ break;
- line = (const gchar *)at_resp->lines->data;
- tokens = tcore_at_tok_new(line);
- if (g_slist_length(tokens) > 0) {
- gchar *resp_str;
- gint cme_err;
+ case SS_OPCO_DEACTIVATE:
+ opco = 0;
+ break;
- resp_str = g_slist_nth_data(tokens, 0);
- if (!resp_str) {
- err("invalid cme error data");
- tcore_at_tok_free(tokens);
- return result;
- }
- cme_err = atoi(resp_str);
- dbg("CME error[%d]", cme_err);
+ default:
+ dbg("unsupported opco : %d", op);
+ return TCORE_RETURN_FAILURE;
+ }
+ dbg("opco - %d", opco);
- switch (cme_err) {
- case 3:
- result = TEL_SS_RESULT_OPERATION_NOT_PERMITTED;
+ switch (barring->mode) {
+ case SS_BARR_MODE_BAOC:
+ facility = "AO";
break;
- case 4:
- result = TEL_SS_RESULT_OPERATION_NOT_SUPPORTED;
+ case SS_BARR_MODE_BOIC:
+ facility = "OI";
break;
- case 16:
- result = TEL_SS_RESULT_INVALID_PASSWORD;
+ case SS_BARR_MODE_BOIC_NOT_HC:
+ facility = "OX";
break;
- case 20:
- result = TEL_SS_RESULT_MEMORY_FAILURE;
+ case SS_BARR_MODE_BAIC:
+ facility = "AI";
break;
- case 50:
- result = TEL_SS_RESULT_INVALID_PARAMETER;
+ case SS_BARR_MODE_BIC_ROAM:
+ facility = "IR";
break;
- case 132:
- case 133:
- case 134:
- result = TEL_SS_RESULT_SERVICE_NOT_AVAILABLE;
+ case SS_BARR_MODE_AB:
+ facility = "AB";
break;
- default:
- result = TEL_SS_RESULT_FAILURE;
- }
- }
- tcore_at_tok_free(tokens);
+ case SS_BARR_MODE_AOB:
+ facility = "AG";
+ break;
- return result;
-}
+ case SS_BARR_MODE_AIB:
+ facility = "AC";
+ break;
-static gboolean __imc_ss_convert_modem_class_to_class(gint classx, TelSsClass *class)
-{
- switch (classx)
- {
- case 7:
- *class = TEL_SS_CLASS_ALL_TELE;
- break;
- case 1:
- *class = TEL_SS_CLASS_VOICE;
- break;
- case 2:
- *class = TEL_SS_CLASS_ALL_DATA_TELE;
- break;
- case 4:
- *class = TEL_SS_CLASS_FAX;
- break;
- case 8:
- *class = TEL_SS_CLASS_SMS;
- break;
- case 16:
- *class = TEL_SS_CLASS_ALL_CS_SYNC;
- break;
- case 32:
- *class = TEL_SS_CLASS_ALL_CS_ASYNC;
- break;
- case 64:
- *class = TEL_SS_CLASS_ALL_DEDI_PS;
- break;
- case 128:
- *class = TEL_SS_CLASS_ALL_DEDI_PAD;
- break;
+ case SS_BARR_MODE_BIC_NOT_SIM:
+ // facility = "NS";
default:
- err("Invalid modem class: [%d]", classx);
- return FALSE;
+ dbg("unspported mode %d", barring->mode);
+ return TCORE_RETURN_FAILURE;
}
- return TRUE;
-}
-
-static guint __imc_ss_convert_class_to_imc_class(TelSsClass class)
-{
- switch (class)
- {
- case TEL_SS_CLASS_ALL_TELE:
- return 7;
-
- case TEL_SS_CLASS_VOICE:
- return 1;
-
- case TEL_SS_CLASS_ALL_DATA_TELE:
- return 2;
+ dbg("facility - %s", facility);
- case TEL_SS_CLASS_FAX:
- return 4;
+ switch (barring->class) {
+ case SS_CLASS_ALL_TELE:
+ classx = 7;
+ break;
- case TEL_SS_CLASS_SMS:
- return 8;
+ case SS_CLASS_VOICE:
+ classx = 1;
+ break;
- case TEL_SS_CLASS_ALL_CS_SYNC:
- return 16;
+ case SS_CLASS_ALL_DATA_TELE:
+ classx = 2;
+ break;
- case TEL_SS_CLASS_ALL_CS_ASYNC:
- return 32;
+ case SS_CLASS_FAX:
+ classx = 4;
+ break;
- case TEL_SS_CLASS_ALL_DEDI_PS:
- return 64;
+ case SS_CLASS_SMS:
+ classx = 8;
+ break;
- case TEL_SS_CLASS_ALL_DEDI_PAD:
- return 128;
+ case SS_CLASS_ALL_CS_SYNC:
+ classx = 16;
+ break;
default:
- dbg("Unsupported class: [%d], returning default value 7", class);
- return 7;
+ classx = 7;
+ dbg("unsupported class %d. set to default : 7", barring->class);
+ break;
}
-}
-static gboolean __imc_ss_convert_barring_type_to_facility(TelSsBarringType type,
- gchar **facility)
-{
- switch (type)
- {
- case TEL_SS_CB_TYPE_BAOC:
- *facility = "AO";
- break;
- case TEL_SS_CB_TYPE_BOIC:
- *facility = "OI";
- break;
- case TEL_SS_CB_TYPE_BOIC_NOT_HC:
- *facility = "OX";
- break;
- case TEL_SS_CB_TYPE_BAIC:
- *facility = "AI";
- break;
- case TEL_SS_CB_TYPE_BIC_ROAM:
- *facility = "IR";
- break;
- case TEL_SS_CB_TYPE_AB:
- *facility = "AB";
- break;
- case TEL_SS_CB_TYPE_AOB:
- *facility = "AG";
- break;
- case TEL_SS_CB_TYPE_AIB:
- *facility = "AC";
- break;
- case TEL_SS_CB_TYPE_NS:
- *facility = "NS";
- break;
- default:
- err("Unspported type: [%d]", type);
- return FALSE;
- }
- return TRUE;
-}
+ dbg("classx - %d", classx);
-static gboolean __imc_ss_convert_forwarding_mode_to_modem_mode(TelSsForwardMode mode,
- guint *modex)
-{
- switch (mode)
- {
- case TEL_SS_CF_MODE_DISABLE:
- *modex = 0;
- break;
- case TEL_SS_CF_MODE_ENABLE:
- *modex = 1;
- break;
- case TEL_SS_CF_MODE_REGISTER:
- *modex = 3;
- break;
- case TEL_SS_CF_MODE_DEREGISTER:
- *modex = 4;
- break;
- default:
- err("Unspported mode: [%d]", mode);
- return FALSE;
+ user_data = g_new0(struct ss_confirm_info, 1);
+ if (!user_data) {
+ dbg("[ error ] failed to allocate memory");
+ return TCORE_RETURN_ENOMEM;
}
- return TRUE;
-}
-static gboolean __imc_ss_convert_forwarding_condition_to_modem_reason(TelSsForwardCondition condition,
- guint *reason)
-{
- switch (condition) {
- case TEL_SS_CF_COND_CFU:
- *reason = 0;
- break;
- case TEL_SS_CF_COND_CFB:
- *reason = 1;
- break;
- case TEL_SS_CF_COND_CFNRY:
- *reason = 2;
- break;
- case TEL_SS_CF_COND_CFNRC:
- *reason = 3;
- break;
- case TEL_SS_CF_COND_ALL:
- *reason = 4;
- break;
- case TEL_SS_CF_COND_ALL_CFC:
- *reason = 5;
- break;
- default:
- dbg("Unsupported condition: [%d]", condition);
- return FALSE;
- }
- return TRUE;
-}
+ // null-ended pwd handling added - unexpected 0x11 value observed in req string
+ memcpy(passwd, barring->password, MAX_SS_BARRING_PASSWORD_LEN);
+ passwd[MAX_SS_BARRING_PASSWORD_LEN] = '\0';
+ dbg("passwd - %s", passwd);
-static gint __imc_ss_convert_cli_status_modem_status(gint cli_status)
-{
- if (cli_status == TEL_SS_CLI_DISABLE)
- return 0;
- else if (cli_status == TEL_SS_CLI_ENABLE)
- return 1;
- else {
- err("Invalid CLI status: [%d]", cli_status);
- return -1;
- }
-}
+ pending = tcore_pending_new(o, 0);
-static gint __imc_ss_convert_clir_status_modem_status(gint clir_status)
-{
- if (clir_status == TEL_CLIR_STATUS_DEFAULT)
- return 0;
- else if (clir_status == TEL_CLIR_STATUS_INVOCATION)
- return 1;
- else if (clir_status == TEL_CLIR_STATUS_SUPPRESSION)
- return 2;
- else {
- err("Invalid CLIR status: [%d]", clir_status);
- return -1;
- }
-}
+ cmd_str = g_strdup_printf("AT+CLCK=\"%s\",%d,\"%s\",%d", facility, opco, passwd, classx);
+ dbg("request command : %s", cmd_str);
-static gboolean __imc_ss_convert_cli_info_modem_info(const TelSsCliInfo **cli_info,gint *status,
- gchar **cmd_prefix)
-{
- switch ((*cli_info)->type)
- {
- case TEL_SS_CLI_CLIR:
- if ((*status = __imc_ss_convert_clir_status_modem_status((*cli_info)->status.clir))
- != -1) {
- *cmd_prefix = "+CLIR";
- } else {
- err("invalid clir status");
- }
- break;
+ req = tcore_at_request_new(cmd_str, NULL, TCORE_AT_NO_RESULT);
+ dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
- case TEL_SS_CLI_CLIP:
- if ((*status =__imc_ss_convert_cli_status_modem_status((*cli_info)->status.clip)
- != -1)) {
- *cmd_prefix = "+CLIP";
- } else {
- err("invalid clip status");
- }
- break;
- case TEL_SS_CLI_COLP:
- if ((*status =__imc_ss_convert_cli_status_modem_status((*cli_info)->status.colp)
- != -1)) {
- *cmd_prefix = "+COLP";
- } else {
- err("invalid colp status");
- }
- break;
- case TEL_SS_CLI_COLR:
- if ((*status =__imc_ss_convert_cli_status_modem_status((*cli_info)->status.colr)
- != -1)) {
- *cmd_prefix = "+COLR";
- } else {
- err("invalid colr status");
+ tcore_pending_set_request_data(pending, 0, req);
+
+ if (op == SS_OPCO_ACTIVATE) {
+ user_data->resp = TRESP_SS_BARRING_ACTIVATE;
+ } else if (op == SS_OPCO_DEACTIVATE) {
+ user_data->resp = TRESP_SS_BARRING_DEACTIVATE;
+ } else {
+ dbg("[ error ] wrong ss opco (0x%x)", op);
+ if (user_data != NULL) {
+ g_free(user_data);
}
- break;
- case TEL_SS_CLI_CNAP:
- if ((*status =__imc_ss_convert_cli_status_modem_status((*cli_info)->status.cnap)
- != -1)) {
- *cmd_prefix = "+CNAP";
- } else {
- err("invalid cnap status");
+ g_free(cmd_str);
+ tcore_pending_free(pending);
+ tcore_at_request_free(req);
+ return TCORE_RETURN_FAILURE;
+ }
+ user_data->flavor_type = (int) (barring->mode);
+ user_data->class = barring->class;
+
+ ret = _ss_request_message(pending, o, ur, on_response_ss_barring_set, user_data);
+ g_free(cmd_str);
+
+ if (!ret) {
+ dbg("AT request sent failed ");
+ if (user_data != NULL) {
+ g_free(user_data);
+ tcore_pending_free(pending);
+ tcore_at_request_free(req);
}
-
- break;
- case TEL_SS_CLI_CDIP:
- default:
- err("Unsupported CLI type: [%d]", (*cli_info)->type);
- return FALSE;
+ return TCORE_RETURN_FAILURE;
}
-
- if (*cmd_prefix == NULL)
- return FALSE;
-
- return TRUE;
+ return TCORE_RETURN_SUCCESS;
}
-static gboolean __imc_ss_convert_modem_cli_net_status_cli_status(TelSsCliType cli_type,
- gint net_status, gint *status)
+static TReturn _ss_barring_get(CoreObject *o,
+ UserRequest *ur,
+ enum telephony_ss_class class,
+ enum telephony_ss_barring_mode mode,
+ enum tcore_response_command resp)
{
- if (cli_type == TEL_SS_CLI_CLIR) {
- switch (net_status) {
- case 0:
- *status = TEL_CLIR_STATUS_NOT_PROVISIONED;
- break;
- case 1:
- *status = TEL_CLIR_STATUS_PROVISIONED;
+ struct ss_confirm_info *user_data = 0;
+ gboolean ret = FALSE;
+ char *cmd_str = NULL;
+ int opco, classx;
+ char *facility = NULL;
+ TcorePending *pending = NULL;
+ TcoreATRequest *req;
+
+ dbg("function enter");
+
+ // query status - opco is fixed to 2
+ opco = 2;
+ // barring mode
+ switch (mode) {
+ case SS_BARR_MODE_BAOC:
+ facility = "AO";
break;
- case 2:
- *status = TEL_CLIR_STATUS_UNKNOWN;
+
+ case SS_BARR_MODE_BOIC:
+ facility = "OI";
break;
- case 3:
- *status = TEL_CLIR_STATUS_TEMP_RESTRICTED;
+
+ case SS_BARR_MODE_BOIC_NOT_HC:
+ facility = "OX";
break;
- case 4:
- *status = TEL_CLIR_STATUS_TEMP_ALLOWED;
+
+ case SS_BARR_MODE_BAIC:
+ facility = "AI";
break;
- default:
- err("Invalid clir net status: [%d]", net_status);
- return FALSE;
- }
- } else { //CLIP, COLP,COLR,CNAP.
- switch (net_status) {
- case 0:
- *status = TEL_SS_CLI_NOT_PROVISIONED;
+
+ case SS_BARR_MODE_BIC_ROAM:
+ facility = "IR";
break;
- case 1:
- *status = TEL_SS_CLI_PROVISIONED;
+
+ case SS_BARR_MODE_AB:
+ case SS_BARR_MODE_AOB:
+ case SS_BARR_MODE_AIB:
+ case SS_BARR_MODE_BIC_NOT_SIM:
+ default:
+ dbg("unsupported mode %d", mode);
+ return TCORE_RETURN_FAILURE;
+ }
+
+ dbg("facility - %s", facility);
+
+ switch (class) {
+ case SS_CLASS_ALL_TELE:
+ classx = 7;
break;
- case 2:
- *status = TEL_SS_CLI_UNKNOWN;
+
+ case SS_CLASS_VOICE:
+ classx = 1;
break;
- default:
- err("Invalid status: [%d]", net_status);
- return FALSE;
- }
- }
- return TRUE;
-}
-static gboolean __imc_ss_convert_modem_cli_dev_status_cli_status(TelSsCliType cli_type,
- gint dev_status, gint *status)
-{
- if (cli_type == TEL_SS_CLI_CLIR) {
- switch (dev_status) {
- case 0:
- *status = TEL_CLIR_STATUS_DEFAULT;
+ case SS_CLASS_ALL_DATA_TELE:
+ classx = 2;
break;
- case 1:
- *status = TEL_CLIR_STATUS_INVOCATION;
+
+ case SS_CLASS_FAX:
+ classx = 4;
break;
- case 2:
- *status = TEL_CLIR_STATUS_SUPPRESSION;
+
+ case SS_CLASS_SMS:
+ classx = 8;
break;
- default:
- err("Invalid dev status: [%d]", dev_status);
- return FALSE;
- }
- } else { //CLIP, COLP,COLR,CNAP.
- switch (dev_status) {
- case 0:
- *status = TEL_SS_CLI_DISABLE;
+
+ case SS_CLASS_ALL_CS_SYNC:
+ classx = 16;
break;
- case 1:
- *status = TEL_SS_CLI_ENABLE;
+
+ default:
+ classx = 7;
+ dbg("unsupported class %d. set to default : 7", class);
break;
- default:
- err("Invalid dev status: [%d]", dev_status);
- return FALSE;
- }
}
- return TRUE;
-}
-/* SS Responses */
-static void on_response_imc_ss_set_barring(TcorePending *p,
- guint data_len, const void *data, void *user_data)
-{
- const TcoreAtResponse *at_resp = data;
- CoreObject *co = tcore_pending_ref_core_object(p);
- ImcRespCbData *resp_cb_data = user_data;
+ user_data = g_new0(struct ss_confirm_info, 1);
+ if (!user_data) {
+ dbg("[ error ] failed to allocate memory");
+ return TCORE_RETURN_ENOMEM;
+ }
- /* TODO: CMEE error mapping is required */
- TelSsResult result = TEL_SS_RESULT_FAILURE;
- dbg("Enter");
+ dbg("class - %d", classx);
+ if (classx == 7)
+ cmd_str = g_strdup_printf("AT+CLCK=\"%s\",%d", facility, opco);
+ else
+ cmd_str = g_strdup_printf("AT+CLCK=\"%s\",%d,,%d", facility, opco, classx);
- tcore_check_return_assert(co != NULL);
- tcore_check_return_assert(resp_cb_data != NULL);
+ dbg("request command : %s", cmd_str);
- if (at_resp && at_resp->success)
- result = TEL_SS_RESULT_SUCCESS;
- else {
- err("RESPONSE NOK");
- result = __imc_ss_convert_cme_error_tel_ss_result(at_resp);
- }
+ pending = tcore_pending_new(o, 0);
+ req = tcore_at_request_new(cmd_str, "+CLCK", TCORE_AT_MULTILINE);
+ dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
- dbg("Setting Barring status: [%s]",
- (result == TEL_SS_RESULT_SUCCESS ? "SUCCESS" : "FAIL"));
+ tcore_pending_set_request_data(pending, 0, req);
- /* Invoke callback */
- if (resp_cb_data->cb)
- resp_cb_data->cb(co, (gint)result, NULL, resp_cb_data->cb_data);
+ user_data->resp = resp;
+ user_data->flavor_type = (int) (mode);
+ user_data->class = class;
- imc_destroy_resp_cb_data(resp_cb_data);
-}
+ ret = _ss_request_message(pending, o, ur, on_response_ss_barring_get, user_data);
+ g_free(cmd_str);
-static void on_response_imc_ss_get_barring_status(TcorePending *p,
- guint data_len, const void *data, void *user_data)
-{
- const TcoreAtResponse *at_resp = data;
- CoreObject *co = tcore_pending_ref_core_object(p);
- ImcRespCbData *resp_cb_data = user_data;
- TelSsBarringResp barring_resp = {0,};
- TelSsBarringGetInfo *req_info;
- gint valid_records = 0;
- GSList *resp_data = NULL;
- /* TODO: CMEE error mapping is required */
- TelSsResult result = TEL_SS_RESULT_FAILURE;
- dbg("Enter");
-
- tcore_check_return_assert(co != NULL);
- tcore_check_return_assert(resp_cb_data != NULL);
-
- req_info = (TelSsBarringGetInfo *)IMC_GET_DATA_FROM_RESP_CB_DATA(resp_cb_data);
-
- if (at_resp) {
- if (at_resp->lines && at_resp->success) {
- resp_data = (GSList *) at_resp->lines;
- barring_resp.record_num= g_slist_length(resp_data);
- dbg("Total records: [%d]", barring_resp.record_num);
- }
- else {
- err("RESPONSE - [NOK]");
- result = __imc_ss_convert_cme_error_tel_ss_result(at_resp);
+ if (!ret) {
+ dbg("AT request sent failed ");
+ if (user_data != NULL) {
+ g_free(user_data);
+ tcore_pending_free(pending);
+ tcore_at_request_free(req);
}
- } else {
- err("No response data");
+ return TCORE_RETURN_FAILURE;
}
- if (barring_resp.record_num > 0) {
- barring_resp.records = tcore_malloc0((barring_resp.record_num) *
- sizeof(TelSsBarringInfoRecord));
-
- for (valid_records = 0; resp_data != NULL; resp_data = resp_data->next) {
- const gchar *line;
- GSList *tokens = NULL;
+ return TCORE_RETURN_SUCCESS;
+}
- line = (const char *) resp_data->data;
- tokens = tcore_at_tok_new(line);
- if (g_slist_length(tokens) > 0) {
- gchar *classx_str;
- gchar *status = NULL;
+static TReturn imc_ss_barring_activate(CoreObject *o, UserRequest *ur)
+{
+ if(FALSE == tcore_hal_get_power_state(tcore_object_get_hal(o))){
+ dbg("cp not ready/n");
+ return TCORE_RETURN_ENOSYS;
+ }
+ return _ss_barring_set(o, ur, SS_OPCO_ACTIVATE);
+}
- status = g_slist_nth_data(tokens, 0);
- if (!status) {
- dbg("Status is missing");
- tcore_at_tok_free(tokens);
- continue;
- }
+static TReturn imc_ss_barring_deactivate(CoreObject *o, UserRequest *ur)
+{
+ if(FALSE == tcore_hal_get_power_state(tcore_object_get_hal(o))){
+ dbg("cp not ready/n");
+ return TCORE_RETURN_ENOSYS;
+ }
+ return _ss_barring_set(o, ur, SS_OPCO_DEACTIVATE);
+}
- if (atoi(status) == 1) {
- barring_resp.records[valid_records].enable = TRUE;
- } else {
- barring_resp.records[valid_records].enable = FALSE;
- }
+static TReturn imc_ss_barring_change_password(CoreObject *o, UserRequest *ur)
+{
+ TcorePending *pending = NULL;
+ TcoreATRequest *req;
+ struct treq_ss_barring_change_password *barring = 0;
+ struct ss_confirm_info *user_data = 0;
+ char *cmd_str = NULL;
+ gboolean ret = FALSE;
+ char old_password[MAX_SS_BARRING_PASSWORD_LEN + 1];
+ char new_password[MAX_SS_BARRING_PASSWORD_LEN + 1];
+
+ dbg("function enter");
+
+ if(FALSE == tcore_hal_get_power_state(tcore_object_get_hal(o))){
+ dbg("cp not ready/n");
+ return TCORE_RETURN_ENOSYS;
+ }
- classx_str = g_slist_nth_data(tokens, 1);
- if (!classx_str) {
- dbg("Class error. Setting to the requested class: [%d]",
- req_info->class);
- barring_resp.records[valid_records].class =
- req_info->class;
- } else {
- if (__imc_ss_convert_modem_class_to_class(atoi(classx_str),
- &(barring_resp.records[valid_records].class))
- == FALSE) {
- tcore_at_tok_free(tokens);
- continue;
- }
- }
+ barring = (struct treq_ss_barring_change_password *) tcore_user_request_ref_data(ur, 0);
- barring_resp.records[valid_records].type= req_info->type;
- result = TEL_SS_RESULT_SUCCESS;
- valid_records++;
- } else {
- err("Invalid response message");
- }
- tcore_at_tok_free(tokens);
- }
+ if (barring->password_old == NULL || barring->password_new == NULL) {
+ dbg("[error]password is null");
+ return TCORE_RETURN_FAILURE;
}
+ memcpy(old_password, barring->password_old, MAX_SS_BARRING_PASSWORD_LEN);
+ old_password[MAX_SS_BARRING_PASSWORD_LEN] = '\0';
+ memcpy(new_password, barring->password_new, MAX_SS_BARRING_PASSWORD_LEN);
+ new_password[MAX_SS_BARRING_PASSWORD_LEN] = '\0';
+
+ user_data = g_new0(struct ss_confirm_info, 1);
+ if (!user_data) {
+ dbg("[ error ] failed to allocate memory");
+ return TCORE_RETURN_ENOMEM;
+ }
+ user_data->resp = TRESP_SS_BARRING_CHANGE_PASSWORD;
- dbg("Getting Barring status: [%s]",
- (result == TEL_SS_RESULT_SUCCESS ? "SUCCESS" : "FAIL"));
- barring_resp.record_num = valid_records;
+ dbg("old passwd - %s new passwd- %s", old_password, new_password);
+ cmd_str = g_strdup_printf("AT+CPWD=\"%s\",\"%s\",\"%s\"", "AB", old_password, new_password);
+ dbg("request command : %s", cmd_str);
- /* Invoke callback */
- if (resp_cb_data->cb)
- resp_cb_data->cb(co, (gint)result, &barring_resp, resp_cb_data->cb_data);
+ pending = tcore_pending_new(o, 0);
+ req = tcore_at_request_new(cmd_str, NULL, TCORE_AT_NO_RESULT);
+ dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
- imc_destroy_resp_cb_data(resp_cb_data);
+ tcore_pending_set_request_data(pending, 0, req);
- if (barring_resp.records) {
- tcore_free(barring_resp.records);
+ ret = _ss_request_message(pending, o, ur, on_response_ss_barring_change_pwd, user_data);
+ g_free(cmd_str);
+ if (!ret) {
+ dbg("AT request sent failed ");
+ if (user_data != NULL) {
+ g_free(user_data);
+ }
+ tcore_pending_free(pending);
+ tcore_at_request_free(req);
+ return TCORE_RETURN_FAILURE;
}
+ return TCORE_RETURN_SUCCESS;
}
-static void on_response_imc_ss_change_barring_password(TcorePending *p,
- guint data_len, const void *data, void *user_data)
+static TReturn imc_ss_barring_get_status(CoreObject *o, UserRequest *ur)
{
- const TcoreAtResponse *at_resp = data;
- CoreObject *co = tcore_pending_ref_core_object(p);
- ImcRespCbData *resp_cb_data = user_data;
- TelSsResult result = TEL_SS_RESULT_FAILURE;
- dbg("Enter");
+ struct treq_ss_barring *barring = 0;
- tcore_check_return_assert(co != NULL);
- tcore_check_return_assert(resp_cb_data != NULL);
-
- if (at_resp && at_resp->success)
- result = TEL_SS_RESULT_SUCCESS;
- else {
- err("RESPONSE NOK");
- result = __imc_ss_convert_cme_error_tel_ss_result(at_resp);
+ if(FALSE == tcore_hal_get_power_state(tcore_object_get_hal(o))){
+ dbg("cp not ready/n");
+ return TCORE_RETURN_ENOSYS;
}
+ barring = (struct treq_ss_barring *) tcore_user_request_ref_data(ur, 0);
- dbg("Change Barring Password: [%s]",
- (result == TEL_SS_RESULT_SUCCESS ? "SUCCESS" : "FAIL"));
-
- /* Invoke callback */
- if (resp_cb_data->cb)
- resp_cb_data->cb(co, (gint)result, NULL, resp_cb_data->cb_data);
-
- imc_destroy_resp_cb_data(resp_cb_data);
+ return _ss_barring_get(o, ur, barring->class, barring->mode, TRESP_SS_BARRING_GET_STATUS);
}
-static void on_response_imc_ss_set_forwarding(TcorePending *p,
- guint data_len, const void *data, void *user_data)
+static TReturn _ss_forwarding_set(CoreObject *o, UserRequest *ur, enum telephony_ss_opcode op)
{
- const TcoreAtResponse *at_resp = data;
- CoreObject *co = tcore_pending_ref_core_object(p);
- ImcRespCbData *resp_cb_data = user_data;
+ struct treq_ss_forwarding *forwarding = 0;
+ struct ss_confirm_info *user_data = 0;
+ gboolean ret = FALSE;
+ int len = 0;
+ char *cmd_str = NULL;
+ char *tmp_str = NULL;
+ int reason = 0, mode = 0, num_type = 0, classx = 0, time = 0;
+ TcorePending *pending = NULL;
+ TcoreATRequest *req;
+
+ dbg("_ss_forwarding_set with opco %d ", op);
+
+ forwarding = (struct treq_ss_forwarding *) tcore_user_request_ref_data(ur, 0);
+ switch (forwarding->mode) {
+ case SS_CF_MODE_CFU:
+ reason = 0;
+ break;
+
+ case SS_CF_MODE_CFB:
+ reason = 1;
+ break;
+
+ case SS_CF_MODE_CFNRy:
+ reason = 2;
+ break;
+
+ case SS_CF_MODE_CFNRc:
+ reason = 3;
+ break;
- /* TODO: CMEE error mapping is required */
- TelSsResult result = TEL_SS_RESULT_FAILURE;
- dbg("Enter");
+ case SS_CF_MODE_CF_ALL:
+ reason = 4;
+ break;
- tcore_check_return_assert(co != NULL);
- tcore_check_return_assert(resp_cb_data != NULL);
+ case SS_CF_MODE_CFC:
+ reason = 5;
+ break;
- if (at_resp && at_resp->success)
- result = TEL_SS_RESULT_SUCCESS;
- else {
- err("RESPONSE NOK");
- result = __imc_ss_convert_cme_error_tel_ss_result(at_resp);
+ default:
+ dbg("unsupported reason : %d");
+ return TCORE_RETURN_FAILURE;
+ break;
}
- dbg("Set Forwarding Status: [%s]",
- (result == TEL_SS_RESULT_SUCCESS ? "SUCCESS" : "FAIL"));
+ dbg("reason = %d", reason);
+ switch (op) {
+ case SS_OPCO_DEACTIVATE:
+ mode = 0;
+ break;
- /* Invoke callback */
- if (resp_cb_data->cb)
- resp_cb_data->cb(co, (gint)result, NULL, resp_cb_data->cb_data);
+ case SS_OPCO_ACTIVATE:
+ mode = 1;
+ break;
- imc_destroy_resp_cb_data(resp_cb_data);
-}
+ case SS_OPCO_REG:
+ mode = 3;
+ break;
-static void on_response_imc_ss_get_forwarding_status(TcorePending *p,
- guint data_len, const void *data, void *user_data)
-{
- const TcoreAtResponse *at_resp = data;
- CoreObject *co = tcore_pending_ref_core_object(p);
- ImcRespCbData *resp_cb_data = user_data;
- TelSsForwardingResp forwarding_resp = {0,};
- TelSsForwardGetInfo *req_info;
- gint valid_records = 0;
- GSList *resp_data = NULL;
- TelSsResult result = TEL_SS_RESULT_FAILURE;
- dbg("Enter");
-
- tcore_check_return_assert(co != NULL);
- tcore_check_return_assert(resp_cb_data != NULL);
-
- req_info = (TelSsForwardGetInfo *)IMC_GET_DATA_FROM_RESP_CB_DATA(resp_cb_data);
-
- if (at_resp) {
- if (at_resp->lines && at_resp->success) {
- resp_data = (GSList *) at_resp->lines;
- forwarding_resp.record_num= g_slist_length(resp_data);
- dbg("Total records: [%d]", forwarding_resp.record_num);
- } else {
- err("RESPONSE - [NOK]");
- result = __imc_ss_convert_cme_error_tel_ss_result(at_resp);
- }
- } else {
- err("No response data");
- }
+ case SS_OPCO_DEREG:
+ mode = 4;
+ break;
- if (forwarding_resp.record_num > 0) {
- forwarding_resp.records = tcore_malloc0((forwarding_resp.record_num) *
- sizeof(TelSsForwardingInfoRecord));
- for (valid_records = 0; resp_data != NULL; resp_data = resp_data->next) {
- const gchar *line;
- GSList *tokens = NULL;
+ default:
+ dbg("unsupported opco : %d", op);
+ return TCORE_RETURN_FAILURE;
+ }
- line = (const char *) resp_data->data;
- tokens = tcore_at_tok_new(line);
+ dbg("mode = %d", mode);
- if (g_slist_length(tokens) > 0) {
- gchar *classx_str;
- gchar *status = NULL;
- gchar *number = NULL;
- gchar *time_str = NULL;
+ // class
+ switch (forwarding->class) {
+ case SS_CLASS_ALL_TELE:
+ classx = 7;
+ break;
- status = g_slist_nth_data(tokens, 0);
- if (!status) {
- dbg("Status is missing");
- tcore_at_tok_free(tokens);
- continue;
- }
+ case SS_CLASS_VOICE:
+ classx = 1;
+ break;
- if (atoi(status) == 1) {
- forwarding_resp.records[valid_records].enable = TRUE;
- } else {
- forwarding_resp.records[valid_records].enable = FALSE;
- }
+ case SS_CLASS_ALL_DATA_TELE:
+ classx = 2;
+ break;
- classx_str = g_slist_nth_data(tokens, 1);
- if (!classx_str) {
- dbg("Class error. Setting to the requested class: [%d]",
- req_info->class);
- forwarding_resp.records[valid_records].class =
- req_info->class;
- } else {
- if (__imc_ss_convert_modem_class_to_class(atoi(classx_str),
- &(forwarding_resp.records[valid_records].class))
- == FALSE) {
- tcore_at_tok_free(tokens);
- continue;
- }
- }
+ case SS_CLASS_FAX:
+ classx = 4;
+ break;
- number = g_slist_nth_data(tokens, 2);
- if (number) {
- number = tcore_at_tok_extract(number);
- memcpy((forwarding_resp.records[valid_records].number),
- number, strlen(number));
- g_free(number);
- }
+ case SS_CLASS_SMS:
+ classx = 8;
+ break;
- time_str = g_slist_nth_data(tokens, 6);
- if (time_str)
- forwarding_resp.records[valid_records].wait_time =
- atoi(time_str);
+ case SS_CLASS_ALL_CS_SYNC:
+ classx = 16;
+ break;
- forwarding_resp.records[valid_records].condition =
- req_info->condition;
+ default:
+ classx = 7;
+ dbg("unsupported class %d. set to default : 7", forwarding->class);
+ break;
+ }
+ dbg("classx = %d", classx);
+
+ // number
+ len = strlen(forwarding->number);
+ if (len > 0) {
+ if (forwarding->number[0] == '+')
+ num_type = ((NUM_TYPE_INTERNATIONAL << 4) | NUM_PLAN_ISDN);
+ else
+ num_type = 0;
+ }
+ dbg("number = %s", forwarding->number);
- result = TEL_SS_RESULT_SUCCESS;
- valid_records++;
- } else {
- err("Invalid response message");
- }
- tcore_at_tok_free(tokens);
- }
+ user_data = g_new0(struct ss_confirm_info, 1);
+ if (!user_data) {
+ dbg("[ error ] failed to allocate memory");
+ return TCORE_RETURN_ENOMEM;
}
- dbg("Getting Forwarding Status: [%s]",
- (result == TEL_SS_RESULT_SUCCESS ? "SUCCESS" : "FAIL"));
- forwarding_resp.record_num = valid_records;
+ switch (op) {
+ case SS_OPCO_REG:
+ user_data->resp = TRESP_SS_FORWARDING_REGISTER;
+ break;
+
+ case SS_OPCO_DEREG:
+ user_data->resp = TRESP_SS_FORWARDING_DEREGISTER;
+ break;
- /* Invoke callback */
- if (resp_cb_data->cb)
- resp_cb_data->cb(co, (gint)result, &forwarding_resp, resp_cb_data->cb_data);
+ case SS_OPCO_ACTIVATE:
+ user_data->resp = TRESP_SS_FORWARDING_ACTIVATE;
+ break;
- imc_destroy_resp_cb_data(resp_cb_data);
+ case SS_OPCO_DEACTIVATE:
+ user_data->resp = TRESP_SS_FORWARDING_DEACTIVATE;
+ break;
- if (forwarding_resp.records) {
- tcore_free(forwarding_resp.records);
+ default:
+ dbg("[ error ] unknown op (0x%x)", op);
+ break;
}
-}
-static void on_response_imc_ss_set_waiting(TcorePending *p,
- guint data_len, const void *data, void *user_data)
-{
- const TcoreAtResponse *at_resp = data;
- CoreObject *co = tcore_pending_ref_core_object(p);
- ImcRespCbData *resp_cb_data = user_data;
- TelSsResult result = TEL_SS_RESULT_FAILURE;
- dbg("Enter");
+ if (forwarding->number[0] == '+')
+ num_type = 145;
+ else
+ num_type = 129;
- tcore_check_return_assert(co != NULL);
- tcore_check_return_assert(resp_cb_data != NULL);
+ if (op == SS_OPCO_REG)
+ tmp_str = g_strdup_printf("AT+CCFC=%d,%d,\"%s\",%d,%d", reason, mode, forwarding->number, num_type, classx);
+ else // other opcode does not need num field
+ tmp_str = g_strdup_printf("AT+CCFC=%d,%d,,,%d", reason, mode, classx);
- if (at_resp && at_resp->success)
- result = TEL_SS_RESULT_SUCCESS;
- else {
- err("RESPONSE NOK");
- result = __imc_ss_convert_cme_error_tel_ss_result(at_resp);
+ if (forwarding->mode == SS_CF_MODE_CFNRy) {
+ // add time info to 'no reply' case
+ time = (int) (forwarding->time);
+ cmd_str = g_strdup_printf("%s,,,%d", tmp_str, time);
+ } else {
+ cmd_str = g_strdup_printf("%s", tmp_str);
}
- dbg("Set Waiting Status: [%s]",
- (result == TEL_SS_RESULT_SUCCESS ? "SUCCESS" : "FAIL"));
+ dbg("request command : %s", cmd_str);
+ pending = tcore_pending_new(o, 0);
+ req = tcore_at_request_new(cmd_str, NULL, TCORE_AT_NO_RESULT);
+ dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
- /* Invoke callback */
- if (resp_cb_data->cb)
- resp_cb_data->cb(co, (gint)result, NULL, resp_cb_data->cb_data);
+ tcore_pending_set_request_data(pending, 0, req);
- imc_destroy_resp_cb_data(resp_cb_data);
-}
+ user_data->flavor_type = forwarding->mode;
+ user_data->class = forwarding->class;
-static void on_response_imc_ss_get_waiting_status(TcorePending *p,
- guint data_len, const void *data, void *user_data)
-{
- const TcoreAtResponse *at_resp = data;
- CoreObject *co = tcore_pending_ref_core_object(p);
- ImcRespCbData *resp_cb_data = user_data;
- TelSsWaitingResp waiting_resp = {0,};
- TelSsClass *class;
- gint valid_records = 0;
- GSList *resp_data = NULL;
- TelSsResult result = TEL_SS_RESULT_FAILURE;
- dbg("Enter");
-
- tcore_check_return_assert(co != NULL);
- tcore_check_return_assert(resp_cb_data != NULL);
-
- class = (TelSsClass *)IMC_GET_DATA_FROM_RESP_CB_DATA(resp_cb_data);
-
- if (at_resp) {
- if (at_resp->lines && at_resp->success) {
- resp_data = (GSList *) at_resp->lines;
- waiting_resp.record_num= g_slist_length(resp_data);
- dbg("Total records: [%d]", waiting_resp.record_num);
- } else {
- err("RESPONSE - [NOK]");
- result = __imc_ss_convert_cme_error_tel_ss_result(at_resp);
+ ret = _ss_request_message(pending, o, ur, on_response_ss_forwarding_set, user_data);
+
+ g_free(tmp_str);
+ g_free(cmd_str);
+
+ if (!ret) {
+ dbg("AT request sent failed ");
+ if (user_data != NULL) {
+ g_free(user_data);
}
- } else {
- err("No response data");
+ return TCORE_RETURN_FAILURE;
}
- if (waiting_resp.record_num > 0) {
- waiting_resp.records = tcore_malloc0((waiting_resp.record_num) *
- sizeof(TelSsWaitingInfo));
+ return TCORE_RETURN_SUCCESS;
+}
- for (valid_records = 0; resp_data != NULL; resp_data = resp_data->next) {
- const gchar *line;
- GSList *tokens = NULL;
+static TReturn _ss_forwarding_get(CoreObject *o,
+ UserRequest *ur,
+ enum telephony_ss_class class,
+ enum telephony_ss_forwarding_mode type,
+ enum tcore_response_command resp)
+{
+ struct ss_confirm_info *user_data = 0;
+ gboolean ret = FALSE;
+ char *cmd_str = NULL;
+ int reason = 0, mode = 0, classx = 0;
+ TcorePending *pending = NULL;
+ TcoreATRequest *req;
+
+ dbg("function enter");
+
+ switch (type) {
+ case SS_CF_MODE_CFU:
+ reason = 0;
+ break;
- line = (const char *) resp_data->data;
- tokens = tcore_at_tok_new(line);
+ case SS_CF_MODE_CFB:
+ reason = 1;
+ break;
- if (g_slist_length(tokens) > 0) {
- gchar *classx_str;
- gchar *status = NULL;
+ case SS_CF_MODE_CFNRy:
+ reason = 2;
+ break;
- status = g_slist_nth_data(tokens, 0);
- if (!status) {
- dbg("Status is missing");
- tcore_at_tok_free(tokens);
- continue;
- }
+ case SS_CF_MODE_CFNRc:
+ reason = 3;
+ break;
- if (atoi(status) == 1) {
- waiting_resp.records[valid_records].enable= TRUE;
- } else {
- waiting_resp.records[valid_records].enable = FALSE;
- }
+ case SS_CF_MODE_CF_ALL:
+ reason = 4;
+ break;
- classx_str = g_slist_nth_data(tokens, 1);
- if (!classx_str) {
- dbg("Class error. Setting to the requested class: [%d]",
- *class);
- waiting_resp.records[valid_records].class = *class;
- } else {
- if (__imc_ss_convert_modem_class_to_class(atoi(classx_str),
- &(waiting_resp.records[valid_records].class))
- == FALSE) {
- tcore_at_tok_free(tokens);
- continue;
- }
- }
+ case SS_CF_MODE_CFC:
+ reason = 5;
+ break;
- result = TEL_SS_RESULT_SUCCESS;
- valid_records++;
- } else {
- err("Invalid response message");
- }
- tcore_at_tok_free(tokens);
- }
+ default:
+ dbg("unsupported reason : %d");
+ break;
}
+ dbg("reason = %d", reason);
- dbg("Getting Waiting Status: [%s]",
- (result == TEL_SS_RESULT_SUCCESS ? "SUCCESS" : "FAIL"));
- waiting_resp.record_num = valid_records;
+ switch (class) {
+ case SS_CLASS_ALL_TELE:
+ classx = 7;
+ break;
- /* Invoke callback */
- if (resp_cb_data->cb)
- resp_cb_data->cb(co, (gint)result, &waiting_resp, resp_cb_data->cb_data);
+ case SS_CLASS_VOICE:
+ classx = 1;
+ break;
- imc_destroy_resp_cb_data(resp_cb_data);
+ case SS_CLASS_ALL_DATA_TELE:
+ classx = 2;
+ break;
- if (waiting_resp.records) {
- tcore_free(waiting_resp.records);
- }
-}
+ case SS_CLASS_FAX:
+ classx = 4;
+ break;
-static void on_response_imc_ss_set_cli(TcorePending *p,
- guint data_len, const void *data, void *user_data)
-{
- const TcoreAtResponse *at_resp = data;
- CoreObject *co = tcore_pending_ref_core_object(p);
- ImcRespCbData *resp_cb_data = user_data;
- /* TODO: CMEE error mapping is required */
- TelSsResult result = TEL_SS_RESULT_FAILURE;
- dbg("Enter");
+ case SS_CLASS_SMS:
+ classx = 8;
+ break;
- tcore_check_return_assert(co != NULL);
- tcore_check_return_assert(resp_cb_data != NULL);
+ case SS_CLASS_ALL_CS_SYNC:
+ classx = 16;
+ break;
- if (at_resp && at_resp->success)
- result = TEL_SS_RESULT_SUCCESS;
- else {
- err("RESPONSE - [NOK]");
- result = __imc_ss_convert_cme_error_tel_ss_result(at_resp);
+ default:
+ classx = 7;
+ dbg("unsupported class %d. set to default : 7", class);
+ break;
}
- dbg("Set Cli Status: [%s]",
- (result == TEL_SS_RESULT_SUCCESS ? "SUCCESS" : "FAIL"));
+ dbg("classx = %d", classx);
- /* Invoke callback */
- if (resp_cb_data->cb)
- resp_cb_data->cb(co, (gint)result, NULL, resp_cb_data->cb_data);
+ // query status - mode set to 2
+ mode = 2;
+ user_data = g_new0(struct ss_confirm_info, 1);
+ if (!user_data) {
+ dbg("[ error ] failed to allocate memory");
+ return TCORE_RETURN_ENOMEM;
+ }
+ user_data->resp = resp;
+ user_data->class = class;
+ user_data->flavor_type = type;
- imc_destroy_resp_cb_data(resp_cb_data);
-}
+ if (classx == 7)
+ cmd_str = g_strdup_printf("AT+CCFC=%d,%d", reason, mode);
+ else
+ cmd_str = g_strdup_printf("AT+CCFC=%d,%d,,,%d", reason, mode, classx);
-static void on_response_imc_ss_get_cli_status(TcorePending *p,
- guint data_len, const void *data, void *user_data)
-{
- const TcoreAtResponse *at_resp = data;
- CoreObject *co = tcore_pending_ref_core_object(p);
- ImcRespCbData *resp_cb_data = user_data;
- TelSsCliResp cli_resp = {0,};
- TelSsCliType *cli_type;
- GSList *tokens = NULL;
- /* TODO: CMEE error mapping is required */
- TelSsResult result = TEL_SS_RESULT_FAILURE;
- dbg("Enter");
+ dbg("request command : %s", cmd_str);
- tcore_check_return_assert(co != NULL);
- tcore_check_return_assert(resp_cb_data != NULL);
+ pending = tcore_pending_new(o, 0);
+ req = tcore_at_request_new(cmd_str, "+CCFC", TCORE_AT_MULTILINE);
+ dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
- cli_type = (TelSsCliType *)IMC_GET_DATA_FROM_RESP_CB_DATA(resp_cb_data);
+ tcore_pending_set_request_data(pending, 0, req);
- if (at_resp && at_resp->success) {
- const gchar *line;
- gchar *status = NULL;
- gint net_status;
- gint dev_status;
+ ret = _ss_request_message(pending, o, ur, on_response_ss_forwarding_get, user_data);
+ g_free(cmd_str);
- if (!at_resp->lines) {
- err("Invalid response message");
- goto END;
- }
- line = (const gchar *)at_resp->lines->data;
- tokens = tcore_at_tok_new(line);
- if (g_slist_length(tokens) < 1) {
- err("Invalid response message");
- goto END;
+ if (!ret) {
+ dbg("AT request sent failed ");
+ if (user_data != NULL) {
+ g_free(user_data);
+ tcore_pending_free(pending);
+ tcore_at_request_free(req);
}
+ return TCORE_RETURN_FAILURE;
+ }
- status = g_slist_nth_data(tokens, 0);
- if (!status) {
- err("dev_status is missing");
- goto END;
- }
- if (!__imc_ss_convert_modem_cli_dev_status_cli_status(*cli_type,
- atoi(status), &dev_status))
- goto END;
-
- status = g_slist_nth_data(tokens, 1);
- if (!status) {
- err("net_status is missing");
- goto END;
- }
- if (!__imc_ss_convert_modem_cli_net_status_cli_status(*cli_type,
- atoi(status), &net_status))
- goto END;
-
- switch (*cli_type){
- case TEL_SS_CLI_CLIR:
- cli_resp.status.clir.net_status = net_status;
- cli_resp.status.clir.dev_status = dev_status;
- break;
- case TEL_SS_CLI_CLIP:
- cli_resp.status.clip.net_status = net_status;
- cli_resp.status.clip.dev_status = dev_status;
- break;
- case TEL_SS_CLI_COLP:
- cli_resp.status.colp.net_status = net_status;
- cli_resp.status.colp.dev_status = dev_status;
- break;
- case TEL_SS_CLI_COLR:
- cli_resp.status.colr.net_status = net_status;
- cli_resp.status.colr.dev_status = dev_status;
- break;
- case TEL_SS_CLI_CNAP:
- cli_resp.status.cnap.net_status = net_status;
- cli_resp.status.cnap.dev_status = dev_status;
- break;
- default:
- err("Unsupported CLI type: [%d]", *cli_type);
- result = TEL_SS_RESULT_INVALID_PARAMETER;
- goto END;
- }
- dbg("RESPONSE OK");
- cli_resp.type = *cli_type;
- result = TEL_SS_RESULT_SUCCESS;
- } else{
- err("RESPONSE NOK");
- result = __imc_ss_convert_cme_error_tel_ss_result(at_resp);
+ return TCORE_RETURN_SUCCESS;
+}
+
+static TReturn imc_ss_forwarding_activate(CoreObject *o, UserRequest *ur)
+{
+ if(FALSE == tcore_hal_get_power_state(tcore_object_get_hal(o))){
+ dbg("cp not ready/n");
+ return TCORE_RETURN_ENOSYS;
}
+ return _ss_forwarding_set(o, ur, SS_OPCO_ACTIVATE);
+}
-END:
- tcore_at_tok_free(tokens);
+static TReturn imc_ss_forwarding_deactivate(CoreObject *o, UserRequest *ur)
+{
+ if(FALSE == tcore_hal_get_power_state(tcore_object_get_hal(o))){
+ dbg("cp not ready/n");
+ return TCORE_RETURN_ENOSYS;
+ }
+ return _ss_forwarding_set(o, ur, SS_OPCO_DEACTIVATE);
+}
- /* Invoke callback */
- if (resp_cb_data->cb)
- resp_cb_data->cb(co, (gint)result, &cli_resp, resp_cb_data->cb_data);
+static TReturn imc_ss_forwarding_register(CoreObject *o, UserRequest *ur)
+{
+ if(FALSE == tcore_hal_get_power_state(tcore_object_get_hal(o))){
+ dbg("cp not ready/n");
+ return TCORE_RETURN_ENOSYS;
+ }
+ return _ss_forwarding_set(o, ur, SS_OPCO_REG);
+}
- imc_destroy_resp_cb_data(resp_cb_data);
+static TReturn imc_ss_forwarding_deregister(CoreObject *o, UserRequest *ur)
+{
+ if(FALSE == tcore_hal_get_power_state(tcore_object_get_hal(o))){
+ dbg("cp not ready/n");
+ return TCORE_RETURN_ENOSYS;
+ }
+ return _ss_forwarding_set(o, ur, SS_OPCO_DEREG);
}
-static void on_response_imc_ss_send_ussd_request(TcorePending *p,
- guint data_len, const void *data, void *user_data)
+static TReturn imc_ss_forwarding_get_status(CoreObject *o, UserRequest *ur)
{
- const TcoreAtResponse *at_resp = data;
- CoreObject *co = tcore_pending_ref_core_object(p);
- ImcRespCbData *resp_cb_data = user_data;
- TelSsUssdResp ussd_resp = {0,};
- UssdSession *ussd_s = NULL;
- /* TODO: CMEE error mapping is required */
- TelSsResult result = TEL_SS_RESULT_FAILURE;
- dbg("Enter");
+ struct treq_ss_forwarding *forwarding = 0;
- tcore_check_return_assert(co != NULL);
- tcore_check_return_assert(resp_cb_data != NULL);
+ if(FALSE == tcore_hal_get_power_state(tcore_object_get_hal(o))){
+ dbg("cp not ready/n");
+ return TCORE_RETURN_ENOSYS;
+ }
- ussd_s = tcore_ss_ussd_get_session(co);
- tcore_check_return(ussd_s != NULL);
+ forwarding = (struct treq_ss_forwarding *) tcore_user_request_ref_data(ur, 0);
- tcore_ss_ussd_get_session_type(ussd_s, &ussd_resp.type);
+ return _ss_forwarding_get(o, ur, forwarding->class, forwarding->mode, TRESP_SS_FORWARDING_GET_STATUS);
+}
- if (at_resp && at_resp->success) {
- result = TEL_SS_RESULT_SUCCESS;
- /* Need to initialise ussd response string */
- ussd_resp.str = (unsigned char *)g_strdup("Operation success");
- } else {
- err("RESPONSE - [NOK]");
- ussd_resp.str = (unsigned char *)g_strdup("Operation failed");
- result = __imc_ss_convert_cme_error_tel_ss_result(at_resp);
+static TReturn _ss_waiting_set(CoreObject *o, UserRequest *ur, enum telephony_ss_opcode opco)
+{
+ struct treq_ss_waiting *waiting = 0;
+ struct ss_confirm_info *user_data = 0;
+ gboolean ret = FALSE;
+ int mode = 0, classx = 0;
+ char *cmd_str;
+ TcorePending *pending = NULL;
+ TcoreATRequest *req;
+
+ dbg("function enter ");
+ waiting = (struct treq_ss_waiting *) tcore_user_request_ref_data(ur, 0);
+ user_data = g_new0(struct ss_confirm_info, 1);
+ if (!user_data) {
+ dbg("[ error ] failed to allocate memory");
+ return TCORE_RETURN_ENOMEM;
}
- dbg("Send Ussd Request: [%s]",
- (result == TEL_SS_RESULT_SUCCESS ? "SUCCESS" : "FAIL"));
+ if (opco == SS_OPCO_ACTIVATE) {
+ user_data->resp = TRESP_SS_WAITING_ACTIVATE;
+ mode = 1; // enable
+ } else if (opco == SS_OPCO_DEACTIVATE) {
+ user_data->resp = TRESP_SS_WAITING_DEACTIVATE;
+ mode = 0; // disable
+ } else
+ dbg("[ error ] unknown ss mode (0x%x)", opco);
+
+ switch (waiting->class) {
+ case SS_CLASS_ALL_TELE:
+ classx = 7;
+ break;
- tcore_ss_ussd_destroy_session(ussd_s);
+ case SS_CLASS_VOICE:
+ classx = 1;
+ break;
- /* Invoke callback */
- if (resp_cb_data->cb)
- resp_cb_data->cb(co, (gint)result, &ussd_resp, resp_cb_data->cb_data);
+ case SS_CLASS_ALL_DATA_TELE:
+ classx = 2;
+ break;
- imc_destroy_resp_cb_data(resp_cb_data);
- g_free(ussd_resp.str);
-}
+ case SS_CLASS_FAX:
+ classx = 4;
+ break;
-/* SS Operations */
-/*
- * Operation - set_barring/get_barring_status
- *
- * Request -
- * AT-Command: AT+CLCK=<fac>,<mode>[,<passwd>[,<class>]]
- * where,
- * <fac>
- * Barring facility type. Ref #TelSsBarringType
- *
- * <mode>
- * 0 unlock
- * 1 lock
- * 2 query status
- *
- * <passwd>
- * Barring Password
- *
- * <class>
- * SS class. Ref #TelSsClass
- *
- * <status>
- * 0 not active
- * 1 active
- *
- * Success: when <mode>=2:
- * OK
- * +CLCK: <status>[,<class1> [<CR><LF>
- * +CLCK: <status>,<class2> [...]]
- *
- * Failure:
- * +CME ERROR: <error>
- */
-static TelReturn imc_ss_set_barring(CoreObject *co, const TelSsBarringInfo *barring_info,
- TcoreObjectResponseCallback cb, void *cb_data)
-{
- gchar *at_cmd = NULL;
- guint mode;
- guint classx;
- gchar *facility = NULL;
- ImcRespCbData *resp_cb_data = NULL;
- TelReturn ret = TEL_RETURN_INVALID_PARAMETER;
-
- if (barring_info->enable == TRUE)
- mode = 1;
- else
- mode = 0;
+ case SS_CLASS_SMS:
+ classx = 8;
+ break;
- if (__imc_ss_convert_barring_type_to_facility(barring_info->type,
- &facility) == FALSE) {
- err("Invalid arguments");
- return ret;
+ default:
+ classx = 1;
+ dbg("unsupported class %d. set to default : 1", waiting->class);
+ break;
}
+ dbg("mode = %d classxx- %d", mode, classx);
- classx = __imc_ss_convert_class_to_imc_class(barring_info->class);
+ user_data->class = waiting->class;
+ user_data->flavor_type = (int) opco;
- dbg("facility: [%s], classx:[%d], mode: [%d]", facility, classx, mode);
+ cmd_str = g_strdup_printf("AT+CCWA=1,%d,%d", mode, classx); // always enable +CCWA: unsolicited cmd
+ dbg("request command : %s", cmd_str);
- /* AT-Command */
- at_cmd = g_strdup_printf("AT+CLCK=\"%s\",%d,\"%s\",%d", facility, mode,
- barring_info->pwd, classx);
+ pending = tcore_pending_new(o, 0);
+ req = tcore_at_request_new(cmd_str, NULL, TCORE_AT_NO_RESULT);
+ dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
- resp_cb_data = imc_create_resp_cb_data(cb, cb_data, NULL, 0);
+ tcore_pending_set_request_data(pending, 0, req);
- /* Send Request to modem */
- ret = tcore_at_prepare_and_send_request(co,
- at_cmd, NULL,
- TCORE_AT_COMMAND_TYPE_NO_RESULT,
- NULL,
- on_response_imc_ss_set_barring, resp_cb_data,
- on_send_imc_request, NULL);
- IMC_CHECK_REQUEST_RET(ret, resp_cb_data, "Set Barring");
-
- g_free(at_cmd);
- return ret;
+ ret = _ss_request_message(pending, o, ur, on_response_ss_waiting_set, user_data);
+ g_free(cmd_str);
+ if (!ret) {
+ dbg("AT request sent failed ");
+ if (user_data != NULL) {
+ g_free(user_data);
+ tcore_pending_free(pending);
+ tcore_at_request_free(req);
+ }
+ return TCORE_RETURN_FAILURE;
+ }
+ return TCORE_RETURN_SUCCESS;
}
-static TelReturn imc_ss_get_barring_status(CoreObject *co,
- const TelSsBarringGetInfo *get_barring_info,
- TcoreObjectResponseCallback cb, void *cb_data)
+static TReturn _ss_waiting_get(CoreObject *o,
+ UserRequest *ur,
+ enum telephony_ss_class class,
+ enum tcore_response_command resp)
{
- gchar *at_cmd = NULL;
- guint mode;
- guint classx;
- gchar *facility = NULL;
- ImcRespCbData *resp_cb_data = NULL;
- TelReturn ret = TEL_RETURN_INVALID_PARAMETER;
-
- mode = 2; /* query status - mode is fixed to 2 */
-
- if (__imc_ss_convert_barring_type_to_facility(get_barring_info->type,
- &facility) == FALSE) {
- err("Invalid arguments");
- return ret;
- }
+ struct ss_confirm_info *user_data = 0;
+ gboolean ret = FALSE;
+ int classx; // mode,
+ char *cmd_str;
+ TcorePending *pending = NULL;
+ TcoreATRequest *req;
+
+ dbg("function enter");
+ switch (class) {
+ case SS_CLASS_ALL_TELE:
+ classx = 7;
+ break;
- classx = __imc_ss_convert_class_to_imc_class(get_barring_info->class);
+ case SS_CLASS_VOICE:
+ classx = 1;
+ break;
- dbg("facility: [%s], classx:[%d], mode: [%d]", facility, classx, mode);
+ case SS_CLASS_ALL_DATA_TELE:
+ classx = 2;
+ break;
- /* AT-Command */
- at_cmd = g_strdup_printf("AT+CLCK=\"%s\",%d,,%d", facility, mode, classx);
+ case SS_CLASS_FAX:
+ classx = 4;
+ break;
- resp_cb_data = imc_create_resp_cb_data(cb, cb_data, (void *)get_barring_info,
- sizeof(TelSsBarringGetInfo));
+ case SS_CLASS_SMS:
+ classx = 8;
+ break;
- /* Send Request to modem */
- ret = tcore_at_prepare_and_send_request(co,
- at_cmd, "+CLCK",
- TCORE_AT_COMMAND_TYPE_MULTILINE,
- NULL,
- on_response_imc_ss_get_barring_status, resp_cb_data,
- on_send_imc_request, NULL);
- IMC_CHECK_REQUEST_RET(ret, resp_cb_data, "Get Barring Status");
+ default:
+ classx = 7;
+ dbg("unsupported class %d. set to default : 7", class);
+ break;
+ }
+ dbg("classx - %d", classx);
- g_free(at_cmd);
- return ret;
+ dbg("allocating user data");
+ user_data = g_new0(struct ss_confirm_info, 1);
+ if (!user_data) {
+ dbg("[ error ] failed to allocate memory");
+ return TCORE_RETURN_ENOMEM;
+ }
+ user_data->resp = resp;
+ user_data->class = class;
+
+ cmd_str = g_strdup_printf("AT+CCWA=1,2,%d", classx); // always enable +CCWA: unsolicited cmd , mode is fixed to 2(query status)
+ dbg("request cmd : %s", cmd_str);
+
+ pending = tcore_pending_new(o, 0);
+ req = tcore_at_request_new(cmd_str, "+CCWA", TCORE_AT_MULTILINE);
+ dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
+
+ tcore_pending_set_request_data(pending, 0, req);
+
+ ret = _ss_request_message(pending, o, ur, on_response_ss_waiting_get, user_data);
+ g_free(cmd_str);
+ if (!ret) {
+ dbg("AT request sent failed ");
+ if (user_data != NULL) {
+ g_free(user_data);
+ tcore_pending_free(pending);
+ tcore_at_request_free(req);
+ }
+ return TCORE_RETURN_FAILURE;
+ }
+ return TCORE_RETURN_SUCCESS;
}
-/*
- * Operation - change_barring_password
- *
- * Request -
- * AT-Command: AT+CPWD= <fac>,<oldpwd>,<newpwd>
- * where,
- * <fac>
- * Barring facility type. Ref #TelSsBarringType
- * Eg: "AB" All Barring services
- *
- * <oldpwd>
- * Old Barring Password
- *
- * <newpwd>
- * New Barring Password
- *
- * Success:
- * OK
- *
- * Failure:
- * +CME ERROR: <error>
- */
-static TelReturn imc_ss_change_barring_password(CoreObject *co,
- const TelSsBarringPwdInfo *barring_pwd_info,
- TcoreObjectResponseCallback cb, void *cb_data)
+static TReturn imc_ss_waiting_activate(CoreObject *o, UserRequest *ur)
{
- gchar *at_cmd = NULL;
- ImcRespCbData *resp_cb_data = NULL;
- TelReturn ret = TEL_RETURN_INVALID_PARAMETER;
-
- tcore_check_return_value(barring_pwd_info != NULL, ret);
-
- dbg("Old password: [%s], New password: [%s]", barring_pwd_info->old_pwd,
- barring_pwd_info->new_pwd);
+ if(FALSE == tcore_hal_get_power_state(tcore_object_get_hal(o))){
+ dbg("cp not ready/n");
+ return TCORE_RETURN_ENOSYS;
+ }
+ return _ss_waiting_set(o, ur, SS_OPCO_ACTIVATE);
+}
- at_cmd = g_strdup_printf("AT+CPWD=\"%s\",\"%s\",\"%s\"", "AB",
- barring_pwd_info->old_pwd, barring_pwd_info->new_pwd);
+static TReturn imc_ss_waiting_deactivate(CoreObject *o, UserRequest *ur)
+{
+ if(FALSE == tcore_hal_get_power_state(tcore_object_get_hal(o))){
+ dbg("cp not ready/n");
+ return TCORE_RETURN_ENOSYS;
+ }
+ return _ss_waiting_set(o, ur, SS_OPCO_DEACTIVATE);
+}
- resp_cb_data = imc_create_resp_cb_data(cb, cb_data, NULL, 0);
+static TReturn imc_ss_waiting_get_status(CoreObject *o, UserRequest *ur)
+{
+ struct treq_ss_waiting *waiting = 0;
- /* Send Request to modem */
- ret = tcore_at_prepare_and_send_request(co,
- at_cmd, NULL,
- TCORE_AT_COMMAND_TYPE_NO_RESULT,
- NULL,
- on_response_imc_ss_change_barring_password, resp_cb_data,
- on_send_imc_request, NULL);
- IMC_CHECK_REQUEST_RET(ret, resp_cb_data, "Change Barring Password");
+ if(FALSE == tcore_hal_get_power_state(tcore_object_get_hal(o))){
+ dbg("cp not ready/n");
+ return TCORE_RETURN_ENOSYS;
+ }
+ waiting = (struct treq_ss_waiting *) tcore_user_request_ref_data(ur, 0);
- g_free(at_cmd);
- return ret;
+ return _ss_waiting_get(o, ur, waiting->class, TRESP_SS_WAITING_GET_STATUS);
}
-/*
- * Operation - set_forwarding/get_forwarding_status
- *
- * Request -
- * AT-Command: AT+CCFC=<reason>,<mode>[,<number>[,<type>
- * [,<class>[,<subaddr>[,<satype>[,<time>]]]]]]
- * where,
- * <reason>
- * Forwarding Condition. Ref #TelSsForwardCondition
- *
- * <mode>
- * Forwarding Mode. Ref #TelSsForwardMode
- * 0 disable
- * 1 enable
- * 2 query status
- * 3 registration
- * 4 erasure
- *
- *
- * <number>
- * Call Forwarding Number
- *
- * <type>
- * Default 145 when available string includes "+"
- * Otherwise 129
- *
- * <subaddr>
- * Parameter String type subaddress of format specified by <satype>
- *
- * <satype>
- * Parameter type of subaddress octet in integer format
- * Default 128
- *
- * <time>
- * Parameter time in seconds to wait before call is forwarded
- * Default 20, but only when <reason>=2 (no reply) is enabled
- *
- * <class>
- * SS class. Ref #TelSsClass
- *
- * <status>
- * 0 not active
- * 1 active
- *
- * Success: when <mode>=2:
- * OK
- * +CCFC: <status>,<class1>[,<number>,<type>[,<subaddr>,<satype>[,<time>]]][<CR><LF>
- * +CCFC: <status>,<class2>[,<number>,<type>[,<subaddr>,<satype>[,<time>]]][...]]
- *
- * Failure:
- * +CME ERROR: <error>
- */
-static TelReturn imc_ss_set_forwarding(CoreObject *co, const TelSsForwardInfo *forwarding_info,
- TcoreObjectResponseCallback cb, void *cb_data)
+static TReturn imc_ss_cli_activate(CoreObject *o, UserRequest *ur)
{
- gchar *at_cmd = NULL;
- gchar *tmp_cmd = NULL;
- guint classx;
- guint reason;
- guint mode;
- guint num_type;
- ImcRespCbData *resp_cb_data = NULL;
- TelReturn ret = TEL_RETURN_INVALID_PARAMETER;
-
- classx = __imc_ss_convert_class_to_imc_class(forwarding_info->class);
+ if(FALSE == tcore_hal_get_power_state(tcore_object_get_hal(o))){
+ dbg("cp not ready/n");
+ return TCORE_RETURN_ENOSYS;
+ }
+ return TCORE_RETURN_SUCCESS;
+}
- if (__imc_ss_convert_forwarding_mode_to_modem_mode(forwarding_info->mode, &mode)
- == FALSE) {
- err("Invalid arguments");
- return ret;
+static TReturn imc_ss_cli_deactivate(CoreObject *o, UserRequest *ur)
+{
+ if(FALSE == tcore_hal_get_power_state(tcore_object_get_hal(o))){
+ dbg("cp not ready/n");
+ return TCORE_RETURN_ENOSYS;
}
+ return TCORE_RETURN_SUCCESS;
+}
- if (__imc_ss_convert_forwarding_condition_to_modem_reason(forwarding_info->condition,
- &reason) == FALSE) {
- err("Invalid arguments");
- return ret;
+static TReturn imc_ss_cli_get_status(CoreObject *o, UserRequest *ur)
+{
+ struct treq_ss_cli *cli = 0;
+ gboolean ret = FALSE;
+ char *cmd_prefix = NULL, *rsp_prefix = NULL, *cmd_str = NULL;
+ enum telephony_ss_cli_type *user_data = 0;
+ TcorePending *pending = NULL;
+ TcoreATRequest *req;
+
+ if(FALSE == tcore_hal_get_power_state(tcore_object_get_hal(o))){
+ dbg("cp not ready/n");
+ return TCORE_RETURN_ENOSYS;
}
- if (forwarding_info->number[0] == '+')
- num_type = 145;
- else
- num_type = 129;
+ cli = (struct treq_ss_cli *) tcore_user_request_ref_data(ur, 0);
+ switch (cli->type) {
+ case SS_CLI_TYPE_CLIP:
+ cmd_prefix = "+CLIP";
+ rsp_prefix = "+CLIP";
+ break;
- dbg("classx: [%d], reason:[%d], mode: [%d]", classx, reason, mode);
+ case SS_CLI_TYPE_CLIR:
+ cmd_prefix = "+CLIR";
+ rsp_prefix = "+CLIR";
+ break;
- if (mode == 3) /* TEL_SS_CF_MODE_REGISTER */
- tmp_cmd = g_strdup_printf("AT+CCFC=%d,%d,\"%s\",%d,%d", reason, mode,
- forwarding_info->number, num_type, classx);
- else
- tmp_cmd = g_strdup_printf("AT+CCFC=%d,%d,,,%d", reason, mode, classx);
+ case SS_CLI_TYPE_COLP:
+ cmd_prefix = "+COLP";
+ rsp_prefix = "+COLP";
+ break;
- if (reason == 2) /* TEL_SS_CF_COND_CFNRY */
- at_cmd = g_strdup_printf("%s,,,%d", tmp_cmd, forwarding_info->wait_time);
- else
- at_cmd = g_strdup_printf("%s", tmp_cmd);
+ case SS_CLI_TYPE_COLR:
+ cmd_prefix = "+COLR";
+ rsp_prefix = "+COLR";
+ break;
- resp_cb_data = imc_create_resp_cb_data(cb, cb_data, NULL, 0);
+ case SS_CLI_TYPE_CNAP:
+ cmd_prefix = "+CNAP";
+ rsp_prefix = "+CNAP";
+ break;
- /* Send Request to modem */
- ret = tcore_at_prepare_and_send_request(co,
- at_cmd, NULL,
- TCORE_AT_COMMAND_TYPE_NO_RESULT,
- NULL,
- on_response_imc_ss_set_forwarding, resp_cb_data,
- on_send_imc_request, NULL);
- IMC_CHECK_REQUEST_RET(ret, resp_cb_data, "Set Forwarding");
+ case SS_CLI_TYPE_CDIP:
+ default:
+ dbg("unsupported cli_type : %d", cli->type);
+ return TCORE_RETURN_FAILURE;
+ break;
+ }
+ dbg("cmd_prefix : %s", cmd_prefix);
- g_free(tmp_cmd);
- g_free(at_cmd);
+ cmd_str = g_strdup_printf("AT%s?", cmd_prefix);
+ dbg("request cmd : %s", cmd_str);
- return ret;
+ user_data = g_new0(enum telephony_ss_cli_type, 1);
+ if (!user_data) {
+ dbg("[ error ] failed to allocate memory");
+ g_free(cmd_str);
+ return TCORE_RETURN_ENOMEM;
+ }
+ *user_data = cli->type;
+
+ pending = tcore_pending_new(o, 0);
+
+ req = tcore_at_request_new(cmd_str, rsp_prefix, TCORE_AT_SINGLELINE);
+ dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
+ tcore_pending_set_request_data(pending, 0, req);
+
+ ret = _ss_request_message(pending, o, ur, on_response_ss_cli_get, user_data);
+ g_free(cmd_str);
+ if (!ret) {
+ dbg("AT request sent failed ");
+ if (user_data != NULL) {
+ g_free(user_data);
+ tcore_pending_free(pending);
+ tcore_at_request_free(req);
+ }
+ return TCORE_RETURN_FAILURE;
+ }
+ return TCORE_RETURN_SUCCESS;
}
-static TelReturn imc_ss_get_forwarding_status(CoreObject *co, const TelSsForwardGetInfo *get_forwarding_info,
- TcoreObjectResponseCallback cb, void *cb_data)
+static TReturn imc_ss_send_ussd(CoreObject *o, UserRequest *ur)
{
- gchar *at_cmd = NULL;
- guint classx;
- guint reason;
- guint mode = 2; /* query status */
- ImcRespCbData *resp_cb_data = NULL;
- TelReturn ret = TEL_RETURN_INVALID_PARAMETER;
+ UssdSession *ussd_s = 0;
+ struct treq_ss_ussd *ussd = 0;
+ struct ss_confirm_info *user_data = 0;
+ gboolean ret = FALSE;
+ char *cmd_str;
+ TcorePending *pending = NULL;
+ TcoreATRequest *req;
+
+ dbg("function enter");
+
+ if(FALSE == tcore_hal_get_power_state(tcore_object_get_hal(o))){
+ dbg("cp not ready/n");
+ return TCORE_RETURN_ENOSYS;
+ }
+
+ ussd = (struct treq_ss_ussd *) tcore_user_request_ref_data(ur, 0);
- classx = __imc_ss_convert_class_to_imc_class(get_forwarding_info->class);
+ user_data = g_new0(struct ss_confirm_info, 1);
- if (__imc_ss_convert_forwarding_condition_to_modem_reason(get_forwarding_info->condition,
- &reason) == FALSE) {
- err("Invalid arguments");
- return ret;
+ user_data->resp = TRESP_SS_SEND_USSD;
+ ussd_s = tcore_ss_ussd_get_session(o);
+ if (!ussd_s) {
+ dbg("USSD session does not exist");
+ tcore_ss_ussd_create_session(o, (enum tcore_ss_ussd_type) ussd->type, (void *) tcore_user_request_ref(ur), 0);
+ } else {
+ if (ussd->type == SS_USSD_TYPE_USER_INITIATED) {
+ dbg("[ error ] ussd session is already exist");
+ g_free(user_data);
+ return TCORE_RETURN_FAILURE;
+ }
+
+ tcore_ss_ussd_set_session_type(ussd_s, (enum tcore_ss_ussd_type) ussd->type);
}
- dbg("classx: [%d], reason: [%d], mode: [%d]", classx, reason, mode);
+ 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
+ dbg("request command : %s", cmd_str);
- at_cmd = g_strdup_printf("AT+CCFC=%d,%d,,,%d", reason, mode, classx);
+ pending = tcore_pending_new(o, 0);
+ req = tcore_at_request_new(cmd_str, NULL, TCORE_AT_NO_RESULT);
+ dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
- resp_cb_data = imc_create_resp_cb_data(cb, cb_data, (void *)get_forwarding_info,
- sizeof(TelSsForwardGetInfo));
+ tcore_pending_set_request_data(pending, 0, req);
- /* Send Request to modem */
- ret = tcore_at_prepare_and_send_request(co,
- at_cmd, "+CCFC",
- TCORE_AT_COMMAND_TYPE_MULTILINE,
- NULL,
- on_response_imc_ss_get_forwarding_status, resp_cb_data,
- on_send_imc_request, NULL);
- IMC_CHECK_REQUEST_RET(ret, resp_cb_data, "Get Forwarding Status");
+ ret = _ss_request_message(pending, o, ur, on_confirmation_ss_ussd, user_data);
+ g_free(cmd_str);
- g_free(at_cmd);
- return ret;
+ if (!ret) {
+ dbg("AT request sent failed ");
+ if (user_data != NULL) {
+ g_free(user_data);
+ tcore_pending_free(pending);
+ tcore_at_request_free(req);
+ }
+ return TCORE_RETURN_FAILURE;
+ }
+ return TCORE_RETURN_SUCCESS;
}
-/*
- * Operation - set_waiting/get_waiting_status
- *
- * Request -
- * AT-Command: AT+CCWA=[<n>[,<mode>[,<class>]]]
- * where,
- * <n>
- * Parameter Sets/shows the result code presentation status to the TE.
- * 0 presentation status is disabled to TE(default)
- * 1 presentation status is enabled to TE
- *
- * <mode>
- * 0 Disable call waiting
- * 1 Enable call waiting
- * 2 Query status
- *
- * <class>
- * SS class. Ref #TelSsClass
- *
- * <status>
- * 0 not active
- * 1 active
- *
- * Success: when <mode>=2:
- * OK
- * +CCWA: <status>,<class1>
- * +CCWA: <status>,<class2>
- *
- * Failure:
- * +CME ERROR: <error>
- */
-static TelReturn imc_ss_set_waiting(CoreObject *co, const TelSsWaitingInfo *waiting_info,
- TcoreObjectResponseCallback cb, void *cb_data)
+static TReturn imc_ss_set_aoc(CoreObject *o, UserRequest *ur)
{
- gchar *at_cmd = NULL;
- guint classx;
- guint mode;
- ImcRespCbData *resp_cb_data = NULL;
- TelReturn ret = TEL_RETURN_INVALID_PARAMETER;
-
- if (waiting_info->enable == TRUE)
- mode = 1;
- else
- mode = 0;
+ if(FALSE == tcore_hal_get_power_state(tcore_object_get_hal(o))){
+ dbg("cp not ready/n");
+ return TCORE_RETURN_ENOSYS;
+ }
- classx = __imc_ss_convert_class_to_imc_class(waiting_info->class);
+ dbg("[ error ] unsupported function");
+ return TCORE_RETURN_SUCCESS;
+}
- dbg("mode: [%d], class: [%d]", mode, classx);
+static TReturn imc_ss_get_aoc(CoreObject *o, UserRequest *ur)
+{
+ if(FALSE == tcore_hal_get_power_state(tcore_object_get_hal(o))){
+ dbg("cp not ready/n");
+ return TCORE_RETURN_ENOSYS;
+ }
- at_cmd = g_strdup_printf("AT+CCWA=1,%d,%d", mode, classx);
+ dbg("[ error ] unsupported function");
+ return TCORE_RETURN_SUCCESS;
+}
- resp_cb_data = imc_create_resp_cb_data(cb, cb_data, NULL, 0);
- /* Send Request to modem */
- ret = tcore_at_prepare_and_send_request(co,
- at_cmd, NULL,
- TCORE_AT_COMMAND_TYPE_NO_RESULT,
- NULL,
- on_response_imc_ss_set_waiting, resp_cb_data,
- on_send_imc_request, NULL);
- IMC_CHECK_REQUEST_RET(ret, resp_cb_data, "Set Waiting");
+static struct tcore_call_control_operations call_ops = {
+ .answer_hold_and_accept = imc_ss_manage_call_2_send,
+ .answer_replace = imc_ss_manage_call_1_send,
+ .answer_reject = imc_ss_manage_call_0_send,
+ .end_specific = imc_ss_manage_call_1x_send,
+ .end_all_active = imc_ss_manage_call_1_send,
+ .end_all_held = imc_ss_manage_call_0_send,
+ .active = imc_ss_manage_call_2_send,
+ .hold = imc_ss_manage_call_2_send,
+ .swap = imc_ss_manage_call_2_send,
+ .join = imc_ss_manage_call_3_send,
+ .split = imc_ss_manage_call_2x_send,
+ .transfer = imc_ss_manage_call_4_send,
+ .deflect = imc_ss_manage_call_4dn_send,
+};
- g_free(at_cmd);
- return ret;
+static TReturn imc_ss_manage_call_send(CoreObject *o, UserRequest *ur, const char *cmd, ConfirmCallback cb, void *user_data)
+{
+ TcorePending *pending = NULL;
+ TcoreATRequest *req;
+ gboolean ret = FALSE;
+
+ pending = tcore_pending_new(o, 0);
+ req = tcore_at_request_new(cmd, NULL, TCORE_AT_NO_RESULT);
+ dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
+ tcore_pending_set_request_data(pending, 0, req);
+
+ ret = _ss_request_message(pending, o, ur, (TcorePendingResponseCallback) cb, user_data);
+ if (!ret) {
+ dbg("AT request sent failed ");
+ return TCORE_RETURN_FAILURE;
+ }
+ return TCORE_RETURN_SUCCESS;
}
-static TelReturn imc_ss_get_waiting_status(CoreObject *co, TelSsClass ss_class,
- TcoreObjectResponseCallback cb, void *cb_data)
+static TReturn imc_ss_manage_call_0_send(CoreObject *o, UserRequest *ur, ConfirmCallback cb, void *user_data)
{
- gchar *at_cmd = NULL;
- guint classx;
- ImcRespCbData *resp_cb_data = NULL;
- TelReturn ret = TEL_RETURN_INVALID_PARAMETER;
-
- classx = __imc_ss_convert_class_to_imc_class(ss_class);
+ char *cmd_str = NULL;
+ gboolean ret = FALSE;
- dbg("class: [%d]", classx);
+ dbg("function enter");
+ cmd_str = g_strdup_printf("%s", "AT+CHLD=0");
+ dbg("cmd : %s, prefix(if any) : %s, cmd_len : %d", cmd_str, "N/A", strlen(cmd_str));
- at_cmd = g_strdup_printf("AT+CCWA=1,2,%d", classx);
+ ret = imc_ss_manage_call_send(o, ur, cmd_str, cb, user_data);
+ g_free(cmd_str);
+ return ret;
+}
- resp_cb_data = imc_create_resp_cb_data(cb, cb_data, &ss_class, sizeof(TelSsClass));
+static TReturn imc_ss_manage_call_1_send(CoreObject *o, UserRequest *ur, ConfirmCallback cb, void *user_data)
+{
+ char *cmd_str = NULL;
+ gboolean ret = FALSE;
- /* Send Request to modem */
- ret = tcore_at_prepare_and_send_request(co,
- at_cmd, "+CCWA",
- TCORE_AT_COMMAND_TYPE_MULTILINE,
- NULL,
- on_response_imc_ss_get_waiting_status, resp_cb_data,
- on_send_imc_request, NULL);
- IMC_CHECK_REQUEST_RET(ret, resp_cb_data, "Get Waiting Status");
+ dbg("function enter");
+ cmd_str = g_strdup_printf("%s", "AT+CHLD=1");
+ dbg("cmd : %s, prefix(if any) : %s, cmd_len : %d", cmd_str, "N/A", strlen(cmd_str));
- g_free(at_cmd);
+ ret = imc_ss_manage_call_send(o, ur, cmd_str, cb, user_data);
+ g_free(cmd_str);
return ret;
}
-/*
- * Operation - set_cli/get_cli_status
- *
- * Request -
- * AT-Command:
- * For CLIR: AT+CLIR= [<n>]
- * For CLIP: AT+CLIP= [<n>]
- * For COLP: AT+COLP= [<n>]
- * For COLR: AT+COLR= [<n>]
- * For CNAP: AT+CNAP= [<n>]
- *
- * where,
- * <n> All CLI except CLIR
- * 0 disable(default)
- * 1 enable
- *
- * <n> for CLIR
- * 0 default
- * 1 CLIR invocation
- * 2 CLIR suppression
- *
- * Success:
- * OK
- * +CLIR: <n>,<m>
- *
- * where,
- * <m> All CLI except CLIR
- * 0 Not provisioned
- * 1 Provisioned
- * 2 Unknown
- *
- *<m> For CLIR
- * 0 Not provisioned
- * 1 Provisioned in permanent mode
- * 2 Unknown (e.g. no network, etc.)
- * 3 Temporary mode presentation restricted
- * 4 Temporary mode presentation allowed
- *
- * Failure:
- * +CME ERROR: <error>
- */
-static TelReturn imc_ss_set_cli(CoreObject *co, const TelSsCliInfo *cli_info,
- TcoreObjectResponseCallback cb, void *cb_data)
+static TReturn imc_ss_manage_call_1x_send(CoreObject *o, UserRequest *ur, const int id, ConfirmCallback cb, void *user_data)
{
- gchar *at_cmd = NULL;
- gchar *cmd_prefix = NULL;
- gint status = 0;
- ImcRespCbData *resp_cb_data = NULL;
- TelReturn ret = TEL_RETURN_INVALID_PARAMETER;
+ char *cmd_str = NULL;
+ gboolean ret = FALSE;
- if (__imc_ss_convert_cli_info_modem_info(&cli_info, &status, &cmd_prefix) == FALSE)
- return ret;
+ dbg("function enter");
+ cmd_str = g_strdup_printf("%s%d", "AT+CHLD=1", id);
+ dbg("cmd : %s, prefix(if any) : %s, cmd_len : %d", cmd_str, "N/A", strlen(cmd_str));
- at_cmd = g_strdup_printf("AT%s=%d", cmd_prefix, status);
+ ret = imc_ss_manage_call_send(o, ur, cmd_str, cb, user_data);
+ g_free(cmd_str);
+ return ret;
+}
- resp_cb_data = imc_create_resp_cb_data(cb, cb_data, NULL, 0);
+static TReturn imc_ss_manage_call_2_send(CoreObject *o, UserRequest *ur, ConfirmCallback cb, void *user_data)
+{
+ char *cmd_str = NULL;
+ gboolean ret = FALSE;
- /* Send Request to modem */
- ret = tcore_at_prepare_and_send_request(co,
- at_cmd, NULL,
- TCORE_AT_COMMAND_TYPE_NO_RESULT,
- NULL,
- on_response_imc_ss_set_cli, resp_cb_data,
- on_send_imc_request, NULL);
- IMC_CHECK_REQUEST_RET(ret, resp_cb_data, "Set Cli");
+ dbg("function enter");
+ cmd_str = g_strdup_printf("%s", "AT+CHLD=2");
+ dbg("cmd : %s, prefix(if any) : %s, cmd_len : %d", cmd_str, "N/A", strlen(cmd_str));
- g_free(at_cmd);
+ ret = imc_ss_manage_call_send(o, ur, cmd_str, cb, user_data);
+ g_free(cmd_str);
return ret;
}
-static TelReturn imc_ss_get_cli_status(CoreObject *co, TelSsCliType cli_type,
- TcoreObjectResponseCallback cb, void *cb_data)
+static TReturn imc_ss_manage_call_2x_send(CoreObject *o, UserRequest *ur, const int id, ConfirmCallback cb, void *user_data)
{
- gchar *at_cmd = NULL;
- gchar *cmd_prefix = NULL;
- ImcRespCbData *resp_cb_data = NULL;
- TelReturn ret = TEL_RETURN_INVALID_PARAMETER;
+ char *cmd_str = NULL;
+ gboolean ret = FALSE;
- switch (cli_type) {
- case TEL_SS_CLI_CLIR:
- cmd_prefix = "+CLIR";
- break;
- case TEL_SS_CLI_CLIP:
- cmd_prefix = "+CLIP";
- break;
- case TEL_SS_CLI_COLP:
- cmd_prefix = "+COLP";
- break;
- case TEL_SS_CLI_COLR:
- cmd_prefix = "+COLR";
- break;
- case TEL_SS_CLI_CNAP:
- cmd_prefix = "+CNAP";
- break;
- case TEL_SS_CLI_CDIP:
- default:
- dbg("Unsupported CLI type: [%d]", cli_type);
- return ret;
- }
+ dbg("function enter");
+ cmd_str = g_strdup_printf("%s%d", "AT+CHLD=2", id);
+ dbg("cmd : %s, prefix(if any) : %s, cmd_len : %d", cmd_str, "N/A", strlen(cmd_str));
- at_cmd = g_strdup_printf("AT%s?", cmd_prefix);
+ ret = imc_ss_manage_call_send(o, ur, cmd_str, cb, user_data);
+ g_free(cmd_str);
+ return ret;
+}
- resp_cb_data = imc_create_resp_cb_data(cb, cb_data, &cli_type, sizeof(TelSsCliType));
+static TReturn imc_ss_manage_call_3_send(CoreObject *o, UserRequest *ur, ConfirmCallback cb, void *user_data)
+{
+ char *cmd_str = NULL;
+ gboolean ret = FALSE;
- /* Send Request to modem */
- ret = tcore_at_prepare_and_send_request(co,
- at_cmd, cmd_prefix,
- TCORE_AT_COMMAND_TYPE_SINGLELINE,
- NULL,
- on_response_imc_ss_get_cli_status, resp_cb_data,
- on_send_imc_request, NULL);
- IMC_CHECK_REQUEST_RET(ret, resp_cb_data, "Get Cli Status");
+ dbg("function enter");
+ cmd_str = g_strdup_printf("%s", "AT+CHLD=3");
- g_free(at_cmd);
+ ret = imc_ss_manage_call_send(o, ur, cmd_str, cb, user_data);
+ g_free(cmd_str);
return ret;
}
-/*
- * Operation - send_ussd_request
- *
- * Request -
- * AT-Command: AT+CUSD = [<n> [, <str> [, <dcs>]]]
- * where,
- * <n>
- * 0 Disable the result code presentation to the TE(default)
- * 1 Enable the result code presentation to the TE
- * 2 Cancel session (not applicable to read command response)
- *
- * <str>
- * USSD string
- *
- * <dcs>
- * Cell Broadcast Data Coding Scheme. Default value is 0.
- *
- * Success:
- * OK
- *
- * Failure:
- * +CME ERROR: <error>
- */
-static TelReturn imc_ss_send_ussd_request(CoreObject *co, const TelSsUssdInfo *ussd_request,
- TcoreObjectResponseCallback cb, void *cb_data)
+
+static TReturn imc_ss_manage_call_4_send(CoreObject *o, UserRequest *ur, ConfirmCallback cb, void *user_data)
{
- gchar *at_cmd = NULL;
- UssdSession *ussd_s = NULL;
- ImcRespCbData *resp_cb_data = NULL;
- TelReturn ret = TEL_RETURN_INVALID_PARAMETER;
+ char *cmd_str = NULL;
+ gboolean ret = FALSE;
- ussd_s = tcore_ss_ussd_get_session(co);
- if (!ussd_s) {
- dbg("USSD session does not exist");
- tcore_ss_ussd_create_session(co, ussd_request->type, (void *)ussd_request->str,
- strlen((char *)ussd_request->str));
- } else {
- if (ussd_request->type == TEL_SS_USSD_TYPE_USER_INIT) {
- err("Ussd session is already exist");
- return TEL_RETURN_OPERATION_NOT_SUPPORTED;
- }
- tcore_ss_ussd_set_session_type(ussd_s, ussd_request->type);
- }
+ dbg("function enter");
+ cmd_str = g_strdup_printf("%s", "AT+CHLD=4");
+
+ ret = imc_ss_manage_call_send(o, ur, cmd_str, cb, user_data);
+ g_free(cmd_str);
+ return ret;
+}
- at_cmd = g_strdup_printf("AT+CUSD=1,\"%s\",%d", ussd_request->str, 0x0f);
+static TReturn imc_ss_manage_call_4dn_send(CoreObject *o, UserRequest *ur, const char *number, ConfirmCallback cb, void *user_data)
+{
+ char *cmd_str = NULL;
+ gboolean ret = FALSE;
- resp_cb_data = imc_create_resp_cb_data(cb, cb_data, NULL, 0);
+ dbg("function enter");
+ cmd_str = g_strdup_printf("%s%s", "AT+CHLD=4", number);
- /* Send Request to modem */
- ret = tcore_at_prepare_and_send_request(co,
- at_cmd, NULL,
- TCORE_AT_COMMAND_TYPE_NO_RESULT,
- NULL,
- on_response_imc_ss_send_ussd_request, resp_cb_data,
- on_send_imc_request, NULL);
- IMC_CHECK_REQUEST_RET(ret, resp_cb_data, "Send Ussd Request");
+ ret = imc_ss_manage_call_send(o, ur, cmd_str, cb, user_data);
+ g_free(cmd_str);
- g_free(at_cmd);
return ret;
}
-/* SS Operations */
-static TcoreSsOps imc_ss_ops = {
- .set_barring = imc_ss_set_barring,
- .get_barring_status = imc_ss_get_barring_status,
- .change_barring_password = imc_ss_change_barring_password,
- .set_forwarding = imc_ss_set_forwarding,
- .get_forwarding_status = imc_ss_get_forwarding_status,
- .set_waiting = imc_ss_set_waiting,
- .get_waiting_status = imc_ss_get_waiting_status,
- .set_cli = imc_ss_set_cli,
- .get_cli_status = imc_ss_get_cli_status,
- .send_ussd_request = imc_ss_send_ussd_request
-};
-
-gboolean imc_ss_init(TcorePlugin *p, CoreObject *co)
+gboolean imc_ss_init(TcorePlugin *cp, CoreObject *co_ss)
{
- dbg("Entry");
+ CoreObject *co_call = NULL;
/* Set operations */
- tcore_ss_set_ops(co, &imc_ss_ops);
+ tcore_ss_set_ops(co_ss, &ss_ops);
- /* Add Callbacks */
- tcore_object_add_callback(co, "+CUSD", on_notification_imc_ss_ussd, NULL);
- dbg("Exit");
+ co_call = tcore_plugin_ref_core_object(cp,
+ CORE_OBJECT_TYPE_CALL);
+ if (co_call == NULL) {
+ err("Can't find CALL core object");
+ return FALSE;
+ }
+
+ /* Set operations */
+ tcore_call_control_set_operations(co_call, &call_ops);
+
+ tcore_object_add_callback(co_ss, "+CSSU", on_notification_ss_info, NULL);
+ tcore_object_add_callback(co_ss, "+CSSI", on_notification_ss_info, NULL);
+ tcore_object_add_callback(co_ss, "+CUSD", on_notification_ss_ussd, NULL);
+
return TRUE;
}
-void imc_ss_exit(TcorePlugin *p, CoreObject *co)
+void imc_ss_exit(TcorePlugin *cp, CoreObject *co_ss)
{
dbg("Exit");
}