2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FIo_MmcStorageManagerProxy.cpp
20 * @brief This is the implementation for the _MmcStorageManagerProxy class.
26 #include <FBaseErrors.h>
27 #include <FBaseSysLog.h>
28 #include <FIo_IpcClient.h>
30 #include "FIo_IMmcStorageServiceEventListener.h"
31 #include "FIo_MmcStorageManagerProxy.h"
32 #include "FIo_MmcStorageManagerIpcMessages.h"
34 using namespace Tizen::Base;
36 namespace Tizen { namespace Io
39 _IMmcStorageServiceEventListener* _MmcStorageManagerProxy::__pImpl = null;
41 _MmcStorageManagerProxy::_MmcStorageManagerProxy(void)
46 _MmcStorageManagerProxy::~_MmcStorageManagerProxy(void)
52 _MmcStorageManagerProxy::Construct(_IMmcStorageServiceEventListener* pImpl)
54 __pIpcClient = new (std::nothrow) _IpcClient();
55 SysTryReturnResult(NID_IO, __pIpcClient != null, E_OUT_OF_MEMORY, "_IpcClient creation failed.");
57 result r = __pIpcClient->Construct("osp.io.ipcserver.mmcstoragemanager", this);
58 SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] _IpcClient::Construct failed.", GetErrorMessage(r));
66 _MmcStorageManagerProxy::Mount(void)
68 SysTryReturnResult(NID_IO, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null.");
70 result response = E_SUCCESS;
71 std::auto_ptr<IPC::Message> pMsg (new (std::nothrow) MmcStorageManager_Mount(&response));
72 result r = __pIpcClient->SendRequest(pMsg.get());
74 SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] SendRequest is failed.", GetErrorMessage(r));
76 SysLog(NID_IO, "Received sync mount response msg from server is: [%s]\n", GetErrorMessage(response));
81 _MmcStorageManagerProxy::Unmount(void)
83 SysTryReturnResult(NID_IO, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null.");
85 result response = E_SUCCESS;
86 std::auto_ptr<IPC::Message> pMsg (new (std::nothrow) MmcStorageManager_Unmount(&response));
87 result r = __pIpcClient->SendRequest(pMsg.get());
89 SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] SendRequest is failed.", GetErrorMessage(r));
91 SysLog(NID_IO, "Received sync unmount response msg from server is: [%s]\n", GetErrorMessage(response));
96 _MmcStorageManagerProxy::Format(void)
98 SysTryReturnResult(NID_IO, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null.");
100 result response = E_SUCCESS;
101 std::auto_ptr<IPC::Message> pMsg (new (std::nothrow) MmcStorageManager_Format(&response));
102 result r = __pIpcClient->SendRequest(pMsg.get());
104 SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] SendRequest is failed.", GetErrorMessage(r));
106 SysLog(NID_IO, "Received sync format response msg from server is: [%s]\n", GetErrorMessage(response));
111 _MmcStorageManagerProxy::OnIpcResponseReceived(Tizen::Io::_IpcClient& client, const IPC::Message& message)
113 IPC_BEGIN_MESSAGE_MAP(_MmcStorageManagerProxy, message)
114 IPC_MESSAGE_HANDLER_EX(MmcStorageManager_MountReceived, &client, MountResponseReceived)
115 IPC_MESSAGE_HANDLER_EX(MmcStorageManager_UnmountReceived, &client, UnmountResponseReceived)
116 IPC_MESSAGE_HANDLER_EX(MmcStorageManager_FormatReceived, &client, FormatResponseReceived)
117 IPC_END_MESSAGE_MAP()
121 _MmcStorageManagerProxy::MountResponseReceived(result r)
123 SysLog(NID_IO, "Received Async mount response msg from server is : [%s]\n", GetErrorMessage(r));
124 __pImpl->OnMmcMountResponseReceived(r);
128 _MmcStorageManagerProxy::UnmountResponseReceived(result r)
130 SysLog(NID_IO, "Received Async unmount response msg from server is : [%s]\n", GetErrorMessage(r));
131 __pImpl->OnMmcUnmountResponseReceived(r);
135 _MmcStorageManagerProxy::FormatResponseReceived(result r)
137 SysLog(NID_IO, "Received Async format response msg from server is : [%s]\n", GetErrorMessage(r));
138 __pImpl->OnMmcFormatResponseReceived(r);