ui_app: update ui_application_init() API. 60/95360/4
authorHermet Park <hermet@hermet.pe.kr>
Thu, 3 Nov 2016 04:26:28 +0000 (13:26 +0900)
committerHermet Park <hermet@hermet.pe.kr>
Thu, 3 Nov 2016 05:05:09 +0000 (14:05 +0900)
remove pkg, locale_dir parameters.
it's not mandatory for users.

Change-Id: Id865837dae6ac3cf01119f32dd74ae9a6006f378

12 files changed:
src/examples/efl/c/main.cpp
src/examples/efl/cpp/main.cpp
src/include/efl/UiBaseViewmgr.h
src/include/efl/mobile/UiApp.h
src/include/efl/mobile/UiViewmgr.h
src/include/efl/mobile/c/ui_application.h
src/include/interface/UiIfaceApp.h
src/lib/efl/UiBaseViewmgr.cpp
src/lib/efl/mobile/UiApp.cpp
src/lib/efl/mobile/UiViewmgr.cpp
src/lib/efl/mobile/c/ui_application.cpp
src/lib/interface/UiIfaceApp.cpp

index 0d098275d7559a38ab0e84194f8eed5556ac9246..89779d8d50e4002dc848c0fec2df86cd4ce571aa 100644 (file)
@@ -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);
index 272935fa00dc14c39a40d290dffe26eeea6bfc64..c8a6c7e69e18fa0151b5a6983e9fc71591f1c585 100644 (file)
@@ -36,7 +36,7 @@ class SampleApp: public UiApp
 {
 public:
        SampleApp()
-                       : UiApp(PACKAGE, LOCALE_DIR)
+                       : UiApp()
        {
        }
        ~SampleApp()
index 6c2268494c3ca359aeae1f56da39e5f2198e4aeb..dc340582b6a290b8900f3f100ec75c3ffd9af7c8 100644 (file)
@@ -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:
index dfffd92b22f77b5a95dec9670cc6c60d8613c6c4..a9d15e0465cc0c147e163ffae735f81c096a9604 100644 (file)
@@ -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);
 };
 
index 0d15ae48682f0ea6faefa06e36f23161bffdcd59..783af40dcc811939c472e84c1df3c0949a16e4f7 100644 (file)
@@ -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);
index cb8109f1e73fdfd6384b44a520d846b3512d9b92..0f1dce8a79df1c7959dd4d59418d681662a6eac1 100644 (file)
@@ -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.
index dbe09d0b0fbbc8e99ea4cd9d12e2e2474ffe77cd..3e9e8a935baafb75e9d53e7194eed1cc65e020ce 100644 (file)
@@ -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();
index b4d76f0aef8af5d199a66f47281efd2f78528b1f..c6bc8560cfec617a2904f24acfef5b7128e9137e 100644 (file)
@@ -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))
 {
 }
 
index 66688fec51da213d8a77e298540d5ac578bc65a3..a7ee04f2f761fdb0d3a87e3f34df2a77d910c19c 100644 (file)
@@ -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())
 {
 }
 
index 1756fcebedc9de23c3bf63d41167d277be58dc9e..6332d67363159010e3b8748b1b8dc17be5164323 100644 (file)
@@ -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))
 {
 }
 
index a0ecfb1321c38fc5bab71f15a28903eff094dcf0..732d562792eb834d1ba66fa7e66a18b1875316a5 100644 (file)
@@ -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()!");
index 1ee060053c2ba0e108e190148eaf75c558473126..36b6decf5a00b9715d656ab2bc4c47219a71c65a 100644 (file)
@@ -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)