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

/No description available in the introspection data./
-}

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

module GI.OSTree.Objects.RepoFinderAvahi
    (

-- * Exported types
    RepoFinderAvahi(..)                     ,
    IsRepoFinderAvahi                       ,
    toRepoFinderAvahi                       ,
    noRepoFinderAvahi                       ,


 -- * Methods
-- ** new #method:new#

    repoFinderAvahiNew                      ,


-- ** start #method:start#

#if ENABLE_OVERLOADING
    RepoFinderAvahiStartMethodInfo          ,
#endif
    repoFinderAvahiStart                    ,


-- ** stop #method:stop#

#if ENABLE_OVERLOADING
    RepoFinderAvahiStopMethodInfo           ,
#endif
    repoFinderAvahiStop                     ,




    ) 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.Structs.MainContext as GLib.MainContext
import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.OSTree.Interfaces.RepoFinder as OSTree.RepoFinder

-- | Memory-managed wrapper type.
newtype RepoFinderAvahi = RepoFinderAvahi (ManagedPtr RepoFinderAvahi)
foreign import ccall "ostree_repo_finder_avahi_get_type"
    c_ostree_repo_finder_avahi_get_type :: IO GType

instance GObject RepoFinderAvahi where
    gobjectType = c_ostree_repo_finder_avahi_get_type


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

instance O.HasParentTypes RepoFinderAvahi
type instance O.ParentTypes RepoFinderAvahi = '[GObject.Object.Object, OSTree.RepoFinder.RepoFinder]

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

-- | A convenience alias for `Nothing` :: `Maybe` `RepoFinderAvahi`.
noRepoFinderAvahi :: Maybe RepoFinderAvahi
noRepoFinderAvahi = Nothing

