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