Fix _SettingService class
authorJoohyun Kim <joohyune.kim@samsung.com>
Fri, 12 Jul 2013 04:21:55 +0000 (13:21 +0900)
committerJoohyun Kim <joohyune.kim@samsung.com>
Fri, 12 Jul 2013 04:21:55 +0000 (13:21 +0900)
Change-Id: I876d91beb29c53cc106a43603c803573e7f42a9e
Signed-off-by: Joohyun Kim <joohyune.kim@samsung.com>
src/CommonService.cpp
src/system/FSys_SettingService.cpp

index bacaecc..5909a38 100644 (file)
@@ -42,22 +42,12 @@ CommonService::~CommonService(void)
 ServiceApp*
 CommonService::CreateInstance(void)
 {
-       // Create the instance through the constructor.
        return new CommonService();
 }
 
 bool
 CommonService::OnAppInitializing(AppRegistry& appRegistry)
 {
-       // TODO:
-       // Initialize App specific data.
-       // The App's permanent data and context can be obtained from the appRegistry.
-       //
-       // If this method is successful, return true; otherwise, return false.
-       // If this method returns false, the App will be terminated.
-
-       // TODO: Add your initialization code here
-
        return true;
 }
 
@@ -72,37 +62,23 @@ CommonService::OnAppInitialized(void)
 bool
 CommonService::OnAppWillTerminate(void)
 {
-       // TODO:
-       // Comment.
-
        return true;
 }
 
 bool
 CommonService::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination)
 {
-       // TODO:
-       // Deallocate resources allocated by this App for termination.
-       // The App's permanent data and context can be saved via appRegistry.
-
-       // TODO: Add your termination code here
-
        return true;
 }
 
 void
 CommonService::OnLowMemory(void)
 {
-       // TODO:
-       // Free unused resources or close the App.
 }
 
 void
 CommonService::OnBatteryLevelChanged(BatteryLevel batteryLevel)
 {
-       // TODO:
-       // Handle any changes in battery level here.
-       // Stop using multimedia features(camera, mp3 etc.) if the battery level is CRITICAL.
 }
 
 void
index 1f3949f..4faa0d5 100644 (file)
@@ -80,15 +80,13 @@ _SettingService::_SettingService()
        , __pSettingInfo(null)
        , __asyncList(SingleObjectDeleter)
        , __eventList(SingleObjectDeleter)
+       , __eventListForInternal(SingleObjectDeleter)
 {
        result r = E_SUCCESS;
 
        r = __ipcServer.Construct(__serviceId, *this, true);
        SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, r, "It is failed to construct IPC server.");
 
-       r = __ipcServer.Start();
-       SysTryCatch(NID_SYS, r == E_SUCCESS, , r, "It is failed to start IPC server.");
-
        __pSettingInfo = _SettingInfo::GetInstance();
        SysTryCatch(NID_SYS, __pSettingInfo != null, r = E_SYSTEM, E_SYSTEM, "It is failed to get instance of _SettingInfo.");
 
@@ -102,6 +100,9 @@ _SettingService::_SettingService()
        r = __eventListForInternal.Construct();
        SysTryCatch(NID_SYS, r == E_SUCCESS, , r, "It is failed to construct event list for internal.");
 
+       r = __ipcServer.Start();
+       SysTryCatch(NID_SYS, r == E_SUCCESS, , r, "It is failed to start IPC server.");
+
 CATCH:
        if(r != E_SUCCESS)
        {
@@ -134,8 +135,7 @@ void
 _SettingService::InitSingleton(void)
 {
        _SettingService* pSettingService = new (nothrow) _SettingService();
-       SysTryReturnVoidResult(NID_SYS, pSettingService != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.",
-                                                  GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturnVoidResult(NID_SYS, pSettingService != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
        __pSettingService = pSettingService;
        atexit(DestroySingleton);
@@ -374,14 +374,14 @@ CATCH:
                String* pCommandCode = new (nothrow) String(*pCommand);
                String* pResultCode = new (nothrow) String(GetErrorMessage(r));
 
-               SysLog(NID_SYS, "Result value is %ls.", pCommandCode->GetPointer());
-               SysLog(NID_SYS, "Result value is %ls.", pResultCode->GetPointer());
+               SysLog(NID_SYS, "Command Code is %ls.", pCommandCode->GetPointer());
+               SysLog(NID_SYS, "Result Code is %ls.", pResultCode->GetPointer());
 
                response->Add(pCommandCode);
                response->Add(pResultCode);
                if(pValue != null)
                {
-                       SysLog(NID_SYS, "Result value is %ls.", pValue->GetPointer());
+                       SysLog(NID_SYS, "Value is %ls.", pValue->GetPointer());
                        response->Add(pValue);
                }
        }
@@ -436,14 +436,14 @@ _SettingService::OnSettingChanged(Tizen::Base::String& key)
                {
                        Integer* pid = (Integer*) pEnum->GetCurrent();
 
-                       ArrayList* pData = new (nothrow) ArrayList;
-                       pData->Construct();
-                       String cmdCode(SETTING_SERVICE_COMMAND_EVENT);
+                       ArrayList data;
+                       data.Construct();
+                       String cmdCode(SETTING_SERVICE_COMMAND_EVENT_INTERNAL);
                        String keyCode(key);
-                       pData->Add(cmdCode);
-                       pData->Add(keyCode);
+                       data.Add(cmdCode);
+                       data.Add(keyCode);
 
-                       r = __ipcServer.SendResponse(pid->value, new (nothrow) IoService_Data(*pData));
+                       r = __ipcServer.SendResponse(pid->value, new (nothrow) IoService_Data(data));
                        SysLog(NID_SYS, "Internal setting event is delivered to %d. result is %s.", pid->value, GetErrorMessage(r));
                }
                delete pEnum;
@@ -454,14 +454,14 @@ _SettingService::OnSettingChanged(Tizen::Base::String& key)
        {
                Integer* pid = (Integer*) pEnum->GetCurrent();
 
-               ArrayList* pData = new (nothrow) ArrayList;
-               pData->Construct();
+               ArrayList data;
+               data.Construct();
                String cmdCode(SETTING_SERVICE_COMMAND_EVENT);
                String keyCode(key);
-               pData->Add(cmdCode);
-               pData->Add(keyCode);
+               data.Add(cmdCode);
+               data.Add(keyCode);
 
-               r = __ipcServer.SendResponse(pid->value, new (nothrow) IoService_Data(*pData));
+               r = __ipcServer.SendResponse(pid->value, new (nothrow) IoService_Data(data));
                SysLog(NID_SYS, "Setting event is delivered to %d. result is %s.", pid->value, GetErrorMessage(r));
        }