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 FApp_ConditionManagerProxy.cpp
20 * @brief This is the implementation for the _ConditionManagerProxy.cpp class.
26 #include <FBaseErrors.h>
28 #include <FBaseSysLog.h>
29 #include <FIo_IpcClient.h>
31 #include "FApp_ConditionManagerIpcMessages.h"
32 #include "FApp_ConditionManagerProxy.h"
35 using namespace Tizen::Base;
36 using namespace Tizen::Base::Collection;
38 namespace Tizen { namespace App
41 _ConditionManagerProxy::_ConditionManagerProxy(void)
47 _ConditionManagerProxy::~_ConditionManagerProxy(void)
53 _ConditionManagerProxy::Construct()
55 __pIpcClient = new (std::nothrow) Tizen::Io::_IpcClient();
56 SysTryReturnResult(NID_APP, __pIpcClient != null, E_OUT_OF_MEMORY, "_IpcClient creation failed.");
58 result r = __pIpcClient->Construct("osp.app.ipcserver.conditionmanager");
59 SysTryReturn(NID_APP, !IsFailed(r), r, r, "_IpcClient constructing faliied [%s].", GetErrorMessage(r));
65 _ConditionManagerProxy::RegisterAppLaunch(const AppId& appId, const Tizen::Base::String& executableName, const String& condition,
66 const IList* pArguments, AppManager::LaunchOption option)
68 SysTryReturnResult(NID_APP, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null.");
71 result response = E_SUCCESS;
72 const ArrayList* pArrayList = dynamic_cast<const ArrayList*>(pArguments);
76 std::auto_ptr<IPC::Message> pMsg (new (std::nothrow) ConditionManager_RegisterAppLaunch(
77 appId, executableName, condition, (pArrayList != null) ? *pArrayList : dummy,
78 (int) AppManager::LAUNCH_OPTION_DEFAULT, &response));
79 result r = __pIpcClient->SendRequest(*pMsg.get());
81 SysTryReturn(NID_APP, !IsFailed(r), r, r, "__pIpcClient->SendRequest is failed. (%s)", GetErrorMessage(r));
88 _ConditionManagerProxy::UnregisterAppLaunch(const AppId& appId, const Tizen::Base::String& executableName, const String* pCondition)
90 SysTryReturnResult(NID_APP, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null.");
94 result response = E_SUCCESS;
95 std::auto_ptr<IPC::Message> pMsg (new (std::nothrow) ConditionManager_UnregisterAppLaunch(
96 appId, executableName, (pCondition != null) ? *pCondition : L"", &response));
97 result r = __pIpcClient->SendRequest(*pMsg.get());
99 SysTryReturn(NID_APP, !IsFailed(r), r, r, "__pIpcClient->SendRequest is failed. (%s)", GetErrorMessage(r));
105 _ConditionManagerProxy::IsAppLaunchRegistered(const AppId& appId, const Tizen::Base::String& executableName, const String* pCondition) const
107 SysTryReturnResult(NID_APP, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null.");
110 bool isAppLaunchRegistered = false;
111 result exception = E_SYSTEM;
112 std::auto_ptr<IPC::Message> pMsg(new (std::nothrow) ConditionManager_IsAppLaunchRegistered(
113 appId, executableName, (pCondition != null) ? *pCondition : L"", &isAppLaunchRegistered, &exception));
114 result r = __pIpcClient->SendRequest(*pMsg.get());
116 SysTryReturn(NID_APP, !IsFailed(r), false, r, "__pIpcClient->SendRequest is failed. (%s)", GetErrorMessage(r));
117 SysTryReturn(NID_APP, !IsFailed(exception), false, exception, "__pIpcClient->SendRequest is failed. (%s)", GetErrorMessage(exception));
119 return isAppLaunchRegistered;