{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)
-}

module GI.Gio.Interfaces.Volume
    ( 

-- * Exported types
    Volume(..)                              ,
    noVolume                                ,
    VolumeK                                 ,
    toVolume                                ,


 -- * Methods
-- ** volumeCanEject
    volumeCanEject                          ,


-- ** volumeCanMount
    volumeCanMount                          ,


-- ** volumeEject
    volumeEject                             ,


-- ** volumeEjectFinish
    volumeEjectFinish                       ,


-- ** volumeEjectWithOperation
    volumeEjectWithOperation                ,


-- ** volumeEjectWithOperationFinish
    volumeEjectWithOperationFinish          ,


-- ** volumeEnumerateIdentifiers
    volumeEnumerateIdentifiers              ,


-- ** volumeGetActivationRoot
    volumeGetActivationRoot                 ,


-- ** volumeGetDrive
    volumeGetDrive                          ,


-- ** volumeGetIcon
    volumeGetIcon                           ,


-- ** volumeGetIdentifier
    volumeGetIdentifier                     ,


-- ** volumeGetMount
    volumeGetMount                          ,


-- ** volumeGetName
    volumeGetName                           ,


-- ** volumeGetSortKey
    volumeGetSortKey                        ,


-- ** volumeGetSymbolicIcon
    volumeGetSymbolicIcon                   ,


-- ** volumeGetUuid
    volumeGetUuid                           ,


-- ** volumeMount
    volumeMount                             ,


-- ** volumeMountFinish
    volumeMountFinish                       ,


-- ** volumeShouldAutomount
    volumeShouldAutomount                   ,




 -- * Signals
-- ** Changed
    VolumeChangedCallback                   ,
    VolumeChangedCallbackC                  ,
    VolumeChangedSignalInfo                 ,
    afterVolumeChanged                      ,
    mkVolumeChangedCallback                 ,
    noVolumeChangedCallback                 ,
    onVolumeChanged                         ,
    volumeChangedCallbackWrapper            ,
    volumeChangedClosure                    ,


-- ** Removed
    VolumeRemovedCallback                   ,
    VolumeRemovedCallbackC                  ,
    VolumeRemovedSignalInfo                 ,
    afterVolumeRemoved                      ,
    mkVolumeRemovedCallback                 ,
    noVolumeRemovedCallback                 ,
    onVolumeRemoved                         ,
    volumeRemovedCallbackWrapper            ,
    volumeRemovedClosure                    ,




    ) where

import Prelude ()
import Data.GI.Base.ShortPrelude

import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map

import GI.Gio.Types
import GI.Gio.Callbacks
import qualified GI.GObject as GObject

-- interface Volume 

newtype Volume = Volume (ForeignPtr Volume)
noVolume :: Maybe Volume
noVolume = Nothing

-- signal Volume::changed
type VolumeChangedCallback =
    IO ()

noVolumeChangedCallback :: Maybe VolumeChangedCallback
noVolumeChangedCallback = Nothing

type VolumeChangedCallbackC =
    Ptr () ->                               -- object
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mkVolumeChangedCallback :: VolumeChangedCallbackC -> IO (FunPtr VolumeChangedCallbackC)

volumeChangedClosure :: VolumeChangedCallback -> IO Closure
volumeChangedClosure cb = newCClosure =<< mkVolumeChangedCallback wrapped
    where wrapped = volumeChangedCallbackWrapper cb

volumeChangedCallbackWrapper ::
    VolumeChangedCallback ->
    Ptr () ->
    Ptr () ->
    IO ()
volumeChangedCallbackWrapper _cb _ _ = do
    _cb 

onVolumeChanged :: (GObject a, MonadIO m) => a -> VolumeChangedCallback -> m SignalHandlerId
onVolumeChanged obj cb = liftIO $ connectVolumeChanged obj cb SignalConnectBefore
afterVolumeChanged :: (GObject a, MonadIO m) => a -> VolumeChangedCallback -> m SignalHandlerId
afterVolumeChanged obj cb = connectVolumeChanged obj cb SignalConnectAfter

connectVolumeChanged :: (GObject a, MonadIO m) =>
                        a -> VolumeChangedCallback -> SignalConnectMode -> m SignalHandlerId
