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