4 * Copyright 2012 Samsung Electronics Co., Ltd
6 * Contact: Hocheol Seo <hocheol.seo@samsung.com>
7 * Injun Yang <injun.yang@samsung.com>
8 * Seungyoun Ju <sy39.ju@samsung.com>
10 * Licensed under the Flora License, Version 1.1 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.tizenopensource.org/license
16 * Unless required by applicable law or agreed to in writing,
17 * software distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
25 #include <efl_assist.h>
27 #include "bt-connection-main.h"
28 #include "bt-connection-view.h"
29 #include "bt-connection-handler.h"
30 #include "bt-connection-ipc.h"
32 static Evas_Object* _create_win(const char *name)
38 eo = elm_win_add(NULL, name, ELM_WIN_DIALOG_BASIC);
40 elm_win_title_set(eo, name);
41 elm_win_borderless_set(eo, EINA_TRUE);
42 ecore_x_window_size_get(ecore_x_window_root_first_get(),
44 evas_object_resize(eo, w, h);
50 static Eina_Bool _pop_cb(void *data, Elm_Object_Item *it)
62 void __destory_app_cb(void *data, Evas_Object *obj, void *event_info)
67 DBG("EA Back on navi");
69 bt_app_data_t *ad = (bt_app_data_t *)data;
74 static Evas_Object* _create_layout_main(Evas_Object* parent)
81 layout = elm_layout_add(parent);
85 elm_layout_theme_set(layout, "layout", "application", "default");
86 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
87 elm_object_part_content_set(parent, "elm.swallow.content", layout);
88 evas_object_show(layout);
93 static Evas_Object* _create_naviframe(Evas_Object* parent)
95 Evas_Object *naviframe;
99 naviframe = elm_naviframe_add(parent);
100 elm_object_part_content_set(parent, "elm.swallow.content", naviframe);
105 static void _create_view_layout(bt_app_data_t *ad)
107 if (ad == NULL || ad->navi == NULL)
110 ea_object_event_callback_add(ad->navi, EA_CALLBACK_BACK,
111 __destory_app_cb, ad);
113 _bt_create_connection_query_popup(ad);
118 static int __initialize_view(bt_app_data_t *ad)
122 Elm_Object_Item *navi_it;
127 ad->layout_main = _create_layout_main(ad->window);
128 if (!ad->layout_main)
131 ad->navi = _create_naviframe(ad->layout_main);
133 _create_view_layout(ad);
135 navi_it = elm_naviframe_item_push(ad->navi, NULL, NULL, NULL, ad->main_layout, NULL);
136 elm_naviframe_item_title_enabled_set(navi_it, EINA_FALSE, EINA_FALSE);
137 elm_naviframe_item_pop_cb_set(navi_it, _pop_cb, ad);
138 elm_naviframe_item_title_visible_set(navi_it, EINA_FALSE);
145 static bool app_create(void *data)
150 ad = (bt_app_data_t *)data;
152 ad->initialize = FALSE;
153 ad->window = _create_win(PACKAGE);
154 if (ad->window == NULL)
157 evas_object_show(ad->window);
159 /* Handle rotation */
160 if (elm_win_wm_rotation_supported_get(ad->window)) {
161 int rots[4] = {0, 90, 180, 270};
162 elm_win_wm_rotation_available_rotations_set(ad->window,
163 (const int*)(&rots), 4);
166 _bt_register_vconf_handler(ad);
171 static void app_terminate(void *data)
176 bt_app_data_t *ad = (bt_app_data_t *)data;
180 status = _bt_get_wms_status();
181 if (status == WMS_DISCONNECTED) {
182 /* In case WMS_CONNECTED, */
183 /* we sent result on connected view */
184 DBG("App terminiated. Send response (Not Connected)");
185 _bt_send_result(ad, KEY_VAL_NOT_CONNECTED);
188 _bt_get_sap_status(); /* Check sap status */
193 static void app_pause(void *data)
199 static void app_resume(void *data)
205 static void app_service(service_h service, void *data)
212 ad = (bt_app_data_t *)data;
216 if (ad->dbus_conn == NULL) {
217 _bt_dbus_signal_init(ad);
220 ad->service = service;
221 service_clone(&ad->service_clone, service);
222 service_get_caller(service, &caller);
223 DBG_SECURE("Launched by %s", caller);
225 if (__initialize_view(ad) < 0) {
226 ERR("__initialize_view failed");
232 static void app_lang_changed(void *data)
237 static void app_regeion_changed(void *data)
244 * The entry of the program
251 DLL_DEFAULT int main(int argc, char *argv[])
255 app_event_callback_s event_callback;
257 event_callback.create = app_create;
258 event_callback.terminate = app_terminate;
259 event_callback.pause = app_pause;
260 event_callback.resume = app_resume;
261 event_callback.service = app_service;
262 event_callback.low_memory = NULL;
263 event_callback.low_battery = NULL;
264 event_callback.device_orientation = NULL;
265 event_callback.language_changed = app_lang_changed;
266 event_callback.region_format_changed = app_regeion_changed;
268 memset(&ad, 0x0, sizeof(bt_app_data_t));
269 setenv("EVAS_NO_DRI_SWAPBUF", "1", 1);
272 return app_efl_main(&argc, &argv, &event_callback, &ad);