/* * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include #include #include #include #include #include #include #include "uat-menu.h" #include "uat-common.h" ua_monitor_h g_ua_mon_h = NULL; extern struct menu_data menu_ua_init[]; extern struct menu_data menu_ua_devices[]; extern struct menu_data menu_ua_users[]; extern struct menu_data menu_ua_services[]; extern struct menu_data menu_ua_sensors[]; extern struct menu_data menu_ua_detections[]; static struct menu_data menu_main[] = { { "1", "Init", menu_ua_init, NULL, NULL }, { "2", "Devices", menu_ua_devices, NULL, NULL }, { "3", "Users", menu_ua_users, NULL, NULL }, { "4", "Services", menu_ua_services, NULL, NULL }, { "5", "Sensors", menu_ua_sensors, NULL, NULL }, { "6", "Detection", menu_ua_detections, NULL, NULL }, { NULL, NULL, }, }; static int __init_func(MManager *mm, struct menu_data *menu) { int ret = UA_ERROR_NONE; msg("ua_initialize"); ret = ua_initialize(); msg(" - ua_initialize() ret: [0x%X] [%s]", ret, uat_get_error_str(ret)); return RET_SUCCESS; } static gboolean __create_init_menu(struct menu_data init_menu[1]) { init_menu[0].key = "1"; init_menu[0].title = "Init"; init_menu[0].sub_menu = menu_main; init_menu[0].callback = __init_func; init_menu[0].data = NULL; return TRUE; } int main(int arg, char **argv) { GMainLoop *mainloop = NULL; GIOChannel *channel = g_io_channel_unix_new(STDIN_FILENO); MManager *manager; struct menu_data init_menu[1+1] = { {NULL, NULL, } }; #if !GLIB_CHECK_VERSION(2, 35, 0) g_type_init(); #endif mainloop = g_main_loop_new(NULL, FALSE); msg(""); msg("* User Awareness test application "); msg("* Build On: %s %s", __DATE__, __TIME__); if (__create_init_menu(init_menu) == FALSE) goto OUT; manager = menu_manager_new(init_menu, mainloop); if (!manager) goto OUT; menu_manager_run(manager); g_io_add_watch(channel, (G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL), on_menu_manager_keyboard, manager); g_main_loop_run(mainloop); OUT: if (g_ua_mon_h) ua_monitor_destroy(g_ua_mon_h); ua_deinitialize(); g_main_loop_unref(mainloop); msg("******* Bye bye *******"); return 0; }