#if ENABLE_OVERLOADING
type family ResolveRepoFinderAvahiMethod (t :: Symbol) (o :: *) :: * where
    ResolveRepoFinderAvahiMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveRepoFinderAvahiMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveRepoFinderAvahiMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveRepoFinderAvahiMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveRepoFinderAvahiMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveRepoFinderAvahiMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveRepoFinderAvahiMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveRepoFinderAvahiMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveRepoFinderAvahiMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveRepoFinderAvahiMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveRepoFinderAvahiMethod "resolveAsync" o = OSTree.RepoFinder.RepoFinderResolveAsyncMethodInfo
    ResolveRepoFinderAvahiMethod "resolveFinish" o = OSTree.RepoFinder.RepoFinderResolveFinishMethodInfo
    ResolveRepoFinderAvahiMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveRepoFinderAvahiMethod "start" o = RepoFinderAvahiStartMethodInfo
    ResolveRepoFinderAvahiMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveRepoFinderAvahiMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveRepoFinderAvahiMethod "stop" o = RepoFinderAvahiStopMethodInfo
    ResolveRepoFinderAvahiMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveRepoFinderAvahiMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveRepoFinderAvahiMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveRepoFinderAvahiMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveRepoFinderAvahiMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveRepoFinderAvahiMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveRepoFinderAvahiMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveRepoFinderAvahiMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveRepoFinderAvahiMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveRepoFinderAvahiMethod t RepoFinderAvahi, O.MethodInfo info RepoFinderAvahi p) => OL.IsLabel t (RepoFinderAvahi -> 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 RepoFinderAvahi
type instance O.AttributeList RepoFinderAvahi = RepoFinderAvahiAttributeList
type RepoFinderAvahiAttributeList = ('[ ] :: [(Symbol, *)])
#endif

#if ENABLE_OVERLOADING
#endif

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

#endif

-- method RepoFinderAvahi::new
-- method type : Constructor
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "GLib", name = "MainContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "OSTree", name = "RepoFinderAvahi"}))
-- throws : False
-- Skip return : False

foreign import ccall "ostree_repo_finder_avahi_new" ostree_repo_finder_avahi_new ::
    Ptr GLib.MainContext.MainContext ->     -- context : TInterface (Name {namespace = "GLib", name = "MainContext"})
    IO (Ptr RepoFinderAvahi)

{- |
/No description available in the introspection data./
-}
repoFinderAvahiNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GLib.MainContext.MainContext
    -> m RepoFinderAvahi
repoFinderAvahiNew context = liftIO $ do
    context' <- unsafeManagedPtrGetPtr context
    result <- ostree_repo_finder_avahi_new context'
    checkUnexpectedReturnNULL "repoFinderAvahiNew" result
    result' <- (wrapObject RepoFinderAvahi) result
    touchManagedPtr context
    return result'

#if ENABLE_OVERLOADING
#endif

-- method RepoFinderAvahi::start
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "OSTree", name = "RepoFinderAvahi"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #OstreeRepoFinderAvahi", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : True
-- Skip return : False

foreign import ccall "ostree_repo_finder_avahi_start" ostree_repo_finder_avahi_start ::
    Ptr RepoFinderAvahi ->                  -- self : TInterface (Name {namespace = "OSTree", name = "RepoFinderAvahi"})
    Ptr (Ptr GError) ->                     -- error
    IO ()

{- |
Start monitoring the local network for peers who are advertising OSTree
repositories, using Avahi. In order for this to work, the 'GI.GLib.Structs.MainContext.MainContext'
passed to /@self@/ at construction time must be iterated (so it will typically
be the global 'GI.GLib.Structs.MainContext.MainContext', or be a separate 'GI.GLib.Structs.MainContext.MainContext' in a worker
thread).

This will return an error ('GI.Gio.Enums.IOErrorEnumFailed') if initialisation fails, or if
Avahi support is not available ('GI.Gio.Enums.IOErrorEnumNotSupported'). In either case,
the 'GI.OSTree.Objects.RepoFinderAvahi.RepoFinderAvahi' instance is useless afterwards and should be
destroyed.

Call 'GI.OSTree.Objects.RepoFinderAvahi.repoFinderAvahiStop' to stop the repo finder.

It is an error to call this function multiple times on the same
'GI.OSTree.Objects.RepoFinderAvahi.RepoFinderAvahi' instance, or to call it after
'GI.OSTree.Objects.RepoFinderAvahi.repoFinderAvahiStop'.

/Since: 2018.6/
-}
repoFinderAvahiStart ::
    (B.CallStack.HasCallStack, MonadIO m, IsRepoFinderAvahi a) =>
    a
    {- ^ /@self@/: an 'GI.OSTree.Objects.RepoFinderAvahi.RepoFinderAvahi' -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
repoFinderAvahiStart self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    onException (do
        propagateGError $ ostree_repo_finder_avahi_start self'
        touchManagedPtr self
        return ()
     ) (do
        return ()
     )

#if ENABLE_OVERLOADING
data RepoFinderAvahiStartMethodInfo
instance (signature ~ (m ()), MonadIO m, IsRepoFinderAvahi a) => O.MethodInfo RepoFinderAvahiStartMethodInfo a signature where
    overloadedMethod _ = repoFinderAvahiStart

#endif

-- method RepoFinderAvahi::stop
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "OSTree", name = "RepoFinderAvahi"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #OstreeRepoFinderAvahi", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "ostree_repo_finder_avahi_stop" ostree_repo_finder_avahi_stop ::
    Ptr RepoFinderAvahi ->                  -- self : TInterface (Name {namespace = "OSTree", name = "RepoFinderAvahi"})
    IO ()

{- |
Stop monitoring the local network for peers who are advertising OSTree
repositories. If any resolve tasks (from 'GI.OSTree.Interfaces.RepoFinder.repoFinderResolveAsync')
are in progress, they will be cancelled and will return 'GI.Gio.Enums.IOErrorEnumCancelled'.

Call 'GI.OSTree.Objects.RepoFinderAvahi.repoFinderAvahiStart' to start the repo finder.

It is an error to call this function multiple times on the same
'GI.OSTree.Objects.RepoFinderAvahi.RepoFinderAvahi' instance, or to call it before
'GI.OSTree.Objects.RepoFinderAvahi.repoFinderAvahiStart'.

/Since: 2018.6/
-}
repoFinderAvahiStop ::
    (B.CallStack.HasCallStack, MonadIO m, IsRepoFinderAvahi a) =>
    a
    {- ^ /@self@/: an 'GI.OSTree.Objects.RepoFinderAvahi.RepoFinderAvahi' -}
    -> m ()
repoFinderAvahiStop self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    ostree_repo_finder_avahi_stop self'
    touchManagedPtr self
    return ()

#if ENABLE_OVERLOADING
data RepoFinderAvahiStopMethodInfo
instance (signature ~ (m ()), MonadIO m, IsRepoFinderAvahi a) => O.MethodInfo RepoFinderAvahiStopMethodInfo a signature where
    overloadedMethod _ = repoFinderAvahiStop

#endif