Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria (inaki@blueleaf.cc) |
Safe Haskell | None |
Language | Haskell2010 |
- Exported types
- Methods
- canEject
- canPollForMedia
- canStart
- canStartDegraded
- canStop
- eject
- ejectFinish
- ejectWithOperation
- ejectWithOperationFinish
- enumerateIdentifiers
- getIcon
- getIdentifier
- getName
- getSortKey
- getStartStopType
- getSymbolicIcon
- getVolumes
- hasMedia
- hasVolumes
- isMediaCheckAutomatic
- isMediaRemovable
- isRemovable
- pollForMedia
- pollForMediaFinish
- start
- startFinish
- stop
- stopFinish
- Signals
Drive
- this represent a piece of hardware connected to the machine.
It's generally only created for removable hardware or hardware with
removable media.
Drive
is a container class for Volume
objects that stem from
the same piece of media. As such, Drive
abstracts a drive with
(or without) removable media and provides operations for querying
whether media is available, determining whether media change is
automatically detected and ejecting the media.
If the Drive
reports that media isn't automatically detected, one
can poll for media; typically one should not do this periodically
as a poll for media operation is potententially expensive and may
spin up the drive creating noise.
Drive
supports starting and stopping drives with authentication
support for the former. This can be used to support a diverse set
of use cases including connecting/disconnecting iSCSI devices,
powering down external disk enclosures and starting/stopping
multi-disk devices such as RAID devices. Note that the actual
semantics and side-effects of starting/stopping a Drive
may vary
according to implementation. To choose the correct verbs in e.g. a
file manager, use driveGetStartStopType
.
For porting from GnomeVFS note that there is no equivalent of
Drive
in that API.
Synopsis
- newtype Drive = Drive (ManagedPtr Drive)
- noDrive :: Maybe Drive
- class (GObject o, IsDescendantOf Drive o) => IsDrive o
- toDrive :: (MonadIO m, IsDrive o) => o -> m Drive
- driveCanEject :: (HasCallStack, MonadIO m, IsDrive a) => a -> m Bool
- driveCanPollForMedia :: (HasCallStack, MonadIO m, IsDrive a) => a -> m Bool
- driveCanStart :: (HasCallStack, MonadIO m, IsDrive a) => a -> m Bool
- driveCanStartDegraded :: (HasCallStack, MonadIO m, IsDrive a) => a -> m Bool
- driveCanStop :: (HasCallStack, MonadIO m, IsDrive a) => a -> m Bool
- driveEject :: (HasCallStack, MonadIO m, IsDrive a, IsCancellable b) => a -> [MountUnmountFlags] -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- driveEjectFinish :: (HasCallStack, MonadIO m, IsDrive a, IsAsyncResult b) => a -> b -> m ()
- driveEjectWithOperation :: (HasCallStack, MonadIO m, IsDrive a, IsMountOperation b, IsCancellable c) => a -> [MountUnmountFlags] -> Maybe b -> Maybe c -> Maybe AsyncReadyCallback -> m ()
- driveEjectWithOperationFinish :: (HasCallStack, MonadIO m, IsDrive a, IsAsyncResult b) => a -> b -> m ()
- driveEnumerateIdentifiers :: (HasCallStack, MonadIO m, IsDrive a) => a -> m [Text]
- driveGetIcon :: (HasCallStack, MonadIO m, IsDrive a) => a -> m Icon
- driveGetIdentifier :: (HasCallStack, MonadIO m, IsDrive a) => a -> Text -> m (Maybe Text)
- driveGetName :: (HasCallStack, MonadIO m, IsDrive a) => a -> m Text
- driveGetSortKey :: (HasCallStack, MonadIO m, IsDrive a) => a -> m (Maybe Text)
- driveGetStartStopType :: (HasCallStack, MonadIO m, IsDrive a) => a -> m DriveStartStopType
- driveGetSymbolicIcon :: (HasCallStack, MonadIO m, IsDrive a) => a -> m Icon
- driveGetVolumes :: (HasCallStack, MonadIO m, IsDrive a) => a -> m [Volume]
- driveHasMedia :: (HasCallStack, MonadIO m, IsDrive a) => a -> m Bool
- driveHasVolumes :: (HasCallStack, MonadIO m, IsDrive a) => a -> m Bool
- driveIsMediaCheckAutomatic :: (HasCallStack, MonadIO m, IsDrive a) => a -> m Bool
- driveIsMediaRemovable :: (HasCallStack, MonadIO m, IsDrive a) => a -> m Bool
- driveIsRemovable :: (HasCallStack, MonadIO m, IsDrive a) => a -> m Bool
- drivePollForMedia :: (HasCallStack, MonadIO m, IsDrive a, IsCancellable b) => a -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- drivePollForMediaFinish :: (HasCallStack, MonadIO m, IsDrive a, IsAsyncResult b) => a -> b -> m ()
- driveStart :: (HasCallStack, MonadIO m, IsDrive a, IsMountOperation b, IsCancellable c) => a -> [DriveStartFlags] -> Maybe b -> Maybe c -> Maybe AsyncReadyCallback -> m ()
- driveStartFinish :: (HasCallStack, MonadIO m, IsDrive a, IsAsyncResult b) => a -> b -> m ()
- driveStop :: (HasCallStack, MonadIO m, IsDrive a, IsMountOperation b, IsCancellable c) => a -> [MountUnmountFlags] -> Maybe b -> Maybe c -> Maybe AsyncReadyCallback -> m ()
- driveStopFinish :: (HasCallStack, MonadIO m, IsDrive a, IsAsyncResult b) => a -> b -> m ()
- type C_DriveChangedCallback = Ptr () -> Ptr () -> IO ()
- type DriveChangedCallback = IO ()
- afterDriveChanged :: (IsDrive a, MonadIO m) => a -> DriveChangedCallback -> m SignalHandlerId
- genClosure_DriveChanged :: MonadIO m => DriveChangedCallback -> m (GClosure C_DriveChangedCallback)
- mk_DriveChangedCallback :: C_DriveChangedCallback -> IO (FunPtr C_DriveChangedCallback)
- noDriveChangedCallback :: Maybe DriveChangedCallback
- onDriveChanged :: (IsDrive a, MonadIO m) => a -> DriveChangedCallback -> m SignalHandlerId
- wrap_DriveChangedCallback :: DriveChangedCallback -> C_DriveChangedCallback
- type C_DriveDisconnectedCallback = Ptr () -> Ptr () -> IO ()
- type DriveDisconnectedCallback = IO ()
- afterDriveDisconnected :: (IsDrive a, MonadIO m) => a -> DriveDisconnectedCallback -> m SignalHandlerId
- genClosure_DriveDisconnected :: MonadIO m => DriveDisconnectedCallback -> m (GClosure C_DriveDisconnectedCallback)
- mk_DriveDisconnectedCallback :: C_DriveDisconnectedCallback -> IO (FunPtr C_DriveDisconnectedCallback)
- noDriveDisconnectedCallback :: Maybe DriveDisconnectedCallback
- onDriveDisconnected :: (IsDrive a, MonadIO m) => a -> DriveDisconnectedCallback -> m SignalHandlerId
- wrap_DriveDisconnectedCallback :: DriveDisconnectedCallback -> C_DriveDisconnectedCallback
- type C_DriveEjectButtonCallback = Ptr () -> Ptr () -> IO ()
- type DriveEjectButtonCallback = IO ()
- afterDriveEjectButton :: (IsDrive a, MonadIO m) => a -> DriveEjectButtonCallback -> m SignalHandlerId
- genClosure_DriveEjectButton :: MonadIO m => DriveEjectButtonCallback -> m (GClosure C_DriveEjectButtonCallback)
- mk_DriveEjectButtonCallback :: C_DriveEjectButtonCallback -> IO (FunPtr C_DriveEjectButtonCallback)
- noDriveEjectButtonCallback :: Maybe DriveEjectButtonCallback
- onDriveEjectButton :: (IsDrive a, MonadIO m) => a -> DriveEjectButtonCallback -> m SignalHandlerId
- wrap_DriveEjectButtonCallback :: DriveEjectButtonCallback -> C_DriveEjectButtonCallback
- type C_DriveStopButtonCallback = Ptr () -> Ptr () -> IO ()
- type DriveStopButtonCallback = IO ()
- afterDriveStopButton :: (IsDrive a, MonadIO m) => a -> DriveStopButtonCallback -> m SignalHandlerId
- genClosure_DriveStopButton :: MonadIO m => DriveStopButtonCallback -> m (GClosure C_DriveStopButtonCallback)
- mk_DriveStopButtonCallback :: C_DriveStopButtonCallback -> IO (FunPtr C_DriveStopButtonCallback)
- noDriveStopButtonCallback :: Maybe DriveStopButtonCallback
- onDriveStopButton :: (IsDrive a, MonadIO m) => a -> DriveStopButtonCallback -> m SignalHandlerId
- wrap_DriveStopButtonCallback :: DriveStopButtonCallback -> C_DriveStopButtonCallback
Exported types
Memory-managed wrapper type.
Instances
GObject Drive Source # | |
Defined in GI.Gio.Interfaces.Drive gobjectType :: IO GType # | |
HasParentTypes Drive Source # | |
Defined in GI.Gio.Interfaces.Drive | |
type ParentTypes Drive Source # | |
Defined in GI.Gio.Interfaces.Drive |
class (GObject o, IsDescendantOf Drive o) => IsDrive o Source #
Instances
(GObject o, IsDescendantOf Drive o) => IsDrive o Source # | |
Defined in GI.Gio.Interfaces.Drive |
Methods
canEject
:: (HasCallStack, MonadIO m, IsDrive a) | |
=> a |
|
-> m Bool |
Checks if a drive can be ejected.
canPollForMedia
:: (HasCallStack, MonadIO m, IsDrive a) | |
=> a |
|
-> m Bool | Returns: |
Checks if a drive can be polled for media changes.
canStart
:: (HasCallStack, MonadIO m, IsDrive a) | |
=> a |
|
-> m Bool |
Checks if a drive can be started.
Since: 2.22
canStartDegraded
driveCanStartDegraded Source #
:: (HasCallStack, MonadIO m, IsDrive a) | |
=> a |
|
-> m Bool | Returns: |
Checks if a drive can be started degraded.
Since: 2.22
canStop
:: (HasCallStack, MonadIO m, IsDrive a) | |
=> a |
|
-> m Bool |
Checks if a drive can be stopped.
Since: 2.22
eject
:: (HasCallStack, MonadIO m, IsDrive a, IsCancellable b) | |
=> a |
|
-> [MountUnmountFlags] |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> m () |
Deprecated: (Since version 2.22)Use driveEjectWithOperation
instead.
Asynchronously ejects a drive.
When the operation is finished, callback
will be called.
You can then call driveEjectFinish
to obtain the
result of the operation.
ejectFinish
:: (HasCallStack, MonadIO m, IsDrive a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m () | (Can throw |
Deprecated: (Since version 2.22)Use driveEjectWithOperationFinish
instead.
Finishes ejecting a drive.
ejectWithOperation
driveEjectWithOperation Source #
:: (HasCallStack, MonadIO m, IsDrive a, IsMountOperation b, IsCancellable c) | |
=> a |
|
-> [MountUnmountFlags] |
|
-> Maybe b |
|
-> Maybe c |
|
-> Maybe AsyncReadyCallback |
|
-> m () |
Ejects a drive. This is an asynchronous operation, and is
finished by calling driveEjectWithOperationFinish
with the drive
and AsyncResult
data returned in the callback
.
Since: 2.22
ejectWithOperationFinish
driveEjectWithOperationFinish Source #
:: (HasCallStack, MonadIO m, IsDrive a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m () | (Can throw |
Finishes ejecting a drive. If any errors occurred during the operation,
error
will be set to contain the errors and False
will be returned.
Since: 2.22
enumerateIdentifiers
driveEnumerateIdentifiers Source #
:: (HasCallStack, MonadIO m, IsDrive a) | |
=> a |
|
-> m [Text] | Returns: a |
Gets the kinds of identifiers that drive
has.
Use driveGetIdentifier
to obtain the identifiers
themselves.
getIcon
:: (HasCallStack, MonadIO m, IsDrive a) | |
=> a |
|
-> m Icon | Returns: |
Gets the icon for drive
.
getIdentifier
:: (HasCallStack, MonadIO m, IsDrive a) | |
=> a |
|
-> Text |
|
-> m (Maybe Text) | Returns: a newly allocated string containing the
requested identifier, or |
Gets the identifier of the given kind for drive
. The only
identifier currently available is
DRIVE_IDENTIFIER_KIND_UNIX_DEVICE
.
getName
:: (HasCallStack, MonadIO m, IsDrive a) | |
=> a |
|
-> m Text | Returns: a string containing |
Gets the name of drive
.
getSortKey
:: (HasCallStack, MonadIO m, IsDrive a) | |
=> a |
|
-> m (Maybe Text) | Returns: Sorting key for |
Gets the sort key for drive
, if any.
Since: 2.32
getStartStopType
driveGetStartStopType Source #
:: (HasCallStack, MonadIO m, IsDrive a) | |
=> a |
|
-> m DriveStartStopType | Returns: A value from the |
Gets a hint about how a drive can be started/stopped.
Since: 2.22
getSymbolicIcon
:: (HasCallStack, MonadIO m, IsDrive a) | |
=> a |
|
-> m Icon | Returns: symbolic |
Gets the icon for drive
.
Since: 2.34
getVolumes
:: (HasCallStack, MonadIO m, IsDrive a) | |
=> a |
|
-> m [Volume] | Returns: |
Get a list of mountable volumes for drive
.
The returned list should be freed with g_list_free()
, after
its elements have been unreffed with objectUnref
.
hasMedia
:: (HasCallStack, MonadIO m, IsDrive a) | |
=> a |
|
-> m Bool |
Checks if the drive
has media. Note that the OS may not be polling
the drive for media changes; see driveIsMediaCheckAutomatic
for more details.
hasVolumes
:: (HasCallStack, MonadIO m, IsDrive a) | |
=> a |
|
-> m Bool | Returns: |
Check if drive
has any mountable volumes.
isMediaCheckAutomatic
driveIsMediaCheckAutomatic Source #
:: (HasCallStack, MonadIO m, IsDrive a) | |
=> a |
|
-> m Bool | Returns: |
Checks if drive
is capabable of automatically detecting media changes.
isMediaRemovable
driveIsMediaRemovable Source #
:: (HasCallStack, MonadIO m, IsDrive a) | |
=> a |
|
-> m Bool | Returns: |
Checks if the drive
supports removable media.
isRemovable
:: (HasCallStack, MonadIO m, IsDrive a) | |
=> a |
|
-> m Bool | Returns: |
Checks if the Drive
and/or its media is considered removable by the user.
See driveIsMediaRemovable
.
Since: 2.50
pollForMedia
:: (HasCallStack, MonadIO m, IsDrive a, IsCancellable b) | |
=> a |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> m () |
Asynchronously polls drive
to see if media has been inserted or removed.
When the operation is finished, callback
will be called.
You can then call drivePollForMediaFinish
to obtain the
result of the operation.
pollForMediaFinish
drivePollForMediaFinish Source #
:: (HasCallStack, MonadIO m, IsDrive a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m () | (Can throw |
Finishes an operation started with drivePollForMedia
on a drive.
start
:: (HasCallStack, MonadIO m, IsDrive a, IsMountOperation b, IsCancellable c) | |
=> a |
|
-> [DriveStartFlags] |
|
-> Maybe b |
|
-> Maybe c |
|
-> Maybe AsyncReadyCallback |
|
-> m () |
Asynchronously starts a drive.
When the operation is finished, callback
will be called.
You can then call driveStartFinish
to obtain the
result of the operation.
Since: 2.22
startFinish
:: (HasCallStack, MonadIO m, IsDrive a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m () | (Can throw |
Finishes starting a drive.
Since: 2.22
stop
:: (HasCallStack, MonadIO m, IsDrive a, IsMountOperation b, IsCancellable c) | |
=> a |
|
-> [MountUnmountFlags] |
|
-> Maybe b |
|
-> Maybe c |
|
-> Maybe AsyncReadyCallback |
|
-> m () |
Asynchronously stops a drive.
When the operation is finished, callback
will be called.
You can then call driveStopFinish
to obtain the
result of the operation.
Since: 2.22
stopFinish
:: (HasCallStack, MonadIO m, IsDrive a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m () | (Can throw |
Finishes stopping a drive.
Since: 2.22
Signals
changed
type C_DriveChangedCallback = Ptr () -> Ptr () -> IO () Source #
Type for the callback on the (unwrapped) C side.
type DriveChangedCallback = IO () Source #
Emitted when the drive's state has changed.
afterDriveChanged :: (IsDrive a, MonadIO m) => a -> DriveChangedCallback -> m SignalHandlerId Source #
Connect a signal handler for the “changed
” signal, to be run after the default handler.
When overloading is enabled, this is equivalent to
after
drive #changed callback
genClosure_DriveChanged :: MonadIO m => DriveChangedCallback -> m (GClosure C_DriveChangedCallback) Source #
Wrap the callback into a GClosure
.
mk_DriveChangedCallback :: C_DriveChangedCallback -> IO (FunPtr C_DriveChangedCallback) Source #
Generate a function pointer callable from C code, from a C_DriveChangedCallback
.
noDriveChangedCallback :: Maybe DriveChangedCallback Source #
A convenience synonym for
.Nothing
:: Maybe
DriveChangedCallback
onDriveChanged :: (IsDrive a, MonadIO m) => a -> DriveChangedCallback -> m SignalHandlerId Source #
Connect a signal handler for the “changed
” signal, to be run before the default handler.
When overloading is enabled, this is equivalent to
on
drive #changed callback
wrap_DriveChangedCallback :: DriveChangedCallback -> C_DriveChangedCallback Source #
Wrap a DriveChangedCallback
into a C_DriveChangedCallback
.
disconnected
type C_DriveDisconnectedCallback = Ptr () -> Ptr () -> IO () Source #
Type for the callback on the (unwrapped) C side.
type DriveDisconnectedCallback = IO () Source #
This signal is emitted when the Drive
have been
disconnected. If the recipient is holding references to the
object they should release them so the object can be
finalized.
afterDriveDisconnected :: (IsDrive a, MonadIO m) => a -> DriveDisconnectedCallback -> m SignalHandlerId Source #
Connect a signal handler for the “disconnected
” signal, to be run after the default handler.
When overloading is enabled, this is equivalent to
after
drive #disconnected callback
genClosure_DriveDisconnected :: MonadIO m => DriveDisconnectedCallback -> m (GClosure C_DriveDisconnectedCallback) Source #
Wrap the callback into a GClosure
.
mk_DriveDisconnectedCallback :: C_DriveDisconnectedCallback -> IO (FunPtr C_DriveDisconnectedCallback) Source #
Generate a function pointer callable from C code, from a C_DriveDisconnectedCallback
.
noDriveDisconnectedCallback :: Maybe DriveDisconnectedCallback Source #
A convenience synonym for
.Nothing
:: Maybe
DriveDisconnectedCallback
onDriveDisconnected :: (IsDrive a, MonadIO m) => a -> DriveDisconnectedCallback -> m SignalHandlerId Source #
Connect a signal handler for the “disconnected
” signal, to be run before the default handler.
When overloading is enabled, this is equivalent to
on
drive #disconnected callback
wrap_DriveDisconnectedCallback :: DriveDisconnectedCallback -> C_DriveDisconnectedCallback Source #
Wrap a DriveDisconnectedCallback
into a C_DriveDisconnectedCallback
.
ejectButton
type C_DriveEjectButtonCallback = Ptr () -> Ptr () -> IO () Source #
Type for the callback on the (unwrapped) C side.
type DriveEjectButtonCallback = IO () Source #
Emitted when the physical eject button (if any) of a drive has been pressed.
afterDriveEjectButton :: (IsDrive a, MonadIO m) => a -> DriveEjectButtonCallback -> m SignalHandlerId Source #
Connect a signal handler for the “eject-button
” signal, to be run after the default handler.
When overloading is enabled, this is equivalent to
after
drive #ejectButton callback
genClosure_DriveEjectButton :: MonadIO m => DriveEjectButtonCallback -> m (GClosure C_DriveEjectButtonCallback) Source #
Wrap the callback into a GClosure
.
mk_DriveEjectButtonCallback :: C_DriveEjectButtonCallback -> IO (FunPtr C_DriveEjectButtonCallback) Source #
Generate a function pointer callable from C code, from a C_DriveEjectButtonCallback
.
noDriveEjectButtonCallback :: Maybe DriveEjectButtonCallback Source #
A convenience synonym for
.Nothing
:: Maybe
DriveEjectButtonCallback
onDriveEjectButton :: (IsDrive a, MonadIO m) => a -> DriveEjectButtonCallback -> m SignalHandlerId Source #
Connect a signal handler for the “eject-button
” signal, to be run before the default handler.
When overloading is enabled, this is equivalent to
on
drive #ejectButton callback
wrap_DriveEjectButtonCallback :: DriveEjectButtonCallback -> C_DriveEjectButtonCallback Source #
Wrap a DriveEjectButtonCallback
into a C_DriveEjectButtonCallback
.
stopButton
type C_DriveStopButtonCallback = Ptr () -> Ptr () -> IO () Source #
Type for the callback on the (unwrapped) C side.
type DriveStopButtonCallback = IO () Source #
Emitted when the physical stop button (if any) of a drive has been pressed.
Since: 2.22
afterDriveStopButton :: (IsDrive a, MonadIO m) => a -> DriveStopButtonCallback -> m SignalHandlerId Source #
Connect a signal handler for the “stop-button
” signal, to be run after the default handler.
When overloading is enabled, this is equivalent to
after
drive #stopButton callback
genClosure_DriveStopButton :: MonadIO m => DriveStopButtonCallback -> m (GClosure C_DriveStopButtonCallback) Source #
Wrap the callback into a GClosure
.
mk_DriveStopButtonCallback :: C_DriveStopButtonCallback -> IO (FunPtr C_DriveStopButtonCallback) Source #
Generate a function pointer callable from C code, from a C_DriveStopButtonCallback
.
noDriveStopButtonCallback :: Maybe DriveStopButtonCallback Source #
A convenience synonym for
.Nothing
:: Maybe
DriveStopButtonCallback
onDriveStopButton :: (IsDrive a, MonadIO m) => a -> DriveStopButtonCallback -> m SignalHandlerId Source #
Connect a signal handler for the “stop-button
” signal, to be run before the default handler.
When overloading is enabled, this is equivalent to
on
drive #stopButton callback