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."));
106 return _SettingInfoImpl::SetWallpaper(filePath);
110 SettingInfo::SetRingtone(const String& filePath)
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."));
116 return _SettingInfoImpl::SetRingtone(filePath);
120 SettingInfo::SetVolume(const String& soundCategory, int level)
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."));
126 return _SettingInfoImpl::SetVolume(soundCategory, level);
130 SettingInfo::GetValueForPrivilegedKey(const String& key, bool& value)
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);
139 SettingInfo::HasKey(const String& key)
141 return _SettingInfoImpl::HasKey(key);
145 SettingInfo::SetValue(const String& key, bool value)
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."));
151 return _SettingInfoImpl::SetValue(key, value);
155 SettingInfo::SetValue(const String& key, int value)
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."));
161 return _SettingInfoImpl::SetValue(key, value);
165 SettingInfo::SetValue(const String& key, String value)
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."));
171 return _SettingInfoImpl::SetValue(key, value);
175 SettingInfo::SetValueForPrivilegedKey(const String& key, bool value)
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);
184 SettingInfo::SetValueForPrivilegedKey(const String& key, String value)
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);
193 SettingInfo::ResetToFactoryDefault(void)
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();
202 SettingInfo::SetValueAsyncForPrivilegedKey(const String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener)
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);