Fix System namespace
[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         return _SettingInfoImpl::SetWallpaper(filePath);
106 }
107
108 result
109 SettingInfo::SetRingtone(const String& filePath)
110 {
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);
115 }
116
117 result
118 SettingInfo::SetVolume(const String& soundCategory, int level)
119 {
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);
124 }
125
126 result 
127 SettingInfo::GetValueForPrivilegedKey(const String& key, bool& value)
128 {
129         return _SettingInfoImpl::GetValueForPrivilegedKey(key, value);
130 }
131
132 bool
133 SettingInfo::HasKey(const String& key)
134 {
135         return _SettingInfoImpl::HasKey(key);
136 }
137
138 result 
139 SettingInfo::SetValue(const String& key, bool value)
140 {
141         result r = E_SUCCESS;
142         r = _AccessController::CheckUserPrivilege(_PRV_SETTING);
143         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."));       
144         return _SettingInfoImpl::SetValue(key, value);
145 }
146
147 result 
148 SettingInfo::SetValue(const String& key, int value)
149 {
150         result r = E_SUCCESS;
151         r = _AccessController::CheckUserPrivilege(_PRV_SETTING);
152         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."));
153         return _SettingInfoImpl::SetValue(key, value);
154 }
155
156 result 
157 SettingInfo::SetValue(const String& key, String value)
158 {
159         result r = E_SUCCESS;
160         r = _AccessController::CheckUserPrivilege(_PRV_SETTING);
161         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."));
162         return _SettingInfoImpl::SetValue(key, value);
163 }
164
165 result 
166 SettingInfo::SetValueForPrivilegedKey(const String& key, bool value)
167 {
168         return _SettingInfoImpl::SetValueForPrivilegedKey(key, value);
169 }
170
171 result 
172 SettingInfo::SetValueForPrivilegedKey(const String& key, String value)
173 {
174         return _SettingInfoImpl::SetValueForPrivilegedKey(key, value);
175 }
176
177 result 
178 SettingInfo::ResetToFactoryDefault(void)
179 {
180         return _SettingInfoImpl::ResetToFactoryDefault();
181 }
182
183 result 
184 SettingInfo::SetValueAsync(const String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener)
185 {
186         result r = E_SUCCESS;
187         r = _AccessController::CheckUserPrivilege(_PRV_SETTING);
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::SetValueAsync(key, value, listener);
190 }
191
192 result 
193 SettingInfo::SetValueAsyncForPrivilegedKey(const String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener)
194 {
195         result r = E_SUCCESS;
196         return _SettingInfoImpl::SetValueAsyncForPrivilegedKey(key, value, listener);
197 }
198
199 } } // Tizen::System