Merge "[2.2.1] Modify doxygen example of Encode/DecodeBase64StringN" into tizen_2.2
[platform/framework/native/appfw.git] / src / system / FSys_SettingInfoImpl.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                FSys_SettingInfoImpl.cpp
19  * @brief               This is the implementation file for _SysSettingInfoImpl class.
20  */
21 #include <unique_ptr.h>
22 #include <system/system_settings.h>
23
24 #include <FBaseColArrayList.h>
25 #include <FBaseSysLog.h>
26 #include <FBaseUtilStringUtil.h>
27 #include <FIoFile.h>
28
29 #include <FApp_AppInfo.h>
30 #include <FBase_StringConverter.h>
31 #include <FBase_NativeError.h>
32 #include <FSys_SettingInfoImpl.h>
33
34 #include "FSys_SettingClient.h"
35 #include "FSys_SettingClientEx.h"
36
37 using namespace std;
38
39 using namespace Tizen::App;
40 using namespace Tizen::Base;
41 using namespace Tizen::Base::Collection;
42 using namespace Tizen::Io;
43 using namespace Tizen::Base::Utility;
44
45 namespace Tizen { namespace System
46 {
47 //IDs for IPC
48 static const int _SYSTEM_RESPONSE_DATA = 2;
49
50 //Reserved key
51 static const wchar_t* _SETTING_SCREEN_WALLPAPER = L"http://tizen.org/setting/screen.wallpaper";
52 static const wchar_t* _SETTING_SYSTEM_SOUND_VOLUME = L"SystemSoundVolume";
53 static const wchar_t* _SETTING_SOUND_SYSTEM_VOLUME= L"http://tizen.org/setting/sound.system.volume";
54 static const wchar_t* _SETTING_MEDIA_SOUND_VOLUME = L"MediaSoundVolume";
55 static const wchar_t* _SETTING_SOUND_MEDIA_VOLUME = L"http://tizen.org/setting/sound.media.volume";
56 static const wchar_t* _SETTING_RINGTONE_SOUND_VOLUME = L"RingtoneSoundVolume";
57 static const wchar_t* _SETTING_SOUND_RINGTONE = L"http://tizen.org/setting/sound.ringtone";
58 static const wchar_t* _SETTING_SOUND_RINGTONE_VOLUME = L"http://tizen.org/setting/sound.ringtone.volume";
59 static const wchar_t* _SETTING_NOTIFICATION_SOUND_VOLUME = L"NotificationSoundVolume";
60 static const wchar_t* _SETTING_SOUND_NOTIFICATION_VOLUME = L"http://tizen.org/setting/sound.notification.volume";
61
62 //Font
63 static const wchar_t* _FONT_SIZE = L"http://tizen.org/setting/font.size";
64 static const wchar_t* _FONTSIZE = L"FontSize";
65 static const wchar_t* _FONT_TYPE = L"http://tizen.org/setting/font.type";
66 static const wchar_t* _FONTTYPE = L"FontType";
67
68 static const wchar_t* _FONT_SIZE_GIANT = L"giant";
69 static const wchar_t* _FONT_SIZE_HUGE = L"huge";
70 static const wchar_t* _FONT_SIZE_LARGE = L"large";
71 static const wchar_t* _FONT_SIZE_MEDIUM = L"medium";
72 static const wchar_t* _FONT_SIZE_SMALL = L"small";
73
74 static const int _FONT_SIZE_GIANT_VCONF = 4;
75 static const int _FONT_SIZE_HUGE_VCONF = 3;
76 static const int _FONT_SIZE_LARGE_VCONF = 2;
77 static const int _FONT_SIZE_MEDIUM_VCONF = 1;
78 static const int _FONT_SIZE_SMALL_VCONF = 0;
79
80
81 static _SettingClient* pSettingClient = null;
82 static _SettingClientEx* pSettingClientEx = null;
83
84 static const wchar_t* _COMMON_SERVICE_ENABLED = L"/opt/usr/etc/setting_common";
85 static bool common_mode = false;
86 void
87 _SettingInfoImpl::InitSettingClient(void)
88 {
89         if(pSettingClient == null && pSettingClientEx == null)
90         {
91 /*
92                 if(File::IsFileExist(_COMMON_SERVICE_ENABLED) == false)
93                 {
94                         if(pSettingClient == null)
95                         {
96                                 pSettingClient =  _SettingClient::GetInstance();
97                         }
98                 }
99                 else
100 */
101                 {
102                         common_mode = true;
103                         if(pSettingClientEx == null)
104                         {
105                                 pSettingClientEx =  _SettingClientEx::GetInstance();
106                         }
107                 }
108         }
109 }
110 result
111 _SettingInfoImpl::GetValue(const Tizen::Base::String& key, Tizen::Base::String& value)
112 {
113         result r = E_SUCCESS;
114
115         if (key == _FONT_SIZE || key == _FONT_TYPE || key == _FONTSIZE || key == _FONTTYPE)
116         {
117                 String tizenKey(key);
118                 if(tizenKey == _FONTSIZE)
119                 {
120                         tizenKey = _FONT_SIZE;
121                 }
122                 else if(tizenKey == _FONTTYPE)
123                 {
124                         tizenKey = _FONT_TYPE;
125                 }
126
127                 r = GetValueForFont(tizenKey, value);
128
129                 if(key == _FONTSIZE)
130                 {
131                         if(_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat() == true)
132                         {
133                                 if(value ==  _FONT_SIZE_GIANT || value == _FONT_SIZE_HUGE)
134                                 {
135                                         value = _FONT_SIZE_LARGE; //OSP not support giant or huge size of font.
136                                 }
137                         }
138                 }
139         }
140         else
141         {
142                 InitSettingClient();
143                 if(common_mode == false)
144                 {
145                         SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
146                         r = pSettingClient->GetValue(key, value);
147                 }
148                 else
149                 {
150                         SysTryReturnResult(NID_SYS, pSettingClientEx != null, E_SYSTEM, "It is failed to intialize setting manager");
151                         r = pSettingClientEx->GetValue(key, value);
152                 }
153         }
154         return r;
155 }
156
157 result
158 _SettingInfoImpl::GetValue(const Tizen::Base::String& key, int& value)
159 {
160         InitSettingClient();
161         if(common_mode == false)
162         {
163                 SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
164                 return pSettingClient->GetValue(key, value);
165         }
166         else
167         {
168                 SysTryReturnResult(NID_SYS, pSettingClientEx != null, E_SYSTEM, "It is failed to intialize setting manager");
169                 return pSettingClientEx->GetValue(key, value);
170         }
171 }
172
173 result
174 _SettingInfoImpl::GetValue(const Tizen::Base::String& key, long long& value)
175 {
176         InitSettingClient();
177         if(common_mode == false)
178         {
179                 SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
180                 return pSettingClient->GetValue(key, value);
181         }
182         else
183         {
184                 SysTryReturnResult(NID_SYS, pSettingClientEx != null, E_SYSTEM, "It is failed to intialize setting manager");
185                 return pSettingClientEx->GetValue(key, value);
186         }
187 }
188
189 result
190 _SettingInfoImpl::GetValue(const Tizen::Base::String& key, double& value)
191 {
192         InitSettingClient();
193         if(common_mode == false)
194         {
195                 SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
196                 return pSettingClient->GetValue(key, value);
197         }
198         else
199         {
200                 SysTryReturnResult(NID_SYS, pSettingClientEx != null, E_SYSTEM, "It is failed to intialize setting manager");
201                 return pSettingClientEx->GetValue(key, value);
202         }
203 }
204
205 result
206 _SettingInfoImpl::GetValue(const Tizen::Base::String& key, bool& value)
207 {
208         InitSettingClient();
209         if(common_mode == false)
210         {
211                 SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
212                 return pSettingClient->GetValue(key, value);
213         }
214         else
215         {
216                 SysTryReturnResult(NID_SYS, pSettingClientEx != null, E_SYSTEM, "It is failed to intialize setting manager");
217                 return pSettingClientEx->GetValue(key, value);
218         }
219 }
220
221 result
222 _SettingInfoImpl::GetValue(const Tizen::Base::String& key, Tizen::Base::UuId& value)
223 {
224         InitSettingClient();
225         if(common_mode == false)
226         {
227                 SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
228                 return pSettingClient->GetValue(key, value);
229         }
230         else
231         {
232                 SysTryReturnResult(NID_SYS, pSettingClientEx != null, E_SYSTEM, "It is failed to intialize setting manager");
233                 return pSettingClientEx->GetValue(key, value);
234         }
235 }
236
237 result
238 _SettingInfoImpl::SetWallpaper(const Tizen::Base::String& filePath)
239 {
240         InitSettingClient();
241         result r = E_SUCCESS;
242
243         if(common_mode == false)
244         {
245                 SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
246                 r = pSettingClient->SetValue(_SETTING_SCREEN_WALLPAPER, filePath);
247         }
248         else
249         {
250                 SysTryReturnResult(NID_SYS, pSettingClientEx != null, E_SYSTEM, "It is failed to intialize setting manager");
251                 r = pSettingClientEx->SetValue(_SETTING_SCREEN_WALLPAPER, filePath);
252         }
253
254         if(r == E_INVALID_ARG)
255                 r = E_FILE_NOT_FOUND;
256         else if(r == E_OBJ_NOT_FOUND)
257                 r = E_SYSTEM;
258         else if(r == E_UNSUPPORTED_OPERATION)
259                 r = E_SYSTEM;
260
261         return r;
262 }
263
264 result
265 _SettingInfoImpl::GetValueForPrivilegedKey(const String& key, bool& value)
266 {
267         InitSettingClient();
268         
269         if(common_mode == false)
270         {
271                 SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
272                 return pSettingClient->GetValueForPrivilegedKey(key, value);
273         }
274         else
275         {
276                 SysTryReturnResult(NID_SYS, pSettingClientEx != null, E_SYSTEM, "It is failed to intialize setting manager");
277                 return pSettingClientEx->GetValueForPrivilegedKey(key, value);
278         }
279 }
280
281 result
282 _SettingInfoImpl::SetValue(const String& key, bool value)
283 {
284         InitSettingClient();
285         if(common_mode == false)
286         {
287                 SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
288                 return pSettingClient->SetValue(key, value);
289         }
290         else
291         {
292                 SysTryReturnResult(NID_SYS, pSettingClientEx != null, E_SYSTEM, "It is failed to intialize setting manager");
293                 return pSettingClientEx->SetValue(key, value);
294         }
295 }
296
297 result
298 _SettingInfoImpl::SetValue(const String& key, int value)
299 {
300         InitSettingClient();
301         if(common_mode == false)
302         {
303                 SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
304                 return pSettingClient->SetValue(key, value);
305         }
306         else
307         {
308                 SysTryReturnResult(NID_SYS, pSettingClientEx != null, E_SYSTEM, "It is failed to intialize setting manager");
309                 return pSettingClientEx->SetValue(key, value);
310         }
311 }
312
313
314 result
315 _SettingInfoImpl::SetValue(const String& key, String value)
316 {
317         result r = E_SUCCESS;
318         if (key == _FONT_SIZE || key == _FONT_TYPE)
319         {
320                 r = SetValueForFont(key, value);
321         }
322         else
323         {
324                 InitSettingClient();
325                 if(common_mode == false)
326                 {
327                         SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
328                         return pSettingClient->SetValue(key, value);
329                 }
330                 else
331                 {
332                         SysTryReturnResult(NID_SYS, pSettingClientEx != null, E_SYSTEM, "It is failed to intialize setting manager");
333                         return pSettingClientEx->SetValue(key, value);
334                 }
335         }
336         return r;
337 }
338
339 result
340 _SettingInfoImpl::SetValueForPrivilegedKey(const String& key, bool value)
341 {
342         InitSettingClient();
343         if(common_mode == false)
344         {
345                 SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
346                 return pSettingClient->SetValueForPrivilegedKey(key, value);
347         }
348         else
349         {
350                 SysTryReturnResult(NID_SYS, pSettingClientEx != null, E_SYSTEM, "It is failed to intialize setting manager");
351                 return pSettingClientEx->SetValueForPrivilegedKey(key, value);
352         }
353 }
354
355 result
356 _SettingInfoImpl::SetValueForPrivilegedKey(const String& key, String value)
357 {
358         InitSettingClient();
359         if(common_mode == false)
360         {
361                 SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
362                 return pSettingClient->SetValueForPrivilegedKey(key, value);
363         }
364         else
365         {
366                 SysTryReturnResult(NID_SYS, pSettingClientEx != null, E_SYSTEM, "It is failed to intialize setting manager");
367                 return pSettingClientEx->SetValueForPrivilegedKey(key, value);
368         }
369 }
370
371 bool
372 _SettingInfoImpl::HasKey(const String& key)
373 {
374         InitSettingClient();
375         if(common_mode == false)
376         {
377                 SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
378                 return pSettingClient->HasKey(key);
379         }
380         else
381         {
382                 SysTryReturnResult(NID_SYS, pSettingClientEx != null, E_SYSTEM, "It is failed to intialize setting manager");
383                 return pSettingClientEx->HasKey(key);
384         }
385 }
386 result
387 _SettingInfoImpl::ResetToFactoryDefault(void)
388 {
389         InitSettingClient();
390         if(common_mode == false)
391         {
392                 SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
393                 return pSettingClient->ResetToFactoryDefault();
394         }
395         else
396         {
397                 SysTryReturnResult(NID_SYS, pSettingClientEx != null, E_SYSTEM, "It is failed to intialize setting manager");
398                 return pSettingClientEx->ResetToFactoryDefault();
399         }
400 }
401
402 result
403 _SettingInfoImpl::SetRingtone(const Tizen::Base::String& filePath)
404 {
405         result r = E_SUCCESS;
406         InitSettingClient();
407         if(common_mode == false)
408         {
409                 SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
410                 r = pSettingClient->SetValue(_SETTING_SOUND_RINGTONE, filePath);
411         }
412         else
413         {
414                 SysTryReturnResult(NID_SYS, pSettingClientEx != null, E_SYSTEM, "It is failed to intialize setting manager");
415                 r = pSettingClientEx->SetValue(_SETTING_SOUND_RINGTONE, filePath);
416         }
417
418         if(r == E_INVALID_ARG)
419                 r = E_FILE_NOT_FOUND;
420         else if(r == E_OBJ_NOT_FOUND)
421                 r = E_SYSTEM;
422         else if(r == E_UNSUPPORTED_OPERATION)
423                 r = E_SYSTEM;
424
425         return r;
426 }
427
428 result
429 _SettingInfoImpl::SetVolume(const Tizen::Base::String& soundCategory, int level)
430 {
431         result r = E_SUCCESS;
432         String key;
433
434         if (soundCategory == _SETTING_SYSTEM_SOUND_VOLUME)
435         {
436                 key = _SETTING_SOUND_SYSTEM_VOLUME;
437         }
438         else if (soundCategory == _SETTING_MEDIA_SOUND_VOLUME)
439         {
440                 key = _SETTING_SOUND_MEDIA_VOLUME;
441         }
442         else if (soundCategory == _SETTING_RINGTONE_SOUND_VOLUME)
443         {
444                 key = _SETTING_SOUND_RINGTONE_VOLUME;
445         }
446         else if (soundCategory == _SETTING_NOTIFICATION_SOUND_VOLUME)
447         {
448                 key = _SETTING_SOUND_NOTIFICATION_VOLUME;
449         }
450         else
451         {
452                 key = soundCategory;
453         }
454
455         InitSettingClient();
456         if(common_mode == false)
457         {
458                 SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
459                 r = pSettingClient->SetValue(key, level);
460         }
461         else
462         {
463                 SysTryReturnResult(NID_SYS, pSettingClientEx != null, E_SYSTEM, "It is failed to intialize setting manager");
464                 r = pSettingClientEx->SetValue(key, level);
465         }
466
467         if (r == E_OBJ_NOT_FOUND)
468         {
469                 r = E_INVALID_ARG;
470         }
471         else if(r == E_INVALID_ARG)
472         {
473                 r = E_OUT_OF_RANGE;
474         }
475         else if(r == E_UNSUPPORTED_OPERATION)
476         {
477                 r = E_SYSTEM;
478         }
479         return r;
480 }
481
482 result
483 _SettingInfoImpl::AddSettingEventListener(ISettingEventListener& listener)
484 {
485         InitSettingClient();
486         if(common_mode == false)
487         {
488                 SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
489                 return pSettingClient->AddSettingEventListener(listener);
490         }
491         else
492         {
493                 SysTryReturnResult(NID_SYS, pSettingClientEx != null, E_SYSTEM, "It is failed to intialize setting manager");
494                 return pSettingClientEx->AddSettingEventListener(listener);
495         }
496 }
497
498 result
499 _SettingInfoImpl::RemoveSettingEventListener(ISettingEventListener& listener)
500 {
501         InitSettingClient();
502         if(common_mode == false)
503         {
504                 SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
505                 return pSettingClient->RemoveSettingEventListener(listener);
506         }
507         else
508         {
509                 SysTryReturnResult(NID_SYS, pSettingClientEx != null, E_SYSTEM, "It is failed to intialize setting manager");
510                 return pSettingClientEx->RemoveSettingEventListener(listener);
511         }
512 }
513
514 result
515 _SettingInfoImpl::AddSettingEventListenerForInternal(ISettingEventListener& listener)
516 {
517         InitSettingClient();
518         if(common_mode == false)
519         {
520                 SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
521                 return pSettingClient->AddSettingEventListenerForInternal(listener);
522         }
523         else
524         {
525                 SysTryReturnResult(NID_SYS, pSettingClientEx != null, E_SYSTEM, "It is failed to intialize setting manager");
526                 return pSettingClientEx->AddSettingEventListenerForInternal(listener);
527         }
528 }
529
530 result
531 _SettingInfoImpl::RemoveSettingEventListenerForInternal(ISettingEventListener& listener)
532 {
533         InitSettingClient();
534         if(common_mode == false)
535         {
536                 SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
537                 return pSettingClient->RemoveSettingEventListenerForInternal(listener);
538         }
539         else
540         {
541                 SysTryReturnResult(NID_SYS, pSettingClientEx != null, E_SYSTEM, "It is failed to intialize setting manager");
542                 return pSettingClientEx->RemoveSettingEventListenerForInternal(listener);
543         }
544 }
545
546 result
547 _SettingInfoImpl::SetSettingEventListener(ISettingEventListener* pListener)
548 {
549         InitSettingClient();
550         if(common_mode == false)
551         {
552                 SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
553                 return pSettingClient->SetSettingEventListener(pListener);
554         }
555         else
556         {
557                 SysTryReturnResult(NID_SYS, pSettingClientEx != null, E_SYSTEM, "It is failed to intialize setting manager");
558                 return pSettingClientEx->SetSettingEventListener(pListener);
559         }
560 }
561
562 result
563 _SettingInfoImpl::SetValueAsync(const Tizen::Base::String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener)
564 {
565         InitSettingClient();
566         if(common_mode == false)
567         {
568                 SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
569                 return pSettingClient->SetValueAsync(key, value, listener);
570         }
571         else
572         {
573                 SysTryReturnResult(NID_SYS, pSettingClientEx != null, E_SYSTEM, "It is failed to intialize setting manager");
574                 return pSettingClientEx->SetValueAsync(key, value, listener);
575         }
576 }
577
578 result
579 _SettingInfoImpl::SetValueAsyncForPrivilegedKey(const Tizen::Base::String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener)
580 {
581         InitSettingClient();
582         if(common_mode == false)
583         {
584                 SysTryReturnResult(NID_SYS, pSettingClient != null, E_SYSTEM, "It is failed to intialize setting manager");
585                 return pSettingClient->SetValueAsyncForPrivilegedKey(key, value, listener);
586         }
587         else
588         {
589                 SysTryReturnResult(NID_SYS, pSettingClientEx != null, E_SYSTEM, "It is failed to intialize setting manager");
590                 return pSettingClientEx->SetValueAsyncForPrivilegedKey(key, value, listener);
591         }
592 }
593
594 _SettingInfoImpl*
595 _SettingInfoImpl::GetInstance(SettingInfo& settinginfo)
596 {
597         return settinginfo.__pSettingInfoImpl;
598 }
599
600 const _SettingInfoImpl*
601 _SettingInfoImpl::GetInstance(const SettingInfo& settinginfo)
602 {
603         return settinginfo.__pSettingInfoImpl;
604 }
605
606 result
607 _SettingInfoImpl::GetValueForFont(const Tizen::Base::String& key, Tizen::Base::String& value)
608 {
609         result r = E_OBJ_NOT_FOUND;
610
611         if (key == _FONT_SIZE)
612         {
613                 int fontSize = 0;
614                 int res = 0;
615                 res = system_settings_get_value_int(SYSTEM_SETTINGS_KEY_FONT_SIZE, &fontSize);
616
617                 SysTryReturnResult(NID_SYS, res == SYSTEM_SETTINGS_ERROR_NONE, E_SYSTEM, "It is failed to get font size.");
618
619                 r = E_SUCCESS;
620                 switch (fontSize)
621                 {
622                 case _FONT_SIZE_GIANT_VCONF:
623                         value.Append(_FONT_SIZE_GIANT);
624                         break;
625                 case _FONT_SIZE_HUGE_VCONF:
626                         value.Append(_FONT_SIZE_HUGE);
627                         break;
628                 case _FONT_SIZE_LARGE_VCONF:
629                         value.Append(_FONT_SIZE_LARGE);
630                         break;
631                 case _FONT_SIZE_MEDIUM_VCONF:
632                         value.Append(_FONT_SIZE_MEDIUM);
633                         break;
634                 case _FONT_SIZE_SMALL_VCONF:
635                         value.Append(_FONT_SIZE_SMALL);
636                         break;
637                 default:
638                         r = E_SYSTEM;
639                         break;
640                 }
641
642         }
643         else if (key == _FONT_TYPE)
644         {
645                 r = E_SUCCESS;
646                 char* pFontType = null;
647                 int res = 0;
648                 res = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_FONT_TYPE, &pFontType);
649                 SysTryReturnResult(NID_SYS, res == SYSTEM_SETTINGS_ERROR_NONE, E_SYSTEM, "Failed to get font type");
650                 r = StringUtil::Utf8ToString(pFontType, value);
651                 SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] StringUtil::Utf8ToString failed", GetErrorMessage(r));
652                 free(pFontType);
653         }
654         return r;
655 }
656
657
658 result
659 _SettingInfoImpl::SetValueForFont(const Tizen::Base::String& key, Tizen::Base::String value)
660 {
661         result r = E_OBJ_NOT_FOUND;
662
663         if(key == _FONT_SIZE)
664         {
665                 int fontSize = 0;
666                 int res = 0;
667                 String lowerValue = value;
668                 lowerValue.ToLowerCase();
669                 r = E_SUCCESS;
670
671                 if (lowerValue == _FONT_SIZE_GIANT)
672                 {
673                         fontSize = _FONT_SIZE_GIANT_VCONF;
674                 }
675                 else if (lowerValue == _FONT_SIZE_HUGE)
676                 {
677                         fontSize = _FONT_SIZE_HUGE_VCONF;
678                 }
679                 else if (lowerValue == _FONT_SIZE_LARGE)
680                 {
681                         fontSize = _FONT_SIZE_LARGE_VCONF;
682                 }
683                 else if (lowerValue == _FONT_SIZE_MEDIUM)
684                 {
685                         fontSize = _FONT_SIZE_MEDIUM_VCONF;
686                 }
687                 else if (lowerValue == _FONT_SIZE_SMALL)
688                 {
689                         fontSize = _FONT_SIZE_SMALL_VCONF;
690                 }
691                 else
692                 {
693                         return E_INVALID_ARG;
694                 }
695                 res = system_settings_set_value_int(SYSTEM_SETTINGS_KEY_FONT_SIZE, fontSize);
696                 SysTryReturnResult(NID_SYS, res == SYSTEM_SETTINGS_ERROR_NONE, E_SYSTEM, "It is failed to set font size.");
697         }
698         else if(key == _FONT_TYPE)
699         {
700                 int res = 0;
701                 r = E_SUCCESS;
702
703                 unique_ptr<char[]> pFontType(_StringConverter::CopyToCharArrayN(value));
704                 SysTryReturnResult(NID_SYS, pFontType.get() != null, E_SYSTEM, "It is failed to convert String to string.");
705                 SysLog(NID_SYS, "Requested font type is %s.", pFontType.get());
706                 res = system_settings_set_value_string(SYSTEM_SETTINGS_KEY_FONT_TYPE, pFontType.get());
707                 SysTryReturnResult(NID_SYS, res != SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER, E_INVALID_ARG, "It is not valid font type.");
708                 SysTryReturnResult(NID_SYS, res == SYSTEM_SETTINGS_ERROR_NONE, E_SYSTEM, "It is failed to set font type.");
709         }
710         return r;
711 }
712
713
714 } } // Tizen::System