aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/bryce_migration/config_migration.c
blob: 0e2c18020f6396a45cc3236b162a8874c3c52db7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
#include <Eet.h>
#include <e.h>

#define BRYCE_MIGRATION 1

#include "../time/config_descriptor.h"
#include "../clock/config_descriptor.h"
#include "../ibar/config_descriptor.h"
#include "../luncher/config_descriptor.h"

typedef struct _E_Gadget_Config
{
   int id;
   int zone;
   const char *type;
   struct {
        const char *name;
   } style;
   double x;
   double y;
   double w;
   double h;
} E_Gadget_Config;

typedef struct _E_Gadget_Site
{
   E_Gadget_Site_Gravity gravity;
   E_Gadget_Site_Orient orient;
   E_Gadget_Site_Anchor anchor;
   unsigned char autoadd;
   const char *name;
   Eina_List *gadgets;
} E_Gadget_Site;

typedef struct _E_Gadget_Sites
{
   Eina_List *sites;
} E_Gadget_Sites;

typedef struct _Bryce
{
   const char *name;
   const char *style;
   unsigned int zone;
   int size;
   unsigned int layer;
   unsigned char autosize;
   unsigned char autohide;
   E_Gadget_Site_Orient orient;
   E_Gadget_Site_Anchor anchor;
   unsigned int version;
} Bryce;

typedef struct _Bryces
{
   Eina_List *bryces;
} Bryces;



E_Config *e_config = NULL;
static E_Gadget_Sites *_sites = NULL;
static Bryces *_bryces = NULL;

E_Config_DD *e_remember_edd;
static Eet_Data_Descriptor *_edd_bryces;
static Eet_Data_Descriptor *_edd_bryce;
static Eet_Data_Descriptor *_edd_sites;
static Eet_Data_Descriptor *_edd_gadget_site;
static Eet_Data_Descriptor *_edd_gadget_config;

static void
_init(const char *path)
{
   Eet_File *f;
   char buf[PATH_MAX];

   eet_init();

   e_config_descriptor_init(EINA_FALSE);
   clock_config_descriptor_init();
   time_config_descriptor_init();
   ibar_config_descriptor_init();
   luncher_config_descriptor_init();

   snprintf(buf, sizeof(buf), "%s/e.cfg", path);
   f = eet_open(buf, EET_FILE_MODE_READ);
   if (!f)
     {
        printf("Can't open config file\n");
     }

   e_config = eet_data_read(f, e_config_descriptor_get(), "config");
   if (!e_config)
     {
        fprintf(stderr, "Error on loading config file\n");
        eet_close(f);
        return;
     }
   eet_close(f);


}

