b6e051e5f5fcd8ed501b4af1d69e9f0631ae352b
[apps/core/preloaded/settings.git] / setting-common / src / setting-common-general-func.c
1 /*
2  * setting
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
5  *
6  * Contact: MyoungJune Park <mj2004.park@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21 #include <ail.h>
22 #include <setting-common-general-func.h>
23 #include <setting-common-data-slp-setting.h>
24
25 #include <glib.h>
26 #include <iniparser.h>
27 #include <dlfcn.h>
28 #include <libxml/xmlmemory.h>
29 #include <libxml/parser.h>
30 #include <system_info.h>
31
32 #include <system_settings.h>
33
34 char *setting_file_basename(char *path)
35 {
36         if (NULL == path || '\0' == path[0]) {
37                 return NULL;    /* invalid arguement */
38         }
39         char *p = strrchr(path, '/');
40         if (!p) {
41                 return (char *)g_strdup(path);  /*  cannot find '/' */
42         }
43         if ('\0' == p[1]) {
44                 return NULL;    /* end with '/' */
45         }
46         return (char *)g_strdup(p + 1);
47 }
48
49 char *get_pa_usb_connect_mode_str()
50 {
51         int ret = SETTING_RETURN_FAIL;
52         int value;
53
54         ret = vconf_get_int(VCONFKEY_SETAPPL_USB_MODE_INT, &value);
55         setting_retvm_if(SETTING_RETURN_FAIL == ret, NULL, "Failed to get vconf value");        /* file system exceptional handle */
56
57         switch (value)
58         {
59         case SETTING_USB_DEBUG_MODE:
60                 return (char*)g_strdup(_("IDS_ST_BODY_USB_DEBUGGING"));
61         default:
62                 return (char*)g_strdup(_("IDS_COM_POP_DISCONNECTED"));
63         }
64 }
65
66 char *get_brightness_mode_str()
67 {
68         int value, err;
69         setting_get_int_slp_key(INT_SLP_SETTING_AUTOMATIC_BRIGHTNESS, &value,
70                                  &err);
71         if (value != SETTING_BRIGHTNESS_AUTOMATIC_OFF) {
72                 return setting_gettext("IDS_COM_BODY_AUTOMATIC");
73         } else {
74                 return setting_gettext("IDS_COM_BODY_MANUAL");
75         }
76 }
77
78 char *get_pa_backlight_time_str()
79 {
80         int value = 0;
81         char backlight_time_str[MAX_DISPLAY_NAME_LEN_ON_UI];
82
83 #if SUPPORT_LCD_TIMEOUT_KEEPING
84         if (0 != vconf_get_int(VCONFKEY_LCD_TIMEOUT_NORMAL_BACKUP, &value)) {
85                 /* value = 600; */
86                 if(isEmulBin())
87                         value = 0;      /* keep agree with postin file */
88                 else
89                         value = 30;
90                 vconf_set_int(VCONFKEY_LCD_TIMEOUT_NORMAL_BACKUP, value);
91         }
92 #else
93         int err;
94         int ret =
95             setting_get_int_slp_key(INT_SLP_SETTING_LCD_TIMEOUT_NORMAL, &value,
96                                     &err);
97         #if NORMAL
98         if (SETTING_RETURN_FAIL == ret || value < 0) {  /* file system exceptional handle, eg. The vconf file lost due to file system. */
99                 /* value = 600; */
100                 if(isEmulBin())
101                         value = 0;      /* keep agree with postin file */
102                 else
103                         value = 30;
104                 setting_set_int_slp_key(INT_SLP_SETTING_LCD_TIMEOUT_NORMAL,
105                                         value, &err);
106         }
107         #else // for MDM server
108         // adjust value.
109         // if < 15, 15
110         // if 15 < < 30, 15
111         // if 30 < < 60, 30
112         // if 60 < < 120, 60
113         // if 120 < < 300, 120
114         // if 300 < < 600, 300
115         // if > 600, 600
116         if(isEmulBin())
117         {
118                 if (SETTING_RETURN_FAIL == ret || value < 15)
119                         value = 0;
120                 else if(value >= 15 && value < 30)
121                         value = 15;
122                 else if(value >= 30 && value < 60)
123                         value = 30;
124                 else if(value >= 60 && value < 120)
125                         value = 60;
126                 else if(value >= 120 && value < 300)
127                         value = 120;
128                 else if(value >= 300 && value < 600)
129                         value = 300;
130                 else
131                         value = 600;
132         }
133         else
134         {
135                 if (SETTING_RETURN_FAIL == ret || value < 30)
136                         value = 15;
137                 else if(value >= 30 && value < 60)
138                         value = 30;
139                 else if(value >= 60 && value < 120)
140                         value = 60;
141                 else if(value >= 120 && value < 300)
142                         value = 120;
143                 else if(value >= 300 && value < 600)
144                         value = 300;
145                 else
146                         value = 600;
147         }
148
149         setting_set_int_slp_key(INT_SLP_SETTING_LCD_TIMEOUT_NORMAL,
150                                         value, &err);
151         #endif
152 #endif
153
154         if (value == 0) {
155                 snprintf(backlight_time_str, sizeof(backlight_time_str), "%s",
156                          _("IDS_ST_BODY_ALWAYS_ON"));
157         } else if (value == 60) {
158                 snprintf(backlight_time_str, sizeof(backlight_time_str), "%s",
159                          _("IDS_COM_BODY_1_MINUTE"));
160         } else if (value > 60) {
161                 snprintf(backlight_time_str, sizeof(backlight_time_str),
162                          "%d %s", value / 60, (char *)(_("IDS_COM_BODY_MINUTES_LC")));
163         } else {
164                 snprintf(backlight_time_str, sizeof(backlight_time_str),
165                          "%d %s", value, (char *)(_("IDS_COM_BODY_SECONDS_LC")));
166         }
167         return (char *)g_strdup(backlight_time_str);
168 }
169
170 char *get_pa_powersaving_at_str()
171 {
172         int value = 30;
173         char powersaving_at_str[MAX_DISPLAY_NAME_LEN_ON_UI + 1];
174
175         int err;
176         int ret =
177             setting_get_int_slp_key(INT_SLP_SETTING_POWERSAVING_AT, &value,
178                                     &err);
179         if (SETTING_RETURN_FAIL == ret || value < 0) {  /* file system exceptional handle, eg. The vconf file lost due to file system. */
180                 value = 30;     /* keep agree with postin file */
181                 setting_set_int_slp_key(INT_SLP_SETTING_POWERSAVING_AT,
182                                         value, &err);
183         }
184
185         snprintf(powersaving_at_str, MAX_DISPLAY_NAME_LEN_ON_UI, "At %d%% %s",
186                  value, "battery power");
187         return (char *)g_strdup(powersaving_at_str);
188 }
189
190 char *get_pa_screen_timeout_str()
191 {
192         int value = 15;
193         char screen_timeout_str[MAX_DISPLAY_NAME_LEN_ON_UI + 1];
194
195         int err;
196         int ret =
197             setting_get_int_slp_key(INT_SLP_SETTING_POWERSAVING_SCREEN_TIMEOUT,
198                                     &value,
199                                     &err);
200         if (SETTING_RETURN_FAIL == ret || value < 0) {  /* file system exceptional handle, eg. The vconf file lost due to file system. */
201                 value = 15;     /* keep agree with postin file */
202                 setting_set_int_slp_key
203                     (INT_SLP_SETTING_POWERSAVING_SCREEN_TIMEOUT, value, &err);
204         }
205
206         if (value == 60) {
207                 snprintf(screen_timeout_str, MAX_DISPLAY_NAME_LEN_ON_UI, "%s",
208                          _("1 minute"));
209         } else if (value >= 60) {
210                 snprintf(screen_timeout_str, MAX_DISPLAY_NAME_LEN_ON_UI,
211                          "%d %s", value / 60,
212                          (char *)(_("IDS_COM_BODY_MINUTES_LC")));
213         } else {
214                 snprintf(screen_timeout_str, MAX_DISPLAY_NAME_LEN_ON_UI,
215                          "%d %s", value,
216                          (char *)(_("IDS_COM_BODY_SECONDS_LC")));
217         }
218         return (char *)g_strdup(screen_timeout_str);
219 }
220
221 char *get_pa_display_language_str()
222 {
223         int ret = SETTING_RETURN_FAIL;
224         int err;
225         int index;
226
227         Eina_List* list = setting_get_language_list();
228         Eina_List* elist = NULL;
229
230         ret = setting_get_int_slp_key(INT_SLP_SETTING_LANG, &index, &err);
231
232         if (0 == index)
233                 return g_strdup("Automatic");
234
235         setting_lang_entry* pnode;
236
237         char* title = NULL;
238     EINA_LIST_FOREACH( list, elist, pnode)
239     {
240                 if (pnode->number == index)
241                 title = g_strdup(pnode->title);
242     }
243         return title;
244 }
245
246 char *get_pa_Wi_Fi_on_off_str()
247 {
248         int value, err;
249         int ret = SETTING_RETURN_FAIL;
250         ret =
251             setting_get_int_slp_key(INT_SLP_SETTING_WIFI_STATUS, &value, &err);
252
253         if (SETTING_RETURN_FAIL == ret) {       /* file system exceptional handle, eg. The vconf file lost due to file system. */
254                 value = VCONFKEY_WIFI_OFF;
255                 setting_set_int_slp_key(INT_SLP_SETTING_WIFI_STATUS,
256                                         VCONFKEY_WIFI_OFF, &err);
257         }
258
259         if (value) {
260                 char *pa_wifi_device = vconf_get_str(VCONFKEY_WIFI_CONNECTED_AP_NAME);
261                 SETTING_TRACE("pa_wifi_device:%s", pa_wifi_device);
262                 if (NULL != pa_wifi_device && '\0' != pa_wifi_device[0]) {
263                         return pa_wifi_device;
264                 }
265
266                 return (char*)g_strdup(setting_gettext("IDS_COM_BODY_ON_M_STATUS"));
267         } else {
268                 return (char*)g_strdup(setting_gettext("IDS_COM_BODY_OFF_M_STATUS"));
269         }
270 }
271
272 char *get_Mobile_AP_on_off_str()
273 {
274         int value = -1, err;
275         int ret =
276             setting_get_int_slp_key(INT_SLP_SETTING_MOBILE_AP_STATUS, &value,
277                                     &err);
278
279         /*  7 means bitwise-operation */
280         /*
281               - 1 : wi-fi
282               - 2 : bluetooth
283               - 4 : USB
284               4, 2, 1 = 7
285         */
286         if (0 != ret || value < 0 || value > 7) {
287                 value = 0;
288                 setting_set_int_slp_key(INT_SLP_SETTING_MOBILE_AP_STATUS, value,
289                                         &err);
290         }
291
292         if (value != 0) {
293                 return setting_gettext("IDS_COM_BODY_ON_M_STATUS");
294         } else {                /*  0 */
295                 return setting_gettext("IDS_COM_BODY_OFF_M_STATUS");
296         }
297 }
298
299 char *get_BT_on_off_str()
300 {
301         int ret = SETTING_RETURN_FAIL;
302         int value, err;
303         ret = setting_get_int_slp_key(INT_SLP_SETTING_BT_STATUS, &value, &err);
304
305         if (SETTING_RETURN_FAIL == ret) {       /* file system exceptional handle, eg. The vconf file lost due to file system. */
306                 value = VCONFKEY_BT_STATUS_OFF;
307                 setting_set_int_slp_key(INT_SLP_SETTING_BT_STATUS,
308                                         VCONFKEY_BT_STATUS_OFF, &err);
309         }
310
311         if (VCONFKEY_BT_STATUS_OFF == value) {
312                 return setting_gettext("IDS_COM_BODY_OFF_M_STATUS");
313         } else {
314                 return setting_gettext("IDS_COM_BODY_ON_M_STATUS");
315         }
316 }
317
318 char *get_NFC_on_off_str()
319 {
320         int ret = SETTING_RETURN_FAIL;
321         int value = 0, err = 0;
322         ret = setting_get_bool_slp_key(BOOL_SLP_SETTING_NFC_STATUS, &value, &err);
323
324         if (SETTING_RETURN_FAIL == ret) {       /* file system exceptional handle, eg. The vconf file lost due to file system. */
325                 SETTING_TRACE_DEBUG("fail to get nfc status from vconf");
326                 value = VCONFKEY_NFC_STATE_OFF;
327         }
328
329         if (VCONFKEY_NFC_STATE_OFF == value) {
330                 return setting_gettext("IDS_COM_BODY_OFF_M_STATUS");
331         } else {
332                 return setting_gettext("IDS_COM_BODY_ON_M_STATUS");
333         }
334 }
335
336 char *get_pa_time_format_str()
337 {
338         int ret = SETTING_RETURN_FAIL;
339         int value, err;
340         char *format_str[] = { _("IDS_COM_BODY_12_HOURS"),
341                                 _("IDS_ST_BODY_24_HOURS") };
342         ret =
343             setting_get_int_slp_key(INT_SLP_SETTING_REGIONFORMAT_TIME1224,
344                                     &value, &err);
345         setting_retvm_if(SETTING_RETURN_FAIL == ret, NULL, "Failed to get vconf value");        /* file system exceptional handle */
346
347         /*  scope */
348         /*  value 1:12H  2:24H */
349         if (value > 0 && value <= 2)    /*  1, 2 */
350                 return (char *)g_strdup(format_str[value - 1]);
351         else
352                 return (char *)g_strdup(format_str[0]); /*  set to 12H compelsery */
353 }
354
355 /** @deprecated */
356 char *get_pa_date_format_str()
357 {
358         int ret = SETTING_RETURN_FAIL;
359         int value, err;
360         char *format_str[] = { _("IDS_ST_BODY_DDMMYYYY_DOT"),
361                 _("IDS_ST_BODY_MM_DD_YYYY_DOT"),
362                 _("IDS_COM_BODY_YYYYMMDD"), _("IDS_ST_BODY_YYYY_DD_MM_DOT")
363         };
364         ret =
365             setting_get_int_slp_key(INT_SLP_SETTING_DATE_FORMAT, &value, &err);
366         setting_retvm_if(SETTING_RETURN_FAIL == ret, NULL, "Failed to get vconf value");        /* file system exceptional handle */
367         return (char *)g_strdup(format_str[value]);
368 }
369
370 char *get_pa_week_format_str()
371 {
372         int ret = SETTING_RETURN_FAIL;
373         int value, err;
374         char *format_str[] = {
375                 _("IDS_ST_BODY_SUNDAY"),
376                 _("IDS_ST_BODY_MONDAY"),
377         };
378
379         ret =
380             setting_get_int_slp_key(INT_SLP_SETTING_WEEK_FORMAT, &value, &err);
381         setting_retvm_if(SETTING_RETURN_FAIL == ret, NULL, "Failed to get vconf value");        /* file system exceptional handle */
382         return (char *)g_strdup(format_str[value]);
383 }
384
385 char *get_pa_roaming_network_str()
386 {
387         int ret = SETTING_RETURN_FAIL;
388         int value, err;
389         char *roaming_str[] = {
390                 _("IDS_ST_BODY_AUTO_DOWNLOAD"), _("IDS_COM_BODY_MANUAL"),
391                 _("IDS_ST_BODY_ALWAYS_REJECT")
392         };
393         ret =
394             setting_get_int_slp_key(INT_SLP_SETTING_ROAMING_NETWORK, &value,
395                                     &err);
396         setting_retvm_if(SETTING_RETURN_FAIL == ret, NULL, "Failed to get vconf value");        /* file system exceptional handle */
397         return (char *)g_strdup(roaming_str[value]);
398 }
399
400 double get_widgets_factor()
401 {
402         return elm_scale_get();
403 }
404
405 char *setting_gettext(const char *s)
406 {
407         /* fisrt find in app pg */
408
409         if (s == NULL) {
410                 return "NULL";
411         }
412
413         char *p = dgettext(SETTING_PACKAGE, s);
414
415         if (!safeStrCmp(s, p)) {        /* not found */
416                 /* find in system pkg */
417                 p = dgettext(SYSTEM_PACKAGE, s);
418         }
419         return p;
420 }
421
422 bool is_digital_str(const char *cstr)
423 {
424         if (cstr == NULL || cstr[0] == 0) {
425                 return FALSE;
426         }
427
428         int len = (int)(safeStrLen(cstr));
429         int pos = 0;
430         if (cstr[0] == '-' || cstr[0] == '+') {
431                 if (len <= 1) {
432                         return FALSE;
433                 }
434                 pos++;
435         }
436
437         while (pos < len) {
438                 if (cstr[pos] < '0' || cstr[pos] > '9') {
439                         return FALSE;
440                 }
441                 pos++;
442         }
443
444         return TRUE;
445 }
446
447 bool is_substr_ncase(const char *parentstr, const char *substr)
448 {
449         if (NULL == parentstr || '\0' == parentstr[0])
450                 return FALSE;
451
452         int word_len = safeStrLen(parentstr);
453         int search_len = safeStrLen(substr);
454         int i;
455         bool result = FALSE;
456         for (i = 0; i < word_len; i++) {
457                 if (!strncasecmp(substr, &parentstr[i], search_len)) {
458                         result = TRUE;
459                         break;
460                 }
461         }
462         return result;
463 }
464
465 bool is_string_belong_to_array(const char *partern, const char **array,
466                                int array_num)
467 {
468         int idx = 0;
469         for (; idx < array_num; idx++) {
470                 if (!safeStrCmp(partern, array[idx])) {
471                         return TRUE;
472                 }
473         }
474         return FALSE;
475 }
476
477 //NULL, "", "  ", "     " etc.. are all empty strings
478 bool isEmptyStr(const char *str)
479 {
480         //if (NULL == str)
481         //      return TRUE;
482         while (str)
483         {
484                 if (*str != '\0' && *str != ' ')
485                 {
486                         return FALSE;
487                 }
488                 else if (*str == '\0')
489                 {
490                         return TRUE;
491                 }
492                 str++;
493         }
494         return TRUE;
495 }
496
497
498 int safeStrCmp(const char *s1, const char *s2)
499 {
500         /*  Check NULL value first */
501         if (isEmptyStr(s1) && isEmptyStr(s2)) {
502                 return 0;
503         } else if (isEmptyStr(s1)) {
504                 return 1;
505         } else if (isEmptyStr(s2)) {
506                 return SETTING_RETURN_FAIL;
507         }
508
509         return strcmp(s1, s2);
510 }
511
512 int safeStrNCmp(const char *s1, const char *s2, int len)
513 {
514
515         /*  Check NULL value first */
516         if (isEmptyStr(s1) && isEmptyStr(s2)) {
517                 return 0;
518         } else if (isEmptyStr(s1)) {
519                 return 1;
520         } else if (isEmptyStr(s2)) {
521                 return SETTING_RETURN_FAIL;
522         }
523
524         if (0 == len) {
525                 return 0;
526         }
527
528         return strncmp(s1, s2, len);
529 }
530
531 char *safeStrNCat(char *dst, const char *src, int maxlen)
532 {
533         if (dst && !isEmptyStr(src) && maxlen > 0) {
534                 (void) g_strlcat(dst, src, maxlen + 1);
535         }
536
537         return dst;
538 }
539
540
541 char *safeCopyStr(char *dst, const char *src, int maxlen)
542 {
543         if (maxlen < 0) {
544                 return NULL;
545         }
546
547         if (dst) {
548                 int len = 0;
549
550                 if (src) {
551                         int temp = (int)safeStrLen(src);
552                         len = (temp <= maxlen) ? temp : maxlen;
553                         memcpy(dst, src, len);
554                 }
555
556                 dst[len] = '\0';
557         }
558
559         return dst;
560 }
561
562 int safeStrLen(const char *str)
563 {
564         if (isEmptyStr(str)) {
565                 SETTING_TRACE_DEBUG("string is empty");
566                 return 0;
567         } else {
568                 return strlen(str);
569         }
570 }
571
572 /**
573 * get the int value of substring before delim
574 */
575 bool get_substring_int(const char **ipStr, int *ipValue, char delim)
576 {
577         int iValue = *ipValue = 0;
578         const char *str = *ipStr;
579
580         if (str == NULL || str[0] == 0) {       /* empty string */
581                 return FALSE;
582         }
583
584         bool bNegative = FALSE;
585         if ('-' == str[0]) {    /* allow Negative number.. */
586                 bNegative = TRUE;
587                 str++;
588         }
589         if (str[0] < '0' || str[0] > '9') {     /* first elementy is not digital */
590                 *ipStr = str;
591                 return FALSE;
592         }
593         if (str[0] == '0') {    /* first elementy is 0 */
594                 if (str[1] == delim) {
595                         str += 2;
596                         *ipStr = str;
597                         return TRUE;
598                 }
599                 if (str[1] == 0) {
600                         str++;
601                         *ipStr = str;
602                         return TRUE;
603                 }
604                 *ipStr = str;
605                 return FALSE;
606         }
607
608         for (;;) {
609 /****first elementy is not 0*/
610                 iValue = iValue * 10 + str[0] - '0';
611                 *ipValue = iValue;
612                 if (((unsigned int)iValue & 0x80000000) != 0) { /* think about overloading */
613                         break;
614                 }
615                 str++;
616                 if (str[0] == delim) {
617                         str++;
618                         if (bNegative) {
619                                 iValue = -iValue;
620                         }
621                         *ipStr = str;
622                         *ipValue = iValue;
623                         return TRUE;
624                 }
625                 if (str[0] == 0) {
626                         if (bNegative) {
627                                 iValue = -iValue;
628                         }
629                         *ipStr = str;
630                         *ipValue = iValue;
631                         return TRUE;
632                 }
633                 if (str[0] < '0' || str[0] > '9') {
634                         break;
635                 }
636         }
637
638         *ipStr = str;
639         return FALSE;
640 }
641
642 #define MaxIPAddressLength      15
643
644 /**
645 * CHeck Whether a special string Is An IP String
646 *
647 * @param ipstr string representing IP numbers like "aaa.bbb.ccc.ddd"
648 *
649 * @return true if it's IP format string otherwise false
650 */
651 bool is_ip_string(const char *ipstr)
652 {
653         if (NULL == ipstr || 0 == ipstr[0])
654                 return FALSE;
655         int len = (int)safeStrLen(ipstr);
656         if (len > MaxIPAddressLength) {
657                 return FALSE;
658         }
659
660         if (ipstr[len - 1] == '.') {
661                 return FALSE;
662         }
663
664         int ip;
665         int i = 0;
666         for (; i < 4; i++) {
667                 if (!get_substring_int(&ipstr, &ip, '.') || ip > 255) {
668                         SETTING_TRACE("ipstr:%s", ipstr);
669                         return FALSE;
670                 }
671                 SETTING_TRACE("ipstr:%s", ipstr);
672         }
673         if (ipstr[0] != 0) {
674                 return FALSE;
675         }
676
677         return TRUE;
678 }
679
680 int setting_invoke_reset_function(char *ug_name, service_h service, void *ext)
681 {
682         SETTING_TRACE("Enter %s with ug_name:%s", __FUNCTION__, ug_name);
683         int (*reset) (service_h pair, void *ptr);
684         int ret = OPERATE_LIB_SUCESS;
685
686         //1.first do exist-checking in /opt/ug/lib
687         char ug_file[PATH_MAX + 1];
688         snprintf(ug_file, PATH_MAX, "%s/libug-%s.so", SETTING_UG_PATH, ug_name);
689         struct stat st;
690         if(stat(ug_file, &st) != 0) { 
691
692                 //2.if it does not exit in /opt/ug/lib, then do exist-checking in /usr/ug/lib
693                 memset(ug_file, 0x00, PATH_MAX + 1);
694                 snprintf(ug_file, PATH_MAX, "%s/libug-%s.so", SETTING_UG_PATH_USR, ug_name);
695                 if(stat(ug_file, &st) != 0) {
696                         //both not exist,skip it
697                         SETTING_TRACE_ERROR(" libug-%s.so is *NOT* present, so skip it..\n", ug_name);
698                         return OPERATE_LIB_SUCESS;
699                 }
700         }
701         //-------------------------------------------------------------------------------------
702         void *handle = dlopen(ug_file, RTLD_LAZY);
703         if (!handle) {
704                 SETTING_TRACE_ERROR(" >>>>>>>>>>> %s", dlerror());
705                 return LOAD_LIB_FAILED;
706         }
707
708         char *error = NULL;
709         reset = dlsym(handle, "setting_plugin_reset");
710         if ((error = dlerror()) != NULL) {
711                 SETTING_TRACE_ERROR(" >>>>>>>>>>> %s", error);
712                 dlclose(handle);
713                 return UNDEFINED_LIB_SYMBOL;
714         }
715
716         if (reset)
717                 ret = (*reset) (service, ext);   /*  CALL */
718
719         if (ret < 0) ret += UNDEFINED_LIB_SYMBOL;//from -2 on
720
721         dlclose(handle);
722         return ret;
723 }
724
725 int excuteCmd(char* exec_path, int option_num, ...)
726 {
727         char cmd[MAX_COMMON_BUFFER_LEN + 1] = {0, };
728         snprintf(cmd, MAX_COMMON_BUFFER_LEN,
729                  "%s", exec_path);
730
731
732         va_list args;
733         va_start(args, option_num);
734
735         char *para;
736         int argno = 0;
737         for (; argno < option_num; argno++) {
738                 para = va_arg( args, char *);
739                 SETTING_TRACE("Parameter #%d is: %s", argno, para);
740                 if (para)
741                 {
742                         g_strlcat(cmd, " ", MAX_COMMON_BUFFER_LEN + 1);
743                         g_strlcat(cmd, para, MAX_COMMON_BUFFER_LEN + 1);
744                 }
745         }
746
747         va_end(args);
748
749         SETTING_TRACE("excute:%s", cmd);
750         return system(cmd);
751 }
752
753
754 void create_fontlink(const char *linkpath, const char *linkname,
755                     const char *fontfilepath, const char *fontfilename)
756 {
757         char newpath[MAX_COMMON_BUFFER_LEN + 1];
758         char lcpath[MAX_COMMON_BUFFER_LEN + 1];
759
760         int ret =
761             snprintf(newpath, MAX_COMMON_BUFFER_LEN, "%s/%s", linkpath, linkname);
762         ret_if(ret < 0);
763         snprintf(lcpath, MAX_COMMON_BUFFER_LEN, "%s/%s", fontfilepath, fontfilename);
764
765         SETTING_TRACE("newpath:%s", newpath);
766         SETTING_TRACE("lcpath:%s", lcpath);
767
768         remove(newpath);
769         ret = symlink(lcpath, newpath);
770         setting_retm_if(ret != 0, "fail to call symlink");
771 }
772
773 char* get_icon_path(const char *package)
774 {
775         ail_appinfo_h handle;
776
777         char* ret_str;
778         char *icon_path = IMG_DefaultIcon;//The default icon must exist.(it will be installed by Setting App)
779
780         bool result = TRUE;
781         bool destroy = TRUE;
782
783         if (ail_package_get_appinfo(package, &handle) != AIL_ERROR_OK) {
784                 SETTING_TRACE_ERROR("Failed to ail_package_get_appinfo.");
785                 result = FALSE;
786                 destroy = FALSE;
787         }
788
789         if (result && ail_appinfo_get_str(handle, AIL_PROP_ICON_STR, &icon_path) != AIL_ERROR_OK) {
790                 SETTING_TRACE_ERROR("Failed to ail_appinfo_get_str.");
791                 result = FALSE;
792         }
793
794         if (result && access(icon_path, R_OK|F_OK ) !=0 ) {//The file cannot be accessed.
795                 SETTING_TRACE_ERROR("The file[%s] cannot be accessed. To use defaut icon.", icon_path);
796                 icon_path = IMG_DefaultIcon;
797         }
798
799         ret_str = strdup(icon_path);
800         if (destroy && ail_package_destroy_appinfo(handle) != AIL_ERROR_OK) {
801                 SETTING_TRACE_ERROR("Failed to ail_package_destroy_appinfo.");
802         }
803         return ret_str;
804 }
805
806 // SLP : 1
807 // not SLP : 0
808 int is_slp_binary()
809 {
810         dictionary* dic = iniparser_load("/etc/info.ini");
811         char* str = (char *)iniparser_getstr(dic, "Version:Build");
812         char* pos = str;
813         if (str) {
814                 while(*pos++){
815                         if('_' == *pos) {
816                                 *pos = '\0';
817                                 if (!strncmp(str, "SLP", 3)) return 1;
818                         }
819                 }
820         }
821         if (dic) {
822                 iniparser_freedict(dic);
823                 dic = NULL;
824         }
825         return 0;
826 }
827
828 bool isEmulBin()
829 {
830 #if DISABLED_CODE
831         char szEmul[__LEN_STR_EMUL+1];
832         const char* szBinVer = NULL;
833
834         dictionary* dic = iniparser_load(BIN_INFO_FILE_PATH);
835         // when failed to get the info, let's regard the binary as an emulator one
836         if (!dic)
837                 return TRUE;
838
839         szBinVer = (const char*)iniparser_getstr(dic, "Version:Build");
840         if (szBinVer) {
841                 char* str = g_strdup(szBinVer);
842                 if (str) {
843                         char* pPos = str;
844                         while (*pPos++) {
845                                 if ('_' == *pPos)
846                                         *pPos = ' ';
847                         }
848                         sscanf(str, "%*s %4s", szEmul);
849                 }
850                 G_FREE(str);
851         }
852
853         if (dic) {
854                 iniparser_freedict(dic);
855                 dic = NULL;
856         }
857
858         if (!strncmp(szEmul, __STR_EMUL, __LEN_STR_EMUL)) {
859                 return TRUE;
860         } else {
861                 return FALSE;
862         }
863 #else
864         char *model_str = NULL;
865         int ret = system_info_get_value_string(SYSTEM_INFO_KEY_MODEL, &model_str);
866         //SETTING_TRACE("model_str : %s", model_str);
867         if (ret != SYSTEM_INFO_ERROR_NONE) {
868                 SETTING_TRACE_ERROR("fail to call system_info_get_value_string");
869                 FREE(model_str);
870                 return FALSE;
871         }
872
873         if (0 == safeStrCmp(KeyStr_Emulator, model_str)) {
874                 FREE(model_str);
875                 return TRUE;
876         } else {
877                 FREE(model_str);
878                 return FALSE;
879         }
880 #endif
881 }
882
883 int get_popup_btn_response_type(const char *btn_str)
884 {
885         SETTING_TRACE("btn_str:%s", btn_str);
886         POPUP_BTN_RESPONSE_TYPE rsp_type = POPUP_RESPONSE_INVALID;
887         retv_if(!btn_str, rsp_type);
888         if (0 == safeStrCmp(btn_str, _("IDS_COM_BODY_CLOSE"))
889             || 0 == safeStrCmp(btn_str, _("IDS_COM_SK_TRY"))//KeyStr_Try
890             || 0 == safeStrCmp(btn_str, _("IDS_COM_SK_OK"))
891             || 0 == safeStrCmp(btn_str, _("IDS_COM_SK_YES"))
892             || 0 == safeStrCmp(btn_str, _("IDS_ST_BODY_USE_MOTION"))
893             || 0 == safeStrCmp(btn_str, _("IDS_COM_POP_TRY_AGAIN"))
894             || 0 == safeStrCmp(btn_str, _("IDS_COM_SK_DELETE"))
895             || 0 == safeStrCmp(btn_str, _(KeyStr_Save)))
896         {
897                 rsp_type = POPUP_RESPONSE_OK;
898         }
899         else //for others,
900         {
901                 rsp_type = POPUP_RESPONSE_CANCEL;
902         }
903         return rsp_type;
904 }
905
906 #define SUPPORT_STATIC_LOAD 1
907 #if SUPPORT_STATIC_LOAD
908 static char *system_service_list[MAX_SYSTEM_SERVICE_NUM] = {NULL, };
909 #endif
910 void clear_system_service_data()
911 {
912         #if SUPPORT_STATIC_LOAD
913         int idx;
914         for (idx = 0; idx < MAX_SYSTEM_SERVICE_NUM && system_service_list[idx]; idx++)
915         {
916                 FREE(system_service_list[idx]);
917         }
918         #endif
919 }
920
921 bool is_system_service(const char *pkg_name)
922 {
923         //SLP native apps list,
924         if (0 == safeStrCmp(pkg_name, "com.samsung.menu-screen")
925             || 0 == safeStrCmp(pkg_name, "com.samsung.live-data-provider")
926             || 0 == safeStrCmp(pkg_name, "com.samsung.live-magazine")
927             || 0 == safeStrCmp(pkg_name, "com.samsung.pwlock")
928             || 0 == safeStrCmp(pkg_name, "com.samsung.quickpanel")
929             || 0 == safeStrCmp(pkg_name, "com.samsung.vtmain")
930             || 0 == safeStrCmp(pkg_name, "com.samsung.call")
931             || 0 == safeStrCmp(pkg_name, "usb_setting")
932             || 0 == safeStrCmp(pkg_name, "com.samsung.indicator")
933             || 0 == safeStrCmp(pkg_name, "com.samsung.cluster-home")
934            )
935         {
936                 return TRUE;
937         }
938
939         //OSP service app list,
940         bool ret = FALSE;
941 #if SUPPORT_STATIC_LOAD
942         int idx = 0;
943         if (!system_service_list[0]) //just load the file
944         {
945                 FILE *fp = fopen(SYSTEM_SERVICE_LIST_PATH, "r");
946                 if (fp) {
947                         char result[MAX_PKG_NAME_LEN+1] = {0, };
948                         while (fgets(result, MAX_PKG_NAME_LEN, fp))
949                         {
950                                 result[strlen(result) - 1] = '\0';//offset 1
951                                 system_service_list[idx++] = strdup(result);
952                         }
953                         fclose(fp);
954                 }
955
956         }
957
958         for (idx = 0; idx < MAX_SYSTEM_SERVICE_NUM && system_service_list[idx]; idx++)
959         {
960                 if (0 == safeStrCmp(pkg_name, system_service_list[idx])) {
961                         ret = TRUE;
962                         break;
963                 }
964         }
965 #else
966         FILE *fp = fopen(SYSTEM_SERVICE_LIST_PATH, "r");
967         if (fp) {
968                 char result[MAX_PKG_NAME_LEN+1] = {0, };
969                 while (fgets(result, MAX_PKG_NAME_LEN, fp))
970                 {
971                         result[strlen(result) - 1] = '\0';//offset 1
972                         if (0 == safeStrCmp(pkg_name, result)) {
973                                 ret = TRUE;
974                                 break;
975                         }
976                 }
977                 fclose(fp);
978         }
979 #endif
980         SETTING_TRACE("ret:%d", ret);
981         return ret;
982 }
983
984 /**
985   * should use g_free to free returned string
986   */
987 char *get_default_font(int language)
988 {
989         char *font_name = NULL;
990
991         switch(language)
992         {
993         case SETTING_LANG_KOREA:
994                 font_name = g_strdup("SLPSansKorean");
995                 break;
996         case SETTING_LANG_CHINA:
997                 /* output_font : SLPSansFallback*/
998         case SETTING_LANG_CANTONESE:
999                 /* output_font : SLPSansFallback*/
1000         case SETTING_LANG_TAIWAN:
1001                 font_name = g_strdup("SLPSansFallback");
1002                 break;
1003         case SETTING_LANG_JAPAN:
1004                 font_name = g_strdup("UDGothic");
1005                 break;
1006         case SETTING_LANG_AUTOMATIC:
1007                 /* output_font : HelveticaNeue*/
1008         case SETTING_LANG_ENGLISH:
1009                 /* output_font : HelveticaNeue*/
1010         case SETTING_LANG_GERMAN:
1011                 /* output_font : HelveticaNeue*/
1012         case SETTING_LANG_DUTCH:
1013                 /* output_font : HelveticaNeue*/
1014         case SETTING_LANG_SPAINISH:
1015                 /* output_font : HelveticaNeue*/
1016         case SETTING_LANG_PORTUGUESE:
1017                 /* output_font : HelveticaNeue*/
1018         case SETTING_LANG_GREEK:
1019                 /* output_font : HelveticaNeue*/
1020         case SETTING_LANG_ITALIAN:
1021                 /* output_font : HelveticaNeue*/
1022         case SETTING_LANG_FRENCH:
1023                 /* output_font : HelveticaNeue*/
1024         case SETTING_LANG_TURKISH:
1025                 /* output_font : HelveticaNeue*/
1026         case SETTING_LANG_RUSSIAN:
1027                 font_name = g_strdup("HelveticaNeue");
1028                 break;
1029         default:
1030                 font_name = g_strdup("HelveticaNeue");
1031                 break;
1032         }
1033         return font_name;
1034 }
1035
1036 void *font_conf_doc_parse(char *doc_name, char *font_name)
1037 {
1038         SETTING_TRACE_BEGIN;
1039         setting_retvm_if(doc_name == NULL, NULL, "Param data is NULL");
1040         setting_retvm_if(font_name == NULL, NULL, "Param data is NULL");
1041         xmlDocPtr doc = NULL;
1042         xmlNodePtr cur = NULL;
1043         xmlNodePtr cur2 = NULL;
1044         xmlNodePtr cur3 = NULL;
1045         xmlChar *key = NULL;
1046
1047         doc = xmlParseFile(doc_name);
1048         setting_retvm_if(doc == NULL, NULL, "Document not parsed successfully.");
1049
1050         cur = xmlDocGetRootElement(doc);
1051
1052         if (cur == NULL) {
1053                 SETTING_TRACE_DEBUG("empty document");
1054                 xmlFreeDoc(doc);
1055                 doc = NULL;
1056                 return NULL;
1057         }
1058
1059         if(xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
1060                 SETTING_TRACE_DEBUG("document of the wrong type, root node != fontconfig");
1061                 xmlFreeDoc(doc);
1062                 doc = NULL;
1063                 return NULL;
1064         }
1065
1066         cur = cur->xmlChildrenNode;
1067
1068         Eina_Bool is_changed = EINA_FALSE;
1069         while(cur != NULL)
1070         {
1071                 if((!xmlStrcmp(cur->name, (const xmlChar *)"match")))
1072                 {
1073                         cur2 = cur->xmlChildrenNode;
1074                         while(cur2 != NULL)
1075                         {
1076                                 if((!xmlStrcmp(cur2->name, (const xmlChar *)"edit")))
1077                                 {
1078                                         xmlChar *name = xmlGetProp(cur2, (const xmlChar *)"name");
1079                                         SETTING_TRACE_DEBUG("name is: %s", name);
1080                                         /* if name is not 'family', break */
1081                                         if (xmlStrcmp(name, (const xmlChar *)"family"))
1082                                         {
1083                                                 xmlFree(name);
1084                                                 name = NULL;
1085                                                 break;
1086                                         }
1087                                         xmlFree(name);
1088                                         name = NULL;
1089
1090                                         cur3 = cur2->xmlChildrenNode;
1091                                         while(cur3 != NULL)
1092                                         {
1093                                                 if((!xmlStrcmp(cur3->name, (const xmlChar *)"string")))
1094                                                 {
1095                                                         xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
1096                                                         key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1097                                                         SETTING_TRACE_DEBUG("after changed, string is: %s", key);
1098                                                         xmlFree(key);
1099                                                         key = NULL;
1100                                                         is_changed = EINA_TRUE;
1101                                                 }
1102                                                 cur3 = cur3->next;
1103                                         }
1104                                 }
1105                                 cur2 = cur2->next;
1106                         }
1107                 } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"alias")))
1108                 {
1109                         cur2 = cur->xmlChildrenNode;
1110                         while (cur2 != NULL)
1111                         {
1112                                 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"family")))
1113                                 {
1114                                         xmlNodeSetContent(cur2->xmlChildrenNode, (const xmlChar *)font_name);
1115                                         key = xmlNodeListGetString(doc, cur2->xmlChildrenNode, 1);
1116                                         SETTING_TRACE_DEBUG("after changed, string is: %s", key);
1117                                         xmlFree(key);
1118                                         key = NULL;
1119                                         is_changed = EINA_TRUE;
1120                                 } else if ((!xmlStrcmp(cur2->name, (const xmlChar *)"prefer")))
1121                                 {
1122                                         cur3 = cur2->xmlChildrenNode;
1123                                         while (cur3 != NULL)
1124                                         {
1125                                                 if((!xmlStrcmp(cur3->name, (const xmlChar *)"family")))
1126                                                 {
1127                                                         xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
1128                                                         key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1129                                                         SETTING_TRACE_DEBUG("after changed, string is: %s", key);
1130                                                         xmlFree(key);
1131                                                         key = NULL;
1132                                                         is_changed = EINA_TRUE;
1133                                                         cur3 = cur3->next;
1134                                                         break; /* just set first element, so break */
1135                                                 }
1136                                                 cur3 = cur3->next;
1137                                         }
1138                                 }
1139                                 cur2 = cur2->next;
1140                         }
1141
1142                 }
1143                 cur = cur->next;
1144         }
1145
1146         if (is_changed) {
1147                 return doc;
1148         } else {
1149                 xmlFreeDoc(doc);
1150                 doc = NULL;
1151                 return NULL;
1152         }
1153 }
1154
1155 /**
1156  * should use g_free to free return string
1157  */
1158 char *cur_font_get()
1159 {
1160         SETTING_TRACE_BEGIN;
1161         xmlDocPtr doc = NULL;
1162         xmlNodePtr cur = NULL;
1163         xmlNodePtr cur2 = NULL;
1164         xmlNodePtr cur3 = NULL;
1165         xmlChar *key = NULL;
1166
1167         char *font_name = NULL;
1168
1169         doc = xmlParseFile(SETTING_FONT_CONF_FILE);
1170         setting_retvm_if(doc == NULL, NULL, "Document not parsed successfully.");
1171
1172         cur = xmlDocGetRootElement(doc);
1173
1174         if(cur == NULL) {
1175                 SETTING_TRACE_DEBUG("empty document");
1176                 xmlFreeDoc(doc);
1177                 doc = NULL;
1178                 return NULL;
1179         }
1180
1181         if(xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
1182                 SETTING_TRACE_DEBUG("document of the wrong type, root node != fontconfig");
1183                 xmlFreeDoc(doc);
1184                 doc = NULL;
1185                 return NULL;
1186         }
1187
1188         cur = cur->xmlChildrenNode;
1189
1190         while(cur != NULL)
1191         {
1192                 if((!xmlStrcmp(cur->name, (const xmlChar *)"match")))
1193                 {
1194                         cur2 = cur->xmlChildrenNode;
1195                         while(cur2 != NULL)
1196                         {
1197                                 if((!xmlStrcmp(cur2->name, (const xmlChar *)"edit")))
1198                                 {
1199                                         cur3 = cur2->xmlChildrenNode;
1200                                         while(cur3 != NULL)
1201                                         {
1202                                                 if((!xmlStrcmp(cur3->name, (const xmlChar *)"string")))
1203                                                 {
1204                                                         key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1205                                                         SETTING_TRACE_DEBUG("string is: %s", key);
1206
1207                                                         font_name = g_strdup((char *)key);
1208                                                         xmlFree(key);
1209                                                         key = NULL;
1210                                                         xmlFreeDoc(doc);
1211                                                         doc = NULL;
1212                                                         return font_name;
1213                                                 }
1214                                                 cur3 = cur3->next;
1215                                         }
1216                                 }
1217                                 cur2 = cur2->next;
1218                         }
1219                 }
1220                 cur = cur->next;
1221         }
1222
1223         xmlFreeDoc(doc);
1224         doc = NULL;
1225         return NULL;
1226 }
1227
1228 static int __font_size_get()
1229 {
1230         int font_size = -1;
1231         int value = -1;
1232         int err = -1;
1233         int ret = setting_get_int_slp_key(INT_SLP_SETTING_ACCESSIBILITY_FONT_SIZE, &value, &err);
1234         retvm_if(ret != 0, -1, "get vconf failed");
1235
1236         switch(value) {
1237         case SYSTEM_SETTINGS_FONT_SIZE_SMALL:
1238                 font_size = SMALL_FONT_DPI;
1239                 break;
1240         case SYSTEM_SETTINGS_FONT_SIZE_NORMAL:
1241                 font_size = MIDDLE_FONT_DPI;
1242                 break;
1243         case SYSTEM_SETTINGS_FONT_SIZE_LARGE:
1244                 font_size = LARGE_FONT_DPI;
1245                 break;
1246         case SYSTEM_SETTINGS_FONT_SIZE_HUGE:
1247                 font_size = HUGE_FONT_DPI;
1248                 break;
1249         case SYSTEM_SETTINGS_FONT_SIZE_GIANT:
1250                 font_size = GIANT_FONT_DPI;
1251                 break;
1252         default:
1253                 font_size = MIDDLE_FONT_DPI;
1254                 break;
1255         }
1256         return font_size;
1257 }
1258
1259 void font_config_set(char *font_name)
1260 {
1261         Eina_List *text_classes = NULL;
1262         Elm_Text_Class *etc = NULL;
1263         const Eina_List *l = NULL;
1264         Eina_List *fo_list = NULL;
1265         Elm_Font_Overlay *efo = NULL;
1266         int font_size = __font_size_get();
1267         int size = 0;
1268
1269         text_classes = elm_config_text_classes_list_get();
1270
1271         fo_list = (Eina_List *)elm_config_font_overlay_list_get();
1272
1273         Eina_List *ll = NULL;
1274         Eina_List *l_next = NULL;
1275
1276         Eina_Bool slp_medium_exist = EINA_FALSE;
1277         Eina_Bool slp_roman_exist = EINA_FALSE;
1278         Eina_Bool slp_bold_exist = EINA_FALSE;
1279         Eina_Bool slp_regular_exist = EINA_FALSE;
1280
1281         EINA_LIST_FOREACH_SAFE(fo_list, ll, l_next, efo)
1282         {
1283                 if (!safeStrCmp(efo->text_class, "slp_medium")) {
1284                         elm_config_font_overlay_set(efo->text_class, (const char*)font_name, efo->size);
1285                         slp_medium_exist = EINA_TRUE;
1286                 } else if (!safeStrCmp(efo->text_class, "slp_roman")) {
1287                         elm_config_font_overlay_set(efo->text_class, (const char*)font_name, efo->size);
1288                         slp_roman_exist = EINA_TRUE;
1289                 } else if (!safeStrCmp(efo->text_class, "slp_bold")) {
1290                         elm_config_font_overlay_set(efo->text_class, (const char*)font_name, efo->size);
1291                         slp_bold_exist = EINA_TRUE;
1292                 } else if (!safeStrCmp(efo->text_class, "slp_regular")) {
1293                         elm_config_font_overlay_set(efo->text_class, (const char*)font_name, efo->size);
1294                         slp_regular_exist = EINA_TRUE;
1295                 }
1296         }
1297
1298         /* if slp_XX do not exist, need to set them, font size is -100(100%) */
1299         if (slp_medium_exist == EINA_FALSE) {
1300                 elm_config_font_overlay_set("slp_medium", (const char*)font_name,  MIDDLE_FONT_DPI);
1301         }
1302         if (slp_roman_exist == EINA_FALSE) {
1303                 elm_config_font_overlay_set("slp_roman", (const char*)font_name,  MIDDLE_FONT_DPI);
1304         }
1305         if (slp_bold_exist == EINA_FALSE) {
1306                 elm_config_font_overlay_set("slp_bold", (const char*)font_name,  MIDDLE_FONT_DPI);
1307         }
1308         if (slp_regular_exist == EINA_FALSE) {
1309                 elm_config_font_overlay_set("slp_regular", (const char*)font_name,  MIDDLE_FONT_DPI);
1310         }
1311
1312         EINA_LIST_FOREACH(text_classes, l, etc)
1313         {
1314                 ll = NULL;
1315
1316                 size = font_size;
1317                 EINA_LIST_FOREACH(fo_list, ll, efo)
1318                 {
1319                         if (!safeStrCmp(etc->name, efo->text_class)) {
1320                                 size = efo->size;
1321                         }
1322                 }
1323                 elm_config_font_overlay_set(etc->name, (const char*)font_name, size);
1324         }
1325
1326         elm_config_font_overlay_apply();
1327         elm_config_all_flush();
1328         elm_config_engine_set("software_x11");
1329         elm_config_save();
1330         elm_config_text_classes_list_free(text_classes);
1331         text_classes = NULL;
1332
1333         // vconf update
1334         vconf_set_str(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, font_name);
1335 }
1336
1337 void font_size_set()
1338 {
1339         Eina_List *text_classes = NULL;
1340         Elm_Text_Class *etc = NULL;
1341         const Eina_List *l = NULL;
1342         int font_size = __font_size_get();
1343         char *font_name = cur_font_get();
1344
1345         if (font_size == -1) {
1346                 SETTING_TRACE_DEBUG("failed to call font_size_get");
1347                 return;
1348         }
1349
1350         text_classes = elm_config_text_classes_list_get();
1351
1352         EINA_LIST_FOREACH(text_classes, l, etc)
1353         {
1354                 elm_config_font_overlay_set(etc->name, font_name, font_size);
1355         }
1356
1357         elm_config_all_flush();
1358         elm_config_engine_set("software_x11");
1359         elm_config_save();
1360         elm_config_text_classes_list_free(text_classes);
1361         text_classes = NULL;
1362         G_FREE(font_name);
1363 }