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

The 'GI.Gio.Interfaces.Volume.Volume' interface represents user-visible objects that can be
mounted. Note, when porting from GnomeVFS, 'GI.Gio.Interfaces.Volume.Volume' is the moral
equivalent of @/GnomeVFSDrive/@.

Mounting a 'GI.Gio.Interfaces.Volume.Volume' instance is an asynchronous operation. For more
information about asynchronous operations, see 'GI.Gio.Interfaces.AsyncResult.AsyncResult' and
'GI.Gio.Objects.Task.Task'. To mount a 'GI.Gio.Interfaces.Volume.Volume', first call 'GI.Gio.Interfaces.Volume.volumeMount' with (at
least) the 'GI.Gio.Interfaces.Volume.Volume' instance, optionally a 'GI.Gio.Objects.MountOperation.MountOperation' object
and a 'GI.Gio.Callbacks.AsyncReadyCallback'.

Typically, one will only want to pass 'Nothing' for the
'GI.Gio.Objects.MountOperation.MountOperation' if automounting all volumes when a desktop session
starts since it\'s not desirable to put up a lot of dialogs asking
for credentials.

The callback will be fired when the operation has resolved (either
with success or failure), and a @/GAsyncReady/@ structure will be
passed to the callback.  That callback should then call
'GI.Gio.Interfaces.Volume.volumeMountFinish' with the 'GI.Gio.Interfaces.Volume.Volume' instance and the
@/GAsyncReady/@ data to see if the operation was completed
successfully.  If an /@error@/ is present when 'GI.Gio.Interfaces.Volume.volumeMountFinish'
is called, then it will be filled with any error information.

## Volume Identifiers # {@/volume/@-identifier}

It is sometimes necessary to directly access the underlying
operating system object behind a volume (e.g. for passing a volume
to an application via the commandline). For this purpose, GIO
allows to obtain an \'identifier\' for the volume. There can be
different kinds of identifiers, such as Hal UDIs, filesystem labels,
traditional Unix devices (e.g. @\/dev\/sda2@), UUIDs. GIO uses predefined
strings as names for the different kinds of identifiers:
'GI.Gio.Constants.VOLUME_IDENTIFIER_KIND_HAL_UDI', 'GI.Gio.Constants.VOLUME_IDENTIFIER_KIND_LABEL', etc.
Use 'GI.Gio.Interfaces.Volume.volumeGetIdentifier' to obtain an identifier for a volume.


Note that 'GI.Gio.Constants.VOLUME_IDENTIFIER_KIND_HAL_UDI' will only be available
when the gvfs hal volume monitor is in use. Other volume monitors
will generally be able to provide the 'GI.Gio.Constants.VOLUME_IDENTIFIER_KIND_UNIX_DEVICE'
identifier, which can be used to obtain a hal device by means of
@/libhal_manager_find_device_string_match()/@.
-}

