From: Hermet Park Date: Tue, 31 May 2016 13:47:56 +0000 (+0900) Subject: promote from ui_base_app to ui_iface_app. X-Git-Tag: submit/tizen/20160617.075742~25 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F52%2F72352%2F2;p=platform%2Fcore%2Fuifw%2Fui-viewmgr.git promote from ui_base_app to ui_iface_app. Change-Id: I2f3cdb85f12d1ec0d508c36503fa946ef83edeed --- diff --git a/src/include/efl/mobile/ui_app.h b/src/include/efl/mobile/ui_app.h index 61d314b..b09de41 100644 --- a/src/include/efl/mobile/ui_app.h +++ b/src/include/efl/mobile/ui_app.h @@ -22,7 +22,7 @@ namespace efl_viewmanager class ui_viewmgr; -class ui_app : public ui_base_app +class ui_app : public ui_iface_app { public: /** diff --git a/src/include/efl/ui_base_app.h b/src/include/efl/ui_base_app.h deleted file mode 100644 index 7f50d57..0000000 --- a/src/include/efl/ui_base_app.h +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) 2016 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. - * - */ -#ifndef _UI_BASE_APP_H_ -#define _UI_BASE_APP_H_ - -namespace efl_viewmanager -{ - -class ui_base_viewmgr; - -class ui_base_app -{ -public: - /** - * @brief This is a constructor for initializing ui_base_app. - * - * @param pkg The name of package. - * @param loale_dir The path of locale directory. - * @param viewmgr instance of ui_viewmgr. - */ - ui_base_app(const char *pkg, const char *locale_dir, ui_base_viewmgr *viewmgr); - - ///Destructor. - virtual ~ui_base_app(); - - /** - * @brief Return the viewmgr instance. - * - * @return ui_viewmgr instance. - */ - ui_base_viewmgr *get_viewmgr(); - - /** - * @brief Return ui_base_app instance. - * - * @return The instance of ui_base_app. - */ - static ui_base_app *get_instance(); - - /** - * @brief Application life-cycle start and add application event callback functions add. - * - * @note This is calling ui_base_app_main function to start application life-cycle start. - * and adding all of the functions for application events handling such as - * create, terminate, pause, resume, app_control, APP_EVENT_LOW_BATTERY, APP_EVENT_LOW_MEMORY - * APP_EVENT_DEVICE_ORIENTATION_CHANGED, APP_EVENT_LANGUAGE_CHANGED, APP_EVENT_REGION_FORMAT_CHANGED. - * Application can add those events using wrapping functions by viewmgr supported. - */ - virtual int run(int argc, char **argv); - -protected: - /** - * @brief Calling before the main event loop start. - * - * @note Take necessary actions like a Initialize UI resources and application data. - * - * @return If this function returns true, the application main loop starts. - * If this function returns false, the application terminates. - */ - virtual bool on_create(); - - /** - * @brief Calling before the main event loop finish. - * - * @note Release all resources here. - */ - virtual void on_terminate(); - - /** - * @brief Calling when application becomes invisible. - */ - virtual void on_pause(); - - /** - * @brief Calling when application becomes visible. - */ - virtual void on_resume(); - - /** - * @brief Calling when gets a launch request event. - * - * @param app_control_h The instance of app_control_h. - */ - virtual void on_control(app_control_h app_control); - - /** - * @brief Calling when device low battery. - * - * @param app_event_info_h The instance of app_event_info_h. - */ - virtual void on_low_battery(app_event_info_h event_info); - - /** - * @brief Calling when device low memory. - * - * @param app_event_info_h The instance of app_event_info_h. - */ - virtual void on_low_memory(app_event_info_h event_info); - - /** - * @brief Calling when device region changed. - * - * @param app_event_info_h The instance of app_event_info_h. - */ - virtual void on_region_changed(app_event_info_h event_info); - - /** - * @brief Calling when device orient changed. - * - * @param app_event_info_h The instance of app_event_info_h. - */ - virtual void on_orient_changed(app_event_info_h event_info); - - /** - * @brief Calling when language changed. - * - * @param app_event_info_h The instance of app_event_info_h. - */ - virtual void on_lang_changed(app_event_info_h event_info); - -private: - _UI_DECLARE_PRIVATE_IMPL(ui_base_app); - _UI_DISABLE_COPY_AND_ASSIGN(ui_base_app); -}; - -} - -#endif /* _UI_BASE_APP_H_ */ diff --git a/src/include/efl/ui_base_viewmanager.h b/src/include/efl/ui_base_viewmanager.h index 5c715c4..6b5f37e 100644 --- a/src/include/efl/ui_base_viewmanager.h +++ b/src/include/efl/ui_base_viewmanager.h @@ -22,13 +22,11 @@ #define Elm_Conformant Evas_Object #endif -#include #include "../interface/ui_iface_viewmanager.h" #include "ui_base_overlay.h" #include "ui_base_key_listener.h" #include "ui_base_viewmgr.h" #include "ui_base_view.h" -#include "ui_base_app.h" #define UI_BASE_VIEWMGR dynamic_cast(ui_iface_viewmgr::get_instance()) diff --git a/src/include/efl/ui_base_viewmgr.h b/src/include/efl/ui_base_viewmgr.h index c124368..b44fdc8 100644 --- a/src/include/efl/ui_base_viewmgr.h +++ b/src/include/efl/ui_base_viewmgr.h @@ -192,7 +192,6 @@ private: _UI_DECLARE_PRIVATE_IMPL(ui_base_viewmgr); _UI_DISABLE_COPY_AND_ASSIGN(ui_base_viewmgr); _UI_DECLARE_FRIENDS(ui_base_view); - _UI_DECLARE_FRIENDS(ui_base_app); }; } diff --git a/src/include/interface/ui_iface_app.h b/src/include/interface/ui_iface_app.h new file mode 100644 index 0000000..6eb4aa3 --- /dev/null +++ b/src/include/interface/ui_iface_app.h @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2016 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. + * + */ +#ifndef _UI_IFACE_APP_H_ +#define _UI_IFACE_APP_H_ + +namespace ui_viewmanager { + +class ui_iface_viewmgr; + +class ui_iface_app +{ +public: + /** + * @brief This is a constructor for initializing ui_iface_app. + * + * @param pkg The name of package. + * @param loale_dir The path of locale directory. + * @param viewmgr instance of ui_viewmgr. + */ + ui_iface_app(const char *pkg, const char *locale_dir, ui_iface_viewmgr *viewmgr); + + ///Destructor. + virtual ~ui_iface_app(); + + /** + * @brief Return the viewmgr instance. + * + * @return ui_iface_viewmgr instance. + */ + ui_iface_viewmgr *get_viewmgr(); + + /** + * @brief Return ui_iface_app instance. + * + * @return The instance of ui_iface_app. + */ + static ui_iface_app *get_instance(); + + /** + * @brief Application life-cycle start and add application event callback functions add. + * + * @note This is calling ui_app_main function to start application life-cycle start. + * and adding all of the functions for application events handling such as + * create, terminate, pause, resume, app_control, APP_EVENT_LOW_BATTERY, APP_EVENT_LOW_MEMORY + * APP_EVENT_DEVICE_ORIENTATION_CHANGED, APP_EVENT_LANGUAGE_CHANGED, APP_EVENT_REGION_FORMAT_CHANGED. + * Application can add those events using wrapping functions by viewmgr supported. + */ + virtual int run(int argc, char **argv); + +protected: + /** + * @brief Calling before the main event loop start. + * + * @note Take necessary actions like a Initialize UI resources and application data. + * + * @return If this function returns true, the application main loop starts. + * If this function returns false, the application terminates. + */ + virtual bool on_create(); + + /** + * @brief Calling before the main event loop finish. + * + * @note Release all resources here. + */ + virtual void on_terminate(); + + /** + * @brief Calling when application becomes invisible. + */ + virtual void on_pause(); + + /** + * @brief Calling when application becomes visible. + */ + virtual void on_resume(); + + /** + * @brief Calling when gets a launch request event. + * + * @param app_control_h The instance of app_control_h. + */ + virtual void on_control(app_control_h app_control); + + /** + * @brief Calling when device low battery. + * + * @param app_event_info_h The instance of app_event_info_h. + */ + virtual void on_low_battery(app_event_info_h event_info); + + /** + * @brief Calling when device low memory. + * + * @param app_event_info_h The instance of app_event_info_h. + */ + virtual void on_low_memory(app_event_info_h event_info); + + /** + * @brief Calling when device region changed. + * + * @param app_event_info_h The instance of app_event_info_h. + */ + virtual void on_region_changed(app_event_info_h event_info); + + /** + * @brief Calling when device orient changed. + * + * @param app_event_info_h The instance of app_event_info_h. + */ + virtual void on_orient_changed(app_event_info_h event_info); + + /** + * @brief Calling when language changed. + * + * @param app_event_info_h The instance of app_event_info_h. + */ + virtual void on_lang_changed(app_event_info_h event_info); + +private: + _UI_DECLARE_PRIVATE_IMPL(ui_iface_app); + _UI_DISABLE_COPY_AND_ASSIGN(ui_iface_app); +}; + +} + +#endif /* _UI_IFACE_APP_H_ */ diff --git a/src/include/interface/ui_iface_singleton.h b/src/include/interface/ui_iface_singleton.h deleted file mode 100644 index d351ad2..0000000 --- a/src/include/interface/ui_iface_singleton.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef _UI_IFACE_SINGLETON_H_ -#define _UI_IFACE_SINGLETON_H_ - -namespace ui_viewmanager -{ - -template -class singleton -{ -private: - static XX* inst; - -public: - singleton(); - virtual ~singleton(); - inline static XX* get_instance(); -}; - -template XX* singleton::inst = NULL; - -template -singleton::singleton() -{ - XX* pT = reinterpret_cast(1); - - //Derived Class - Singleton class - int offset = reinterpret_cast(pT) - reinterpret_cast(reinterpret_cast*>(pT)); - singleton::inst = reinterpret_cast((reinterpret_cast(this) + offset)); -} - -template -singleton::~singleton() -{ - singleton::inst = NULL; -} - -template -XX* singleton::get_instance() -{ - return singleton::inst; -} - -} - -#endif /* _UI_IFACE_SINGLETON_H_ */ diff --git a/src/include/interface/ui_iface_viewmanager.h b/src/include/interface/ui_iface_viewmanager.h index 7ebe660..a6ecb93 100644 --- a/src/include/interface/ui_iface_viewmanager.h +++ b/src/include/interface/ui_iface_viewmanager.h @@ -70,11 +70,12 @@ enum ui_view_state A(const A&) = delete; \ const A& operator=(const A&) = delete -#include "ui_iface_singleton.h" +#include #include "ui_iface_rotatable.h" #include "ui_iface_overlay.h" #include "ui_iface_view.h" #include "ui_iface_viewmgr.h" +#include "ui_iface_app.h" using namespace ui_viewmanager; diff --git a/src/include/interface/ui_iface_viewmgr.h b/src/include/interface/ui_iface_viewmgr.h index fab8329..e889f9e 100644 --- a/src/include/interface/ui_iface_viewmgr.h +++ b/src/include/interface/ui_iface_viewmgr.h @@ -45,7 +45,7 @@ public: * * @see deactivate() */ - bool activate(); + virtual bool activate(); /** * @brief Deactivate this view manager. @@ -57,7 +57,7 @@ public: * * @see activate() */ - bool deactivate(); + virtual bool deactivate(); /** * @brief Return the active status of viewmgr. @@ -248,6 +248,7 @@ private: _UI_DECLARE_PRIVATE_IMPL(ui_iface_viewmgr); _UI_DISABLE_COPY_AND_ASSIGN(ui_iface_viewmgr); _UI_DECLARE_FRIENDS(ui_iface_view); + _UI_DECLARE_FRIENDS(ui_iface_app); }; } diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 150b892..65d8292 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -2,7 +2,7 @@ SET(SRCS interface/ui_iface_overlay.cpp interface/ui_iface_view.cpp interface/ui_iface_viewmgr.cpp - efl/ui_base_app.cpp + interface/ui_iface_app.cpp efl/ui_base_view.cpp efl/ui_base_viewmgr.cpp efl/ui_base_key_listener.cpp diff --git a/src/lib/efl/mobile/ui_app.cpp b/src/lib/efl/mobile/ui_app.cpp index ce71b9e..6ff5157 100644 --- a/src/lib/efl/mobile/ui_app.cpp +++ b/src/lib/efl/mobile/ui_app.cpp @@ -14,7 +14,6 @@ * limitations under the License. * */ -#include #include "../../../include/efl/mobile/ui_mobile_viewmanager.h" /***********************************************************************************************/ @@ -26,7 +25,7 @@ /***********************************************************************************************/ ui_app::ui_app(const char *pkg, const char *locale_dir) - : ui_base_app(pkg, locale_dir, new ui_viewmgr(pkg)) + : ui_iface_app(pkg, locale_dir, new ui_viewmgr(pkg)) { } @@ -36,10 +35,10 @@ ui_app::~ui_app() ui_viewmgr *ui_app::get_viewmgr() { - return dynamic_cast(ui_base_app::get_viewmgr()); + return dynamic_cast(ui_iface_app::get_viewmgr()); } ui_app *ui_app::get_instance() { - return dynamic_cast(ui_base_app::get_instance()); + return dynamic_cast(ui_iface_app::get_instance()); } diff --git a/src/lib/efl/ui_base_app.cpp b/src/lib/efl/ui_base_app.cpp deleted file mode 100644 index 6e43db9..0000000 --- a/src/lib/efl/ui_base_app.cpp +++ /dev/null @@ -1,311 +0,0 @@ -/* - * Copyright (c) 2016 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/efl/ui_base_viewmanager.h" - -/***********************************************************************************************/ -/* Internal class Implementation */ -/***********************************************************************************************/ -namespace efl_viewmanager -{ - -class ui_base_app_impl -{ -public: - friend class ui_base_app; - - ui_base_app *app; - ui_base_viewmgr *viewmgr; - Eina_Stringshare *pkg; - Eina_Stringshare *locale_dir; - - ui_base_app_impl(ui_base_app *app, const char *pkg, const char *locale_dir, ui_base_viewmgr* viewmgr); - ~ui_base_app_impl(); - - int run(int argc, char **argv); - - bool init(); - bool on_create(); - void on_terminate(); - void on_pause(); - void on_resume(); - void on_control(app_control_h app_control); - void on_low_battery(app_event_info_h event_info); - void on_low_memory(app_event_info_h event_info); - void on_region_changed(app_event_info_h event_info); - void on_orient_changed(app_event_info_h event_info); - void on_lang_changed(app_event_info_h event_info); -}; - -} - -static bool app_create(void *data) -{ - ui_base_app_impl *app = static_cast(data); - return app->on_create(); -} - -static void app_terminate(void *data) -{ - ui_base_app_impl *app = static_cast(data); - app->on_terminate(); -} - -static void app_pause(void *data) -{ - ui_base_app_impl *app = static_cast(data); - app->on_pause(); -} - -static void app_resume(void *data) -{ - ui_base_app_impl *app = static_cast(data); - app->on_resume(); -} - -static void app_control(app_control_s *app_control, void *data) -{ - ui_base_app_impl *app = static_cast(data); - app->on_control(app_control); -} - -static void ui_app_lang_changed(app_event_info_h event_info, void *data) -{ - ui_base_app_impl *app = static_cast(data); - app->on_lang_changed(event_info); -} - -static void ui_app_orient_changed(app_event_info_h event_info, void *data) -{ - ui_base_app_impl *app = static_cast(data); - app->on_orient_changed(event_info); -} - -static void ui_app_region_changed(app_event_info_h event_info, void *data) -{ - ui_base_app_impl *app = static_cast(data); - app->on_region_changed(event_info); -} - -static void ui_app_low_battery(app_event_info_h event_info, void *data) -{ - ui_base_app_impl *app = static_cast(data); - app->on_low_battery(event_info); -} - -static void ui_app_low_memory(app_event_info_h event_info, void *data) -{ - ui_base_app_impl *app = static_cast(data); - app->on_low_memory(event_info); -} - -bool ui_base_app_impl::init() -{ - //FIXME: this scale value should be configurable. - elm_app_base_scale_set(2.6); - - /* Bind package locale file */ - bindtextdomain(this->pkg, this->locale_dir); - textdomain(this->pkg); - - return true; -} - -ui_base_app_impl::ui_base_app_impl(ui_base_app *app, const char *pkg, const char *locale_dir, ui_base_viewmgr *viewmgr) - : app(app), viewmgr(viewmgr) -{ - this->pkg = eina_stringshare_add(pkg); - this->locale_dir = eina_stringshare_add(locale_dir); -} - -int ui_base_app_impl::run(int argc, char **argv) -{ - ui_app_lifecycle_callback_s event_callback = - { 0, }; - app_event_handler_h handlers[5] = - { NULL, }; - - event_callback.create = app_create; - event_callback.terminate = app_terminate; - event_callback.pause = app_pause; - event_callback.resume = app_resume; - event_callback.app_control = app_control; - - ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, ui_app_low_battery, this); - ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, ui_app_low_memory, this); - ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, ui_app_orient_changed, this); - ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, ui_app_lang_changed, this); - ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, ui_app_region_changed, this); - - int ret = ui_app_main(argc, argv, &event_callback, this); - - if (ret != APP_ERROR_NONE) - { - LOGE("ui_app_main() is failed. err = %d", ret); - } - - return ret; -} - -ui_base_app_impl::~ui_base_app_impl() -{ - delete (this->viewmgr); - eina_stringshare_del(this->pkg); - eina_stringshare_del(this->locale_dir); -} - -void ui_base_app_impl::on_lang_changed(app_event_info_h event_info) -{ - this->app->on_lang_changed(event_info); -} - -void ui_base_app_impl::on_low_memory(app_event_info_h event_info) -{ - this->app->on_low_memory(event_info); -} - -void ui_base_app_impl::on_low_battery(app_event_info_h event_info) -{ - this->app->on_low_battery(event_info); -} - -void ui_base_app_impl::on_region_changed(app_event_info_h event_info) -{ - this->app->on_region_changed(event_info); -} - -void ui_base_app_impl::on_orient_changed(app_event_info_h event_info) -{ - this->app->on_orient_changed(event_info); -} - -bool ui_base_app_impl::on_create() -{ - return this->app->on_create(); -} - -void ui_base_app_impl::on_pause() -{ - this->app->on_pause(); -} - -void ui_base_app_impl::on_resume() -{ - this->app->on_resume(); -} - -void ui_base_app_impl::on_control(app_control_h app_control) -{ - this->app->on_control(app_control); -} - -void ui_base_app_impl::on_terminate() -{ - this->app->on_terminate(); -} - -/***********************************************************************************************/ -/* External class Implementation */ -/***********************************************************************************************/ - -static ui_base_app *inst = NULL; - -void ui_base_app::on_lang_changed(app_event_info_h event_info) -{ - char *locale = NULL; - system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale); - elm_language_set(locale); - free(locale); -} - -void ui_base_app::on_low_memory(app_event_info_h event_info) -{ - -} - -void ui_base_app::on_low_battery(app_event_info_h event_info) -{ - -} - -void ui_base_app::on_region_changed(app_event_info_h event_info) -{ - -} - -void ui_base_app::on_orient_changed(app_event_info_h event_info) -{ - -} - -bool ui_base_app::on_create() -{ - return this->impl->init(); -} - -void ui_base_app::on_pause() -{ - this->impl->viewmgr->deactivate(); -} - -void ui_base_app::on_resume() -{ -// this->impl->viewmgr->activate(); -} - -void ui_base_app::on_control(app_control_h app_control) -{ - /* Handle the launch request. */ - this->impl->viewmgr->activate(); -} - -void ui_base_app::on_terminate() -{ - delete(this); -} - -ui_base_app::ui_base_app(const char *pkg, const char *locale_dir, ui_base_viewmgr *viewmgr) -{ - if (inst) - { - LOGE("You created ui_base_app multiple times!!"); - } - inst = this; - - this->impl = new ui_base_app_impl(this, pkg, locale_dir, viewmgr); -} - -int ui_base_app::run(int argc, char **argv) -{ - return this->impl->run(argc, argv); -} - -ui_base_app::~ui_base_app() -{ - delete (this->impl); - inst = NULL; -} - -ui_base_viewmgr *ui_base_app::get_viewmgr() -{ - return this->impl->viewmgr; -} - -ui_base_app *ui_base_app::get_instance() -{ - return inst; -} diff --git a/src/lib/interface/ui_iface_app.cpp b/src/lib/interface/ui_iface_app.cpp new file mode 100644 index 0000000..ecaec2d --- /dev/null +++ b/src/lib/interface/ui_iface_app.cpp @@ -0,0 +1,311 @@ +/* + * Copyright (c) 2016 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/interface/ui_iface_viewmanager.h" + +/***********************************************************************************************/ +/* Internal class Implementation */ +/***********************************************************************************************/ +namespace ui_viewmanager +{ + +class ui_iface_app_impl +{ +public: + friend class ui_iface_app; + + ui_iface_app *app; + ui_iface_viewmgr *viewmgr; + Eina_Stringshare *pkg; + Eina_Stringshare *locale_dir; + + ui_iface_app_impl(ui_iface_app *app, const char *pkg, const char *locale_dir, ui_iface_viewmgr* viewmgr); + ~ui_iface_app_impl(); + + int run(int argc, char **argv); + + bool init(); + bool on_create(); + void on_terminate(); + void on_pause(); + void on_resume(); + void on_control(app_control_h app_control); + + // + void on_low_battery(app_event_info_h event_info); + void on_low_memory(app_event_info_h event_info); + void on_region_changed(app_event_info_h event_info); + void on_orient_changed(app_event_info_h event_info); + void on_lang_changed(app_event_info_h event_info); +}; + +} + +static bool app_create(void *data) +{ + ui_iface_app_impl *app = static_cast(data); + return app->on_create(); +} + +static void app_terminate(void *data) +{ + ui_iface_app_impl *app = static_cast(data); + app->on_terminate(); +} + +static void app_pause(void *data) +{ + ui_iface_app_impl *app = static_cast(data); + app->on_pause(); +} + +static void app_resume(void *data) +{ + ui_iface_app_impl *app = static_cast(data); + app->on_resume(); +} + +static void app_control(app_control_s *app_control, void *data) +{ + ui_iface_app_impl *app = static_cast(data); + app->on_control(app_control); +} + +static void ui_app_lang_changed(app_event_info_h event_info, void *data) +{ + ui_iface_app_impl *app = static_cast(data); + app->on_lang_changed(event_info); +} + +static void ui_app_orient_changed(app_event_info_h event_info, void *data) +{ + ui_iface_app_impl *app = static_cast(data); + app->on_orient_changed(event_info); +} + +static void ui_app_region_changed(app_event_info_h event_info, void *data) +{ + ui_iface_app_impl *app = static_cast(data); + app->on_region_changed(event_info); +} + +static void ui_app_low_battery(app_event_info_h event_info, void *data) +{ + ui_iface_app_impl *app = static_cast(data); + app->on_low_battery(event_info); +} + +static void ui_app_low_memory(app_event_info_h event_info, void *data) +{ + ui_iface_app_impl *app = static_cast(data); + app->on_low_memory(event_info); +} + +bool ui_iface_app_impl::init() +{ + //FIXME: this scale value should be configurable. + elm_app_base_scale_set(2.6); + + /* Bind package locale file */ + bindtextdomain(this->pkg, this->locale_dir); + textdomain(this->pkg); + + return true; +} + +ui_iface_app_impl::ui_iface_app_impl(ui_iface_app *app, const char *pkg, const char *locale_dir, ui_iface_viewmgr *viewmgr) + : app(app), viewmgr(viewmgr) +{ + this->pkg = eina_stringshare_add(pkg); + this->locale_dir = eina_stringshare_add(locale_dir); +} + +int ui_iface_app_impl::run(int argc, char **argv) +{ + ui_app_lifecycle_callback_s event_callback = { 0, }; + app_event_handler_h handlers[5] = { NULL, }; + + event_callback.create = app_create; + event_callback.terminate = app_terminate; + event_callback.pause = app_pause; + event_callback.resume = app_resume; + event_callback.app_control = app_control; + + ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, ui_app_low_battery, this); + ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, ui_app_low_memory, this); + ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, ui_app_orient_changed, this); + ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, ui_app_lang_changed, this); + ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, ui_app_region_changed, this); + + int ret = ui_app_main(argc, argv, &event_callback, this); + + if (ret != APP_ERROR_NONE) + { + LOGE("ui_app_main() is failed. err = %d", ret); + } + + return ret; +} + +ui_iface_app_impl::~ui_iface_app_impl() +{ + delete (this->viewmgr); + eina_stringshare_del(this->pkg); + eina_stringshare_del(this->locale_dir); +} + +void ui_iface_app_impl::on_lang_changed(app_event_info_h event_info) +{ + this->app->on_lang_changed(event_info); +} + +void ui_iface_app_impl::on_low_memory(app_event_info_h event_info) +{ + this->app->on_low_memory(event_info); +} + +void ui_iface_app_impl::on_low_battery(app_event_info_h event_info) +{ + this->app->on_low_battery(event_info); +} + +void ui_iface_app_impl::on_region_changed(app_event_info_h event_info) +{ + this->app->on_region_changed(event_info); +} + +void ui_iface_app_impl::on_orient_changed(app_event_info_h event_info) +{ + this->app->on_orient_changed(event_info); +} + +bool ui_iface_app_impl::on_create() +{ + return this->app->on_create(); +} + +void ui_iface_app_impl::on_pause() +{ + this->app->on_pause(); +} + +void ui_iface_app_impl::on_resume() +{ + this->app->on_resume(); +} + +void ui_iface_app_impl::on_control(app_control_h app_control) +{ + this->app->on_control(app_control); +} + +void ui_iface_app_impl::on_terminate() +{ + this->app->on_terminate(); +} + +/***********************************************************************************************/ +/* External class Implementation */ +/***********************************************************************************************/ + +static ui_iface_app *inst = NULL; + +void ui_iface_app::on_lang_changed(app_event_info_h event_info) +{ + char *locale = NULL; + system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale); + elm_language_set(locale); + free(locale); +} + +void ui_iface_app::on_low_memory(app_event_info_h event_info) +{ + +} + +void ui_iface_app::on_low_battery(app_event_info_h event_info) +{ + +} + +void ui_iface_app::on_region_changed(app_event_info_h event_info) +{ + +} + +void ui_iface_app::on_orient_changed(app_event_info_h event_info) +{ + +} + +bool ui_iface_app::on_create() +{ + return this->impl->init(); +} + +void ui_iface_app::on_pause() +{ + this->impl->viewmgr->deactivate(); +} + +void ui_iface_app::on_resume() +{ +// this->impl->viewmgr->activate(); +} + +void ui_iface_app::on_control(app_control_h app_control) +{ + /* Handle the launch request. */ + this->impl->viewmgr->activate(); +} + +void ui_iface_app::on_terminate() +{ + delete(this); +} + +ui_iface_app::ui_iface_app(const char *pkg, const char *locale_dir, ui_iface_viewmgr *viewmgr) +{ + if (inst) + { + LOGE("You created ui_iface_app multiple times!!"); + } + inst = this; + + this->impl = new ui_iface_app_impl(this, pkg, locale_dir, viewmgr); +} + +int ui_iface_app::run(int argc, char **argv) +{ + return this->impl->run(argc, argv); +} + +ui_iface_app::~ui_iface_app() +{ + delete (this->impl); + inst = NULL; +} + +ui_iface_viewmgr *ui_iface_app::get_viewmgr() +{ + return this->impl->viewmgr; +} + +ui_iface_app *ui_iface_app::get_instance() +{ + return inst; +}