{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- /No description available in the introspection data./

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

module GI.OSTree.Objects.RepoFinderAvahi
    ( 

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


 -- * Methods
-- ** Overloaded methods #method:Overloaded methods#

#if defined(ENABLE_OVERLOADING)
    ResolveRepoFinderAvahiMethod            ,
#endif


-- ** new #method:new#

    repoFinderAvahiNew                      ,


-- ** start #method:start#

#if defined(ENABLE_OVERLOADING)
    RepoFinderAvahiStartMethodInfo          ,
#endif
    repoFinderAvahiStart                    ,


-- ** stop #method:stop#

#if defined(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.BasicTypes as B.Types
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.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
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 (SP.ManagedPtr RepoFinderAvahi)
    deriving (RepoFinderAvahi -> RepoFinderAvahi -> Bool
(RepoFinderAvahi -> RepoFinderAvahi -> Bool)
-> (RepoFinderAvahi -> RepoFinderAvahi -> Bool)
-> Eq RepoFinderAvahi
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RepoFinderAvahi -> RepoFinderAvahi -> Bool
$c/= :: RepoFinderAvahi -> RepoFinderAvahi -> Bool
== :: RepoFinderAvahi -> RepoFinderAvahi -> Bool
$c== :: RepoFinderAvahi -> RepoFinderAvahi -> Bool
Eq)

instance SP.ManagedPtrNewtype RepoFinderAvahi where
    toManagedPtr :: RepoFinderAvahi -> ManagedPtr RepoFinderAvahi
toManagedPtr (RepoFinderAvahi ManagedPtr RepoFinderAvahi
p) = ManagedPtr RepoFinderAvahi
p

foreign import ccall "ostree_repo_finder_avahi_get_type"
    c_ostree_repo_finder_avahi_get_type :: IO B.Types.GType

instance B.Types.TypedObject RepoFinderAvahi where
    glibType :: IO GType
glibType = IO GType
c_ostree_repo_finder_avahi_get_type

instance B.Types.GObject RepoFinderAvahi

-- | Convert 'RepoFinderAvahi' to and from 'Data.GI.Base.GValue.GValue' with 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue RepoFinderAvahi where
    toGValue :: RepoFinderAvahi -> IO GValue
toGValue RepoFinderAvahi
o = do
        GType
gtype <- IO GType
c_ostree_repo_finder_avahi_get_type
        RepoFinderAvahi -> (Ptr RepoFinderAvahi -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr RepoFinderAvahi
o (GType
-> (GValue -> Ptr RepoFinderAvahi -> IO ())
-> Ptr RepoFinderAvahi
-> IO GValue
forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
B.GValue.buildGValue GType
gtype GValue -> Ptr RepoFinderAvahi -> IO ()
forall a. GObject a => GValue -> Ptr a -> IO ()
B.GValue.set_object)
        
    fromGValue :: GValue -> IO RepoFinderAvahi
fromGValue GValue
gv = do
        Ptr RepoFinderAvahi
ptr <- GValue -> IO (Ptr RepoFinderAvahi)
forall b. GObject b => GValue -> IO (Ptr b)
B.GValue.get_object GValue
gv :: IO (Ptr RepoFinderAvahi)
        (ManagedPtr RepoFinderAvahi -> RepoFinderAvahi)
-> Ptr RepoFinderAvahi -> IO RepoFinderAvahi
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
B.ManagedPtr.newObject ManagedPtr RepoFinderAvahi -> RepoFinderAvahi
RepoFinderAvahi Ptr RepoFinderAvahi
ptr
        
    

-- | Type class for types which can be safely cast to `RepoFinderAvahi`, for instance with `toRepoFinderAvahi`.
class (SP.GObject o, O.IsDescendantOf RepoFinderAvahi o) => IsRepoFinderAvahi o
instance (SP.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 :: o -> m RepoFinderAvahi
toRepoFinderAvahi = IO RepoFinderAvahi -> m RepoFinderAvahi
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO RepoFinderAvahi -> m RepoFinderAvahi)
-> (o -> IO RepoFinderAvahi) -> o -> m RepoFinderAvahi
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr RepoFinderAvahi -> RepoFinderAvahi)
-> o -> IO RepoFinderAvahi
forall o o'.
(HasCallStack, ManagedPtrNewtype o, TypedObject o,
 ManagedPtrNewtype o', TypedObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
unsafeCastTo ManagedPtr RepoFinderAvahi -> RepoFinderAvahi
RepoFinderAvahi

#if defined(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 "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    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 @info
#else
    fromLabel _ = O.overloadedMethod @info
#endif

#endif

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

#if defined(ENABLE_OVERLOADING)
#endif

#if defined(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 :: MainContext -> m RepoFinderAvahi
repoFinderAvahiNew MainContext
context = IO RepoFinderAvahi -> m RepoFinderAvahi
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO RepoFinderAvahi -> m RepoFinderAvahi)
-> IO RepoFinderAvahi -> m RepoFinderAvahi
forall a b. (a -> b) -> a -> b
$ do
    Ptr MainContext
context' <- MainContext -> IO (Ptr MainContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr MainContext
context
    Ptr RepoFinderAvahi
result <- Ptr MainContext -> IO (Ptr RepoFinderAvahi)
ostree_repo_finder_avahi_new Ptr MainContext
context'
    Text -> Ptr RepoFinderAvahi -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"repoFinderAvahiNew" Ptr RepoFinderAvahi
result
    RepoFinderAvahi
result' <- ((ManagedPtr RepoFinderAvahi -> RepoFinderAvahi)
-> Ptr RepoFinderAvahi -> IO RepoFinderAvahi
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr RepoFinderAvahi -> RepoFinderAvahi
RepoFinderAvahi) Ptr RepoFinderAvahi
result
    MainContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr MainContext
context
    RepoFinderAvahi -> IO RepoFinderAvahi
forall (m :: * -> *) a. Monad m => a -> m a
return RepoFinderAvahi
result'

#if defined(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 t'GI.GLib.Structs.MainContext.MainContext'
-- passed to /@self@/ at construction time must be iterated (so it will typically
-- be the global t'GI.GLib.Structs.MainContext.MainContext', or be a separate t'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 t'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
-- t'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 t'GI.OSTree.Objects.RepoFinderAvahi.RepoFinderAvahi'
    -> m ()
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
repoFinderAvahiStart :: a -> m ()
repoFinderAvahiStart a
self = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr RepoFinderAvahi
self' <- a -> IO (Ptr RepoFinderAvahi)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
self
    IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
        (Ptr (Ptr GError) -> IO ()) -> IO ()
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO ()) -> IO ())
-> (Ptr (Ptr GError) -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ Ptr RepoFinderAvahi -> Ptr (Ptr GError) -> IO ()
ostree_repo_finder_avahi_start Ptr RepoFinderAvahi
self'
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
self
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

#if defined(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
-- t'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 t'GI.OSTree.Objects.RepoFinderAvahi.RepoFinderAvahi'
    -> m ()
repoFinderAvahiStop :: a -> m ()
repoFinderAvahiStop a
self = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr RepoFinderAvahi
self' <- a -> IO (Ptr RepoFinderAvahi)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
self
    Ptr RepoFinderAvahi -> IO ()
ostree_repo_finder_avahi_stop Ptr RepoFinderAvahi
self'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
self
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

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

#endif