static void
_bryce_init(const char *path)
{
   Eet_Data_Descriptor_Class eddc_gadget_config, eddc_gadget_site, eddc_sites, eddc_bryce, eddc_bryces;
   char buf[PATH_MAX];
   Eet_File *f;

   EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc_gadget_config, E_Gadget_Config);
   _edd_gadget_config = eet_data_descriptor_stream_new(&eddc_gadget_config);
   EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_gadget_config, E_Gadget_Config, "id", id, EET_T_INT);
   EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_gadget_config, E_Gadget_Config, "zone", zone, EET_T_INT);
   EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_gadget_config, E_Gadget_Config, "type", type, EET_T_STRING);
   EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_gadget_config, E_Gadget_Config, "style.name", style.name, EET_T_STRING);
   EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_gadget_config, E_Gadget_Config, "x", x, EET_T_DOUBLE);
   EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_gadget_config, E_Gadget_Config, "y", y, EET_T_DOUBLE);
   EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_gadget_config, E_Gadget_Config, "w", w, EET_T_DOUBLE);
   EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_gadget_config, E_Gadget_Config, "h", h, EET_T_DOUBLE);

   EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc_gadget_site, E_Gadget_Site);
   _edd_gadget_site = eet_data_descriptor_stream_new(&eddc_gadget_site);
   EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_gadget_site, E_Gadget_Site, "gravity", gravity, EET_T_UINT);
   EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_gadget_site, E_Gadget_Site, "orient", orient, EET_T_UINT);
   EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_gadget_site, E_Gadget_Site, "anchor", anchor, EET_T_UINT);
   EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_gadget_site, E_Gadget_Site, "autoadd", autoadd, EET_T_UCHAR);
   EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_gadget_site, E_Gadget_Site, "name", name, EET_T_STRING);
   EET_DATA_DESCRIPTOR_ADD_LIST(_edd_gadget_site, E_Gadget_Site, "gadgets", gadgets, _edd_gadget_config);

   EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc_sites, E_Gadget_Sites);
   _edd_sites = eet_data_descriptor_stream_new(&eddc_sites);
   EET_DATA_DESCRIPTOR_ADD_LIST(_edd_sites, E_Gadget_Sites, "sites", sites, _edd_gadget_site);

   EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc_bryce, Bryce);
   _edd_bryce = eet_data_descriptor_stream_new(&eddc_bryce);
   EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_bryce, Bryce, "name", name, EET_T_STRING);
   EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_bryce, Bryce, "style", style, EET_T_STRING);
   EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_bryce, Bryce, "zone", zone, EET_T_UINT);
   EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_bryce, Bryce, "size", size, EET_T_INT);
   EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_bryce, Bryce, "layer", layer, EET_T_UINT);
   EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_bryce, Bryce, "autosize", autosize, EET_T_UCHAR);
   EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_bryce, Bryce, "autohide", autohide, EET_T_UCHAR);
   EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_bryce, Bryce, "orient", orient, EET_T_UINT);
   EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_bryce, Bryce, "anchor", anchor, EET_T_UINT);
   EET_DATA_DESCRIPTOR_ADD_BASIC(_edd_bryce, Bryce, "version", version, EET_T_UINT);

   EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc_bryces, Bryces);
   _edd_bryces = eet_data_descriptor_stream_new(&eddc_bryces);
   EET_DATA_DESCRIPTOR_ADD_LIST(_edd_bryces, Bryces, "bryces", bryces, _edd_bryce);


   snprintf(buf, sizeof(buf), "%s/e_gadgets_sites.cfg", path);
   f = eet_open(buf, EET_FILE_MODE_READ);
   if (!f)
     {
        printf("Can't open config file\n");
     }

   _sites = eet_data_read(f, _edd_sites, "config");
   if (!_sites)
     {
        fprintf(stderr, "Error on loading config file\n");
        eet_close(f);
        return;
     }
   eet_close(f);

   printf("gadget site loaded %d\n", eina_list_count(_sites->sites));
   snprintf(buf, sizeof(buf), "%s/e_bryces.cfg", path);
   f = eet_open(buf, EET_FILE_MODE_READ);
   if (!f)
     {
        printf("Can't open config file\n");
     }

   _bryces = eet_data_read(f, _edd_bryces, "config");
   if (!_bryces)
     {
        fprintf(stderr, "Error on loading config bryce file\n");
        eet_close(f);
        return;
     }
   eet_close(f);
}

static void
_bryce_shutdown(const char *path)
{
   Eet_File *f;
   char buf[PATH_MAX];

   snprintf(buf, sizeof(buf), "%s/e_gadgets_sites.cfg", path);
   f = eet_open(buf, EET_FILE_MODE_READ_WRITE);
   if (!f)
     {
        printf("Can't open config file\n");
     }

   eet_data_write(f, _edd_sites, "config", _sites, 1);
   eet_close(f);

   snprintf(buf, sizeof(buf), "%s/e_bryces.cfg", path);
   f = eet_open(buf, EET_FILE_MODE_READ_WRITE);
   if (!f)
     {
        printf("Can't open config file\n");
     }

   eet_data_write(f, _edd_bryces, "config", _bryces, 1);
   eet_close(f);
}

