Merge "Update code of system and text for reporting Klocwork." into devel_3.0_main
[platform/framework/native/appfw.git] / src / security / FSecPrivilegeInfo.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        FSecPrivilegeInfo.cpp
19  * @brief       This is the implementation for the PrivilegeInfo class.
20  */
21
22 #include <new>
23
24 #include <FSecPrivilegeInfo.h>
25
26 #include <FBaseSysLog.h>
27 #include <FSec_AccessController.h>
28 #include "FSec_PrivilegeInfoImpl.h"
29
30 using namespace Tizen::Base;
31 using namespace Tizen::Security;
32
33 namespace Tizen { namespace Security
34 {
35
36
37 PrivilegeInfo::PrivilegeInfo(void)
38         : __pImpl(null)
39 {
40
41 }
42
43 PrivilegeInfo::~PrivilegeInfo(void)
44 {
45         delete __pImpl;
46 }
47
48 result
49 PrivilegeInfo::Construct(const Tizen::Base::String& privilegeId)
50 {
51         result r = E_SUCCESS;
52
53         SysAssertf(__pImpl == null,
54                     "Already constructed. Calling Construct() twice or more on a same in stance is not allowed for this class.");
55
56         __pImpl = new (std::nothrow) _PrivilegeInfoImpl;
57     SysTryReturnResult(NID_SEC, __pImpl != null, E_OUT_OF_MEMORY, "");
58
59     r = __pImpl->Construct(privilegeId);
60     SysTryCatch(NID_SEC, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
61
62     return r;
63
64 CATCH:
65     delete __pImpl;
66     __pImpl = null;
67
68     return r;
69
70 }
71
72 String
73 PrivilegeInfo::GetId(void) const
74 {
75         SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
76
77         return __pImpl->GetId();
78 }
79
80
81 String
82 PrivilegeInfo::GetDisplayName(void) const
83 {
84         SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
85
86         return __pImpl->GetDisplayName();
87 }
88
89 String
90 PrivilegeInfo::GetDescription(void) const
91 {
92         SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
93
94         return __pImpl->GetDescription();
95 }
96
97 }} // Tizen::Security