Revert manifest to default one
[profile/ivi/tel-plugin-dbus_tapi.git] / src / sat.c
1 /*
2  * tel-plugin-dbus
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 <string.h>
23 #include <stdlib.h>
24 #include <errno.h>
25 #include <glib-object.h>
26
27 #include <tcore.h>
28 #include <server.h>
29 #include <plugin.h>
30 #include <hal.h>
31 #include <communicator.h>
32 #include <core_object.h>
33 #include <queue.h>
34 #include <user_request.h>
35 #include <util.h>
36 #include <co_sat.h>
37
38 #include "generated-code.h"
39 #include "common.h"
40 #include "sat_manager.h"
41 #include "sat_ui_support/sat_ui_support.h"
42
43 static gboolean on_sat_get_main_menu_info(TelephonySAT *sat, GDBusMethodInvocation *invocation,
44                 gpointer user_data)
45 {
46         struct custom_data *ctx = user_data;
47         GVariant *main_menu = NULL;
48
49         gchar *title;
50         gint result = 1, command_id, item_cnt;
51         gboolean b_present, b_help_info, b_updated;
52         GVariant *items;
53
54
55         if(!ctx->cached_sat_main_menu){
56                 dbg("no main menu");
57                 return FALSE;
58         }
59
60         main_menu = ctx->cached_sat_main_menu;
61
62         g_variant_get(main_menu, "(ibs@vibb)", &command_id, &b_present, &title, &items, &item_cnt,
63                         &b_help_info, &b_updated);
64
65         telephony_sat_complete_get_main_menu_info(sat, invocation, result, command_id, b_present, title,
66                         items, item_cnt, b_help_info, b_updated);
67
68         return TRUE;
69 }
70
71 static gboolean on_sat_send_display_status(TelephonySAT *sat, GDBusMethodInvocation *invocation,
72                 gint arg_command_id, gboolean arg_display_status,
73                 gpointer user_data)
74 {
75         TcorePlugin *plg = NULL;
76         char *plugin_name;
77         struct custom_data *ctx = user_data;
78         gboolean result = FALSE;
79         gint out_param = 1;
80
81         plugin_name = GET_PLUGIN_NAME(invocation);
82         plg = tcore_server_find_plugin(ctx->server, plugin_name);
83         if (!plg){
84                 dbg("there is no valid plugin at this point");
85                 out_param = 0;
86                 telephony_sat_complete_send_ui_display_status(sat, invocation, out_param);
87                 return TRUE;
88         }
89
90         result = sat_manager_handle_ui_display_status(ctx, plg, arg_command_id, arg_display_status);
91         if(!result){
92                 dbg("fail to send exec result");
93         }
94
95         out_param = (result ? 1 : 0);
96         telephony_sat_complete_send_ui_display_status(sat, invocation, out_param);
97         return TRUE;
98 }
99
100 static gboolean on_sat_send_user_confirm(TelephonySAT *sat, GDBusMethodInvocation *invocation,
101                 gint arg_command_id, gint arg_command_type, gint arg_user_confirm_type,
102                 GVariant *arg_additional_data, gpointer user_data)
103 {
104         TcorePlugin *plg = NULL;
105         char *plugin_name;
106         struct custom_data *ctx = user_data;
107
108         gboolean result = FALSE;
109         gint out_param = 1;
110         GVariant *confirm_data = NULL;
111
112         plugin_name = GET_PLUGIN_NAME(invocation);
113         plg = tcore_server_find_plugin(ctx->server, plugin_name);
114         if (!plg){
115                 dbg("there is no valid plugin at this point");
116                 out_param = 0;
117                 telephony_sat_complete_send_user_confirm(sat, invocation, out_param);
118                 return TRUE;
119         }
120
121         confirm_data = g_variant_new("(iiv)", arg_command_id, arg_user_confirm_type, arg_additional_data);
122
123         result = sat_manager_handle_user_confirm(ctx, plg, confirm_data);
124         if(!result){
125                 dbg("fail to send user confirm");
126         }
127
128         out_param = (result ? 1 : 0);
129         telephony_sat_complete_send_user_confirm(sat, invocation, out_param);
130
131         return TRUE;
132 }
133
134 static gboolean on_sat_send_app_exec_result(TelephonySAT *sat, GDBusMethodInvocation *invocation,
135                 gint arg_command_id, gint arg_command_type, GVariant *arg_exec_result,
136                 gpointer user_data)
137 {
138         TcorePlugin *plg = NULL;
139         char *plugin_name;
140         struct custom_data *ctx = user_data;
141
142         gboolean result = FALSE;
143         gint out_param = 1;
144
145         plugin_name = GET_PLUGIN_NAME(invocation);
146         plg = tcore_server_find_plugin(ctx->server, plugin_name);
147         if (!plg){
148                 dbg("there is no valid plugin at this point");
149                 out_param = 0;
150                 telephony_sat_complete_send_app_exec_result(sat, invocation, out_param);
151                 return TRUE;
152         }
153
154         dbg("processing app exec result");
155         result = sat_manager_handle_app_exec_result(ctx, plg, arg_command_id, arg_command_type, arg_exec_result);
156         if(!result){
157                 dbg("fail to send exec result");
158         }
159
160         out_param = (result ? 1 : 0);
161         telephony_sat_complete_send_app_exec_result(sat, invocation, out_param);
162         return TRUE;
163 }
164
165 static gboolean on_sat_select_menu(TelephonySAT *sat, GDBusMethodInvocation *invocation,
166                 guchar arg_item_identifier, gboolean arg_help_request,
167                 gpointer user_data)
168 {
169         struct custom_data *ctx = user_data;
170         UserRequest *ur = NULL;
171
172         struct treq_sat_envelop_cmd_data envelop_data;
173
174         ur = MAKE_UR(ctx, sat, invocation);
175         memset(&envelop_data, 0, sizeof(struct treq_sat_envelop_cmd_data));
176         envelop_data.sub_cmd = ENVELOP_MENU_SELECTION;
177         envelop_data.envelop_data.menu_select.device_identitie.src = DEVICE_ID_KEYPAD;
178         envelop_data.envelop_data.menu_select.device_identitie.dest = DEVICE_ID_SIM;
179         envelop_data.envelop_data.menu_select.item_identifier.item_identifier = arg_item_identifier;
180         envelop_data.envelop_data.menu_select.help_request = arg_help_request;
181
182         tcore_user_request_set_data(ur, sizeof(struct treq_sat_envelop_cmd_data), &envelop_data);
183         tcore_user_request_set_command(ur, TREQ_SAT_REQ_ENVELOPE);
184         tcore_communicator_dispatch_request(ctx->comm, ur);
185
186         return TRUE;
187 }
188
189 static gboolean on_sat_download_event(TelephonySAT *sat, GDBusMethodInvocation *invocation,
190                 gint arg_event_download_type, gint arg_src_device,gint arg_dest_device,
191                 GVariant *arg_download_data, gpointer user_data)
192 {
193         struct custom_data *ctx = user_data;
194         UserRequest *ur = NULL;
195
196         struct treq_sat_envelop_cmd_data envelop_data;
197
198         ur = MAKE_UR(ctx, sat, invocation);
199         memset(&envelop_data, 0, sizeof(struct treq_sat_envelop_cmd_data));
200         envelop_data.sub_cmd = ENVELOP_EVENT_DOWNLOAD;
201         envelop_data.envelop_data.event_download.event = arg_event_download_type;
202         sat_manager_handle_event_download_envelop(arg_event_download_type, arg_src_device, arg_dest_device,
203                         &envelop_data.envelop_data.event_download, arg_download_data);
204
205         tcore_user_request_set_data(ur, sizeof(struct treq_sat_envelop_cmd_data), &envelop_data);
206         tcore_user_request_set_command(ur, TREQ_SAT_REQ_ENVELOPE);
207         tcore_communicator_dispatch_request(ctx->comm, ur);
208
209         return TRUE;
210 }
211
212 gboolean dbus_plugin_setup_sat_interface(TelephonyObjectSkeleton *object, struct custom_data *ctx)
213 {
214         TelephonySAT *sat;
215
216         sat = telephony_sat_skeleton_new();
217         telephony_object_skeleton_set_sat(object, sat);
218         g_object_unref(sat);
219
220         dbg("sat = %p", sat);
221
222         g_signal_connect (sat,
223                         "handle-get-main-menu-info",
224                         G_CALLBACK (on_sat_get_main_menu_info),
225                         ctx);
226
227         g_signal_connect (sat,
228                         "handle-send-ui-display-status",
229                         G_CALLBACK (on_sat_send_display_status),
230                         ctx);
231
232         g_signal_connect (sat,
233                         "handle-send-user-confirm",
234                         G_CALLBACK (on_sat_send_user_confirm),
235                         ctx);
236
237         g_signal_connect (sat,
238                         "handle-send-app-exec-result",
239                         G_CALLBACK (on_sat_send_app_exec_result),
240                         ctx);
241
242         g_signal_connect (sat,
243                         "handle-select-menu",
244                         G_CALLBACK (on_sat_select_menu),
245                         ctx);
246
247         g_signal_connect (sat,
248                         "handle-download-event",
249                         G_CALLBACK (on_sat_download_event),
250                         ctx);
251
252         return TRUE;
253 }
254
255 gboolean dbus_plugin_sat_response(struct custom_data *ctx, UserRequest *ur,
256                 struct dbus_request_info *dbus_info, enum tcore_response_command command,
257                 unsigned int data_len, const void *data)
258 {
259         const struct tresp_sat_envelop_data *envelop_rsp = NULL;
260
261         dbg("sat response command = [0x%x], data_len = %d", command, data_len);
262
263         switch (command) {
264                 case TRESP_SAT_REQ_ENVELOPE: {
265                         envelop_rsp = (struct tresp_sat_envelop_data *)data;
266
267                         dbg("envelop sub_cmd(%d) result(%d) rsp(%d)", envelop_rsp->sub_cmd, envelop_rsp->result, envelop_rsp->envelop_resp);
268
269                         if(envelop_rsp->sub_cmd == ENVELOP_MENU_SELECTION){
270                                 telephony_sat_complete_select_menu(dbus_info->interface_object, dbus_info->invocation,
271                                                 envelop_rsp->result, envelop_rsp->envelop_resp);
272                         }
273                         else if(envelop_rsp->sub_cmd == ENVELOP_EVENT_DOWNLOAD){
274                                 telephony_sat_complete_download_event(dbus_info->interface_object, dbus_info->invocation,
275                                                 envelop_rsp->result, envelop_rsp->envelop_resp);
276                         }
277                 } break;
278
279                 case TRESP_SAT_REQ_TERMINALRESPONSE:
280                         dbg("receive TRESP_SAT_REQ_TERMINALRESPONSE");
281                 break;
282
283                 default:
284                         dbg("not handled command[%d]", command);
285                 break;
286         }
287         return TRUE;
288 }
289
290 gboolean dbus_plugin_sat_notification(struct custom_data *ctx, const char *plugin_name,
291                 TelephonyObjectSkeleton *object, enum tcore_notification_command command,
292                 unsigned int data_len, const void *data)
293 {
294         TcorePlugin *plg = NULL;
295         TelephonySAT *sat;
296         struct tnoti_sat_proactive_ind *p_ind = (struct tnoti_sat_proactive_ind *)data;
297
298         if (!object) {
299                 dbg("object is NULL");
300                 return FALSE;
301         }
302
303         plg = tcore_server_find_plugin(ctx->server, plugin_name);
304         if (!plg){
305                 dbg("there is no valid plugin at this point");
306                 return FALSE;
307         }
308
309         sat = telephony_object_peek_sat(TELEPHONY_OBJECT(object));
310         dbg("sat = %p", sat);
311
312         dbg("notification !!! (command = 0x%x, data_len = %d)", command, data_len);
313
314         if (command == TNOTI_SAT_SESSION_END) {
315
316                 dbg("notified sat session end evt");
317                 sat_manager_init_queue(ctx);
318
319                 sat_ui_support_terminate_sat_ui();
320                 telephony_sat_emit_end_proactive_session(sat, SAT_PROATV_CMD_TYPE_END_PROACTIVE_SESSION);
321                 return TRUE;
322         }
323
324         //Proactive Command Notification
325         dbg("notified sat proactive command(%d)", p_ind->cmd_type);
326
327         switch (p_ind->cmd_type) {
328                 case SAT_PROATV_CMD_SETUP_MENU:{
329                         gboolean rv = FALSE;
330                         GVariant *menu_info = NULL;
331                         GVariant *resp = NULL;
332                         GVariant *exec_result = NULL;
333
334                         gchar *title;
335                         gint command_id, menu_cnt;
336                         gboolean b_present, b_helpinfo, b_updated;
337                         GVariant *items;
338
339                         menu_info = sat_manager_caching_setup_menu_info(ctx, plugin_name, (struct tel_sat_setup_menu_tlv*) &p_ind->proactive_ind_data.setup_menu);
340                         ctx->cached_sat_main_menu = menu_info;
341
342                         if(!menu_info){
343                                 dbg("no main menu data");
344                                 sat_ui_support_remove_desktop_file();
345                                 return TRUE;
346                         }
347
348                         dbg("menu_info type_format(%s)", g_variant_get_type_string(menu_info));
349                         g_variant_get(menu_info, "(ibs@vibb)", &command_id, &b_present, &title, &items,
350                                         &menu_cnt, &b_helpinfo, &b_updated);
351
352                         rv = sat_ui_support_create_desktop_file(title);
353                         rv = TRUE;
354                         dbg("return value (%d)", rv);
355                         if(rv)
356                                 resp = g_variant_new("(i)", RESULT_SUCCESS);
357                         else
358                                 resp = g_variant_new("(i)", RESULT_ME_UNABLE_TO_PROCESS_COMMAND);
359
360                         exec_result = g_variant_new_variant(resp);
361                         sat_manager_handle_app_exec_result(ctx, plg, command_id, SAT_PROATV_CMD_SETUP_MENU, exec_result);
362
363                         //sat_ui_support_launch_sat_ui(SAT_PROATV_CMD_SETUP_MENU, menu_info);
364
365                         telephony_sat_emit_setup_menu(sat, command_id, b_present, title, items, menu_cnt,
366                                         b_helpinfo, b_updated);
367                 } break;
368
369                 case SAT_PROATV_CMD_DISPLAY_TEXT:{
370                         GVariant *display_text = NULL;
371
372                         gint command_id, text_len, duration;
373                         gboolean high_priority, user_rsp_required, immediately_rsp;
374                         gchar text[SAT_TEXT_STRING_LEN_MAX];
375                         GVariant *icon_id = NULL;
376
377                         display_text = sat_manager_display_text_noti(ctx, plugin_name, (struct tel_sat_display_text_tlv*) &p_ind->proactive_ind_data.display_text);
378
379                         if(!display_text){
380                                 dbg("no display text data");
381                                 return TRUE;
382                         }
383
384                         dbg("display text type_format(%s)", g_variant_get_type_string(display_text));
385                         g_variant_get(display_text, "(isiibbb@v)", &command_id, &text, &text_len, &duration,
386                                                 &high_priority, &user_rsp_required, &immediately_rsp, &icon_id);
387
388                         sat_ui_support_launch_sat_ui(SAT_PROATV_CMD_DISPLAY_TEXT, display_text);
389
390                         telephony_sat_emit_display_text(sat, command_id, text, text_len, duration,
391                                         high_priority, user_rsp_required, immediately_rsp);
392
393                 } break;
394
395                 case SAT_PROATV_CMD_SELECT_ITEM:{
396                         GVariant *select_menu = NULL;
397
398                         gboolean help_info ;
399                         gchar *selected_text;
400                         gint command_id, default_item_id, menu_cnt, text_len =0;
401                         GVariant *menu_items, *icon_id, *icon_list;
402
403                         select_menu = sat_manager_select_item_noti(ctx, plugin_name, (struct tel_sat_select_item_tlv*) &p_ind->proactive_ind_data.select_item);
404
405                         if(!select_menu){
406                                 dbg("no select menu data");
407                                 return TRUE;
408                         }
409
410                         dbg("select menu type_format(%s)", g_variant_get_type_string(select_menu));
411                         g_variant_get(select_menu, "(ibsiii@v@v@v)", &command_id, &help_info, &selected_text,
412                                         &text_len, &default_item_id, &menu_cnt, &menu_items, &icon_id, &icon_list);
413
414                         sat_ui_support_launch_sat_ui(SAT_PROATV_CMD_SELECT_ITEM, select_menu);
415
416                         telephony_sat_emit_select_item (sat, command_id, help_info, selected_text, text_len,
417                                         default_item_id, menu_cnt, menu_items);
418                 } break;
419
420                 case SAT_PROATV_CMD_GET_INKEY:{
421                         GVariant *get_inkey = NULL;
422
423                         gint command_id, key_type, input_character_mode;
424                         gint text_len, duration;
425                         gboolean b_numeric, b_help_info;
426                         gchar *text;
427                         GVariant *icon_id;
428
429                         get_inkey = sat_manager_get_inkey_noti(ctx, plugin_name, (struct tel_sat_get_inkey_tlv*) &p_ind->proactive_ind_data.get_inkey);
430
431                         if(!get_inkey){
432                                 dbg("no get inkey data");
433                                 return TRUE;
434                         }
435
436                         dbg("get inkey type_format(%s)", g_variant_get_type_string(get_inkey));
437                         g_variant_get(get_inkey, "(iiibbsii@v)", &command_id, &key_type, &input_character_mode,
438                                         &b_numeric,&b_help_info, &text, &text_len, &duration, &icon_id);
439
440                         sat_ui_support_launch_sat_ui(SAT_PROATV_CMD_GET_INKEY, get_inkey);
441
442                         telephony_sat_emit_get_inkey(sat, command_id, key_type, input_character_mode,
443                                         b_numeric, b_help_info, text, text_len, duration);
444                 } break;
445
446                 case SAT_PROATV_CMD_GET_INPUT:{
447                         GVariant *get_input = NULL;
448
449                         gint command_id, input_character_mode;
450                         gint text_len, def_text_len, rsp_len_min, rsp_len_max;
451                         gboolean b_numeric, b_help_info, b_echo_input;
452                         gchar *text, *def_text;
453                         GVariant *icon_id;
454
455                         get_input = sat_manager_get_input_noti(ctx, plugin_name, (struct tel_sat_get_input_tlv*) &p_ind->proactive_ind_data.get_input);
456
457                         if(!get_input){
458                                 dbg("no get input data");
459                                 return TRUE;
460                         }
461
462                         dbg("get input type_format(%s)", g_variant_get_type_string(get_input));
463                         g_variant_get(get_input, "(iibbbsiiisi@v)", &command_id, &input_character_mode, &b_numeric, &b_help_info, &b_echo_input,
464                                         &text, &text_len, &rsp_len_max, &rsp_len_min, &def_text, &def_text_len, &icon_id);
465
466                         sat_ui_support_launch_sat_ui(SAT_PROATV_CMD_GET_INPUT, get_input);
467
468                         telephony_sat_emit_get_input(sat, command_id, input_character_mode, b_numeric, b_help_info,
469                                         b_echo_input, text, text_len, rsp_len_max, rsp_len_min, def_text, def_text_len);
470                 } break;
471
472                 case SAT_PROATV_CMD_PLAY_TONE:{
473                         GVariant *play_tone = NULL;
474
475                         gint command_id, tone_type, duration;
476                         gint text_len;
477                         gchar* text;
478                         GVariant *icon_id;
479
480                         play_tone = sat_manager_play_tone_noti(ctx, plugin_name, (struct tel_sat_play_tone_tlv*) &p_ind->proactive_ind_data.play_tone);
481
482                         if(!play_tone){
483                                 dbg("no play tone data");
484                                 return TRUE;
485                         }
486
487                         dbg("play tone type_format(%s)", g_variant_get_type_string(play_tone));
488                         g_variant_get(play_tone, "(isi@vii)", &command_id, &text, &text_len, &icon_id, &tone_type, &duration);
489
490                         dbg("check display text : text(%s) text len(%d)", text, text_len);
491                         if(text_len > 1 && (g_strcmp0(text,"") != 0) ){
492                                 GVariant *ui_info = NULL;
493                                 gboolean user_confirm = FALSE;
494                                 dbg("text should be displayed by ui");
495                                 dbg("play tone is pending!!!")
496
497                                 ui_info = g_variant_new("(isib)", command_id, text, text_len, user_confirm);
498                                 sat_ui_support_launch_sat_ui(SAT_PROATV_CMD_NONE, ui_info);
499                                 return TRUE;
500                         }
501
502                         telephony_sat_emit_play_tone(sat, command_id, text, text_len, tone_type, duration);
503                 } break;
504
505                 case SAT_PROATV_CMD_SEND_SMS:{
506                         GVariant *send_sms = NULL;
507
508                         gint command_id, ton, npi, tpdu_type;
509                         gboolean b_packing_required;
510                         gint text_len, number_len, tpdu_data_len;
511                         gchar* text, *dialling_number;
512                         GVariant *tpdu_data, *icon_id;
513
514                         send_sms = sat_manager_send_sms_noti(ctx, plugin_name, (struct tel_sat_send_sms_tlv*) &p_ind->proactive_ind_data.send_sms);
515
516                         if(!send_sms){
517                                 dbg("no send sms data");
518                                 return TRUE;
519                         }
520
521                         dbg("send sms type_format(%s)", g_variant_get_type_string(send_sms));
522                         g_variant_get(send_sms, "(isi@vbiisii@vi)", &command_id, &text, &text_len, &icon_id, &b_packing_required, &ton, &npi,
523                                         &dialling_number, &number_len, &tpdu_type, &tpdu_data, &tpdu_data_len);
524
525                         dbg("check display text : text(%s) text len(%d)", text, text_len);
526                         if(text_len > 1 && (g_strcmp0(text,"") != 0) ){
527                                 GVariant *ui_info = NULL;
528                                 gboolean user_confirm = FALSE;
529                                 dbg("text should be displayed by ui");
530                                 dbg("send sms is pending!!!")
531
532                                 ui_info = g_variant_new("(isib)", command_id, text, text_len, user_confirm);
533                                 sat_ui_support_launch_sat_ui(SAT_PROATV_CMD_NONE, ui_info);
534                                 return TRUE;
535                         }
536
537                         telephony_sat_emit_send_sms(sat, command_id, text, text_len, b_packing_required,
538                                         ton, npi, dialling_number, number_len, tpdu_type, tpdu_data, tpdu_data_len);
539                 } break;
540
541                 case SAT_PROATV_CMD_SEND_SS:{
542                         GVariant *send_ss = NULL;
543
544                         gint command_id, ton, npi;
545                         gint text_len, ss_str_len;
546                         gchar* text, *ss_string;
547
548                         GVariant *icon_id;
549
550                         send_ss = sat_manager_send_ss_noti(ctx, plugin_name, (struct tel_sat_send_ss_tlv*) &p_ind->proactive_ind_data.send_ss);
551
552                         if(!send_ss){
553                                 dbg("no send ss data");
554                                 return TRUE;
555                         }
556
557                         dbg("send ss type_format(%s)", g_variant_get_type_string(send_ss));
558                         g_variant_get(send_ss, "(isi@viiis)", &command_id, &text, &text_len, &icon_id,
559                                         &ton, &npi, &ss_str_len, &ss_string);
560
561                         dbg("check display text : text(%s) text len(%d)", text, text_len);
562                         if(text_len > 1 && (g_strcmp0(text,"") != 0) ){
563                                 GVariant *ui_info = NULL;
564                                 gboolean user_confirm = FALSE;
565                                 dbg("text should be displayed by ui");
566                                 dbg("send ss is pending!!!")
567
568                                 ui_info = g_variant_new("(isib)", command_id, text, text_len, user_confirm);
569                                 sat_ui_support_launch_sat_ui(SAT_PROATV_CMD_NONE, ui_info);
570                                 return TRUE;
571                         }
572
573                         telephony_sat_emit_send_ss(sat, command_id, text, text_len, ton, npi, ss_string);
574                 } break;
575
576                 case SAT_PROATV_CMD_SEND_USSD:{
577                         GVariant *send_ussd = NULL;
578
579                         gint command_id;
580                         gint text_len, ussd_str_len;
581                         gchar* text, *ussd_string;
582
583                         GVariant *icon_id;
584
585                         send_ussd = sat_manager_send_ussd_noti(ctx, plugin_name, (struct tel_sat_send_ussd_tlv*) &p_ind->proactive_ind_data.send_ussd);
586
587                         if(!send_ussd){
588                                 dbg("no send ussd data");
589                                 return TRUE;
590                         }
591
592                         dbg("send ussd type_format(%s)", g_variant_get_type_string(send_ussd));
593                         g_variant_get(send_ussd, "(isi@vis)", &command_id, &text, &text_len, &icon_id, &ussd_str_len, &ussd_string);
594
595                         dbg("check display text : text(%s) text len(%d)", text, text_len);
596                         if(text_len > 1 && (g_strcmp0(text,"") != 0) ){
597                                 GVariant *ui_info = NULL;
598                                 gboolean user_confirm = FALSE;
599                                 dbg("text should be displayed by ui");
600                                 dbg("send ussd is pending!!!")
601
602                                 ui_info = g_variant_new("(isib)", command_id, text, text_len, user_confirm);
603                                 sat_ui_support_launch_sat_ui(SAT_PROATV_CMD_NONE, ui_info);
604                                 return TRUE;
605                         }
606
607                         telephony_sat_emit_setup_ussd(sat, command_id, text, text_len, ussd_string);
608                 } break;
609
610                 case SAT_PROATV_CMD_SETUP_CALL:{
611                         GVariant *setup_call = NULL;
612
613                         gint command_id, call_type, text_len, duration;
614                         gchar *text, *call_number;
615                         GVariant *icon_id;
616
617                         setup_call = sat_manager_setup_call_noti(ctx, plugin_name, (struct tel_sat_setup_call_tlv*) &p_ind->proactive_ind_data.setup_call);
618
619                         if(!setup_call){
620                                 dbg("no setup call data");
621                                 return TRUE;
622                         }
623
624                         dbg("setup call type_format(%s)", g_variant_get_type_string(setup_call));
625                         g_variant_get(setup_call, "(isi@visi)", &command_id, &text, &text_len, &icon_id, &call_type, &call_number, &duration);
626
627                         dbg("check display text : text(%s) text len(%d)", text, text_len);
628                         if(text_len > 1 && (g_strcmp0(text,"") != 0) ){
629                                 GVariant *ui_info = NULL;
630                                 gboolean user_confirm = TRUE;
631                                 dbg("text should be displayed by ui");
632                                 dbg("setup call is pending!!!")
633
634                                 ui_info = g_variant_new("(isib)", command_id, text, text_len, user_confirm);
635                                 sat_ui_support_launch_sat_ui(SAT_PROATV_CMD_NONE, ui_info);
636                                 return TRUE;
637                         }
638
639                         telephony_sat_emit_setup_call(sat, command_id, text, text_len, call_type,
640                                         call_number, duration);
641                 }break;
642
643                 case SAT_PROATV_CMD_SETUP_EVENT_LIST:{
644                         GVariant *event_list = NULL;
645
646                         gint event_cnt;
647                         GVariant *evt_list;
648
649                         event_list = sat_manager_setup_event_list_noti(ctx, plugin_name, (struct tel_sat_setup_event_list_tlv*) &p_ind->proactive_ind_data.setup_event_list);
650
651                         if(!event_list){
652                                 dbg("no setup event list data");
653                                 return TRUE;
654                         }
655
656                         dbg("setup event list type_format(%s)", g_variant_get_type_string(event_list));
657                         g_variant_get(event_list, "(i@v)", &event_cnt, &evt_list);
658
659                         telephony_sat_emit_setup_event_list(sat, event_cnt, evt_list);
660                 } break;
661
662                 case SAT_PROATV_CMD_SETUP_IDLE_MODE_TEXT:{
663                         GVariant *setup_idle_mode = NULL;
664
665                         gint command_id, text_len;
666                         gchar* text;
667                         GVariant *icon_id;
668
669                         setup_idle_mode = sat_manager_setup_idle_mode_text_noti(ctx, plugin_name, (struct tel_sat_setup_idle_mode_text_tlv*) &p_ind->proactive_ind_data.setup_idle_mode_text);
670
671                         if(!setup_idle_mode){
672                                 dbg("no setup idle mode text data");
673                                 return TRUE;
674                         }
675
676                         dbg("setup idle mode text type_format(%s)", g_variant_get_type_string(setup_idle_mode));
677                         g_variant_get(setup_idle_mode, "(isi@v)", &command_id, &text, &text_len, &icon_id);
678
679                         if(text_len > 1 && (g_strcmp0(text,"") != 0) ){
680                                 GVariant *ui_info = NULL;
681                                 gboolean user_confirm = TRUE;
682                                 dbg("text should be displayed by ui");
683                                 dbg("setup idle mode text is displayed!!!")
684
685                                 ui_info = g_variant_new("(isib)", command_id, text, text_len, user_confirm);
686                                 sat_ui_support_launch_sat_ui(SAT_PROATV_CMD_NONE, ui_info);
687                                 return TRUE;
688                         }
689
690                         telephony_sat_emit_setup_idle_mode_text(sat, command_id, text, text_len);
691                 } break;
692
693                 case SAT_PROATV_CMD_OPEN_CHANNEL:{
694                         GVariant *open_channel = NULL;
695
696                         gint command_id, bearer_type, protocol_type, dest_addr_type;
697                         gboolean immediate_link, auto_reconnection, bg_mode;
698                         gint text_len, buffer_size, port_number;
699                         gchar *text, *dest_address;
700                         GVariant *icon_id;
701                         GVariant *bearer_param;
702                         GVariant *bearer_detail;
703
704                         open_channel = sat_manager_open_channel_noti(ctx, plugin_name, (struct tel_sat_open_channel_tlv*) &p_ind->proactive_ind_data.open_channel);
705
706                         if(!open_channel){
707                                 dbg("no open channel data");
708                                 return TRUE;
709                         }
710
711                         dbg("open channel type_format(%s)", g_variant_get_type_string(open_channel));
712                         g_variant_get(open_channel,"(isi@vbbbi@viiiis@v)", &command_id, &text, &text_len, &icon_id, &immediate_link, &auto_reconnection, &bg_mode,
713                                         &bearer_type, &bearer_param, &buffer_size, &protocol_type, &port_number, &dest_addr_type, &dest_address, &bearer_detail);
714
715                         dbg("check display text : text(%s) text len(%d)", text, text_len);
716                         if(text_len > 1 && (g_strcmp0(text,"") != 0) ){
717                                 GVariant *ui_info = NULL;
718                                 gboolean user_confirm = TRUE;
719                                 dbg("text should be displayed by ui");
720                                 dbg("open channel text is displayed!!!")
721
722                                 ui_info = g_variant_new("(isib)", command_id, text, text_len, user_confirm);
723                                 sat_ui_support_launch_sat_ui(SAT_PROATV_CMD_NONE, ui_info);
724                                 return TRUE;
725                         }
726
727                         telephony_sat_emit_open_channel(sat, command_id, text, text_len, immediate_link, auto_reconnection, bg_mode,
728                                                 bearer_type, bearer_param, buffer_size, protocol_type, port_number, dest_addr_type, dest_address, bearer_detail);
729                 } break;
730
731                 case SAT_PROATV_CMD_CLOSE_CHANNEL:{
732                         GVariant *close_channel = NULL;
733
734                         gint command_id, channel_id, text_len;
735                         gchar *text;
736                         GVariant *icon_id;
737
738                         close_channel = sat_manager_close_channel_noti(ctx, plugin_name, (struct tel_sat_close_channel_tlv*) &p_ind->proactive_ind_data.close_channel);
739
740                         if(!close_channel){
741                                 dbg("no close channel data");
742                                 return TRUE;
743                         }
744
745                         //TODO check the data for sat-ui
746
747                         dbg("close channel type_format(%s)", g_variant_get_type_string(close_channel));
748                         g_variant_get(close_channel, "(isi@vi)", &command_id, &text, &text_len, &icon_id, &channel_id);
749
750                         telephony_sat_emit_close_channel(sat, command_id, text, text_len, channel_id);
751                 } break;
752
753                 case SAT_PROATV_CMD_RECEIVE_DATA:{
754                         GVariant *receive_data = NULL;
755
756                         gint command_id, text_len, channel_id, channel_data_len = 0;
757                         gchar *text;
758                         GVariant *icon_id;
759
760                         receive_data = sat_manager_receive_data_noti(ctx, plugin_name, (struct tel_sat_receive_channel_tlv*) &p_ind->proactive_ind_data.receive_data);
761
762                         if(!receive_data){
763                                 dbg("no receive data data");
764                                 return TRUE;
765                         }
766
767                         //TODO check the data for sat-ui
768
769                         dbg("receive data type_format(%s)", g_variant_get_type_string(receive_data));
770                         g_variant_get(receive_data, "(isi@vii)", &command_id, &text, &text_len, &icon_id, &channel_id, &channel_data_len);
771
772                         telephony_sat_emit_receive_data(sat, command_id, text, text_len, channel_id, channel_data_len);
773                 } break;
774
775                 case SAT_PROATV_CMD_SEND_DATA:{
776                         GVariant *send_data = NULL;
777
778                         gint command_id, channel_id, text_len, channel_data_len;
779                         gboolean send_data_immediately;
780                         gchar *text;
781                         GVariant *channel_data;
782                         GVariant *icon_id;
783
784                         send_data = sat_manager_send_data_noti(ctx, plugin_name, (struct tel_sat_send_channel_tlv*) &p_ind->proactive_ind_data.send_data);
785
786                         if(!send_data){
787                                 dbg("no send data data");
788                                 return TRUE;
789                         }
790
791                         //TODO check the data for sat-ui
792
793                         dbg("send data type_format(%s)", g_variant_get_type_string(send_data));
794                         g_variant_get(send_data, "(isi@vib@vi)", &command_id, &text, &text_len, &icon_id, &channel_id, &send_data_immediately, &channel_data, &channel_data_len);
795
796                         telephony_sat_emit_send_data(sat, command_id, text, text_len, channel_id, send_data_immediately, channel_data, channel_data_len);
797                 } break;
798
799                 case SAT_PROATV_CMD_GET_CHANNEL_STATUS:{
800                         GVariant *channel_status = NULL;
801
802                         gint command_id;
803
804                         channel_status = sat_manager_get_channel_status_noti(ctx, plugin_name, (struct tel_sat_get_channel_status_tlv*) &p_ind->proactive_ind_data.get_channel_status);
805
806                         if(!channel_status){
807                                 dbg("no get channel status data");
808                                 return TRUE;
809                         }
810
811                         //TODO check the data for sat-ui
812
813                         dbg("get channel status type_format(%s)", g_variant_get_type_string(channel_status));
814                         g_variant_get(channel_status, "(i)", &command_id);
815
816                         telephony_sat_emit_get_channel_status(sat, command_id);
817                 } break;
818
819                 case SAT_PROATV_CMD_REFRESH:{
820                         GVariant *refresh = NULL;
821                         gint command_id = 0;
822                         gint refresh_type =0;
823                         GVariant *file_list = NULL;
824
825                         GVariant *ui_info = NULL;
826                         gboolean user_confirm = FALSE;
827                         gchar info[] = "refresh from SIM TOOLKIT";
828
829                         refresh = sat_manager_refresh_noti(ctx, plugin_name, (struct tel_sat_refresh_tlv*) &p_ind->proactive_ind_data.refresh);
830
831                         if(!refresh){
832                                 dbg("no refresh data");
833                                 return TRUE;
834                         }
835
836                         dbg("refresh type_format(%s)", g_variant_get_type_string(refresh));
837                         g_variant_get(refresh, "(ii@v)", &command_id, &refresh_type, &file_list);
838
839                         dbg("check refresh_type(%d)", refresh_type);
840                         dbg("text should be displayed by ui");
841
842                         ui_info = g_variant_new("(isib)", command_id, info, strlen(info), user_confirm);
843                         sat_ui_support_launch_sat_ui(SAT_PROATV_CMD_NONE, ui_info);
844
845                         telephony_sat_emit_refresh(sat, command_id, refresh_type, file_list);
846                 }break;
847
848                 case SAT_PROATV_CMD_MORE_TIME:{
849                         sat_manager_more_time_noti(ctx, plugin_name, (struct tel_sat_more_time_tlv*) &p_ind->proactive_ind_data.more_time);
850                         telephony_sat_emit_more_time(sat);
851                 }break;
852
853                 case SAT_PROATV_CMD_SEND_DTMF:{
854                         GVariant *send_dtmf = NULL;
855                         gint command_id = 0;
856                         gint text_len = 0, dtmf_str_len = 0;
857                         gchar *text = NULL;
858                         gchar *dtmf_str = NULL;
859                         GVariant *icon_id = NULL;
860
861                         send_dtmf = sat_manager_send_dtmf_noti(ctx, plugin_name, (struct tel_sat_send_dtmf_tlv*) &p_ind->proactive_ind_data.send_dtmf);
862                         if(!send_dtmf){
863                                 dbg("no send_dtmf data");
864                                 return TRUE;
865                         }
866
867                         dbg("send_dtmf type_format(%s)", g_variant_get_type_string(send_dtmf));
868                         g_variant_get(send_dtmf, "(isi@vis)", &command_id, &text, &text_len, &icon_id, &dtmf_str, &dtmf_str_len);
869
870                         if(text_len > 1 && (g_strcmp0(text,"") != 0) ){
871                                 GVariant *ui_info = NULL;
872                                 gboolean user_confirm = FALSE;
873                                 dbg("text should be displayed by ui");
874                                 dbg("send dtmf is displayed!!!")
875
876                                 ui_info = g_variant_new("(isib)", command_id, text, text_len, user_confirm);
877                                 sat_ui_support_launch_sat_ui(SAT_PROATV_CMD_NONE, ui_info);
878                                 return TRUE;
879                         }
880
881                         telephony_sat_emit_send_dtmf(sat, command_id, text, text_len, dtmf_str, dtmf_str_len);
882                 }break;
883
884                 case SAT_PROATV_CMD_LAUNCH_BROWSER:{
885                         GVariant *launch_browser = NULL;
886                         gint command_id = 0;
887                         gint browser_id = 0;
888                         gint url_len = 0, text_len = 0, gateway_proxy_len =0;
889                         gchar *url = NULL;
890                         gchar *text = NULL;
891                         gchar *gateway_proxy = NULL;
892                         GVariant *icon_id = NULL;
893
894                         launch_browser = sat_manager_launch_browser_noti(ctx, plugin_name, (struct tel_sat_launch_browser_tlv*) &p_ind->proactive_ind_data.launch_browser);
895                         if(!launch_browser){
896                                 dbg("no launch_browser data");
897                                 return TRUE;
898                         }
899
900                         dbg("launch_browser type_format(%s)", g_variant_get_type_string(launch_browser));
901                         g_variant_get(launch_browser, "(iisisisi@v)", &command_id, &browser_id, &url, &url_len, &gateway_proxy, &gateway_proxy_len, &text, &text_len, &icon_id);
902
903                         if(text_len > 1 && (g_strcmp0(text,"") != 0) ){
904                                 GVariant *ui_info = NULL;
905                                 gboolean user_confirm = TRUE;
906                                 dbg("text should be displayed by ui");
907                                 dbg("launch browser is displayed!!!")
908
909                                 ui_info = g_variant_new("(isib)", command_id, text, text_len, user_confirm);
910                                 sat_ui_support_launch_sat_ui(SAT_PROATV_CMD_NONE, ui_info);
911                                 return TRUE;
912                         }
913
914                         telephony_sat_emit_launch_browser(sat, command_id, browser_id, url, url_len, gateway_proxy, gateway_proxy_len, text, text_len);
915                 }break;
916
917                 case SAT_PROATV_CMD_PROVIDE_LOCAL_INFO:{
918                         GVariant *provide_info = NULL;
919                         gint command_id = 0;
920                         gint info_type = 0;
921
922                         provide_info = sat_manager_provide_local_info_noti(ctx, plugin_name, (struct tel_sat_provide_local_info_tlv*) &p_ind->proactive_ind_data.provide_local_info);
923                         if(!provide_info){
924                                 dbg("no provide_info data");
925                                 return TRUE;
926                         }
927
928                         dbg("provide_info type_format(%s)", g_variant_get_type_string(provide_info));
929                         g_variant_get(provide_info, "(ii)", &command_id, &info_type);
930
931                         telephony_sat_emit_provide_local_info(sat, command_id, info_type);
932                 }break;
933
934                 case SAT_PROATV_CMD_LANGUAGE_NOTIFICATION:{
935                         GVariant *language_noti = NULL;
936                         gint command_id = 0;
937                         gint language = 0;
938                         gboolean b_specified = FALSE;
939
940                         language_noti = sat_manager_language_notification_noti(ctx, plugin_name, (struct tel_sat_language_notification_tlv*) &p_ind->proactive_ind_data.language_notification);
941                         if(!language_noti){
942                                 dbg("no language_noti data");
943                                 return TRUE;
944                         }
945
946                         dbg("language_noti type_format(%s)", g_variant_get_type_string(language_noti));
947                         g_variant_get(language_noti, "(iib)", &command_id, &language, &b_specified);
948
949                         telephony_sat_emit_language_notification(sat, command_id, language, b_specified);
950                 }break;
951
952                 default:
953                         dbg("not handled ind->cmd_type[0x%x]", p_ind->cmd_type);
954                         break;
955         }
956
957         return TRUE;
958 }