Installer SignatureValidator implementation
[platform/framework/native/installer.git] / src / Context / InstallationContextData.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  * @file        InstallationContextData.cpp
19  * @brief       This is the implementation for the InstallationContextData class.
20  */
21
22 #include "InstallationContextData.h"
23
24
25 using namespace Tizen::Base;
26 using namespace Tizen::Base::Collection;
27 using namespace Tizen::Io;
28 using namespace Tizen::Security::Cert;
29
30
31 AppControlData::AppControlData()
32 :__pOperationList(null)
33 ,__pMimeTypeList(null)
34 ,__pUriList(null)
35
36 {
37         __pOperationList = new (std::nothrow) ArrayListT<String*>;
38         __pMimeTypeList = new (std::nothrow) ArrayListT<String*>;
39         __pUriList = new (std::nothrow) ArrayListT<String*>;
40 }
41
42 AppControlData::~AppControlData()
43 {
44         __pOperationList->RemoveAll();
45         delete __pOperationList;
46
47         __pMimeTypeList->RemoveAll();
48         delete __pMimeTypeList;
49
50         __pUriList->RemoveAll();
51         delete __pUriList;
52 }
53
54 AccountData::AccountData()
55 :__pNameList(null)
56 ,__pCapabilityList(null)
57 {
58
59 }
60
61 AccountData::~AccountData()
62 {
63         __pNameList->RemoveAll(true);
64         delete __pNameList;
65
66         __pCapabilityList->RemoveAll();
67         delete __pCapabilityList;
68 }
69
70 bool
71 AccountData::Construct()
72 {
73         result r = E_SUCCESS;
74
75         __pNameList = new (std::nothrow) HashMap;
76         TryReturn(__pNameList, false, "__pNameList is null.");
77
78         r = __pNameList->Construct();
79         TryReturn(!IsFailed(r), false, "__pNameList->Construct() is failed.");
80
81         __pCapabilityList = new (std::nothrow) ArrayListT<String*>;
82         TryReturn(__pCapabilityList, false, "__pCapabilityList is null.");
83
84         return true;
85 }
86
87
88 LiveboxData::LiveboxData(void)
89 :__updatePeriod(0)
90 ,__pNameList(null)
91 ,__pSizeList(null)
92 {
93         __pNameList = new (std::nothrow) HashMap;
94         TryReturn(__pNameList, , "__pNameList is null.");
95         __pNameList->Construct();
96
97         __pSizeList = new (std::nothrow) HashMap;
98         TryReturn(__pSizeList, , "__pSizeList is null.");
99         __pSizeList->Construct();
100 }
101
102 LiveboxData::~LiveboxData(void)
103 {
104         __pNameList->RemoveAll(true);
105         delete __pNameList;
106
107         __pSizeList->RemoveAll(true);
108         delete __pSizeList;
109 }
110
111 result
112 LiveboxData::SetUpdatePeriod(long long period)
113 {
114         __updatePeriod = period;
115         return E_SUCCESS;
116 }
117
118 long long
119 LiveboxData::GetUpdatePeriod(void) const
120 {
121         return __updatePeriod;
122 }
123
124 result
125 LiveboxData::SetPopupEnabled(const String& value)
126 {
127         __popupEnabled = value;
128         return E_SUCCESS;
129 }
130
131 const String&
132 LiveboxData::GetPopupEnabled(void) const
133 {
134         return __popupEnabled;
135 }
136
137 result
138 LiveboxData::SetIcon(const String& icon)
139 {
140         __icon = icon;
141         return E_SUCCESS;
142 }
143
144 const String&
145 LiveboxData::GetIcon(void) const
146 {
147         return __icon;
148 }
149
150 result
151 LiveboxData::SetProviderName(const String& providerName)
152 {
153         __providerName = providerName;
154         return E_SUCCESS;
155 }
156
157 const String&
158 LiveboxData::GetProviderName(void) const
159 {
160         return __providerName;
161 }
162
163 result
164 LiveboxData::AddName(const String& language, const String& name)
165 {
166         result r = E_SUCCESS;
167
168         r = __pNameList->Add(language, name);
169
170         return r;
171 }
172
173 HashMap*
174 LiveboxData::GetNameList(void) const
175 {
176         return __pNameList;
177 }
178
179 result
180 LiveboxData::AddSize(String* pSize, String* pPreviewImage)
181 {
182         result r = E_SUCCESS;
183
184         r = __pSizeList->Add(pSize, pPreviewImage);
185
186         return r;
187 }
188
189 HashMap*
190 LiveboxData::GetSizeList(void) const
191 {
192         return __pSizeList;
193 }
194
195
196 _AppControlResolutionInfo::_AppControlResolutionInfo(void)
197         : __pUriScheme(null)
198         , __pMimeType(null)
199 {
200
201 }
202
203 _AppControlResolutionInfo::~_AppControlResolutionInfo(void)
204 {
205                 delete __pUriScheme;
206                 delete __pMimeType;
207 }
208
209 String*
210 _AppControlResolutionInfo::GetUriScheme(void) const
211 {
212         return __pUriScheme;
213 }
214
215 result
216 _AppControlResolutionInfo::SetUriScheme(String* pUriScheme)
217 {
218         __pUriScheme = pUriScheme;
219         return E_SUCCESS;
220 }
221
222 String*
223 _AppControlResolutionInfo::GetMimeType(void) const
224 {
225         return __pMimeType;
226 }
227
228 result
229 _AppControlResolutionInfo::SetMimeType(String* pMimeType)
230 {
231         __pMimeType = pMimeType;
232         return E_SUCCESS;
233 }
234
235 _AppControlCapabilityInfo::_AppControlCapabilityInfo(void)
236         : __appControlId(0)
237         ,__pResolutionList(null)
238 {
239         __pResolutionList = new (std::nothrow) ArrayList;
240         TryReturnVoidResult(__pResolutionList != null, E_OUT_OF_MEMORY, "__pResolutionList instance must not be null.");
241         __pResolutionList->Construct();
242 }
243
244 _AppControlCapabilityInfo::~_AppControlCapabilityInfo(void)
245 {
246         __pResolutionList->RemoveAll(true);
247         delete __pResolutionList;
248 }
249
250 int
251 _AppControlCapabilityInfo::GetAppControlId(void) const
252 {
253         return __appControlId;
254 }
255
256 result
257 _AppControlCapabilityInfo::SetAppControlId(int appControlId)
258 {
259         __appControlId = appControlId;
260         return E_SUCCESS;
261 }
262
263 const String&
264 _AppControlCapabilityInfo::GetOperationId(void) const
265 {
266         return __operationId;
267 }
268
269 result
270 _AppControlCapabilityInfo::SetOperationId(const String& operationId)
271 {
272         __operationId = operationId;
273         return E_SUCCESS;
274 }
275
276 ArrayList*
277 _AppControlCapabilityInfo::GetResolutionList(void) const
278 {
279         return __pResolutionList;
280 }
281
282 result
283 _AppControlCapabilityInfo::AddResolution(_AppControlResolutionInfo* pResolutionImpl)
284 {
285         result r = E_SUCCESS;
286         r = __pResolutionList->Add(*pResolutionImpl);
287         TryReturn(!IsFailed(r), r, "__pResolutionList->Add() is failed.");
288
289         return r;
290 }
291
292 _AppControlInfo::_AppControlInfo(void)
293         : __pCapabilityList(null)
294 {
295         __pCapabilityList = new (std::nothrow) ArrayList;
296         TryReturnVoidResult(__pCapabilityList != null, E_OUT_OF_MEMORY, "__pCapabilityList instance must not be null.");
297         __pCapabilityList->Construct();
298 }
299
300 _AppControlInfo::~_AppControlInfo(void)
301 {
302         __pCapabilityList->RemoveAll(true);
303         delete __pCapabilityList;
304 }
305
306 const String&
307 _AppControlInfo::GetProviderId(void) const
308 {
309         return __providerId;
310 }
311
312 result
313 _AppControlInfo::SetProviderId(const String& providerId)
314 {
315         __providerId = providerId;
316         return E_SUCCESS;
317 }
318
319 const String&
320 _AppControlInfo::GetCategory(void) const
321 {
322         return __category;
323 }
324
325 result
326 _AppControlInfo::SetCategory(const String& category)
327 {
328         __category = category;
329         return E_SUCCESS;
330 }
331
332 ArrayList*
333 _AppControlInfo::GetCapabilityList(void) const
334 {
335         return __pCapabilityList;
336 }
337
338 result
339 _AppControlInfo::AddCapability(_AppControlCapabilityInfo* pCapability)
340 {
341         result r = E_SUCCESS;
342         r = __pCapabilityList->Add(*pCapability);
343         TryReturn(!IsFailed(r), r, "__pCapabilityList->Add() is failed.");
344
345         return r;
346 }
347
348
349 DataControlType::DataControlType(void)
350 {
351
352 }
353
354 DataControlType::~DataControlType(void)
355 {
356
357 }
358
359
360 DataControlInfo::DataControlInfo(void)
361         : __pControlTypeList(null)
362 {
363         __pControlTypeList = new (std::nothrow) ArrayListT<DataControlType*>;
364         TryReturnVoidResult(__pControlTypeList != null, E_OUT_OF_MEMORY, "__pControlTypeList instance must not be null.");
365 }
366
367 DataControlInfo::~DataControlInfo(void)
368 {
369         __pControlTypeList->RemoveAll();
370         delete __pControlTypeList;
371 }
372
373
374 ContentData::ContentData(void)
375 :__pNameList(null)
376 {
377         __pNameList = new (std::nothrow) HashMap;
378         TryReturn(__pNameList, , "__pNameList is null.");
379         __pNameList->Construct();
380 }
381
382 ContentData::~ContentData(void)
383 {
384         __pNameList->RemoveAll(true);
385         delete __pNameList;
386 }
387
388 result
389 ContentData::SetContentId(const String& contentId)
390 {
391         __contentId = contentId;
392         return E_SUCCESS;
393 }
394
395 const String&
396 ContentData::GetContentId(void) const
397 {
398         return __contentId;
399 }
400
401 result
402 ContentData::SetIcon(const String& icon)
403 {
404         __icon = icon;
405         return E_SUCCESS;
406 }
407
408 const String&
409 ContentData::GetIcon(void) const
410 {
411         return __icon;
412 }
413
414 result
415 ContentData::AddName(const String& language, const String& name)
416 {
417         result r = E_SUCCESS;
418
419         r = __pNameList->Add(language, name);
420
421         return r;
422 }
423
424 HashMap*
425 ContentData::GetNameList(void) const
426 {
427         return __pNameList;
428 }
429
430 AppData::AppData()
431 :__pCategoryList(null)
432 ,__pAccountDataList(null)
433 ,__pAppControlDataList(null)
434 ,__pAppControlImplList(null)
435 ,__pDataControlList(null)
436 ,__pSubModeAppControlDataList(null)
437 ,__pLiveboxDataList(null)
438 ,__pNameList(null)
439 ,__pFeatureList(null)
440 ,__pNotificationMap(null)
441 ,__pMetadataMap(null)
442 ,__pLaunchConditionList(null)
443 ,__feature(0)
444 ,__isSubMode(false)
445 ,__isSubModeAllowed(true)
446 ,__legacyAppControls(false)
447 ,__isSystemService(false)
448 ,__menuIconVisible(false)
449 {
450 }
451
452 AppData::~AppData()
453 {
454         if (__pCategoryList)
455         {
456                 __pCategoryList->RemoveAll();
457                 delete __pCategoryList;
458         }
459
460         if (__pAccountDataList)
461         {
462                 __pAccountDataList->RemoveAll();
463                 delete __pAccountDataList;
464         }
465
466         if (__pAppControlDataList)
467         {
468                 __pAppControlDataList->RemoveAll();
469                 delete __pAppControlDataList;
470         }
471
472         if (__pAppControlImplList)
473         {
474                 __pAppControlImplList->RemoveAll();
475                 delete __pAppControlImplList;
476         }
477
478         if (__pDataControlList)
479         {
480                 __pDataControlList->RemoveAll();
481                 delete __pDataControlList;
482         }
483
484         if (__pSubModeAppControlDataList)
485         {
486                 __pSubModeAppControlDataList->RemoveAll();
487                 delete __pSubModeAppControlDataList;
488         }
489
490         if (__pLiveboxDataList)
491         {
492                 __pLiveboxDataList->RemoveAll();
493                 delete __pLiveboxDataList;
494                 __pLiveboxDataList = null;
495         }
496
497         if (__pNameList)
498         {
499                 __pNameList->RemoveAll();
500                 delete __pNameList;
501         }
502
503         if (__pFeatureList)
504         {
505                 __pFeatureList->RemoveAll();
506                 delete __pFeatureList;
507         }
508
509         if (__pNotificationMap)
510         {
511                 __pNotificationMap->RemoveAll();
512                 delete __pNotificationMap;
513         }
514
515         if (__pMetadataMap)
516         {
517                 __pMetadataMap->RemoveAll();
518                 delete __pMetadataMap;
519         }
520
521         if (__pLaunchConditionList)
522         {
523                 __pLaunchConditionList->RemoveAll();
524                 delete __pLaunchConditionList;
525         }
526 }
527
528 InstallerError
529 AppData::Construct(void)
530 {
531         result r = E_SUCCESS;
532
533         __pCategoryList = new (std::nothrow) ArrayListT<String*>;
534         TryReturn(__pCategoryList, INSTALLER_ERROR_OUT_OF_MEMORY, "__pCategoryList is null.");
535
536         __pAccountDataList = new (std::nothrow) ArrayListT<AccountData*>;
537         TryReturn(__pAccountDataList, INSTALLER_ERROR_OUT_OF_MEMORY, "__pAccountDataList is null.");
538
539         __pAppControlDataList = new (std::nothrow) ArrayListT<AppControlData*>;
540         TryReturn(__pAppControlDataList, INSTALLER_ERROR_OUT_OF_MEMORY, "__pAppControlDataList is null.");
541
542         __pAppControlImplList = new (std::nothrow) ArrayListT<_AppControlInfo*>;
543         TryReturn(__pAppControlImplList, INSTALLER_ERROR_OUT_OF_MEMORY, "__pAppControlImplList is null.");
544
545         __pDataControlList = new (std::nothrow) ArrayListT<DataControlInfo*>;
546         TryReturn(__pDataControlList, INSTALLER_ERROR_OUT_OF_MEMORY, "__pDataControlList is null.");
547
548         __pSubModeAppControlDataList = new (std::nothrow) ArrayListT<AppControlData*>;
549         TryReturn(__pSubModeAppControlDataList, INSTALLER_ERROR_OUT_OF_MEMORY, "__pSubModeAppControlDataList is null.");
550
551         __pNameList = new (std::nothrow) HashMap(SingleObjectDeleter);
552         TryReturn(__pNameList, INSTALLER_ERROR_OUT_OF_MEMORY, "__pNameList is null.");
553         r = __pNameList->Construct();
554         TryReturn(!IsFailed(r), INSTALLER_ERROR_OUT_OF_MEMORY, "__pNameList->Construct() failed.");
555
556         __pFeatureList = new (std::nothrow) HashMap(SingleObjectDeleter);
557         TryReturn(__pFeatureList, INSTALLER_ERROR_OUT_OF_MEMORY, "__pFeatureList is null.");
558         r = __pFeatureList->Construct();
559         TryReturn(!IsFailed(r), INSTALLER_ERROR_OUT_OF_MEMORY, "__pFeatureList->Construct() failed.");
560
561         __pNotificationMap = new (std::nothrow) HashMap(SingleObjectDeleter);
562         TryReturn(__pNotificationMap, INSTALLER_ERROR_OUT_OF_MEMORY, "__pNotificationMap is null.");
563         r = __pNotificationMap->Construct();
564         TryReturn(!IsFailed(r), INSTALLER_ERROR_OUT_OF_MEMORY, "__pNotificationMap->Construct() failed.");
565
566         __pMetadataMap = new (std::nothrow) HashMap(SingleObjectDeleter);
567         TryReturn(__pMetadataMap, INSTALLER_ERROR_OUT_OF_MEMORY, "__pMetadataMap is null.");
568         r = __pMetadataMap->Construct();
569         TryReturn(!IsFailed(r), INSTALLER_ERROR_OUT_OF_MEMORY, "__pMetadataMap->Construct() failed.");
570
571         __pLaunchConditionList = new (std::nothrow) MultiHashMap(SingleObjectDeleter);
572         TryReturn(__pLaunchConditionList, INSTALLER_ERROR_OUT_OF_MEMORY, "__pLaunchConditionList is null.");
573         r = __pLaunchConditionList->Construct();
574         TryReturn(!IsFailed(r), INSTALLER_ERROR_OUT_OF_MEMORY, "__pLaunchConditionList->Construct() failed.");
575
576         return INSTALLER_ERROR_NONE;
577 }