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