summaryrefslogtreecommitdiff
path: root/src/e_mod_eeze.c
blob: f253a279b11a239de8b928d0543c90a19188f8f7 (plain)
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

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#ifdef HAVE_EEZE

#include <e.h>
#include "e_mod_places.h"
#include <Eeze.h>
#include <Eeze_Disk.h>

/* Local Function Prototypes */


/* Local Variables */

// Eina_Bool eeze_mount_mtab_scan (void)
// Eina_Bool eeze_mount_fstab_scan (void)

// Eina_Bool eeze_mount_tabs_watch (void)
// void      eeze_mount_tabs_unwatch (void)

// Eina_Bool eeze_disk_mount (Eeze_Disk *disk)
// Eina_Bool eeze_disk_unmount (Eeze_Disk *disk)
// Eina_Bool eeze_disk_eject (Eeze_Disk *disk)

/* Implementation */

void _places_eeze_disk_print(Eeze_Disk *disk)
{
   eeze_disk_scan(disk); // NEEDED ??

   printf("PLACES: SysPath: %s\n", eeze_disk_syspath_get(disk));
   printf("PLACES:        devpath: %s\n", eeze_disk_devpath_get(disk));
   printf("PLACES:    mount_point: %s\n", eeze_disk_mount_point_get(disk));
   printf("PLACES:      mountopts: %ld\n", eeze_disk_mountopts_get(disk));
   printf("PLACES:          label: %s\n", eeze_disk_label_get(disk));
   printf("PLACES:           type: %d\n", eeze_disk_type_get(disk));
   printf("PLACES:         fstype: %s\n", eeze_disk_fstype_get(disk));
   if (eeze_disk_devpath_get(disk)) // prevent eeze segfault :/
      printf("PLACES:        mounted: %d\n", eeze_disk_mounted_get(disk));
   printf("PLACES:      removable: %d\n", eeze_disk_removable_get(disk));
   printf("PLACES:  mount_wrapper: %s\n", eeze_disk_mount_wrapper_get(disk));

   printf("PLACES:         vendor: %s\n", eeze_disk_vendor_get(disk));
   printf("PLACES:          model: %s\n", eeze_disk_model_get(disk));
   printf("PLACES:         serial: %s\n", eeze_disk_serial_get(disk));
   printf("PLACES:           uuid: %s\n", eeze_disk_uuid_get(disk));

   printf("PLACES: -----------------------------------------------\n");
}

Eina_Bool
places_eeze_init(void)
{
   printf("PLACES: *****************************************\n");
   printf("PLACES: eeze: init()\n");

   // init eeze
   if (!eeze_init())
   {
      printf("PLACES: Impossible to setup eeze.\n");
      return EINA_FALSE;
   }

   // This will fail on compilation/runtime if Disk functions not available
   eeze_disk_function();

   // check eeze mount/umont/eject support
   if (!eeze_disk_can_mount() ||
       !eeze_disk_can_unmount() ||
       !eeze_disk_can_eject())
   {
      printf("PLACES: Eeze don't have mount/umount/eject support.\n");
      eeze_shutdown();
      return EINA_FALSE;
   }

   if (!eeze_mount_tabs_watch())
   {
      printf("PLACES: Cannot setup watcher for fstab/mtab.\n");
      eeze_shutdown();
      return EINA_FALSE;
   }

   eeze_mount_fstab_scan();
   eeze_mount_mtab_scan();


   Eina_List *disks;
   const char *syspath;
   Eeze_Disk *disk;

   disks = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_INTERNAL, NULL);
   printf("PLACES: Found the following internal drive:\n");
   EINA_LIST_FREE(disks, syspath)
     {
        disk = eeze_disk_new(syspath);
        _places_eeze_disk_print(disk);
        eina_stringshare_del(syspath);
        eeze_disk_free(disk);
     }

   disks = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_MOUNTABLE, NULL);
   printf("PLACES: Found the following mountable drive:\n");
   EINA_LIST_FREE(disks, syspath)
     {
        disk = eeze_disk_new(syspath);
        _places_eeze_disk_print(disk);
        eeze_disk_free(disk);
        eina_stringshare_del(syspath);
     }

   disks = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_CDROM, NULL);
   printf("PLACES: Found the following cdrom drive:\n");
   EINA_LIST_FREE(disks, syspath)
     {
        disk = eeze_disk_new(syspath);
        _places_eeze_disk_print(disk);
        eeze_disk_free(disk);
        eina_stringshare_del(syspath);
     }

   disks = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_REMOVABLE, NULL);
   printf("PLACES: Found the following removable drive:\n");
   EINA_LIST_FREE(disks, syspath)
     {
        disk = eeze_disk_new(syspath);
        _places_eeze_disk_print(disk);
        eeze_disk_free(disk);
        eina_stringshare_del(syspath);
     }

   printf("PLACES: Searching for your root:\n");
   disk = eeze_disk_new_from_mount("/");
   if (disk)
   {
      _places_eeze_disk_print(disk);
      eeze_disk_free(disk);
   }

   return EINA_TRUE;
}

void
places_eeze_shutdown(void)
{
   eeze_mount_tabs_unwatch();
   eeze_shutdown();
}


/* Internals */

#endif