4c45936deda36914093dab5cb0a66e2d0d175560
[framework/telephony/libslp-tapi.git] / wearable / src / tapi_sat.c
1 /*
2  * libslp-tapi
3  *
4  * Copyright (c) 2012 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 index;
68                         gint exec_result, me_problem, ss_cause, call_ctrl_problem, ss_str_len;
69                         GVariantBuilder *builder = NULL;
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                         builder = g_variant_builder_new(G_VARIANT_TYPE ("ay"));
80                         for (index = 0; index < ss_str_len; index++) {
81                                 dbg("index(%d) data(%d)", index, result_info->appsRet.sendSs.ssString.string[index]);
82                                 g_variant_builder_add(builder, "y", result_info->appsRet.sendSs.ssString.string[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 index;
90                         gint exec_result, me_problem, ss_cause, ussd_str_len;
91                         GVariantBuilder *builder = NULL;
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                         builder = g_variant_builder_new(G_VARIANT_TYPE ("ay"));
102                         for (index = 0; index < ussd_str_len; index++) {
103                                 dbg("index(%d) data(%d)", index, result_info->appsRet.sendUssd.ussdString.string[index]);
104                                 g_variant_builder_add(builder, "y", result_info->appsRet.sendUssd.ussdString.string[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 *rst;
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         rst = g_dbus_connection_call_finish(conn, res, &error);
228         CHECK_DEINIT(error);
229
230         if(!rst){
231                 evt_cb_data->cb_fn(evt_cb_data->handle, result, &envelop_rsp, evt_cb_data->user_data);
232
233                 g_error_free (error);
234                 g_free(evt_cb_data);
235                 return;
236         }
237
238         g_variant_get (rst, "(ii)", &result, &envelop_rsp);
239         dbg("menu selection envelop result(%d) envelop response(%d)", result, envelop_rsp);
240
241         if (evt_cb_data->cb_fn) {
242                 evt_cb_data->cb_fn(evt_cb_data->handle, result, &envelop_rsp, evt_cb_data->user_data);
243         }
244
245         g_variant_unref(rst);
246         g_free(evt_cb_data);
247 }
248
249 static void on_response_download_event_envelop(GObject *source_object, GAsyncResult *res, gpointer user_data)
250 {
251         GError *error = NULL;
252         GDBusConnection *conn = NULL;
253
254         GVariant *rst;
255         struct tapi_resp_data *evt_cb_data = user_data;
256
257         int result = -1;
258         int envelop_rsp = 0;
259
260         conn = G_DBUS_CONNECTION (source_object);
261         rst = g_dbus_connection_call_finish(conn, res, &error);
262         CHECK_DEINIT(error);
263
264         if(!rst){
265                 evt_cb_data->cb_fn(evt_cb_data->handle, result, &envelop_rsp, evt_cb_data->user_data);
266
267                 g_error_free (error);
268                 g_free(evt_cb_data);
269                 return;
270         }
271
272         g_variant_get (rst, "(ii)", &result, &envelop_rsp);
273         dbg("download event envelop result(%d) envelop response(%d)", result, envelop_rsp);
274
275         if (evt_cb_data->cb_fn) {
276                 evt_cb_data->cb_fn(evt_cb_data->handle, result, &envelop_rsp, evt_cb_data->user_data);
277         }
278
279         g_variant_unref(rst);
280         g_free(evt_cb_data);
281 }
282
283 /**
284  *
285  * To send envelope command (MENU SELECTION) to USIM.
286  *
287  * @return              values in enum TapiResult_t.
288  * @param[in]           TelSatMenuSelectionReqInfo_t    menu selection evelope data.
289  * @Interface           Asynchronous.
290  * @remark
291  * @Refer               TelSatMenuSelectionReqInfo_t
292  */
293
294 EXPORT_API int tel_select_sat_menu(TapiHandle *handle, const TelSatMenuSelectionReqInfo_t *pMenuSelect, tapi_response_cb callback, void *user_data)
295 {
296         gint item_id;
297         gboolean help_req;
298         GVariant *inparam = NULL;
299         struct tapi_resp_data *evt_cb_data = NULL;
300
301         dbg("Func Entrance ");
302
303         TAPI_RET_ERR_NUM_IF_FAIL(handle, TAPI_API_INVALID_PTR);
304         TAPI_RET_ERR_NUM_IF_FAIL(handle->dbus_connection, TAPI_API_INVALID_PTR);
305         TAPI_RET_ERR_NUM_IF_FAIL(pMenuSelect, TAPI_API_INVALID_PTR);
306
307         MAKE_RESP_CB_DATA(evt_cb_data, handle, callback, user_data);
308
309         item_id = pMenuSelect->itemIdentifier;
310         help_req = ( (pMenuSelect->bIsHelpRequested != 0) ? TRUE : FALSE);
311         dbg("item id(%d) help request(%d)", item_id, help_req);
312         inparam = g_variant_new("(ib)", item_id, help_req);
313
314         g_dbus_connection_call(handle->dbus_connection, DBUS_TELEPHONY_SERVICE, handle->path,
315                         DBUS_TELEPHONY_SAT_INTERFACE, "SelectMenu", inparam, NULL, G_DBUS_CALL_FLAGS_NONE, TAPI_DEFAULT_TIMEOUT,
316                         handle->ca, on_response_menu_selection_envelop, evt_cb_data);
317
318         g_variant_unref(inparam);
319
320         return TAPI_API_SUCCESS;
321 }
322
323 /**
324  *
325  * API to send event download to SIM.
326  *
327  * @return              values in enum TapiResult_t.
328  * @param[in]           TelSatEventDownloadReqInfo_t    event download data.
329  * @Interface           Asynchronous.
330  * @remark
331  * @Refer               TelSatEventDownloadReqInfo_t
332  */
333 EXPORT_API int tel_download_sat_event(TapiHandle *handle, const TelSatEventDownloadReqInfo_t *pEventData, tapi_response_cb callback, void *user_data)
334 {
335         gboolean evt_check = FALSE;
336         int g_index = 0;
337         gint event_download_type, src_dev, dest_dev;
338         GVariant *download_data = NULL;
339
340         GVariant *inparam = NULL;
341         struct tapi_resp_data *evt_cb_data = NULL;
342
343         dbg("Func Entrance ");
344
345         TAPI_RET_ERR_NUM_IF_FAIL(handle, TAPI_API_INVALID_PTR);
346         TAPI_RET_ERR_NUM_IF_FAIL(handle->dbus_connection, TAPI_API_INVALID_PTR);
347         TAPI_RET_ERR_NUM_IF_FAIL(pEventData, TAPI_API_INVALID_PTR);
348
349         for(g_index = 0; g_event_list[g_index] > 0; g_index++){
350                 if(pEventData->eventDownloadType == TAPI_EVENT_SAT_DW_TYPE_BROWSER_TERMINATION || g_event_list[g_index] == pEventData->eventDownloadType ){
351                         dbg("event (%d) shoud be passed to sim");
352                         evt_check = TRUE;
353                 }
354         }
355
356         if(!evt_check){
357                 dbg("sim does not request event(%d)", pEventData->eventDownloadType);
358                 return TAPI_API_SAT_EVENT_NOT_REQUIRED_BY_USIM;
359         }
360
361         MAKE_RESP_CB_DATA(evt_cb_data, handle, callback, user_data);
362
363         event_download_type = pEventData->eventDownloadType;
364         src_dev = TAPI_SAT_DEVICE_ID_ME;
365         dest_dev = TAPI_SAT_DEVICE_ID_SIM;
366         download_data = _tapi_sat_gen_event_download_data(pEventData);
367         TAPI_RET_ERR_NUM_IF_FAIL(download_data, TAPI_API_INVALID_PTR);
368
369         dbg("event type(%d)", event_download_type);
370         inparam = g_variant_new("(iiiv)", event_download_type, src_dev, dest_dev, download_data);
371
372         g_dbus_connection_call(handle->dbus_connection, DBUS_TELEPHONY_SERVICE, handle->path,
373                         DBUS_TELEPHONY_SAT_INTERFACE, "DownloadEvent", inparam, NULL, G_DBUS_CALL_FLAGS_NONE, TAPI_DEFAULT_TIMEOUT,
374                         handle->ca, on_response_download_event_envelop, evt_cb_data);
375
376         g_variant_unref(inparam);
377
378         return TAPI_API_SUCCESS;
379 }
380
381 /**
382  *
383  * API to get main menu information.
384  *
385  * @return              values in enum TapiResult_t.
386  * @param[out]          TelSatSetupMenuInfo_t   main menu data.
387  * @Interface           Synchronous.
388  * @remark
389  * @Refer               TelSatSetupMenuInfo_t
390  */
391 EXPORT_API int tel_get_sat_main_menu_info(TapiHandle *handle, TelSatSetupMenuInfo_t *pMainMenu)
392 {
393         GError *error;
394         GVariant *rst = NULL;
395
396         gchar *title;
397         gint result, command_id, item_cnt;
398         gboolean b_present, b_helpinfo, b_updated;
399         GVariant *items = NULL;
400 #if defined(TIZEN_SUPPORT_SAT_ICON)
401         GVariant *icon_id = NULL;
402         GVariant *icon_list = NULL;
403         int index = 0, icon_index = 0;
404         /* Used to get icon data */
405         GVariant *unbox;
406         gboolean is_exist;
407         gint icon_quali, icon_identifier, width, height, ics, icon_data_len;
408         gchar *icon_data = NULL;
409         /* Used to get icon list data */
410         GVariant *unbox_list, *unbox_list_info ;
411         GVariantIter *iter, *iter2;
412         GVariant *icon_list_info;
413         gboolean is_list_exist;
414         gint icon_list_quali, list_cnt, icon_list_identifier, list_width, list_height, list_ics, icon_list_data_len;
415         gchar *icon_list_data = NULL;
416 #else
417         int index = 0;
418 #endif
419         dbg("Func Entrance ");
420
421         TAPI_RET_ERR_NUM_IF_FAIL(handle, TAPI_API_INVALID_PTR);
422         TAPI_RET_ERR_NUM_IF_FAIL(handle->dbus_connection, TAPI_API_INVALID_PTR);
423         TAPI_RET_ERR_NUM_IF_FAIL(pMainMenu, TAPI_API_INVALID_PTR);
424
425         memset(pMainMenu, 0, sizeof(TelSatSetupMenuInfo_t));
426
427         error = NULL;
428         rst = g_dbus_connection_call_sync(handle->dbus_connection, DBUS_TELEPHONY_SERVICE , handle->path,
429                         DBUS_TELEPHONY_SAT_INTERFACE, "GetMainMenuInfo", NULL, NULL, G_DBUS_CALL_FLAGS_NONE, TAPI_DEFAULT_TIMEOUT, handle->ca, &error);
430
431         if(!rst){
432                 dbg( "error to get main menu(%s)", error->message);
433                 g_error_free (error);
434                 return TAPI_API_OPERATION_FAILED;
435         }
436
437         dbg("menu_info type_format(%s)", g_variant_get_type_string(rst));
438
439 #if defined(TIZEN_SUPPORT_SAT_ICON)
440         g_variant_get(rst, "(iibs@vibb@v@v)", &result, &command_id, &b_present, &title, &items, &item_cnt,
441                         &b_helpinfo, &b_updated, &icon_id, &icon_list);
442 #else
443         g_variant_get(rst, "(iibs@vibb)", &result, &command_id, &b_present, &title, &items, &item_cnt,
444                         &b_helpinfo, &b_updated);
445 #endif
446
447         pMainMenu->commandId = command_id;
448         pMainMenu->bIsMainMenuPresent = (b_present ? 1 : 0);
449
450         if(strlen(title) > TAPI_SAT_DEF_TITLE_LEN_MAX+1){
451                 memcpy(pMainMenu->satMainTitle, title, TAPI_SAT_DEF_TITLE_LEN_MAX+1);
452         }
453         else{
454                 memcpy(pMainMenu->satMainTitle, title, strlen(title));
455         }
456
457         pMainMenu->satMainMenuNum = item_cnt;
458         if(items && item_cnt > 0){
459                 GVariant *unbox;
460                 GVariantIter *iter;
461
462                 gchar *item_str;
463                 gint item_id;
464                 unbox = g_variant_get_variant(items);
465                 dbg("items(%p) items type_format(%s)", items, g_variant_get_type_string(unbox));
466
467                 g_variant_get(unbox, "a(si)", &iter);
468                 while(g_variant_iter_loop(iter,"(si)",&item_str, &item_id)){
469                         pMainMenu->satMainMenuItem[index].itemId = item_id;
470
471                         if(strlen(item_str) > TAPI_SAT_DEF_ITEM_STR_LEN_MAX + 6){
472                                 memcpy(pMainMenu->satMainMenuItem[index].itemString, item_str, TAPI_SAT_DEF_ITEM_STR_LEN_MAX + 6);
473                         }
474                         else{
475                                 memcpy(pMainMenu->satMainMenuItem[index].itemString, item_str, strlen(item_str));
476                         }
477
478                         dbg("item index(%d) id(%d) str(%s)",index, pMainMenu->satMainMenuItem[index].itemId, pMainMenu->satMainMenuItem[index].itemString);
479                         //dbg("item index(%d) id(%d) str(%s)",index, item_id, item_str);
480                         index++;
481                 }
482                 g_variant_iter_free(iter);
483         }
484         pMainMenu->bIsSatMainMenuHelpInfo = (b_helpinfo ? 1 : 0);
485         pMainMenu->bIsUpdatedSatMainMenu = (b_updated ? 1 : 0);
486
487 #if defined(TIZEN_SUPPORT_SAT_ICON)
488         if(icon_id) {
489                 unbox = g_variant_get_variant(icon_id);
490                 g_variant_get(unbox, "a(biiiiiis)", &iter);
491
492                 while(g_variant_iter_loop(iter,"(biiiiiis)", &is_exist, &icon_quali, &icon_identifier, &width, &height, &ics, &icon_data_len, &icon_data)){
493                         if(!is_exist)
494                                 break;
495                         pMainMenu->iconId.bIsPresent = is_exist;
496                         pMainMenu->iconId.iconQualifier = icon_quali;
497                         pMainMenu->iconId.iconIdentifier = icon_identifier;
498                         pMainMenu->iconId.iconInfo.width = width;
499                         pMainMenu->iconId.iconInfo.height = height;
500                         pMainMenu->iconId.iconInfo.ics = ics;
501                         if(icon_data_len > 0) {
502                                 pMainMenu->iconId.iconInfo.iconDataLen = icon_data_len;
503                                 memcpy(pMainMenu->iconId.iconInfo.iconFile, icon_data, icon_data_len);
504                         }
505                         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,
506                                 pMainMenu->iconId.iconInfo.height, pMainMenu->iconId.iconInfo.ics, pMainMenu->iconId.iconInfo.iconDataLen);
507                 }
508                 g_variant_iter_free(iter);
509         }
510
511         if(icon_list){
512                 unbox_list = g_variant_get_variant(icon_list);
513                 g_variant_get(unbox_list, "a(biiv)", &iter);
514
515                 while(g_variant_iter_loop(iter,"(biiv)", &is_list_exist, &icon_list_quali, &list_cnt, &icon_list_info)){
516                         if(!is_list_exist)
517                                 break;
518                         pMainMenu->iconIdList.bIsPresent = is_list_exist;
519                         pMainMenu->iconIdList.iconListQualifier = icon_list_quali;
520                         pMainMenu->iconIdList.iconCount = list_cnt;
521
522                         unbox_list_info = g_variant_get_variant(icon_list_info);
523                         g_variant_get(unbox_list_info, "a(iiiiis)", &iter2);
524
525                         while(g_variant_iter_loop(iter2,"(iiiiis)",&icon_list_identifier, &list_width, &list_height, &list_ics, &icon_list_data_len, &icon_list_data)){
526                                 pMainMenu->iconIdList.iconIdentifierList[icon_index]= icon_identifier;
527                                 pMainMenu->iconIdList.iconInfo[icon_index].width = list_width;
528                                 pMainMenu->iconIdList.iconInfo[icon_index].height = list_height;
529                                 pMainMenu->iconIdList.iconInfo[icon_index].ics = list_ics;
530                                 if(icon_list_data_len > 0) {
531                                         pMainMenu->iconIdList.iconInfo[icon_index].iconDataLen = icon_list_data_len;
532                                         memcpy(pMainMenu->iconIdList.iconInfo[icon_index].iconFile, icon_list_data, icon_list_data_len);
533                                 }
534                                 icon_index++;
535                         }
536                         g_variant_iter_free(iter2);
537                 }
538                 g_variant_iter_free(iter);
539         }
540 #endif
541         dbg("result (%d)", result);
542         dbg("command id (%d)", pMainMenu->commandId);
543         dbg("menu present (%d)", pMainMenu->bIsMainMenuPresent);
544         dbg("menu title (%s)", pMainMenu->satMainTitle);
545         dbg("item cnt (%d)", pMainMenu->satMainMenuNum);
546         dbg("menu help info (%d)", pMainMenu->bIsSatMainMenuHelpInfo);
547         dbg("menu updated (%d)", pMainMenu->bIsUpdatedSatMainMenu);
548
549         return TAPI_API_SUCCESS;
550 }
551
552 /**
553  *
554  * API to send UI display status.
555  *
556  * @return              values in enum TapiResult_t.
557  * @param[in]           TelSatUiDisplayStatusType_t     display status data.
558  command_id     command identifier
559  * @Interface           Asynchronous.
560  * @remark
561  * @Refer               TelSatUiDisplayStatusType_t
562  */
563 EXPORT_API int tel_send_sat_ui_display_status(TapiHandle *handle, int commandId, TelSatUiDisplayStatusType_t status)
564 {
565         GError *error;
566         GVariant *rst = NULL;
567
568         gint result, command_id;
569         gboolean display_status;
570         GVariant *inparam = NULL;
571
572         dbg("Func Entrance ");
573
574         TAPI_RET_ERR_NUM_IF_FAIL(handle, TAPI_API_INVALID_PTR);
575         TAPI_RET_ERR_NUM_IF_FAIL(handle->dbus_connection, TAPI_API_INVALID_PTR);
576
577         command_id = commandId;
578         display_status = ( (status == TAPI_SAT_DISPLAY_SUCCESS) ? TRUE : FALSE);
579         dbg("command id(%d) display status(%d)", command_id, display_status);
580         inparam = g_variant_new("(ib)", command_id, display_status);
581
582         error = NULL;
583         rst = g_dbus_connection_call_sync(handle->dbus_connection, DBUS_TELEPHONY_SERVICE , handle->path,
584                         DBUS_TELEPHONY_SAT_INTERFACE, "SendUiDisplayStatus", inparam, NULL, G_DBUS_CALL_FLAGS_NONE, TAPI_DEFAULT_TIMEOUT, handle->ca, &error);
585
586         if(!rst){
587                 dbg( "error to send ui display status(%s)", error->message);
588                 g_error_free (error);
589                 return TAPI_API_OPERATION_FAILED;
590         }
591
592         dbg("send ui display status format(%s)", g_variant_get_type_string(rst));
593
594         g_variant_get(rst, "(i)", &result);
595         if(result){
596                 result = TAPI_API_SUCCESS;
597         }
598         else{
599                 result = TAPI_API_OPERATION_FAILED;
600         }
601         dbg("result (%d)", result);
602
603         return result;
604 }
605
606 /**
607  *
608  * API to send UI user confirmation data.
609  *
610  * @return              values in enum TapiResult_t.
611  * @param[in]           command_id      command identifier
612  command_type           command type
613  key_type                       user confirmation value
614  addtional_data         addtional data
615  data_len                       data length
616  * @Interface           Asynchronous.
617  * @remark
618  * @Refer
619  */
620 EXPORT_API int tel_send_sat_ui_user_confirm(TapiHandle *handle, TelSatUiUserConfirmInfo_t *pUserConfirmData)
621 {
622         GError *error;
623         GVariant *rst = NULL;
624         GVariantBuilder *builder = NULL;
625         GVariant *inner_gv = NULL;
626
627         int index = 0;
628         gchar *data;
629         gint result, command_id, command_type, key_type, data_len;
630         GVariant *inparam = NULL;
631
632         dbg("Func Entrance ");
633
634         TAPI_RET_ERR_NUM_IF_FAIL(handle, TAPI_API_INVALID_PTR);
635         TAPI_RET_ERR_NUM_IF_FAIL(handle->dbus_connection, TAPI_API_INVALID_PTR);
636         TAPI_RET_ERR_NUM_IF_FAIL(pUserConfirmData, TAPI_API_INVALID_PTR);
637
638         command_id = pUserConfirmData->commandId;
639         command_type = pUserConfirmData->commandType;
640         key_type = pUserConfirmData->keyType;
641         data = (gchar *)pUserConfirmData->pAdditionalData;
642         data_len = pUserConfirmData->dataLen;
643
644         builder = g_variant_builder_new(G_VARIANT_TYPE ("ay"));
645         for (index = 0; index < data_len; index++) {
646                 dbg("index(%d) data(%d)", index, data[index]);
647                 g_variant_builder_add(builder, "y", data[index]);
648         }
649         inner_gv = g_variant_builder_end(builder);
650
651         dbg("command id(%d) command type(%d) key type(%d) data len(%d)",
652                         command_id, command_type, key_type, data_len);
653         inparam = g_variant_new("(iiiv)", command_id, command_type, key_type, inner_gv);
654
655         error = NULL;
656         rst = g_dbus_connection_call_sync(handle->dbus_connection, DBUS_TELEPHONY_SERVICE , handle->path,
657                         DBUS_TELEPHONY_SAT_INTERFACE, "SendUserConfirm", inparam, NULL, G_DBUS_CALL_FLAGS_NONE, TAPI_DEFAULT_TIMEOUT, handle->ca, &error);
658
659         if(!rst){
660                 dbg( "error to send ui user confirm(%s)", error->message);
661                 g_error_free (error);
662                 return TAPI_API_OPERATION_FAILED;
663         }
664
665         dbg("send ui user confirm format(%s)", g_variant_get_type_string(rst));
666
667         g_variant_get(rst, "(i)", &result);
668         if(result){
669                 result = TAPI_API_SUCCESS;
670         }
671         else{
672                 result = TAPI_API_OPERATION_FAILED;
673         }
674         dbg("result (%d)", result);
675
676         return result;
677 }
678
679 /**
680  *
681  * API to send application excution result.
682  *
683  * @return              values in enum TapiResult_t.
684  * @param[in]           TelSatAppsRetInfo_t     application result information data.
685  * @Interface           Asynchronous.
686  * @remark
687  * @Refer               TelSatAppsRetInfo_t
688  */
689 EXPORT_API int tel_send_sat_app_exec_result(TapiHandle *handle, TelSatAppsRetInfo_t *pAppRetInfo)
690 {
691         GError *error;
692         GVariant *rst = NULL;
693
694         gint result, command_id, command_type;
695         GVariant *app_exec_result = NULL;
696         GVariant *inparam = NULL;
697
698         dbg("Func Entrance ");
699
700         TAPI_RET_ERR_NUM_IF_FAIL(handle, TAPI_API_INVALID_PTR);
701         TAPI_RET_ERR_NUM_IF_FAIL(handle->dbus_connection, TAPI_API_INVALID_PTR);
702         TAPI_RET_ERR_NUM_IF_FAIL(pAppRetInfo, TAPI_API_INVALID_PTR);
703
704         command_id = pAppRetInfo->commandId;
705         command_type = pAppRetInfo->commandType;
706         app_exec_result = _tapi_sat_gen_app_exec_result_data(pAppRetInfo);
707         TAPI_RET_ERR_NUM_IF_FAIL(app_exec_result, TAPI_API_INVALID_PTR);
708
709         dbg("command id(%d) command type(%d) exec_result(%s)", command_id, command_type, g_variant_get_type_string(app_exec_result));
710         inparam = g_variant_new("(iiv)", command_id, command_type, app_exec_result);
711
712         error = NULL;
713         dbg("test (%s)", g_variant_get_type_string(inparam));
714         rst = g_dbus_connection_call_sync(handle->dbus_connection, DBUS_TELEPHONY_SERVICE , handle->path,
715                         DBUS_TELEPHONY_SAT_INTERFACE, "SendAppExecResult", inparam, NULL, G_DBUS_CALL_FLAGS_NONE, TAPI_DEFAULT_TIMEOUT, handle->ca, &error);
716
717         if(!rst){
718                 dbg( "error to send app execution result(%s)", error->message);
719                 g_error_free (error);
720                 return TAPI_API_OPERATION_FAILED;
721         }
722
723         dbg("send app execution result format(%s)", g_variant_get_type_string(rst));
724
725         g_variant_get(rst, "(i)", &result);
726         if(result){
727                 result = TAPI_API_SUCCESS;
728         }
729         else{
730                 result = TAPI_API_OPERATION_FAILED;
731         }
732         dbg("result (%d)", result);
733
734         return result;
735 }