typedef int (*Migrate_Cb)(const char *path, const char *id);

typedef struct _Bryce_Migration_Module_Compat{
     const char *shelf;
     const char *bryce;
     Migrate_Cb migrate;
} Bryce_Migration_Module_Compat;


static int
_start_migrate(const char *path, const char *id)
{
   return 0;
}

static int
_pager_migrate(const char *path, const char *id)
{
   return 0;
}

static int
_ibar_migrate(const char *path, const char *id)
{
   Eet_File *f;
   Ibar_Config *ibar;
   Eina_List *l;
   Ibar_Config_Item *it;
   Luncher_Config *luncher_config;
   Luncher_Config_Item *luncher_it;
   char buf[PATH_MAX];

   snprintf(buf, sizeof(buf), "%s/module.ibar.cfg", path);
   printf("%s open %s\n", path, buf);
   f = eet_open(buf, EET_FILE_MODE_READ);
   ibar = eet_data_read(f, ibar_config_descriptor_get(), "config");
   eet_close(f);

   EINA_LIST_FOREACH(ibar->items, l, it)
     {
        if (it->id == id) break;
     }

   if (l)
     {
        printf("Found Ibar config!\n");
        printf("Ibar dir %s\n", it->dir);
        snprintf(buf, sizeof(buf), "%s/module.luncher.cfg", path);
        f = eet_open(buf, EET_FILE_MODE_READ);
        luncher_config = eet_data_read(f, luncher_config_descriptor_get(), "config");
        eet_close(f);
        luncher_it = calloc(1, sizeof(Luncher_Config_Item));
        luncher_it->id = eina_list_count(luncher_config->items) + 1;
        luncher_it->dir = eina_stringshare_ref(it->dir);
        luncher_it->style = eina_stringshare_add("default");
        luncher_config->items = eina_list_append(luncher_config->items, luncher_it);
        f = eet_open(buf, EET_FILE_MODE_READ_WRITE);
        eet_data_write(f, luncher_config_descriptor_get(), "config",
                       luncher_config, 1);
        eet_close(f);
        return luncher_it->id;
     }

   return -1;
}

static int
_clock_migrate(const char *path, const char *id)
{
   Eet_File *f, *ff;
   Clock_Config *clock;
   Time_Config *time_config;
   Eina_List *l;
   Clock_Config_Item *it;
   Time_Config_Item *time_it;
   char buf[PATH_MAX];

   snprintf(buf, sizeof(buf), "%s/module.clock.cfg", path);
   f = eet_open(buf, EET_FILE_MODE_READ);
   clock = eet_data_read(f, clock_config_descriptor_get(), "config");
   eet_close(f);

   EINA_LIST_FOREACH(clock->items, l, it)
     {
        if (it->id == id) break;
     }
   if (l)
     {
        snprintf(buf, sizeof(buf), "%s/module.time.cfg", path);
        ff = eet_open(buf, EET_FILE_MODE_READ);
        time_config = eet_data_read(ff, time_config_descriptor_get(), "config");
        eet_close(ff);
        time_it = calloc(1, sizeof(Time_Config_Item));
        time_it->id = eina_list_count(time_config->items) + 1;
        time_it->weekend.start = it->weekend.start;
        time_it->weekend.len = it->weekend.len;
        time_it->week.start = it->week.start;
        time_it->digital_clock = it->digital_clock ? 1 : 0;
        time_it->digital_24h = it->digital_24h ? 1 : 0;
        time_it->show_seconds = it->show_seconds ? 1 : 0;
        time_it->show_date = it->show_date ? 1 : 0;
        time_it->time_str[0] = eina_stringshare_add("%I:%M");
        time_it->time_str[1] = eina_stringshare_add("%F");

        time_config->items = eina_list_append(time_config->items, time_it);

        ff = eet_open(buf, EET_FILE_MODE_READ_WRITE);
        eet_data_write(ff, time_config_descriptor_get(), "config",
                       time_config, 1);
        eet_close(ff);

        return time_it->id;

     }
   return -1;
}

