Set packageId for efltpk
[platform/framework/native/appfw.git] / src / app / FApp_ConditionManagerProxy.cpp
index bef8692..2c77a29 100644 (file)
@@ -1,5 +1,4 @@
 //
-// Open Service Platform
 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
 //
 // Licensed under the Apache License, Version 2.0 (the License);
@@ -23,8 +22,9 @@
 #include <new>
 #include <memory>
 
-#include <FBaseErrors.h>
+#include <unique_ptr.h>
 
+#include <FBaseErrors.h>
 #include <FBaseSysLog.h>
 #include <FIo_IpcClient.h>
 
 
 using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
+using namespace Tizen::Io;
 
 namespace Tizen { namespace App
 {
 
+const char CONDITION_MANAGER_IPC_NAME[] = "osp.app.ipcserver.conditionmanager";
+
 _ConditionManagerProxy::_ConditionManagerProxy(void)
        : __pIpcClient(null)
 {
@@ -52,17 +55,19 @@ _ConditionManagerProxy::~_ConditionManagerProxy(void)
 result
 _ConditionManagerProxy::Construct()
 {
-       __pIpcClient = new (std::nothrow) Tizen::Io::_IpcClient();
-       SysTryReturnResult(NID_APP, __pIpcClient != null, E_OUT_OF_MEMORY, "_IpcClient creation failed.");
+       std::unique_ptr<_IpcClient> pIpcClient(new (std::nothrow) _IpcClient());
+       SysTryReturnResult(NID_APP, pIpcClient.get() != null, E_OUT_OF_MEMORY, "_IpcClient creation failed.");
+
+       result r = pIpcClient->Construct(CONDITION_MANAGER_IPC_NAME);
+       SysTryReturn(NID_APP, !IsFailed(r), r, r, "[%%s] _IpcClient constructing faliied.", GetErrorMessage(r));
 
-       result r = __pIpcClient->Construct("osp.app.ipcserver.conditionmanager");
-       SysTryReturn(NID_APP, !IsFailed(r), r, r, "_IpcClient constructing faliied [%s].", GetErrorMessage(r));
+       __pIpcClient = pIpcClient.release();
 
        return E_SUCCESS;
 }
 
 result
-_ConditionManagerProxy::RegisterAppLaunch(const AppId& appId, const Tizen::Base::String& executableName, const String& condition,
+_ConditionManagerProxy::RegisterAppLaunch(const AppId& appId, const String& condition,
                                                                                  const IList* pArguments, AppManager::LaunchOption option)
 {
        SysTryReturnResult(NID_APP, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null.");
@@ -74,8 +79,8 @@ _ConditionManagerProxy::RegisterAppLaunch(const AppId& appId, const Tizen::Base:
        dummy.Construct();
 
        std::auto_ptr<IPC::Message> pMsg (new (std::nothrow) ConditionManager_RegisterAppLaunch(
-                                               appId, executableName, condition, (pArrayList != null) ? *pArrayList : dummy,
-                                               (int) AppManager::LAUNCH_OPTION_DEFAULT, &response));
+                                               appId, condition, (pArrayList != null) ? *pArrayList : dummy,
+                                               static_cast<int>(AppManager::LAUNCH_OPTION_DEFAULT), &response));
        result r = __pIpcClient->SendRequest(*pMsg.get());
 
        SysTryReturn(NID_APP, !IsFailed(r), r, r, "__pIpcClient->SendRequest is failed. (%s)", GetErrorMessage(r));
@@ -85,7 +90,7 @@ _ConditionManagerProxy::RegisterAppLaunch(const AppId& appId, const Tizen::Base:
 
 
 result
-_ConditionManagerProxy::UnregisterAppLaunch(const AppId& appId, const Tizen::Base::String& executableName, const String* pCondition)
+_ConditionManagerProxy::UnregisterAppLaunch(const AppId& appId, const String* pCondition)
 {
        SysTryReturnResult(NID_APP, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null.");
        SysLog(NID_APP, "");
@@ -93,7 +98,7 @@ _ConditionManagerProxy::UnregisterAppLaunch(const AppId& appId, const Tizen::Bas
 
        result response = E_SUCCESS;
        std::auto_ptr<IPC::Message> pMsg (new (std::nothrow) ConditionManager_UnregisterAppLaunch(
-                                                                                                       appId, executableName, (pCondition != null) ? *pCondition : L"", &response));
+                                                                                                       appId, (pCondition != null) ? *pCondition : L"", &response));
        result r = __pIpcClient->SendRequest(*pMsg.get());
 
        SysTryReturn(NID_APP, !IsFailed(r), r, r, "__pIpcClient->SendRequest is failed. (%s)", GetErrorMessage(r));
@@ -102,7 +107,7 @@ _ConditionManagerProxy::UnregisterAppLaunch(const AppId& appId, const Tizen::Bas
 }
 
 bool
-_ConditionManagerProxy::IsAppLaunchRegistered(const AppId& appId, const Tizen::Base::String& executableName, const String* pCondition) const
+_ConditionManagerProxy::IsAppLaunchRegistered(const AppId& appId, const String* pCondition) const
 {
        SysTryReturnResult(NID_APP, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null.");
        SysLog(NID_APP, "");
@@ -110,7 +115,7 @@ _ConditionManagerProxy::IsAppLaunchRegistered(const AppId& appId, const Tizen::B
        bool isAppLaunchRegistered = false;
        result exception = E_SYSTEM;
        std::auto_ptr<IPC::Message> pMsg(new (std::nothrow) ConditionManager_IsAppLaunchRegistered(
-                       appId, executableName, (pCondition != null) ? *pCondition : L"", &isAppLaunchRegistered, &exception));
+                       appId, (pCondition != null) ? *pCondition : L"", &isAppLaunchRegistered, &exception));
        result r = __pIpcClient->SendRequest(*pMsg.get());
 
        SysTryReturn(NID_APP, !IsFailed(r), false, r, "__pIpcClient->SendRequest is failed. (%s)", GetErrorMessage(r));