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