Add privilege check code.
[platform/framework/native/appfw.git] / src / system / FSysSettingInfo.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                FSysSettingInfo.cpp
19  * @brief               This is the implementation file for SettingInfo class.
20  */
21
22 #include <FBaseString.h>
23 #include <FSysSettingInfo.h>
24
25 #include <FBaseSysLog.h>
26 #include <FSys_SettingInfoImpl.h>
27 #include <FSec_AccessController.h>
28
29 using namespace Tizen::Base;
30 using namespace Tizen::Security;
31
32 namespace Tizen { namespace System
33 {
34
35 SettingInfo::SettingInfo(void)
36         :__pSettingInfoImpl(null)
37 {
38 }
39
40 SettingInfo::~SettingInfo(void)
41 {
42 }
43
44 result
45 SettingInfo::SetSettingEventListener(ISettingEventListener* pListener)
46 {
47         return _SettingInfoImpl::SetSettingEventListener(pListener);
48 }
49
50 result
51 SettingInfo::AddSettingEventListener(ISettingEventListener& listener)
52 {
53         return _SettingInfoImpl::AddSettingEventListener(listener);
54 }
55
56 result
57 SettingInfo::RemoveSettingEventListener(ISettingEventListener& listener)
58 {
59         return _SettingInfoImpl::RemoveSettingEventListener(listener);
60 }
61
62 result
63 SettingInfo::GetValue(const String& key, String& value)
64 {
65         return _SettingInfoImpl::GetValue(key, value);
66 }
67
68 result
69 SettingInfo::GetValue(const String& key, int& value)
70 {
71         return _SettingInfoImpl::GetValue(key, value);
72 }
73
74 result
75 SettingInfo::GetValue(const String& key, long long& value)
76 {
77         return _SettingInfoImpl::GetValue(key, value);
78 }
79
80 result
81 SettingInfo::GetValue(const String& key, double& value)
82 {
83         return _SettingInfoImpl::GetValue(key, value);
84 }
85
86 result
87 SettingInfo::GetValue(const String& key, bool& value)
88 {
89         return _SettingInfoImpl::GetValue(key, value);
90 }
91
92 result
93 SettingInfo::GetValue(const String& key, UuId& value)
94 {
95         return _SettingInfoImpl::GetValue(key, value);
96 }
97
98 result
99 SettingInfo::SetWallpaper(const String& filePath)
100 {
101         return _SettingInfoImpl::SetWallpaper(filePath);
102 }
103
104 result
105 SettingInfo::SetRingtone(const String& filePath)
106 {
107         return _SettingInfoImpl::SetRingtone(filePath);
108 }
109
110 result
111 SettingInfo::SetVolume(const String& soundCategory, int level)
112 {
113         return _SettingInfoImpl::SetVolume(soundCategory, level);
114 }
115
116 result 
117 SettingInfo::GetValueForPrivilegedKey(const String& key, bool& value)
118 {
119         result r = _AccessController::CheckUserPrivilege(_PRV_SETTINGMANAGER_READ);
120         SysTryReturn(NID_SYS, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, ("[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."));
121
122         return _SettingInfoImpl::GetValueForPrivilegedKey(key, value);
123 }
124
125 bool
126 SettingInfo::HasKey(const String& key)
127 {
128         return _SettingInfoImpl::HasKey(key);
129 }
130
131 result 
132 SettingInfo::SetValue(const String& key, bool value)
133 {       
134         return _SettingInfoImpl::SetValue(key, value);
135 }
136
137 result 
138 SettingInfo::SetValue(const String& key, int value)
139 {
140         return _SettingInfoImpl::SetValue(key, value);
141 }
142
143 result 
144 SettingInfo::SetValue(const String& key, String value)
145 {
146         return _SettingInfoImpl::SetValue(key, value);
147 }
148
149 result 
150 SettingInfo::SetValueForPrivilegedKey(const String& key, bool value)
151 {
152         return _SettingInfoImpl::SetValueForPrivilegedKey(key, value);
153 }
154
155 result 
156 SettingInfo::SetValueForPrivilegedKey(const String& key, String value)
157 {
158         return _SettingInfoImpl::SetValueForPrivilegedKey(key, value);
159 }
160
161 result 
162 SettingInfo::ResetToFactoryDefault(void)
163 {
164         return _SettingInfoImpl::ResetToFactoryDefault();
165 }
166
167 result 
168 SettingInfo::SetValueAsync(const String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener)
169 {
170         return _SettingInfoImpl::SetValueAsync(key, value, listener);
171 }
172
173 result 
174 SettingInfo::SetValueAsyncForPrivilegedKey(const String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener)
175 {
176         return _SettingInfoImpl::SetValueAsyncForPrivilegedKey(key, value, listener);
177 }
178
179 } } // Tizen::System