forked from enlightenment/efl
parent
b63e9a5689
commit
775b86bccd
|
@ -1,3 +1,8 @@
|
|||
2011-05-16 Mike Blumenkrantz (discomfitor/zmike)
|
||||
+EEZE_EVENT_DISK_EJECT
|
||||
+eeze_disk_eject
|
||||
Functions for ejecting a disk
|
||||
|
||||
2011-05-15 Mike Blumenkrantz (discomfitor/zmike)
|
||||
+eeze_disk_cancel
|
||||
Cancel the current pending mount/umount operation on a disk
|
||||
|
|
|
@ -109,6 +109,7 @@ if test "x$eeze_mount" = "xyes";then
|
|||
with_umount="/bin/umount"
|
||||
AC_ARG_WITH([mount], AS_HELP_STRING([--with-mount], [specify mount bin @<:@default=detect@:>@]))
|
||||
AC_ARG_WITH([umount], AS_HELP_STRING([--with-umount], [specify umount bin @<:@default=detect@:>@]))
|
||||
AC_ARG_WITH([eject], AS_HELP_STRING([--with-eject], [specify eject bin @<:@default=detect@:>@]))
|
||||
PKG_CHECK_MODULES([LIBMOUNT], [mount >= 2.18.0])
|
||||
mount_v=$(pkg-config --modversion mount)
|
||||
PKG_CHECK_MODULES([ECORE_FILE], [ecore-file >= 1.0.0])
|
||||
|
@ -122,6 +123,11 @@ if test "x$eeze_mount" = "xyes";then
|
|||
AC_PATH_PROG([with_umount], [umount], AC_MSG_ERROR([umount could not be found in PATH]))
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED([EEZE_UNMOUNT_BIN], ["$with_umount"], [umount bin to use])
|
||||
|
||||
if test "x$with_eject" = "xdetect";then
|
||||
AC_PATH_PROG([with_eject], [eject], AC_MSG_ERROR([eject could not be found in PATH]))
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED([EEZE_EJECT_BIN], ["$with_eject"], [eject bin to use])
|
||||
fi
|
||||
AM_CONDITIONAL([OLD_LIBMOUNT], [test -n $mount_v -a $(echo $mount_v | cut -d'.' -f2) -lt 19])
|
||||
if test -z "$OLD_LIBMOUNT_TRUE" ; then
|
||||
|
@ -182,6 +188,7 @@ if test "x$eeze_mount" = "xyes";then
|
|||
echo
|
||||
echo "Mount..................: ${with_mount}"
|
||||
echo "Umount.................: ${with_umount}"
|
||||
echo "Eject..................: ${with_eject}"
|
||||
echo
|
||||
fi
|
||||
echo "Test...................: ${have_eeze_udev_test}"
|
||||
|
|
|
@ -55,23 +55,19 @@ typedef enum
|
|||
|
||||
EAPI extern int EEZE_EVENT_DISK_MOUNT;
|
||||
EAPI extern int EEZE_EVENT_DISK_UNMOUNT;
|
||||
EAPI extern int EEZE_EVENT_DISK_EJECT;
|
||||
EAPI extern int EEZE_EVENT_DISK_ERROR;
|
||||
|
||||
typedef struct _Eeze_Event_Disk_Mount Eeze_Event_Disk_Mount;
|
||||
typedef struct _Eeze_Event_Disk_Unmount Eeze_Event_Disk_Unmount;
|
||||
typedef struct _Eeze_Event_Disk Eeze_Event_Disk_Mount;
|
||||
typedef struct _Eeze_Event_Disk Eeze_Event_Disk_Unmount;
|
||||
typedef struct _Eeze_Event_Disk Eeze_Event_Disk_Eject;
|
||||
typedef struct _Eeze_Disk Eeze_Disk;
|
||||
|
||||
struct _Eeze_Event_Disk_Mount
|
||||
struct _Eeze_Event_Disk
|
||||
{
|
||||
Eeze_Disk *disk;
|
||||
};
|
||||
|
||||
struct _Eeze_Event_Disk_Unmount
|
||||
{
|
||||
Eeze_Disk *disk;
|
||||
};
|
||||
|
||||
|
||||
typedef struct _Eeze_Event_Disk_Error Eeze_Event_Disk_Error;
|
||||
|
||||
struct _Eeze_Event_Disk_Error
|
||||
|
|
|
@ -197,6 +197,9 @@ eeze_disk_free(Eeze_Disk *disk)
|
|||
eina_strbuf_free(disk->mount_cmd);
|
||||
if (disk->unmount_cmd)
|
||||
eina_strbuf_free(disk->unmount_cmd);
|
||||
if (disk->eject_cmd)
|
||||
eina_strbuf_free(disk->eject_cmd);
|
||||
if (disk->mounter) ecore_exe_kill(disk->mounter);
|
||||
_eeze_disks = eina_list_remove(_eeze_disks, disk);
|
||||
free(disk);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
EAPI int EEZE_EVENT_DISK_MOUNT = 0;
|
||||
EAPI int EEZE_EVENT_DISK_UNMOUNT = 0;
|
||||
EAPI int EEZE_EVENT_DISK_EJECT = 0;
|
||||
EAPI int EEZE_EVENT_DISK_ERROR = 0;
|
||||
static Ecore_Event_Handler *_mount_handler = NULL;
|
||||
static Eina_List *eeze_events = NULL;
|
||||
|
@ -91,7 +92,7 @@ _eeze_disk_mount_result_handler(void *data __UNUSED__, int type __UNUSED__, Ecor
|
|||
else
|
||||
_eeze_disk_mount_error_handler(disk, "incorrect invocation or permissions");
|
||||
}
|
||||
else
|
||||
else if (disk->mount_status == EEZE_DISK_UNMOUNTING)
|
||||
switch (ev->exit_code)
|
||||
{
|
||||
case 0:
|
||||
|
@ -104,11 +105,27 @@ _eeze_disk_mount_result_handler(void *data __UNUSED__, int type __UNUSED__, Ecor
|
|||
|
||||
default:
|
||||
INF("Could not unmount disk, retrying");
|
||||
disk->mounter = ecore_exe_pipe_run(eina_strbuf_string_get(disk->unmount_cmd), 0, disk);
|
||||
disk->mounter = ecore_exe_run(eina_strbuf_string_get(disk->unmount_cmd), disk);
|
||||
eeze_events = eina_list_append(eeze_events, disk);
|
||||
return ECORE_CALLBACK_RENEW;
|
||||
}
|
||||
else
|
||||
switch (ev->exit_code)
|
||||
{
|
||||
case 0:
|
||||
e = malloc(sizeof(Eeze_Event_Disk_Eject));
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(e, ECORE_CALLBACK_RENEW);
|
||||
e->disk = disk;
|
||||
disk->mounter = NULL;
|
||||
ecore_event_add(EEZE_EVENT_DISK_EJECT, e, NULL, NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
INF("Could not eject disk, retrying");
|
||||
disk->mounter = ecore_exe_run(eina_strbuf_string_get(disk->unmount_cmd), disk);
|
||||
eeze_events = eina_list_append(eeze_events, disk);
|
||||
return ECORE_CALLBACK_RENEW;
|
||||
}
|
||||
return ECORE_CALLBACK_RENEW;
|
||||
}
|
||||
|
||||
|
@ -123,6 +140,7 @@ eeze_mount_init(void)
|
|||
{
|
||||
EEZE_EVENT_DISK_MOUNT = ecore_event_type_new();
|
||||
EEZE_EVENT_DISK_UNMOUNT = ecore_event_type_new();
|
||||
EEZE_EVENT_DISK_EJECT = ecore_event_type_new();
|
||||
EEZE_EVENT_DISK_ERROR = ecore_event_type_new();
|
||||
_mount_handler = ecore_event_handler_add(ECORE_EXE_EVENT_DEL,
|
||||
(Ecore_Event_Handler_Cb)_eeze_disk_mount_result_handler, NULL);
|
||||
|
@ -324,13 +342,37 @@ eeze_disk_unmount(Eeze_Disk *disk)
|
|||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
eeze_disk_eject(Eeze_Disk *disk)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(disk, EINA_FALSE);
|
||||
|
||||
if (!disk->eject_cmd)
|
||||
{
|
||||
disk->eject_cmd = eina_strbuf_new();
|
||||
if (disk->mount_wrapper)
|
||||
eina_strbuf_append_printf(disk->eject_cmd, "%s ", disk->mount_wrapper);
|
||||
eina_strbuf_append_printf(disk->eject_cmd, EEZE_EJECT_BIN" %s", eeze_disk_devpath_get(disk));
|
||||
}
|
||||
|
||||
INF("Ejecting: %s", eina_strbuf_string_get(disk->eject_cmd));
|
||||
disk->mounter = ecore_exe_run(eina_strbuf_string_get(disk->eject_cmd), disk);
|
||||
if (!disk->mounter)
|
||||
return EINA_FALSE;
|
||||
|
||||
eeze_events = eina_list_append(eeze_events, disk);
|
||||
disk->mount_status = EEZE_DISK_EJECTING;
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
eeze_disk_cancel(Eeze_Disk *disk)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN(disk);
|
||||
if ((!disk->mount_status) || (!disk->mounter)) return;
|
||||
disk->mount_status = EEZE_DISK_NULL;
|
||||
ecore_exe_quit(disk->mounter);
|
||||
ecore_exe_kill(disk->mounter);
|
||||
disk->mounter = NULL;
|
||||
}
|
||||
|
||||
EAPI const char *
|
||||
|
|
|
@ -34,7 +34,8 @@ typedef enum
|
|||
{
|
||||
EEZE_DISK_NULL,
|
||||
EEZE_DISK_MOUNTING,
|
||||
EEZE_DISK_UNMOUNTING
|
||||
EEZE_DISK_UNMOUNTING,
|
||||
EEZE_DISK_EJECTING
|
||||
} Eeze_Disk_Status;
|
||||
|
||||
struct _Eeze_Disk
|
||||
|
@ -45,6 +46,7 @@ struct _Eeze_Disk
|
|||
Eeze_Disk_Status mount_status;
|
||||
Eina_Strbuf *mount_cmd;
|
||||
Eina_Strbuf *unmount_cmd;
|
||||
Eina_Strbuf *eject_cmd;
|
||||
Eina_Bool mount_cmd_changed : 1;
|
||||
Eina_Bool unmount_cmd_changed : 1;
|
||||
Eina_Bool mounted : 1;
|
||||
|
|
Loading…
Reference in New Issue