#include <FBaseSysLog.h>
#include <FIoMmcStorageManager.h>
-#include <FSec_AccessController.h>
#include <FBase_NativeError.h>
#include <FIo_MmcStorageManagerImpl.h>
+#include <FSec_AccessController.h>
using namespace Tizen::Base;
using namespace Tizen::Security;
pInst->__pMmcStorageManagerImpl = _MmcStorageManagerImpl::GetInstance();
SysTryCatch(NID_IO, pInst->__pMmcStorageManagerImpl != null, , GetLastResult(),
- "[%s] Propagated.", GetErrorMessage(GetLastResult()));
+ "[%s] Propagating to caller...", GetErrorMessage(GetLastResult()));
__pMmcStorageManagerInstance = pInst;
#include <FBaseSysLog.h>
#include <FBaseRtIEventArg.h>
#include <FBase_NativeError.h>
-#include <FIoIMmcStorageMountListener.h>
-#include <FIoIMmcStorageFormatListener.h>
+#include "FIoIMmcStorageMountListener.h"
+#include "FIoIMmcStorageFormatListener.h"
#include "FIo_MmcStorageManagerImpl.h"
#include "FIo_MmcStorageManagerProxy.h"
_MmcStorageManagerImpl::~_MmcStorageManagerImpl(void)
{
- delete __pMmcStorageManagerProxy;
delete __pMountEvent;
delete __pFormatEvent;
}
result
_MmcStorageManagerImpl::Construct(void)
{
- result r = E_SUCCESS;
-
- unique_ptr<_MmcStorageManagerProxy> pMmcStorageManagerProxy(new (std::nothrow) _MmcStorageManagerProxy);
- SysTryReturnResult(NID_IO, pMmcStorageManagerProxy != null, E_OUT_OF_MEMORY, "The memory is insufficient");
-
- r = pMmcStorageManagerProxy->Construct(this);
- SysTryReturnResult(NID_IO, r == E_SUCCESS, r, "__pMmcStorageManagerProxy->Construct() failed.");
-
unique_ptr<_MountEvent> pMountEvent(new (std::nothrow) _MountEvent);
SysTryReturnResult(NID_IO, pMountEvent != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
unique_ptr<_FormatEvent> pFormatEvent(new (std::nothrow) _FormatEvent);
SysTryReturnResult(NID_IO, pFormatEvent != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
- __pMmcStorageManagerProxy = pMmcStorageManagerProxy.release();
-
__pMountEvent = pMountEvent.release();
__pFormatEvent = pFormatEvent.release();
static _MmcStorageManagerImpl* pImpl = null;
if (pImpl == null)
{
- unique_ptr<_MmcStorageManagerImpl> p(new (std::nothrow) _MmcStorageManagerImpl);
- SysTryReturn(NID_IO, p != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ unique_ptr<_MmcStorageManagerImpl> pMmcStorageManagerImpl(new (std::nothrow) _MmcStorageManagerImpl);
+ SysTryReturn(NID_IO, pMmcStorageManagerImpl != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
- result r = p->Construct();
- SysTryReturn(NID_IO, r == E_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Failed to initialize channel.");
+ result r = pMmcStorageManagerImpl->Construct();
+ SysTryReturn(NID_IO, !IsFailed(r), null, r, "[%s] Propagating to caller...", GetErrorMessage(r));
- pImpl = p.release();
+ pImpl = pMmcStorageManagerImpl.release();
}
return pImpl;
-
}
result
_MmcStorageManagerImpl::Mount(void)
{
+ if (__pMmcStorageManagerProxy == null)
+ {
+ __pMmcStorageManagerProxy = _MmcStorageManagerProxy::GetInstance();
+ SysTryReturnResult(NID_IO, __pMmcStorageManagerProxy != null, E_SERVICE_BUSY, "Failed to get IPC proxy instance.");
+ __pMmcStorageManagerProxy->SetMmcStorageManagerListener(this);
+ }
return __pMmcStorageManagerProxy->Mount();
}
result
_MmcStorageManagerImpl::Unmount(void)
{
+ if (__pMmcStorageManagerProxy == null)
+ {
+ __pMmcStorageManagerProxy = _MmcStorageManagerProxy::GetInstance();
+ SysTryReturnResult(NID_IO, __pMmcStorageManagerProxy != null, E_SERVICE_BUSY, "Failed to get IPC proxy instance.");
+ __pMmcStorageManagerProxy->SetMmcStorageManagerListener(this);
+ }
return __pMmcStorageManagerProxy->Unmount();
}
result
_MmcStorageManagerImpl::Format(void)
{
+ if (__pMmcStorageManagerProxy == null)
+ {
+ __pMmcStorageManagerProxy = _MmcStorageManagerProxy::GetInstance();
+ SysTryReturnResult(NID_IO, __pMmcStorageManagerProxy != null, E_SERVICE_BUSY, "Failed to get IPC proxy instance.");
+ __pMmcStorageManagerProxy->SetMmcStorageManagerListener(this);
+ }
return __pMmcStorageManagerProxy->Format();
}
#include <FBaseErrors.h>
#include <FBaseSysLog.h>
-#include <FIo_IpcClient.h>
+#include "FIo_IpcClient.h"
-#include "FIo_IMmcStorageServiceEventListener.h"
#include "FIo_MmcStorageManagerProxy.h"
#include "FIo_MmcStorageManagerIpcMessages.h"
using namespace std;
-
using namespace Tizen::Base;
namespace Tizen { namespace Io
{
+_MmcStorageManagerProxy* _MmcStorageManagerProxy::__pMmcStorageManagerProxyInstance = null;
+
_MmcStorageManagerProxy::_MmcStorageManagerProxy(void)
: __pIpcClient(null)
+ , __pListener(null)
{
}
}
result
-_MmcStorageManagerProxy::Construct(_IMmcStorageServiceEventListener* pListener)
+_MmcStorageManagerProxy::Construct(void)
{
unique_ptr<_IpcClient> pIpcClient(new (std::nothrow) _IpcClient);
SysTryReturnResult(NID_IO, pIpcClient != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
SysTryReturnResult(NID_IO, r == E_SUCCESS, r, "Failed to connect to IPC server.");
__pIpcClient = pIpcClient.release();
- __pListener = pListener;
return E_SUCCESS;
}
+void
+_MmcStorageManagerProxy::InitSingleton(void)
+{
+ _MmcStorageManagerProxy* pInst = new (std::nothrow) _MmcStorageManagerProxy();
+ SysTryReturnVoidResult(NID_IO, pInst != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ result r = pInst->Construct();
+ SysTryCatch(NID_IO, !IsFailed(r), , r, "[%s] Propagating to caller...", GetErrorMessage(r));
+
+ __pMmcStorageManagerProxyInstance = pInst;
+
+ std::atexit(DestroySingleton);
+ return;
+
+CATCH:
+ delete pInst;
+}
+
+void
+_MmcStorageManagerProxy::DestroySingleton(void)
+{
+ delete __pMmcStorageManagerProxyInstance;
+}
+
+_MmcStorageManagerProxy*
+_MmcStorageManagerProxy::GetInstance(void)
+{
+ static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+
+ if (__pMmcStorageManagerProxyInstance == null)
+ {
+ ClearLastResult();
+ pthread_once(&onceBlock, InitSingleton);
+ result r = GetLastResult();
+ if (IsFailed(r))
+ {
+ onceBlock = PTHREAD_ONCE_INIT;
+ SysPropagate(NID_IO, r);
+ }
+ }
+
+ return __pMmcStorageManagerProxyInstance;
+}
+
+void
+_MmcStorageManagerProxy::SetMmcStorageManagerListener(_IMmcStorageManagerListener* pListener)
+{
+ __pListener = pListener;
+}
+
result
_MmcStorageManagerProxy::Mount(void)
{
_MmcStorageManagerProxy::MountResponseReceived(result r)
{
SysLog(NID_IO, "Received Async mount response msg from server is : [%s]", GetErrorMessage(r));
-
- __pListener->OnMmcMountResponseReceived(r);
+ if (__pListener != null)
+ {
+ __pListener->OnMmcMountResponseReceived(r);
+ }
}
void
_MmcStorageManagerProxy::UnmountResponseReceived(result r)
{
SysLog(NID_IO, "Received Async unmount response msg from server is : [%s]", GetErrorMessage(r));
-
- __pListener->OnMmcUnmountResponseReceived(r);
+ if (__pListener != null)
+ {
+ __pListener->OnMmcUnmountResponseReceived(r);
+ }
}
void
_MmcStorageManagerProxy::FormatResponseReceived(result r)
{
SysLog(NID_IO, "Received Async format response msg from server is : [%s]", GetErrorMessage(r));
-
- __pListener->OnMmcFormatResponseReceived(r);
+ if (__pListener != null)
+ {
+ __pListener->OnMmcFormatResponseReceived(r);
+ }
}
-} } // Tizen::Io
+}} // Tizen::Io
+
//
-// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+// Copyright (c) 2013 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.
//
/**
- * @file FIo_IMmcStorageServiceEventListener.h
- * @brief This is the header file for the _IMmcStorageServiceEventListener class.
+ * @file FIo_IMmcStorageManagerListener.h
+ * @brief This is the header file for the _IMmcStorageManagerListener class.
*/
-#ifndef _FIO_INTERNAL_IMMC_STORAGE_SERVICE_EVENT_LISTENER_H_
-#define _FIO_INTERNAL_IMMC_STORAGE_SERVICE_EVENT_LISTENER_H_
+#ifndef _FIO_INTERNAL_IMMC_STORAGE_MANAGER_LISTENER_H_
+#define _FIO_INTERNAL_IMMC_STORAGE_MANAGER_LISTENER_H_
#include <FBaseResult.h>
#include <FBaseRtIEventListener.h>
{
/**
- * @interface _IMmcStorageServiceEventListener
+ * @interface _IMmcStorageManagerListener
* @brief This interface defines the listener for the events from _MmcStorageManagerService
- * @since 2.1
+ * @since 2.2
*
* Application should not implement this interface.
*/
-class _OSP_EXPORT_ _IMmcStorageServiceEventListener
+class _OSP_EXPORT_ _IMmcStorageManagerListener
: virtual public Tizen::Base::Runtime::IEventListener
{
-public:
- ~_IMmcStorageServiceEventListener(void) {}
+public:
+ ~_IMmcStorageManagerListener(void) {}
virtual void OnMmcMountResponseReceived(result r) = 0;
virtual void OnMmcUnmountResponseReceived(result r) = 0;
virtual void OnMmcFormatResponseReceived(result r) = 0;
-}; // _MmcStorageServiceEventListener
-} } // Tizen::Io
+}; // _MmcStorageManagerListener
+
+}} // Tizen::Io
+
+#endif // _FIO_INTERNAL_IMMC_STORAGE_MANAGER_LISTENER_H_
-#endif // _FIO_INTERNAL_IMMC_STORAGE_SERVICE_EVENT_LISTENER_H_
#include <FBaseColLinkedListT.h>
#include <FBaseRtEvent.h>
-#include <FIoMmcStorageManager.h>
-
-#include "FIo_IMmcStorageServiceEventListener.h"
+#include "FIo_IMmcStorageManagerListener.h"
namespace Tizen { namespace Io
{
class IMmcStorageFormatListener;
class _OSP_EXPORT_ _MmcStorageManagerImpl
- : public _IMmcStorageServiceEventListener
+ : public _IMmcStorageManagerListener
{
public:
private:
_MmcStorageManagerImpl(void);
+
result Construct(void);
_MmcStorageManagerImpl(const _MmcStorageManagerImpl& source);
+
_MmcStorageManagerImpl& operator =(const _MmcStorageManagerImpl& source);
private:
#include <FBaseString.h>
#include <FIo_IIpcClientEventListener.h>
+#include <FIo_IMmcStorageManagerListener.h>
namespace Tizen { namespace Io
{
-class _IMmcStorageServiceEventListener;
class _IpcClient;
class _MmcStorageManagerProxy
{
public:
_MmcStorageManagerProxy(void);
+
virtual ~_MmcStorageManagerProxy(void);
- result Construct(_IMmcStorageServiceEventListener* pListener);
+ result Construct(void);
result Mount(void);
+
result Unmount(void);
+
result Format(void);
virtual void OnIpcResponseReceived(Tizen::Io::_IpcClient& client, const IPC::Message& message);
void MountResponseReceived(result r);
+
void UnmountResponseReceived(result r);
+
void FormatResponseReceived(result r);
+ void SetMmcStorageManagerListener(_IMmcStorageManagerListener* pListener);
+
+ static _MmcStorageManagerProxy* GetInstance(void);
+
private:
_MmcStorageManagerProxy(const _MmcStorageManagerProxy& rhs);
_MmcStorageManagerProxy& operator =(const _MmcStorageManagerProxy& rhs);
+ static void InitSingleton(void);
+
+ static void DestroySingleton(void);
+
private:
+ static _MmcStorageManagerProxy* __pMmcStorageManagerProxyInstance;
_IpcClient* __pIpcClient;
- _IMmcStorageServiceEventListener* __pListener;
+ _IMmcStorageManagerListener* __pListener;
}; // _MmcStorageManagerProxy
-} } // Tizen::App
+}} // Tizen::Io
#endif // _FIO_INTERNAL_MMC_STORAGE_MANAGER_PROXY_H_