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

Entry point for using GIO functionality.
-}

#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
       && !defined(__HADDOCK_VERSION__))

module GI.Gio.Objects.Vfs
    (

-- * Exported types
    Vfs(..)                                 ,
    IsVfs                                   ,
    toVfs                                   ,
    noVfs                                   ,


 -- * Methods
-- ** getDefault #method:getDefault#

    vfsGetDefault                           ,


-- ** getFileForPath #method:getFileForPath#

#if ENABLE_OVERLOADING
    VfsGetFileForPathMethodInfo             ,
#endif
    vfsGetFileForPath                       ,


-- ** getFileForUri #method:getFileForUri#

#if ENABLE_OVERLOADING
    VfsGetFileForUriMethodInfo              ,
#endif
    vfsGetFileForUri                        ,


-- ** getLocal #method:getLocal#

    vfsGetLocal                             ,


-- ** getSupportedUriSchemes #method:getSupportedUriSchemes#

#if ENABLE_OVERLOADING
    VfsGetSupportedUriSchemesMethodInfo     ,
#endif
    vfsGetSupportedUriSchemes               ,


-- ** isActive #method:isActive#

#if ENABLE_OVERLOADING
    VfsIsActiveMethodInfo                   ,
#endif
    vfsIsActive                             ,


-- ** parseName #method:parseName#

#if ENABLE_OVERLOADING
    VfsParseNameMethodInfo                  ,
#endif
    vfsParseName                            ,


-- ** registerUriScheme #method:registerUriScheme#

#if ENABLE_OVERLOADING
    VfsRegisterUriSchemeMethodInfo          ,
#endif
    vfsRegisterUriScheme                    ,


-- ** unregisterUriScheme #method:unregisterUriScheme#

#if ENABLE_OVERLOADING
    VfsUnregisterUriSchemeMethodInfo        ,
#endif
    vfsUnregisterUriScheme                  ,




    ) 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.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
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 GHC.OverloadedLabels as OL

