setting/providers/FSys_SettingSpeechProvider.cpp
setting/providers/FSys_SettingStorageProvider.cpp
setting/providers/FSys_SettingVibrationProvider.cpp
+ runtime/FSys_RuntimeInfo.cpp
)
INCLUDE(FindPkgConfig)
--- /dev/null
+//
+// 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_RuntimeInfo.h
+ * @brief This is the header file for the _RuntimeInfo class.
+ */
+
+#ifndef _FSYS_SERVICE_SYS_RUNTIME_INFO__H_
+#define _FSYS_SERVICE_SYS_RUNTIME_INFO__H_
+
+#include <FApp.h>
+#include <FBase.h>
+
+namespace Tizen { namespace System
+{
+class _OSP_EXPORT_ _RuntimeInfo
+{
+public:
+ static _RuntimeInfo* GetInstance(void);
+ static long long GetDirectorySize(const char* path);
+
+private:
+ _RuntimeInfo();
+ virtual ~_RuntimeInfo();
+
+private:
+ static _RuntimeInfo* __pRuntimeInfo;
+};
+
+} } // Tizen::System
+
+#endif // _FSYS_SERVICE_SYS_RUNTIME_INFO__H_
--- /dev/null
+//
+// 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_RuntimeInfo.cpp
+ * @brief This is the implementation file for _RuntimeInfo class.
+ */
+
+#include <pthread.h>
+#include <errno.h>
+#include <string.h>
+#include <stdio.h>
+#include <dirent.h>
+#include <sys/stat.h>
+
+#include <FBaseSysLog.h>
+#include "FSys_RuntimeInfo.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace System
+{
+
+_RuntimeInfo::_RuntimeInfo()
+{
+}
+
+_RuntimeInfo::~_RuntimeInfo()
+{
+}
+
+long long
+_RuntimeInfo::GetDirectorySize(const char* path)
+{
+ struct dirent *de;
+ struct stat buf;
+ DIR* d = opendir(path);
+ long long total_size = 0;
+ if(d == null)
+ {
+ return 0;
+ }
+
+ for (de = readdir(d); de != null; de = readdir(d))
+ {
+ char filePath[1024] = {0,};
+ sprintf(filePath, "%s%s", path, de->d_name);
+
+ if (lstat(filePath, &buf) == 0)
+ {
+ if (S_ISLNK(buf.st_mode) == true)
+ {
+ total_size += buf.st_size;
+ }
+ else // reg file
+ {
+ if(stat(filePath, &buf) == 0)
+ {
+ if(S_ISDIR(buf.st_mode) == true)
+ {
+ char directoryName[1024] = {0,};
+ sprintf(directoryName, "%s%s/", path, de->d_name);
+ if(strcmp(de->d_name, ".") != 0 && strcmp(de->d_name, "..") != 0)
+ {
+ total_size += GetDirectorySize(directoryName);
+ }
+ total_size += buf.st_size;
+
+ }
+ else
+ {
+ total_size += buf.st_size;
+ }
+ }
+ }
+ }
+ }
+ closedir(d);
+ return total_size;
+}
+} } // Tizen::System
FSys_PowerManagerImpl.cpp
FSysRuntimeInfo.cpp
FSys_RuntimeClient.cpp
+ FSys_RuntimeClientEx.cpp
FSys_RuntimeInfoImpl.cpp
FSysSettingInfo.cpp
FSys_SettingInfoImpl.cpp
FSys_SettingClient.cpp
FSys_SettingClientEx.cpp
FSys_SystemClient.cpp
+ FSys_SystemServiceMessageClient.cpp
)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
--- /dev/null
+//
+// 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_RuntimeClientEx.cpp
+ * @brief This is the implementation file for _RuntimeClientEx class.
+ */
+
+#include <unique_ptr.h>
+
+#include <FBaseInteger.h>
+#include <FBaseLongLong.h>
+#include <FBaseSysLog.h>
+
+#include <FApp_AppInfo.h>
+
+#include <FIo_AppServiceIpcMessages.h>
+#include "FSys_SystemServiceMessageClient.h"
+#include "FSys_RuntimeClientEx.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.sys.ipcserver.runtimeinfo";
+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";
+
+_RuntimeClientEx* _RuntimeClientEx::__pRuntimeClientEx= 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);
+ }
+};
+
+_RuntimeClientEx*
+_RuntimeClientEx::GetInstance(void)
+{
+ if(__pRuntimeClientEx == null)
+ {
+ __pRuntimeClientEx = new (std::nothrow) _RuntimeClientEx();
+ }
+ return __pRuntimeClientEx;
+}
+
+_RuntimeClientEx::_RuntimeClientEx()
+ : __msgCount(0)
+ , __pIpcClient(null)
+ , __pMessageClient(null)
+{
+ result r = E_SUCCESS;
+ static String RUNTIME_SERVICE_ID(_RUNTIME_SERVICE_ID);
+
+ __pMessageClient = _SystemServiceMessageClient::CreateInstance(RUNTIME_SERVICE_ID);
+ SysTryCatch(NID_SYS, __pMessageClient != null, r = E_SYSTEM, r, "It is failed to create SystemServiceMessageClient.");
+
+ r = __pMessageClient->RegisterListener(RUNTIME_SERVICE_ID, *this);
+ SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "It is failed to register on MessageClient.");
+
+ __pIpcClient = __pMessageClient->GetIpcClient();
+
+ __asyncEventList.Construct();
+CATCH:
+ SetLastResult(r);
+}
+
+_RuntimeClientEx::~_RuntimeClientEx()
+{
+ result r = E_SUCCESS;
+ String key(_RUNTIME_SERVICE_ID);
+ r = __pMessageClient->UnregisterListener(key);
+ SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "It is failed to register on MessageClient.");
+
+ __asyncEventList.RemoveAll(true);
+ __pIpcClient = null;
+ delete __pMessageClient;
+CATCH:
+ SetLastResult(r);
+}
+
+result
+_RuntimeClientEx::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.");
+
+ 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
+_RuntimeClientEx::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
+//
+// 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_RuntimeClientEx.h
+ * @brief This is the header file for _RuntimeClientEx class.
+ */
+
+#ifndef _FSYSTEM_INTERNAL_RUNTIME_CLIENT_EX_H_
+#define _FSYSTEM_INTERNAL_RUNTIME_CLIENT_EX_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>
+#include "FSys_SystemServiceMessageClient.h"
+
+namespace Tizen { namespace System
+{
+
+class _RuntimeClientEx
+ : public Tizen::Base::Object
+ , public Tizen::System::_ICommunicationDispatcherListener
+{
+private:
+ _RuntimeClientEx(void);
+ virtual ~_RuntimeClientEx(void);
+
+public:
+ result GetDirectorySizeValueAsync(const Tizen::Base::String& path, IRuntimeInfoGetLonglongAsyncResultListener* listener);
+ static _RuntimeClientEx* GetInstance();
+
+private:
+ void OnDataReceived(const Tizen::Base::Collection::ArrayList& data);
+
+private:
+ Tizen::Base::Collection::HashMap __asyncEventList;
+ int __msgCount;
+ Tizen::Io::_IpcClient* __pIpcClient;
+ _SystemServiceMessageClient* __pMessageClient;
+ static _RuntimeClientEx* __pRuntimeClientEx;
+ };
+
+} } // Tizen::System
+
+#endif //_FSYSTEM_INTERNAL_RUNTIME_CLIENT_EX_H_
#include <runtime_info.h>
#include <vconf.h>
+#include <FIo.h>
#include <FAppApp.h>
#include <FBaseRtEvent.h>
#include <FBaseRtIEventArg.h>
#include "FSys_EnvironmentImpl.h"
#include "FSys_RuntimeInfoImpl.h"
#include "FSys_RuntimeClient.h"
+#include "FSys_RuntimeClientEx.h"
using namespace Tizen::App;
using namespace Tizen::Base;
SysLog(NID_SYS, "%ls", directoryPath.GetPointer());
if(r == E_SUCCESS)
{
- _RuntimeClient* pRuntimeClient = _RuntimeClient::GetInstance();
- pRuntimeClient->GetDirectorySizeValueAsync(directoryPath, listener);
+ if(Tizen::Io::File::IsFileExist(L"/opt/usr/etc/common_service_for_runtime") == true)
+ {
+ SysLog(NID_SYS, "Runtime is serviced by common-service.");
+ _RuntimeClientEx* pRuntimeClientEx = _RuntimeClientEx::GetInstance();
+ pRuntimeClientEx->GetDirectorySizeValueAsync(directoryPath, listener);
+ }
+ else
+ {
+ SysLog(NID_SYS, "Runtime is serviced by app-service.");
+ _RuntimeClient* pRuntimeClient = _RuntimeClient::GetInstance();
+ pRuntimeClient->GetDirectorySizeValueAsync(directoryPath, listener);
+ }
}
return r;
--- /dev/null
+//
+// 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_SystemServiceMessageClient.cpp
+ * @brief This is the implementation file for _SystemServiceMessageClient class.
+ */
+
+#include <FApp_AppInfo.h>
+#include <FBaseSysLog.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <FIo_AppServiceIpcMessages.h>
+#include "FSys_SystemServiceMessageClient.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace System
+{
+_SystemServiceMessageClient::_SystemServiceMessageClient()
+ : __pIpcClient(null)
+ , __pSystemServiceMessageListener(null)
+{
+}
+
+_SystemServiceMessageClient::_SystemServiceMessageClient(const String id)
+ : __pIpcClient(null)
+ , __pSystemServiceMessageListener(null)
+{
+ result r = E_SUCCESS;
+ std::unique_ptr< _IpcClient > pIpcClient(new (std::nothrow) _IpcClient());
+ SysTryReturn(NID_SYS, pIpcClient != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] It is failed to create IPC client");
+
+ r = pIpcClient->Construct(id, this);
+ SysTryReturn(NID_SYS, r == E_SUCCESS, , r, "Propagated. [%s]", GetErrorMessage(r));
+
+ __pIpcClient = std::move(pIpcClient);
+ SetLastResult(r);
+}
+_SystemServiceMessageClient::~_SystemServiceMessageClient()
+{
+}
+
+_SystemServiceMessageClient*
+_SystemServiceMessageClient::CreateInstance(const Tizen::Base::String id)
+{
+ _SystemServiceMessageClient* pSystemServiceMessageClient = new (std::nothrow) _SystemServiceMessageClient(id);
+ SysTryReturn(NID_SYS, pSystemServiceMessageClient, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] It is not enough memory.");
+ return pSystemServiceMessageClient;
+}
+
+_IpcClient*
+_SystemServiceMessageClient::GetIpcClient()
+{
+ return __pIpcClient.get();
+}
+
+result
+_SystemServiceMessageClient::RegisterListener(const String key, _ICommunicationDispatcherListener& listener)
+{
+ SysTryReturnResult(NID_SYS, !__pSystemServiceMessageListener, E_OBJ_ALREADY_EXIST,
+ "SystemService listener was set already.[%ls]", key.GetPointer());
+ __pSystemServiceMessageListener = &listener;
+ return E_SUCCESS;
+}
+
+result
+_SystemServiceMessageClient::UnregisterListener(const String key)
+{
+ SysTryReturnResult(NID_SYS, __pSystemServiceMessageListener, E_OBJ_NOT_FOUND,
+ "SystemService listener is not set.[%ls]",key.GetPointer());
+ __pSystemServiceMessageListener = null;
+ return E_SUCCESS;
+}
+
+void
+_SystemServiceMessageClient::OnIpcResponseReceived(_IpcClient& client, const IPC::Message& message)
+{
+ SysLog(NID_SYS, "Enter.");
+ IPC_BEGIN_MESSAGE_MAP(_SystemServiceMessageClient, message)
+ IPC_MESSAGE_HANDLER_EX(IoService_Data, &client, OnDataReceived)
+ IPC_END_MESSAGE_MAP_EX()
+ SysLog(NID_SYS, "Exit.");
+}
+
+void
+_SystemServiceMessageClient::OnDataReceived(const ArrayList& data)
+{
+ result r = E_SUCCESS;
+ String* pServiceId = (String*) data.GetAt(0);
+
+ SysTryReturnVoidResult(NID_SYS, pServiceId != null, E_SYSTEM, "There is no service id.");
+ SysLog(NID_SYS, "Service id = %ls", pServiceId->GetPointer());
+
+ SysTryReturnVoidResult(NID_SYS, __pSystemServiceMessageListener, E_SYSTEM,
+ "Service[%ls] is available, but listener does not exist. [%s]", pServiceId->GetPointer(), GetErrorMessage(r));
+
+ __pSystemServiceMessageListener->OnDataReceived(data);
+
+ SysLog(NID_SYS, "Message is delivered to \"%ls\"[%x]", pServiceId->GetPointer(), __pSystemServiceMessageListener);
+ ArrayList* temp = const_cast< ArrayList *> (&data);
+ temp->RemoveAll(true);
+}
+
+}}
--- /dev/null
+//
+// 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_SystemServiceMessageClient.h
+ * @brief This is the header file for the _SystemServiceMessageClient class.
+ */
+
+#ifndef _FSYS_INTERNAL_SYSTEM_SERVICE_MESSAGE_CLIENT_IMPL_H_
+#define _FSYS_INTERNAL_SYSTEM_SERVICE_MESSAGE_CLIENT_IMPL_H_
+
+#include <unique_ptr.h>
+#include <FBaseString.h>
+#include <FBaseComparerT.h>
+#include <FBaseStringHashCodeProvider.h>
+#include <FBaseColHashMapT.h>
+
+#include <FIo_IpcClient.h>
+#include <FIo_IIpcClientEventListener.h>
+#include <FSys_ICommunicationDispatcherListener.h>
+
+namespace Tizen { namespace System
+{
+
+class _SystemServiceMessageClient
+ : public Tizen::Io::_IIpcClientEventListener
+{
+private:
+ _SystemServiceMessageClient();
+public:
+ _SystemServiceMessageClient(const Tizen::Base::String id);
+ ~_SystemServiceMessageClient();
+ result RegisterListener(const Tizen::Base::String key, _ICommunicationDispatcherListener& listener);
+ result UnregisterListener(const Tizen::Base::String key);
+ void OnIpcResponseReceived(Tizen::Io::_IpcClient& client, const IPC::Message& message);
+ void OnDataReceived(const Tizen::Base::Collection::ArrayList& data);
+
+ Tizen::Io::_IpcClient* GetIpcClient(void);
+ static _SystemServiceMessageClient* CreateInstance(const Tizen::Base::String id);
+
+private:
+ std::unique_ptr< Tizen::Io::_IpcClient > __pIpcClient;
+ _ICommunicationDispatcherListener* __pSystemServiceMessageListener;
+};
+
+}} // Tizen::System
+
+#endif //_FSYS_INTERNAL_SYSTEM_SERVICE_MESSAGE_CLIENT_IMPL_H_