Fix system issues
authorJoohyun Kim <joohyune.kim@samsung.com>
Wed, 10 Apr 2013 12:39:47 +0000 (21:39 +0900)
committerJoohyun Kim <joohyune.kim@samsung.com>
Wed, 10 Apr 2013 12:39:47 +0000 (21:39 +0900)
Change-Id: I057fe600f1948405436989303b49661daa288962
Signed-off-by: Joohyun Kim <joohyune.kim@samsung.com>
inc/FSysSettingInfo.h
src/system/FSysSettingInfo.cpp
src/system/FSys_AlarmImpl.cpp
src/system/FSys_RuntimeInfoImpl.cpp
src/system/FSys_SettingClient.cpp
src/system/FSys_SettingClient.h
src/system/FSys_SettingInfoImpl.cpp
src/system/inc/FSys_SettingInfoImpl.h

index 4766602..ab8bdd1 100644 (file)
@@ -404,11 +404,34 @@ public:
         * @exception   E_INVALID_ARG           The specified @c value is invalid value.
         * @exception   E_OBJ_NOT_FOUND         The specified @c key is not found.
         * @exception   E_UNSUPPORTED_OPERATION The specified @c key is existed, However it is not supported by this device.
+        * @exception   E_IN_PROGRESS           The specified key is under processing or invalid state.
         * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
         */
        static result SetValueAsyncForPrivilegedKey(const Tizen::Base::String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener);
 
        /**
+        * Sets the specific @c bool type sett   * @exception   E_IN_PROGRESS           The specified key is under processing or invalid state.ing information based on the specified designators (key) asynchronously.
+        *
+        * @since 2.0
+        * @privlevel   platform
+        * @privilege   %http://tizen.org/privilege/setting
+        *
+        * @return      An error code
+        * @param[in]   key                     The <a href="../org.tizen.native.appprogramming/html/guide/system/settings_info.htm">key name</a> of the setting information
+        * @param[in]   value                   The setting information of type bool
+        * @param[in]   listener                The result listener.
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_PRIVILEGED_DENIED     The application does not have the privilege to call this method.
+        * @exception   E_INVALID_ARG           The specified @c value is invalid value.
+        * @exception   E_OBJ_NOT_FOUND         The specified @c key is not found.
+        * @exception   E_UNSUPPORTED_OPERATION The specified @c key is existed, However it is not supported by this device.
+        * @exception   E_IN_PROGRESS           The specified key is under processing or invalid state.
+        * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
+        */
+       static result SetValueAsync(const Tizen::Base::String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener);
+
+
+       /**
         * Sets the specific Tizen::Base::String type setting information based on the specified designators (key).
         *
         * @since 2.0
index c1598a8..3857712 100644 (file)
@@ -100,29 +100,26 @@ result
 SettingInfo::SetWallpaper(const String& filePath)
 {
        result r = E_SUCCESS;
-        r = _AccessController::CheckUserPrivilege(_PRV_SETTING);
-        SysTryReturn(NID_SYS, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, ("[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."));
-
+       r = _AccessController::CheckUserPrivilege(_PRV_SETTING);
+       SysTryReturn(NID_SYS, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, ("[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."));
        return _SettingInfoImpl::SetWallpaper(filePath);
 }
 
 result
 SettingInfo::SetRingtone(const String& filePath)
 {
-        result r = E_SUCCESS;
-        r = _AccessController::CheckUserPrivilege(_PRV_SETTING);
-        SysTryReturn(NID_SYS, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, ("[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."));
-
+       result r = E_SUCCESS;
+       r = _AccessController::CheckUserPrivilege(_PRV_SETTING);
+       SysTryReturn(NID_SYS, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, ("[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."));
        return _SettingInfoImpl::SetRingtone(filePath);
 }
 
 result
 SettingInfo::SetVolume(const String& soundCategory, int level)
 {
-        result r = E_SUCCESS;
-        r = _AccessController::CheckUserPrivilege(_PRV_SETTING);
-        SysTryReturn(NID_SYS, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, ("[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."));
-
+       result r = E_SUCCESS;
+       r = _AccessController::CheckUserPrivilege(_PRV_SETTING);
+       SysTryReturn(NID_SYS, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, ("[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."));
        return _SettingInfoImpl::SetVolume(soundCategory, level);
 }
 
@@ -130,8 +127,8 @@ result
 SettingInfo::GetValueForPrivilegedKey(const String& key, bool& value)
 {
        result r = E_SUCCESS;
-        r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMSETTING_READ);
-        SysTryReturn(NID_SYS, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, ("[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."));
+       r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMSETTING_READ);
+       SysTryReturn(NID_SYS, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, ("[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."));
        return _SettingInfoImpl::GetValueForPrivilegedKey(key, value);
 }
 
@@ -145,9 +142,8 @@ result
 SettingInfo::SetValue(const String& key, bool value)
 {
        result r = E_SUCCESS;
-        r = _AccessController::CheckUserPrivilege(_PRV_SETTING);
-        SysTryReturn(NID_SYS, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, ("[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."));
-       
+       r = _AccessController::CheckUserPrivilege(_PRV_SETTING);
+       SysTryReturn(NID_SYS, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, ("[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."));       
        return _SettingInfoImpl::SetValue(key, value);
 }
 
@@ -155,9 +151,8 @@ result
 SettingInfo::SetValue(const String& key, int value)
 {
        result r = E_SUCCESS;
-        r = _AccessController::CheckUserPrivilege(_PRV_SETTING);
-        SysTryReturn(NID_SYS, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, ("[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."));
-
+       r = _AccessController::CheckUserPrivilege(_PRV_SETTING);
+       SysTryReturn(NID_SYS, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, ("[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."));
        return _SettingInfoImpl::SetValue(key, value);
 }
 
@@ -165,9 +160,8 @@ result
 SettingInfo::SetValue(const String& key, String value)
 {
        result r = E_SUCCESS;
-        r = _AccessController::CheckUserPrivilege(_PRV_SETTING);
-        SysTryReturn(NID_SYS, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, ("[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."));
-
+       r = _AccessController::CheckUserPrivilege(_PRV_SETTING);
+       SysTryReturn(NID_SYS, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, ("[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."));
        return _SettingInfoImpl::SetValue(key, value);
 }
 
@@ -175,8 +169,8 @@ result
 SettingInfo::SetValueForPrivilegedKey(const String& key, bool value)
 {
        result r = E_SUCCESS;
-        r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMSETTING_WRITE);
-        SysTryReturn(NID_SYS, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, ("[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."));
+       r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMSETTING_WRITE);
+       SysTryReturn(NID_SYS, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, ("[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."));
        return _SettingInfoImpl::SetValueForPrivilegedKey(key, value);
 }
 
@@ -184,8 +178,8 @@ result
 SettingInfo::SetValueForPrivilegedKey(const String& key, String value)
 {
        result r = E_SUCCESS;
-        r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMSETTING_WRITE);
-        SysTryReturn(NID_SYS, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, ("[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."));
+       r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMSETTING_WRITE);
+       SysTryReturn(NID_SYS, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, ("[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."));
        return _SettingInfoImpl::SetValueForPrivilegedKey(key, value);
 }
 
@@ -193,17 +187,24 @@ result
 SettingInfo::ResetToFactoryDefault(void)
 {
        result r = E_SUCCESS;
-        r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMSETTING_WRITE);
-        SysTryReturn(NID_SYS, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, ("[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."));
+       r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMSETTING_WRITE);
+       SysTryReturn(NID_SYS, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, ("[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."));
        return _SettingInfoImpl::ResetToFactoryDefault();
 }
 
 result 
+SettingInfo::SetValueAsync(const String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener)
+{
+       result r = E_SUCCESS;
+       r = _AccessController::CheckUserPrivilege(_PRV_SETTING);
+       SysTryReturn(NID_SYS, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, ("[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."));
+       return _SettingInfoImpl::SetValueAsync(key, value, listener);
+}
+
+result 
 SettingInfo::SetValueAsyncForPrivilegedKey(const String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener)
 {
        result r = E_SUCCESS;
-        r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMSETTING_WRITE);
-        SysTryReturn(NID_SYS, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, ("[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."));
        return _SettingInfoImpl::SetValueAsyncForPrivilegedKey(key, value, listener);
 }
 
index b098347..01e52d5 100644 (file)
@@ -92,6 +92,12 @@ _AlarmImpl::~_AlarmImpl(void)
        {
                Cancel();
        }
+
+       if(__pEvent != null)
+       {
+               delete __pEvent;
+               __pEvent = null;
+       }
 }
 
 result
index 73e8c23..2137e7c 100644 (file)
@@ -35,6 +35,7 @@
 #include <runtime_info.h>
 #include <vconf.h>
 
+#include <FAppApp.h>
 #include <FBaseRtEvent.h>
 #include <FBaseRtIEventArg.h>
 #include <FBaseRtIEventListener.h>
@@ -351,22 +352,62 @@ _RuntimeInfoImpl::GetDirectorySize(const char* path)
        }
 
        char command[512] = {0,};
+       char fileName[512] = {0,};
        long long size = 0;
        int ret = 0;
 
-       sprintf(command, "du -sk -P %s >> /tmp/size_of_directory.tmp", path);
+       Tizen::App::App* pApp = Tizen::App::App::GetInstance();
+       if(pApp == null)
+       {
+               return 0;
+       }
+
+       String appId(pApp->GetAppId());
+       unique_ptr <char> appIdPath(_StringConverter::CopyToCharArrayN(appId));
+
+       ret = sprintf(fileName, "/tmp/size_of_directory_%s.tmp", appIdPath.get());
+       if(ret < 1)
+       {
+               SysLogException(NID_SYS, E_SYSTEM, "It is failed to write file path.");
+               return 0;
+       }
+
+       ret = sprintf(command, "rm -rf %s", fileName);
+       if(ret < 1)
+       {
+               SysLogException(NID_SYS, E_SYSTEM, "It is failed to write remove command.");
+               return 0;
+       }
+
+       ret = system(command);
 
-       system("rm -rf /tmp/size_of_directory.tmp");
-       system(command);
+       if(ret == -1)
+       {
+               SysLogException(NID_SYS, E_SYSTEM, "It is failed to execute command[%s].", command);
+       }
+
+       ret = sprintf(command, "du -skb -P %s >> %s", path, fileName);
+       if(ret < 1)
+       {
+               SysLogException(NID_SYS, E_SYSTEM, "It is failed to write du command.");
+               return 0;
+       }
+
+       ret = system(command);
+       if(ret == -1)
+       {
+               SysLogException(NID_SYS, E_SYSTEM, "It is failed to execute command[%s].", command);
+               return 0;
+       }
 
        FILE* pFile = null;
-       pFile = fopen("/tmp/size_of_directory.tmp", "r");
+       pFile = fopen(fileName, "r");
        if(pFile == null)
        {
                return 0;
        }
-       ret = fscanf(pFile, "%lld", &size);
 
+       ret = fscanf(pFile, "%lld", &size);
        if(ret < 1)
        {
                if(pFile != null)
@@ -381,7 +422,21 @@ _RuntimeInfoImpl::GetDirectorySize(const char* path)
        {
                fclose(pFile);
        }
-       system("rm -rf /tmp/size_of_directory.tmp");
+
+       ret = sprintf(command, "rm -rf %s", fileName);
+       if(ret < 1)
+       {
+               SysLogException(NID_SYS, E_SYSTEM, "It is failed to write remove command.");
+               return 0;
+       }
+
+       ret = system(command);
+       if(ret == -1)
+       {
+               SysLogException(NID_SYS, E_SYSTEM, "It is failed to execute command[%s].", command);
+       }
+
+
        return size;
 }
 
@@ -632,8 +687,7 @@ _RuntimeInfoImpl::GetValueAsync(const String& key, IRuntimeInfoGetIntAsyncResult
        {
                if(listener != null)
                {
-                       SysLog(NID_SYS, "%x", listener);
-                       runtimeInfoEvent.AddListener(*listener, false);
+                       runtimeInfoEvent.AddListener(*listener);
                }
 
                int thr_id = 0;
@@ -714,7 +768,7 @@ _RuntimeInfoImpl::GetValueAsync(const String& key, IRuntimeInfoGetLonglongAsyncR
        {
                if(listener != null)
                {
-                       SysLog(NID_SYS, "test %x", listener);
+                       SysLog(NID_SYS, "listener instance is %x.", listener);
                        runtimeInfoEvent.AddListener(*listener);
                }
 
@@ -723,7 +777,7 @@ _RuntimeInfoImpl::GetValueAsync(const String& key, IRuntimeInfoGetLonglongAsyncR
                pEventArg->DirectoryPath = directoryPath;
 
                thr_id = pthread_create(&p_thread, null, GetDirectorySizeAsync, pEventArg);
-               SysLog(NID_SYS, "%d", thr_id);
+               SysLog(NID_SYS, "Thread id is %d.", thr_id);
                pthread_detach(p_thread);
        }
 
index e06fccf..13d9412 100644 (file)
@@ -758,6 +758,40 @@ _SettingClient::SetValueForPrivilegedKey(const String& key, String value)
        return SetOnService(_SETTING_COMMAND_SET_STRING_PRIV, key, requestValue);
 }
 
+
+result
+_SettingClient::SetValueAsync(const String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener)
+{
+       result r = E_SUCCESS;
+       String requestValue;
+
+       SysTryReturnResult(NID_SYS, __asyncEventList.ContainsKey(key) == false, E_IN_PROGRESS, "Required key[%ls] is already in progress.", key.GetPointer());
+
+       if(value == true)
+       {
+               requestValue.Append("true");
+       }
+       else
+       {
+               requestValue.Append("false");
+       }
+
+       r = SetOnService(_SETTING_COMMAND_SET_BOOL_ASYNC, key, requestValue);
+
+       if(r == E_SUCCESS)
+       {
+               if(listener != null)
+               {
+                       _SettingAsyncEvent* pEvent = new (std::nothrow) _SettingAsyncEvent();
+                       pEvent->AddListener(*listener);
+
+                       __asyncEventList.Add(new String(key), pEvent);
+               }
+       }
+
+       return r;
+}
+
 result
 _SettingClient::SetValueAsyncForPrivilegedKey(const String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener)
 {
@@ -779,10 +813,13 @@ _SettingClient::SetValueAsyncForPrivilegedKey(const String& key, bool value, ISe
 
        if(r == E_SUCCESS)
        {
-               _SettingAsyncEvent* pEvent = new (std::nothrow) _SettingAsyncEvent();
-               pEvent->AddListener(*listener);
+               if(listener != null)
+               {
+                       _SettingAsyncEvent* pEvent = new (std::nothrow) _SettingAsyncEvent();
+                       pEvent->AddListener(*listener);
 
-               __asyncEventList.Add(new String(key), pEvent);
+                       __asyncEventList.Add(new String(key), pEvent);
+               }
        }
 
        return r;
@@ -873,6 +910,7 @@ _SettingClient::HasKey(const String& key)
        String response;
        result r = GetOnService(_SETTING_COMMAND_SUPPORTED, key, response);
 
+       SysLog(NID_SYS, "HasKey result key:%ls, %ls", key.GetPointer(), response.GetPointer());
        if(response == L"1" && r == E_SUCCESS)
        {
                return true;
index f0c7816..7a94342 100644 (file)
@@ -62,6 +62,7 @@ public:
 
        result SetValue(const Tizen::Base::String& key, const bool& value);
        result SetValueForPrivilegedKey(const Tizen::Base::String& key, bool value);
+       result SetValueAsync(const Tizen::Base::String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener);
        result SetValueAsyncForPrivilegedKey(const Tizen::Base::String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener);
        result SetValue(const Tizen::Base::String& key, const int& value);
        result SetValue(const Tizen::Base::String& key, const Tizen::Base::String& value);
index 3f3e59b..17e657e 100644 (file)
@@ -332,6 +332,14 @@ _SettingInfoImpl::SetSettingEventListener(ISettingEventListener* pListener)
 }
 
 result
+_SettingInfoImpl::SetValueAsync(const Tizen::Base::String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener)
+{
+       InitSettingClient();
+       SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
+       return pSettingClient->SetValueAsync(key, value, listener);
+}
+
+result
 _SettingInfoImpl::SetValueAsyncForPrivilegedKey(const Tizen::Base::String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener)
 {
        InitSettingClient();
index bce08b3..8d70cd8 100644 (file)
@@ -61,6 +61,7 @@ public:
        static result SetValue(const Tizen::Base::String& key, int value);
        static result SetValue(const Tizen::Base::String& key, Tizen::Base::String value);
        static result SetValueForPrivilegedKey(const Tizen::Base::String& key, bool value);
+       static result SetValueAsync(const Tizen::Base::String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener);
        static result SetValueAsyncForPrivilegedKey(const Tizen::Base::String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener);
        static result SetValueForPrivilegedKey(const Tizen::Base::String& key, Tizen::Base::String value);
 
@@ -69,7 +70,7 @@ private:
        static void InitSettingClient(void);
 
        static result GetValueForFont(const Tizen::Base::String& key, Tizen::Base::String& value);
-        static result SetValueForFont(const Tizen::Base::String& key, Tizen::Base::String value);
+       static result SetValueForFont(const Tizen::Base::String& key, Tizen::Base::String value);
 };
 
 } } // Tizen::Sys