import qualified GI.GLib.Callbacks as GLib.Callbacks
import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Callbacks as Gio.Callbacks
import {-# SOURCE #-} qualified GI.Gio.Interfaces.File as Gio.File

-- | Memory-managed wrapper type.
newtype Vfs = Vfs (ManagedPtr Vfs)
foreign import ccall "g_vfs_get_type"
    c_g_vfs_get_type :: IO GType

instance GObject Vfs where
    gobjectType = c_g_vfs_get_type


-- | Type class for types which can be safely cast to `Vfs`, for instance with `toVfs`.
class (GObject o, O.IsDescendantOf Vfs o) => IsVfs o
instance (GObject o, O.IsDescendantOf Vfs o) => IsVfs o

instance O.HasParentTypes Vfs
type instance O.ParentTypes Vfs = '[GObject.Object.Object]

-- | Cast to `Vfs`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toVfs :: (MonadIO m, IsVfs o) => o -> m Vfs
toVfs = liftIO . unsafeCastTo Vfs

-- | A convenience alias for `Nothing` :: `Maybe` `Vfs`.
noVfs :: Maybe Vfs
noVfs = Nothing

#if ENABLE_OVERLOADING
type family ResolveVfsMethod (t :: Symbol) (o :: *) :: * where
    ResolveVfsMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveVfsMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveVfsMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveVfsMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveVfsMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveVfsMethod "isActive" o = VfsIsActiveMethodInfo
    ResolveVfsMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveVfsMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveVfsMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveVfsMethod "parseName" o = VfsParseNameMethodInfo
    ResolveVfsMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveVfsMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveVfsMethod "registerUriScheme" o = VfsRegisterUriSchemeMethodInfo
    ResolveVfsMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveVfsMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveVfsMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveVfsMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveVfsMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveVfsMethod "unregisterUriScheme" o = VfsUnregisterUriSchemeMethodInfo
    ResolveVfsMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveVfsMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveVfsMethod "getFileForPath" o = VfsGetFileForPathMethodInfo
    ResolveVfsMethod "getFileForUri" o = VfsGetFileForUriMethodInfo
    ResolveVfsMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveVfsMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveVfsMethod "getSupportedUriSchemes" o = VfsGetSupportedUriSchemesMethodInfo
    ResolveVfsMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveVfsMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveVfsMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveVfsMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveVfsMethod t Vfs, O.MethodInfo info Vfs p) => OL.IsLabel t (Vfs -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

#endif

#if ENABLE_OVERLOADING
instance O.HasAttributeList Vfs
type instance O.AttributeList Vfs = VfsAttributeList
type VfsAttributeList = ('[ ] :: [(Symbol, *)])
#endif

#if ENABLE_OVERLOADING
#endif

#if ENABLE_OVERLOADING
type instance O.SignalList Vfs = VfsSignalList
type VfsSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

-- method Vfs::get_file_for_path
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "vfs", argType = TInterface (Name {namespace = "Gio", name = "Vfs"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GVfs.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "path", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string containing a VFS path.", 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_vfs_get_file_for_path" g_vfs_get_file_for_path ::
    Ptr Vfs ->                              -- vfs : TInterface (Name {namespace = "Gio", name = "Vfs"})
    CString ->                              -- path : TBasicType TUTF8
    IO (Ptr Gio.File.File)

{- |
Gets a 'GI.Gio.Interfaces.File.File' for /@path@/.
-}
vfsGetFileForPath ::
    (B.CallStack.HasCallStack, MonadIO m, IsVfs a) =>
    a
    {- ^ /@vfs@/: a 'GI.Gio.Objects.Vfs.Vfs'. -}
    -> T.Text
    {- ^ /@path@/: a string containing a VFS path. -}
    -> m Gio.File.File
    {- ^ __Returns:__ a 'GI.Gio.Interfaces.File.File'.
    Free the returned object with 'GI.GObject.Objects.Object.objectUnref'. -}
vfsGetFileForPath vfs path = liftIO $ do
    vfs' <- unsafeManagedPtrCastPtr vfs
    path' <- textToCString path
    result <- g_vfs_get_file_for_path vfs' path'
    checkUnexpectedReturnNULL "vfsGetFileForPath" result
    result' <- (wrapObject Gio.File.File) result
    touchManagedPtr vfs
    freeMem path'
    return result'

#if ENABLE_OVERLOADING
data VfsGetFileForPathMethodInfo
instance (signature ~ (T.Text -> m Gio.File.File), MonadIO m, IsVfs a) => O.MethodInfo VfsGetFileForPathMethodInfo a signature where
    overloadedMethod _ = vfsGetFileForPath

#endif

-- method Vfs::get_file_for_uri
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "vfs", argType = TInterface (Name {namespace = "Gio", name = "Vfs"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a#GVfs.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "uri", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string containing a URI", 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_vfs_get_file_for_uri" g_vfs_get_file_for_uri ::
    Ptr Vfs ->                              -- vfs : TInterface (Name {namespace = "Gio", name = "Vfs"})
    CString ->                              -- uri : TBasicType TUTF8
    IO (Ptr Gio.File.File)

{- |
Gets a 'GI.Gio.Interfaces.File.File' for /@uri@/.

This operation never fails, but the returned object
might not support any I\/O operation if the URI
is malformed or if the URI scheme is not supported.
-}
vfsGetFileForUri ::
    (B.CallStack.HasCallStack, MonadIO m, IsVfs a) =>
    a
    {- ^ /@vfs@/: a'GI.Gio.Objects.Vfs.Vfs'. -}
    -> T.Text
    {- ^ /@uri@/: a string containing a URI -}
    -> m Gio.File.File
    {- ^ __Returns:__ a 'GI.Gio.Interfaces.File.File'.
    Free the returned object with 'GI.GObject.Objects.Object.objectUnref'. -}
vfsGetFileForUri vfs uri = liftIO $ do
    vfs' <- unsafeManagedPtrCastPtr vfs
    uri' <- textToCString uri
    result <- g_vfs_get_file_for_uri vfs' uri'
    checkUnexpectedReturnNULL "vfsGetFileForUri" result
    result' <- (wrapObject Gio.File.File) result
    touchManagedPtr vfs
    freeMem uri'
    return result'

#if ENABLE_OVERLOADING
data VfsGetFileForUriMethodInfo
instance (signature ~ (T.Text -> m Gio.File.File), MonadIO m, IsVfs a) => O.MethodInfo VfsGetFileForUriMethodInfo a signature where
    overloadedMethod _ = vfsGetFileForUri

#endif

-- method Vfs::get_supported_uri_schemes
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "vfs", argType = TInterface (Name {namespace = "Gio", name = "Vfs"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GVfs.", 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_vfs_get_supported_uri_schemes" g_vfs_get_supported_uri_schemes ::
    Ptr Vfs ->                              -- vfs : TInterface (Name {namespace = "Gio", name = "Vfs"})
    IO (Ptr CString)

{- |
Gets a list of URI schemes supported by /@vfs@/.
-}
vfsGetSupportedUriSchemes ::
    (B.CallStack.HasCallStack, MonadIO m, IsVfs a) =>
    a
    {- ^ /@vfs@/: a 'GI.Gio.Objects.Vfs.Vfs'. -}
    -> m [T.Text]
    {- ^ __Returns:__ a 'Nothing'-terminated array of strings.
    The returned array belongs to GIO and must
    not be freed or modified. -}
vfsGetSupportedUriSchemes vfs = liftIO $ do
    vfs' <- unsafeManagedPtrCastPtr vfs
    result <- g_vfs_get_supported_uri_schemes vfs'
    checkUnexpectedReturnNULL "vfsGetSupportedUriSchemes" result
    result' <- unpackZeroTerminatedUTF8CArray result
    touchManagedPtr vfs
    return result'

#if ENABLE_OVERLOADING
data VfsGetSupportedUriSchemesMethodInfo
instance (signature ~ (m [T.Text]), MonadIO m, IsVfs a) => O.MethodInfo VfsGetSupportedUriSchemesMethodInfo a signature where
    overloadedMethod _ = vfsGetSupportedUriSchemes

#endif

-- method Vfs::is_active
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "vfs", argType = TInterface (Name {namespace = "Gio", name = "Vfs"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GVfs.", 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_vfs_is_active" g_vfs_is_active ::
    Ptr Vfs ->                              -- vfs : TInterface (Name {namespace = "Gio", name = "Vfs"})
    IO CInt

{- |
Checks if the VFS is active.
-}
vfsIsActive ::
    (B.CallStack.HasCallStack, MonadIO m, IsVfs a) =>
    a
    {- ^ /@vfs@/: a 'GI.Gio.Objects.Vfs.Vfs'. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if construction of the /@vfs@/ was successful
    and it is now active. -}
vfsIsActive vfs = liftIO $ do
    vfs' <- unsafeManagedPtrCastPtr vfs
    result <- g_vfs_is_active vfs'
    let result' = (/= 0) result
    touchManagedPtr vfs
    return result'

#if ENABLE_OVERLOADING
data VfsIsActiveMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsVfs a) => O.MethodInfo VfsIsActiveMethodInfo a signature where
    overloadedMethod _ = vfsIsActive

#endif

-- method Vfs::parse_name
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "vfs", argType = TInterface (Name {namespace = "Gio", name = "Vfs"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GVfs.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "parse_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string to be parsed by the VFS module.", 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_vfs_parse_name" g_vfs_parse_name ::
    Ptr Vfs ->                              -- vfs : TInterface (Name {namespace = "Gio", name = "Vfs"})
    CString ->                              -- parse_name : TBasicType TUTF8
    IO (Ptr Gio.File.File)

{- |
This operation never fails, but the returned object might
not support any I\/O operations if the /@parseName@/ cannot
be parsed by the 'GI.Gio.Objects.Vfs.Vfs' module.
-}
vfsParseName ::
    (B.CallStack.HasCallStack, MonadIO m, IsVfs a) =>
    a
    {- ^ /@vfs@/: a 'GI.Gio.Objects.Vfs.Vfs'. -}
    -> T.Text
    {- ^ /@parseName@/: a string to be parsed by the VFS module. -}
    -> m Gio.File.File
    {- ^ __Returns:__ a 'GI.Gio.Interfaces.File.File' for the given /@parseName@/.
    Free the returned object with 'GI.GObject.Objects.Object.objectUnref'. -}
vfsParseName vfs parseName = liftIO $ do
    vfs' <- unsafeManagedPtrCastPtr vfs
    parseName' <- textToCString parseName
    result <- g_vfs_parse_name vfs' parseName'
    checkUnexpectedReturnNULL "vfsParseName" result
    result' <- (wrapObject Gio.File.File) result
    touchManagedPtr vfs
    freeMem parseName'
    return result'

#if ENABLE_OVERLOADING
data VfsParseNameMethodInfo
instance (signature ~ (T.Text -> m Gio.File.File), MonadIO m, IsVfs a) => O.MethodInfo VfsParseNameMethodInfo a signature where
    overloadedMethod _ = vfsParseName

#endif

-- method Vfs::register_uri_scheme
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "vfs", argType = TInterface (Name {namespace = "Gio", name = "Vfs"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GVfs", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "scheme", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an URI scheme, e.g. \"http\"", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "uri_func", argType = TInterface (Name {namespace = "Gio", name = "VfsFileLookupFunc"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GVfsFileLookupFunc", sinceVersion = Nothing}, argScope = ScopeTypeNotified, argClosure = 3, argDestroy = 4, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "uri_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "custom data passed to be passed to @uri_func, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "uri_destroy", argType = TInterface (Name {namespace = "GLib", name = "DestroyNotify"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "function to be called when unregistering the\n    URI scheme, or when @vfs is disposed, to free the resources used\n    by the URI lookup function", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "parse_name_func", argType = TInterface (Name {namespace = "Gio", name = "VfsFileLookupFunc"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GVfsFileLookupFunc", sinceVersion = Nothing}, argScope = ScopeTypeNotified, argClosure = 6, argDestroy = 7, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "parse_name_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "custom data passed to be passed to\n    @parse_name_func, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "parse_name_destroy", argType = TInterface (Name {namespace = "GLib", name = "DestroyNotify"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "function to be called when unregistering the\n    URI scheme, or when @vfs is disposed, to free the resources used\n    by the parse name lookup function", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_vfs_register_uri_scheme" g_vfs_register_uri_scheme ::
    Ptr Vfs ->                              -- vfs : TInterface (Name {namespace = "Gio", name = "Vfs"})
    CString ->                              -- scheme : TBasicType TUTF8
    FunPtr Gio.Callbacks.C_VfsFileLookupFunc -> -- uri_func : TInterface (Name {namespace = "Gio", name = "VfsFileLookupFunc"})
    Ptr () ->                               -- uri_data : TBasicType TPtr
    FunPtr GLib.Callbacks.C_DestroyNotify -> -- uri_destroy : TInterface (Name {namespace = "GLib", name = "DestroyNotify"})
    FunPtr Gio.Callbacks.C_VfsFileLookupFunc -> -- parse_name_func : TInterface (Name {namespace = "Gio", name = "VfsFileLookupFunc"})
    Ptr () ->                               -- parse_name_data : TBasicType TPtr
    FunPtr GLib.Callbacks.C_DestroyNotify -> -- parse_name_destroy : TInterface (Name {namespace = "GLib", name = "DestroyNotify"})
    IO CInt

{- |
Registers /@uriFunc@/ and /@parseNameFunc@/ as the 'GI.Gio.Interfaces.File.File' URI and parse name
lookup functions for URIs with a scheme matching /@scheme@/.
Note that /@scheme@/ is registered only within the running application, as
opposed to desktop-wide as it happens with GVfs backends.

When a 'GI.Gio.Interfaces.File.File' is requested with an URI containing /@scheme@/ (e.g. through
'GI.Gio.Functions.fileNewForUri'), /@uriFunc@/ will be called to allow a custom
constructor. The implementation of /@uriFunc@/ should not be blocking, and
must not call 'GI.Gio.Objects.Vfs.vfsRegisterUriScheme' or 'GI.Gio.Objects.Vfs.vfsUnregisterUriScheme'.

When 'GI.Gio.Functions.fileParseName' is called with a parse name obtained from such file,
/@parseNameFunc@/ will be called to allow the 'GI.Gio.Interfaces.File.File' to be created again. In
that case, it\'s responsibility of /@parseNameFunc@/ to make sure the parse
name matches what the custom 'GI.Gio.Interfaces.File.File' implementation returned when
'GI.Gio.Interfaces.File.fileGetParseName' was previously called. The implementation of
/@parseNameFunc@/ should not be blocking, and must not call
'GI.Gio.Objects.Vfs.vfsRegisterUriScheme' or 'GI.Gio.Objects.Vfs.vfsUnregisterUriScheme'.

It\'s an error to call this function twice with the same scheme. To unregister
a custom URI scheme, use 'GI.Gio.Objects.Vfs.vfsUnregisterUriScheme'.

/Since: 2.50/
-}
vfsRegisterUriScheme ::
    (B.CallStack.HasCallStack, MonadIO m, IsVfs a) =>
    a
    {- ^ /@vfs@/: a 'GI.Gio.Objects.Vfs.Vfs' -}
    -> T.Text
    {- ^ /@scheme@/: an URI scheme, e.g. \"http\" -}
    -> Maybe (Gio.Callbacks.VfsFileLookupFunc)
    {- ^ /@uriFunc@/: a 'GI.Gio.Callbacks.VfsFileLookupFunc' -}
    -> Maybe (Gio.Callbacks.VfsFileLookupFunc)
    {- ^ /@parseNameFunc@/: a 'GI.Gio.Callbacks.VfsFileLookupFunc' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@scheme@/ was successfully registered, or 'False' if a handler
    for /@scheme@/ already exists. -}
vfsRegisterUriScheme vfs scheme uriFunc parseNameFunc = liftIO $ do
    vfs' <- unsafeManagedPtrCastPtr vfs
    scheme' <- textToCString scheme
    maybeUriFunc <- case uriFunc of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jUriFunc -> do
            jUriFunc' <- Gio.Callbacks.mk_VfsFileLookupFunc (Gio.Callbacks.wrap_VfsFileLookupFunc Nothing (Gio.Callbacks.drop_closures_VfsFileLookupFunc jUriFunc))
            return jUriFunc'
    maybeParseNameFunc <- case parseNameFunc of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jParseNameFunc -> do
            jParseNameFunc' <- Gio.Callbacks.mk_VfsFileLookupFunc (Gio.Callbacks.wrap_VfsFileLookupFunc Nothing (Gio.Callbacks.drop_closures_VfsFileLookupFunc jParseNameFunc))
            return jParseNameFunc'
    let uriData = castFunPtrToPtr maybeUriFunc
    let uriDestroy = safeFreeFunPtrPtr
    let parseNameData = castFunPtrToPtr maybeParseNameFunc
    let parseNameDestroy = safeFreeFunPtrPtr
    result <- g_vfs_register_uri_scheme vfs' scheme' maybeUriFunc uriData uriDestroy maybeParseNameFunc parseNameData parseNameDestroy
    let result' = (/= 0) result
    touchManagedPtr vfs
    freeMem scheme'
    return result'

#if ENABLE_OVERLOADING
data VfsRegisterUriSchemeMethodInfo
instance (signature ~ (T.Text -> Maybe (Gio.Callbacks.VfsFileLookupFunc) -> Maybe (Gio.Callbacks.VfsFileLookupFunc) -> m Bool), MonadIO m, IsVfs a) => O.MethodInfo VfsRegisterUriSchemeMethodInfo a signature where
    overloadedMethod _ = vfsRegisterUriScheme

#endif

-- method Vfs::unregister_uri_scheme
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "vfs", argType = TInterface (Name {namespace = "Gio", name = "Vfs"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GVfs", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "scheme", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an URI scheme, e.g. \"http\"", 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_vfs_unregister_uri_scheme" g_vfs_unregister_uri_scheme ::
    Ptr Vfs ->                              -- vfs : TInterface (Name {namespace = "Gio", name = "Vfs"})
    CString ->                              -- scheme : TBasicType TUTF8
    IO CInt

{- |
Unregisters the URI handler for /@scheme@/ previously registered with
'GI.Gio.Objects.Vfs.vfsRegisterUriScheme'.

/Since: 2.50/
-}
vfsUnregisterUriScheme ::
    (B.CallStack.HasCallStack, MonadIO m, IsVfs a) =>
    a
    {- ^ /@vfs@/: a 'GI.Gio.Objects.Vfs.Vfs' -}
    -> T.Text
    {- ^ /@scheme@/: an URI scheme, e.g. \"http\" -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@scheme@/ was successfully unregistered, or 'False' if a
    handler for /@scheme@/ does not exist. -}
vfsUnregisterUriScheme vfs scheme = liftIO $ do
    vfs' <- unsafeManagedPtrCastPtr vfs
    scheme' <- textToCString scheme
    result <- g_vfs_unregister_uri_scheme vfs' scheme'
    let result' = (/= 0) result
    touchManagedPtr vfs
    freeMem scheme'
    return result'

#if ENABLE_OVERLOADING
data VfsUnregisterUriSchemeMethodInfo
instance (signature ~ (T.Text -> m Bool), MonadIO m, IsVfs a) => O.MethodInfo VfsUnregisterUriSchemeMethodInfo a signature where
    overloadedMethod _ = vfsUnregisterUriScheme

#endif

-- method Vfs::get_default
-- method type : MemberFunction
-- Args : []
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "Vfs"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_vfs_get_default" g_vfs_get_default ::
    IO (Ptr Vfs)

{- |
Gets the default 'GI.Gio.Objects.Vfs.Vfs' for the system.
-}
vfsGetDefault ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Vfs
    {- ^ __Returns:__ a 'GI.Gio.Objects.Vfs.Vfs'. -}
vfsGetDefault  = liftIO $ do
    result <- g_vfs_get_default
    checkUnexpectedReturnNULL "vfsGetDefault" result
    result' <- (newObject Vfs) result
    return result'

#if ENABLE_OVERLOADING
#endif

-- method Vfs::get_local
-- method type : MemberFunction
-- Args : []
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "Vfs"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_vfs_get_local" g_vfs_get_local ::
    IO (Ptr Vfs)

{- |
Gets the local 'GI.Gio.Objects.Vfs.Vfs' for the system.
-}
vfsGetLocal ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Vfs
    {- ^ __Returns:__ a 'GI.Gio.Objects.Vfs.Vfs'. -}
vfsGetLocal  = liftIO $ do
    result <- g_vfs_get_local
    checkUnexpectedReturnNULL "vfsGetLocal" result
    result' <- (newObject Vfs) result
    return result'

#if ENABLE_OVERLOADING
#endif