From fd2c08c11eda09dd6a5aeb64e02edd4fc96237fe Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Thu, 3 Nov 2016 13:26:28 +0900 Subject: [PATCH] ui_app: update ui_application_init() API. remove pkg, locale_dir parameters. it's not mandatory for users. Change-Id: Id865837dae6ac3cf01119f32dd74ae9a6006f378 --- src/examples/efl/c/main.cpp | 2 +- src/examples/efl/cpp/main.cpp | 2 +- src/include/efl/UiBaseViewmgr.h | 7 ++---- src/include/efl/mobile/UiApp.h | 5 +---- src/include/efl/mobile/UiViewmgr.h | 5 +---- src/include/efl/mobile/c/ui_application.h | 5 +---- src/include/interface/UiIfaceApp.h | 4 +--- src/lib/efl/UiBaseViewmgr.cpp | 22 ++++++++++-------- src/lib/efl/mobile/UiApp.cpp | 4 ++-- src/lib/efl/mobile/UiViewmgr.cpp | 4 ++-- src/lib/efl/mobile/c/ui_application.cpp | 8 +++---- src/lib/interface/UiIfaceApp.cpp | 27 +++++------------------ 12 files changed, 35 insertions(+), 60 deletions(-) diff --git a/src/examples/efl/c/main.cpp b/src/examples/efl/c/main.cpp index 0d09827..89779d8 100644 --- a/src/examples/efl/c/main.cpp +++ b/src/examples/efl/c/main.cpp @@ -34,7 +34,7 @@ main(int argc, char *argv[]) int ret; //Initialize ui_app. ui_app initializes basic resources including ui_viewmgr internally. - ret = ui_application_init(PACKAGE, LOCALE_DIR); + ret = ui_application_init(); if (ret != UI_VIEWMGR_ERROR_NONE) { dlog_print(DLOG_ERROR, LOG_TAG, "ui_app_init() is failed, ret = %d", ret); diff --git a/src/examples/efl/cpp/main.cpp b/src/examples/efl/cpp/main.cpp index 272935f..c8a6c7e 100644 --- a/src/examples/efl/cpp/main.cpp +++ b/src/examples/efl/cpp/main.cpp @@ -36,7 +36,7 @@ class SampleApp: public UiApp { public: SampleApp() - : UiApp(PACKAGE, LOCALE_DIR) + : UiApp() { } ~SampleApp() diff --git a/src/include/efl/UiBaseViewmgr.h b/src/include/efl/UiBaseViewmgr.h index 6c22684..dc34058 100644 --- a/src/include/efl/UiBaseViewmgr.h +++ b/src/include/efl/UiBaseViewmgr.h @@ -217,23 +217,20 @@ protected: /** * @brief This is a constructor for initializing viewmgr. * - * @param[in] pkg The name of package. * @param[in] key_listener The instance of UiBaseKeyListener. */ - UiBaseViewmgr(const char *pkg, UiBaseKeyListener *keyListener); + UiBaseViewmgr(UiBaseKeyListener *keyListener); /** * @brief This is a constructor for initializing viewmgr. * - * @param[in] pkg The name of package. */ - explicit UiBaseViewmgr(const char *pkg); + UiBaseViewmgr(); ///Destructor. virtual ~UiBaseViewmgr(); public: - _UI_DISABLE_DEFAULT_CTOR(UiBaseViewmgr); _UI_DISABLE_COPY_AND_ASSIGN(UiBaseViewmgr); private: diff --git a/src/include/efl/mobile/UiApp.h b/src/include/efl/mobile/UiApp.h index dfffd92..a9d15e0 100644 --- a/src/include/efl/mobile/UiApp.h +++ b/src/include/efl/mobile/UiApp.h @@ -39,10 +39,8 @@ public: /** * @brief This is a constructor for initializing UiApp. * - * @param[in] pkg The name of package. - * @param[in] loale_dir The path of locale directory. */ - UiApp(const char *pkg, const char *locale_dir); + UiApp(); ///Destructor. virtual ~UiApp(); @@ -62,7 +60,6 @@ public: static UiApp *getInstance(); public: - _UI_DISABLE_DEFAULT_CTOR(UiApp); _UI_DISABLE_COPY_AND_ASSIGN(UiApp); }; diff --git a/src/include/efl/mobile/UiViewmgr.h b/src/include/efl/mobile/UiViewmgr.h index 0d15ae4..783af40 100644 --- a/src/include/efl/mobile/UiViewmgr.h +++ b/src/include/efl/mobile/UiViewmgr.h @@ -35,20 +35,17 @@ class UiApp; class UiViewmgr: public efl_viewmanager::UiBaseViewmgr { protected: - //Don't allow to create UiViewmgr instance /** * @brief This is a constructor for initializing viewmgr. * - * @param[in] pkg The name of package. */ - explicit UiViewmgr(const char *pkg); + UiViewmgr(); ///Destructor. virtual ~UiViewmgr(); public: _UI_DISABLE_COPY_AND_ASSIGN(UiViewmgr); - _UI_DISABLE_DEFAULT_CTOR(UiViewmgr); private: _UI_DECLARE_FRIENDS(UiView); diff --git a/src/include/efl/mobile/c/ui_application.h b/src/include/efl/mobile/c/ui_application.h index cb8109f..0f1dce8 100644 --- a/src/include/efl/mobile/c/ui_application.h +++ b/src/include/efl/mobile/c/ui_application.h @@ -61,9 +61,6 @@ typedef struct * @since_tizen 3.0 * @remarks Before exit application, call ui_application_term(). * - * @param[in] pkg The name of package - * @param[in] locale_dir The path of locale directory - * * @return @c 0 on success, otherwise a negative error value * @retval #UI_VIEWMGR_ERROR_NONE Successful * @retval #UI_VIEWMGR_ERROR_ALREADY_IN_PROGRESS Initialization was already done @@ -72,7 +69,7 @@ typedef struct * @see ui_application_term() * @see ui_application_run() */ -EAPI int ui_application_init(const char *pkg, const char *locale_dir); +EAPI int ui_application_init(); /** * @brief Runs ui_application. This triggers application main loop. diff --git a/src/include/interface/UiIfaceApp.h b/src/include/interface/UiIfaceApp.h index dbe09d0..3e9e8a9 100644 --- a/src/include/interface/UiIfaceApp.h +++ b/src/include/interface/UiIfaceApp.h @@ -38,11 +38,9 @@ public: /** * @brief This is a constructor for initializing UiIfaceApp. * - * @param[in] pkg The name of package. - * @param[in] loale_dir The path of locale directory. * @param[in] viewmgr instance of ui_viewmgr. */ - UiIfaceApp(const char *pkg, const char *locale_dir, UiIfaceViewmgr *viewmgr); + UiIfaceApp(UiIfaceViewmgr *viewmgr); ///Destructor. virtual ~UiIfaceApp(); diff --git a/src/lib/efl/UiBaseViewmgr.cpp b/src/lib/efl/UiBaseViewmgr.cpp index b4d76f0..c6bc856 100644 --- a/src/lib/efl/UiBaseViewmgr.cpp +++ b/src/lib/efl/UiBaseViewmgr.cpp @@ -55,7 +55,7 @@ private: bool _term(); public: - UiBaseViewmgrImpl(UiBaseViewmgr *viewmgr, const char *pkg, UiBaseKeyListener *keyListener); + UiBaseViewmgrImpl(UiBaseViewmgr *viewmgr, UiBaseKeyListener *keyListener); ~UiBaseViewmgrImpl(); void activate(); @@ -250,12 +250,14 @@ bool UiBaseViewmgrImpl::_createScroller(Elm_Conformant *conform) return true; } -UiBaseViewmgrImpl::UiBaseViewmgrImpl(UiBaseViewmgr *viewmgr, const char *pkg, UiBaseKeyListener *keyListener) +UiBaseViewmgrImpl::UiBaseViewmgrImpl(UiBaseViewmgr *viewmgr, UiBaseKeyListener *keyListener) : _viewmgr(viewmgr), _keyListener(keyListener) { - if (!pkg) { - LOGE("Invalid package name"); - return; + char *pkg = NULL; + int ret = app_get_id(&pkg); + if (ret != APP_ERROR_NONE) + { + LOGE("failed app_get_id(%d)", ret); } //Window @@ -319,6 +321,8 @@ UiBaseViewmgrImpl::UiBaseViewmgrImpl(UiBaseViewmgr *viewmgr, const char *pkg, Ui elm_win_indicator_mode_set(this->_win, ELM_WIN_INDICATOR_SHOW); elm_win_indicator_opacity_set(this->_win, ELM_WIN_INDICATOR_OPAQUE); elm_win_autodel_set(this->_win, EINA_TRUE); + + free(pkg); } UiBaseViewmgrImpl::~UiBaseViewmgrImpl() @@ -436,15 +440,15 @@ void UiBaseViewmgrImpl::pushView(UiBaseView *view) /* External class Implementation */ /***********************************************************************************************/ -UiBaseViewmgr::UiBaseViewmgr(const char *pkg, UiBaseKeyListener *key_listener) +UiBaseViewmgr::UiBaseViewmgr(UiBaseKeyListener *key_listener) : UiIfaceViewmgr() { - this->_impl = new UiBaseViewmgrImpl(this, pkg, key_listener); + this->_impl = new UiBaseViewmgrImpl(this, key_listener); this->_impl->_init(); } -UiBaseViewmgr::UiBaseViewmgr(const char *pkg) - : UiBaseViewmgr(pkg, new UiBaseKeyListener(this)) +UiBaseViewmgr::UiBaseViewmgr() + : UiBaseViewmgr(new UiBaseKeyListener(this)) { } diff --git a/src/lib/efl/mobile/UiApp.cpp b/src/lib/efl/mobile/UiApp.cpp index 66688fe..a7ee04f 100644 --- a/src/lib/efl/mobile/UiApp.cpp +++ b/src/lib/efl/mobile/UiApp.cpp @@ -27,8 +27,8 @@ using namespace efl_viewmanager; /* External class Implementation */ /***********************************************************************************************/ -UiApp::UiApp(const char *pkg, const char *locale_dir) - : UiIfaceApp(pkg, locale_dir, new UiViewmgr(pkg)) +UiApp::UiApp() + : UiIfaceApp(new UiViewmgr()) { } diff --git a/src/lib/efl/mobile/UiViewmgr.cpp b/src/lib/efl/mobile/UiViewmgr.cpp index 1756fce..6332d67 100644 --- a/src/lib/efl/mobile/UiViewmgr.cpp +++ b/src/lib/efl/mobile/UiViewmgr.cpp @@ -32,8 +32,8 @@ class UiViewmgrImpl; /***********************************************************************************************/ /* External class Implementation */ /***********************************************************************************************/ -UiViewmgr::UiViewmgr(const char *pkg) - : UiBaseViewmgr(pkg, new UiKeyListener(this)) +UiViewmgr::UiViewmgr() + : UiBaseViewmgr(new UiKeyListener(this)) { } diff --git a/src/lib/efl/mobile/c/ui_application.cpp b/src/lib/efl/mobile/c/ui_application.cpp index a0ecfb1..732d562 100644 --- a/src/lib/efl/mobile/c/ui_application.cpp +++ b/src/lib/efl/mobile/c/ui_application.cpp @@ -86,8 +86,8 @@ public: } } - ui_app_capi(const char *pkg, const char *locale_dir) - : UiApp(pkg, locale_dir) + ui_app_capi() + : UiApp() { } @@ -111,12 +111,12 @@ public: static ui_app_capi *g_app = nullptr; -EAPI int ui_application_init(const char *pkg, const char *locale_dir) +EAPI int ui_application_init() { ui_app_capi *app = g_app; if (app) return UI_VIEWMGR_ERROR_ALREADY_IN_PROGRESS; - app = new ui_app_capi(pkg, locale_dir); + app = new ui_app_capi(); if (!app) { LOGE("Failed to create new ui_app_capi()!"); diff --git a/src/lib/interface/UiIfaceApp.cpp b/src/lib/interface/UiIfaceApp.cpp index 1ee0600..36b6dec 100644 --- a/src/lib/interface/UiIfaceApp.cpp +++ b/src/lib/interface/UiIfaceApp.cpp @@ -32,15 +32,12 @@ public: UiIfaceApp *app = nullptr; UiIfaceViewmgr *viewmgr = nullptr; - Eina_Stringshare *pkg = nullptr; - Eina_Stringshare *locale_dir = nullptr; - UiIfaceAppImpl(UiIfaceApp *app, const char *pkg, const char *locale_dir, UiIfaceViewmgr* viewmgr); + UiIfaceAppImpl(UiIfaceApp *app, UiIfaceViewmgr* viewmgr); ~UiIfaceAppImpl(); int run(int argc, char **argv); - bool init(); bool onCreate(); void onTerminate(); void onPause(); @@ -116,20 +113,9 @@ static void uiAppLowMemory(app_event_info_h event_info, void *data) app->onLowMemory(event_info); } -bool UiIfaceAppImpl::init() -{ - /* Bind package locale file */ - bindtextdomain(this->pkg, this->locale_dir); - textdomain(this->pkg); - - return true; -} - -UiIfaceAppImpl::UiIfaceAppImpl(UiIfaceApp *app, const char *pkg, const char *locale_dir, UiIfaceViewmgr *viewmgr) +UiIfaceAppImpl::UiIfaceAppImpl(UiIfaceApp *app, UiIfaceViewmgr *viewmgr) : app(app), viewmgr(viewmgr) { - this->pkg = eina_stringshare_add(pkg); - this->locale_dir = eina_stringshare_add(locale_dir); } int UiIfaceAppImpl::run(int argc, char **argv) @@ -143,6 +129,7 @@ int UiIfaceAppImpl::run(int argc, char **argv) event_callback.resume = appResume; event_callback.app_control = appControl; + //FIXME: don't add these events in default. this is a little burdensome to system. ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, uiAppLowBattery, this); ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, uiAppLowMemory, this); ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, uiAppOrientChanged, this); @@ -155,8 +142,6 @@ int UiIfaceAppImpl::run(int argc, char **argv) UiIfaceAppImpl::~UiIfaceAppImpl() { delete (this->viewmgr); - eina_stringshare_del(this->pkg); - eina_stringshare_del(this->locale_dir); } void UiIfaceAppImpl::onLangChanged(app_event_info_h event_info) @@ -263,7 +248,7 @@ void UiIfaceApp::onOrientChanged(app_event_info_h event_info) bool UiIfaceApp::onCreate() { - return this->_impl->init(); + return true; } void UiIfaceApp::onPause() @@ -286,14 +271,14 @@ void UiIfaceApp::onTerminate() { } -UiIfaceApp::UiIfaceApp(const char *pkg, const char *locale_dir, UiIfaceViewmgr *viewmgr) +UiIfaceApp::UiIfaceApp(UiIfaceViewmgr *viewmgr) { if (_inst) { throw UiIfaceException("Requested to create UiIfaceApp instance multiple times!!"); } _inst = this; - this->_impl = new UiIfaceAppImpl(this, pkg, locale_dir, viewmgr); + this->_impl = new UiIfaceAppImpl(this, viewmgr); } int UiIfaceApp::run(int argc, char **argv) -- 2.34.1