summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichaël Bouchaud (yoz) <yoz@efl.so>2016-11-28 15:04:21 +0100
committerMichaël Bouchaud (yoz) <yoz@efl.so>2017-01-08 12:12:08 +0100
commitbef6457d03fbf9c7f7e20e77abf548723967d684 (patch)
treebce682c8019c379f90869a4ac680a1b4b39356a4
parentfe821b5eeae6529b9742e4d7d242c42adc789efe (diff)
bryce_migration: add a module to migrate from shelf to brycedevs/yoz/bryce
-rw-r--r--configure.ac2
-rw-r--r--src/bin/e_bryce.c29
-rw-r--r--src/bin/e_bryce.h1
-rw-r--r--src/bin/e_module.c1
-rw-r--r--src/modules/Makefile.mk3
-rw-r--r--src/modules/Makefile_bryce_migration.mk32
-rw-r--r--src/modules/bryce_migration/config_migration.c618
-rw-r--r--src/modules/bryce_migration/e_mod_main.c181
-rw-r--r--src/modules/bryce_migration/module.desktop.in7
9 files changed, 867 insertions, 7 deletions
diff --git a/configure.ac b/configure.ac
index df69b29e7..0d0b1d503 100644
--- a/configure.ac
+++ b/configure.ac
@@ -902,6 +902,7 @@ AC_E_OPTIONAL_MODULE([geolocation], true)
902AC_E_OPTIONAL_MODULE([xwayland], $have_wayland_dep, [CHECK_MODULE_XWAYLAND]) 902AC_E_OPTIONAL_MODULE([xwayland], $have_wayland_dep, [CHECK_MODULE_XWAYLAND])
903AC_E_OPTIONAL_MODULE([wireless], true) 903AC_E_OPTIONAL_MODULE([wireless], true)
904AC_E_OPTIONAL_MODULE([time], true) 904AC_E_OPTIONAL_MODULE([time], true)
905AC_E_OPTIONAL_MODULE([bryce_migration], true)
905 906
906if test "x${HAVE_WL_X11}" != "xyes" && test "x${have_wayland}" = "xyes" && test "x${HAVE_XWAYLAND}" != "xyes"; then 907if test "x${HAVE_WL_X11}" != "xyes" && test "x${have_wayland}" = "xyes" && test "x${HAVE_XWAYLAND}" != "xyes"; then
907 AC_DEFINE_UNQUOTED([HAVE_WAYLAND_ONLY],[1],[enable wayland-only version of enlightenment]) 908 AC_DEFINE_UNQUOTED([HAVE_WAYLAND_ONLY],[1],[enable wayland-only version of enlightenment])
@@ -1132,6 +1133,7 @@ src/modules/wl_desktop_shell/module.desktop
1132src/modules/wireless/module.desktop 1133src/modules/wireless/module.desktop
1133src/modules/time/module.desktop 1134src/modules/time/module.desktop
1134src/modules/luncher/module.desktop 1135src/modules/luncher/module.desktop
1136src/modules/bryce_migration/module.desktop
1135data/xsession/enlightenment.desktop 1137data/xsession/enlightenment.desktop
1136data/etc/sysactions.conf 1138data/etc/sysactions.conf
1137data/units/enlightenment.service 1139data/units/enlightenment.service
diff --git a/src/bin/e_bryce.c b/src/bin/e_bryce.c
index a8e38e608..9bc13ac38 100644
--- a/src/bin/e_bryce.c
+++ b/src/bin/e_bryce.c
@@ -53,6 +53,9 @@ typedef struct Bryces
53 Eina_List *bryces; 53 Eina_List *bryces;
54} Bryces; 54} Bryces;
55 55
56
57static void _bryce_delete(Bryce *b);
58
56static E_Config_DD *edd_bryces; 59static E_Config_DD *edd_bryces;
57static E_Config_DD *edd_bryce; 60static E_Config_DD *edd_bryce;
58static Bryces *bryces; 61static Bryces *bryces;
@@ -750,13 +753,7 @@ _bryce_autohide_menu(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UNU
750static void 753static void
751_bryce_remove_menu(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED) 754_bryce_remove_menu(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED)
752{ 755{
753 Bryce *b = data; 756 _bryce_delete(data);
754 bryces->bryces = eina_list_remove(bryces->bryces, data);
755 e_gadget_site_del(b->site);
756 eina_stringshare_del(b->name);
757 eina_stringshare_del(b->style);
758 evas_object_hide(b->bryce);
759 evas_object_del(b->bryce);
760 e_config_save_queue(); 757 e_config_save_queue();
761} 758}
762 759
@@ -940,6 +937,17 @@ _bryce_create(Bryce *b, Evas_Object *parent)
940 _bryce_autosize(b); 937 _bryce_autosize(b);
941} 938}
942 939
940static void
941_bryce_delete(Bryce *b)
942{
943 bryces->bryces = eina_list_remove(bryces->bryces, b);
944 e_gadget_site_del(b->site);
945 eina_stringshare_del(b->name);
946 eina_stringshare_del(b->style);
947 evas_object_hide(b->bryce);
948 evas_object_del(b->bryce);
949}
950
943static Eina_Bool 951static Eina_Bool
944_bryce_act_resize(E_Object *obj, const char *params, E_Binding_Event_Wheel *ev) 952_bryce_act_resize(E_Object *obj, const char *params, E_Binding_Event_Wheel *ev)
945{ 953{
@@ -1035,6 +1043,13 @@ e_bryce_add(Evas_Object *parent, const char *name, E_Gadget_Site_Orient orient,
1035} 1043}
1036 1044
1037E_API void 1045E_API void
1046e_bryce_delete(Evas_Object *bryce)
1047{
1048 BRYCE_GET(bryce);
1049 _bryce_delete(b);
1050}
1051
1052E_API void
1038e_bryce_orient(Evas_Object *bryce, E_Gadget_Site_Orient orient, E_Gadget_Site_Anchor an) 1053e_bryce_orient(Evas_Object *bryce, E_Gadget_Site_Orient orient, E_Gadget_Site_Anchor an)
1039{ 1054{
1040 const char *loc = NULL, *loc2 = NULL; 1055 const char *loc = NULL, *loc2 = NULL;
diff --git a/src/bin/e_bryce.h b/src/bin/e_bryce.h
index 3f575a2d8..644c7e663 100644
--- a/src/bin/e_bryce.h
+++ b/src/bin/e_bryce.h
@@ -6,6 +6,7 @@ EINTERN void e_bryce_init(void);
6EINTERN void e_bryce_shutdown(void); 6EINTERN void e_bryce_shutdown(void);
7 7
8E_API Evas_Object *e_bryce_add(Evas_Object *parent, const char *name, E_Gadget_Site_Orient orient, E_Gadget_Site_Anchor an); 8E_API Evas_Object *e_bryce_add(Evas_Object *parent, const char *name, E_Gadget_Site_Orient orient, E_Gadget_Site_Anchor an);
9E_API void e_bryce_delete(Evas_Object *bryce);
9E_API void e_bryce_orient(Evas_Object *bryce, E_Gadget_Site_Orient orient, E_Gadget_Site_Anchor an); 10E_API void e_bryce_orient(Evas_Object *bryce, E_Gadget_Site_Orient orient, E_Gadget_Site_Anchor an);
10E_API Evas_Object *e_bryce_site_get(Evas_Object *bryce); 11E_API Evas_Object *e_bryce_site_get(Evas_Object *bryce);
11E_API Eina_Bool e_bryce_autosize_get(Evas_Object *bryce); 12E_API Eina_Bool e_bryce_autosize_get(Evas_Object *bryce);
diff --git a/src/bin/e_module.c b/src/bin/e_module.c
index 9bfc3170b..ba9e0791f 100644
--- a/src/bin/e_module.c
+++ b/src/bin/e_module.c
@@ -1042,6 +1042,7 @@ _e_module_whitelist_check(void)
1042 "policy_mobile", 1042 "policy_mobile",
1043 "geolocation", 1043 "geolocation",
1044 "xwayland", 1044 "xwayland",
1045 "bryce_migration",
1045 NULL // end marker 1046 NULL // end marker
1046 }; 1047 };
1047 1048
diff --git a/src/modules/Makefile.mk b/src/modules/Makefile.mk
index fc7ace3a6..dd0a2ae94 100644
--- a/src/modules/Makefile.mk
+++ b/src/modules/Makefile.mk
@@ -132,4 +132,7 @@ include src/modules/Makefile_policy_mobile.mk
132include src/modules/Makefile_geolocation.mk 132include src/modules/Makefile_geolocation.mk
133 133
134include src/modules/Makefile_wireless.mk 134include src/modules/Makefile_wireless.mk
135
135include src/modules/Makefile_time.mk 136include src/modules/Makefile_time.mk
137
138include src/modules/Makefile_bryce_migration.mk
diff --git a/src/modules/Makefile_bryce_migration.mk b/src/modules/Makefile_bryce_migration.mk
new file mode 100644
index 000000000..0fa2d6c44
--- /dev/null
+++ b/src/modules/Makefile_bryce_migration.mk
@@ -0,0 +1,32 @@
1EXTRA_DIST += src/modules/bryce_migration/module.desktop.in
2if USE_MODULE_BRYCE_MIGRATION
3bryce_migrationdir = $(MDIR)/bryce_migration
4bryce_migration_DATA = src/modules/bryce_migration/module.desktop
5
6bryce_migrationpkgdir = $(MDIR)/bryce_migration/$(MODULE_ARCH)
7bryce_migrationpkg_LTLIBRARIES = src/modules/bryce_migration/module.la
8
9src_modules_bryce_migration_module_la_LIBADD = $(MOD_LIBS)
10src_modules_bryce_migration_module_la_CPPFLAGS = $(MOD_CPPFLAGS)
11src_modules_bryce_migration_module_la_LDFLAGS = $(MOD_LDFLAGS)
12src_modules_bryce_migration_module_la_SOURCES = src/modules/bryce_migration/e_mod_main.c
13
14
15internal_bin_PROGRAMS += enlightenment_bryce_migration
16enlightenment_bryce_migration_SOURCES = \
17src/modules/bryce_migration/config_migration.c \
18src/modules/clock/config_descriptor.c \
19src/modules/time/config_descriptor.c \
20src/modules/ibar/config_descriptor.c \
21src/modules/luncher/config_descriptor.c \
22src/bin/e_config_descriptor.c \
23src/bin/e_config_data.c
24enlightenment_bryce_migration_CPPFLAGS = $(E_CPPFLAGS)
25enlightenment_bryce_migration_LDFLAGS = @E_SYS_LIBS@ @EET_LIBS@
26#@EINA_LIBS@ @ECORE_LIBS@ @EET_LIBS@
27
28PHONIES += bryce_migration install-bryce_migration
29bryce_migration: $(bryce_migrationpkg_LTLIBRARIES) $(bryce_migration_DATA)
30install-bryce_migration: install-bryce_migrationDATA install-bryce_migrationpkgLTLIBRARIES
31
32endif
diff --git a/src/modules/bryce_migration/config_migration.c b/src/modules/bryce_migration/config_migration.c
new file mode 100644
index 000000000..0e2c18020
--- /dev/null
+++ b/src/modules/bryce_migration/config_migration.c
@@ -0,0 +1,618 @@
1#include <Eet.h>
2#include <e.h>
3
4#define BRYCE_MIGRATION 1
5
6#include "../time/config_descriptor.h"
7#include "../clock/config_descriptor.h"
8#include "../ibar/config_descriptor.h"
9#include "../luncher/config_descriptor.h"
10
11typedef struct _E_Gadget_Config
12{
13 int id;
14 int zone;
15 const char *type;
16 struct {
17 const char *name;
18 } style;
19 double x;
20 double y;
21 double w;
22 double h;
23} E_Gadget_Config;
24
25typedef struct _E_Gadget_Site
26{
27 E_Gadget_Site_Gravity gravity;
28 E_Gadget_Site_Orient orient;
29 E_Gadget_Site_Anchor anchor;
30 unsigned char autoadd;
31 const char *name;
32 Eina_List *gadgets;
33} E_Gadget_Site;
34
35typedef struct _E_Gadget_Sites
36{
37 Eina_List *sites;
38} E_Gadget_Sites;
39
40typedef struct _Bryce
41{
42 const char *name;
43 const char *style;
44 unsigned int zone;
45 int size;
46 unsigned int layer;
47 unsigned char autosize;
48 unsigned char autohide;
49 E_Gadget_Site_Orient orient;
50 E_Gadget_Site_Anchor anchor;
51 unsigned int version;
52} Bryce;
53
54typedef struct _Bryces
55{
56 Eina_List *bryces;
57} Bryces;
58
59
60
61E_Config *e_config = NULL;
62static E_Gadget_Sites *_sites = NULL;
63static Bryces *_bryces = NULL;
64
65E_Config_DD *e_remember_edd;
66static Eet_Data_Descriptor *_edd_bryces;
67static Eet_Data_Descriptor *_edd_bryce;
68static Eet_Data_Descriptor *_edd_sites;
69static Eet_Data_Descriptor *_edd_gadget_site;
70static Eet_Data_Descriptor *_edd_gadget_config;
71
72static void
73_init(const char *path)
74{
75 Eet_File *f;
76 char buf[PATH_MAX];
77
78 eet_init();
79
80 e_config_descriptor_init(EINA_FALSE);
81 clock_config_descriptor_init();
82 time_config_descriptor_init();
83 ibar_config_descriptor_init();
84 luncher_config_descriptor_init();
85
86 snprintf(buf, sizeof(buf), "%s/e.cfg", path);
87 f = eet_open(buf, EET_FILE_MODE_READ);
88 if (!f)
89 {
90 printf("Can't open config file\n");
91 }
92
93 e_config = eet_data_read(f, e_config_descriptor_get(), "config");
94 if (!e_config)
95 {
96 fprintf(stderr, "Error on loading config file\n");
97 eet_close(f);
98 return;
99 }
100 eet_close(f);
101
102
103}
104
105static void
106_bryce_init(const char *path)
107{
108 Eet_Data_Descriptor_Class eddc_gadget_config, eddc_gadget_site, eddc_sites, eddc_bryce, eddc_bryces;
109 char buf[PATH_MAX];
110 Eet_File *f;
111
112 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc_gadget_config, E_Gadget_Config);
113 _edd_gadget_config = eet_data_descriptor_stream_new(&eddc_gadget_config);
114 EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_gadget_config, E_Gadget_Config, "id", id, EET_T_INT);
115 EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_gadget_config, E_Gadget_Config, "zone", zone, EET_T_INT);
116 EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_gadget_config, E_Gadget_Config, "type", type, EET_T_STRING);
117 EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_gadget_config, E_Gadget_Config, "style.name", style.name, EET_T_STRING);
118 EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_gadget_config, E_Gadget_Config, "x", x, EET_T_DOUBLE);
119 EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_gadget_config, E_Gadget_Config, "y", y, EET_T_DOUBLE);
120 EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_gadget_config, E_Gadget_Config, "w", w, EET_T_DOUBLE);
121 EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_gadget_config, E_Gadget_Config, "h", h, EET_T_DOUBLE);
122
123 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc_gadget_site, E_Gadget_Site);
124 _edd_gadget_site = eet_data_descriptor_stream_new(&eddc_gadget_site);
125 EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_gadget_site, E_Gadget_Site, "gravity", gravity, EET_T_UINT);
126 EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_gadget_site, E_Gadget_Site, "orient", orient, EET_T_UINT);
127 EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_gadget_site, E_Gadget_Site, "anchor", anchor, EET_T_UINT);
128 EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_gadget_site, E_Gadget_Site, "autoadd", autoadd, EET_T_UCHAR);
129 EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_gadget_site, E_Gadget_Site, "name", name, EET_T_STRING);
130 EET_DATA_DESCRIPTOR_ADD_LIST(_edd_gadget_site, E_Gadget_Site, "gadgets", gadgets, _edd_gadget_config);
131
132 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc_sites, E_Gadget_Sites);
133 _edd_sites = eet_data_descriptor_stream_new(&eddc_sites);
134 EET_DATA_DESCRIPTOR_ADD_LIST(_edd_sites, E_Gadget_Sites, "sites", sites, _edd_gadget_site);
135
136 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc_bryce, Bryce);
137 _edd_bryce = eet_data_descriptor_stream_new(&eddc_bryce);
138 EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_bryce, Bryce, "name", name, EET_T_STRING);
139 EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_bryce, Bryce, "style", style, EET_T_STRING);
140 EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_bryce, Bryce, "zone", zone, EET_T_UINT);
141 EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_bryce, Bryce, "size", size, EET_T_INT);
142 EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_bryce, Bryce, "layer", layer, EET_T_UINT);
143 EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_bryce, Bryce, "autosize", autosize, EET_T_UCHAR);
144 EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_bryce, Bryce, "autohide", autohide, EET_T_UCHAR);
145 EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_bryce, Bryce, "orient", orient, EET_T_UINT);
146 EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_bryce, Bryce, "anchor", anchor, EET_T_UINT);
147 EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_bryce, Bryce, "version", version, EET_T_UINT);
148
149 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc_bryces, Bryces);
150 _edd_bryces = eet_data_descriptor_stream_new(&eddc_bryces);
151 EET_DATA_DESCRIPTOR_ADD_LIST(_edd_bryces, Bryces, "bryces", bryces, _edd_bryce);
152
153
154 snprintf(buf, sizeof(buf), "%s/e_gadgets_sites.cfg", path);
155 f = eet_open(buf, EET_FILE_MODE_READ);
156 if (!f)
157 {
158 printf("Can't open config file\n");
159 }
160
161 _sites = eet_data_read(f, _edd_sites, "config");
162 if (!_sites)
163 {
164 fprintf(stderr, "Error on loading config file\n");
165 eet_close(f);
166 return;
167 }
168 eet_close(f);
169
170 printf("gadget site loaded %d\n", eina_list_count(_sites->sites));
171 snprintf(buf, sizeof(buf), "%s/e_bryces.cfg", path);
172 f = eet_open(buf, EET_FILE_MODE_READ);
173 if (!f)
174 {
175 printf("Can't open config file\n");
176 }
177
178 _bryces = eet_data_read(f, _edd_bryces, "config");
179 if (!_bryces)
180 {
181 fprintf(stderr, "Error on loading config bryce file\n");
182 eet_close(f);
183 return;
184 }
185 eet_close(f);
186}
187
188static void
189_bryce_shutdown(const char *path)
190{
191 Eet_File *f;
192 char buf[PATH_MAX];
193
194 snprintf(buf, sizeof(buf), "%s/e_gadgets_sites.cfg", path);
195 f = eet_open(buf, EET_FILE_MODE_READ_WRITE);
196 if (!f)
197 {
198 printf("Can't open config file\n");
199 }
200
201 eet_data_write(f, _edd_sites, "config", _sites, 1);
202 eet_close(f);
203
204 snprintf(buf, sizeof(buf), "%s/e_bryces.cfg", path);
205 f = eet_open(buf, EET_FILE_MODE_READ_WRITE);
206 if (!f)
207 {
208 printf("Can't open config file\n");
209 }
210
211 eet_data_write(f, _edd_bryces, "config", _bryces, 1);
212 eet_close(f);
213}
214
215typedef int (*Migrate_Cb)(const char *path, const char *id);
216
217typedef struct _Bryce_Migration_Module_Compat{
218 const char *shelf;
219 const char *bryce;
220 Migrate_Cb migrate;
221} Bryce_Migration_Module_Compat;
222
223
224static int
225_start_migrate(const char *path, const char *id)
226{
227 return 0;
228}
229
230static int
231_pager_migrate(const char *path, const char *id)
232{
233 return 0;
234}
235
236static int
237_ibar_migrate(const char *path, const char *id)
238{
239 Eet_File *f;
240 Ibar_Config *ibar;
241 Eina_List *l;
242 Ibar_Config_Item *it;
243 Luncher_Config *luncher_config;
244 Luncher_Config_Item *luncher_it;
245 char buf[PATH_MAX];
246
247 snprintf(buf, sizeof(buf), "%s/module.ibar.cfg", path);
248 printf("%s open %s\n", path, buf);
249 f = eet_open(buf, EET_FILE_MODE_READ);
250 ibar = eet_data_read(f, ibar_config_descriptor_get(), "config");
251 eet_close(f);
252
253 EINA_LIST_FOREACH(ibar->items, l, it)
254 {
255 if (it->id == id) break;
256 }
257
258 if (l)
259 {
260 printf("Found Ibar config!\n");
261 printf("Ibar dir %s\n", it->dir);
262 snprintf(buf, sizeof(buf), "%s/module.luncher.cfg", path);
263 f = eet_open(buf, EET_FILE_MODE_READ);
264 luncher_config = eet_data_read(f, luncher_config_descriptor_get(), "config");
265 eet_close(f);
266 luncher_it = calloc(1, sizeof(Luncher_Config_Item));
267 luncher_it->id = eina_list_count(luncher_config->items) + 1;
268 luncher_it->dir = eina_stringshare_ref(it->dir);
269 luncher_it->style = eina_stringshare_add("default");
270 luncher_config->items = eina_list_append(luncher_config->items, luncher_it);
271 f = eet_open(buf, EET_FILE_MODE_READ_WRITE);
272 eet_data_write(f, luncher_config_descriptor_get(), "config",
273 luncher_config, 1);
274 eet_close(f);
275 return luncher_it->id;
276 }
277
278 return -1;
279}
280
281static int
282_clock_migrate(const char *path, const char *id)
283{
284 Eet_File *f, *ff;
285 Clock_Config *clock;
286 Time_Config *time_config;
287 Eina_List *l;
288 Clock_Config_Item *it;
289 Time_Config_Item *time_it;
290 char buf[PATH_MAX];
291
292 snprintf(buf, sizeof(buf), "%s/module.clock.cfg", path);
293 f = eet_open(buf, EET_FILE_MODE_READ);
294 clock = eet_data_read(f, clock_config_descriptor_get(), "config");
295 eet_close(f);
296
297 EINA_LIST_FOREACH(clock->items, l, it)
298 {
299 if (it->id == id) break;
300 }
301 if (l)
302 {
303 snprintf(buf, sizeof(buf), "%s/module.time.cfg", path);
304 ff = eet_open(buf, EET_FILE_MODE_READ);
305 time_config = eet_data_read(ff, time_config_descriptor_get(), "config");
306 eet_close(ff);
307 time_it = calloc(1, sizeof(Time_Config_Item));
308 time_it->id = eina_list_count(time_config->items) + 1;
309 time_it->weekend.start = it->weekend.start;
310 time_it->weekend.len = it->weekend.len;
311 time_it->week.start = it->week.start;
312 time_it->digital_clock = it->digital_clock ? 1 : 0;
313 time_it->digital_24h = it->digital_24h ? 1 : 0;
314 time_it->show_seconds = it->show_seconds ? 1 : 0;
315 time_it->show_date = it->show_date ? 1 : 0;
316 time_it->time_str[0] = eina_stringshare_add("%I:%M");
317 time_it->time_str[1] = eina_stringshare_add("%F");
318
319 time_config->items = eina_list_append(time_config->items, time_it);
320
321 ff = eet_open(buf, EET_FILE_MODE_READ_WRITE);
322 eet_data_write(ff, time_config_descriptor_get(), "config",
323 time_config, 1);
324 eet_close(ff);
325
326 return time_it->id;
327
328 }
329 return -1;
330}
331
332static Bryce_Migration_Module_Compat _compat[] =
333{
334 {"start", "Start", _start_migrate},
335 {"pager", "Pager Gadget", _pager_migrate},
336 {"ibar", "Luncher Bar", _ibar_migrate},
337 {"clock", "Digital Clock", _clock_migrate}
338};
339
340
341
342static void
343_migrate_shelf(const char *path, E_Config_Shelf *shelf, const char *bryce, E_Gadget_Site_Anchor anchor, E_Gadget_Site_Gravity gravity, E_Gadget_Site_Orient orient)
344{
345 Eina_List *l, *ll;
346 E_Config_Gadcon *gc;
347 E_Config_Gadcon_Client *client;
348 int i;
349 int id;
350 E_Gadget_Site *site;
351 E_Gadget_Config *gcfg;
352 char buf[PATH_MAX];
353 Bryce *b;
354
355 site = calloc(1, sizeof(E_Gadget_Site));
356
357 printf("Starting migration %s %s\n", path, shelf->name);
358
359 EINA_LIST_FOREACH(e_config->gadcons, l, gc)
360 {
361 printf("gadcon %s\n", gc->name);
362 if (!strcmp(gc->name, shelf->name))
363 {
364 EINA_LIST_FOREACH(gc->clients, ll, client)
365 {
366 id = -1;
367 for (i = 0; i < (sizeof(_compat) / sizeof(_compat[0])); ++i)
368 {
369 if (!strcmp(_compat[i].shelf, client->name))
370 {
371 id = _compat[i].migrate(path, client->id);
372 break;
373 }
374 }
375 if (id < 0)
376 {
377 printf("Fail to migrate %s\n", client->name);
378 continue;
379 }
380 gcfg = calloc(1, sizeof(E_Gadget_Config));
381 gcfg->id = id;
382 gcfg->type = eina_stringshare_add(_compat[i].bryce);
383 site->gadgets = eina_list_append(site->gadgets, gcfg);
384 }
385 e_config->gadcons = eina_list_remove_list(e_config->gadcons, l);
386 break;
387 }
388 }
389 if (l)
390 {
391 snprintf(buf, sizeof(buf), "__bryce%s", bryce);
392 site->name = eina_stringshare_add(buf);
393 site->gravity = gravity;
394 site->orient = orient;
395 site->anchor = anchor;
396
397 printf("Append %d %d\n", eina_list_count(_sites->sites), eina_list_count(site->gadgets));
398 _sites->sites = eina_list_append(_sites->sites, site);
399 printf("Append %d %d\n", eina_list_count(_sites->sites), eina_list_count(site->gadgets));
400
401 b = calloc(1, sizeof(Bryce));
402 b->name = eina_stringshare_add(bryce);
403 b->style = eina_stringshare_add("default");
404 b->zone = shelf->zone; /* TODO */
405 b->size = 48;
406 b->layer = shelf->layer;
407 b->autosize = !!shelf->fit_along;
408 b->autohide = !!shelf->autohide;
409 b->orient = orient;
410 b->anchor = anchor;
411 b->version = 2;
412 _bryces->bryces = eina_list_append(_bryces->bryces, b);
413 }
414}
415
416static void
417_migrate(const char *path)
418{
419 E_Config_Shelf *shelf;
420 E_Gadget_Site_Orient orient;
421 E_Gadget_Site_Anchor anchor;
422 E_Gadget_Site_Gravity gravity;
423 const char *loc, *loc2;
424 char buf[PATH_MAX];
425 Eet_File *f;
426
427
428
429 EINA_LIST_FREE(e_config->shelves, shelf)
430 {
431 switch(shelf->orient)
432 {
433// case E_GADCON_ORIENT_FLOAT: ???? UNUSED ????
434 case E_GADCON_ORIENT_HORIZ:
435 orient = E_GADGET_SITE_ORIENT_HORIZONTAL;
436 anchor = E_GADGET_SITE_ANCHOR_TOP;
437 break;
438 case E_GADCON_ORIENT_TOP:
439 orient = E_GADGET_SITE_ORIENT_HORIZONTAL;
440 anchor = E_GADGET_SITE_ANCHOR_TOP;
441 break;
442 case E_GADCON_ORIENT_BOTTOM:
443 orient = E_GADGET_SITE_ORIENT_HORIZONTAL;
444 anchor = E_GADGET_SITE_ANCHOR_BOTTOM;
445 break;
446 case E_GADCON_ORIENT_CORNER_TL:
447 orient = E_GADGET_SITE_ORIENT_HORIZONTAL;
448 anchor = E_GADGET_SITE_ANCHOR_TOP | E_GADGET_SITE_ANCHOR_LEFT;
449 break;
450 case E_GADCON_ORIENT_CORNER_TR:
451 orient = E_GADGET_SITE_ORIENT_HORIZONTAL;
452 anchor = E_GADGET_SITE_ANCHOR_TOP | E_GADGET_SITE_ANCHOR_RIGHT;
453 break;
454 case E_GADCON_ORIENT_CORNER_BL:
455 orient = E_GADGET_SITE_ORIENT_HORIZONTAL;
456 anchor = E_GADGET_SITE_ANCHOR_BOTTOM | E_GADGET_SITE_ANCHOR_LEFT;
457 break;
458 case E_GADCON_ORIENT_CORNER_BR:
459 orient = E_GADGET_SITE_ORIENT_HORIZONTAL;
460 anchor = E_GADGET_SITE_ANCHOR_BOTTOM | E_GADGET_SITE_ANCHOR_RIGHT;
461 break;
462 case E_GADCON_ORIENT_VERT:
463 orient = E_GADGET_SITE_ORIENT_VERTICAL;
464 anchor = E_GADGET_SITE_ANCHOR_LEFT;
465 break;
466 case E_GADCON_ORIENT_LEFT:
467 orient = E_GADGET_SITE_ORIENT_VERTICAL;
468 anchor = E_GADGET_SITE_ANCHOR_LEFT;
469 break;
470 case E_GADCON_ORIENT_RIGHT:
471 orient = E_GADGET_SITE_ORIENT_VERTICAL;
472 anchor = E_GADGET_SITE_ANCHOR_RIGHT;
473 break;
474 case E_GADCON_ORIENT_CORNER_LT:
475 orient = E_GADGET_SITE_ORIENT_VERTICAL;
476 anchor = E_GADGET_SITE_ANCHOR_LEFT | E_GADGET_SITE_ANCHOR_TOP;
477 break;
478 case E_GADCON_ORIENT_CORNER_RT:
479 orient = E_GADGET_SITE_ORIENT_VERTICAL;
480 anchor = E_GADGET_SITE_ANCHOR_RIGHT | E_GADGET_SITE_ANCHOR_TOP;
481 break;
482 case E_GADCON_ORIENT_CORNER_LB:
483 orient = E_GADGET_SITE_ORIENT_VERTICAL;
484 anchor = E_GADGET_SITE_ANCHOR_LEFT | E_GADGET_SITE_ANCHOR_BOTTOM;
485 break;
486 case E_GADCON_ORIENT_CORNER_RB:
487 orient = E_GADGET_SITE_ORIENT_VERTICAL;
488 anchor = E_GADGET_SITE_ANCHOR_RIGHT | E_GADGET_SITE_ANCHOR_BOTTOM;
489 break;
490 }
491 if (orient == E_GADGET_SITE_ORIENT_HORIZONTAL)
492 {
493 if (anchor & E_GADGET_SITE_ANCHOR_LEFT)
494 gravity = E_GADGET_SITE_GRAVITY_LEFT;
495 else if (anchor & E_GADGET_SITE_ANCHOR_RIGHT)
496 gravity = E_GADGET_SITE_GRAVITY_RIGHT;
497 else
498 gravity = E_GADGET_SITE_GRAVITY_CENTER;
499 }
500 else
501 {
502 if (anchor & E_GADGET_SITE_ANCHOR_TOP)
503 gravity = E_GADGET_SITE_GRAVITY_TOP;
504 else if (anchor & E_GADGET_SITE_ANCHOR_BOTTOM)
505 gravity = E_GADGET_SITE_GRAVITY_BOTTOM;
506 else
507 gravity = E_GADGET_SITE_GRAVITY_CENTER;
508 }
509
510 if (anchor & E_GADGET_SITE_ANCHOR_TOP)
511 loc = "top";
512 else if (anchor & E_GADGET_SITE_ANCHOR_BOTTOM)
513 loc = "bottom";
514 else if (anchor & E_GADGET_SITE_ANCHOR_LEFT)
515 loc = "left";
516 else if (anchor & E_GADGET_SITE_ANCHOR_RIGHT)
517 loc = "right";
518 if (anchor & E_GADGET_SITE_ANCHOR_RIGHT)
519 loc2 = "right";
520 else if (anchor & E_GADGET_SITE_ANCHOR_LEFT)
521 loc2 = "left";
522 else if (anchor & E_GADGET_SITE_ANCHOR_TOP)
523 loc2 = "top";
524 else if (anchor & E_GADGET_SITE_ANCHOR_BOTTOM)
525 loc2 = "bottom";
526
527 snprintf(buf, sizeof(buf), "bryce_%s_%s_%d", loc, loc2, shelf->zone);
528
529 _migrate_shelf(path, shelf, buf, anchor, gravity, orient);
530 }
531 snprintf(buf, sizeof(buf), "%s/e.cfg", path);
532 f = eet_open(buf, EET_FILE_MODE_READ_WRITE);
533 if (!f)
534 {
535 printf("Can't open config file\n");
536 }
537
538 eet_data_write(f, e_config_descriptor_get(), "config",
539 e_config, 1);
540 eet_close(f);
541}
542
543static void
544_shutdown(void)
545{
546 clock_config_descriptor_shutdown();
547 time_config_descriptor_shutdown();
548 ibar_config_descriptor_shutdown();
549 luncher_config_descriptor_shutdown();
550 e_config_descriptor_shutdown();
551 eet_shutdown();
552}
553
554static const Ecore_Getopt options =
555{
556 "Bryce migration",
557 "%prog [options]",
558 "0.1",
559 "(C) 2011 Enlightenment, see AUTHORS.",
560 "GPL, see COPYING",
561 "Bryce migration tool",
562 EINA_TRUE,
563 {
564 ECORE_GETOPT_STORE_STR('p', "path", "path of e config"),
565 ECORE_GETOPT_STORE_STR('s', "shelf", "shelf name"),
566 ECORE_GETOPT_STORE_STR('b', "bryce", "bryce name"),
567 ECORE_GETOPT_STORE_UINT('a', "anchor", "anchor position"),
568 ECORE_GETOPT_STORE_UINT('g', "gravity", "gadget gravity"),
569 ECORE_GETOPT_STORE_UINT('o', "orient", "gadget orientation"),
570 ECORE_GETOPT_HELP('h', "help"),
571 ECORE_GETOPT_SENTINEL
572 }
573};
574
575int
576main(int argc, char **argv)
577{
578 int args;
579 char *path;
580 char *shelf;
581 char *bryce;
582 Eina_Bool quit_option;
583 E_Gadget_Site_Gravity gravity;
584 E_Gadget_Site_Orient orient;
585 E_Gadget_Site_Anchor anchor;
586
587 Ecore_Getopt_Value values[] =
588 {
589 ECORE_GETOPT_VALUE_STR(path),
590 ECORE_GETOPT_VALUE_STR(shelf),
591 ECORE_GETOPT_VALUE_STR(bryce),
592 ECORE_GETOPT_VALUE_UINT(anchor),
593 ECORE_GETOPT_VALUE_UINT(gravity),
594 ECORE_GETOPT_VALUE_UINT(orient),
595 ECORE_GETOPT_VALUE_BOOL(quit_option)
596 };
597
598 args = ecore_getopt_parse(&options, values, argc, argv);
599 if (args < 0)
600 return EXIT_FAILURE;
601 if (quit_option)
602 return EXIT_SUCCESS;
603
604
605 printf("Welcome to migration tool\n");
606 _init(path);
607 _bryce_init(path);
608
609 _migrate(path);
610
611 _bryce_shutdown(path);
612 _shutdown();
613
614 return 0;
615}
616
617
618
diff --git a/src/modules/bryce_migration/e_mod_main.c b/src/modules/bryce_migration/e_mod_main.c
new file mode 100644
index 000000000..deeae97a5
--- /dev/null
+++ b/src/modules/bryce_migration/e_mod_main.c
@@ -0,0 +1,181 @@
1#include <e.h>
2
3static Eina_Bool _ask_user_migration(void *data);
4static Eina_Bool _ask_user_valid(void *data);
5static void _migrate_user_cb(void *data, E_Dialog *dia);
6static void _migrate_user_ok_cb(void *data, E_Dialog *dia);
7static void _migrate_user_cancel_cb(void *data, E_Dialog *dia);
8
9typedef enum _Bryce_Migration_Step
10{
11 BRYCE_MIGRATION_ASK = 0,
12 BRYCE_MIGRATION_RUN,
13 BRYCE_MIGRATION_DONE
14} Bryce_Migration_Step;
15
16typedef struct _Config
17{
18 Bryce_Migration_Step step;
19} Config;
20
21static Config *_bryce_migration_config = NULL;
22static E_Config_DD *_conf_edd = NULL;
23
24
25E_API E_Module_Api e_modapi =
26{
27 E_MODULE_API_VERSION,
28 "Bryce migration"
29};
30
31E_API void *
32e_modapi_init(E_Module *m)
33{
34 _conf_edd = E_CONFIG_DD_NEW("Config", Config);
35#undef T
36#undef D
37#define T Config
38#define D _conf_edd
39 E_CONFIG_VAL(D, T, step, UINT);
40 _bryce_migration_config = e_config_domain_load("module.bryce_migration", _conf_edd);
41 if (!_bryce_migration_config)
42 _bryce_migration_config = E_NEW(Config, 1);
43
44
45
46 switch(_bryce_migration_config->step)
47 {
48 case BRYCE_MIGRATION_ASK:
49 ecore_timer_add(1.0, _ask_user_migration, NULL);
50 break;
51 case BRYCE_MIGRATION_RUN:
52 ecore_timer_add(1.0, _ask_user_valid, NULL);
53 break;
54 case BRYCE_MIGRATION_DONE:
55 fprintf(stderr, "migration done\n");
56 break;
57 }
58
59
60 return m;
61}
62
63E_API int
64e_modapi_shutdown(E_Module *m EINA_UNUSED)
65{
66 E_FREE(_bryce_migration_config);
67 return 1;
68}
69
70E_API int
71e_modapi_save(E_Module *m EINA_UNUSED)
72{
73 e_config_domain_save("module.bryce_migration", _conf_edd, _bryce_migration_config);
74 return 1;
75}
76
77static Eina_Bool
78_ask_user_migration(void *data)
79{
80 E_Dialog *dia;
81
82 dia = e_dialog_new(NULL, "E", "_module_bryce_migration");
83
84 e_dialog_title_set(dia, "Bryce Migration");
85 e_dialog_icon_set(dia, "enlightenment", 64);
86 e_dialog_text_set(dia, "Hi, shelf are deprecatede</br>We Will try to update your config to the new gadget container (bryce). Hope this run works well for you !");
87 e_dialog_button_add(dia, _("Migrate"), NULL, _migrate_user_cb, NULL);
88 e_dialog_button_add(dia, _("Later"), NULL, NULL, NULL);
89 elm_win_center(dia->win, 1, 1);
90 e_win_no_remember_set(dia->win, 1);
91 e_dialog_show(dia);
92
93 return ECORE_CALLBACK_CANCEL;
94}
95
96static Eina_Bool
97_ask_user_valid(void *data)
98{
99 E_Dialog *dia;
100
101 dia = e_dialog_new(NULL, "E", "_module_bryce_migration");
102
103 e_dialog_title_set(dia, "Bryce Migration");
104 e_dialog_icon_set(dia, "enlightenment", 64);
105 e_dialog_text_set(dia, _("Would you keep this setup ?"));
106 e_dialog_button_add(dia, _("Keep this config"), NULL, _migrate_user_ok_cb, NULL);
107 e_dialog_button_add(dia, _("Reset to my old Config"), NULL, _migrate_user_cancel_cb, NULL);
108 elm_win_center(dia->win, 1, 1);
109 e_win_no_remember_set(dia->win, 1);
110 e_dialog_show(dia);
111
112 return ECORE_CALLBACK_CANCEL;
113}
114
115
116
117static void
118_migrate_user_cb(void *data, E_Dialog *dia)
119{
120 char buf[4096];
121 char buf2[4096];
122 char cmd[PATH_MAX];
123
124 e_object_del(E_OBJECT(dia));
125 e_user_dir_snprintf(buf, sizeof(buf), "config/%s", e_config_profile_get());
126 e_user_dir_snprintf(buf2, sizeof(buf2), "config/bryce_backup");
127 snprintf(cmd, sizeof(cmd), "rm -rf %s", buf2);
128 fprintf(stderr, "exec -> %s\n", cmd);
129 system(cmd);
130 snprintf(cmd, sizeof(cmd), "/usr/bin/cp -a %s %s", buf, buf2);
131 fprintf(stderr, "exec -> %s\n", cmd);
132 system(cmd);
133 fprintf(stderr, "Backup current profile %s\n", cmd);
134 _bryce_migration_config->step = BRYCE_MIGRATION_RUN;
135 e_config_save();
136 e_config_save_flush();
137 e_config_save_block_set(EINA_TRUE);
138
139 snprintf(cmd, sizeof(cmd),
140 "/usr/lib/enlightenment/utils/enlightenment_bryce_migration "
141 "--path %s ", buf);
142 system(cmd);
143 kill(getpid(), SIGKILL);
144}
145
146static void
147_migrate_user_ok_cb(void *data, E_Dialog *dia)
148{
149 E_Module *m;
150 e_object_del(E_OBJECT(dia));
151 _bryce_migration_config->step = BRYCE_MIGRATION_DONE;
152 m = e_module_find("bryce_migration");
153 e_module_disable(m);
154 e_config_save_queue();
155}
156
157static void
158_migrate_user_cancel_cb(void *data, E_Dialog *dia)
159{
160 char buf[4096];
161 char buf2[4096];
162 char cmd[PATH_MAX];
163
164 _bryce_migration_config->step = BRYCE_MIGRATION_ASK;
165 e_config_save();
166 e_config_save_flush();
167 e_object_del(E_OBJECT(dia));
168 e_config_save_block_set(EINA_TRUE);
169 fprintf(stderr, "Reset config\n");
170 e_user_dir_snprintf(buf, sizeof(buf), "config/%s", e_config_profile_get());
171 e_user_dir_snprintf(buf2, sizeof(buf2), "config/bryce_backup");
172 fprintf(stderr, "exec -> %s\n", cmd);
173 snprintf(cmd, sizeof(cmd), "rm -rf %s", buf);
174 system(cmd);
175 snprintf(cmd, sizeof(cmd), "/usr/bin/cp -a %s %s", buf2, buf);
176 system(cmd);
177 snprintf(cmd, sizeof(cmd), "rm -rf %s", buf2);
178 system(cmd);
179 kill(getpid(), SIGKILL);
180}
181
diff --git a/src/modules/bryce_migration/module.desktop.in b/src/modules/bryce_migration/module.desktop.in
new file mode 100644
index 000000000..8103d8837
--- /dev/null
+++ b/src/modules/bryce_migration/module.desktop.in
@@ -0,0 +1,7 @@
1[Desktop Entry]
2Encoding=UTF-8
3Type=Link
4Name=Bryce migration
5Comment=Bryce migration wizard
6Icon=e-module-bryce-wizard
7X-Enlightenment-ModuleType=utils