static Bryce_Migration_Module_Compat _compat[] =
{
     {"start", "Start", _start_migrate},
     {"pager", "Pager Gadget", _pager_migrate},
     {"ibar", "Luncher Bar", _ibar_migrate},
     {"clock", "Digital Clock", _clock_migrate}
};



static void
_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)
{
   Eina_List *l, *ll;
   E_Config_Gadcon *gc;
   E_Config_Gadcon_Client *client;
   int i;
   int id;
   E_Gadget_Site *site;
   E_Gadget_Config *gcfg;
   char buf[PATH_MAX];
   Bryce *b;

   site = calloc(1, sizeof(E_Gadget_Site));

   printf("Starting migration %s %s\n", path, shelf->name);

   EINA_LIST_FOREACH(e_config->gadcons, l, gc)
     {
        printf("gadcon %s\n", gc->name);
        if (!strcmp(gc->name, shelf->name))
          {
             EINA_LIST_FOREACH(gc->clients, ll, client)
               {
                  id = -1;
                  for (i = 0; i < (sizeof(_compat) / sizeof(_compat[0])); ++i)
                    {
                       if (!strcmp(_compat[i].shelf, client->name))
                         {
                            id = _compat[i].migrate(path, client->id);
                            break;
                         }
                    }
                  if (id < 0)
                    {
                       printf("Fail to migrate %s\n", client->name);
                       continue;
                    }
                  gcfg = calloc(1, sizeof(E_Gadget_Config));
                  gcfg->id = id;
                  gcfg->type = eina_stringshare_add(_compat[i].bryce);
                  site->gadgets = eina_list_append(site->gadgets, gcfg);
               }
             e_config->gadcons = eina_list_remove_list(e_config->gadcons, l);
             break;
          }
     }
   if (l)
     {
        snprintf(buf, sizeof(buf), "__bryce%s", bryce);
        site->name = eina_stringshare_add(buf);
        site->gravity = gravity;
        site->orient = orient;
        site->anchor = anchor;

        printf("Append %d %d\n", eina_list_count(_sites->sites), eina_list_count(site->gadgets));
        _sites->sites = eina_list_append(_sites->sites, site);
        printf("Append %d %d\n", eina_list_count(_sites->sites), eina_list_count(site->gadgets));

        b = calloc(1, sizeof(Bryce));
        b->name = eina_stringshare_add(bryce);
        b->style = eina_stringshare_add("default");
        b->zone = shelf->zone; /* TODO */
        b->size = 48;
        b->layer = shelf->layer;
        b->autosize = !!shelf->fit_along;
        b->autohide = !!shelf->autohide;
        b->orient = orient;
        b->anchor = anchor;
        b->version = 2;
        _bryces->bryces = eina_list_append(_bryces->bryces, b);
     }
}

