module System.GIO.Volumes.Volume (
Volume(..),
VolumeClass,
volumeGetName,
volumeGetUUID,
volumeGetIcon,
volumeGetDrive,
volumeGetMount,
volumeCanMount,
volumeShouldAutomount,
volumeGetActivationRoot,
volumeMount,
volumeMountFinish,
volumeCanEject,
volumeEjectWithOperation,
volumeEjectWithOperationFinish,
volumeEnumerateIdentifiers,
volumeGetIdentifier,
volumeChanged,
volumeRemoved,
) 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.GObject
import System.Glib.Properties
import System.Glib.Signals
import System.Glib.UTFString
import System.GIO.Async.AsyncResult
import System.GIO.Signals
import System.GIO.Types
volumeGetName :: (VolumeClass volume, GlibString string) => volume
-> IO string
volumeGetName volume =
(\(Volume arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_volume_get_name argPtr1) (toVolume volume)
>>= readUTFString
volumeGetUUID :: (VolumeClass volume, GlibString string) => volume
-> IO (Maybe string)
volumeGetUUID volume =
(\(Volume arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_volume_get_uuid argPtr1) (toVolume volume)
>>= maybePeek readUTFString
volumeGetIcon :: VolumeClass volume => volume
-> IO Icon
volumeGetIcon volume =
wrapNewGObject mkIcon $
(\(Volume arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_volume_get_icon argPtr1) (toVolume volume)
volumeGetDrive :: VolumeClass volume => volume
-> IO (Maybe Drive)
volumeGetDrive volume =
maybeNull (wrapNewGObject mkDrive) $
(\(Volume arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_volume_get_drive argPtr1) (toVolume volume)
volumeGetMount :: VolumeClass volume => volume
-> IO (Maybe Mount)
volumeGetMount volume =
maybeNull (wrapNewGObject mkMount) $
(\(Volume arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_volume_get_mount argPtr1) (toVolume volume)
volumeCanMount :: VolumeClass volume => volume
-> IO Bool
volumeCanMount volume =
liftM toBool $
(\(Volume arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_volume_can_mount argPtr1) (toVolume volume)
volumeShouldAutomount :: VolumeClass volume => volume
-> IO Bool
volumeShouldAutomount volume =
liftM toBool $
(\(Volume arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_volume_should_automount argPtr1) (toVolume volume)
volumeGetActivationRoot :: VolumeClass volume => volume
-> IO (Maybe File)
volumeGetActivationRoot volume =
maybeNull (wrapNewGObject mkFile) $
(\(Volume arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_volume_get_activation_root argPtr1) (toVolume volume)
volumeMount :: VolumeClass volume => volume
-> [MountMountFlags]
-> Maybe MountOperation
-> Maybe Cancellable
-> AsyncReadyCallback
-> IO ()
volumeMount volume flags mountOperation cancellable callback = do
cCallback <- marshalAsyncReadyCallback callback
(\(Volume arg1) arg2 (MountOperation arg3) (Cancellable arg4) arg5 arg6 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg3 $ \argPtr3 ->withForeignPtr arg4 $ \argPtr4 ->g_volume_mount argPtr1 arg2 argPtr3 argPtr4 arg5 arg6)
(toVolume volume)
((fromIntegral . fromFlags) flags)
(fromMaybe (MountOperation nullForeignPtr) mountOperation)
(fromMaybe (Cancellable nullForeignPtr) cancellable)
cCallback
(castFunPtrToPtr cCallback)
volumeMountFinish :: VolumeClass volume => volume
-> AsyncResult
-> IO ()
volumeMountFinish volume result =
propagateGError (\gErrorPtr -> do
(\(Volume arg1) (AsyncResult arg2) arg3 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->g_volume_mount_finish argPtr1 argPtr2 arg3)
(toVolume volume)
result
gErrorPtr
return ())
volumeCanEject :: VolumeClass volume => volume
-> IO Bool
volumeCanEject volume =
liftM toBool $
(\(Volume arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_volume_can_eject argPtr1) (toVolume volume)
volumeEjectWithOperation :: VolumeClass volume => volume
-> [MountUnmountFlags]
-> Maybe MountOperation
-> Maybe Cancellable
-> AsyncReadyCallback
-> IO ()
volumeEjectWithOperation volume flags mountOperation cancellable callback = do
cCallback <- marshalAsyncReadyCallback callback
(\(Volume arg1) arg2 (MountOperation arg3) (Cancellable arg4) arg5 arg6 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg3 $ \argPtr3 ->withForeignPtr arg4 $ \argPtr4 ->g_volume_eject_with_operation argPtr1 arg2 argPtr3 argPtr4 arg5 arg6)
(toVolume volume)
((fromIntegral . fromFlags) flags)
(fromMaybe (MountOperation nullForeignPtr) mountOperation)
(fromMaybe (Cancellable nullForeignPtr) cancellable)
cCallback
(castFunPtrToPtr cCallback)
volumeEjectWithOperationFinish :: VolumeClass volume => volume
-> AsyncResult
-> IO ()
volumeEjectWithOperationFinish volume result =
propagateGError (\gErrorPtr -> do
(\(Volume arg1) (AsyncResult arg2) arg3 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->g_volume_eject_with_operation_finish argPtr1 argPtr2 arg3)
(toVolume volume)
result
gErrorPtr
return ())
volumeEnumerateIdentifiers :: (VolumeClass volume, GlibString string) => volume
-> IO [string]
volumeEnumerateIdentifiers volume =
(\(Volume arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_volume_enumerate_identifiers argPtr1) (toVolume volume)
>>= readUTFStringArray0
volumeGetIdentifier :: (VolumeClass volume, GlibString string) => volume
-> string
-> IO string
volumeGetIdentifier volume kind =
withUTFString kind $ \ kindPtr ->
(\(Volume arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->g_volume_get_identifier argPtr1 arg2) (toVolume volume) kindPtr
>>= readUTFString
volumeChanged :: VolumeClass volume => Signal volume (IO ())
volumeChanged = Signal (connect_NONE__NONE "changed")
volumeRemoved :: VolumeClass volume => Signal volume (IO ())
volumeRemoved = Signal (connect_NONE__NONE "removed")
foreign import ccall safe "g_volume_get_name"
g_volume_get_name :: ((Ptr Volume) -> (IO (Ptr CChar)))
foreign import ccall safe "g_volume_get_uuid"
g_volume_get_uuid :: ((Ptr Volume) -> (IO (Ptr CChar)))
foreign import ccall safe "g_volume_get_icon"
g_volume_get_icon :: ((Ptr Volume) -> (IO (Ptr Icon)))
foreign import ccall safe "g_volume_get_drive"
g_volume_get_drive :: ((Ptr Volume) -> (IO (Ptr Drive)))
foreign import ccall safe "g_volume_get_mount"
g_volume_get_mount :: ((Ptr Volume) -> (IO (Ptr Mount)))
foreign import ccall safe "g_volume_can_mount"
g_volume_can_mount :: ((Ptr Volume) -> (IO CInt))
foreign import ccall safe "g_volume_should_automount"
g_volume_should_automount :: ((Ptr Volume) -> (IO CInt))
foreign import ccall safe "g_volume_get_activation_root"
g_volume_get_activation_root :: ((Ptr Volume) -> (IO (Ptr File)))
foreign import ccall safe "g_volume_mount"
g_volume_mount :: ((Ptr Volume) -> (CInt -> ((Ptr MountOperation) -> ((Ptr Cancellable) -> ((FunPtr ((Ptr ()) -> ((Ptr AsyncResult) -> ((Ptr ()) -> (IO ()))))) -> ((Ptr ()) -> (IO ())))))))
foreign import ccall safe "g_volume_mount_finish"
g_volume_mount_finish :: ((Ptr Volume) -> ((Ptr AsyncResult) -> ((Ptr (Ptr ())) -> (IO CInt))))
foreign import ccall safe "g_volume_can_eject"
g_volume_can_eject :: ((Ptr Volume) -> (IO CInt))
foreign import ccall safe "g_volume_eject_with_operation"
g_volume_eject_with_operation :: ((Ptr Volume) -> (CInt -> ((Ptr MountOperation) -> ((Ptr Cancellable) -> ((FunPtr ((Ptr ()) -> ((Ptr AsyncResult) -> ((Ptr ()) -> (IO ()))))) -> ((Ptr ()) -> (IO ())))))))
foreign import ccall safe "g_volume_eject_with_operation_finish"
g_volume_eject_with_operation_finish :: ((Ptr Volume) -> ((Ptr AsyncResult) -> ((Ptr (Ptr ())) -> (IO CInt))))
foreign import ccall safe "g_volume_enumerate_identifiers"
g_volume_enumerate_identifiers :: ((Ptr Volume) -> (IO (Ptr (Ptr CChar))))
foreign import ccall safe "g_volume_get_identifier"
g_volume_get_identifier :: ((Ptr Volume) -> ((Ptr CChar) -> (IO (Ptr CChar))))