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