static void
_migrate(const char *path)
{
   E_Config_Shelf *shelf;
   E_Gadget_Site_Orient orient;
   E_Gadget_Site_Anchor anchor;
   E_Gadget_Site_Gravity gravity;
   const char *loc, *loc2;
   char buf[PATH_MAX];
   Eet_File *f;



   EINA_LIST_FREE(e_config->shelves, shelf)
     {
        switch(shelf->orient)
          {
//           case E_GADCON_ORIENT_FLOAT: ???? UNUSED ????
           case E_GADCON_ORIENT_HORIZ:
              orient = E_GADGET_SITE_ORIENT_HORIZONTAL;
              anchor = E_GADGET_SITE_ANCHOR_TOP;
              break;
           case E_GADCON_ORIENT_TOP:
              orient = E_GADGET_SITE_ORIENT_HORIZONTAL;
              anchor = E_GADGET_SITE_ANCHOR_TOP;
              break;
           case E_GADCON_ORIENT_BOTTOM:
              orient = E_GADGET_SITE_ORIENT_HORIZONTAL;
              anchor = E_GADGET_SITE_ANCHOR_BOTTOM;
              break;
           case E_GADCON_ORIENT_CORNER_TL:
              orient = E_GADGET_SITE_ORIENT_HORIZONTAL;
              anchor = E_GADGET_SITE_ANCHOR_TOP | E_GADGET_SITE_ANCHOR_LEFT;
              break;
           case E_GADCON_ORIENT_CORNER_TR:
              orient = E_GADGET_SITE_ORIENT_HORIZONTAL;
              anchor = E_GADGET_SITE_ANCHOR_TOP | E_GADGET_SITE_ANCHOR_RIGHT;
              break;
           case E_GADCON_ORIENT_CORNER_BL:
              orient = E_GADGET_SITE_ORIENT_HORIZONTAL;
              anchor = E_GADGET_SITE_ANCHOR_BOTTOM | E_GADGET_SITE_ANCHOR_LEFT;
              break;
           case E_GADCON_ORIENT_CORNER_BR:
              orient = E_GADGET_SITE_ORIENT_HORIZONTAL;
              anchor = E_GADGET_SITE_ANCHOR_BOTTOM | E_GADGET_SITE_ANCHOR_RIGHT;
              break;
           case E_GADCON_ORIENT_VERT:
              orient = E_GADGET_SITE_ORIENT_VERTICAL;
              anchor = E_GADGET_SITE_ANCHOR_LEFT;
              break;
           case E_GADCON_ORIENT_LEFT:
              orient = E_GADGET_SITE_ORIENT_VERTICAL;
              anchor = E_GADGET_SITE_ANCHOR_LEFT;
              break;
           case E_GADCON_ORIENT_RIGHT:
              orient = E_GADGET_SITE_ORIENT_VERTICAL;
              anchor = E_GADGET_SITE_ANCHOR_RIGHT;
              break;
           case E_GADCON_ORIENT_CORNER_LT:
              orient = E_GADGET_SITE_ORIENT_VERTICAL;
              anchor = E_GADGET_SITE_ANCHOR_LEFT | E_GADGET_SITE_ANCHOR_TOP;
              break;
           case E_GADCON_ORIENT_CORNER_RT:
              orient = E_GADGET_SITE_ORIENT_VERTICAL;
              anchor = E_GADGET_SITE_ANCHOR_RIGHT | E_GADGET_SITE_ANCHOR_TOP;
              break;
           case E_GADCON_ORIENT_CORNER_LB:
              orient = E_GADGET_SITE_ORIENT_VERTICAL;
              anchor = E_GADGET_SITE_ANCHOR_LEFT | E_GADGET_SITE_ANCHOR_BOTTOM;
              break;
           case E_GADCON_ORIENT_CORNER_RB:
              orient = E_GADGET_SITE_ORIENT_VERTICAL;
              anchor = E_GADGET_SITE_ANCHOR_RIGHT | E_GADGET_SITE_ANCHOR_BOTTOM;
              break;
          }
        if (orient == E_GADGET_SITE_ORIENT_HORIZONTAL)
          {
             if (anchor & E_GADGET_SITE_ANCHOR_LEFT)
               gravity = E_GADGET_SITE_GRAVITY_LEFT;
             else if (anchor & E_GADGET_SITE_ANCHOR_RIGHT)
               gravity = E_GADGET_SITE_GRAVITY_RIGHT;
             else
               gravity = E_GADGET_SITE_GRAVITY_CENTER;
          }
        else
          {
             if (anchor & E_GADGET_SITE_ANCHOR_TOP)
               gravity = E_GADGET_SITE_GRAVITY_TOP;
             else if (anchor & E_GADGET_SITE_ANCHOR_BOTTOM)
               gravity = E_GADGET_SITE_GRAVITY_BOTTOM;
             else
               gravity = E_GADGET_SITE_GRAVITY_CENTER;
          }

        if (anchor & E_GADGET_SITE_ANCHOR_TOP)
          loc = "top";
        else if (anchor & E_GADGET_SITE_ANCHOR_BOTTOM)
          loc = "bottom";
        else if (anchor & E_GADGET_SITE_ANCHOR_LEFT)
          loc = "left";
        else if (anchor & E_GADGET_SITE_ANCHOR_RIGHT)
          loc = "right";
        if (anchor & E_GADGET_SITE_ANCHOR_RIGHT)
          loc2 = "right";
        else if (anchor & E_GADGET_SITE_ANCHOR_LEFT)
          loc2 = "left";
        else if (anchor & E_GADGET_SITE_ANCHOR_TOP)
          loc2 = "top";
        else if (anchor & E_GADGET_SITE_ANCHOR_BOTTOM)
          loc2 = "bottom";

        snprintf(buf, sizeof(buf), "bryce_%s_%s_%d", loc, loc2, shelf->zone);

        _migrate_shelf(path, shelf, buf, anchor, gravity, orient);
     }
   snprintf(buf, sizeof(buf), "%s/e.cfg", path);
   f = eet_open(buf, EET_FILE_MODE_READ_WRITE);
   if (!f)
     {
        printf("Can't open config file\n");
     }

   eet_data_write(f, e_config_descriptor_get(), "config",
                  e_config, 1);
   eet_close(f);
}

