Update privilege string, PackageAppInfo for wgt
[platform/framework/native/appfw.git] / src / app / FApp_ConditionManagerProxy.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17
18 /**
19  * @file         FApp_ConditionManagerProxy.cpp
20  * @brief       This is the implementation for the _ConditionManagerProxy.cpp class.
21  */
22
23 #include <new>
24 #include <memory>
25
26 #include <FBaseErrors.h>
27
28 #include <FBaseSysLog.h>
29 #include <FIo_IpcClient.h>
30
31 #include "FApp_ConditionManagerIpcMessages.h"
32 #include "FApp_ConditionManagerProxy.h"
33
34
35 using namespace Tizen::Base;
36 using namespace Tizen::Base::Collection;
37
38 namespace Tizen { namespace App
39 {
40
41 _ConditionManagerProxy::_ConditionManagerProxy(void)
42         : __pIpcClient(null)
43 {
44 }
45
46
47 _ConditionManagerProxy::~_ConditionManagerProxy(void)
48 {
49         delete __pIpcClient;
50 }
51
52 result
53 _ConditionManagerProxy::Construct()
54 {
55         __pIpcClient = new (std::nothrow) Tizen::Io::_IpcClient();
56         SysTryReturnResult(NID_APP, __pIpcClient != null, E_OUT_OF_MEMORY, "_IpcClient creation failed.");
57
58         result r = __pIpcClient->Construct("osp.app.ipcserver.conditionmanager");
59         SysTryReturn(NID_APP, !IsFailed(r), r, r, "_IpcClient constructing faliied [%s].", GetErrorMessage(r));
60
61         return E_SUCCESS;
62 }
63
64 result
65 _ConditionManagerProxy::RegisterAppLaunch(const AppId& appId, const String& condition,
66                                                                                   const IList* pArguments, AppManager::LaunchOption option)
67 {
68         SysTryReturnResult(NID_APP, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null.");
69         SysLog(NID_APP, "");
70
71         result response = E_SUCCESS;
72         const ArrayList* pArrayList = dynamic_cast<const ArrayList*>(pArguments);
73         ArrayList dummy;
74         dummy.Construct();
75
76         std::auto_ptr<IPC::Message> pMsg (new (std::nothrow) ConditionManager_RegisterAppLaunch(
77                                                 appId, condition, (pArrayList != null) ? *pArrayList : dummy,
78                                                 (int) AppManager::LAUNCH_OPTION_DEFAULT, &response));
79         result r = __pIpcClient->SendRequest(*pMsg.get());
80
81         SysTryReturn(NID_APP, !IsFailed(r), r, r, "__pIpcClient->SendRequest is failed. (%s)", GetErrorMessage(r));
82
83         return response;
84 }
85
86
87 result
88 _ConditionManagerProxy::UnregisterAppLaunch(const AppId& appId, /*const Tizen::Base::String& executableName,*/ const String* pCondition)
89 {
90         SysTryReturnResult(NID_APP, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null.");
91         SysLog(NID_APP, "");
92
93
94         result response = E_SUCCESS;
95         std::auto_ptr<IPC::Message> pMsg (new (std::nothrow) ConditionManager_UnregisterAppLaunch(
96                                                                                                         appId, (pCondition != null) ? *pCondition : L"", &response));
97         result r = __pIpcClient->SendRequest(*pMsg.get());
98
99         SysTryReturn(NID_APP, !IsFailed(r), r, r, "__pIpcClient->SendRequest is failed. (%s)", GetErrorMessage(r));
100
101         return response;
102 }
103
104 bool
105 _ConditionManagerProxy::IsAppLaunchRegistered(const AppId& appId, const String* pCondition) const
106 {
107         SysTryReturnResult(NID_APP, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null.");
108         SysLog(NID_APP, "");
109
110         bool isAppLaunchRegistered = false;
111         result exception = E_SYSTEM;
112         std::auto_ptr<IPC::Message> pMsg(new (std::nothrow) ConditionManager_IsAppLaunchRegistered(
113                         appId, (pCondition != null) ? *pCondition : L"", &isAppLaunchRegistered, &exception));
114         result r = __pIpcClient->SendRequest(*pMsg.get());
115
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));
118
119         return isAppLaunchRegistered;
120 }
121
122
123 } } // Tizen::App