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