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