Update privilege string, PackageAppInfo for wgt
[platform/framework/native/appfw.git] / src / app / FApp_AppLaunchCondition.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_AppLaunchCondition.cpp
20  * @brief       This is the implementation for the _ConditionManagerStub class.
21  */
22 #include <new>
23 #include "FApp_AppLaunchCondition.h"
24
25 namespace Tizen { namespace App {
26
27 using namespace Tizen::Base;
28 using namespace Tizen::Base::Collection;
29
30
31 _AppLaunchCondition::_AppLaunchCondition(void)
32 : __appId(L""), __pArguments(null), __option(AppManager::LAUNCH_OPTION_DEFAULT), __conditionString(L""), __pUserData(null), __regSectionName(L"")
33 {
34 }
35
36 _AppLaunchCondition::~_AppLaunchCondition(void)
37 {
38         if (__pArguments != null)
39         {
40                 __pArguments->RemoveAll(true);
41                 delete __pArguments;
42         }
43 }
44
45 result
46 _AppLaunchCondition::Construct(const AppId& appId, const String& conditionString, const IList* pArgs, AppManager::LaunchOption option, const String* pRegSectionName)
47 {
48         __appId = appId;
49         __option = option;
50         __conditionString = conditionString;
51         __pUserData = null;
52         __regSectionName = (pRegSectionName != null) ? *pRegSectionName : L"";
53
54         return CopyArgumentsDeeply(pArgs);
55 }
56
57 AppId
58 _AppLaunchCondition::GetAppId(void) const
59 {
60         return __appId;
61 }
62
63 String
64 _AppLaunchCondition::GetConditionString(void) const
65 {
66         return __conditionString;
67 }
68
69 Object*
70 _AppLaunchCondition::GetUserData(void) const
71 {
72         return const_cast<Object*>(__pUserData);
73 }
74
75 result
76 _AppLaunchCondition::SetUserData(const Object* pUserData)
77 {
78         __pUserData = pUserData;
79         return E_SUCCESS;
80 }
81
82 result
83 _AppLaunchCondition::CopyArgumentsDeeply(const IList *pArgs)
84 {
85         result r = E_SUCCESS;
86
87         if (pArgs != null && pArgs->GetCount()  > 0)
88         {
89                 __pArguments = new (std::nothrow) ArrayList();
90                 SysTryReturnResult(NID_APP, __pArguments != null, E_OUT_OF_MEMORY, "failed to allocate 'pArguments'!");
91
92                 __pArguments->Construct();
93                 // deep copy
94                 for (int i = 0; i < pArgs->GetCount() ; i++)
95                 {
96                         r = __pArguments->Add(* new (std::nothrow) String(* static_cast<const String*>(pArgs->GetAt(i))));
97                         SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s]", GetErrorMessage(r));
98                 }
99         }
100
101         return E_SUCCESS;
102
103 CATCH:
104         __pArguments->RemoveAll(true);
105         delete __pArguments;
106         __pArguments = null;
107         return r;
108 }
109
110
111 }}//namespace Tizen { namespace App {