update for beta release
[framework/uifw/e17.git] / src / modules / wizard / page_100.c
1 /* Setup if we need cpufreq? */
2 #include "e.h"
3 #include "e_mod_main.h"
4
5 #ifdef __FreeBSD__
6 #include <sys/types.h>
7 #include <sys/sysctl.h>
8 #endif
9
10 static char *
11 read_file(const char *file)
12 {
13    FILE *f = fopen(file, "r");
14    size_t len;
15    char buf[4096], *p;
16    if (!f) return NULL;
17    len = fread(buf, 1, sizeof(buf) - 1, f);
18    if (len == 0)
19      {
20         fclose(f);
21         return NULL;
22      }
23    buf[len] = 0;
24    for (p = buf; *p; p++)
25      {
26         if (p[0] == '\n') p[0] = 0;
27      }
28    fclose(f);
29    return strdup(buf);
30 }
31
32 EAPI int
33 wizard_page_init(E_Wizard_Page *pg __UNUSED__)
34 {
35    return 1;
36 }
37
38 EAPI int
39 wizard_page_shutdown(E_Wizard_Page *pg __UNUSED__)
40 {
41    return 1;
42 }
43
44 EAPI int
45 wizard_page_show(E_Wizard_Page *pg __UNUSED__)
46 {
47    int hav_cpufreq = 0;
48 #ifdef __FreeBSD__
49    char buf[PATH_MAX];
50    size_t len = 0;
51    
52    len = sizeof(buf);
53    if (sysctlbyname("dev.cpu.0.freq_levels", buf, &len, NULL, 0) == 0)
54       hav_cpufreq = 1;
55 #else
56    char *str, *p;
57
58    str = read_file("/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies");
59    if (str)
60      {
61         for (p = str; *p; p++)
62           {
63              if (isspace(*p))
64                {
65                   hav_cpufreq = 1;
66                   break;
67                }
68           }
69         free(str);
70      }
71 #endif
72    if (!hav_cpufreq)
73      {
74         E_Config_Module *em;
75         Eina_List *l;
76         
77         EINA_LIST_FOREACH(e_config->modules, l, em)
78           {
79              if (!em->name) continue;
80              if (!strcmp(em->name, "cpufreq"))
81                {
82                   e_config->modules = eina_list_remove_list
83                      (e_config->modules, l);
84                   if (em->name) eina_stringshare_del(em->name);
85                   free(em);
86                   break;
87                }
88           }
89         e_config_save_queue();
90      }
91    return 0; /* 1 == show ui, and wait for user, 0 == just continue */
92 }
93
94 EAPI int
95 wizard_page_hide(E_Wizard_Page *pg __UNUSED__)
96 {
97    return 1;
98 }
99
100 EAPI int
101 wizard_page_apply(E_Wizard_Page *pg __UNUSED__)
102 {
103    return 1;
104 }