2 * tel-plugin-socket-communicator
4 * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Ja-young Gu <jygu@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
25 #include <glib-object.h>
31 #include <communicator.h>
32 #include <core_object.h>
34 #include <user_request.h>
39 #include "tapi_common.h"
40 #include "module_req.h"
42 gboolean scomm_service_reqeust_sat(unsigned int ch_id, Communicator *c, TcorePlugin *plugin, tapi_service_command_e cmd, gchar *data, void **outparam)
46 gboolean result = TRUE;
48 gchar *serial_d = NULL;
50 GSList *co_list = NULL;
51 CoreObject *co_sat = NULL;
52 UserRequest *ur = NULL;
53 struct tcore_user_info ui = { 0, 0, 0, NULL,0,0, NULL };
55 struct _sipc_marshal_object *out_obj = NULL;
56 struct _sipc_marshal_object *in_obj = NULL;
58 co_list = tcore_plugin_get_core_objects_bytype(plugin, CORE_OBJECT_TYPE_SAT);
60 dbg("coreobjects does not exist");
65 co_sat = (CoreObject *)co_list->data;
67 dbg("sat objects does not exist");
71 g_slist_free(co_list);
73 in_obj = sipc_util_marshal_object_deserializer(data);
75 dbg("in_obj is NULL");
80 ui.channel_id = ch_id;
81 ui.client_cmd = (unsigned int)cmd;
82 ur = tcore_user_request_new(c, tcore_plugin_get_description(plugin)->name);
88 tcore_user_request_set_user_info(ur, &ui);
91 case TAPI_SERVICE_SAT_MENU_SELECTION_ENVELOP: {
92 gchar item_identifier = '\0';
93 gboolean help_request = FALSE;
94 struct treq_sat_envelop_cmd_data envelop_data;
96 dbg("TAPI_CS_SIMATK_SEND_MENU_SELECTION_ENVELOPE");
98 item_identifier = sipc_util_marshal_object_get_char(in_obj,"item_identifier");
99 help_request = sipc_util_marshal_object_get_boolean(in_obj, "help_request");
100 dbg("[SAT] menu selection envelop item_identifier(0x%x) help_request(%d)");
102 memset(&envelop_data, 0, sizeof(struct treq_sat_envelop_cmd_data));
104 envelop_data.sub_cmd = ENVELOP_MENU_SELECTION;
105 envelop_data.envelop_data.menu_select.device_identitie.src = DEVICE_ID_KEYPAD;
106 envelop_data.envelop_data.menu_select.device_identitie.dest = DEVICE_ID_SIM;
107 envelop_data.envelop_data.menu_select.item_identifier.item_identifier = item_identifier;
108 envelop_data.envelop_data.menu_select.help_request = help_request;
110 tcore_user_request_set_data(ur, sizeof(struct treq_sat_envelop_cmd_data), (void *) &envelop_data);
111 tcore_user_request_set_command(ur, TREQ_SAT_REQ_ENVELOPE);
113 ret = tcore_communicator_dispatch_request(c, ur);
114 if (ret != TCORE_RETURN_SUCCESS){
115 dbg("dispatch request fail");
120 /*case TAPI_SERVICE_SAT_SEND_EVENT_DOWNLOAD: {
121 tcore_user_request_set_data(ur, 0, NULL);
122 tcore_user_request_set_command(ur, TREQ_SAT_REQ_ENVELOPE);
123 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
124 if (ret != TCORE_RETURN_SUCCESS)
125 api_err = TAPI_API_OPERATION_FAILED;
127 g_array_append_vals(*out_param2, &request_id, sizeof(int));
128 dbg("ret = 0x%x", ret);
130 case TAPI_SERVICE_SAT_UI_USER_CONFIRM: {
131 TelSatUiUserConfirmInfo_t cnf;
132 TelSatTextInfo_t* additional_data = NULL;
134 memset(&cnf, 0x00, sizeof(TelSatUiUserConfirmInfo_t));
135 cnf.commandId = g_array_index(in_param1,int, 0);
136 cnf.commandType = g_array_index(in_param1,int, 1);
137 cnf.keyType = g_array_index(in_param1, int, 2);
138 cnf.dataLen = g_array_index(in_param1, int, 3);
140 dbg("command_id = 0x%x", cnf.commandId);
141 dbg("command_type = 0x%x", cnf.commandType);
142 dbg("key_type = 0x%x", cnf.keyType);
143 dbg("data_length = %d", cnf.dataLen);
145 if (cnf.dataLen > 0) {
146 additional_data = &g_array_index(in_param2, TelSatTextInfo_t, 0);
147 dbg("tel_send_sat_ui_user_confirm :[%d]", additional_data->string[0]);
148 api_err = sat_mgr_handle_user_confirm(ctx, plugin, conn_name.name, &cnf, additional_data->string, additional_data->stringLen);
149 if (api_err != TAPI_API_SUCCESS)
150 dbg("return_value = %d", api_err);
152 else if (cnf.dataLen == 0) {
153 api_err = sat_mgr_handle_user_confirm(ctx, plugin, conn_name.name, &cnf, NULL, 0);
154 if (api_err != TAPI_API_SUCCESS)
155 dbg("return_value = %d", api_err);
157 else if (cnf.dataLen < 0) {
158 api_err = TAPI_API_SERVER_FAILURE;
160 if (api_err != TCORE_RETURN_SUCCESS) {
161 api_err = TAPI_API_OPERATION_FAILED;
163 dbg("api_err = 0x%x", api_err);
165 case TAPI_SERVICE_SEND_APP_EXEC_RESULT: {
166 TelSatAppsRetInfo_t* app_req_info = NULL;
167 dbg("TAPI_CS_SIMATK_SEND_APP_EXEC_RESULT");
168 app_req_info = &g_array_index(in_param1, TelSatAppsRetInfo_t, 0);
169 ret = sat_mgr_handle_app_exec_result(ctx, plugin, conn_name.name, app_req_info);
170 if (ret != TCORE_RETURN_SUCCESS)
171 api_err = TAPI_API_OPERATION_FAILED;
173 dbg("ret = 0x%x", ret);
175 case TAPI_SERVICE_GET_MAIN_MENU_INFO: {
176 dbg("TAPI_CS_SIMATK_GET_MAIN_MENU_INFO");
177 if (ctx->pSatMainMenu != NULL && ctx->pSatMainMenu->satMainMenuNum > 0) {
178 dbg("[SAT] pSatMainMenu->satMainMenuNum: [%d]", ctx->pSatMainMenu->satMainMenuNum);
179 dbg("[SAT] pSatMainMenu->satiMainTitle [%s]", ctx->pSatMainMenu->satMainTitle);
180 ctx->pSatMainMenu->bIsMainMenuPresent = TRUE;
181 g_array_append_vals(*out_param2, ctx->pSatMainMenu, sizeof(TelSatSetupMenuInfo_t));
184 memset(&satMainMenu, 0x00, sizeof(TelSatSetupMenuInfo_t));
185 satMainMenu.bIsMainMenuPresent = FALSE;
186 g_array_append_vals(*out_param2, &satMainMenu, sizeof(TelSatSetupMenuInfo_t));
189 case TAPI_SERVICE_SAT_UI_DISPLAY_STATUS:
195 sipc_util_marshal_object_destory(in_obj);
196 out_obj = sipc_util_marshal_object_create();
197 sipc_util_marshal_object_add_data(out_obj, "result", &result, SIPC_MARSHAL_DATA_BOOLEAN_TYPE);
199 dbg("result = %d", result);
201 *outparam = sipc_util_marshal_object_serializer(out_obj);
202 sipc_util_marshal_object_destory(out_obj);
204 if (result == FALSE) {
205 tcore_user_request_unref(ur);
209 ret = tcore_communicator_dispatch_request(c, ur);
210 if (ret != TCORE_RETURN_SUCCESS) {
217 gboolean scomm_service_response_sat(Communicator *comm, UserRequest *ur, enum tcore_response_command command, unsigned int data_len, const void *data)
222 gboolean scomm_service_notification_sat(Communicator *comm, CoreObject *source, enum tcore_notification_command command, unsigned int data_len, const void *data)