* @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
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
{
Cancel();
}
+
+ if(__pEvent != null)
+ {
+ delete __pEvent;
+ __pEvent = null;
+ }
}
result
#include <runtime_info.h>
#include <vconf.h>
+#include <FAppApp.h>
#include <FBaseRtEvent.h>
#include <FBaseRtIEventArg.h>
#include <FBaseRtIEventListener.h>
}
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)
{
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;
}
{
if(listener != null)
{
- SysLog(NID_SYS, "%x", listener);
- runtimeInfoEvent.AddListener(*listener, false);
+ runtimeInfoEvent.AddListener(*listener);
}
int thr_id = 0;
{
if(listener != null)
{
- SysLog(NID_SYS, "test %x", listener);
+ SysLog(NID_SYS, "listener instance is %x.", listener);
runtimeInfoEvent.AddListener(*listener);
}
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);
}
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)
{
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;
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;
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);
}
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();
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);
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