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