connectVolumeChanged obj cb after = liftIO $ do
    cb' <- mkVolumeChangedCallback (volumeChangedCallbackWrapper cb)
    connectSignalFunPtr obj "changed" cb' after

-- signal Volume::removed
type VolumeRemovedCallback =
    IO ()

noVolumeRemovedCallback :: Maybe VolumeRemovedCallback
noVolumeRemovedCallback = Nothing

type VolumeRemovedCallbackC =
    Ptr () ->                               -- object
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mkVolumeRemovedCallback :: VolumeRemovedCallbackC -> IO (FunPtr VolumeRemovedCallbackC)

volumeRemovedClosure :: VolumeRemovedCallback -> IO Closure
volumeRemovedClosure cb = newCClosure =<< mkVolumeRemovedCallback wrapped
    where wrapped = volumeRemovedCallbackWrapper cb

volumeRemovedCallbackWrapper ::
    VolumeRemovedCallback ->
    Ptr () ->
    Ptr () ->
    IO ()
volumeRemovedCallbackWrapper _cb _ _ = do
    _cb 

onVolumeRemoved :: (GObject a, MonadIO m) => a -> VolumeRemovedCallback -> m SignalHandlerId
onVolumeRemoved obj cb = liftIO $ connectVolumeRemoved obj cb SignalConnectBefore
afterVolumeRemoved :: (GObject a, MonadIO m) => a -> VolumeRemovedCallback -> m SignalHandlerId
afterVolumeRemoved obj cb = connectVolumeRemoved obj cb SignalConnectAfter

connectVolumeRemoved :: (GObject a, MonadIO m) =>
                        a -> VolumeRemovedCallback -> SignalConnectMode -> m SignalHandlerId
connectVolumeRemoved obj cb after = liftIO $ do
    cb' <- mkVolumeRemovedCallback (volumeRemovedCallbackWrapper cb)
    connectSignalFunPtr obj "removed" cb' after

type instance AttributeList Volume = VolumeAttributeList
type VolumeAttributeList = ('[ ] :: [(Symbol, *)])

data VolumeChangedSignalInfo
instance SignalInfo VolumeChangedSignalInfo where
    type HaskellCallbackType VolumeChangedSignalInfo = VolumeChangedCallback
    connectSignal _ = connectVolumeChanged

data VolumeRemovedSignalInfo
instance SignalInfo VolumeRemovedSignalInfo where
    type HaskellCallbackType VolumeRemovedSignalInfo = VolumeRemovedCallback
    connectSignal _ = connectVolumeRemoved

type instance SignalList Volume = VolumeSignalList
type VolumeSignalList = ('[ '("changed", VolumeChangedSignalInfo), '("notify", GObject.ObjectNotifySignalInfo), '("removed", VolumeRemovedSignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)])

foreign import ccall "g_volume_get_type"
    c_g_volume_get_type :: IO GType

type instance ParentTypes Volume = VolumeParentTypes
type VolumeParentTypes = '[GObject.Object]

instance GObject Volume where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_g_volume_get_type
    

class GObject o => VolumeK o
instance (GObject o, IsDescendantOf Volume o) => VolumeK o

toVolume :: VolumeK o => o -> IO Volume
toVolume = unsafeCastTo Volume

-- method Volume::can_eject
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Volume", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Volume", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "g_volume_can_eject" g_volume_can_eject :: 
    Ptr Volume ->                           -- _obj : TInterface "Gio" "Volume"
    IO CInt


volumeCanEject ::
    (MonadIO m, VolumeK a) =>
    a ->                                    -- _obj
    m Bool
volumeCanEject _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_volume_can_eject _obj'
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'

-- method Volume::can_mount
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Volume", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Volume", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "g_volume_can_mount" g_volume_can_mount :: 
    Ptr Volume ->                           -- _obj : TInterface "Gio" "Volume"
    IO CInt


volumeCanMount ::
    (MonadIO m, VolumeK a) =>
    a ->                                    -- _obj
    m Bool
volumeCanMount _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_volume_can_mount _obj'
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'

