Added OnSettingChanged() logic and removed OnLanguageChanged()
authorKarthik Subas Chandra Bose <karthik.scb@samsung.com>
Fri, 13 Sep 2013 08:31:10 +0000 (17:31 +0900)
committerKarthik Subas Chandra Bose <karthik.scb@samsung.com>
Fri, 13 Sep 2013 08:31:10 +0000 (17:31 +0900)
Change-Id: If7ca648f5855520a75f82cddea41c68537cab3ac
Signed-off-by: Karthik Subas Chandra Bose <karthik.scb@samsung.com>
src/app/FApp_AppImpl.cpp
src/app/inc/FApp_AppImpl.h

index 8dd78e2..e50a44f 100644 (file)
@@ -56,6 +56,7 @@
 #include "FApp_AppArg.h"
 #include "FApp_IAppImpl.h"
 #include "FApp_AppResourceImpl.h"
+#include <FSys_SettingInfoImpl.h>
 
 using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
@@ -137,6 +138,9 @@ _AppImpl::Construct(const IList* pArgs)
 
        _AppInfo::SetAppState(INITIALIZING);
 
+       r = _SettingInfoImpl::AddSettingEventListenerForInternal(*this);
+       SysTryLog(NID_APP, !IsFailed(r), "[%s] failed to add setting event listener.", GetErrorMessage(r));
+
        return E_SUCCESS;
 }
 
@@ -172,7 +176,7 @@ _AppImpl::Execute(_IAppImpl* pIAppImpl)
 
        state_handler.low_memory = &OnLowMemory;
        state_handler.low_battery = NULL;
-       state_handler.language_changed = &OnLanguageChanged;
+       state_handler.language_changed = NULL;
        state_handler.region_format_changed = NULL;
 
        _Aul::SetPowerOffNotiListener(OnPowerOffNotiReceived, this);
@@ -368,6 +372,9 @@ _AppImpl::OnTerminate(void* user_data)
        SysTryReturnVoidResult(NID_APP, pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
        SysTryReturnVoidResult(NID_APP, pAppImpl->__pIAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
 
+       result r = _SettingInfoImpl::RemoveSettingEventListenerForInternal(*pAppImpl);
+       SysTryLog(NID_APP, !IsFailed(r), "[%s] failed to remove setting event listener.", GetErrorMessage(r));
+
        __isTerminationRequested = true;
        pAppImpl->__pIAppImpl->OnTerminate();
 }
@@ -611,17 +618,6 @@ _AppImpl::OnBatteryLevelChanged(BatteryLevel batteryLevel)
        __pApp->OnBatteryLevelChanged(batteryLevel);
 }
 
-void
-_AppImpl::OnLanguageChanged(void* user_data)
-{
-       SysLog(NID_APP, "");
-       _AppInfo::UpdatePackageInfo(true);
-
-       _AppResourceImpl::Reinitialize();
-       SysLog(NID_APP, "Language change done.");
-}
-
-
 result
 _AppImpl::SendUserEvent(RequestId requestId, const IList* pArgs, bool isPublic)
 {
@@ -1414,6 +1410,17 @@ _AppImpl::OnPowerOffNotiReceived(void* node, void* user_data)
        }
 }
 
+void
+_AppImpl::OnSettingChanged(String& key)
+{
+       if (key == L"http://tizen.org/setting/locale.language")
+       {
+               _AppInfo::UpdatePackageInfo(true);
+               _AppResourceImpl::Reinitialize();
+               SysLog(NID_APP, "Reinitialized resources due to locale change.");
+       }
+}
+
 bool
 _AppImpl::IsForcedTermination(void)
 {
index e5e482a..1aecf26 100644 (file)
@@ -26,6 +26,7 @@
 #include <FSysBattery.h>
 #include <FBaseRtIEventListener.h>
 
+#include <FSysISettingEventListener.h>
 #include "FApp_Types.h"
 #include "FApp_AppUserEvent.h"
 #include "FApp_IAppUserEventListener.h"
@@ -63,6 +64,7 @@ class _OSP_EXPORT_ _AppImpl
        : public Tizen::Base::Object
        , public _IAppUserEventListener
        , virtual public Tizen::Base::Runtime::IEventListener
+       , public Tizen::System::ISettingEventListener
 {
 public:
        typedef result (_AppImpl::*AppRequestHandlerType)(service_s*, int, _AppHandler);
@@ -167,14 +169,6 @@ public:
        static void OnLowMemory(void* user_data);
 
        /**
-        * Called when language setting changes
-        *
-        * @param[in]   user_data       The user data passed from the callback registration function
-        * @remarks     This is a system dependent callback function
-        */
-       static void OnLanguageChanged(void* user_data);
-
-       /**
         * Set Listener
         *
         * @return      An error code
@@ -248,6 +242,11 @@ public:
 
        static void OnPowerOffNotiReceived(void* node, void* pData);
 
+       /**
+        * Called when the setting information is changed.
+        */
+       virtual void OnSettingChanged(Tizen::Base::String& key);
+
 private:
        /**
         * This is the default constructor for this class.