diff options
author | Sehong Na <sehong.na@samsung.com> | 2014-05-31 12:55:16 +0900 |
---|---|---|
committer | Sehong Na <sehong.na@samsung.com> | 2014-05-31 12:55:16 +0900 |
commit | bcf0ca94c63e34ade6a0428f3047384f17adb2aa (patch) | |
tree | 115ecdb76d31814d445f5ea1c07d0a63260ae308 /src/bt-connection-main.c | |
download | bt-connection-popup-tizen_2.3.tar.gz bt-connection-popup-tizen_2.3.tar.bz2 bt-connection-popup-tizen_2.3.zip |
Initialize Tizen 2.3submit/tizen_2.3/20140531.1025112.3a_releasetizen_2.3
Diffstat (limited to 'src/bt-connection-main.c')
-rw-r--r-- | src/bt-connection-main.c | 274 |
1 files changed, 274 insertions, 0 deletions
diff --git a/src/bt-connection-main.c b/src/bt-connection-main.c new file mode 100644 index 0000000..96df31d --- /dev/null +++ b/src/bt-connection-main.c @@ -0,0 +1,274 @@ +/* +* bt-connection-popup +* +* Copyright 2012 Samsung Electronics Co., Ltd +* +* Contact: Hocheol Seo <hocheol.seo@samsung.com> +* Injun Yang <injun.yang@samsung.com> +* Seungyoun Ju <sy39.ju@samsung.com> +* +* Licensed under the Flora License, Version 1.1 (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.tizenopensource.org/license +* +* 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 <app.h> +#include <efl_assist.h> + +#include "bt-connection-main.h" +#include "bt-connection-view.h" +#include "bt-connection-handler.h" +#include "bt-connection-ipc.h" + +static Evas_Object* _create_win(const char *name) +{ + Evas_Object *eo; + int w; + int h; + + eo = elm_win_add(NULL, name, ELM_WIN_DIALOG_BASIC); + if (eo) { + elm_win_title_set(eo, name); + elm_win_borderless_set(eo, EINA_TRUE); + ecore_x_window_size_get(ecore_x_window_root_first_get(), + &w, &h); + evas_object_resize(eo, w, h); + } + + return eo; +} + +static Eina_Bool _pop_cb(void *data, Elm_Object_Item *it) +{ + DBG(""); + + if (!data) { + return EINA_FALSE; + } + + elm_exit(); + return EINA_FALSE; +} + +void __destory_app_cb(void *data, Evas_Object *obj, void *event_info) +{ + if (data == NULL) + return; + + DBG("EA Back on navi"); + + bt_app_data_t *ad = (bt_app_data_t *)data; + + _bt_destroy_app(ad); +} + +static Evas_Object* _create_layout_main(Evas_Object* parent) +{ + Evas_Object *layout; + + if (parent == NULL) + return NULL; + + layout = elm_layout_add(parent); + if (layout == NULL) + return NULL; + + elm_layout_theme_set(layout, "layout", "application", "default"); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_object_part_content_set(parent, "elm.swallow.content", layout); + evas_object_show(layout); + + return layout; +} + +static Evas_Object* _create_naviframe(Evas_Object* parent) +{ + Evas_Object *naviframe; + + if (parent == NULL) + return NULL; + naviframe = elm_naviframe_add(parent); + elm_object_part_content_set(parent, "elm.swallow.content", naviframe); + + return naviframe; +} + +static void _create_view_layout(bt_app_data_t *ad) +{ + if (ad == NULL || ad->navi == NULL) + return; + + ea_object_event_callback_add(ad->navi, EA_CALLBACK_BACK, + __destory_app_cb, ad); + + _bt_create_connection_query_popup(ad); + + DBG("-"); +} + +static int __initialize_view(bt_app_data_t *ad) +{ + DBG("+"); + + Elm_Object_Item *navi_it; + + if (ad == NULL) + return -1; + + ad->layout_main = _create_layout_main(ad->window); + if (!ad->layout_main) + return -1; + + ad->navi = _create_naviframe(ad->layout_main); + + _create_view_layout(ad); + + navi_it = elm_naviframe_item_push(ad->navi, NULL, NULL, NULL, ad->main_layout, NULL); + elm_naviframe_item_title_enabled_set(navi_it, EINA_FALSE, EINA_FALSE); + elm_naviframe_item_pop_cb_set(navi_it, _pop_cb, ad); + elm_naviframe_item_title_visible_set(navi_it, EINA_FALSE); + + DBG("-"); + + return 0; +} + +static bool app_create(void *data) +{ + DBG(""); + + bt_app_data_t *ad; + ad = (bt_app_data_t *)data; + + ad->initialize = FALSE; + ad->window = _create_win(PACKAGE); + if (ad->window == NULL) + return FALSE; + + evas_object_show(ad->window); + + /* Handle rotation */ + if (elm_win_wm_rotation_supported_get(ad->window)) { + int rots[4] = {0, 90, 180, 270}; + elm_win_wm_rotation_available_rotations_set(ad->window, + (const int*)(&rots), 4); + } + + _bt_register_vconf_handler(ad); + + return TRUE; +} + +static void app_terminate(void *data) +{ + DBG(""); + + int status; + bt_app_data_t *ad = (bt_app_data_t *)data; + if (ad == NULL) + return; + + status = _bt_get_wms_status(); + if (status == WMS_DISCONNECTED) { + /* In case WMS_CONNECTED, */ + /* we sent result on connected view */ + DBG("App terminiated. Send response (Not Connected)"); + _bt_send_result(ad, KEY_VAL_NOT_CONNECTED); + } + + _bt_get_sap_status(); /* Check sap status */ + + return; +} + +static void app_pause(void *data) +{ + DBG(""); + return; +} + +static void app_resume(void *data) +{ + DBG(""); + return; +} + +static void app_service(service_h service, void *data) +{ + DBG(""); + + char *caller = NULL; + bt_app_data_t *ad; + + ad = (bt_app_data_t *)data; + if (ad == NULL) + return; + + if (ad->dbus_conn == NULL) { + _bt_dbus_signal_init(ad); + } + + ad->service = service; + service_clone(&ad->service_clone, service); + service_get_caller(service, &caller); + DBG_SECURE("Launched by %s", caller); + + if (__initialize_view(ad) < 0) { + ERR("__initialize_view failed"); + } + + return; +} + +static void app_lang_changed(void *data) +{ + return; +} + +static void app_regeion_changed(void *data) +{ + return; +} + +/** +* @describe +* The entry of the program +* +* @param argc +* @param argv +* @param int +* @exception +*/ +DLL_DEFAULT int main(int argc, char *argv[]) +{ + bt_app_data_t ad; + + app_event_callback_s event_callback; + + event_callback.create = app_create; + event_callback.terminate = app_terminate; + event_callback.pause = app_pause; + event_callback.resume = app_resume; + event_callback.service = app_service; + event_callback.low_memory = NULL; + event_callback.low_battery = NULL; + event_callback.device_orientation = NULL; + event_callback.language_changed = app_lang_changed; + event_callback.region_format_changed = app_regeion_changed; + + memset(&ad, 0x0, sizeof(bt_app_data_t)); + setenv("EVAS_NO_DRI_SWAPBUF", "1", 1); + + DBG(""); + return app_efl_main(&argc, &argv, &event_callback, &ad); + +} |