gi-ostree-1.0.8: GI/OSTree/Structs/Remote.hs
{- |
Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License : LGPL-2.1
Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc)
This represents the configuration for a single remote repository. Currently,
remotes can only be passed around as (reference counted) opaque handles. In
future, more API may be added to create and interrogate them.
/Since: 2018.6/
-}
#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
&& !defined(__HADDOCK_VERSION__))
module GI.OSTree.Structs.Remote
(
-- * Exported types
Remote(..) ,
noRemote ,
-- * Methods
-- ** getName #method:getName#
#if ENABLE_OVERLOADING
RemoteGetNameMethodInfo ,
#endif
remoteGetName ,
-- ** getUrl #method:getUrl#
#if ENABLE_OVERLOADING
RemoteGetUrlMethodInfo ,
#endif
remoteGetUrl ,
-- ** ref #method:ref#
#if ENABLE_OVERLOADING
RemoteRefMethodInfo ,
#endif
remoteRef ,
-- ** unref #method:unref#
#if ENABLE_OVERLOADING
RemoteUnrefMethodInfo ,
#endif
remoteUnref ,
) 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
-- | Memory-managed wrapper type.
newtype Remote = Remote (ManagedPtr Remote)
foreign import ccall "ostree_remote_get_type" c_ostree_remote_get_type ::
IO GType
instance BoxedObject Remote where
boxedType _ = c_ostree_remote_get_type
-- | A convenience alias for `Nothing` :: `Maybe` `Remote`.
noRemote :: Maybe Remote
noRemote = Nothing
#if ENABLE_OVERLOADING
instance O.HasAttributeList Remote
type instance O.AttributeList Remote = RemoteAttributeList
type RemoteAttributeList = ('[ ] :: [(Symbol, *)])
#endif
-- method Remote::get_name
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "remote", argType = TInterface (Name {namespace = "OSTree", name = "Remote"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #OstreeRemote", 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 "ostree_remote_get_name" ostree_remote_get_name ::
Ptr Remote -> -- remote : TInterface (Name {namespace = "OSTree", name = "Remote"})
IO CString
{- |
Get the human-readable name of the remote. This is what the user configured,
if the remote was explicitly configured; and will otherwise be a stable,
arbitrary, string.
/Since: 2018.6/
-}
remoteGetName ::
(B.CallStack.HasCallStack, MonadIO m) =>
Remote
{- ^ /@remote@/: an 'GI.OSTree.Structs.Remote.Remote' -}
-> m T.Text
{- ^ __Returns:__ remote’s name -}
remoteGetName remote = liftIO $ do
remote' <- unsafeManagedPtrGetPtr remote
result <- ostree_remote_get_name remote'
checkUnexpectedReturnNULL "remoteGetName" result
result' <- cstringToText result
touchManagedPtr remote
return result'
#if ENABLE_OVERLOADING
data RemoteGetNameMethodInfo
instance (signature ~ (m T.Text), MonadIO m) => O.MethodInfo RemoteGetNameMethodInfo Remote signature where
overloadedMethod _ = remoteGetName
#endif
-- method Remote::get_url
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "remote", argType = TInterface (Name {namespace = "OSTree", name = "Remote"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #OstreeRemote", 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 "ostree_remote_get_url" ostree_remote_get_url ::
Ptr Remote -> -- remote : TInterface (Name {namespace = "OSTree", name = "Remote"})
IO CString
{- |
Get the URL from the remote.
/Since: 2018.6/
-}
remoteGetUrl ::
(B.CallStack.HasCallStack, MonadIO m) =>
Remote
{- ^ /@remote@/: an 'GI.OSTree.Structs.Remote.Remote' -}
-> m T.Text
{- ^ __Returns:__ the remote\'s URL -}
remoteGetUrl remote = liftIO $ do
remote' <- unsafeManagedPtrGetPtr remote
result <- ostree_remote_get_url remote'
checkUnexpectedReturnNULL "remoteGetUrl" result
result' <- cstringToText result
freeMem result
touchManagedPtr remote
return result'
#if ENABLE_OVERLOADING
data RemoteGetUrlMethodInfo
instance (signature ~ (m T.Text), MonadIO m) => O.MethodInfo RemoteGetUrlMethodInfo Remote signature where
overloadedMethod _ = remoteGetUrl
#endif
-- method Remote::ref
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "remote", argType = TInterface (Name {namespace = "OSTree", name = "Remote"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #OstreeRemote", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "OSTree", name = "Remote"}))
-- throws : False
-- Skip return : False
foreign import ccall "ostree_remote_ref" ostree_remote_ref ::
Ptr Remote -> -- remote : TInterface (Name {namespace = "OSTree", name = "Remote"})
IO (Ptr Remote)
{- |
Increase the reference count on the given /@remote@/.
/Since: 2018.6/
-}
remoteRef ::
(B.CallStack.HasCallStack, MonadIO m) =>
Remote
{- ^ /@remote@/: an 'GI.OSTree.Structs.Remote.Remote' -}
-> m Remote
{- ^ __Returns:__ a copy of /@remote@/, for convenience -}
remoteRef remote = liftIO $ do
remote' <- unsafeManagedPtrGetPtr remote
result <- ostree_remote_ref remote'
checkUnexpectedReturnNULL "remoteRef" result
result' <- (wrapBoxed Remote) result
touchManagedPtr remote
return result'
#if ENABLE_OVERLOADING
data RemoteRefMethodInfo
instance (signature ~ (m Remote), MonadIO m) => O.MethodInfo RemoteRefMethodInfo Remote signature where
overloadedMethod _ = remoteRef
#endif
-- method Remote::unref
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "remote", argType = TInterface (Name {namespace = "OSTree", name = "Remote"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #OstreeRemote", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False
foreign import ccall "ostree_remote_unref" ostree_remote_unref ::
Ptr Remote -> -- remote : TInterface (Name {namespace = "OSTree", name = "Remote"})
IO ()
{- |
Decrease the reference count on the given /@remote@/ and free it if the
reference count reaches 0.
/Since: 2018.6/
-}
remoteUnref ::
(B.CallStack.HasCallStack, MonadIO m) =>
Remote
{- ^ /@remote@/: an 'GI.OSTree.Structs.Remote.Remote' -}
-> m ()
remoteUnref remote = liftIO $ do
remote' <- B.ManagedPtr.disownBoxed remote
ostree_remote_unref remote'
touchManagedPtr remote
return ()
#if ENABLE_OVERLOADING
data RemoteUnrefMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo RemoteUnrefMethodInfo Remote signature where
overloadedMethod _ = remoteUnref
#endif
#if ENABLE_OVERLOADING
type family ResolveRemoteMethod (t :: Symbol) (o :: *) :: * where
ResolveRemoteMethod "ref" o = RemoteRefMethodInfo
ResolveRemoteMethod "unref" o = RemoteUnrefMethodInfo
ResolveRemoteMethod "getName" o = RemoteGetNameMethodInfo
ResolveRemoteMethod "getUrl" o = RemoteGetUrlMethodInfo
ResolveRemoteMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveRemoteMethod t Remote, O.MethodInfo info Remote p) => OL.IsLabel t (Remote -> 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