removed the log message functions
[framework/api/system-settings.git] / src / system_setting_platform.c
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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 #include <stdio.h>
18 #include <stdlib.h>
19 #include <unistd.h>
20 #include <errno.h>
21
22 #include <string.h>
23 #include <sys/types.h>
24 #include <sys/stat.h>
25 #include <fcntl.h>
26
27
28 #include <dlog.h>
29 #include <vconf.h>
30
31 #include <glib.h>
32 #include <libxml/xmlmemory.h>
33 #include <libxml/parser.h>
34
35 #include <Ecore_X.h>
36 #include <Elementary.h>
37
38 #include <system_settings.h>
39 #include <system_settings_private.h>
40
41
42 #ifdef LOG_TAG
43 #undef LOG_TAG
44 #endif
45
46 #define SMALL_FONT_DPI                      (-80)
47 #define MIDDLE_FONT_DPI                     (-100)
48 #define LARGE_FONT_DPI                      (-150)
49 #define HUGE_FONT_DPI                       (-190)
50 #define GIANT_FONT_DPI                      (-250)
51
52 #define SETTING_FONT_CONF_FILE "/opt/etc/fonts/conf.avail/99-slp.conf"
53 #define SETTING_STR_SLP_LEN  256
54
55 static char* _get_cur_font();
56 static void font_size_set();
57 static int __font_size_get();
58
59 static void font_config_set(char *font_name);
60 static void font_config_set_notification();
61
62 int system_setting_get_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void** value)
63 {
64         char* vconf_value;
65         if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, &vconf_value)) {
66                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
67         }
68         *value = vconf_value;
69         return SYSTEM_SETTINGS_ERROR_NONE;
70 }
71
72
73 int system_setting_get_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void** value)
74 {
75         char* vconf_value;
76         if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_EMAIL_RINGTONE_PATH_STR, &vconf_value)) {
77                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
78         }
79         *value = vconf_value;
80         return SYSTEM_SETTINGS_ERROR_NONE;
81 }
82
83
84 int system_setting_get_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void** value)
85 {
86         char* vconf_value;
87         if (system_setting_vconf_get_value_string(VCONFKEY_BGSET, &vconf_value)) {
88                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
89         }
90         *value = vconf_value;
91         return SYSTEM_SETTINGS_ERROR_NONE;
92 }
93
94
95 int system_setting_get_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void** value)
96 {
97         char* vconf_value;
98
99         if (system_setting_vconf_get_value_string(VCONFKEY_IDLE_LOCK_BGSET, &vconf_value)) {
100                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
101         }
102         *value = vconf_value;
103
104         return SYSTEM_SETTINGS_ERROR_NONE;
105 }
106
107
108 // [int] vconf GET
109 int system_setting_get_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void** value)
110 {
111         int vconf_value;
112
113         if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) {
114                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
115         }
116         *value = (void*)vconf_value;
117
118         return SYSTEM_SETTINGS_ERROR_NONE;
119 }
120
121
122 // [int] vconf GET
123 int system_setting_get_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void** value)
124 {
125         char* font_name = _get_cur_font();
126         *value = (void*)font_name;
127
128         return SYSTEM_SETTINGS_ERROR_NONE;
129 }
130
131
132 int system_setting_get_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void** value)
133 {
134         bool vconf_value;
135
136         if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, &vconf_value)) {
137                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
138         }
139         *value = (void*)vconf_value;
140
141         return SYSTEM_SETTINGS_ERROR_NONE;
142 }
143
144 ////////////////////////////////////////////////////////////////////////////////////////////////////
145
146 int system_setting_set_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void* value)
147 {
148         char* vconf_value;
149         vconf_value = (char*)value;
150         if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, vconf_value)) {
151                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
152         }
153
154         return SYSTEM_SETTINGS_ERROR_NONE;
155 }
156
157
158 int system_setting_set_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void* value)
159 {
160         char* vconf_value;
161         vconf_value = (char*)value;
162         if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_EMAIL_RINGTONE_PATH_STR, vconf_value)) {
163                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
164         }
165
166         return SYSTEM_SETTINGS_ERROR_NONE;
167 }
168
169
170 static int _is_file_accessible(const char * path)
171 {
172     int ret = access(path ,R_OK);
173     if (ret == 0)
174         return 0;
175     else
176         return errno;
177 }
178
179 int system_setting_set_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void* value)
180 {
181         char* vconf_value;
182         vconf_value = (char*)value;
183
184         // error handling here
185         if (_is_file_accessible(vconf_value) != 0)
186                 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
187
188         if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
189                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
190         }
191
192         return SYSTEM_SETTINGS_ERROR_NONE;
193 }
194
195 int system_setting_set_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void* value)
196 {
197         char* vconf_value;
198         vconf_value = (char*)value;
199
200         // error handling here
201         if (_is_file_accessible(vconf_value) != 0)
202                 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
203
204         if (system_setting_vconf_set_value_string(VCONFKEY_IDLE_LOCK_BGSET, vconf_value)) {
205                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
206         }
207
208         return SYSTEM_SETTINGS_ERROR_NONE;
209 }
210
211 int system_setting_set_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void* value)
212 {
213         int* vconf_value;
214         vconf_value = (int*)value;
215
216         if (*vconf_value < 0 || *vconf_value > SYSTEM_SETTINGS_FONT_SIZE_GIANT) {
217                 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
218         }
219
220         if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, *vconf_value)) {
221                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
222         }
223         font_size_set();
224         return SYSTEM_SETTINGS_ERROR_NONE;
225 }
226 /**
227  * [internal API]
228  */
229 void *font_conf_doc_parse(char *doc_name, char *font_name)
230 {
231     xmlDocPtr doc = NULL;
232     xmlNodePtr cur = NULL;
233     xmlNodePtr cur2 = NULL;
234     xmlNodePtr cur3 = NULL;
235     xmlChar *key = NULL;
236
237     doc = xmlParseFile(doc_name);
238
239     cur = xmlDocGetRootElement(doc);
240
241     if (cur == NULL) {
242         xmlFreeDoc(doc);
243         doc = NULL;
244         return NULL;
245     }
246
247     if(xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
248         xmlFreeDoc(doc);
249         doc = NULL;
250         return NULL;
251     }
252
253     cur = cur->xmlChildrenNode;
254
255     Eina_Bool is_changed = EINA_FALSE;
256     while(cur != NULL)
257     {
258         if((!xmlStrcmp(cur->name, (const xmlChar *)"match")))
259         {
260             cur2 = cur->xmlChildrenNode;
261             while(cur2 != NULL)
262             {
263                 if((!xmlStrcmp(cur2->name, (const xmlChar *)"edit")))
264                 {
265                     xmlChar *name = xmlGetProp(cur2, (const xmlChar *)"name");
266                     /* if name is not 'family', break */
267                     if (xmlStrcmp(name, (const xmlChar *)"family"))
268                     {
269                         xmlFree(name);
270                         name = NULL;
271                         break;
272                     }
273                     xmlFree(name);
274                     name = NULL;
275
276                     cur3 = cur2->xmlChildrenNode;
277                    while(cur3 != NULL)
278                     {
279                         if((!xmlStrcmp(cur3->name, (const xmlChar *)"string")))
280                         {
281                             xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
282                             key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
283                             //printf("after changed, string is: %s \n", key);
284                             xmlFree(key);
285                             key = NULL;
286                             is_changed = EINA_TRUE;
287                         }
288                         cur3 = cur3->next;
289                     }
290                 }
291                 cur2 = cur2->next;
292             }
293         } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"alias")))
294         {
295             cur2 = cur->xmlChildrenNode;
296             while (cur2 != NULL)
297             {
298                 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"family")))
299                 {
300                     xmlNodeSetContent(cur2->xmlChildrenNode, (const xmlChar *)font_name);
301                     key = xmlNodeListGetString(doc, cur2->xmlChildrenNode, 1);
302                     //printf("after changed, string is: %s\n", key);
303                     xmlFree(key);
304                     key = NULL;
305                     is_changed = EINA_TRUE;
306                 } else if ((!xmlStrcmp(cur2->name, (const xmlChar *)"prefer")))
307                 {
308                     cur3 = cur2->xmlChildrenNode;
309                     while (cur3 != NULL)
310                     {
311                         if((!xmlStrcmp(cur3->name, (const xmlChar *)"family")))
312                         {
313                             xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
314                             key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
315                             xmlFree(key);
316                             key = NULL;
317                             is_changed = EINA_TRUE;
318                             cur3 = cur3->next;
319                             break; /* just set first element, so break */
320                         }
321                         cur3 = cur3->next;
322                     }
323                 }
324                 cur2 = cur2->next;
325             }
326         }
327         cur = cur->next;
328     }
329
330     if (is_changed) {
331         return doc;
332     } else {
333         xmlFreeDoc(doc);
334         doc = NULL;
335         return NULL;
336     }
337 }
338
339 int system_setting_set_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void* value)
340 {
341         char* font_name = NULL;
342         font_name = (char*)value;
343
344         font_config_set(font_name);
345         font_config_set_notification();
346
347         char* vconf_value;
348         vconf_value = (char*)value;
349         if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, vconf_value)) {
350                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
351         }
352
353     xmlDocPtr doc = (xmlDocPtr)font_conf_doc_parse(SETTING_FONT_CONF_FILE, font_name);
354     if(doc != NULL) {
355         xmlSaveFormatFile(SETTING_FONT_CONF_FILE, doc, 0);
356         xmlFreeDoc(doc);
357         doc = NULL;
358     }
359
360         return SYSTEM_SETTINGS_ERROR_NONE;
361 }
362
363 int system_setting_set_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void* value)
364 {
365         bool* vconf_value;
366         vconf_value = (bool*)value;
367         if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, *vconf_value)) {
368                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
369         }
370         return SYSTEM_SETTINGS_ERROR_NONE;
371 }
372
373 /////////////////////////////////////////////////////////////////////////////////////////////////
374 //
375
376 int system_setting_set_changed_callback_incoming_call_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
377 {
378         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0);
379 }
380
381 int system_setting_unset_changed_callback_incoming_call_ringtone(system_settings_key_e key)
382 {
383         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, 0);
384 }
385
386 int system_setting_set_changed_callback_email_alert_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
387 {
388         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_EMAIL_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, 0);
389 }
390
391 int system_setting_unset_changed_callback_email_alert_ringtone(system_settings_key_e key)
392 {
393         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_EMAIL_RINGTONE_PATH_STR, 0);
394 }
395
396 int system_setting_set_changed_callback_wallpaper_home_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
397 {
398         return system_setting_vconf_set_changed_cb(VCONFKEY_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, 0);
399 }
400
401 int system_setting_unset_changed_callback_wallpaper_home_screen(system_settings_key_e key)
402 {
403         return system_setting_vconf_unset_changed_cb(VCONFKEY_BGSET, 0);
404 }
405
406 int system_setting_set_changed_callback_wallpaper_lock_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
407 {
408         return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_BGSET,SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, 0);
409 }
410
411 int system_setting_unset_changed_callback_wallpaper_lock_screen(system_settings_key_e key)
412 {
413         return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, 0);
414 }
415
416 int system_setting_set_changed_callback_font_size(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
417 {
418         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE,SYSTEM_SETTINGS_KEY_FONT_SIZE, 1);
419 }
420
421 int system_setting_unset_changed_callback_font_size(system_settings_key_e key)
422 {
423         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, 1);
424 }
425
426 /**
427  * @todo need to add custom event notification method
428  */
429 int system_setting_set_changed_callback_font_type(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
430 {
431         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME,SYSTEM_SETTINGS_KEY_FONT_TYPE, 2);
432 }
433
434 int system_setting_unset_changed_callback_font_type(system_settings_key_e key)
435 {
436         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME,2);
437 }
438
439 // TODO : 2th argument, callback, is not in use.
440 int system_setting_set_changed_callback_motion_activation(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
441 {
442         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, 3);
443 }
444
445 int system_setting_unset_changed_callback_motion_activation(system_settings_key_e key)
446 {
447         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, 3);
448 }
449
450 static char* _get_cur_font()
451 {
452     xmlDocPtr doc = NULL;
453     xmlNodePtr cur = NULL;
454     xmlNodePtr cur2 = NULL;
455     xmlNodePtr cur3 = NULL;
456     xmlChar *key = NULL;
457
458     char *font_name = NULL;
459
460     doc = xmlParseFile(SETTING_FONT_CONF_FILE);
461
462     cur = xmlDocGetRootElement(doc);
463
464     if(cur == NULL) {
465         xmlFreeDoc(doc);
466         doc = NULL;
467         return NULL;
468     }
469
470     if(xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
471         xmlFreeDoc(doc);
472         doc = NULL;
473         return NULL;
474     }
475
476     cur = cur->xmlChildrenNode;
477
478     while(cur != NULL)
479     {
480         if((!xmlStrcmp(cur->name, (const xmlChar *)"match")))
481         {
482             cur2 = cur->xmlChildrenNode;
483             while(cur2 != NULL)
484             {
485                 if((!xmlStrcmp(cur2->name, (const xmlChar *)"edit")))
486                 {
487                     cur3 = cur2->xmlChildrenNode;
488                     while(cur3 != NULL)
489                     {
490                         if((!xmlStrcmp(cur3->name, (const xmlChar *)"string")))
491                         {
492                             key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
493                             //printf("string is: %s\n", key);
494
495                             font_name = g_strdup((char *)key);
496                             xmlFree(key);
497                             key = NULL;
498                             xmlFreeDoc(doc);
499                             doc = NULL;
500                             return font_name;
501                         }
502                        cur3 = cur3->next;
503                     }
504                 }
505                 cur2 = cur2->next;
506             }
507         }
508         cur = cur->next;
509     }
510
511     xmlFreeDoc(doc);
512     doc = NULL;
513     return NULL;
514 }
515
516 static void font_config_set_notification()
517 {
518     /* notification */
519         Ecore_X_Window ecore_win = ecore_x_window_root_first_get();
520         Ecore_X_Atom atom = ecore_x_atom_get("FONT_TYPE_change");
521         ecore_x_window_prop_string_set(ecore_win, atom, "tizen");
522 }
523
524 static void font_config_set(char *font_name)
525 {
526     Eina_List *text_classes = NULL;
527     Elm_Text_Class *etc = NULL;
528     const Eina_List *l = NULL;
529     Eina_List *fo_list = NULL;
530     Elm_Font_Overlay *efo = NULL;
531     int font_size = __font_size_get();
532     int size = 0;
533
534     text_classes = elm_config_text_classes_list_get();
535
536     fo_list = (Eina_List *)elm_config_font_overlay_list_get();
537
538     Eina_List *ll = NULL;
539     Eina_List *l_next = NULL;
540
541     Eina_Bool slp_medium_exist = EINA_FALSE;
542     Eina_Bool slp_roman_exist = EINA_FALSE;
543     Eina_Bool slp_bold_exist = EINA_FALSE;
544     Eina_Bool slp_regular_exist = EINA_FALSE;
545
546     // Tizen
547     Eina_Bool tizen_exist = EINA_FALSE;
548
549     EINA_LIST_FOREACH_SAFE(fo_list, ll, l_next, efo)
550     {
551         if (!strcmp(efo->text_class, "tizen_medium")) {
552             elm_config_font_overlay_set(efo->text_class, (const char*)font_name, efo->size);
553             slp_medium_exist = EINA_TRUE;
554         } else if (!strcmp(efo->text_class, "tizen_roman")) {
555             elm_config_font_overlay_set(efo->text_class, (const char*)font_name, efo->size);
556             slp_roman_exist = EINA_TRUE;
557         } else if (!strcmp(efo->text_class, "tizen_bold")) {
558             elm_config_font_overlay_set(efo->text_class, (const char*)font_name, efo->size);
559             slp_bold_exist = EINA_TRUE;
560         } else if (!strcmp(efo->text_class, "tizen_regular")) {
561             elm_config_font_overlay_set(efo->text_class, (const char*)font_name, efo->size);
562             slp_regular_exist = EINA_TRUE;
563         }
564
565         // Tizen
566         if (!strcmp(efo->text_class, "tizen")) {
567             elm_config_font_overlay_set(efo->text_class, (const char*)font_name, efo->size);
568             tizen_exist = EINA_TRUE;
569         }
570
571     }
572
573     /* if slp_XX do not exist, need to set them, font size is -100(100%) */
574     if (slp_medium_exist == EINA_FALSE) {
575         elm_config_font_overlay_set("tizen_medium", (const char*)font_name,  MIDDLE_FONT_DPI);
576     }
577     if (slp_roman_exist == EINA_FALSE) {
578         elm_config_font_overlay_set("tizen_roman", (const char*)font_name,  MIDDLE_FONT_DPI);
579     }
580     if (slp_bold_exist == EINA_FALSE) {
581         elm_config_font_overlay_set("tizen_bold", (const char*)font_name,  MIDDLE_FONT_DPI);
582     }
583     if (slp_regular_exist == EINA_FALSE) {
584         elm_config_font_overlay_set("tizen_regular", (const char*)font_name,  MIDDLE_FONT_DPI);
585     }
586
587     // Tizen
588     if (tizen_exist == EINA_FALSE) {
589         elm_config_font_overlay_set("tizen", (const char*)font_name,  MIDDLE_FONT_DPI);
590     }
591
592     elm_config_font_overlay_set("tizen", (const char*)font_name,  MIDDLE_FONT_DPI);
593
594     // Tizen
595     elm_config_font_overlay_set("tizen", (const char*)font_name,  MIDDLE_FONT_DPI);
596
597     EINA_LIST_FOREACH(text_classes, l, etc)
598     {
599         ll = NULL;
600
601         size = font_size;
602         EINA_LIST_FOREACH(fo_list, ll, efo)
603         {
604             if (!strcmp(etc->name, efo->text_class)) {
605                 size = efo->size;
606             }
607         }
608         elm_config_font_overlay_set(etc->name, (const char*)font_name, size);
609     }
610
611     elm_config_font_overlay_apply();
612     elm_config_all_flush();
613 //    elm_config_engine_set("software_x11");
614     elm_config_save();
615     elm_config_text_classes_list_free(text_classes);
616     text_classes = NULL;
617
618     // vconf update
619     vconf_set_str(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, font_name);
620 }
621
622 static void font_size_set()
623 {
624     Eina_List *text_classes = NULL;
625     Elm_Text_Class *etc = NULL;
626     const Eina_List *l = NULL;
627     int font_size = __font_size_get();
628     char *font_name = _get_cur_font();
629
630     if (font_size == -1) {
631         return;
632     }
633
634     text_classes = elm_config_text_classes_list_get();
635
636     EINA_LIST_FOREACH(text_classes, l, etc)
637     {
638         elm_config_font_overlay_set(etc->name, font_name, font_size);
639     }
640
641         elm_config_font_overlay_apply();
642     elm_config_all_flush();
643     elm_config_save();
644     elm_config_text_classes_list_free(text_classes);
645     text_classes = NULL;
646     g_free(font_name);
647 }
648
649 static int __font_size_get()
650 {
651     int font_size = -1;
652     int err = -1;
653
654         int vconf_value = -1;
655         if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) {
656                 return -1;
657         }
658
659     switch(vconf_value) {
660     case SYSTEM_SETTINGS_FONT_SIZE_SMALL:
661         font_size = SMALL_FONT_DPI;
662         break;
663     case SYSTEM_SETTINGS_FONT_SIZE_NORMAL:
664         font_size = MIDDLE_FONT_DPI;
665         break;
666     case SYSTEM_SETTINGS_FONT_SIZE_LARGE:
667         font_size = LARGE_FONT_DPI;
668         break;
669     case SYSTEM_SETTINGS_FONT_SIZE_HUGE:
670         font_size = HUGE_FONT_DPI;
671         break;
672     case SYSTEM_SETTINGS_FONT_SIZE_GIANT:
673         font_size = GIANT_FONT_DPI;
674         break;
675     default:
676         font_size = MIDDLE_FONT_DPI;
677         break;
678     }
679     return font_size;
680 }