sync with master
[platform/framework/native/appfw.git] / src / security / FSecPrivacyInfo.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        FSecPrivacyInfo.cpp
20  * @brief       This is the implementation for the PrivacyInfo class.
21  */
22
23 #include <new>
24 #include <unique_ptr.h>
25 #include <FSecPrivacyInfo.h>
26 #include <FBaseSysLog.h>
27 #include "FSec_PrivacyInfoImpl.h"
28
29 using namespace Tizen::Base;
30 using namespace Tizen::Base::Collection;
31 using namespace Tizen::Security;
32
33 namespace Tizen { namespace Security
34 {
35
36 PrivacyInfo::PrivacyInfo(void)
37         : __pImpl(null)
38 {
39
40 }
41
42 PrivacyInfo::~PrivacyInfo(void)
43 {
44
45 }
46
47 result
48 PrivacyInfo::Construct(const Tizen::Base::String& privacyId, bool enable)
49 {
50         SysAssertf(__pImpl == null,
51                 "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class");
52
53         std::unique_ptr< _PrivacyInfoImpl > pImpl(new (std::nothrow) _PrivacyInfoImpl);
54         SysTryReturnResult(NID_SEC, pImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed");
55
56         result r = pImpl->Construct(privacyId, enable);
57         if (!IsFailed(r))
58         {
59                 __pImpl = pImpl.release();
60                 return E_SUCCESS;
61         }
62
63         return r;
64
65 }
66
67 String
68 PrivacyInfo::GetId(void) const
69 {
70         SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
71         return __pImpl->GetId();
72 }
73
74 bool
75 PrivacyInfo::IsEnabled(void) const
76 {
77         SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
78         return __pImpl->IsEnabled();
79 }
80
81 void
82 PrivacyInfo::SetEnabled(bool enable)
83 {
84         SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
85         __pImpl->SetEnabled(enable);
86 }
87
88 String
89 PrivacyInfo::GetDisplayName(void) const
90 {
91         SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
92         return __pImpl->GetDisplayName();
93 }
94
95 String
96 PrivacyInfo::GetDescription(void) const
97 {
98         SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
99         return __pImpl->GetDescription();
100 }
101
102 }} // Tizen::Security