-- method Volume::eject
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Volume", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TInterface "Gio" "MountUnmountFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "callback", argType = TInterface "Gio" "AsyncReadyCallback", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeAsync, argClosure = 4, argDestroy = -1, transfer = TransferNothing},Arg {argName = "user_data", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Volume", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TInterface "Gio" "MountUnmountFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "callback", argType = TInterface "Gio" "AsyncReadyCallback", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeAsync, argClosure = 4, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_volume_eject" g_volume_eject :: 
    Ptr Volume ->                           -- _obj : TInterface "Gio" "Volume"
    CUInt ->                                -- flags : TInterface "Gio" "MountUnmountFlags"
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    FunPtr AsyncReadyCallbackC ->           -- callback : TInterface "Gio" "AsyncReadyCallback"
    Ptr () ->                               -- user_data : TBasicType TVoid
    IO ()

{-# DEPRECATED volumeEject ["(Since version 2.22)","Use g_volume_eject_with_operation() instead."]#-}
volumeEject ::
    (MonadIO m, VolumeK a, CancellableK b) =>
    a ->                                    -- _obj
    [MountUnmountFlags] ->                  -- flags
    Maybe (b) ->                            -- cancellable
    Maybe (AsyncReadyCallback) ->           -- callback
    m ()
volumeEject _obj flags cancellable callback = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            let jCancellable' = unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr AsyncReadyCallbackC))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- mkAsyncReadyCallback (asyncReadyCallbackWrapper (Just ptrcallback) jCallback)
            poke ptrcallback jCallback'
            return jCallback'
    let user_data = nullPtr
    g_volume_eject _obj' flags' maybeCancellable maybeCallback user_data
    touchManagedPtr _obj
    whenJust cancellable touchManagedPtr
    return ()

-- method Volume::eject_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Volume", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "result", argType = TInterface "Gio" "AsyncResult", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Volume", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "result", argType = TInterface "Gio" "AsyncResult", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : True
-- Skip return : False

foreign import ccall "g_volume_eject_finish" g_volume_eject_finish :: 
    Ptr Volume ->                           -- _obj : TInterface "Gio" "Volume"
    Ptr AsyncResult ->                      -- result : TInterface "Gio" "AsyncResult"
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{-# DEPRECATED volumeEjectFinish ["(Since version 2.22)","Use g_volume_eject_with_operation_finish() instead."]#-}
volumeEjectFinish ::
    (MonadIO m, VolumeK a, AsyncResultK b) =>
    a ->                                    -- _obj
    b ->                                    -- result
    m ()
volumeEjectFinish _obj result_ = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let result_' = unsafeManagedPtrCastPtr result_
    onException (do
        _ <- propagateGError $ g_volume_eject_finish _obj' result_'
        touchManagedPtr _obj
        touchManagedPtr result_
        return ()
     ) (do
        return ()
     )

-- method Volume::eject_with_operation
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Volume", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TInterface "Gio" "MountUnmountFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "mount_operation", argType = TInterface "Gio" "MountOperation", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "callback", argType = TInterface "Gio" "AsyncReadyCallback", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeAsync, argClosure = 5, argDestroy = -1, transfer = TransferNothing},Arg {argName = "user_data", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Volume", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TInterface "Gio" "MountUnmountFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "mount_operation", argType = TInterface "Gio" "MountOperation", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "callback", argType = TInterface "Gio" "AsyncReadyCallback", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeAsync, argClosure = 5, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_volume_eject_with_operation" g_volume_eject_with_operation :: 
    Ptr Volume ->                           -- _obj : TInterface "Gio" "Volume"
    CUInt ->                                -- flags : TInterface "Gio" "MountUnmountFlags"
    Ptr MountOperation ->                   -- mount_operation : TInterface "Gio" "MountOperation"
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    FunPtr AsyncReadyCallbackC ->           -- callback : TInterface "Gio" "AsyncReadyCallback"
    Ptr () ->                               -- user_data : TBasicType TVoid
    IO ()


volumeEjectWithOperation ::
    (MonadIO m, VolumeK a, MountOperationK b, CancellableK c) =>
    a ->                                    -- _obj
    [MountUnmountFlags] ->                  -- flags
    Maybe (b) ->                            -- mount_operation
    Maybe (c) ->                            -- cancellable
    Maybe (AsyncReadyCallback) ->           -- callback
    m ()
volumeEjectWithOperation _obj flags mount_operation cancellable callback = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let flags' = gflagsToWord flags
    maybeMount_operation <- case mount_operation of
        Nothing -> return nullPtr
        Just jMount_operation -> do
            let jMount_operation' = unsafeManagedPtrCastPtr jMount_operation
            return jMount_operation'
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            let jCancellable' = unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr AsyncReadyCallbackC))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- mkAsyncReadyCallback (asyncReadyCallbackWrapper (Just ptrcallback) jCallback)
            poke ptrcallback jCallback'
            return jCallback'
    let user_data = nullPtr
    g_volume_eject_with_operation _obj' flags' maybeMount_operation maybeCancellable maybeCallback user_data
    touchManagedPtr _obj
    whenJust mount_operation touchManagedPtr
    whenJust cancellable touchManagedPtr
    return ()

-- method Volume::eject_with_operation_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Volume", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "result", argType = TInterface "Gio" "AsyncResult", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Volume", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "result", argType = TInterface "Gio" "AsyncResult", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : True
-- Skip return : False

foreign import ccall "g_volume_eject_with_operation_finish" g_volume_eject_with_operation_finish :: 
    Ptr Volume ->                           -- _obj : TInterface "Gio" "Volume"
    Ptr AsyncResult ->                      -- result : TInterface "Gio" "AsyncResult"
    Ptr (Ptr GError) ->                     -- error
    IO CInt


volumeEjectWithOperationFinish ::
    (MonadIO m, VolumeK a, AsyncResultK b) =>
    a ->                                    -- _obj
    b ->                                    -- result
    m ()
volumeEjectWithOperationFinish _obj result_ = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let result_' = unsafeManagedPtrCastPtr result_
    onException (do
        _ <- propagateGError $ g_volume_eject_with_operation_finish _obj' result_'
        touchManagedPtr _obj
        touchManagedPtr result_
        return ()
     ) (do
        return ()
     )

-- method Volume::enumerate_identifiers
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Volume", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Volume", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TCArray True (-1) (-1) (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_volume_enumerate_identifiers" g_volume_enumerate_identifiers :: 
    Ptr Volume ->                           -- _obj : TInterface "Gio" "Volume"
    IO (Ptr CString)


volumeEnumerateIdentifiers ::
    (MonadIO m, VolumeK a) =>
    a ->                                    -- _obj
    m [T.Text]
volumeEnumerateIdentifiers _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_volume_enumerate_identifiers _obj'
    checkUnexpectedReturnNULL "g_volume_enumerate_identifiers" result
    result' <- unpackZeroTerminatedUTF8CArray result
    mapZeroTerminatedCArray freeMem result
    freeMem result
    touchManagedPtr _obj
    return result'

-- method Volume::get_activation_root
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Volume", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Volume", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "File"
-- throws : False
-- Skip return : False

foreign import ccall "g_volume_get_activation_root" g_volume_get_activation_root :: 
    Ptr Volume ->                           -- _obj : TInterface "Gio" "Volume"
    IO (Ptr File)


volumeGetActivationRoot ::
    (MonadIO m, VolumeK a) =>
    a ->                                    -- _obj
    m File
volumeGetActivationRoot _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_volume_get_activation_root _obj'
    checkUnexpectedReturnNULL "g_volume_get_activation_root" result
    result' <- (wrapObject File) result
    touchManagedPtr _obj
    return result'

-- method Volume::get_drive
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Volume", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Volume", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "Drive"
-- throws : False
-- Skip return : False

foreign import ccall "g_volume_get_drive" g_volume_get_drive :: 
    Ptr Volume ->                           -- _obj : TInterface "Gio" "Volume"
    IO (Ptr Drive)


volumeGetDrive ::
    (MonadIO m, VolumeK a) =>
    a ->                                    -- _obj
    m Drive
volumeGetDrive _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_volume_get_drive _obj'
    checkUnexpectedReturnNULL "g_volume_get_drive" result
    result' <- (wrapObject Drive) result
    touchManagedPtr _obj
    return result'

-- method Volume::get_icon
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Volume", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Volume", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "Icon"
-- throws : False
-- Skip return : False

foreign import ccall "g_volume_get_icon" g_volume_get_icon :: 
    Ptr Volume ->                           -- _obj : TInterface "Gio" "Volume"
    IO (Ptr Icon)


volumeGetIcon ::
    (MonadIO m, VolumeK a) =>
    a ->                                    -- _obj
    m Icon
volumeGetIcon _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_volume_get_icon _obj'
    checkUnexpectedReturnNULL "g_volume_get_icon" result
    result' <- (wrapObject Icon) result
    touchManagedPtr _obj
    return result'

-- method Volume::get_identifier
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Volume", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "kind", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Volume", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "kind", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUTF8
-- throws : False
-- Skip return : False

foreign import ccall "g_volume_get_identifier" g_volume_get_identifier :: 
    Ptr Volume ->                           -- _obj : TInterface "Gio" "Volume"
    CString ->                              -- kind : TBasicType TUTF8
    IO CString


volumeGetIdentifier ::
    (MonadIO m, VolumeK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- kind
    m T.Text
volumeGetIdentifier _obj kind = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    kind' <- textToCString kind
    result <- g_volume_get_identifier _obj' kind'
    checkUnexpectedReturnNULL "g_volume_get_identifier" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr _obj
    freeMem kind'
    return result'

-- method Volume::get_mount
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Volume", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Volume", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "Mount"
-- throws : False
-- Skip return : False

foreign import ccall "g_volume_get_mount" g_volume_get_mount :: 
    Ptr Volume ->                           -- _obj : TInterface "Gio" "Volume"
    IO (Ptr Mount)


volumeGetMount ::
    (MonadIO m, VolumeK a) =>
    a ->                                    -- _obj
    m Mount
volumeGetMount _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_volume_get_mount _obj'
    checkUnexpectedReturnNULL "g_volume_get_mount" result
    result' <- (wrapObject Mount) result
    touchManagedPtr _obj
    return result'

-- method Volume::get_name
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Volume", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Volume", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUTF8
-- throws : False
-- Skip return : False

foreign import ccall "g_volume_get_name" g_volume_get_name :: 
    Ptr Volume ->                           -- _obj : TInterface "Gio" "Volume"
    IO CString


volumeGetName ::
    (MonadIO m, VolumeK a) =>
    a ->                                    -- _obj
    m T.Text
volumeGetName _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_volume_get_name _obj'
    checkUnexpectedReturnNULL "g_volume_get_name" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr _obj
    return result'

-- method Volume::get_sort_key
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Volume", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Volume", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUTF8
-- throws : False
-- Skip return : False

foreign import ccall "g_volume_get_sort_key" g_volume_get_sort_key :: 
    Ptr Volume ->                           -- _obj : TInterface "Gio" "Volume"
    IO CString


volumeGetSortKey ::
    (MonadIO m, VolumeK a) =>
    a ->                                    -- _obj
    m T.Text
volumeGetSortKey _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_volume_get_sort_key _obj'
    checkUnexpectedReturnNULL "g_volume_get_sort_key" result
    result' <- cstringToText result
    touchManagedPtr _obj
    return result'

-- method Volume::get_symbolic_icon
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Volume", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Volume", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "Icon"
-- throws : False
-- Skip return : False

foreign import ccall "g_volume_get_symbolic_icon" g_volume_get_symbolic_icon :: 
    Ptr Volume ->                           -- _obj : TInterface "Gio" "Volume"
    IO (Ptr Icon)


volumeGetSymbolicIcon ::
    (MonadIO m, VolumeK a) =>
    a ->                                    -- _obj
    m Icon
volumeGetSymbolicIcon _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_volume_get_symbolic_icon _obj'
    checkUnexpectedReturnNULL "g_volume_get_symbolic_icon" result
    result' <- (wrapObject Icon) result
    touchManagedPtr _obj
    return result'

-- method Volume::get_uuid
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Volume", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Volume", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUTF8
-- throws : False
-- Skip return : False

foreign import ccall "g_volume_get_uuid" g_volume_get_uuid :: 
    Ptr Volume ->                           -- _obj : TInterface "Gio" "Volume"
    IO CString


volumeGetUuid ::
    (MonadIO m, VolumeK a) =>
    a ->                                    -- _obj
    m T.Text
volumeGetUuid _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_volume_get_uuid _obj'
    checkUnexpectedReturnNULL "g_volume_get_uuid" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr _obj
    return result'

-- method Volume::mount
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Volume", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TInterface "Gio" "MountMountFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "mount_operation", argType = TInterface "Gio" "MountOperation", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "callback", argType = TInterface "Gio" "AsyncReadyCallback", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeAsync, argClosure = 5, argDestroy = -1, transfer = TransferNothing},Arg {argName = "user_data", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Volume", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TInterface "Gio" "MountMountFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "mount_operation", argType = TInterface "Gio" "MountOperation", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "callback", argType = TInterface "Gio" "AsyncReadyCallback", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeAsync, argClosure = 5, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_volume_mount" g_volume_mount :: 
    Ptr Volume ->                           -- _obj : TInterface "Gio" "Volume"
    CUInt ->                                -- flags : TInterface "Gio" "MountMountFlags"
    Ptr MountOperation ->                   -- mount_operation : TInterface "Gio" "MountOperation"
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    FunPtr AsyncReadyCallbackC ->           -- callback : TInterface "Gio" "AsyncReadyCallback"
    Ptr () ->                               -- user_data : TBasicType TVoid
    IO ()


volumeMount ::
    (MonadIO m, VolumeK a, MountOperationK b, CancellableK c) =>
    a ->                                    -- _obj
    [MountMountFlags] ->                    -- flags
    Maybe (b) ->                            -- mount_operation
    Maybe (c) ->                            -- cancellable
    Maybe (AsyncReadyCallback) ->           -- callback
    m ()
volumeMount _obj flags mount_operation cancellable callback = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let flags' = gflagsToWord flags
    maybeMount_operation <- case mount_operation of
        Nothing -> return nullPtr
        Just jMount_operation -> do
            let jMount_operation' = unsafeManagedPtrCastPtr jMount_operation
            return jMount_operation'
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            let jCancellable' = unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr AsyncReadyCallbackC))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- mkAsyncReadyCallback (asyncReadyCallbackWrapper (Just ptrcallback) jCallback)
            poke ptrcallback jCallback'
            return jCallback'
    let user_data = nullPtr
    g_volume_mount _obj' flags' maybeMount_operation maybeCancellable maybeCallback user_data
    touchManagedPtr _obj
    whenJust mount_operation touchManagedPtr
    whenJust cancellable touchManagedPtr
    return ()

-- method Volume::mount_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Volume", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "result", argType = TInterface "Gio" "AsyncResult", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Volume", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "result", argType = TInterface "Gio" "AsyncResult", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : True
-- Skip return : False

foreign import ccall "g_volume_mount_finish" g_volume_mount_finish :: 
    Ptr Volume ->                           -- _obj : TInterface "Gio" "Volume"
    Ptr AsyncResult ->                      -- result : TInterface "Gio" "AsyncResult"
    Ptr (Ptr GError) ->                     -- error
    IO CInt


volumeMountFinish ::
    (MonadIO m, VolumeK a, AsyncResultK b) =>
    a ->                                    -- _obj
    b ->                                    -- result
    m ()
volumeMountFinish _obj result_ = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let result_' = unsafeManagedPtrCastPtr result_
    onException (do
        _ <- propagateGError $ g_volume_mount_finish _obj' result_'
        touchManagedPtr _obj
        touchManagedPtr result_
        return ()
     ) (do
        return ()
     )

-- method Volume::should_automount
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Volume", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Volume", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "g_volume_should_automount" g_volume_should_automount :: 
    Ptr Volume ->                           -- _obj : TInterface "Gio" "Volume"
    IO CInt


volumeShouldAutomount ::
    (MonadIO m, VolumeK a) =>
    a ->                                    -- _obj
    m Bool
volumeShouldAutomount _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_volume_should_automount _obj'
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'