{-# LINE 2 "./System/GIO/Volumes/Drive.chs" #-}
-- GIMP Toolkit (GTK) Binding for Haskell: binding to gio -*-haskell-*-
--
-- Author : Andy Stewart
-- Created: 30-Apirl-2010
--
-- Copyright (c) 2010 Andy Stewart
--
-- This library is free software: you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public License
-- as published by the Free Software Foundation, either version 3 of
-- the License, or (at your option) any later version.
--
-- This library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- Lesser General Public License for more details.
--
-- You should have received a copy of the GNU Lesser General Public
-- License along with this program. If not, see
-- <http:
--
-- GIO, the C library which this Haskell library depends on, is
-- available under LGPL Version 2. The documentation included with
-- this library is based on the original GIO documentation.
--
-- | Maintainer : gtk2hs-devel@lists.sourceforge.net
-- Stability : alpha
-- Portability : portable (depends on GHC)
module System.GIO.Volumes.Drive (
-- * Details
--
-- | '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 potentially 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.

-- * Types
    Drive(..),
    DriveClass,

-- * Enums,

    DriveStartStopType (..),
    DriveStartFlags (..),


-- * Methods
    driveGetName,
    driveGetIcon,
    driveHasVolumes,
    driveGetVolumes,
    driveCanEject,

    driveGetStartStopType,
    driveCanStart,
    driveCanStartDegraded,
    driveCanStop,

    driveCanPollForMedia,
    drivePollForMedia,
    driveHasMedia,
    driveIsMediaCheckAutomatic,
    driveIsMediaRemovable,

    driveEjectWithOperation,
    driveEjectWithOperationFinish,
    driveStart,
    driveStartFinish,
    driveStopFinish,

    driveEnumerateIdentifiers,
    driveGetIdentifier,

-- * Signals
    driveChanged,
    driveDisconnected,
    driveEjectButton,

    driveStopButton,

    ) where

import Control.Monad
import Data.Maybe (fromMaybe)
import System.GIO.Enums
import System.Glib.Attributes
import System.Glib.FFI
import System.Glib.Flags
import System.Glib.GError
import System.Glib.GList
import System.Glib.GObject
import System.Glib.Properties
import System.Glib.Signals
import System.Glib.UTFString
import System.GIO.Async.AsyncResult
{-# LINE 113 "./System/GIO/Volumes/Drive.chs" #-}
import System.GIO.Signals
{-# LINE 114 "./System/GIO/Volumes/Drive.chs" #-}
import System.GIO.Types
{-# LINE 115 "./System/GIO/Volumes/Drive.chs" #-}


{-# LINE 117 "./System/GIO/Volumes/Drive.chs" #-}

--------------------
-- Methods
-- | Gets the name of drive.
driveGetName :: (DriveClass drive, GlibString string) => drive
 -> IO string -- ^ returns the name for the given drive.
driveGetName :: forall drive string.
(DriveClass drive, GlibString string) =>
drive -> IO string
driveGetName drive
drive =
  (\(Drive ForeignPtr Drive
arg1) -> ForeignPtr Drive -> (Ptr Drive -> IO (Ptr CChar)) -> IO (Ptr CChar)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Drive
arg1 ((Ptr Drive -> IO (Ptr CChar)) -> IO (Ptr CChar))
-> (Ptr Drive -> IO (Ptr CChar)) -> IO (Ptr CChar)
forall a b. (a -> b) -> a -> b
$ \Ptr Drive
argPtr1 ->Ptr Drive -> IO (Ptr CChar)
g_drive_get_name Ptr Drive
argPtr1) (drive -> Drive
forall o. DriveClass o => o -> Drive
toDrive drive
drive)
  IO (Ptr CChar) -> (Ptr CChar -> IO string) -> IO string
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Ptr CChar -> IO string
forall s. GlibString s => Ptr CChar -> IO s
readUTFString

-- | Gets the icon for drive.
driveGetIcon :: DriveClass drive => drive
 -> IO Icon -- ^ returns a 'Icon'.
driveGetIcon :: forall drive. DriveClass drive => drive -> IO Icon
driveGetIcon drive
drive =
  (ForeignPtr Icon -> Icon, FinalizerPtr Icon)
-> IO (Ptr Icon) -> IO Icon
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
wrapNewGObject (ForeignPtr Icon -> Icon, FinalizerPtr Icon)
forall {a}. (ForeignPtr Icon -> Icon, FinalizerPtr a)
mkIcon (IO (Ptr Icon) -> IO Icon) -> IO (Ptr Icon) -> IO Icon
forall a b. (a -> b) -> a -> b
$
  (\(Drive ForeignPtr Drive
arg1) -> ForeignPtr Drive -> (Ptr Drive -> IO (Ptr Icon)) -> IO (Ptr Icon)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Drive
arg1 ((Ptr Drive -> IO (Ptr Icon)) -> IO (Ptr Icon))
-> (Ptr Drive -> IO (Ptr Icon)) -> IO (Ptr Icon)
forall a b. (a -> b) -> a -> b
$ \Ptr Drive
argPtr1 ->Ptr Drive -> IO (Ptr Icon)
g_drive_get_icon Ptr Drive
argPtr1) (drive -> Drive
forall o. DriveClass o => o -> Drive
toDrive drive
drive)

-- | Check if drive has any mountable volumes.
driveHasVolumes :: DriveClass drive => drive
 -> IO Bool -- ^ returns 'True' if the drive contains volumes, 'False' otherwise.
driveHasVolumes :: forall drive. DriveClass drive => drive -> IO Bool
driveHasVolumes drive
drive =
  (CInt -> Bool) -> IO CInt -> IO Bool
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CInt -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (IO CInt -> IO Bool) -> IO CInt -> IO Bool
forall a b. (a -> b) -> a -> b
$
  (\(Drive ForeignPtr Drive
arg1) -> ForeignPtr Drive -> (Ptr Drive -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Drive
arg1 ((Ptr Drive -> IO CInt) -> IO CInt)
-> (Ptr Drive -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Drive
argPtr1 ->Ptr Drive -> IO CInt
g_drive_has_volumes Ptr Drive
argPtr1) (drive -> Drive
forall o. DriveClass o => o -> Drive
toDrive drive
drive)

-- | Get a list of mountable volumes for drive.
driveGetVolumes :: DriveClass drive => drive
 -> IO [Volume]
driveGetVolumes :: forall drive. DriveClass drive => drive -> IO [Volume]
driveGetVolumes drive
drive = do
  Ptr ()
glistPtr <- (\(Drive ForeignPtr Drive
arg1) -> ForeignPtr Drive -> (Ptr Drive -> IO (Ptr ())) -> IO (Ptr ())
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Drive
arg1 ((Ptr Drive -> IO (Ptr ())) -> IO (Ptr ()))
-> (Ptr Drive -> IO (Ptr ())) -> IO (Ptr ())
forall a b. (a -> b) -> a -> b
$ \Ptr Drive
argPtr1 ->Ptr Drive -> IO (Ptr ())
g_drive_get_volumes Ptr Drive
argPtr1) (drive -> Drive
forall o. DriveClass o => o -> Drive
toDrive drive
drive)
  [Ptr Volume]
volumePtrs <- Ptr () -> IO [Ptr Volume]
forall a. Ptr () -> IO [Ptr a]
fromGList Ptr ()
glistPtr
  (Ptr Volume -> IO Volume) -> [Ptr Volume] -> IO [Volume]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM ((ForeignPtr Volume -> Volume, FinalizerPtr Volume)
-> IO (Ptr Volume) -> IO Volume
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
wrapNewGObject (ForeignPtr Volume -> Volume, FinalizerPtr Volume)
forall {a}. (ForeignPtr Volume -> Volume, FinalizerPtr a)
mkVolume (IO (Ptr Volume) -> IO Volume)
-> (Ptr Volume -> IO (Ptr Volume)) -> Ptr Volume -> IO Volume
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr Volume -> IO (Ptr Volume)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return) [Ptr Volume]
volumePtrs

-- | Checks if drive can be eject.
driveCanEject :: DriveClass drive => drive
 -> IO Bool -- ^ returns 'True' if the drive can be ejected.
driveCanEject :: forall drive. DriveClass drive => drive -> IO Bool
driveCanEject drive
drive =
  (CInt -> Bool) -> IO CInt -> IO Bool
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CInt -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (IO CInt -> IO Bool) -> IO CInt -> IO Bool
forall a b. (a -> b) -> a -> b
$
  (\(Drive ForeignPtr Drive
arg1) -> ForeignPtr Drive -> (Ptr Drive -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Drive
arg1 ((Ptr Drive -> IO CInt) -> IO CInt)
-> (Ptr Drive -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Drive
argPtr1 ->Ptr Drive -> IO CInt
g_drive_can_eject Ptr Drive
argPtr1) (drive -> Drive
forall o. DriveClass o => o -> Drive
toDrive drive
drive)


-- | Gets a hint about how a drive can be started/stopped.
driveGetStartStopType :: DriveClass drive => drive
 -> IO DriveStartStopType -- ^ returns A value from the 'DriveStartStopType' enumeration.
driveGetStartStopType :: forall drive. DriveClass drive => drive -> IO DriveStartStopType
driveGetStartStopType drive
drive =
  (CInt -> DriveStartStopType) -> IO CInt -> IO DriveStartStopType
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (Int -> DriveStartStopType
forall a. Enum a => Int -> a
toEnum (Int -> DriveStartStopType)
-> (CInt -> Int) -> CInt -> DriveStartStopType
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) (IO CInt -> IO DriveStartStopType)
-> IO CInt -> IO DriveStartStopType
forall a b. (a -> b) -> a -> b
$
  (\(Drive ForeignPtr Drive
arg1) -> ForeignPtr Drive -> (Ptr Drive -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Drive
arg1 ((Ptr Drive -> IO CInt) -> IO CInt)
-> (Ptr Drive -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Drive
argPtr1 ->Ptr Drive -> IO CInt
g_drive_get_start_stop_type Ptr Drive
argPtr1) (drive -> Drive
forall o. DriveClass o => o -> Drive
toDrive drive
drive)

-- | Checks if a drive can be started.
driveCanStart :: DriveClass drive => drive
 -> IO Bool -- ^ returns 'True' if the drive can be started, 'False' otherwise.
driveCanStart :: forall drive. DriveClass drive => drive -> IO Bool
driveCanStart drive
drive =
  (CInt -> Bool) -> IO CInt -> IO Bool
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CInt -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (IO CInt -> IO Bool) -> IO CInt -> IO Bool
forall a b. (a -> b) -> a -> b
$
  (\(Drive ForeignPtr Drive
arg1) -> ForeignPtr Drive -> (Ptr Drive -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Drive
arg1 ((Ptr Drive -> IO CInt) -> IO CInt)
-> (Ptr Drive -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Drive
argPtr1 ->Ptr Drive -> IO CInt
g_drive_can_start Ptr Drive
argPtr1) (drive -> Drive
forall o. DriveClass o => o -> Drive
toDrive drive
drive)

-- | Checks if a drive can be started degraded.
driveCanStartDegraded :: DriveClass drive => drive
 -> IO Bool -- ^ returns 'True' if the drive can be started degraded, 'False' otherwise.
driveCanStartDegraded :: forall drive. DriveClass drive => drive -> IO Bool
driveCanStartDegraded drive
drive =
  (CInt -> Bool) -> IO CInt -> IO Bool
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CInt -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (IO CInt -> IO Bool) -> IO CInt -> IO Bool
forall a b. (a -> b) -> a -> b
$
  (\(Drive ForeignPtr Drive
arg1) -> ForeignPtr Drive -> (Ptr Drive -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Drive
arg1 ((Ptr Drive -> IO CInt) -> IO CInt)
-> (Ptr Drive -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Drive
argPtr1 ->Ptr Drive -> IO CInt
g_drive_can_start_degraded Ptr Drive
argPtr1) (drive -> Drive
forall o. DriveClass o => o -> Drive
toDrive drive
drive)

-- | Checks if a drive can be stopped.
driveCanStop :: DriveClass drive => drive
 -> IO Bool -- ^ returns 'True' if the drive can be stopped, 'False' otherwise.
driveCanStop :: forall drive. DriveClass drive => drive -> IO Bool
driveCanStop drive
drive =
  (CInt -> Bool) -> IO CInt -> IO Bool
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CInt -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (IO CInt -> IO Bool) -> IO CInt -> IO Bool
forall a b. (a -> b) -> a -> b
$
  (\(Drive ForeignPtr Drive
arg1) -> ForeignPtr Drive -> (Ptr Drive -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Drive
arg1 ((Ptr Drive -> IO CInt) -> IO CInt)
-> (Ptr Drive -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Drive
argPtr1 ->Ptr Drive -> IO CInt
g_drive_can_stop Ptr Drive
argPtr1) (drive -> Drive
forall o. DriveClass o => o -> Drive
toDrive drive
drive)


-- | Checks if a drive can be polled for media changes.
driveCanPollForMedia :: DriveClass drive => drive
 -> IO Bool
driveCanPollForMedia :: forall drive. DriveClass drive => drive -> IO Bool
driveCanPollForMedia drive
drive =
  (CInt -> Bool) -> IO CInt -> IO Bool
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CInt -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (IO CInt -> IO Bool) -> IO CInt -> IO Bool
forall a b. (a -> b) -> a -> b
$
  (\(Drive ForeignPtr Drive
arg1) -> ForeignPtr Drive -> (Ptr Drive -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Drive
arg1 ((Ptr Drive -> IO CInt) -> IO CInt)
-> (Ptr Drive -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Drive
argPtr1 ->Ptr Drive -> IO CInt
g_drive_can_poll_for_media Ptr Drive
argPtr1) (drive -> Drive
forall o. DriveClass o => o -> Drive
toDrive drive
drive)

-- | 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.
drivePollForMedia :: DriveClass drive => drive
 -> Maybe Cancellable
 -> AsyncReadyCallback
 -> IO ()
drivePollForMedia :: forall drive.
DriveClass drive =>
drive -> Maybe Cancellable -> AsyncReadyCallback -> IO ()
drivePollForMedia drive
drive Maybe Cancellable
cancellable AsyncReadyCallback
callback = do
      GAsyncReadyCallback
cCallback <- AsyncReadyCallback -> IO GAsyncReadyCallback
marshalAsyncReadyCallback AsyncReadyCallback
callback
      (\(Drive ForeignPtr Drive
arg1) (Cancellable ForeignPtr Cancellable
arg2) GAsyncReadyCallback
arg3 Ptr ()
arg4 -> ForeignPtr Drive -> (Ptr Drive -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Drive
arg1 ((Ptr Drive -> IO ()) -> IO ()) -> (Ptr Drive -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Drive
argPtr1 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg2 ((Ptr Cancellable -> IO ()) -> IO ())
-> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr2 ->Ptr Drive
-> Ptr Cancellable -> GAsyncReadyCallback -> Ptr () -> IO ()
g_drive_poll_for_media Ptr Drive
argPtr1 Ptr Cancellable
argPtr2 GAsyncReadyCallback
arg3 Ptr ()
arg4)
{-# LINE 204 "./System/GIO/Volumes/Drive.chs" #-}
        (drive -> Drive
forall o. DriveClass o => o -> Drive
toDrive drive
drive)
        (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
        GAsyncReadyCallback
cCallback
        (GAsyncReadyCallback -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr GAsyncReadyCallback
cCallback)

-- | Finishes an operation started with 'drivePollForMedia' on a drive.
--
-- Throws a 'GError' if an error occurs.
drivePollForMediaFinish :: DriveClass drive => drive
 -> AsyncResult -- ^ @result@ a 'AsyncResult'.
 -> IO ()
drivePollForMediaFinish :: forall drive. DriveClass drive => drive -> AsyncResult -> IO ()
drivePollForMediaFinish drive
drive AsyncResult
result =
    (Ptr (Ptr ()) -> IO ()) -> IO ()
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError (\Ptr (Ptr ())
gErrorPtr -> do
                       (\(Drive ForeignPtr Drive
arg1) (AsyncResult ForeignPtr AsyncResult
arg2) Ptr (Ptr ())
arg3 -> ForeignPtr Drive -> (Ptr Drive -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Drive
arg1 ((Ptr Drive -> IO CInt) -> IO CInt)
-> (Ptr Drive -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Drive
argPtr1 ->ForeignPtr AsyncResult -> (Ptr AsyncResult -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr AsyncResult
arg2 ((Ptr AsyncResult -> IO CInt) -> IO CInt)
-> (Ptr AsyncResult -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr AsyncResult
argPtr2 ->Ptr Drive -> Ptr AsyncResult -> Ptr (Ptr ()) -> IO CInt
g_drive_poll_for_media_finish Ptr Drive
argPtr1 Ptr AsyncResult
argPtr2 Ptr (Ptr ())
arg3)
{-# LINE 218 "./System/GIO/Volumes/Drive.chs" #-}
                          (drive -> Drive
forall o. DriveClass o => o -> Drive
toDrive drive
drive)
                          AsyncResult
result
                          Ptr (Ptr ())
gErrorPtr
                       () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ())

-- | Checks if the drive has media. Note that the OS may not be polling the drive for media changes; see
-- 'driveIsMediaCheckAutomatic' for more details.
driveHasMedia :: DriveClass drive => drive
 -> IO Bool -- ^ returns 'True' if drive has media, 'False' otherwise.
driveHasMedia :: forall drive. DriveClass drive => drive -> IO Bool
driveHasMedia drive
drive =
  (CInt -> Bool) -> IO CInt -> IO Bool
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CInt -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (IO CInt -> IO Bool) -> IO CInt -> IO Bool
forall a b. (a -> b) -> a -> b
$
  (\(Drive ForeignPtr Drive
arg1) -> ForeignPtr Drive -> (Ptr Drive -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Drive
arg1 ((Ptr Drive -> IO CInt) -> IO CInt)
-> (Ptr Drive -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Drive
argPtr1 ->Ptr Drive -> IO CInt
g_drive_has_media Ptr Drive
argPtr1) (drive -> Drive
forall o. DriveClass o => o -> Drive
toDrive drive
drive)

-- | Checks if drive is capable of automatically detecting media changes.
driveIsMediaCheckAutomatic :: DriveClass drive => drive
 -> IO Bool -- ^ returns 'True' if the drive is capable of automatically detecting media changes, 'False' otherwise.
driveIsMediaCheckAutomatic :: forall drive. DriveClass drive => drive -> IO Bool
driveIsMediaCheckAutomatic drive
drive =
  (CInt -> Bool) -> IO CInt -> IO Bool
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CInt -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (IO CInt -> IO Bool) -> IO CInt -> IO Bool
forall a b. (a -> b) -> a -> b
$
  (\(Drive ForeignPtr Drive
arg1) -> ForeignPtr Drive -> (Ptr Drive -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Drive
arg1 ((Ptr Drive -> IO CInt) -> IO CInt)
-> (Ptr Drive -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Drive
argPtr1 ->Ptr Drive -> IO CInt
g_drive_is_media_check_automatic Ptr Drive
argPtr1) (drive -> Drive
forall o. DriveClass o => o -> Drive
toDrive drive
drive)

-- | Checks if the drive supports removable media.
driveIsMediaRemovable :: DriveClass drive => drive
 -> IO Bool -- ^ returns 'True' if drive supports removable media, 'False' otherwise.
driveIsMediaRemovable :: forall drive. DriveClass drive => drive -> IO Bool
driveIsMediaRemovable drive
drive =
  (CInt -> Bool) -> IO CInt -> IO Bool
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CInt -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (IO CInt -> IO Bool) -> IO CInt -> IO Bool
forall a b. (a -> b) -> a -> b
$
  (\(Drive ForeignPtr Drive
arg1) -> ForeignPtr Drive -> (Ptr Drive -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Drive
arg1 ((Ptr Drive -> IO CInt) -> IO CInt)
-> (Ptr Drive -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Drive
argPtr1 ->Ptr Drive -> IO CInt
g_drive_is_media_removable Ptr Drive
argPtr1) (drive -> Drive
forall o. DriveClass o => o -> Drive
toDrive drive
drive)


-- | Ejects a drive. This is an asynchronous operation, and is finished by calling
-- 'driveEjectWithOperationFinish' with the drive and 'AsyncResult' data returned in the callback.
driveEjectWithOperation :: DriveClass drive
 => drive
 -> [MountUnmountFlags] -- ^ @flags@ flags affecting the unmount if required for eject
 -> Maybe MountOperation -- ^ @mountOperation@ a 'MountOperation' or 'Nothing' to avoid user interaction.
 -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore.
 -> AsyncReadyCallback -- ^ @callback@ a 'AsyncReadyCallback'
 -> IO ()
driveEjectWithOperation :: forall drive.
DriveClass drive =>
drive
-> [MountUnmountFlags]
-> Maybe MountOperation
-> Maybe Cancellable
-> AsyncReadyCallback
-> IO ()
driveEjectWithOperation drive
drive [MountUnmountFlags]
flags Maybe MountOperation
mountOperation Maybe Cancellable
cancellable AsyncReadyCallback
callback = do
      GAsyncReadyCallback
cCallback <- AsyncReadyCallback -> IO GAsyncReadyCallback
marshalAsyncReadyCallback AsyncReadyCallback
callback
      (\(Drive ForeignPtr Drive
arg1) CInt
arg2 (MountOperation ForeignPtr MountOperation
arg3) (Cancellable ForeignPtr Cancellable
arg4) GAsyncReadyCallback
arg5 Ptr ()
arg6 -> ForeignPtr Drive -> (Ptr Drive -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Drive
arg1 ((Ptr Drive -> IO ()) -> IO ()) -> (Ptr Drive -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Drive
argPtr1 ->ForeignPtr MountOperation -> (Ptr MountOperation -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr MountOperation
arg3 ((Ptr MountOperation -> IO ()) -> IO ())
-> (Ptr MountOperation -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr MountOperation
argPtr3 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg4 ((Ptr Cancellable -> IO ()) -> IO ())
-> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr4 ->Ptr Drive
-> CInt
-> Ptr MountOperation
-> Ptr Cancellable
-> GAsyncReadyCallback
-> Ptr ()
-> IO ()
g_drive_eject_with_operation Ptr Drive
argPtr1 CInt
arg2 Ptr MountOperation
argPtr3 Ptr Cancellable
argPtr4 GAsyncReadyCallback
arg5 Ptr ()
arg6)
{-# LINE 258 "./System/GIO/Volumes/Drive.chs" #-}
        (drive -> Drive
forall o. DriveClass o => o -> Drive
toDrive drive
drive)
        ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> ([MountUnmountFlags] -> Int) -> [MountUnmountFlags] -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [MountUnmountFlags] -> Int
forall a. Flags a => [a] -> Int
fromFlags) [MountUnmountFlags]
flags)
        (MountOperation -> Maybe MountOperation -> MountOperation
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr MountOperation -> MountOperation
MountOperation ForeignPtr MountOperation
forall a. ForeignPtr a
nullForeignPtr) Maybe MountOperation
mountOperation)
        (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
        GAsyncReadyCallback
cCallback
        (GAsyncReadyCallback -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr GAsyncReadyCallback
cCallback)

-- | Finishes ejecting a drive. If any errors occurred during the operation, error will be set to contain
-- the errors and 'False' will be returned.
--
-- Throws a 'GError' if an error occurs.
driveEjectWithOperationFinish :: DriveClass drive
 => drive
 -> AsyncResult -- ^ @result@ a 'AsyncResult'.
 -> IO ()
driveEjectWithOperationFinish :: forall drive. DriveClass drive => drive -> AsyncResult -> IO ()
driveEjectWithOperationFinish drive
drive AsyncResult
result =
    (Ptr (Ptr ()) -> IO ()) -> IO ()
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError (\Ptr (Ptr ())
gErrorPtr -> do
                        (\(Drive ForeignPtr Drive
arg1) (AsyncResult ForeignPtr AsyncResult
arg2) Ptr (Ptr ())
arg3 -> ForeignPtr Drive -> (Ptr Drive -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Drive
arg1 ((Ptr Drive -> IO CInt) -> IO CInt)
-> (Ptr Drive -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Drive
argPtr1 ->ForeignPtr AsyncResult -> (Ptr AsyncResult -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr AsyncResult
arg2 ((Ptr AsyncResult -> IO CInt) -> IO CInt)
-> (Ptr AsyncResult -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr AsyncResult
argPtr2 ->Ptr Drive -> Ptr AsyncResult -> Ptr (Ptr ()) -> IO CInt
g_drive_eject_with_operation_finish Ptr Drive
argPtr1 Ptr AsyncResult
argPtr2 Ptr (Ptr ())
arg3)
{-# LINE 276 "./System/GIO/Volumes/Drive.chs" #-}
                           (drive -> Drive
forall o. DriveClass o => o -> Drive
toDrive drive
drive)
                           AsyncResult
result
                           Ptr (Ptr ())
gErrorPtr
                        () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ())

-- | 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.
driveStart :: DriveClass drive
 => drive
 -> [DriveStartFlags] -- ^ @flags@ flags affecting the start operation.
 -> Maybe MountOperation -- ^ @mountOperation@ a 'MountOperation' or 'Nothing' to avoid user interaction.
 -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore.
 -> AsyncReadyCallback -- ^ @callback@ a 'AsyncReadyCallback'
 -> IO ()
driveStart :: forall drive.
DriveClass drive =>
drive
-> [DriveStartFlags]
-> Maybe MountOperation
-> Maybe Cancellable
-> AsyncReadyCallback
-> IO ()
driveStart drive
drive [DriveStartFlags]
flags Maybe MountOperation
mountOperation Maybe Cancellable
cancellable AsyncReadyCallback
callback = do
      GAsyncReadyCallback
cCallback <- AsyncReadyCallback -> IO GAsyncReadyCallback
marshalAsyncReadyCallback AsyncReadyCallback
callback
      (\(Drive ForeignPtr Drive
arg1) CInt
arg2 (MountOperation ForeignPtr MountOperation
arg3) (Cancellable ForeignPtr Cancellable
arg4) GAsyncReadyCallback
arg5 Ptr ()
arg6 -> ForeignPtr Drive -> (Ptr Drive -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Drive
arg1 ((Ptr Drive -> IO ()) -> IO ()) -> (Ptr Drive -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Drive
argPtr1 ->ForeignPtr MountOperation -> (Ptr MountOperation -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr MountOperation
arg3 ((Ptr MountOperation -> IO ()) -> IO ())
-> (Ptr MountOperation -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr MountOperation
argPtr3 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg4 ((Ptr Cancellable -> IO ()) -> IO ())
-> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr4 ->Ptr Drive
-> CInt
-> Ptr MountOperation
-> Ptr Cancellable
-> GAsyncReadyCallback
-> Ptr ()
-> IO ()
g_drive_start Ptr Drive
argPtr1 CInt
arg2 Ptr MountOperation
argPtr3 Ptr Cancellable
argPtr4 GAsyncReadyCallback
arg5 Ptr ()
arg6)
{-# LINE 295 "./System/GIO/Volumes/Drive.chs" #-}
        (drive -> Drive
forall o. DriveClass o => o -> Drive
toDrive drive
drive)
        ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> ([DriveStartFlags] -> Int) -> [DriveStartFlags] -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [DriveStartFlags] -> Int
forall a. Flags a => [a] -> Int
fromFlags) [DriveStartFlags]
flags)
        (MountOperation -> Maybe MountOperation -> MountOperation
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr MountOperation -> MountOperation
MountOperation ForeignPtr MountOperation
forall a. ForeignPtr a
nullForeignPtr) Maybe MountOperation
mountOperation)
        (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
        GAsyncReadyCallback
cCallback
        (GAsyncReadyCallback -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr GAsyncReadyCallback
cCallback)

-- | Finishes starting a drive.
--
-- Throws a 'GError' if an error occurs.
driveStartFinish :: DriveClass drive
 => drive
 -> AsyncResult -- ^ @result@ a 'AsyncResult'.
 -> IO ()
driveStartFinish :: forall drive. DriveClass drive => drive -> AsyncResult -> IO ()
driveStartFinish drive
drive AsyncResult
result =
    (Ptr (Ptr ()) -> IO ()) -> IO ()
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError (\Ptr (Ptr ())
gErrorPtr -> do
                       (\(Drive ForeignPtr Drive
arg1) (AsyncResult ForeignPtr AsyncResult
arg2) Ptr (Ptr ())
arg3 -> ForeignPtr Drive -> (Ptr Drive -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Drive
arg1 ((Ptr Drive -> IO CInt) -> IO CInt)
-> (Ptr Drive -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Drive
argPtr1 ->ForeignPtr AsyncResult -> (Ptr AsyncResult -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr AsyncResult
arg2 ((Ptr AsyncResult -> IO CInt) -> IO CInt)
-> (Ptr AsyncResult -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr AsyncResult
argPtr2 ->Ptr Drive -> Ptr AsyncResult -> Ptr (Ptr ()) -> IO CInt
g_drive_start_finish Ptr Drive
argPtr1 Ptr AsyncResult
argPtr2 Ptr (Ptr ())
arg3)
{-# LINE 312 "./System/GIO/Volumes/Drive.chs" #-}
                           (drive -> Drive
forall o. DriveClass o => o -> Drive
toDrive drive
drive)
                           AsyncResult
result
                           Ptr (Ptr ())
gErrorPtr
                       () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ())

-- | 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.
driveStop :: DriveClass drive
 => drive
 -> [MountUnmountFlags] -- ^ @flags@ flags affecting the stop operation.
 -> Maybe MountOperation -- ^ @mountOperation@ a 'MountOperation' or 'Nothing' to avoid user interaction.
 -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore.
 -> AsyncReadyCallback -- ^ @callback@ a 'AsyncReadyCallback'
 -> IO ()
driveStop :: forall drive.
DriveClass drive =>
drive
-> [MountUnmountFlags]
-> Maybe MountOperation
-> Maybe Cancellable
-> AsyncReadyCallback
-> IO ()
driveStop drive
drive [MountUnmountFlags]
flags Maybe MountOperation
mountOperation Maybe Cancellable
cancellable AsyncReadyCallback
callback = do
      GAsyncReadyCallback
cCallback <- AsyncReadyCallback -> IO GAsyncReadyCallback
marshalAsyncReadyCallback AsyncReadyCallback
callback
      (\(Drive ForeignPtr Drive
arg1) CInt
arg2 (MountOperation ForeignPtr MountOperation
arg3) (Cancellable ForeignPtr Cancellable
arg4) GAsyncReadyCallback
arg5 Ptr ()
arg6 -> ForeignPtr Drive -> (Ptr Drive -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Drive
arg1 ((Ptr Drive -> IO ()) -> IO ()) -> (Ptr Drive -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Drive
argPtr1 ->ForeignPtr MountOperation -> (Ptr MountOperation -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr MountOperation
arg3 ((Ptr MountOperation -> IO ()) -> IO ())
-> (Ptr MountOperation -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr MountOperation
argPtr3 ->ForeignPtr Cancellable -> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Cancellable
arg4 ((Ptr Cancellable -> IO ()) -> IO ())
-> (Ptr Cancellable -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Cancellable
argPtr4 ->Ptr Drive
-> CInt
-> Ptr MountOperation
-> Ptr Cancellable
-> GAsyncReadyCallback
-> Ptr ()
-> IO ()
g_drive_stop Ptr Drive
argPtr1 CInt
arg2 Ptr MountOperation
argPtr3 Ptr Cancellable
argPtr4 GAsyncReadyCallback
arg5 Ptr ()
arg6)
{-# LINE 331 "./System/GIO/Volumes/Drive.chs" #-}
        (drive -> Drive
forall o. DriveClass o => o -> Drive
toDrive drive
drive)
        ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt)
-> ([MountUnmountFlags] -> Int) -> [MountUnmountFlags] -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [MountUnmountFlags] -> Int
forall a. Flags a => [a] -> Int
fromFlags) [MountUnmountFlags]
flags)
        (MountOperation -> Maybe MountOperation -> MountOperation
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr MountOperation -> MountOperation
MountOperation ForeignPtr MountOperation
forall a. ForeignPtr a
nullForeignPtr) Maybe MountOperation
mountOperation)
        (Cancellable -> Maybe Cancellable -> Cancellable
forall a. a -> Maybe a -> a
fromMaybe (ForeignPtr Cancellable -> Cancellable
Cancellable ForeignPtr Cancellable
forall a. ForeignPtr a
nullForeignPtr) Maybe Cancellable
cancellable)
        GAsyncReadyCallback
cCallback
        (GAsyncReadyCallback -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr GAsyncReadyCallback
cCallback)

-- | Finishes stopping a drive.
--
-- Throws a 'GError' if an error occurs.
driveStopFinish :: DriveClass drive
 => drive
 -> AsyncResult -- ^ @result@ a 'AsyncResult'.
 -> IO ()
driveStopFinish :: forall drive. DriveClass drive => drive -> AsyncResult -> IO ()
driveStopFinish drive
drive AsyncResult
result =
    (Ptr (Ptr ()) -> IO ()) -> IO ()
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError (\Ptr (Ptr ())
gErrorPtr -> do
                        (\(Drive ForeignPtr Drive
arg1) (AsyncResult ForeignPtr AsyncResult
arg2) Ptr (Ptr ())
arg3 -> ForeignPtr Drive -> (Ptr Drive -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Drive
arg1 ((Ptr Drive -> IO CInt) -> IO CInt)
-> (Ptr Drive -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Drive
argPtr1 ->ForeignPtr AsyncResult -> (Ptr AsyncResult -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr AsyncResult
arg2 ((Ptr AsyncResult -> IO CInt) -> IO CInt)
-> (Ptr AsyncResult -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr AsyncResult
argPtr2 ->Ptr Drive -> Ptr AsyncResult -> Ptr (Ptr ()) -> IO CInt
g_drive_stop_finish Ptr Drive
argPtr1 Ptr AsyncResult
argPtr2 Ptr (Ptr ())
arg3)
{-# LINE 348 "./System/GIO/Volumes/Drive.chs" #-}
                             (drive -> Drive
forall o. DriveClass o => o -> Drive
toDrive drive
drive)
                             AsyncResult
result
                             Ptr (Ptr ())
gErrorPtr
                        () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ())


-- | Gets the kinds of identifiers that drive has. Use 'driveGetIdentifier' to obtain the
-- identifiers themselves.
driveEnumerateIdentifiers :: (DriveClass drive, GlibString string) => drive
                           -> IO [string]
driveEnumerateIdentifiers :: forall drive string.
(DriveClass drive, GlibString string) =>
drive -> IO [string]
driveEnumerateIdentifiers drive
drive =
  (\(Drive ForeignPtr Drive
arg1) -> ForeignPtr Drive
-> (Ptr Drive -> IO (Ptr (Ptr CChar))) -> IO (Ptr (Ptr CChar))
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Drive
arg1 ((Ptr Drive -> IO (Ptr (Ptr CChar))) -> IO (Ptr (Ptr CChar)))
-> (Ptr Drive -> IO (Ptr (Ptr CChar))) -> IO (Ptr (Ptr CChar))
forall a b. (a -> b) -> a -> b
$ \Ptr Drive
argPtr1 ->Ptr Drive -> IO (Ptr (Ptr CChar))
g_drive_enumerate_identifiers Ptr Drive
argPtr1) (drive -> Drive
forall o. DriveClass o => o -> Drive
toDrive drive
drive)
  IO (Ptr (Ptr CChar))
-> (Ptr (Ptr CChar) -> IO [string]) -> IO [string]
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Ptr (Ptr CChar) -> IO [string]
forall s. GlibString s => Ptr (Ptr CChar) -> IO [s]
readUTFStringArray0

-- | Gets the identifier of the given kind for drive. See the introduction for more information about
-- drive identifiers.
driveGetIdentifier :: (DriveClass drive, GlibString string) => drive
                    -> string -- ^ @kind@ the kind of identifier to return
                    -> IO string
driveGetIdentifier :: forall drive string.
(DriveClass drive, GlibString string) =>
drive -> string -> IO string
driveGetIdentifier drive
drive string
kind =
  string -> (Ptr CChar -> IO string) -> IO string
forall a. string -> (Ptr CChar -> IO a) -> IO a
forall s a. GlibString s => s -> (Ptr CChar -> IO a) -> IO a
withUTFString string
kind ((Ptr CChar -> IO string) -> IO string)
-> (Ptr CChar -> IO string) -> IO string
forall a b. (a -> b) -> a -> b
$ \ Ptr CChar
kindPtr ->
  (\(Drive ForeignPtr Drive
arg1) Ptr CChar
arg2 -> ForeignPtr Drive -> (Ptr Drive -> IO (Ptr CChar)) -> IO (Ptr CChar)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Drive
arg1 ((Ptr Drive -> IO (Ptr CChar)) -> IO (Ptr CChar))
-> (Ptr Drive -> IO (Ptr CChar)) -> IO (Ptr CChar)
forall a b. (a -> b) -> a -> b
$ \Ptr Drive
argPtr1 ->Ptr Drive -> Ptr CChar -> IO (Ptr CChar)
g_drive_get_identifier Ptr Drive
argPtr1 Ptr CChar
arg2) (drive -> Drive
forall o. DriveClass o => o -> Drive
toDrive drive
drive) Ptr CChar
kindPtr
  IO (Ptr CChar) -> (Ptr CChar -> IO string) -> IO string
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Ptr CChar -> IO string
forall s. GlibString s => Ptr CChar -> IO s
readUTFString

--------------------
-- Signals
-- | Emitted when a drive changes.
driveChanged :: DriveClass drive => Signal drive (Drive -> IO ())
driveChanged :: forall drive. DriveClass drive => Signal drive (Drive -> IO ())
driveChanged = (Bool -> drive -> (Drive -> IO ()) -> IO (ConnectId drive))
-> Signal drive (Drive -> IO ())
forall object handler.
(Bool -> object -> handler -> IO (ConnectId object))
-> Signal object handler
Signal (SignalName
-> Bool -> drive -> (Drive -> IO ()) -> IO (ConnectId drive)
forall a' obj.
(GObjectClass a', GObjectClass obj) =>
SignalName -> Bool -> obj -> (a' -> IO ()) -> IO (ConnectId obj)
connect_OBJECT__NONE SignalName
"drive-changed")

-- | Emitted when a drive changes.
driveDisconnected :: DriveClass drive => Signal drive (Drive -> IO ())
driveDisconnected :: forall drive. DriveClass drive => Signal drive (Drive -> IO ())
driveDisconnected = (Bool -> drive -> (Drive -> IO ()) -> IO (ConnectId drive))
-> Signal drive (Drive -> IO ())
forall object handler.
(Bool -> object -> handler -> IO (ConnectId object))
-> Signal object handler
Signal (SignalName
-> Bool -> drive -> (Drive -> IO ()) -> IO (ConnectId drive)
forall a' obj.
(GObjectClass a', GObjectClass obj) =>
SignalName -> Bool -> obj -> (a' -> IO ()) -> IO (ConnectId obj)
connect_OBJECT__NONE SignalName
"drive-disconnected")

-- | Emitted when the eject button is pressed on drive.
driveEjectButton :: DriveClass drive => Signal drive (Drive -> IO ())
driveEjectButton :: forall drive. DriveClass drive => Signal drive (Drive -> IO ())
driveEjectButton = (Bool -> drive -> (Drive -> IO ()) -> IO (ConnectId drive))
-> Signal drive (Drive -> IO ())
forall object handler.
(Bool -> object -> handler -> IO (ConnectId object))
-> Signal object handler
Signal (SignalName
-> Bool -> drive -> (Drive -> IO ()) -> IO (ConnectId drive)
forall a' obj.
(GObjectClass a', GObjectClass obj) =>
SignalName -> Bool -> obj -> (a' -> IO ()) -> IO (ConnectId obj)
connect_OBJECT__NONE SignalName
"drive-eject-button")


-- | Emitted when the stop button is pressed on drive.
driveStopButton :: DriveClass drive => Signal drive (Drive -> IO ())
driveStopButton :: forall drive. DriveClass drive => Signal drive (Drive -> IO ())
driveStopButton = (Bool -> drive -> (Drive -> IO ()) -> IO (ConnectId drive))
-> Signal drive (Drive -> IO ())
forall object handler.
(Bool -> object -> handler -> IO (ConnectId object))
-> Signal object handler
Signal (SignalName
-> Bool -> drive -> (Drive -> IO ()) -> IO (ConnectId drive)
forall a' obj.
(GObjectClass a', GObjectClass obj) =>
SignalName -> Bool -> obj -> (a' -> IO ()) -> IO (ConnectId obj)
connect_OBJECT__NONE SignalName
"drive-stop-button")

foreign import ccall safe "g_drive_get_name"
  g_drive_get_name :: ((Ptr Drive) -> (IO (Ptr CChar)))

foreign import ccall safe "g_drive_get_icon"
  g_drive_get_icon :: ((Ptr Drive) -> (IO (Ptr Icon)))

foreign import ccall safe "g_drive_has_volumes"
  g_drive_has_volumes :: ((Ptr Drive) -> (IO CInt))

foreign import ccall safe "g_drive_get_volumes"
  g_drive_get_volumes :: ((Ptr Drive) -> (IO (Ptr ())))

foreign import ccall safe "g_drive_can_eject"
  g_drive_can_eject :: ((Ptr Drive) -> (IO CInt))

foreign import ccall safe "g_drive_get_start_stop_type"
  g_drive_get_start_stop_type :: ((Ptr Drive) -> (IO CInt))

foreign import ccall safe "g_drive_can_start"
  g_drive_can_start :: ((Ptr Drive) -> (IO CInt))

foreign import ccall safe "g_drive_can_start_degraded"
  g_drive_can_start_degraded :: ((Ptr Drive) -> (IO CInt))

foreign import ccall safe "g_drive_can_stop"
  g_drive_can_stop :: ((Ptr Drive) -> (IO CInt))

foreign import ccall safe "g_drive_can_poll_for_media"
  g_drive_can_poll_for_media :: ((Ptr Drive) -> (IO CInt))

foreign import ccall safe "g_drive_poll_for_media"
  g_drive_poll_for_media :: ((Ptr Drive) -> ((Ptr Cancellable) -> ((FunPtr ((Ptr ()) -> ((Ptr AsyncResult) -> ((Ptr ()) -> (IO ()))))) -> ((Ptr ()) -> (IO ())))))

foreign import ccall safe "g_drive_poll_for_media_finish"
  g_drive_poll_for_media_finish :: ((Ptr Drive) -> ((Ptr AsyncResult) -> ((Ptr (Ptr ())) -> (IO CInt))))

foreign import ccall safe "g_drive_has_media"
  g_drive_has_media :: ((Ptr Drive) -> (IO CInt))

foreign import ccall safe "g_drive_is_media_check_automatic"
  g_drive_is_media_check_automatic :: ((Ptr Drive) -> (IO CInt))

foreign import ccall safe "g_drive_is_media_removable"
  g_drive_is_media_removable :: ((Ptr Drive) -> (IO CInt))

foreign import ccall safe "g_drive_eject_with_operation"
  g_drive_eject_with_operation :: ((Ptr Drive) -> (CInt -> ((Ptr MountOperation) -> ((Ptr Cancellable) -> ((FunPtr ((Ptr ()) -> ((Ptr AsyncResult) -> ((Ptr ()) -> (IO ()))))) -> ((Ptr ()) -> (IO ())))))))

foreign import ccall safe "g_drive_eject_with_operation_finish"
  g_drive_eject_with_operation_finish :: ((Ptr Drive) -> ((Ptr AsyncResult) -> ((Ptr (Ptr ())) -> (IO CInt))))

foreign import ccall safe "g_drive_start"
  g_drive_start :: ((Ptr Drive) -> (CInt -> ((Ptr MountOperation) -> ((Ptr Cancellable) -> ((FunPtr ((Ptr ()) -> ((Ptr AsyncResult) -> ((Ptr ()) -> (IO ()))))) -> ((Ptr ()) -> (IO ())))))))

foreign import ccall safe "g_drive_start_finish"
  g_drive_start_finish :: ((Ptr Drive) -> ((Ptr AsyncResult) -> ((Ptr (Ptr ())) -> (IO CInt))))

foreign import ccall safe "g_drive_stop"
  g_drive_stop :: ((Ptr Drive) -> (CInt -> ((Ptr MountOperation) -> ((Ptr Cancellable) -> ((FunPtr ((Ptr ()) -> ((Ptr AsyncResult) -> ((Ptr ()) -> (IO ()))))) -> ((Ptr ()) -> (IO ())))))))

foreign import ccall safe "g_drive_stop_finish"
  g_drive_stop_finish :: ((Ptr Drive) -> ((Ptr AsyncResult) -> ((Ptr (Ptr ())) -> (IO CInt))))

foreign import ccall safe "g_drive_enumerate_identifiers"
  g_drive_enumerate_identifiers :: ((Ptr Drive) -> (IO (Ptr (Ptr CChar))))

foreign import ccall safe "g_drive_get_identifier"
  g_drive_get_identifier :: ((Ptr Drive) -> ((Ptr CChar) -> (IO (Ptr CChar))))