2 * Telephony test application
4 * Copyright (c) 2012 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.
29 #include <tapi_common.h>
30 #include <TapiUtility.h>
37 #include "phonebook.h"
44 extern struct menu_data menu_modem[];
45 extern struct menu_data menu_sat[];
46 extern struct menu_data menu_net[];
47 extern struct menu_data menu_sms[];
48 extern struct menu_data menu_sim[];
49 extern struct menu_data menu_phonebook[];
50 extern struct menu_data menu_ss[];
51 extern struct menu_data menu_call[];
52 extern struct menu_data menu_gps[];
54 TapiHandle *handle = NULL;
56 static char data_modem_name[MENU_DATA_SIZE + 1] = "";
57 static char data_property_int[MENU_DATA_SIZE + 1] = "org.tizen.telephony.Modem:power";
58 static char data_property_string[MENU_DATA_SIZE + 1] = "org.tizen.telephony.Network:network_name";
60 static int get_modem_info(MManager *mm, struct menu_data *menu)
62 char **cp_list = NULL;
65 cp_list = tel_get_cp_name_list();
72 msg("[%02d] strlen(%d), '%s'", i, strlen(cp_list[i]), cp_list[i]);
81 static int init(MManager *mm, struct menu_data *menu)
84 msg("already handle exist");
88 if (strlen(data_modem_name) < 1) {
89 msg("call tel_init(NULL)");
90 handle = tel_init(NULL);
93 msg("call tel_init(\"%s\")", data_modem_name);
94 handle = tel_init(data_modem_name);
98 msg("handle is null");
100 menu_manager_set_user_data(mm, handle);
105 static int deinit(MManager *mm, struct menu_data *menu)
108 msg("handle is null");
112 msg("call tel_deinit()");
116 menu_manager_set_user_data(mm, handle);
121 static int get_property_int(MManager *mm, struct menu_data *menu)
123 TapiHandle *handle = menu_manager_ref_user_data(mm);
127 msg("call tel_get_property_int()");
129 ret = tel_get_property_int(handle, data_property_int, &result_int);
130 if (ret != TAPI_API_SUCCESS) {
131 msg("failed. (return = %d)", ret);
134 msg(" - result = %d", result_int);
139 static int get_property_string(MManager *mm, struct menu_data *menu)
141 TapiHandle *handle = menu_manager_ref_user_data(mm);
142 char *result_str = NULL;
145 msg("call tel_get_property_string()");
147 ret = tel_get_property_string (handle, data_property_string, &result_str);
148 if (ret != TAPI_API_SUCCESS) {
149 msg("failed. (return = %d)", ret);
152 msg(" - result = %s", result_str);
160 static struct menu_data menu_common[] = {
161 { "1", "tel_get_modem_info", NULL, get_modem_info, NULL},
162 { "2", "tel_init", NULL, init, NULL},
163 { "2s", " - modem_name", NULL, NULL, data_modem_name},
164 { "3", "tel_deinit", NULL, deinit, NULL},
165 { "4", "tel_get_property_int", NULL, get_property_int, NULL},
166 { "4s", " - property", NULL, NULL, data_property_int},
167 { "5", "tel_get_property_string", NULL, get_property_string, NULL},
168 { "5s", " - property", NULL, NULL, data_property_string},
172 static struct menu_data menu_main[] = {
173 { "1", "Common", menu_common,NULL, NULL},
174 { "2", "Modem", menu_modem, NULL, NULL},
175 { "3", "Network", menu_net, NULL, NULL},
176 { "4", "SIM", menu_sim, NULL, NULL},
177 { "5", "Phonebook", menu_phonebook, NULL, NULL},
178 { "6", "SMS", menu_sms, NULL, NULL},
179 { "7", "SS", menu_ss, NULL, NULL},
180 { "8", "SAT", menu_sat, NULL, NULL},
181 { "9", "Call", menu_call, NULL, NULL},
182 { "a", "Gps", menu_gps, NULL, NULL},
186 int main(int arg, char **argv)
189 GIOChannel *channel = g_io_channel_unix_new(STDIN_FILENO);
193 mainloop = g_main_loop_new(NULL, FALSE);
196 msg("* Telephony Test application ");
197 msg("* Build On: %s %s", __DATE__, __TIME__);
199 manager = menu_manager_new(menu_main, mainloop);
201 if (strlen(data_modem_name) < 1)
202 handle = tel_init(NULL);
204 handle = tel_init(data_modem_name);
209 msg("tel_init(%s) failed.", data_modem_name);
212 msg("tel_init(%s) success.", data_modem_name);
215 menu_manager_set_user_data(manager, handle);
217 register_network_event(handle);
218 register_modem_event(handle);
219 register_sat_event(handle);
220 register_sim_event(handle);
221 register_phonebook_event(handle);
222 register_sms_event(handle);
223 register_call_event(handle);
224 register_ss_event(handle);
225 register_gps_event(handle);
227 menu_manager_run(manager);
229 g_io_add_watch(channel, (G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL),
230 on_menu_manager_keyboard, manager);
232 g_main_loop_run(mainloop);
234 msg("******* Bye bye *******");