Merge "Update deprecated libprivilege-control API functions." into tizen
[platform/framework/native/appfw.git] / src / server / appfw / app / FApp_AppLaunchCondition.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file         FApp_AppLaunchCondition.cpp
19  * @brief       This is the implementation for the _ConditionManagerStub class.
20  */
21 #include <new>
22 #include "FApp_AppLaunchCondition.h"
23
24 namespace Tizen { namespace App {
25
26 using namespace Tizen::Base;
27 using namespace Tizen::Base::Collection;
28
29
30 _AppLaunchCondition::_AppLaunchCondition(void)
31 : __appId(L""), __pArguments(null), __option(AppManager::LAUNCH_OPTION_DEFAULT), __conditionString(L""), __pUserData(null), __regSectionName(L"")
32 {
33 }
34
35 _AppLaunchCondition::~_AppLaunchCondition(void)
36 {
37         if (__pArguments != null)
38         {
39                 __pArguments->RemoveAll(true);
40                 delete __pArguments;
41         }
42 }
43
44 result
45 _AppLaunchCondition::Construct(const AppId& appId, const String& conditionString, const IList* pArgs, AppManager::LaunchOption option, const String* pRegSectionName)
46 {
47         __appId = appId;
48         __option = option;
49         __conditionString = conditionString;
50         __pUserData = null;
51         __regSectionName = (pRegSectionName != null) ? *pRegSectionName : L"";
52
53         return CopyArgumentsDeeply(pArgs);
54 }
55
56 AppId
57 _AppLaunchCondition::GetAppId(void) const
58 {
59         return __appId;
60 }
61
62 String
63 _AppLaunchCondition::GetConditionString(void) const
64 {
65         return __conditionString;
66 }
67
68 Object*
69 _AppLaunchCondition::GetUserData(void) const
70 {
71         return const_cast<Object*>(__pUserData);
72 }
73
74 IList*
75 _AppLaunchCondition::GetLaunchArgs(void) const
76 {
77         return __pArguments;
78 }
79
80 result
81 _AppLaunchCondition::SetUserData(const Object* pUserData)
82 {
83         __pUserData = pUserData;
84         return E_SUCCESS;
85 }
86
87 result
88 _AppLaunchCondition::CopyArgumentsDeeply(const IList *pArgs)
89 {
90         result r = E_SUCCESS;
91
92         if (pArgs != null && pArgs->GetCount()  > 0)
93         {
94                 __pArguments = new (std::nothrow) ArrayList();
95                 SysTryReturnResult(NID_APP, __pArguments != null, E_OUT_OF_MEMORY, "failed to allocate 'pArguments'!");
96
97                 __pArguments->Construct();
98                 // deep copy
99                 for (int i = 0; i < pArgs->GetCount() ; i++)
100                 {
101                         r = __pArguments->Add(* new (std::nothrow) String(* static_cast<const String*>(pArgs->GetAt(i))));
102                         SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s]", GetErrorMessage(r));
103                 }
104         }
105
106         return E_SUCCESS;
107
108 CATCH:
109         __pArguments->RemoveAll(true);
110         delete __pArguments;
111         __pArguments = null;
112         return r;
113 }
114
115
116 }}//namespace Tizen { namespace App {