PREDEFINED_DIRECTORY_CAMERA, /**< The directory for files to be stored in internal storage by camera application (read-write permission) */
PREDEFINED_DIRECTORY_DOWNLOADS, /**< The directory for files to be stored in internal storage by download manager (read-write permission) */
PREDEFINED_DIRECTORY_OTHERS, /**< The directory for other files to be stored in internal storage (read-write permission) */
+ PREDEFINED_DIRECTORY_SYSTEM_RINGTONES, /**< The directory for preloaded system ringtone files in internal storage (read only permission) @b Since: @b 2.1*/
PREDEFINED_DIRECTORY_EXTERNAL_IMAGES = 100, /**< The directory for image files to be stored in external MMC (read-write permission) */
PREDEFINED_DIRECTORY_EXTERNAL_SOUNDS, /**< The directory for sound files to be stored in external MMC (read-write permission) */
FSysPowerManager.cpp
FSys_PowerManagerImpl.cpp
FSysRuntimeInfo.cpp
+ FSys_RuntimeClient.cpp
FSys_RuntimeInfoImpl.cpp
FSysSettingInfo.cpp
FSys_SettingInfoImpl.cpp
result
SettingInfo::GetValueForPrivilegedKey(const String& key, bool& value)
{
- result r = E_SUCCESS;
- r = _AccessController::CheckUserPrivilege(_PRV_SETTINGMANAGER_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);
}
result
SettingInfo::SetValueForPrivilegedKey(const String& key, bool value)
{
- result r = E_SUCCESS;
- r = _AccessController::CheckUserPrivilege(_PRV_SETTINGMANAGER_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);
}
result
SettingInfo::SetValueForPrivilegedKey(const String& key, String value)
{
- result r = E_SUCCESS;
- r = _AccessController::CheckUserPrivilege(_PRV_SETTINGMANAGER_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);
}
result
SettingInfo::ResetToFactoryDefault(void)
{
- result r = E_SUCCESS;
- r = _AccessController::CheckUserPrivilege(_PRV_SETTINGMANAGER_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
SystemInfo::GetPlatformVersion(String& platformVersion)
{
- result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEM);
+ result r = _AccessController::CheckUserPrivilege(_PRV_PLATFORMINFO, _PRV_SYSTEM);
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 _SystemInfoImpl::GetPlatformVersion(platformVersion);
}
result
SystemInfo::GetBuildInfo(String& buildInfo)
{
- result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEM);
+ result r = _AccessController::CheckUserPrivilege(_PRV_PLATFORMINFO, _PRV_SYSTEM);
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 _SystemInfoImpl::GetBuildInfo(buildInfo);
}
result
SystemInfo::GetNativeApiVersion(String& nativeApiVersion)
{
- result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEM);
+ result r = _AccessController::CheckUserPrivilege(_PRV_PLATFORMINFO, _PRV_SYSTEM);
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 _SystemInfoImpl::GetNativeApiVersion(nativeApiVersion);
}
result
SystemInfo::GetWebApiVersion(String& webApiVersion)
{
- result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEM);
+ result r = _AccessController::CheckUserPrivilege(_PRV_PLATFORMINFO, _PRV_SYSTEM);
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 _SystemInfoImpl::GetWebApiVersion(webApiVersion);
}
{
int reservedAlarmId = -1;
result r = E_SUCCESS;
+
int ret = 0;
service_h service;
static const wchar_t _EXTERNAL_MMC_CAMERA_PATH[] = L"/opt/storage/sdcard/Camera/";
static const wchar_t _EXTERNAL_MMC_DOWNLOADS_PATH[] = L"/opt/storage/sdcard/Downloads/";
static const wchar_t _EXTERNAL_MMC_OTHERS_PATH[] = L"/opt/storage/sdcard/Others/";
+static const wchar_t _RINGTONE_PATH[] = L"/opt/share/settings/Ringtones";
static const wchar_t _APPLICATIONS_PATH[] = L"/opt/usr/apps/";
static const wchar_t _EXTERNAL_APPLICATIONS_PATH[] = L"/opt/storage/sdcard/app2sd/";
static String path(_MEDIA_OTHERS_PATH);
return path;
}
+ case PREDEFINED_DIRECTORY_SYSTEM_RINGTONES:
+ {
+ static String path(_RINGTONE_PATH);
+ }
case PREDEFINED_DIRECTORY_EXTERNAL_IMAGES:
{
static String path(_EXTERNAL_MMC_IMAGES_PATH);
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FSys_RuntimeClient.cpp
+ * @brief This is the implementation file for _RuntimeClient class.
+ */
+
+#include <unique_ptr.h>
+
+#include <FBaseInteger.h>
+#include <FBaseLongLong.h>
+#include <FBaseSysLog.h>
+
+#include <FApp_AppInfo.h>
+
+#include <FIo_AppServiceIpcMessages.h>
+#include "FSys_CommunicationDispatcherClient.h"
+#include "FSys_RuntimeClient.h"
+
+using namespace std;
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace System
+{
+
+static const int _RUNTIME_GET_PARAM_TYPE = 1;
+static const wchar_t* _RUNTIME_SERVICE_ID = L"osp.system.service";
+static const wchar_t* _RUNTIME_GET_SIZE = L"osp.system.command.runtime.get.size";
+static const wchar_t* _RUNTIME_RESULT_SUCCESS = L"osp.system.result.success";
+static const wchar_t* _RUNTIME_RESULT_SYSTEM = L"osp.system.result.system";
+
+_RuntimeClient* _RuntimeClient::__pRuntimeClient= null;
+
+class _RuntimeAsyncEventArg : public IEventArg
+{
+public:
+ long long value;
+ result rCode;
+};
+
+class _RuntimeAsyncEvent : public Event
+{
+protected:
+ virtual void FireImpl(IEventListener& listener, const IEventArg& arg)
+ {
+ IRuntimeInfoGetLonglongAsyncResultListener* pListener = dynamic_cast<IRuntimeInfoGetLonglongAsyncResultListener*> (&listener);
+ const _RuntimeAsyncEventArg* pArg = dynamic_cast<const _RuntimeAsyncEventArg*>(&arg);
+
+ if(pListener == null || pArg == null)
+ {
+ SysLogException(NID_SYS, E_SYSTEM, "It is failed to get listener or arguemnt");
+ return;
+ }
+ pListener->OnResultReceivedForGetValueAsync(pArg->value, pArg->rCode);
+ RemoveListener(listener);
+ }
+};
+
+_RuntimeClient*
+_RuntimeClient::GetInstance(void)
+{
+ if(__pRuntimeClient == null)
+ {
+ __pRuntimeClient = new (std::nothrow) _RuntimeClient();
+ }
+ return __pRuntimeClient;
+}
+
+_RuntimeClient::_RuntimeClient()
+ : __msgCount(0)
+ , __pIpcClient(null)
+{
+ result r = E_SUCCESS;
+ static String RUNTIME_SERVICE_ID(_RUNTIME_SERVICE_ID);
+
+ _CommunicationDispatcherClient* pCommunicationDispatcherClient = _CommunicationDispatcherClient::GetInstance();
+ SysTryCatch(NID_SYS, pCommunicationDispatcherClient != null, r = E_SYSTEM, r, "It is failed to get CommunicationDispatcherClient.");
+
+ r = pCommunicationDispatcherClient->RegisterCommunicationListener(RUNTIME_SERVICE_ID, *this);
+ SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "It is failed to register on CommunicationDispatcherClient.");
+
+ __pIpcClient = pCommunicationDispatcherClient->GetIpcClient();
+
+ __asyncEventList.Construct();
+CATCH:
+ SetLastResult(r);
+}
+
+_RuntimeClient::~_RuntimeClient()
+{
+ result r = E_SUCCESS;
+ String key(_RUNTIME_SERVICE_ID);
+ _CommunicationDispatcherClient* pCommunicationDispatcherClient = _CommunicationDispatcherClient::GetInstance();
+ SysTryCatch(NID_SYS, pCommunicationDispatcherClient != null, r = E_SYSTEM, r, "It is failed to get CommunicationDispatcherClient.");
+
+ r = pCommunicationDispatcherClient->UnregisterCommunicationListener(key);
+ SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "It is failed to register on CommunicationDispatcherClient.");
+
+ __asyncEventList.RemoveAll(true);
+ __pIpcClient = null;
+CATCH:
+ SetLastResult(r);
+}
+
+result
+_RuntimeClient::GetDirectorySizeValueAsync(const String& path, IRuntimeInfoGetLonglongAsyncResultListener* listener)
+{
+ result r = E_SUCCESS;
+
+ ArrayList requestMessages;
+ ArrayList responseMessages;
+
+ requestMessages.Construct();
+ responseMessages.Construct();
+
+ String serviceId(_RUNTIME_SERVICE_ID);
+ String commandId(_RUNTIME_GET_SIZE);
+ String messageId;
+ messageId.Append(__msgCount);
+
+ requestMessages.Add(serviceId);
+ requestMessages.Add(commandId);
+ requestMessages.Add(path);
+ requestMessages.Add(messageId);
+
+ unique_ptr<IoService_Request> pMsg(new (std::nothrow) IoService_Request(requestMessages, &responseMessages));
+ r = __pIpcClient->SendRequest(*pMsg);
+ SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send request by IPC [%s]", GetErrorMessage(r));
+
+ String* pResult = (String*)responseMessages.GetAt(2);
+ SysTryReturnResult(NID_SYS, pResult != null, E_SYSTEM, "There is no result code.");
+ SysLog(NID_SYS, "Result is %ls.", pResult->GetPointer());
+
+ if(*pResult == _RUNTIME_RESULT_SUCCESS)
+ r = E_SUCCESS;
+ else
+ r = E_SYSTEM;
+
+ SysLog(NID_SYS, "r is %s.", GetErrorMessage(r));
+
+ if(r == E_SUCCESS)
+ {
+ _RuntimeAsyncEvent* pEvent = new (std::nothrow) _RuntimeAsyncEvent();
+ pEvent->AddListener(*listener);
+
+ __asyncEventList.Add(new Integer(__msgCount), pEvent);
+ __msgCount++;
+ }
+ return r;
+}
+
+void
+_RuntimeClient::OnDataReceived(const Tizen::Base::Collection::ArrayList& data)
+{
+ SysLog(NID_SYS, "Receive result");
+ String* pServiceId = (String*)(data.GetAt(0));
+ String* pResponseId = (String*)(data.GetAt(1));
+ String* pMessageId = (String*)(data.GetAt(2));
+ String* pValue = (String*)(data.GetAt(3));
+ String* pResultCode = (String*)(data.GetAt(4));
+
+ SysTryReturnVoidResult(NID_SYS, pServiceId != null && pResponseId != null && pMessageId != null && pValue != null && pResultCode != null, E_SYSTEM, "There is no result data.");
+
+ int msg_id = 0;
+ Integer::Parse(*pMessageId, msg_id);
+
+ Integer msgKey(msg_id);
+
+ _RuntimeAsyncEvent* pEvent = dynamic_cast <_RuntimeAsyncEvent*> (__asyncEventList.GetValue(msgKey));
+ SysTryReturnVoidResult(NID_SYS, pEvent != null, E_SYSTEM, "There is no registered event.");
+
+ _RuntimeAsyncEventArg* pEventArg = new (std::nothrow) _RuntimeAsyncEventArg();
+
+ LongLong::Parse(*pValue, pEventArg->value);
+
+ if(*pResultCode == _RUNTIME_RESULT_SUCCESS)
+ {
+ pEventArg->rCode = E_SUCCESS;
+ }
+ else
+ {
+ pEventArg->rCode = E_SYSTEM;
+ }
+
+ pEvent->Fire(*pEventArg);
+}
+
+} } // Tizen::System
+
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FSys_RuntimeClient.h
+ * @brief This is the header file for _RuntimeClient class.
+ */
+
+#ifndef _FSYSTEM_INTERNAL_RUNTIME_CLIENT_H_
+#define _FSYSTEM_INTERNAL_RUNTIME_CLIENT_H_
+
+#include <FIo_IpcClient.h>
+
+#include <FBaseColHashMap.h>
+#include <FBaseRtEvent.h>
+#include <FBaseRtIEventArg.h>
+#include <FBaseRtIEventListener.h>
+#include <FSys_ICommunicationDispatcherListener.h>
+#include <FSysISettingInfoSetValueAsyncResultListener.h>
+#include <FSysIRuntimeInfoGetLonglongAsyncResultListener.h>
+
+namespace Tizen { namespace System
+{
+
+class _RuntimeClient
+ : public Tizen::Base::Object
+ , public Tizen::System::_ICommunicationDispatcherListener
+{
+private:
+ _RuntimeClient(void);
+ virtual ~_RuntimeClient(void);
+
+public:
+ result GetDirectorySizeValueAsync(const Tizen::Base::String& path, IRuntimeInfoGetLonglongAsyncResultListener* listener);
+ static _RuntimeClient* GetInstance();
+
+private:
+ void OnDataReceived(const Tizen::Base::Collection::ArrayList& data);
+
+private:
+ Tizen::Base::Collection::HashMap __asyncEventList;
+ int __msgCount;
+ Tizen::Io::_IpcClient* __pIpcClient;
+
+ static _RuntimeClient* __pRuntimeClient;
+ };
+
+} } // Tizen::System
+
+#endif //_FSYSTEM_INTERNAL_RUNTIME_CLIENT_H_
#include <FBaseSysLog.h>
#include <FApp_AppInfo.h>
#include <FBase_StringConverter.h>
-#include <FSys_EnvironmentImpl.h>
-#include <FSys_RuntimeInfoImpl.h>
+
+#include "FSys_EnvironmentImpl.h"
+#include "FSys_RuntimeInfoImpl.h"
+#include "FSys_RuntimeClient.h"
using namespace Tizen::App;
using namespace Tizen::Base;
int thr_id = 0;
pthread_t p_thread;
result r = E_SUCCESS;
- char* directoryPath = null;
+ String directoryPath;
SysTryReturnResult(NID_SYS, listener != null, E_INVALID_ARG, "listener is null");
if(key == _STORAGE_ALLOCATED_INTERNAL_APPLICATION)
{
- directoryPath = _StringConverter::CopyToCharArrayN(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_APPLICATIONS));
+ directoryPath.Append(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_APPLICATIONS));
}
else if (key == _STORAGE_ALLOCATED_INTERNAL_AUDIO)
{
- directoryPath = _StringConverter::CopyToCharArrayN(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_SOUNDS));
+ directoryPath.Append(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_SOUNDS));
}
else if (key == _STORAGE_ALLOCATED_INTERNAL_VIDEO)
{
- directoryPath = _StringConverter::CopyToCharArrayN(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_VIDEOS));
+ directoryPath.Append(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_VIDEOS));
}
else if (key == _STORAGE_ALLOCATED_INTERNAL_IMAGE)
{
- directoryPath = _StringConverter::CopyToCharArrayN(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_IMAGES));
+ directoryPath.Append(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_IMAGES));
}
else if (key == _STORAGE_ALLOCATED_INTERNAL_DOWNLOAD)
{
- directoryPath = _StringConverter::CopyToCharArrayN(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_DOWNLOADS));
+ directoryPath.Append(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_DOWNLOADS));
}
else if (key == _STORAGE_ALLOCATED_EXTERNAL_APPLICATION)
{
- directoryPath = _StringConverter::CopyToCharArrayN(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_EXTERNAL_APPLICATIONS));
+ directoryPath.Append(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_EXTERNAL_APPLICATIONS));
}
else if (key == _STORAGE_ALLOCATED_EXTERNAL_AUDIO)
{
- directoryPath = _StringConverter::CopyToCharArrayN(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_EXTERNAL_SOUNDS));
+ directoryPath.Append(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_EXTERNAL_SOUNDS));
}
else if (key == _STORAGE_ALLOCATED_EXTERNAL_VIDEO)
{
- directoryPath = _StringConverter::CopyToCharArrayN(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_EXTERNAL_VIDEOS));
+ directoryPath.Append(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_EXTERNAL_VIDEOS));
}
else if (key == _STORAGE_ALLOCATED_EXTERNAL_IMAGE)
{
- directoryPath = _StringConverter::CopyToCharArrayN(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_EXTERNAL_IMAGES));
+ directoryPath.Append(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_EXTERNAL_IMAGES));
}
-
else if (key == _STORAGE_ALLOCATED_EXTERNAL_DOWNLOAD)
{
- directoryPath = _StringConverter::CopyToCharArrayN(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_EXTERNAL_DOWNLOADS));
+ directoryPath.Append(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_EXTERNAL_DOWNLOADS));
}
else
{
}
SysLog(NID_SYS, "%s", GetErrorMessage(r));
- SysLog(NID_SYS, "%s", directoryPath);
+ SysLog(NID_SYS, "%ls", directoryPath.GetPointer());
if(r == E_SUCCESS)
{
- if(listener != null)
- {
- SysLog(NID_SYS, "listener instance is %x.", listener);
- runtimeInfoEvent.AddListener(*listener);
- }
-
- _RuntimeInfoEventArg* pEventArg = new (std::nothrow) _RuntimeInfoEventArg();
- pEventArg->pListener = listener;
- pEventArg->DirectoryPath = directoryPath;
-
- thr_id = pthread_create(&p_thread, null, GetDirectorySizeAsync, pEventArg);
- SysLog(NID_SYS, "Thread id is %d.", thr_id);
- pthread_detach(p_thread);
+ _RuntimeClient* pRuntimeClient = _RuntimeClient::GetInstance();
+ pRuntimeClient->GetDirectorySizeValueAsync(directoryPath, listener);
}
return r;