forked from enlightenment/enlightenment
split _e_fm2_device_volume_setup off to be reused later for setting up volumes which get added before their storage; now removables have the correct icons in udisks mode!
SVN revision: 55922
This commit is contained in:
parent
7f3afa0d00
commit
fb51556c67
|
@ -2,6 +2,11 @@
|
|||
#include "e_fm_shared_codec.h"
|
||||
#include "e_fm_shared_device.h"
|
||||
|
||||
#define TEBIBYTE_SIZE 1099511627776LL
|
||||
#define GIBIBYTE_SIZE 1073741824
|
||||
#define MEBIBYTE_SIZE 1048576
|
||||
#define KIBIBYTE_SIZE 1024
|
||||
|
||||
static void _e_fm2_volume_write(E_Volume *v) EINA_ARG_NONNULL(1);
|
||||
static void _e_fm2_volume_erase(E_Volume *v) EINA_ARG_NONNULL(1);
|
||||
static void _e_fm2_device_mount_free(E_Fm2_Mount *m); EINA_ARG_NONNULL(1);
|
||||
|
@ -13,159 +18,9 @@ static void _e_fm2_device_unmount_fail(E_Fm2_Mount *m) EINA_ARG_NONNULL(1);
|
|||
static Eina_List *_e_stores = NULL;
|
||||
static Eina_List *_e_vols = NULL;
|
||||
|
||||
EAPI void
|
||||
e_fm2_device_storage_add(E_Storage *s)
|
||||
static void
|
||||
_e_fm2_device_volume_setup(E_Volume *v)
|
||||
{
|
||||
if (e_fm2_device_storage_find(s->udi)) return;
|
||||
|
||||
s->validated = EINA_TRUE;
|
||||
_e_stores = eina_list_append(_e_stores, s);
|
||||
/*
|
||||
printf("STO+\n"
|
||||
" udi: %s\n"
|
||||
" bus: %s\n"
|
||||
" drive_type: %s\n"
|
||||
" model: %s\n"
|
||||
" vendor: %s\n"
|
||||
" serial: %s\n"
|
||||
" removable: %i\n"
|
||||
" media_available: %i\n"
|
||||
" media_size: %lli\n"
|
||||
" requires_eject: %i\n"
|
||||
" hotpluggable: %i\n"
|
||||
" media_check_enabled: %i\n"
|
||||
" icon.drive: %s\n"
|
||||
" icon.volume: %s\n\n"
|
||||
,
|
||||
s->udi,
|
||||
s->bus,
|
||||
s->drive_type,
|
||||
s->model,
|
||||
s->vendor,
|
||||
s->serial,
|
||||
s->removable,
|
||||
s->media_available,
|
||||
s->media_size,
|
||||
s->requires_eject,
|
||||
s->hotpluggable,
|
||||
s->media_check_enabled,
|
||||
s->icon.drive,
|
||||
s->icon.volume);
|
||||
*/
|
||||
if ((s->removable == 0) &&
|
||||
(s->media_available == 0) &&
|
||||
(s->media_size == 0) &&
|
||||
(s->requires_eject == 0) &&
|
||||
(s->hotpluggable == 0) &&
|
||||
(s->media_check_enabled == 0))
|
||||
{
|
||||
// printf(" Ignore this storage\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
s->trackable = EINA_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_fm2_device_storage_del(E_Storage *s)
|
||||
{
|
||||
// printf("STO- %s\n", s->udi);
|
||||
_e_stores = eina_list_remove(_e_stores, s);
|
||||
_e_fm_shared_device_storage_free(s);
|
||||
}
|
||||
|
||||
EAPI E_Storage *
|
||||
e_fm2_device_storage_find(const char *udi)
|
||||
{
|
||||
Eina_List *l;
|
||||
E_Storage *s;
|
||||
|
||||
if (!udi) return NULL;
|
||||
EINA_LIST_FOREACH(_e_stores, l, s)
|
||||
{
|
||||
if (!strcmp(udi, s->udi)) return s;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#define TEBIBYTE_SIZE 1099511627776LL
|
||||
#define GIBIBYTE_SIZE 1073741824
|
||||
#define MEBIBYTE_SIZE 1048576
|
||||
#define KIBIBYTE_SIZE 1024
|
||||
|
||||
EAPI void
|
||||
e_fm2_device_volume_add(E_Volume *v)
|
||||
{
|
||||
E_Storage *s;
|
||||
|
||||
if (e_fm2_device_volume_find(v->udi)) return;
|
||||
|
||||
v->validated = EINA_TRUE;
|
||||
_e_vols = eina_list_append(_e_vols, v);
|
||||
/*
|
||||
printf("VOL+\n"
|
||||
" udi: %s\n"
|
||||
" uuid: %s\n"
|
||||
" fstype: %s\n"
|
||||
" size: %llu\n"
|
||||
" label: %s\n"
|
||||
" partition: %d\n"
|
||||
" partition_number: %d\n"
|
||||
" partition_label: %s\n"
|
||||
" mounted: %d\n"
|
||||
" mount_point: %s\n"
|
||||
" parent: %s\n"
|
||||
,
|
||||
v->udi,
|
||||
v->uuid,
|
||||
v->fstype,
|
||||
v->size,
|
||||
v->label,
|
||||
v->partition,
|
||||
v->partition_number,
|
||||
v->partition ? v->partition_label : "(not a partition)",
|
||||
v->mounted,
|
||||
v->mount_point,
|
||||
v->parent);
|
||||
*/
|
||||
/* Check mount point */
|
||||
if ((v->efm_mode == EFM_MODE_USING_HAL_MOUNT) &&
|
||||
((!v->mount_point) || (!v->mount_point[0])))
|
||||
{
|
||||
if (v->mount_point) eina_stringshare_del(v->mount_point);
|
||||
v->mount_point = NULL;
|
||||
v->mount_point = e_fm2_device_volume_mountpoint_get(v);
|
||||
if ((!v->mount_point) || (!v->mount_point[0]))
|
||||
{
|
||||
char buf[PATH_MAX];
|
||||
const char *id;
|
||||
|
||||
if (v->mount_point) eina_stringshare_del(v->mount_point);
|
||||
v->mount_point = NULL;
|
||||
id = "disk";
|
||||
if ((v->uuid) && (v->uuid[0])) id = v->uuid;
|
||||
if (ecore_file_is_dir("/media"))
|
||||
snprintf(buf, sizeof(buf), "/media/%s", id);
|
||||
else if (ecore_file_is_dir("/mnt"))
|
||||
snprintf(buf, sizeof(buf), "/mnt/%s", id);
|
||||
else if (ecore_file_is_dir("/tmp"))
|
||||
snprintf(buf, sizeof(buf), "/tmp/%s", id);
|
||||
else
|
||||
buf[0] = 0;
|
||||
v->mount_point = eina_stringshare_add(buf);
|
||||
}
|
||||
}
|
||||
|
||||
/* Search parent storage */
|
||||
if ((s = e_fm2_device_storage_find(v->parent)))
|
||||
{
|
||||
v->storage = s;
|
||||
s->volumes = eina_list_append(s->volumes, v);
|
||||
}
|
||||
|
||||
if (v->storage)
|
||||
{
|
||||
char label[1024] = {0};
|
||||
char size[256] = {0};
|
||||
const char *icon = NULL;
|
||||
|
@ -251,7 +106,169 @@ e_fm2_device_volume_add(E_Volume *v)
|
|||
strcmp(v->mount_point, "/home") &&
|
||||
strcmp(v->mount_point, "/tmp")))
|
||||
_e_fm2_volume_write(v);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_fm2_device_storage_add(E_Storage *s)
|
||||
{
|
||||
Eina_List *l;
|
||||
E_Volume *v;
|
||||
|
||||
if (e_fm2_device_storage_find(s->udi)) return;
|
||||
|
||||
s->validated = EINA_TRUE;
|
||||
_e_stores = eina_list_append(_e_stores, s);
|
||||
/*
|
||||
printf("STO+\n"
|
||||
" udi: %s\n"
|
||||
" bus: %s\n"
|
||||
" drive_type: %s\n"
|
||||
" model: %s\n"
|
||||
" vendor: %s\n"
|
||||
" serial: %s\n"
|
||||
" removable: %i\n"
|
||||
" media_available: %i\n"
|
||||
" media_size: %lli\n"
|
||||
" requires_eject: %i\n"
|
||||
" hotpluggable: %i\n"
|
||||
" media_check_enabled: %i\n"
|
||||
" icon.drive: %s\n"
|
||||
" icon.volume: %s\n\n"
|
||||
,
|
||||
s->udi,
|
||||
s->bus,
|
||||
s->drive_type,
|
||||
s->model,
|
||||
s->vendor,
|
||||
s->serial,
|
||||
s->removable,
|
||||
s->media_available,
|
||||
s->media_size,
|
||||
s->requires_eject,
|
||||
s->hotpluggable,
|
||||
s->media_check_enabled,
|
||||
s->icon.drive,
|
||||
s->icon.volume);
|
||||
*/
|
||||
if ((s->removable == 0) &&
|
||||
(s->media_available == 0) &&
|
||||
(s->media_size == 0) &&
|
||||
(s->requires_eject == 0) &&
|
||||
(s->hotpluggable == 0) &&
|
||||
(s->media_check_enabled == 0))
|
||||
{
|
||||
// printf(" Ignore this storage\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
s->trackable = EINA_TRUE;
|
||||
}
|
||||
|
||||
EINA_LIST_FOREACH(_e_vols, l, v) /* catch volumes which were added before their storage */
|
||||
{
|
||||
if ((!v->storage) && (s->udi == v->parent))
|
||||
{
|
||||
v->storage = s;
|
||||
_e_fm2_device_volume_setup(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_fm2_device_storage_del(E_Storage *s)
|
||||
{
|
||||
// printf("STO- %s\n", s->udi);
|
||||
_e_stores = eina_list_remove(_e_stores, s);
|
||||
_e_fm_shared_device_storage_free(s);
|
||||
}
|
||||
|
||||
EAPI E_Storage *
|
||||
e_fm2_device_storage_find(const char *udi)
|
||||
{
|
||||
Eina_List *l;
|
||||
E_Storage *s;
|
||||
|
||||
if (!udi) return NULL;
|
||||
EINA_LIST_FOREACH(_e_stores, l, s)
|
||||
{
|
||||
if (!strcmp(udi, s->udi)) return s;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
EAPI void
|
||||
e_fm2_device_volume_add(E_Volume *v)
|
||||
{
|
||||
E_Storage *s;
|
||||
|
||||
if (e_fm2_device_volume_find(v->udi)) return;
|
||||
|
||||
v->validated = EINA_TRUE;
|
||||
_e_vols = eina_list_append(_e_vols, v);
|
||||
/*
|
||||
printf("VOL+\n"
|
||||
" udi: %s\n"
|
||||
" uuid: %s\n"
|
||||
" fstype: %s\n"
|
||||
" size: %llu\n"
|
||||
" label: %s\n"
|
||||
" partition: %d\n"
|
||||
" partition_number: %d\n"
|
||||
" partition_label: %s\n"
|
||||
" mounted: %d\n"
|
||||
" mount_point: %s\n"
|
||||
" parent: %s\n"
|
||||
,
|
||||
v->udi,
|
||||
v->uuid,
|
||||
v->fstype,
|
||||
v->size,
|
||||
v->label,
|
||||
v->partition,
|
||||
v->partition_number,
|
||||
v->partition ? v->partition_label : "(not a partition)",
|
||||
v->mounted,
|
||||
v->mount_point,
|
||||
v->parent);
|
||||
*/
|
||||
/* Check mount point */
|
||||
if ((v->efm_mode == EFM_MODE_USING_HAL_MOUNT) &&
|
||||
((!v->mount_point) || (!v->mount_point[0])))
|
||||
{
|
||||
if (v->mount_point) eina_stringshare_del(v->mount_point);
|
||||
v->mount_point = NULL;
|
||||
v->mount_point = e_fm2_device_volume_mountpoint_get(v);
|
||||
if ((!v->mount_point) || (!v->mount_point[0]))
|
||||
{
|
||||
char buf[PATH_MAX];
|
||||
const char *id;
|
||||
|
||||
if (v->mount_point) eina_stringshare_del(v->mount_point);
|
||||
v->mount_point = NULL;
|
||||
id = "disk";
|
||||
if ((v->uuid) && (v->uuid[0])) id = v->uuid;
|
||||
if (ecore_file_is_dir("/media"))
|
||||
snprintf(buf, sizeof(buf), "/media/%s", id);
|
||||
else if (ecore_file_is_dir("/mnt"))
|
||||
snprintf(buf, sizeof(buf), "/mnt/%s", id);
|
||||
else if (ecore_file_is_dir("/tmp"))
|
||||
snprintf(buf, sizeof(buf), "/tmp/%s", id);
|
||||
else
|
||||
buf[0] = 0;
|
||||
v->mount_point = eina_stringshare_add(buf);
|
||||
}
|
||||
}
|
||||
|
||||
/* Search parent storage */
|
||||
if ((s = e_fm2_device_storage_find(v->parent)))
|
||||
{
|
||||
v->storage = s;
|
||||
s->volumes = eina_list_append(s->volumes, v);
|
||||
}
|
||||
|
||||
if (v->storage) _e_fm2_device_volume_setup(v);
|
||||
|
||||
}
|
||||
|
||||
EAPI void
|
||||
|
|
Loading…
Reference in New Issue