2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @file FSysSettingInfo.cpp
20 * @brief This is the implementation file for SettingInfo class.
23 #include <FBaseString.h>
24 #include <FSysSettingInfo.h>
26 #include <FBaseSysLog.h>
27 #include <FSys_SettingInfoImpl.h>
28 #include <FSec_AccessController.h>
30 using namespace Tizen::Base;
31 using namespace Tizen::Security;
33 namespace Tizen { namespace System
36 SettingInfo::SettingInfo(void)
37 :__pSettingInfoImpl(null)
41 SettingInfo::~SettingInfo(void)
46 SettingInfo::SetSettingEventListener(ISettingEventListener* pListener)
48 return _SettingInfoImpl::SetSettingEventListener(pListener);
52 SettingInfo::AddSettingEventListener(ISettingEventListener& listener)
54 return _SettingInfoImpl::AddSettingEventListener(listener);
58 SettingInfo::RemoveSettingEventListener(ISettingEventListener& listener)
60 return _SettingInfoImpl::RemoveSettingEventListener(listener);
64 SettingInfo::GetValue(const String& key, String& value)
66 return _SettingInfoImpl::GetValue(key, value);
70 SettingInfo::GetValue(const String& key, int& value)
72 return _SettingInfoImpl::GetValue(key, value);
76 SettingInfo::GetValue(const String& key, long long& value)
78 return _SettingInfoImpl::GetValue(key, value);
82 SettingInfo::GetValue(const String& key, double& value)
84 return _SettingInfoImpl::GetValue(key, value);
88 SettingInfo::GetValue(const String& key, bool& value)
90 return _SettingInfoImpl::GetValue(key, value);
94 SettingInfo::GetValue(const String& key, UuId& value)
96 return _SettingInfoImpl::GetValue(key, value);
100 SettingInfo::SetWallpaper(const String& filePath)
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 return _SettingInfoImpl::SetWallpaper(filePath);
109 SettingInfo::SetRingtone(const String& filePath)
111 result r = E_SUCCESS;
112 r = _AccessController::CheckUserPrivilege(_PRV_SETTING);
113 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."));
114 return _SettingInfoImpl::SetRingtone(filePath);
118 SettingInfo::SetVolume(const String& soundCategory, int level)
120 result r = E_SUCCESS;
121 r = _AccessController::CheckUserPrivilege(_PRV_SETTING);
122 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."));
123 return _SettingInfoImpl::SetVolume(soundCategory, level);
127 SettingInfo::GetValueForPrivilegedKey(const String& key, bool& value)
129 result r = E_SUCCESS;
130 r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMSETTING_READ);
131 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."));
132 return _SettingInfoImpl::GetValueForPrivilegedKey(key, value);
136 SettingInfo::HasKey(const String& key)
138 return _SettingInfoImpl::HasKey(key);
142 SettingInfo::SetValue(const String& key, bool value)
144 result r = E_SUCCESS;
145 r = _AccessController::CheckUserPrivilege(_PRV_SETTING);
146 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."));
147 return _SettingInfoImpl::SetValue(key, value);
151 SettingInfo::SetValue(const String& key, int value)
153 result r = E_SUCCESS;
154 r = _AccessController::CheckUserPrivilege(_PRV_SETTING);
155 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."));
156 return _SettingInfoImpl::SetValue(key, value);
160 SettingInfo::SetValue(const String& key, String value)
162 result r = E_SUCCESS;
163 r = _AccessController::CheckUserPrivilege(_PRV_SETTING);
164 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."));
165 return _SettingInfoImpl::SetValue(key, value);
169 SettingInfo::SetValueForPrivilegedKey(const String& key, bool value)
171 result r = E_SUCCESS;
172 r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMSETTING_WRITE);
173 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."));
174 return _SettingInfoImpl::SetValueForPrivilegedKey(key, value);
178 SettingInfo::SetValueForPrivilegedKey(const String& key, String value)
180 result r = E_SUCCESS;
181 r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMSETTING_WRITE);
182 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."));
183 return _SettingInfoImpl::SetValueForPrivilegedKey(key, value);
187 SettingInfo::ResetToFactoryDefault(void)
189 result r = E_SUCCESS;
190 r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMSETTING_WRITE);
191 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."));
192 return _SettingInfoImpl::ResetToFactoryDefault();
196 SettingInfo::SetValueAsync(const String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener)
198 result r = E_SUCCESS;
199 r = _AccessController::CheckUserPrivilege(_PRV_SETTING);
200 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."));
201 return _SettingInfoImpl::SetValueAsync(key, value, listener);
205 SettingInfo::SetValueAsyncForPrivilegedKey(const String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener)
207 result r = E_SUCCESS;
208 return _SettingInfoImpl::SetValueAsyncForPrivilegedKey(key, value, listener);