Tizen 2.1 release
[platform/core/uifw/e17.git] / src / modules / wizard / e_mod_main.c
1 #include "e.h"
2 #include "e_mod_main.h"
3
4 /* actual module specifics */
5 E_Module *wiz_module = NULL;
6
7 /*
8  * These are the currently planned wizard pages:
9  *
10  * o == interactive
11  * . == automatic (no gui - none implemented currently)
12  *
13  * * = done
14  * - = code here, but disabled in build
15  *
16  * --- THE LIST
17  * o *ask for language (default selection is current locale).
18  * o *ask for initial profile
19  * o *find XDG app menus/repositories and list them let user choose which
20  *    one(s) are to be used.
21  * o -ask for ibar initial app set
22  * o -ask if user wants desktop icons or not (enable fwin module but seed it
23  *    with default config icons on desktop and favorites).
24  * o -ask click to focus or sloppy
25  * . *take some of current config (language, fileman, profile) and load
26  *    load profile, apply language to it and save, restart e.
27  *
28  * why are some disabled? profiels take care of this and do a better job
29  * at collecting all the things together. for example illume makes no sense
30  * with pointer focus and ibar icons/desktop makes no sense.
31  */
32
33 /* module setup */
34 EAPI E_Module_Api e_modapi =
35 {
36    E_MODULE_API_VERSION,
37    "Wizard"
38 };
39
40 static int
41 _cb_sort_files(char *f1, char *f2)
42 {
43    return strcmp(f1, f2);
44 }
45
46 EAPI void *
47 e_modapi_init(E_Module *m)
48 {
49    Eina_List *files;
50    char buf[PATH_MAX];
51    char *file;
52
53    wiz_module = m;
54    e_wizard_init();
55
56    snprintf(buf, sizeof(buf), "%s/%s", e_module_dir_get(m), MODULE_ARCH);
57    files = ecore_file_ls(buf);
58    files = eina_list_sort(files, 0, (Eina_Compare_Cb)_cb_sort_files);
59    EINA_LIST_FREE(files, file)
60      {
61         if (!strncmp(file, "page_", 5))
62           {
63              void *handle;
64
65              snprintf(buf, sizeof(buf), "%s/%s/%s",
66                       e_module_dir_get(m), MODULE_ARCH, file);
67              handle = dlopen(buf, RTLD_NOW | RTLD_GLOBAL);
68              if (handle)
69                e_wizard_page_add(handle,
70                                  dlsym(handle, "wizard_page_init"),
71                                  dlsym(handle, "wizard_page_shutdown"),
72                                  dlsym(handle, "wizard_page_show"),
73                                  dlsym(handle, "wizard_page_hide"),
74                                  dlsym(handle, "wizard_page_apply"));
75              else
76                {
77                   // if its an executable...
78                   // XXX
79                   // else...
80                   printf("%s\n", dlerror());
81                }
82           }
83         free(file);
84      }
85    e_wizard_go();
86
87    return m;
88 }
89
90 EAPI int
91 e_modapi_shutdown(E_Module *m __UNUSED__)
92 {
93    e_wizard_shutdown();
94    wiz_module = NULL;
95 // FIXME: wrong place
96 //   e_module_disable(m); /* disable - on restart this won't be loaded now */
97 //   e_sys_action_do(E_SYS_RESTART, NULL); /* restart e - cleanly try settings */
98    return 1;
99 }
100
101 EAPI int
102 e_modapi_save(E_Module *m __UNUSED__)
103 {
104    return 1;
105 }
106