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