static void
_shutdown(void)
{
   clock_config_descriptor_shutdown();
   time_config_descriptor_shutdown();
   ibar_config_descriptor_shutdown();
   luncher_config_descriptor_shutdown();
   e_config_descriptor_shutdown();
   eet_shutdown();
}

static const Ecore_Getopt options =
{
   "Bryce migration",
   "%prog [options]",
   "0.1",
   "(C) 2011 Enlightenment, see AUTHORS.",
   "GPL, see COPYING",
   "Bryce migration tool",
   EINA_TRUE,
   {
      ECORE_GETOPT_STORE_STR('p', "path", "path of e config"),
      ECORE_GETOPT_STORE_STR('s', "shelf", "shelf name"),
      ECORE_GETOPT_STORE_STR('b', "bryce", "bryce name"),
      ECORE_GETOPT_STORE_UINT('a', "anchor", "anchor position"),
      ECORE_GETOPT_STORE_UINT('g', "gravity", "gadget gravity"),
      ECORE_GETOPT_STORE_UINT('o', "orient", "gadget orientation"),
      ECORE_GETOPT_HELP('h', "help"),
      ECORE_GETOPT_SENTINEL
   }
};

int
main(int argc, char **argv)
{
   int args;
   char *path;
   char *shelf;
   char *bryce;
   Eina_Bool quit_option;
   E_Gadget_Site_Gravity gravity;
   E_Gadget_Site_Orient orient;
   E_Gadget_Site_Anchor anchor;

   Ecore_Getopt_Value values[] =
     {
        ECORE_GETOPT_VALUE_STR(path),
        ECORE_GETOPT_VALUE_STR(shelf),
        ECORE_GETOPT_VALUE_STR(bryce),
        ECORE_GETOPT_VALUE_UINT(anchor),
        ECORE_GETOPT_VALUE_UINT(gravity),
        ECORE_GETOPT_VALUE_UINT(orient),
        ECORE_GETOPT_VALUE_BOOL(quit_option)
     };

   args = ecore_getopt_parse(&options, values, argc, argv);
   if (args < 0)
     return EXIT_FAILURE;
   if (quit_option)
     return EXIT_SUCCESS;


   printf("Welcome to migration tool\n");
   _init(path);
   _bryce_init(path);

   _migrate(path);

   _bryce_shutdown(path);
   _shutdown();

   return 0;
}