1 /******************************************************************
3 * Copyright 2015 Samsung Electronics All Rights Reserved.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 ******************************************************************/
21 #include "clientmain.h"
24 #include "OCPlatform.h"
27 typedef struct appdata
33 Evas_Object *findButton;
35 Evas_Object *listview;
39 win_delete_request_cb(void *data , Evas_Object *obj , void *event_info)
45 list_selected_cb(void *data, Evas_Object *obj, void *event_info)
47 Elm_Object_Item *it = (Elm_Object_Item *)event_info;
48 elm_list_item_selected_set(it, EINA_FALSE);
52 naviframe_pop_cb(void *data, Elm_Object_Item *it)
59 create_list_view(appdata_s *ad)
63 Evas_Object *nf = ad->nf;
64 Elm_Object_Item *nf_it;
67 list = elm_list_add(nf);
68 elm_list_mode_set(list, ELM_LIST_COMPRESS);
69 evas_object_smart_callback_add(list, "selected", list_selected_cb, NULL);
71 // Main Menu Items Here
73 elm_list_item_append(list, "Start Container Client", NULL, NULL, containerCreateUI, nf);
77 // This button is set for devices which doesn't have H/W back key.
78 btn = elm_button_add(nf);
79 elm_object_style_set(btn, "naviframe/end_btn/default");
80 nf_it = elm_naviframe_item_push(nf, "Resource Encapsulation", btn, NULL, list, NULL);
81 elm_naviframe_item_pop_cb_set(nf_it, naviframe_pop_cb, ad->win);
86 create_base_gui(appdata_s *ad)
89 ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE);
90 elm_win_conformant_set(ad->win, EINA_TRUE);
91 elm_win_autodel_set(ad->win, EINA_TRUE);
93 if (elm_win_wm_rotation_supported_get(ad->win))
95 int rots[4] = { 0, 90, 180, 270 };
96 elm_win_wm_rotation_available_rotations_set(ad->win, (const int *)(&rots), 4);
99 evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, NULL);
102 ad->conform = elm_conformant_add(ad->win);
103 evas_object_size_hint_weight_set(ad->conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
104 elm_win_resize_object_add(ad->win, ad->conform);
105 evas_object_show(ad->conform);
108 ad->layout = elm_layout_add(ad->conform);
109 evas_object_size_hint_weight_set(ad->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
110 elm_layout_theme_set(ad->layout, "layout", "application", "default");
111 evas_object_show(ad->layout);
113 elm_object_content_set(ad->conform, ad->layout);
116 ad->nf = elm_naviframe_add(ad->layout);
117 create_list_view(ad);
118 elm_object_part_content_set(ad->layout, "elm.swallow.content", ad->nf);
119 eext_object_event_callback_add(ad->nf, EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL);
120 eext_object_event_callback_add(ad->nf, EEXT_CALLBACK_MORE, eext_naviframe_more_cb, NULL);
122 // Show window after base gui is set up
123 evas_object_show(ad->win);
126 // Configures the OCPlatform
132 PlatformConfig config
133 { OC::ServiceType::InProc, ModeType::Client, "0.0.0.0", 0, OC::QualityOfService::LowQos };
135 OCPlatform::Configure(config);
137 dlog_print(DLOG_INFO, LOG_TAG, "#### Platform configuration done!!!!");
139 catch (OCException &e)
141 dlog_print(DLOG_ERROR, LOG_TAG, "Exception occured! (%s)", e.what());
146 app_create(void *data)
148 /* Hook to take necessary actions before main event loop starts
149 Initialize UI resources and application's data
150 If this function returns true, the main loop of application starts
151 If this function returns false, the application is terminated */
152 appdata_s *ad = (appdata_s *)data;
154 elm_app_base_scale_set(1.8);
158 configure_platform();
164 app_control(app_control_h app_control, void *data)
166 // Handle the launch request.
170 app_pause(void *data)
172 // Take necessary actions when application becomes invisible.
176 app_resume(void *data)
178 // Take necessary actions when application becomes visible.
182 app_terminate(void *data)
184 // Release all resources.
188 ui_app_lang_changed(app_event_info_h event_info, void *user_data)
190 // APP_EVENT_LANGUAGE_CHANGED
192 system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale);
193 elm_language_set(locale);
199 ui_app_orient_changed(app_event_info_h event_info, void *user_data)
201 // APP_EVENT_DEVICE_ORIENTATION_CHANGED
206 ui_app_region_changed(app_event_info_h event_info, void *user_data)
208 // APP_EVENT_REGION_FORMAT_CHANGED
212 ui_app_low_battery(app_event_info_h event_info, void *user_data)
214 // APP_EVENT_LOW_BATTERY
218 ui_app_low_memory(app_event_info_h event_info, void *user_data)
220 // APP_EVENT_LOW_MEMORY
224 main(int argc, char *argv[])
229 ui_app_lifecycle_callback_s event_callback = {0,};
230 app_event_handler_h handlers[5] = {NULL, };
232 event_callback.create = app_create;
233 event_callback.terminate = app_terminate;
234 event_callback.pause = app_pause;
235 event_callback.resume = app_resume;
236 event_callback.app_control = app_control;
238 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY,
239 ui_app_low_battery, &ad);
240 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY,
241 ui_app_low_memory, &ad);
242 ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED],
243 APP_EVENT_DEVICE_ORIENTATION_CHANGED,
244 ui_app_orient_changed, &ad);
245 ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED],
246 APP_EVENT_LANGUAGE_CHANGED,
247 ui_app_lang_changed, &ad);
248 ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED],
249 APP_EVENT_REGION_FORMAT_CHANGED,
250 ui_app_region_changed, &ad);
251 ui_app_remove_event_handler(handlers[APP_EVENT_LOW_MEMORY]);
253 ret = ui_app_main(argc, argv, &event_callback, &ad);
254 if (APP_ERROR_NONE != ret)
256 dlog_print(DLOG_ERROR, LOG_TAG, "app_main() is failed. err = %d", ret);