add docs for eject, fix some devastating typos in eject, eject now unmounts mounted disks before ejecting

SVN revision: 59445
This commit is contained in:
Mike Blumenkrantz 2011-05-16 11:24:26 +00:00
parent 775b86bccd
commit d35ef797bc
3 changed files with 42 additions and 8 deletions

View File

@ -288,7 +288,7 @@ EAPI Eina_Bool eeze_disk_mount(Eeze_Disk *disk);
* @return #EINA_TRUE if the operation was started, else #EINA_FALSE
*
* This call is used to begin an unmount operation on @p disk. The operation will
* run asynchronously in a pipe, emitting an EEZE_EVENT_DISK_MOUNT event with the disk object
* run asynchronously in a pipe, emitting an EEZE_EVENT_DISK_UNMOUNT event with the disk object
* as its event on completion. If any errors are encountered, they will automatically logged
* to the eeze_disk domain and an EEZE_EVENT_DISK_ERROR event will be generated with
* an #Eeze_Event_Disk_Error struct as its event.
@ -297,6 +297,20 @@ EAPI Eina_Bool eeze_disk_mount(Eeze_Disk *disk);
*/
EAPI Eina_Bool eeze_disk_unmount(Eeze_Disk *disk);
/**
* @brief Begin an eject operation on the disk
* @param disk The disk
* @return #EINA_TRUE if the operation was started, else #EINA_FALSE
*
* This call is used to begin an eject operation on @p disk. The operation will
* run asynchronously in a pipe, emitting an EEZE_EVENT_DISK_EJECT event with the disk object
* as its event on completion. If any errors are encountered, they will automatically logged
* to the eeze_disk domain and an EEZE_EVENT_DISK_ERROR event will be generated with
* an #Eeze_Event_Disk_Error struct as its event.
*
* NOTE: The return value of this function does not in any way reflect the mount state of a disk.
*/
EAPI Eina_Bool eeze_disk_eject(Eeze_Disk *disk);
/**
* @brief Cancel a pending operation on the disk
* @param disk The disk

View File

@ -100,6 +100,7 @@ _eeze_disk_mount_result_handler(void *data __UNUSED__, int type __UNUSED__, Ecor
EINA_SAFETY_ON_NULL_RETURN_VAL(e, ECORE_CALLBACK_RENEW);
e->disk = disk;
disk->mounter = NULL;
disk->mounted = EINA_FALSE;
ecore_event_add(EEZE_EVENT_DISK_UNMOUNT, e, NULL, NULL);
break;
@ -117,12 +118,23 @@ _eeze_disk_mount_result_handler(void *data __UNUSED__, int type __UNUSED__, Ecor
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);
if (disk->mount_status & EEZE_DISK_UNMOUNTING)
{
disk->mount_status |= EEZE_DISK_UNMOUNTING;
disk->mounted = EINA_FALSE;
ecore_event_add(EEZE_EVENT_DISK_UNMOUNT, e, NULL, NULL);
eeze_disk_eject(disk);
}
else
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);
if (disk->mount_status & EEZE_DISK_UNMOUNTING)
disk->mounter = ecore_exe_run(eina_strbuf_string_get(disk->unmount_cmd), disk);
else
disk->mounter = ecore_exe_run(eina_strbuf_string_get(disk->eject_cmd), disk);
eeze_events = eina_list_append(eeze_events, disk);
return ECORE_CALLBACK_RENEW;
}
@ -356,6 +368,14 @@ eeze_disk_eject(Eeze_Disk *disk)
}
INF("Ejecting: %s", eina_strbuf_string_get(disk->eject_cmd));
if (eeze_disk_libmount_mounted_get(disk))
{
Eina_Bool ret;
ret = eeze_disk_unmount(disk);
if (ret) disk->mount_status |= EEZE_DISK_EJECTING;
return ret;
}
disk->mounter = ecore_exe_run(eina_strbuf_string_get(disk->eject_cmd), disk);
if (!disk->mounter)
return EINA_FALSE;

View File

@ -32,10 +32,10 @@ extern int _eeze_disk_log_dom;
typedef enum
{
EEZE_DISK_NULL,
EEZE_DISK_MOUNTING,
EEZE_DISK_UNMOUNTING,
EEZE_DISK_EJECTING
EEZE_DISK_NULL = 0,
EEZE_DISK_MOUNTING = 1,
EEZE_DISK_UNMOUNTING = 2,
EEZE_DISK_EJECTING = 4
} Eeze_Disk_Status;
struct _Eeze_Disk
@ -43,7 +43,7 @@ struct _Eeze_Disk
_udev_device *device;
void *data;
Eeze_Disk_Status mount_status;
int mount_status;
Eina_Strbuf *mount_cmd;
Eina_Strbuf *unmount_cmd;
Eina_Strbuf *eject_cmd;