tizen 2.3.1 release
[framework/telephony/libslp-tapi.git] / src / tapi_sat.c
1 /*
2  * libslp-tapi
3  *
4  * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Ja-young Gu <jygu@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24
25 #include "tapi_common.h"
26 #include "TapiUtility.h"
27 #include "TelSat.h"
28
29 #include "common.h"
30 #include "tapi_log.h"
31 #include "ITapiSat.h"
32
33 extern TelSatEventDownloadType_t g_event_list[TAPI_SAT_EVENT_LIST_MAX_COUNT];
34
35 static GVariant* _tapi_sat_gen_app_exec_result_data(TelSatAppsRetInfo_t *result_info)
36 {
37         GVariant *result = NULL;
38
39         switch(result_info->commandType)
40         {
41                 case TAPI_SAT_CMD_TYPE_SETUP_MENU:{
42                         gint exec_result;
43                         dbg("setup menu : result format (i)");
44
45                         exec_result = result_info->appsRet.setupMenu.resp;
46                         result = g_variant_new("(i)", exec_result);
47                 } break;
48                 case TAPI_SAT_CMD_TYPE_REFRESH:{
49                         gint app_type, exec_result;
50                         dbg("refresh : result format (ii)");
51
52                         app_type = result_info->appsRet.refresh.appType;
53                         exec_result = result_info->appsRet.refresh.resp;
54                         result = g_variant_new("(ii)", app_type, exec_result);
55                 } break;
56                 case TAPI_SAT_CMD_TYPE_SETUP_CALL:{
57                         gint exec_result, me_problem, call_ctrl_problem, call_cause;
58                         dbg("setup call : result format (iiii)");
59
60                         exec_result = result_info->appsRet.setupCall.resp;
61                         me_problem = result_info->appsRet.setupCall.meProblem;
62                         call_ctrl_problem = result_info->appsRet.setupCall.permanentCallCtrlProblem;
63                         call_cause = result_info->appsRet.setupCall.tapiCause;
64                         result = g_variant_new("(iiii)", exec_result, me_problem, call_ctrl_problem, call_cause);
65                 } break;
66                 case TAPI_SAT_CMD_TYPE_SEND_SS:{
67                         int ss_index;
68                         gint exec_result, me_problem, ss_cause, call_ctrl_problem, ss_str_len;
69                         GVariantBuilder builder;
70                         GVariant *ss_str = NULL;
71                         dbg("send ss : result format (iiivii)");
72
73                         exec_result = result_info->appsRet.sendSs.resp;
74                         me_problem = result_info->appsRet.sendSs.meProblem;
75                         ss_cause = result_info->appsRet.sendSs.ssCause;
76                         call_ctrl_problem = result_info->appsRet.sendSs.additionalCallCtrlProblemInfo;
77                         ss_str_len = result_info->appsRet.sendSs.ssString.stringLen;
78
79                         g_variant_builder_init(&builder, G_VARIANT_TYPE ("ay"));
80                         for (ss_index = 0; ss_index < ss_str_len; ss_index++) {
81                                 dbg("index(%d) data(%d)", ss_index, result_info->appsRet.sendSs.ssString.string[ss_index]);
82                                 g_variant_builder_add(&builder, "y", result_info->appsRet.sendSs.ssString.string[ss_index]);
83                         }
84                         ss_str = g_variant_builder_end(&builder);
85
86                         result = g_variant_new("(iiivii)", exec_result, me_problem, ss_cause, ss_str, ss_str_len, call_ctrl_problem);
87                 } break;
88                 case TAPI_SAT_CMD_TYPE_SEND_USSD:{
89                         int ussd_index;
90                         gint exec_result, me_problem, ss_cause, ussd_str_len;
91                         GVariantBuilder builder;
92                         GVariant *ussd_str = NULL;
93
94                         dbg("send ussd : result format (iiivi)");
95
96                         exec_result = result_info->appsRet.sendUssd.resp;
97                         me_problem = result_info->appsRet.sendUssd.meProblem;
98                         ss_cause = result_info->appsRet.sendUssd.ssCause;
99                         ussd_str_len = result_info->appsRet.sendUssd.ussdString.stringLen;
100
101                         g_variant_builder_init(&builder, G_VARIANT_TYPE ("ay"));
102                         for (ussd_index = 0; ussd_index < ussd_str_len; ussd_index++) {
103                                 dbg("index(%d) data(%d)", ussd_index, result_info->appsRet.sendUssd.ussdString.string[ussd_index]);
104                                 g_variant_builder_add(&builder, "y", result_info->appsRet.sendUssd.ussdString.string[ussd_index]);
105                         }
106                         ussd_str = g_variant_builder_end(&builder);
107
108                         result = g_variant_new("(iiivi)", exec_result, me_problem, ss_cause, ussd_str, ussd_str_len);
109                 } break;
110                 case TAPI_SAT_CMD_TYPE_SEND_SMS:{
111                         gint exec_result;
112                         dbg("send sms: result format (i)");
113
114                         exec_result = result_info->appsRet.sendSms.resp;
115                         result = g_variant_new("(i)", exec_result);
116                 } break;
117                 case TAPI_SAT_CMD_TYPE_SEND_DTMF:{
118                         gint exec_result;
119                         dbg("send DTMF: result format (i)");
120
121                         exec_result = result_info->appsRet.sendDtmf.resp;
122                         result = g_variant_new("(i)", exec_result);
123                 } break;
124                 case TAPI_SAT_CMD_TYPE_LAUNCH_BROWSER:{
125                         gint exec_result, browser_problem;
126                         dbg("launch browser: result format (ii)");
127
128                         exec_result = result_info->appsRet.launchBrowser.resp;
129                         browser_problem = result_info->appsRet.launchBrowser.browserProblem;
130                         result = g_variant_new("(ii)", exec_result, browser_problem);
131                 } break;
132                 case TAPI_SAT_CMD_TYPE_SETUP_IDLE_MODE_TEXT:{
133                         gint exec_result;
134                         dbg("setup idle mode text: result format (i)");
135
136                         exec_result = result_info->appsRet.setupIdleModeText.resp;
137                         result = g_variant_new("(i)", exec_result);
138                 } break;
139                 case TAPI_SAT_CMD_TYPE_LANGUAGE_NOTIFICATION:{
140                         gint exec_result;
141                         dbg("language notification: result format (i)");
142
143                         exec_result = result_info->appsRet.languageNoti.resp;
144                         result = g_variant_new("(i)", exec_result);
145                 } break;
146                 case TAPI_SAT_CMD_TYPE_PROVIDE_LOCAL_INFO:{
147                         gint exec_result;
148                         dbg("provide local info: result format (i)");
149
150                         exec_result = result_info->appsRet.provideLocalInfo.resp;
151                         result = g_variant_new("(i)", exec_result);
152                 } break;
153                 case TAPI_SAT_CMD_TYPE_PLAY_TONE:{
154                         gint exec_result;
155                         dbg("play tone: result format (i)");
156
157                         exec_result = result_info->appsRet.playTone.resp;
158                         result = g_variant_new("(i)", exec_result);
159                 } break;
160                 case TAPI_SAT_CMD_TYPE_DISPLAY_TEXT:{
161                         gint exec_result, me_problem;
162                         dbg("display text: result format (ii)");
163
164                         exec_result = result_info->appsRet.displayText.resp;
165                         me_problem = result_info->appsRet.displayText.meProblem;
166                         result = g_variant_new("(ii)", exec_result, me_problem);
167                 } break;
168                 default:
169                         dbg("unhandled command type(0x%x", result_info->commandType);
170                         result = g_variant_new("()");
171                         break;
172         }
173
174         return result;
175 }
176
177 static GVariant* _tapi_sat_gen_event_download_data(const TelSatEventDownloadReqInfo_t *pEventData)
178 {
179         GVariant *result = NULL;
180
181         switch(pEventData->eventDownloadType)
182         {
183                 case TAPI_EVENT_SAT_DW_TYPE_IDLE_SCREEN_AVAILABLE:{
184                         gboolean idle_screen;
185                         dbg("idle screen available (%d)", pEventData->u.bIdleScreenAvailable);
186
187                         idle_screen = pEventData->u.bIdleScreenAvailable;
188                         result = g_variant_new("(b)", idle_screen);
189                 } break;
190                 case TAPI_EVENT_SAT_DW_TYPE_LANGUAGE_SELECTION:{
191                         gint selected_language;
192                         dbg("selected language (%d)", pEventData->u.languageSelectionEventReqInfo.language);
193
194                         selected_language = pEventData->u.languageSelectionEventReqInfo.language;
195                         result = g_variant_new("(i)", selected_language);
196                 } break;
197                 case TAPI_EVENT_SAT_DW_TYPE_BROWSER_TERMINATION:{
198                         gint browser_termination_cause;
199                         dbg("Cause of browser termination (%d)", pEventData->u.browserTerminationEventReqInfo.browserTerminationCause);
200
201                         browser_termination_cause = pEventData->u.browserTerminationEventReqInfo.browserTerminationCause;
202                         result = g_variant_new("(i)", browser_termination_cause);
203                 } break;
204                 case TAPI_EVENT_SAT_DW_TYPE_DATA_AVAILABLE:
205                 case TAPI_EVENT_SAT_DW_TYPE_CHANNEL_STATUS:
206                 default :
207                         dbg("not support download event (%d)", pEventData->eventDownloadType);
208                         result = g_variant_new("()");
209                         break;
210         }
211
212         return result;
213 }
214
215 static void on_response_menu_selection_envelop(GObject *source_object, GAsyncResult *res, gpointer user_data)
216 {
217         GError *error = NULL;
218         GDBusConnection *conn = NULL;
219
220         GVariant *dbus_result;
221         struct tapi_resp_data *evt_cb_data = user_data;
222
223         int result = -1;
224         int envelop_rsp = 0;
225
226         conn = G_DBUS_CONNECTION (source_object);
227         dbus_result = g_dbus_connection_call_finish(conn, res, &error);
228         CHECK_ERROR(error);
229
230         g_variant_get (dbus_result, "(ii)", &result, &envelop_rsp);
231         dbg("menu selection envelop result(%d) envelop response(%d)", result, envelop_rsp);
232
233         if (evt_cb_data->cb_fn) {
234                 evt_cb_data->cb_fn(evt_cb_data->handle, result, &envelop_rsp, evt_cb_data->user_data);
235         }
236
237         g_variant_unref(dbus_result);
238         g_free(evt_cb_data);
239 }
240
241 static void on_response_download_event_envelop(GObject *source_object, GAsyncResult *res, gpointer user_data)
242 {
243         GError *error = NULL;
244         GDBusConnection *conn = NULL;
245
246         GVariant *dbus_result;
247         struct tapi_resp_data *evt_cb_data = user_data;
248
249         int result = -1;
250         int envelop_rsp = 0;
251
252         conn = G_DBUS_CONNECTION (source_object);
253         dbus_result = g_dbus_connection_call_finish(conn, res, &error);
254         CHECK_ERROR(error);
255
256         g_variant_get (dbus_result, "(ii)", &result, &envelop_rsp);
257         dbg("download event envelop result(%d) envelop response(%d)", result, envelop_rsp);
258
259         if (evt_cb_data->cb_fn) {
260                 evt_cb_data->cb_fn(evt_cb_data->handle, result, &envelop_rsp, evt_cb_data->user_data);
261         }
262
263         g_variant_unref(dbus_result);
264         g_free(evt_cb_data);
265 }
266
267 /**
268  *
269  * To send envelope command (MENU SELECTION) to USIM.
270  *
271  * @return              values in enum TapiResult_t.
272  * @param[in]           TelSatMenuSelectionReqInfo_t    menu selection evelope data.
273  * @Interface           Asynchronous.
274  * @remark
275  * @Refer               TelSatMenuSelectionReqInfo_t
276  */
277
278 EXPORT_API int tel_select_sat_menu(TapiHandle *handle, const TelSatMenuSelectionReqInfo_t *pMenuSelect, tapi_response_cb callback, void *user_data)
279 {
280         gint item_id;
281         gboolean help_req;
282         GVariant *inparam = NULL;
283         struct tapi_resp_data *evt_cb_data = NULL;
284
285         dbg("Func Entrance ");
286
287         TAPI_RET_ERR_NUM_IF_FAIL(handle, TAPI_API_INVALID_PTR);
288         TAPI_RET_ERR_NUM_IF_FAIL(handle->dbus_connection, TAPI_API_INVALID_PTR);
289         TAPI_RET_ERR_NUM_IF_FAIL(pMenuSelect, TAPI_API_INVALID_PTR);
290
291         MAKE_RESP_CB_DATA(evt_cb_data, handle, callback, user_data);
292
293         item_id = pMenuSelect->itemIdentifier;
294         help_req = ( (pMenuSelect->bIsHelpRequested != 0) ? TRUE : FALSE);
295         dbg("item id(%d) help request(%d)", item_id, help_req);
296         inparam = g_variant_new("(ib)", item_id, help_req);
297
298         g_dbus_connection_call(handle->dbus_connection, DBUS_TELEPHONY_SERVICE, handle->path,
299                         DBUS_TELEPHONY_SAT_INTERFACE, "SelectMenu", inparam, NULL, G_DBUS_CALL_FLAGS_NONE, TAPI_DEFAULT_TIMEOUT,
300                         handle->ca, on_response_menu_selection_envelop, evt_cb_data);
301
302         g_variant_unref(inparam);
303
304         return TAPI_API_SUCCESS;
305 }
306
307 /**
308  *
309  * API to send event download to SIM.
310  *
311  * @return              values in enum TapiResult_t.
312  * @param[in]           TelSatEventDownloadReqInfo_t    event download data.
313  * @Interface           Asynchronous.
314  * @remark
315  * @Refer               TelSatEventDownloadReqInfo_t
316  */
317 EXPORT_API int tel_download_sat_event(TapiHandle *handle, const TelSatEventDownloadReqInfo_t *pEventData, tapi_response_cb callback, void *user_data)
318 {
319         gboolean evt_check = FALSE;
320         int g_index = 0;
321         gint event_download_type, src_dev, dest_dev;
322         GVariant *download_data = NULL;
323
324         GVariant *inparam = NULL;
325         struct tapi_resp_data *evt_cb_data = NULL;
326
327         dbg("Func Entrance ");
328
329         TAPI_RET_ERR_NUM_IF_FAIL(handle, TAPI_API_INVALID_PTR);
330         TAPI_RET_ERR_NUM_IF_FAIL(handle->dbus_connection, TAPI_API_INVALID_PTR);
331         TAPI_RET_ERR_NUM_IF_FAIL(pEventData, TAPI_API_INVALID_PTR);
332
333         for(g_index = 0; g_event_list[g_index] > 0; g_index++){
334                 if(pEventData->eventDownloadType == TAPI_EVENT_SAT_DW_TYPE_BROWSER_TERMINATION || g_event_list[g_index] == pEventData->eventDownloadType ){
335                         dbg("event (%d) shoud be passed to sim");
336                         evt_check = TRUE;
337                 }
338         }
339
340         if(!evt_check){
341                 dbg("sim does not request event(%d)", pEventData->eventDownloadType);
342                 return TAPI_API_SAT_EVENT_NOT_REQUIRED_BY_USIM;
343         }
344
345         MAKE_RESP_CB_DATA(evt_cb_data, handle, callback, user_data);
346
347         event_download_type = pEventData->eventDownloadType;
348         src_dev = TAPI_SAT_DEVICE_ID_ME;
349         dest_dev = TAPI_SAT_DEVICE_ID_SIM;
350         download_data = _tapi_sat_gen_event_download_data(pEventData);
351         TAPI_RET_ERR_NUM_IF_FAIL(download_data, TAPI_API_INVALID_PTR);
352
353         dbg("event type(%d)", event_download_type);
354         inparam = g_variant_new("(iiiv)", event_download_type, src_dev, dest_dev, download_data);
355
356         g_dbus_connection_call(handle->dbus_connection, DBUS_TELEPHONY_SERVICE, handle->path,
357                         DBUS_TELEPHONY_SAT_INTERFACE, "DownloadEvent", inparam, NULL, G_DBUS_CALL_FLAGS_NONE, TAPI_DEFAULT_TIMEOUT,
358                         handle->ca, on_response_download_event_envelop, evt_cb_data);
359
360         g_variant_unref(inparam);
361
362         return TAPI_API_SUCCESS;
363 }
364
365 /**
366  *
367  * API to get main menu information.
368  *
369  * @return              values in enum TapiResult_t.
370  * @param[out]          TelSatSetupMenuInfo_t   main menu data.
371  * @Interface           Synchronous.
372  * @remark
373  * @Refer               TelSatSetupMenuInfo_t
374  */
375 EXPORT_API int tel_get_sat_main_menu_info(TapiHandle *handle, TelSatSetupMenuInfo_t *pMainMenu)
376 {
377         GError *error;
378         GVariant *rst = NULL;
379
380         gchar *title;
381         gint result, command_id, item_cnt;
382         gboolean b_present, b_helpinfo, b_updated;
383         GVariant *items = NULL;
384 #if defined(TIZEN_SUPPORT_SAT_ICON)
385         GVariant *icon_id = NULL;
386         GVariant *icon_list = NULL;
387         int sat_index = 0, icon_index = 0;
388         /* Used to get icon data */
389         GVariant *unbox;
390         gboolean is_exist;
391         gint icon_quali, icon_identifier, width, height, ics, icon_data_len;
392         gchar *icon_data = NULL;
393         /* Used to get icon list data */
394         GVariant *unbox_list, *unbox_list_info ;
395         GVariantIter *iter, *iter2;
396         GVariant *icon_list_info;
397         gboolean is_list_exist;
398         gint icon_list_quali, list_cnt, icon_list_identifier, list_width, list_height, list_ics, icon_list_data_len;
399         gchar *icon_list_data = NULL;
400 #else
401         int sat_index = 0;
402 #endif
403         dbg("Func Entrance ");
404
405         TAPI_RET_ERR_NUM_IF_FAIL(handle, TAPI_API_INVALID_PTR);
406         TAPI_RET_ERR_NUM_IF_FAIL(handle->dbus_connection, TAPI_API_INVALID_PTR);
407         TAPI_RET_ERR_NUM_IF_FAIL(pMainMenu, TAPI_API_INVALID_PTR);
408
409         memset(pMainMenu, 0, sizeof(TelSatSetupMenuInfo_t));
410
411         error = NULL;
412         rst = g_dbus_connection_call_sync(handle->dbus_connection, DBUS_TELEPHONY_SERVICE , handle->path,
413                         DBUS_TELEPHONY_SAT_INTERFACE, "GetMainMenuInfo", NULL, NULL, G_DBUS_CALL_FLAGS_NONE, TAPI_DEFAULT_TIMEOUT, handle->ca, &error);
414
415         if(!rst){
416                 dbg( "error to get main menu(%s)", error->message);
417                 g_error_free (error);
418                 return TAPI_API_OPERATION_FAILED;
419         }
420
421         dbg("menu_info type_format(%s)", g_variant_get_type_string(rst));
422
423 #if defined(TIZEN_SUPPORT_SAT_ICON)
424         g_variant_get(rst, "(iibs@vibb@v@v)", &result, &command_id, &b_present, &title, &items, &item_cnt,
425                         &b_helpinfo, &b_updated, &icon_id, &icon_list);
426 #else
427         g_variant_get(rst, "(iibs@vibb)", &result, &command_id, &b_present, &title, &items, &item_cnt,
428                         &b_helpinfo, &b_updated);
429 #endif
430         g_variant_unref(rst);
431
432         pMainMenu->commandId = command_id;
433         pMainMenu->bIsMainMenuPresent = (b_present ? 1 : 0);
434
435         if(strlen(title) > TAPI_SAT_DEF_TITLE_LEN_MAX+1){
436                 memcpy(pMainMenu->satMainTitle, title, TAPI_SAT_DEF_TITLE_LEN_MAX+1);
437         }
438         else{
439                 memcpy(pMainMenu->satMainTitle, title, strlen(title));
440         }
441         g_free(title);
442
443         pMainMenu->satMainMenuNum = item_cnt;
444         if(items && item_cnt > 0){
445                 GVariant *unbox;
446                 GVariantIter *iter;
447
448                 gchar *item_str;
449                 gint item_id;
450                 unbox = g_variant_get_variant(items);
451                 dbg("items(%p) items type_format(%s)", items, g_variant_get_type_string(unbox));
452
453                 g_variant_get(unbox, "a(si)", &iter);
454                 while(g_variant_iter_loop(iter,"(si)",&item_str, &item_id)){
455                         pMainMenu->satMainMenuItem[sat_index].itemId = item_id;
456
457                         if(strlen(item_str) > TAPI_SAT_DEF_ITEM_STR_LEN_MAX + 6){
458                                 memcpy(pMainMenu->satMainMenuItem[sat_index].itemString, item_str, TAPI_SAT_DEF_ITEM_STR_LEN_MAX + 6);
459                         }
460                         else{
461                                 memcpy(pMainMenu->satMainMenuItem[sat_index].itemString, item_str, strlen(item_str));
462                         }
463
464                         dbg("item index(%d) id(%d) str(%s)",sat_index, pMainMenu->satMainMenuItem[sat_index].itemId, pMainMenu->satMainMenuItem[sat_index].itemString);
465                         //dbg("item index(%d) id(%d) str(%s)",index, item_id, item_str);
466                         sat_index++;
467                 }
468                 g_variant_iter_free(iter);
469         }
470         pMainMenu->bIsSatMainMenuHelpInfo = (b_helpinfo ? 1 : 0);
471         pMainMenu->bIsUpdatedSatMainMenu = (b_updated ? 1 : 0);
472
473 #if defined(TIZEN_SUPPORT_SAT_ICON)
474         if(icon_id) {
475                 unbox = g_variant_get_variant(icon_id);
476                 g_variant_get(unbox, "a(biiiiiis)", &iter);
477
478                 while(g_variant_iter_loop(iter,"(biiiiiis)", &is_exist, &icon_quali, &icon_identifier, &width, &height, &ics, &icon_data_len, &icon_data)){
479                         if(!is_exist)
480                                 break;
481                         pMainMenu->iconId.bIsPresent = is_exist;
482                         pMainMenu->iconId.iconQualifier = icon_quali;
483                         pMainMenu->iconId.iconIdentifier = icon_identifier;
484                         pMainMenu->iconId.iconInfo.width = width;
485                         pMainMenu->iconId.iconInfo.height = height;
486                         pMainMenu->iconId.iconInfo.ics = ics;
487                         if(icon_data_len > 0) {
488                                 pMainMenu->iconId.iconInfo.iconDataLen = icon_data_len;
489                                 memcpy(pMainMenu->iconId.iconInfo.iconFile, icon_data, icon_data_len);
490                         }
491                         dbg("icon exist(%d), icon_quali: (%d), icon_id: (%d), width: (%d), height: (%d), ics: (%d), icon_data_len: (%d)", pMainMenu->iconId.bIsPresent, pMainMenu->iconId.iconQualifier, pMainMenu->iconId.iconIdentifier, pMainMenu->iconId.iconInfo.width,
492                                 pMainMenu->iconId.iconInfo.height, pMainMenu->iconId.iconInfo.ics, pMainMenu->iconId.iconInfo.iconDataLen);
493                 }
494                 g_variant_iter_free(iter);
495         }
496
497         if(icon_list){
498                 unbox_list = g_variant_get_variant(icon_list);
499                 g_variant_get(unbox_list, "a(biiv)", &iter);
500
501                 while(g_variant_iter_loop(iter,"(biiv)", &is_list_exist, &icon_list_quali, &list_cnt, &icon_list_info)){
502                         if(!is_list_exist)
503                                 break;
504                         pMainMenu->iconIdList.bIsPresent = is_list_exist;
505                         pMainMenu->iconIdList.iconListQualifier = icon_list_quali;
506                         pMainMenu->iconIdList.iconCount = list_cnt;
507
508                         unbox_list_info = g_variant_get_variant(icon_list_info);
509                         g_variant_get(unbox_list_info, "a(iiiiis)", &iter2);
510
511                         while(g_variant_iter_loop(iter2,"(iiiiis)",&icon_list_identifier, &list_width, &list_height, &list_ics, &icon_list_data_len, &icon_list_data)){
512                                 pMainMenu->iconIdList.iconIdentifierList[icon_index]= icon_identifier;
513                                 pMainMenu->iconIdList.iconInfo[icon_index].width = list_width;
514                                 pMainMenu->iconIdList.iconInfo[icon_index].height = list_height;
515                                 pMainMenu->iconIdList.iconInfo[icon_index].ics = list_ics;
516                                 if(icon_list_data_len > 0) {
517                                         pMainMenu->iconIdList.iconInfo[icon_index].iconDataLen = icon_list_data_len;
518                                         memcpy(pMainMenu->iconIdList.iconInfo[icon_index].iconFile, icon_list_data, icon_list_data_len);
519                                 }
520                                 icon_index++;
521                         }
522                         g_variant_iter_free(iter2);
523                 }
524                 g_variant_iter_free(iter);
525         }
526 #endif
527         dbg("result (%d)", result);
528         dbg("command id (%d)", pMainMenu->commandId);
529         dbg("menu present (%d)", pMainMenu->bIsMainMenuPresent);
530         dbg("menu title (%s)", pMainMenu->satMainTitle);
531         dbg("item cnt (%d)", pMainMenu->satMainMenuNum);
532         dbg("menu help info (%d)", pMainMenu->bIsSatMainMenuHelpInfo);
533         dbg("menu updated (%d)", pMainMenu->bIsUpdatedSatMainMenu);
534
535         return TAPI_API_SUCCESS;
536 }
537
538 /**
539  *
540  * API to send UI display status.
541  *
542  * @return              values in enum TapiResult_t.
543  * @param[in]           TelSatUiDisplayStatusType_t     display status data.
544  command_id     command identifier
545  * @Interface           Asynchronous.
546  * @remark
547  * @Refer               TelSatUiDisplayStatusType_t
548  */
549 EXPORT_API int tel_send_sat_ui_display_status(TapiHandle *handle, int commandId, TelSatUiDisplayStatusType_t status)
550 {
551         GError *error;
552         GVariant *rst = NULL;
553
554         gint result, command_id;
555         gboolean display_status;
556         GVariant *inparam = NULL;
557
558         dbg("Func Entrance ");
559
560         TAPI_RET_ERR_NUM_IF_FAIL(handle, TAPI_API_INVALID_PTR);
561         TAPI_RET_ERR_NUM_IF_FAIL(handle->dbus_connection, TAPI_API_INVALID_PTR);
562
563         command_id = commandId;
564         display_status = ( (status == TAPI_SAT_DISPLAY_SUCCESS) ? TRUE : FALSE);
565         dbg("command id(%d) display status(%d)", command_id, display_status);
566         inparam = g_variant_new("(ib)", command_id, display_status);
567
568         error = NULL;
569         rst = g_dbus_connection_call_sync(handle->dbus_connection, DBUS_TELEPHONY_SERVICE , handle->path,
570                         DBUS_TELEPHONY_SAT_INTERFACE, "SendUiDisplayStatus", inparam, NULL, G_DBUS_CALL_FLAGS_NONE, TAPI_DEFAULT_TIMEOUT, handle->ca, &error);
571
572         if(!rst){
573                 dbg( "error to send ui display status(%s)", error->message);
574                 g_error_free (error);
575                 return TAPI_API_OPERATION_FAILED;
576         }
577
578         dbg("send ui display status format(%s)", g_variant_get_type_string(rst));
579
580         g_variant_get(rst, "(i)", &result);
581         if(result){
582                 result = TAPI_API_SUCCESS;
583         }
584         else{
585                 result = TAPI_API_OPERATION_FAILED;
586         }
587         g_variant_unref(rst);
588         dbg("result (%d)", result);
589
590         return result;
591 }
592
593 /**
594  *
595  * API to send UI user confirmation data.
596  *
597  * @return              values in enum TapiResult_t.
598  * @param[in]           command_id      command identifier
599  command_type           command type
600  key_type                       user confirmation value
601  addtional_data         addtional data
602  data_len                       data length
603  * @Interface           Asynchronous.
604  * @remark
605  * @Refer
606  */
607 EXPORT_API int tel_send_sat_ui_user_confirm(TapiHandle *handle, TelSatUiUserConfirmInfo_t *pUserConfirmData)
608 {
609         GError *error;
610         GVariant *rst = NULL;
611         GVariantBuilder builder;
612         GVariant *inner_gv = NULL;
613
614         int sat_index = 0;
615         gchar *data;
616         gint result, command_id, command_type, key_type, data_len;
617         GVariant *inparam = NULL;
618
619         dbg("Func Entrance ");
620
621         TAPI_RET_ERR_NUM_IF_FAIL(handle, TAPI_API_INVALID_PTR);
622         TAPI_RET_ERR_NUM_IF_FAIL(handle->dbus_connection, TAPI_API_INVALID_PTR);
623         TAPI_RET_ERR_NUM_IF_FAIL(pUserConfirmData, TAPI_API_INVALID_PTR);
624
625         command_id = pUserConfirmData->commandId;
626         command_type = pUserConfirmData->commandType;
627         key_type = pUserConfirmData->keyType;
628         data = (gchar *)pUserConfirmData->pAdditionalData;
629         data_len = pUserConfirmData->dataLen;
630
631         g_variant_builder_init(&builder, G_VARIANT_TYPE ("ay"));
632         for (sat_index = 0; sat_index < data_len; sat_index++) {
633                 dbg("index(%d) data(%d)", sat_index, data[sat_index]);
634                 g_variant_builder_add(&builder, "y", data[sat_index]);
635         }
636         inner_gv = g_variant_builder_end(&builder);
637
638         dbg("command id(%d) command type(%d) key type(%d) data len(%d)",
639                         command_id, command_type, key_type, data_len);
640         inparam = g_variant_new("(iiiv)", command_id, command_type, key_type, inner_gv);
641
642         error = NULL;
643         rst = g_dbus_connection_call_sync(handle->dbus_connection, DBUS_TELEPHONY_SERVICE , handle->path,
644                         DBUS_TELEPHONY_SAT_INTERFACE, "SendUserConfirm", inparam, NULL, G_DBUS_CALL_FLAGS_NONE, TAPI_DEFAULT_TIMEOUT, handle->ca, &error);
645
646         if(!rst){
647                 dbg( "error to send ui user confirm(%s)", error->message);
648                 g_error_free (error);
649                 return TAPI_API_OPERATION_FAILED;
650         }
651
652         dbg("send ui user confirm format(%s)", g_variant_get_type_string(rst));
653
654         g_variant_get(rst, "(i)", &result);
655         if(result){
656                 result = TAPI_API_SUCCESS;
657         }
658         else{
659                 result = TAPI_API_OPERATION_FAILED;
660         }
661         g_variant_unref(rst);
662         dbg("result (%d)", result);
663
664         return result;
665 }
666
667 /**
668  *
669  * API to send application excution result.
670  *
671  * @return              values in enum TapiResult_t.
672  * @param[in]           TelSatAppsRetInfo_t     application result information data.
673  * @Interface           Asynchronous.
674  * @remark
675  * @Refer               TelSatAppsRetInfo_t
676  */
677 EXPORT_API int tel_send_sat_app_exec_result(TapiHandle *handle, TelSatAppsRetInfo_t *pAppRetInfo)
678 {
679         GError *error;
680         GVariant *rst = NULL;
681
682         gint result, command_id, command_type;
683         GVariant *app_exec_result = NULL;
684         GVariant *inparam = NULL;
685
686         dbg("Func Entrance ");
687
688         TAPI_RET_ERR_NUM_IF_FAIL(handle, TAPI_API_INVALID_PTR);
689         TAPI_RET_ERR_NUM_IF_FAIL(handle->dbus_connection, TAPI_API_INVALID_PTR);
690         TAPI_RET_ERR_NUM_IF_FAIL(pAppRetInfo, TAPI_API_INVALID_PTR);
691
692         command_id = pAppRetInfo->commandId;
693         command_type = pAppRetInfo->commandType;
694         app_exec_result = _tapi_sat_gen_app_exec_result_data(pAppRetInfo);
695         TAPI_RET_ERR_NUM_IF_FAIL(app_exec_result, TAPI_API_INVALID_PTR);
696
697         dbg("command id(%d) command type(%d) exec_result(%s)", command_id, command_type, g_variant_get_type_string(app_exec_result));
698         inparam = g_variant_new("(iiv)", command_id, command_type, app_exec_result);
699
700         error = NULL;
701         dbg("test (%s)", g_variant_get_type_string(inparam));
702         rst = g_dbus_connection_call_sync(handle->dbus_connection, DBUS_TELEPHONY_SERVICE , handle->path,
703                         DBUS_TELEPHONY_SAT_INTERFACE, "SendAppExecResult", inparam, NULL, G_DBUS_CALL_FLAGS_NONE, TAPI_DEFAULT_TIMEOUT, handle->ca, &error);
704
705         if(!rst){
706                 dbg( "error to send app execution result(%s)", error->message);
707                 g_error_free (error);
708                 return TAPI_API_OPERATION_FAILED;
709         }
710
711         dbg("send app execution result format(%s)", g_variant_get_type_string(rst));
712
713         g_variant_get(rst, "(i)", &result);
714         if(result){
715                 result = TAPI_API_SUCCESS;
716         }
717         else{
718                 result = TAPI_API_OPERATION_FAILED;
719         }
720         g_variant_unref(rst);
721         dbg("result (%d)", result);
722
723         return result;
724 }