4 * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Ja-young Gu <jygu@samsung.com>
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
28 #include <tapi_common.h>
30 #include <TapiUtility.h>
35 TelSatSetupMenuInfo_t main_menu;
37 static void on_noti_setup_menu(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
40 TelSatSetupMenuInfo_t *setup_menu = NULL;
42 msg("noti id (%s)", noti_id);
45 msg("noti data is null");
49 setup_menu = (TelSatSetupMenuInfo_t *)data;
50 msg("command id (%d)", setup_menu->commandId);
51 msg("menu present (%d)", setup_menu->bIsMainMenuPresent);
52 msg("menu title (%s)", setup_menu->satMainTitle);
53 msg("item cnt (%d)", setup_menu->satMainMenuNum);
54 for(local_index=0;local_index < setup_menu->satMainMenuNum; local_index++){
55 msg("item id(%d) (%s)", setup_menu->satMainMenuItem[local_index].itemId, setup_menu->satMainMenuItem[local_index].itemString);
57 msg("menu help info (%d)", setup_menu->bIsSatMainMenuHelpInfo);
58 msg("menu updated (%d)", setup_menu->bIsUpdatedSatMainMenu);
61 static void on_noti_display_text(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
63 TelSatDisplayTextInd_t *display_text = NULL;
65 msg("noti id (%s)", noti_id);
68 msg("noti data is null");
72 display_text = (TelSatDisplayTextInd_t *)data;
74 msg("command id (%d)", display_text->commandId);
75 msg("display text (%s)", display_text->text.string);
76 msg("string len(%d)", display_text->text.stringLen);
77 msg("duration (%d)", display_text->duration);
78 msg("high priority (%d)", display_text->bIsPriorityHigh);
79 msg("user response required(%d)", display_text->bIsUserRespRequired);
82 static void on_noti_select_item(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
85 TelSatSelectItemInd_t *select_item = NULL;
87 msg("noti id (%s)", noti_id);
90 msg("noti data is null");
94 select_item = (TelSatSelectItemInd_t *)data;
96 msg("command id (%d)", select_item->commandId);
97 msg("help info(%d)", select_item->bIsHelpInfoAvailable);
98 msg("selected item string(%s)", select_item->text.string);
99 msg("string len(%d)", select_item->text.stringLen);
100 msg("default item local_index(%d)", select_item->defaultItemIndex);
101 msg("item count(%d)", select_item->menuItemCount);
102 for(local_index=0;local_index < select_item->menuItemCount; local_index++){
103 msg("item local_index(%d) id(%d) len(%d) str(%s)", local_index,
104 select_item->menuItem[local_index].itemId, select_item->menuItem[local_index].textLen, select_item->menuItem[local_index].text);
108 static void on_resp_select_menu(TapiHandle *handle, int result, void *data, void *user_data)
111 msg("select menu item result(%d)", result);
114 static int run_sat_get_main_menu_info(MManager *mm, struct menu_data *menu)
116 TapiHandle *handle = menu_manager_ref_user_data(mm);
119 msg("call get main menu info()");
121 result = tel_get_sat_main_menu_info(handle, &main_menu);
122 if (result != TAPI_API_SUCCESS) {
123 msg("failed. (result = %d)", result);
126 msg("success to get main menu");
130 static int run_sat_select_menu(MManager *mm, struct menu_data *menu)
132 TapiHandle *handle = menu_manager_ref_user_data(mm);
133 TelSatMenuSelectionReqInfo_t selected_menu;
134 int result, local_index=0;
137 msg("call select menu()");
139 for(local_index=0;local_index < main_menu.satMainMenuNum; local_index++){
140 msg("item id(%d) (%s)", main_menu.satMainMenuItem[local_index].itemId, main_menu.satMainMenuItem[local_index].itemString);
142 msg("select item >>> ");
143 if (scanf("%d", &item_id) < 0) {
144 msg("scanf() failed.");
148 selected_menu.bIsHelpRequested = 0;
149 selected_menu.itemIdentifier = item_id;
151 msg("selected item id (%d)", selected_menu.itemIdentifier);
152 result = tel_select_sat_menu(handle, &selected_menu, on_resp_select_menu, NULL);
153 if (result != TAPI_API_SUCCESS) {
154 msg("failed. (result = %d)", result);
160 struct menu_data menu_sat[] = {
161 { "1", "GET Main Menu Info", NULL, run_sat_get_main_menu_info, NULL},
162 { "2", "SELECT Main Menu", NULL, run_sat_select_menu, NULL},
163 /* { "2a", "SET PLMN Selection mode (Automatic)", menu_net_set_plmn_mode_automatic, NULL, NULL},
164 { "2s", "SET PLMN Selection mode (Manual)", menu_net_set_plmn_mode_manual, NULL, NULL},
165 { "2g", "GET PLMN Selection mode", menu_net_get_plmn_mode, NULL, NULL},
166 { "3s", "SET Service Domain", menu_net_set_service_domain, NULL, NULL},
167 { "3g", "GET Service Domain", menu_net_get_service_domain, NULL, NULL},
168 { "4s", "SET Band", menu_net_set_band, NULL, NULL},
169 { "4g", "GET Band", menu_net_get_band, NULL, NULL},
170 { "5s", "SET Preferred PLMN", menu_net_set_preferred_plmn, NULL, NULL},
171 { "5g", "GET Preferred PLMN", menu_net_get_preferred_plmn, NULL, NULL},
172 { "6", "SET Cancel manual search", menu_net_set_cancel_manual_search, NULL, NULL},
173 { "7", "GET Serving network", menu_net_get_serving_network, NULL, NULL},*/
177 void register_sat_event(TapiHandle *handle)
182 ret = tel_register_noti_event(handle, TAPI_NOTI_SAT_SETUP_MENU, on_noti_setup_menu, NULL);
183 if (ret != TAPI_API_SUCCESS) {
184 msg("event register failed(%d)", ret);
187 ret = tel_register_noti_event(handle, TAPI_NOTI_SAT_DISPLAY_TEXT, on_noti_display_text, NULL);
188 if (ret != TAPI_API_SUCCESS) {
189 msg("event register failed(%d)", ret);
192 ret = tel_register_noti_event(handle, TAPI_NOTI_SAT_SELECT_ITEM, on_noti_select_item, NULL);
193 if (ret != TAPI_API_SUCCESS) {
194 msg("event register failed(%d)", ret);
197 /* ret = tel_register_noti_event(handle, TAPI_NOTI_SAT_GET_INKEY, on_noti_get_inkey, NULL);
198 ret = tel_register_noti_event(handle, TAPI_NOTI_SAT_GET_INPUT, on_noti_get_input, NULL);*/