module GI.Gio.Interfaces.Volume
    ( 

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


 -- * Methods
-- ** canEject #method:canEject#
    VolumeCanEjectMethodInfo                ,
    volumeCanEject                          ,


-- ** canMount #method:canMount#
    VolumeCanMountMethodInfo                ,
    volumeCanMount                          ,


-- ** eject #method:eject#
    VolumeEjectMethodInfo                   ,
    volumeEject                             ,


-- ** ejectFinish #method:ejectFinish#
    VolumeEjectFinishMethodInfo             ,
    volumeEjectFinish                       ,


-- ** ejectWithOperation #method:ejectWithOperation#
    VolumeEjectWithOperationMethodInfo      ,
    volumeEjectWithOperation                ,


-- ** ejectWithOperationFinish #method:ejectWithOperationFinish#
    VolumeEjectWithOperationFinishMethodInfo,
    volumeEjectWithOperationFinish          ,


-- ** enumerateIdentifiers #method:enumerateIdentifiers#
    VolumeEnumerateIdentifiersMethodInfo    ,
    volumeEnumerateIdentifiers              ,


-- ** getActivationRoot #method:getActivationRoot#
    VolumeGetActivationRootMethodInfo       ,
    volumeGetActivationRoot                 ,


-- ** getDrive #method:getDrive#
    VolumeGetDriveMethodInfo                ,
    volumeGetDrive                          ,


-- ** getIcon #method:getIcon#
    VolumeGetIconMethodInfo                 ,
    volumeGetIcon                           ,


-- ** getIdentifier #method:getIdentifier#
    VolumeGetIdentifierMethodInfo           ,
    volumeGetIdentifier                     ,


-- ** getMount #method:getMount#
    VolumeGetMountMethodInfo                ,
    volumeGetMount                          ,


-- ** getName #method:getName#
    VolumeGetNameMethodInfo                 ,
    volumeGetName                           ,


-- ** getSortKey #method:getSortKey#
    VolumeGetSortKeyMethodInfo              ,
    volumeGetSortKey                        ,


-- ** getSymbolicIcon #method:getSymbolicIcon#
    VolumeGetSymbolicIconMethodInfo         ,
    volumeGetSymbolicIcon                   ,


-- ** getUuid #method:getUuid#
    VolumeGetUuidMethodInfo                 ,
    volumeGetUuid                           ,


-- ** mount #method:mount#
    VolumeMountMethodInfo                   ,
    volumeMount                             ,


-- ** mountFinish #method:mountFinish#
    VolumeMountFinishMethodInfo             ,
    volumeMountFinish                       ,


-- ** shouldAutomount #method:shouldAutomount#
    VolumeShouldAutomountMethodInfo         ,
    volumeShouldAutomount                   ,




 -- * Signals
-- ** changed #signal:changed#
    C_VolumeChangedCallback                 ,
    VolumeChangedCallback                   ,
    VolumeChangedSignalInfo                 ,
    afterVolumeChanged                      ,
    genClosure_VolumeChanged                ,
    mk_VolumeChangedCallback                ,
    noVolumeChangedCallback                 ,
    onVolumeChanged                         ,
    wrap_VolumeChangedCallback              ,


-- ** removed #signal:removed#
    C_VolumeRemovedCallback                 ,
    VolumeRemovedCallback                   ,
    VolumeRemovedSignalInfo                 ,
    afterVolumeRemoved                      ,
    genClosure_VolumeRemoved                ,
    mk_VolumeRemovedCallback                ,
    noVolumeRemovedCallback                 ,
    onVolumeRemoved                         ,
    wrap_VolumeRemovedCallback              ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Callbacks as Gio.Callbacks
import {-# SOURCE #-} qualified GI.Gio.Flags as Gio.Flags
import {-# SOURCE #-} qualified GI.Gio.Interfaces.AsyncResult as Gio.AsyncResult
import {-# SOURCE #-} qualified GI.Gio.Interfaces.Drive as Gio.Drive
import {-# SOURCE #-} qualified GI.Gio.Interfaces.File as Gio.File
import {-# SOURCE #-} qualified GI.Gio.Interfaces.Icon as Gio.Icon
import {-# SOURCE #-} qualified GI.Gio.Interfaces.Mount as Gio.Mount
import {-# SOURCE #-} qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import {-# SOURCE #-} qualified GI.Gio.Objects.MountOperation as Gio.MountOperation

-- interface Volume 
newtype Volume = Volume (ManagedPtr Volume)
noVolume :: Maybe Volume
noVolume = Nothing

type family ResolveVolumeMethod (t :: Symbol) (o :: *) :: * where
    ResolveVolumeMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveVolumeMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveVolumeMethod "canEject" o = VolumeCanEjectMethodInfo
    ResolveVolumeMethod "canMount" o = VolumeCanMountMethodInfo
    ResolveVolumeMethod "eject" o = VolumeEjectMethodInfo
    ResolveVolumeMethod "ejectFinish" o = VolumeEjectFinishMethodInfo
    ResolveVolumeMethod "ejectWithOperation" o = VolumeEjectWithOperationMethodInfo
    ResolveVolumeMethod "ejectWithOperationFinish" o = VolumeEjectWithOperationFinishMethodInfo
    ResolveVolumeMethod "enumerateIdentifiers" o = VolumeEnumerateIdentifiersMethodInfo
    ResolveVolumeMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveVolumeMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveVolumeMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveVolumeMethod "mount" o = VolumeMountMethodInfo
    ResolveVolumeMethod "mountFinish" o = VolumeMountFinishMethodInfo
    ResolveVolumeMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveVolumeMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveVolumeMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveVolumeMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveVolumeMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveVolumeMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveVolumeMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveVolumeMethod "shouldAutomount" o = VolumeShouldAutomountMethodInfo
    ResolveVolumeMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveVolumeMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveVolumeMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveVolumeMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveVolumeMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveVolumeMethod "getActivationRoot" o = VolumeGetActivationRootMethodInfo
    ResolveVolumeMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveVolumeMethod "getDrive" o = VolumeGetDriveMethodInfo
    ResolveVolumeMethod "getIcon" o = VolumeGetIconMethodInfo
    ResolveVolumeMethod "getIdentifier" o = VolumeGetIdentifierMethodInfo
    ResolveVolumeMethod "getMount" o = VolumeGetMountMethodInfo
    ResolveVolumeMethod "getName" o = VolumeGetNameMethodInfo
    ResolveVolumeMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveVolumeMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveVolumeMethod "getSortKey" o = VolumeGetSortKeyMethodInfo
    ResolveVolumeMethod "getSymbolicIcon" o = VolumeGetSymbolicIconMethodInfo
    ResolveVolumeMethod "getUuid" o = VolumeGetUuidMethodInfo
    ResolveVolumeMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveVolumeMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveVolumeMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveVolumeMethod t Volume, O.MethodInfo info Volume p) => O.IsLabelProxy t (Volume -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveVolumeMethod t Volume, O.MethodInfo info Volume p) => O.IsLabel t (Volume -> p) where
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

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

noVolumeChangedCallback :: Maybe VolumeChangedCallback
noVolumeChangedCallback = Nothing

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

foreign import ccall "wrapper"
    mk_VolumeChangedCallback :: C_VolumeChangedCallback -> IO (FunPtr C_VolumeChangedCallback)

genClosure_VolumeChanged :: VolumeChangedCallback -> IO Closure
genClosure_VolumeChanged cb = do
    let cb' = wrap_VolumeChangedCallback cb
    mk_VolumeChangedCallback cb' >>= newCClosure


wrap_VolumeChangedCallback ::
    VolumeChangedCallback ->
    Ptr () ->
    Ptr () ->
    IO ()
wrap_VolumeChangedCallback _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
    let cb' = wrap_VolumeChangedCallback cb
    cb'' <- mk_VolumeChangedCallback cb'
    connectSignalFunPtr obj "changed" cb'' after

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

noVolumeRemovedCallback :: Maybe VolumeRemovedCallback
noVolumeRemovedCallback = Nothing

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

foreign import ccall "wrapper"
    mk_VolumeRemovedCallback :: C_VolumeRemovedCallback -> IO (FunPtr C_VolumeRemovedCallback)

genClosure_VolumeRemoved :: VolumeRemovedCallback -> IO Closure
genClosure_VolumeRemoved cb = do
    let cb' = wrap_VolumeRemovedCallback cb
    mk_VolumeRemovedCallback cb' >>= newCClosure


wrap_VolumeRemovedCallback ::
    VolumeRemovedCallback ->
    Ptr () ->
    Ptr () ->
    IO ()
wrap_VolumeRemovedCallback _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
    let cb' = wrap_VolumeRemovedCallback cb
    cb'' <- mk_VolumeRemovedCallback cb'
    connectSignalFunPtr obj "removed" cb'' after

instance O.HasAttributeList Volume
type instance O.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 O.SignalList Volume = VolumeSignalList
type VolumeSignalList = ('[ '("changed", VolumeChangedSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo), '("removed", VolumeRemovedSignalInfo)] :: [(Symbol, *)])

foreign import ccall "g_volume_get_type"
    c_g_volume_get_type :: IO GType

instance GObject Volume where
    gobjectType _ = c_g_volume_get_type
    

class GObject o => IsVolume o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError Volume a) =>
    IsVolume a
#endif
instance IsVolume Volume
instance GObject.Object.IsObject Volume

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

-- method Volume::can_eject
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "volume", argType = TInterface (Name {namespace = "Gio", name = "Volume"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GVolume", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_volume_can_eject" g_volume_can_eject :: 
    Ptr Volume ->                           -- volume : TInterface (Name {namespace = "Gio", name = "Volume"})
    IO CInt

{- |
Checks if a volume can be ejected.
-}
volumeCanEject ::
    (B.CallStack.HasCallStack, MonadIO m, IsVolume a) =>
    a
    {- ^ /@volume@/: a 'GI.Gio.Interfaces.Volume.Volume' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the /@volume@/ can be ejected. 'False' otherwise -}
volumeCanEject volume = liftIO $ do
    volume' <- unsafeManagedPtrCastPtr volume
    result <- g_volume_can_eject volume'
    let result' = (/= 0) result
    touchManagedPtr volume
    return result'

data VolumeCanEjectMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsVolume a) => O.MethodInfo VolumeCanEjectMethodInfo a signature where
    overloadedMethod _ = volumeCanEject

-- method Volume::can_mount
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "volume", argType = TInterface (Name {namespace = "Gio", name = "Volume"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GVolume", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_volume_can_mount" g_volume_can_mount :: 
    Ptr Volume ->                           -- volume : TInterface (Name {namespace = "Gio", name = "Volume"})
    IO CInt

{- |
Checks if a volume can be mounted.
-}
volumeCanMount ::
    (B.CallStack.HasCallStack, MonadIO m, IsVolume a) =>
    a
    {- ^ /@volume@/: a 'GI.Gio.Interfaces.Volume.Volume' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the /@volume@/ can be mounted. 'False' otherwise -}
volumeCanMount volume = liftIO $ do
    volume' <- unsafeManagedPtrCastPtr volume
    result <- g_volume_can_mount volume'
    let result' = (/= 0) result
    touchManagedPtr volume
    return result'

data VolumeCanMountMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsVolume a) => O.MethodInfo VolumeCanMountMethodInfo a signature where
    overloadedMethod _ = volumeCanMount

-- method Volume::eject
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "volume", argType = TInterface (Name {namespace = "Gio", name = "Volume"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GVolume", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "MountUnmountFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "flags affecting the unmount if required for eject", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object, %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 4, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data that gets passed to @callback", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_volume_eject" g_volume_eject :: 
    Ptr Volume ->                           -- volume : TInterface (Name {namespace = "Gio", name = "Volume"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "MountUnmountFlags"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{-# DEPRECATED volumeEject ["(Since version 2.22)","Use 'GI.Gio.Interfaces.Volume.volumeEjectWithOperation' instead."] #-}
{- |
Ejects a volume. This is an asynchronous operation, and is
finished by calling 'GI.Gio.Interfaces.Volume.volumeEjectFinish' with the /@volume@/
and 'GI.Gio.Interfaces.AsyncResult.AsyncResult' returned in the /@callback@/.
-}
volumeEject ::
    (B.CallStack.HasCallStack, MonadIO m, IsVolume a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@volume@/: a 'GI.Gio.Interfaces.Volume.Volume' -}
    -> [Gio.Flags.MountUnmountFlags]
    {- ^ /@flags@/: flags affecting the unmount if required for eject -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object, 'Nothing' to ignore -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback', or 'Nothing' -}
    -> m ()
volumeEject volume flags cancellable callback = liftIO $ do
    volume' <- unsafeManagedPtrCastPtr volume
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_volume_eject volume' flags' maybeCancellable maybeCallback userData
    touchManagedPtr volume
    whenJust cancellable touchManagedPtr
    return ()

data VolumeEjectMethodInfo
instance (signature ~ ([Gio.Flags.MountUnmountFlags] -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsVolume a, Gio.Cancellable.IsCancellable b) => O.MethodInfo VolumeEjectMethodInfo a signature where
    overloadedMethod _ = volumeEject

-- method Volume::eject_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "volume", argType = TInterface (Name {namespace = "Gio", name = "Volume"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "pointer to a #GVolume", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_volume_eject_finish" g_volume_eject_finish :: 
    Ptr Volume ->                           -- volume : TInterface (Name {namespace = "Gio", name = "Volume"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{-# DEPRECATED volumeEjectFinish ["(Since version 2.22)","Use 'GI.Gio.Interfaces.Volume.volumeEjectWithOperationFinish' instead."] #-}
{- |
Finishes ejecting a volume. If any errors occurred during the operation,
/@error@/ will be set to contain the errors and 'False' will be returned.
-}
volumeEjectFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsVolume a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@volume@/: pointer to a 'GI.Gio.Interfaces.Volume.Volume' -}
    -> b
    {- ^ /@result@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
volumeEjectFinish volume result_ = liftIO $ do
    volume' <- unsafeManagedPtrCastPtr volume
    result_' <- unsafeManagedPtrCastPtr result_
    onException (do
        _ <- propagateGError $ g_volume_eject_finish volume' result_'
        touchManagedPtr volume
        touchManagedPtr result_
        return ()
     ) (do
        return ()
     )

data VolumeEjectFinishMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsVolume a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo VolumeEjectFinishMethodInfo a signature where
    overloadedMethod _ = volumeEjectFinish

-- method Volume::eject_with_operation
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "volume", argType = TInterface (Name {namespace = "Gio", name = "Volume"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GVolume", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "MountUnmountFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "flags affecting the unmount if required for eject", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "mount_operation", argType = TInterface (Name {namespace = "Gio", name = "MountOperation"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GMountOperation or %NULL to\n    avoid user interaction", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object, %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 5, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data passed to @callback", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_volume_eject_with_operation" g_volume_eject_with_operation :: 
    Ptr Volume ->                           -- volume : TInterface (Name {namespace = "Gio", name = "Volume"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "MountUnmountFlags"})
    Ptr Gio.MountOperation.MountOperation -> -- mount_operation : TInterface (Name {namespace = "Gio", name = "MountOperation"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Ejects a volume. This is an asynchronous operation, and is
finished by calling 'GI.Gio.Interfaces.Volume.volumeEjectWithOperationFinish' with the /@volume@/
and 'GI.Gio.Interfaces.AsyncResult.AsyncResult' data returned in the /@callback@/.

@since 2.22
-}
volumeEjectWithOperation ::
    (B.CallStack.HasCallStack, MonadIO m, IsVolume a, Gio.MountOperation.IsMountOperation b, Gio.Cancellable.IsCancellable c) =>
    a
    {- ^ /@volume@/: a 'GI.Gio.Interfaces.Volume.Volume' -}
    -> [Gio.Flags.MountUnmountFlags]
    {- ^ /@flags@/: flags affecting the unmount if required for eject -}
    -> Maybe (b)
    {- ^ /@mountOperation@/: a 'GI.Gio.Objects.MountOperation.MountOperation' or 'Nothing' to
    avoid user interaction -}
    -> Maybe (c)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object, 'Nothing' to ignore -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback', or 'Nothing' -}
    -> m ()
volumeEjectWithOperation volume flags mountOperation cancellable callback = liftIO $ do
    volume' <- unsafeManagedPtrCastPtr volume
    let flags' = gflagsToWord flags
    maybeMountOperation <- case mountOperation of
        Nothing -> return nullPtr
        Just jMountOperation -> do
            jMountOperation' <- unsafeManagedPtrCastPtr jMountOperation
            return jMountOperation'
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_volume_eject_with_operation volume' flags' maybeMountOperation maybeCancellable maybeCallback userData
    touchManagedPtr volume
    whenJust mountOperation touchManagedPtr
    whenJust cancellable touchManagedPtr
    return ()

data VolumeEjectWithOperationMethodInfo
instance (signature ~ ([Gio.Flags.MountUnmountFlags] -> Maybe (b) -> Maybe (c) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsVolume a, Gio.MountOperation.IsMountOperation b, Gio.Cancellable.IsCancellable c) => O.MethodInfo VolumeEjectWithOperationMethodInfo a signature where
    overloadedMethod _ = volumeEjectWithOperation

-- method Volume::eject_with_operation_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "volume", argType = TInterface (Name {namespace = "Gio", name = "Volume"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GVolume", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_volume_eject_with_operation_finish" g_volume_eject_with_operation_finish :: 
    Ptr Volume ->                           -- volume : TInterface (Name {namespace = "Gio", name = "Volume"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Finishes ejecting a volume. If any errors occurred during the operation,
/@error@/ will be set to contain the errors and 'False' will be returned.

@since 2.22
-}
volumeEjectWithOperationFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsVolume a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@volume@/: a 'GI.Gio.Interfaces.Volume.Volume' -}
    -> b
    {- ^ /@result@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
volumeEjectWithOperationFinish volume result_ = liftIO $ do
    volume' <- unsafeManagedPtrCastPtr volume
    result_' <- unsafeManagedPtrCastPtr result_
    onException (do
        _ <- propagateGError $ g_volume_eject_with_operation_finish volume' result_'
        touchManagedPtr volume
        touchManagedPtr result_
        return ()
     ) (do
        return ()
     )

data VolumeEjectWithOperationFinishMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsVolume a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo VolumeEjectWithOperationFinishMethodInfo a signature where
    overloadedMethod _ = volumeEjectWithOperationFinish

-- method Volume::enumerate_identifiers
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "volume", argType = TInterface (Name {namespace = "Gio", name = "Volume"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GVolume", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TCArray True (-1) (-1) (TBasicType TUTF8))
-- throws : False
-- Skip return : False

foreign import ccall "g_volume_enumerate_identifiers" g_volume_enumerate_identifiers :: 
    Ptr Volume ->                           -- volume : TInterface (Name {namespace = "Gio", name = "Volume"})
    IO (Ptr CString)

{- |
Gets the kinds of [identifiers][volume-identifier] that /@volume@/ has.
Use 'GI.Gio.Interfaces.Volume.volumeGetIdentifier' to obtain the identifiers themselves.
-}
volumeEnumerateIdentifiers ::
    (B.CallStack.HasCallStack, MonadIO m, IsVolume a) =>
    a
    {- ^ /@volume@/: a 'GI.Gio.Interfaces.Volume.Volume' -}
    -> m [T.Text]
    {- ^ __Returns:__ a 'Nothing'-terminated array
  of strings containing kinds of identifiers. Use 'GI.GLib.Functions.strfreev' to free. -}
volumeEnumerateIdentifiers volume = liftIO $ do
    volume' <- unsafeManagedPtrCastPtr volume
    result <- g_volume_enumerate_identifiers volume'
    checkUnexpectedReturnNULL "volumeEnumerateIdentifiers" result
    result' <- unpackZeroTerminatedUTF8CArray result
    mapZeroTerminatedCArray freeMem result
    freeMem result
    touchManagedPtr volume
    return result'

data VolumeEnumerateIdentifiersMethodInfo
instance (signature ~ (m [T.Text]), MonadIO m, IsVolume a) => O.MethodInfo VolumeEnumerateIdentifiersMethodInfo a signature where
    overloadedMethod _ = volumeEnumerateIdentifiers

-- method Volume::get_activation_root
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "volume", argType = TInterface (Name {namespace = "Gio", name = "Volume"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GVolume", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "File"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_volume_get_activation_root" g_volume_get_activation_root :: 
    Ptr Volume ->                           -- volume : TInterface (Name {namespace = "Gio", name = "Volume"})
    IO (Ptr Gio.File.File)

{- |
Gets the activation root for a 'GI.Gio.Interfaces.Volume.Volume' if it is known ahead of
mount time. Returns 'Nothing' otherwise. If not 'Nothing' and if /@volume@/
is mounted, then the result of 'GI.Gio.Interfaces.Mount.mountGetRoot' on the
'GI.Gio.Interfaces.Mount.Mount' object obtained from 'GI.Gio.Interfaces.Volume.volumeGetMount' will always
either be equal or a prefix of what this function returns. In
other words, in code


=== /C code/
>
>  GMount *mount;
>  GFile *mount_root
>  GFile *volume_activation_root;
>
>  mount = g_volume_get_mount (volume); // mounted, so never NULL
>  mount_root = g_mount_get_root (mount);
>  volume_activation_root = g_volume_get_activation_root (volume); // assume not NULL

then the expression

=== /C code/
>
>  (g_file_has_prefix (volume_activation_root, mount_root) ||
>      g_file_equal (volume_activation_root, mount_root))

will always be 'True'.

Activation roots are typically used in 'GI.Gio.Objects.VolumeMonitor.VolumeMonitor'
implementations to find the underlying mount to shadow, see
'GI.Gio.Interfaces.Mount.mountIsShadowed' for more details.

@since 2.18
-}
volumeGetActivationRoot ::
    (B.CallStack.HasCallStack, MonadIO m, IsVolume a) =>
    a
    {- ^ /@volume@/: a 'GI.Gio.Interfaces.Volume.Volume' -}
    -> m (Maybe Gio.File.File)
    {- ^ __Returns:__ the activation root of /@volume@/
    or 'Nothing'. Use 'GI.GObject.Objects.Object.objectUnref' to free. -}
volumeGetActivationRoot volume = liftIO $ do
    volume' <- unsafeManagedPtrCastPtr volume
    result <- g_volume_get_activation_root volume'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapObject Gio.File.File) result'
        return result''
    touchManagedPtr volume
    return maybeResult

data VolumeGetActivationRootMethodInfo
instance (signature ~ (m (Maybe Gio.File.File)), MonadIO m, IsVolume a) => O.MethodInfo VolumeGetActivationRootMethodInfo a signature where
    overloadedMethod _ = volumeGetActivationRoot

-- method Volume::get_drive
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "volume", argType = TInterface (Name {namespace = "Gio", name = "Volume"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GVolume", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "Drive"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_volume_get_drive" g_volume_get_drive :: 
    Ptr Volume ->                           -- volume : TInterface (Name {namespace = "Gio", name = "Volume"})
    IO (Ptr Gio.Drive.Drive)

{- |
Gets the drive for the /@volume@/.
-}
volumeGetDrive ::
    (B.CallStack.HasCallStack, MonadIO m, IsVolume a) =>
    a
    {- ^ /@volume@/: a 'GI.Gio.Interfaces.Volume.Volume' -}
    -> m Gio.Drive.Drive
    {- ^ __Returns:__ a 'GI.Gio.Interfaces.Drive.Drive' or 'Nothing' if /@volume@/ is not
    associated with a drive. The returned object should be unreffed
    with 'GI.GObject.Objects.Object.objectUnref' when no longer needed. -}
volumeGetDrive volume = liftIO $ do
    volume' <- unsafeManagedPtrCastPtr volume
    result <- g_volume_get_drive volume'
    checkUnexpectedReturnNULL "volumeGetDrive" result
    result' <- (wrapObject Gio.Drive.Drive) result
    touchManagedPtr volume
    return result'

data VolumeGetDriveMethodInfo
instance (signature ~ (m Gio.Drive.Drive), MonadIO m, IsVolume a) => O.MethodInfo VolumeGetDriveMethodInfo a signature where
    overloadedMethod _ = volumeGetDrive

-- method Volume::get_icon
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "volume", argType = TInterface (Name {namespace = "Gio", name = "Volume"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GVolume", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "Icon"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_volume_get_icon" g_volume_get_icon :: 
    Ptr Volume ->                           -- volume : TInterface (Name {namespace = "Gio", name = "Volume"})
    IO (Ptr Gio.Icon.Icon)

{- |
Gets the icon for /@volume@/.
-}
volumeGetIcon ::
    (B.CallStack.HasCallStack, MonadIO m, IsVolume a) =>
    a
    {- ^ /@volume@/: a 'GI.Gio.Interfaces.Volume.Volume' -}
    -> m Gio.Icon.Icon
    {- ^ __Returns:__ a 'GI.Gio.Interfaces.Icon.Icon'.
    The returned object should be unreffed with 'GI.GObject.Objects.Object.objectUnref'
    when no longer needed. -}
volumeGetIcon volume = liftIO $ do
    volume' <- unsafeManagedPtrCastPtr volume
    result <- g_volume_get_icon volume'
    checkUnexpectedReturnNULL "volumeGetIcon" result
    result' <- (wrapObject Gio.Icon.Icon) result
    touchManagedPtr volume
    return result'

data VolumeGetIconMethodInfo
instance (signature ~ (m Gio.Icon.Icon), MonadIO m, IsVolume a) => O.MethodInfo VolumeGetIconMethodInfo a signature where
    overloadedMethod _ = volumeGetIcon

-- method Volume::get_identifier
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "volume", argType = TInterface (Name {namespace = "Gio", name = "Volume"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GVolume", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "kind", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the kind of identifier to return", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_volume_get_identifier" g_volume_get_identifier :: 
    Ptr Volume ->                           -- volume : TInterface (Name {namespace = "Gio", name = "Volume"})
    CString ->                              -- kind : TBasicType TUTF8
    IO CString

{- |
Gets the identifier of the given kind for /@volume@/.
See the [introduction][volume-identifier] for more
information about volume identifiers.
-}
volumeGetIdentifier ::
    (B.CallStack.HasCallStack, MonadIO m, IsVolume a) =>
    a
    {- ^ /@volume@/: a 'GI.Gio.Interfaces.Volume.Volume' -}
    -> T.Text
    {- ^ /@kind@/: the kind of identifier to return -}
    -> m T.Text
    {- ^ __Returns:__ a newly allocated string containing the
    requested identfier, or 'Nothing' if the 'GI.Gio.Interfaces.Volume.Volume'
    doesn\'t have this kind of identifier -}
volumeGetIdentifier volume kind = liftIO $ do
    volume' <- unsafeManagedPtrCastPtr volume
    kind' <- textToCString kind
    result <- g_volume_get_identifier volume' kind'
    checkUnexpectedReturnNULL "volumeGetIdentifier" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr volume
    freeMem kind'
    return result'

data VolumeGetIdentifierMethodInfo
instance (signature ~ (T.Text -> m T.Text), MonadIO m, IsVolume a) => O.MethodInfo VolumeGetIdentifierMethodInfo a signature where
    overloadedMethod _ = volumeGetIdentifier

-- method Volume::get_mount
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "volume", argType = TInterface (Name {namespace = "Gio", name = "Volume"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GVolume", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "Mount"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_volume_get_mount" g_volume_get_mount :: 
    Ptr Volume ->                           -- volume : TInterface (Name {namespace = "Gio", name = "Volume"})
    IO (Ptr Gio.Mount.Mount)

{- |
Gets the mount for the /@volume@/.
-}
volumeGetMount ::
    (B.CallStack.HasCallStack, MonadIO m, IsVolume a) =>
    a
    {- ^ /@volume@/: a 'GI.Gio.Interfaces.Volume.Volume' -}
    -> m Gio.Mount.Mount
    {- ^ __Returns:__ a 'GI.Gio.Interfaces.Mount.Mount' or 'Nothing' if /@volume@/ isn\'t mounted.
    The returned object should be unreffed with 'GI.GObject.Objects.Object.objectUnref'
    when no longer needed. -}
volumeGetMount volume = liftIO $ do
    volume' <- unsafeManagedPtrCastPtr volume
    result <- g_volume_get_mount volume'
    checkUnexpectedReturnNULL "volumeGetMount" result
    result' <- (wrapObject Gio.Mount.Mount) result
    touchManagedPtr volume
    return result'

data VolumeGetMountMethodInfo
instance (signature ~ (m Gio.Mount.Mount), MonadIO m, IsVolume a) => O.MethodInfo VolumeGetMountMethodInfo a signature where
    overloadedMethod _ = volumeGetMount

-- method Volume::get_name
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "volume", argType = TInterface (Name {namespace = "Gio", name = "Volume"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GVolume", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_volume_get_name" g_volume_get_name :: 
    Ptr Volume ->                           -- volume : TInterface (Name {namespace = "Gio", name = "Volume"})
    IO CString

{- |
Gets the name of /@volume@/.
-}
volumeGetName ::
    (B.CallStack.HasCallStack, MonadIO m, IsVolume a) =>
    a
    {- ^ /@volume@/: a 'GI.Gio.Interfaces.Volume.Volume' -}
    -> m T.Text
    {- ^ __Returns:__ the name for the given /@volume@/. The returned string should
    be freed with 'GI.GLib.Functions.free' when no longer needed. -}
volumeGetName volume = liftIO $ do
    volume' <- unsafeManagedPtrCastPtr volume
    result <- g_volume_get_name volume'
    checkUnexpectedReturnNULL "volumeGetName" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr volume
    return result'

data VolumeGetNameMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsVolume a) => O.MethodInfo VolumeGetNameMethodInfo a signature where
    overloadedMethod _ = volumeGetName

-- method Volume::get_sort_key
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "volume", argType = TInterface (Name {namespace = "Gio", name = "Volume"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GVolume", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_volume_get_sort_key" g_volume_get_sort_key :: 
    Ptr Volume ->                           -- volume : TInterface (Name {namespace = "Gio", name = "Volume"})
    IO CString

{- |
Gets the sort key for /@volume@/, if any.

@since 2.32
-}
volumeGetSortKey ::
    (B.CallStack.HasCallStack, MonadIO m, IsVolume a) =>
    a
    {- ^ /@volume@/: a 'GI.Gio.Interfaces.Volume.Volume' -}
    -> m T.Text
    {- ^ __Returns:__ Sorting key for /@volume@/ or 'Nothing' if no such key is available -}
volumeGetSortKey volume = liftIO $ do
    volume' <- unsafeManagedPtrCastPtr volume
    result <- g_volume_get_sort_key volume'
    checkUnexpectedReturnNULL "volumeGetSortKey" result
    result' <- cstringToText result
    touchManagedPtr volume
    return result'

data VolumeGetSortKeyMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsVolume a) => O.MethodInfo VolumeGetSortKeyMethodInfo a signature where
    overloadedMethod _ = volumeGetSortKey

-- method Volume::get_symbolic_icon
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "volume", argType = TInterface (Name {namespace = "Gio", name = "Volume"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GVolume", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "Icon"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_volume_get_symbolic_icon" g_volume_get_symbolic_icon :: 
    Ptr Volume ->                           -- volume : TInterface (Name {namespace = "Gio", name = "Volume"})
    IO (Ptr Gio.Icon.Icon)

{- |
Gets the symbolic icon for /@volume@/.

@since 2.34
-}
volumeGetSymbolicIcon ::
    (B.CallStack.HasCallStack, MonadIO m, IsVolume a) =>
    a
    {- ^ /@volume@/: a 'GI.Gio.Interfaces.Volume.Volume' -}
    -> m Gio.Icon.Icon
    {- ^ __Returns:__ a 'GI.Gio.Interfaces.Icon.Icon'.
    The returned object should be unreffed with 'GI.GObject.Objects.Object.objectUnref'
    when no longer needed. -}
volumeGetSymbolicIcon volume = liftIO $ do
    volume' <- unsafeManagedPtrCastPtr volume
    result <- g_volume_get_symbolic_icon volume'
    checkUnexpectedReturnNULL "volumeGetSymbolicIcon" result
    result' <- (wrapObject Gio.Icon.Icon) result
    touchManagedPtr volume
    return result'

data VolumeGetSymbolicIconMethodInfo
instance (signature ~ (m Gio.Icon.Icon), MonadIO m, IsVolume a) => O.MethodInfo VolumeGetSymbolicIconMethodInfo a signature where
    overloadedMethod _ = volumeGetSymbolicIcon

-- method Volume::get_uuid
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "volume", argType = TInterface (Name {namespace = "Gio", name = "Volume"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GVolume", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_volume_get_uuid" g_volume_get_uuid :: 
    Ptr Volume ->                           -- volume : TInterface (Name {namespace = "Gio", name = "Volume"})
    IO CString

{- |
Gets the UUID for the /@volume@/. The reference is typically based on
the file system UUID for the volume in question and should be
considered an opaque string. Returns 'Nothing' if there is no UUID
available.
-}
volumeGetUuid ::
    (B.CallStack.HasCallStack, MonadIO m, IsVolume a) =>
    a
    {- ^ /@volume@/: a 'GI.Gio.Interfaces.Volume.Volume' -}
    -> m T.Text
    {- ^ __Returns:__ the UUID for /@volume@/ or 'Nothing' if no UUID can be computed.
    The returned string should be freed with 'GI.GLib.Functions.free'
    when no longer needed. -}
volumeGetUuid volume = liftIO $ do
    volume' <- unsafeManagedPtrCastPtr volume
    result <- g_volume_get_uuid volume'
    checkUnexpectedReturnNULL "volumeGetUuid" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr volume
    return result'

data VolumeGetUuidMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsVolume a) => O.MethodInfo VolumeGetUuidMethodInfo a signature where
    overloadedMethod _ = volumeGetUuid

-- method Volume::mount
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "volume", argType = TInterface (Name {namespace = "Gio", name = "Volume"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GVolume", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "MountMountFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "flags affecting the operation", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "mount_operation", argType = TInterface (Name {namespace = "Gio", name = "MountOperation"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GMountOperation or %NULL to avoid user interaction", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object, %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 5, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data that gets passed to @callback", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_volume_mount" g_volume_mount :: 
    Ptr Volume ->                           -- volume : TInterface (Name {namespace = "Gio", name = "Volume"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "MountMountFlags"})
    Ptr Gio.MountOperation.MountOperation -> -- mount_operation : TInterface (Name {namespace = "Gio", name = "MountOperation"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Mounts a volume. This is an asynchronous operation, and is
finished by calling 'GI.Gio.Interfaces.Volume.volumeMountFinish' with the /@volume@/
and 'GI.Gio.Interfaces.AsyncResult.AsyncResult' returned in the /@callback@/.
-}
volumeMount ::
    (B.CallStack.HasCallStack, MonadIO m, IsVolume a, Gio.MountOperation.IsMountOperation b, Gio.Cancellable.IsCancellable c) =>
    a
    {- ^ /@volume@/: a 'GI.Gio.Interfaces.Volume.Volume' -}
    -> [Gio.Flags.MountMountFlags]
    {- ^ /@flags@/: flags affecting the operation -}
    -> Maybe (b)
    {- ^ /@mountOperation@/: a 'GI.Gio.Objects.MountOperation.MountOperation' or 'Nothing' to avoid user interaction -}
    -> Maybe (c)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object, 'Nothing' to ignore -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback', or 'Nothing' -}
    -> m ()
volumeMount volume flags mountOperation cancellable callback = liftIO $ do
    volume' <- unsafeManagedPtrCastPtr volume
    let flags' = gflagsToWord flags
    maybeMountOperation <- case mountOperation of
        Nothing -> return nullPtr
        Just jMountOperation -> do
            jMountOperation' <- unsafeManagedPtrCastPtr jMountOperation
            return jMountOperation'
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_volume_mount volume' flags' maybeMountOperation maybeCancellable maybeCallback userData
    touchManagedPtr volume
    whenJust mountOperation touchManagedPtr
    whenJust cancellable touchManagedPtr
    return ()

data VolumeMountMethodInfo
instance (signature ~ ([Gio.Flags.MountMountFlags] -> Maybe (b) -> Maybe (c) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsVolume a, Gio.MountOperation.IsMountOperation b, Gio.Cancellable.IsCancellable c) => O.MethodInfo VolumeMountMethodInfo a signature where
    overloadedMethod _ = volumeMount

-- method Volume::mount_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "volume", argType = TInterface (Name {namespace = "Gio", name = "Volume"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GVolume", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_volume_mount_finish" g_volume_mount_finish :: 
    Ptr Volume ->                           -- volume : TInterface (Name {namespace = "Gio", name = "Volume"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Finishes mounting a volume. If any errors occurred during the operation,
/@error@/ will be set to contain the errors and 'False' will be returned.

If the mount operation succeeded, 'GI.Gio.Interfaces.Volume.volumeGetMount' on /@volume@/
is guaranteed to return the mount right after calling this
function; there\'s no need to listen for the \'mount-added\' signal on
'GI.Gio.Objects.VolumeMonitor.VolumeMonitor'.
-}
volumeMountFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsVolume a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@volume@/: a 'GI.Gio.Interfaces.Volume.Volume' -}
    -> b
    {- ^ /@result@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
volumeMountFinish volume result_ = liftIO $ do
    volume' <- unsafeManagedPtrCastPtr volume
    result_' <- unsafeManagedPtrCastPtr result_
    onException (do
        _ <- propagateGError $ g_volume_mount_finish volume' result_'
        touchManagedPtr volume
        touchManagedPtr result_
        return ()
     ) (do
        return ()
     )

data VolumeMountFinishMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsVolume a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo VolumeMountFinishMethodInfo a signature where
    overloadedMethod _ = volumeMountFinish

-- method Volume::should_automount
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "volume", argType = TInterface (Name {namespace = "Gio", name = "Volume"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GVolume", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_volume_should_automount" g_volume_should_automount :: 
    Ptr Volume ->                           -- volume : TInterface (Name {namespace = "Gio", name = "Volume"})
    IO CInt

{- |
Returns whether the volume should be automatically mounted.
-}
volumeShouldAutomount ::
    (B.CallStack.HasCallStack, MonadIO m, IsVolume a) =>
    a
    {- ^ /@volume@/: a 'GI.Gio.Interfaces.Volume.Volume' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the volume should be automatically mounted -}
volumeShouldAutomount volume = liftIO $ do
    volume' <- unsafeManagedPtrCastPtr volume
    result <- g_volume_should_automount volume'
    let result' = (/= 0) result
    touchManagedPtr volume
    return result'

data VolumeShouldAutomountMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsVolume a) => O.MethodInfo VolumeShouldAutomountMethodInfo a signature where
    overloadedMethod _ = volumeShouldAutomount