{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- t'GI.Gio.Objects.Resolver.Resolver' provides cancellable synchronous and asynchronous DNS
-- resolution, for hostnames ('GI.Gio.Objects.Resolver.resolverLookupByAddress',
-- 'GI.Gio.Objects.Resolver.resolverLookupByName' and their async variants) and SRV
-- (service) records ('GI.Gio.Objects.Resolver.resolverLookupService').
-- 
-- t'GI.Gio.Objects.NetworkAddress.NetworkAddress' and t'GI.Gio.Objects.NetworkService.NetworkService' provide wrappers around
-- t'GI.Gio.Objects.Resolver.Resolver' functionality that also implement t'GI.Gio.Interfaces.SocketConnectable.SocketConnectable',
-- making it easy to connect to a remote host\/service.

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

module GI.Gio.Objects.Resolver
    ( 

-- * Exported types
    Resolver(..)                            ,
    IsResolver                              ,
    toResolver                              ,
    noResolver                              ,


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

#if defined(ENABLE_OVERLOADING)
    ResolveResolverMethod                   ,
#endif


-- ** getDefault #method:getDefault#

    resolverGetDefault                      ,


-- ** lookupByAddress #method:lookupByAddress#

#if defined(ENABLE_OVERLOADING)
    ResolverLookupByAddressMethodInfo       ,
#endif
    resolverLookupByAddress                 ,


-- ** lookupByAddressAsync #method:lookupByAddressAsync#

#if defined(ENABLE_OVERLOADING)
    ResolverLookupByAddressAsyncMethodInfo  ,
#endif
    resolverLookupByAddressAsync            ,


-- ** lookupByAddressFinish #method:lookupByAddressFinish#

#if defined(ENABLE_OVERLOADING)
    ResolverLookupByAddressFinishMethodInfo ,
#endif
    resolverLookupByAddressFinish           ,


-- ** lookupByName #method:lookupByName#

#if defined(ENABLE_OVERLOADING)
    ResolverLookupByNameMethodInfo          ,
#endif
    resolverLookupByName                    ,


-- ** lookupByNameAsync #method:lookupByNameAsync#

#if defined(ENABLE_OVERLOADING)
    ResolverLookupByNameAsyncMethodInfo     ,
#endif
    resolverLookupByNameAsync               ,


-- ** lookupByNameFinish #method:lookupByNameFinish#

#if defined(ENABLE_OVERLOADING)
    ResolverLookupByNameFinishMethodInfo    ,
#endif
    resolverLookupByNameFinish              ,


-- ** lookupByNameWithFlags #method:lookupByNameWithFlags#

#if defined(ENABLE_OVERLOADING)
    ResolverLookupByNameWithFlagsMethodInfo ,
#endif
    resolverLookupByNameWithFlags           ,


-- ** lookupByNameWithFlagsAsync #method:lookupByNameWithFlagsAsync#

#if defined(ENABLE_OVERLOADING)
    ResolverLookupByNameWithFlagsAsyncMethodInfo,
#endif
    resolverLookupByNameWithFlagsAsync      ,


-- ** lookupByNameWithFlagsFinish #method:lookupByNameWithFlagsFinish#

#if defined(ENABLE_OVERLOADING)
    ResolverLookupByNameWithFlagsFinishMethodInfo,
#endif
    resolverLookupByNameWithFlagsFinish     ,


-- ** lookupRecords #method:lookupRecords#

#if defined(ENABLE_OVERLOADING)
    ResolverLookupRecordsMethodInfo         ,
#endif
    resolverLookupRecords                   ,


-- ** lookupRecordsAsync #method:lookupRecordsAsync#

#if defined(ENABLE_OVERLOADING)
    ResolverLookupRecordsAsyncMethodInfo    ,
#endif
    resolverLookupRecordsAsync              ,


-- ** lookupRecordsFinish #method:lookupRecordsFinish#

#if defined(ENABLE_OVERLOADING)
    ResolverLookupRecordsFinishMethodInfo   ,
#endif
    resolverLookupRecordsFinish             ,


-- ** lookupService #method:lookupService#

#if defined(ENABLE_OVERLOADING)
    ResolverLookupServiceMethodInfo         ,
#endif
    resolverLookupService                   ,


-- ** lookupServiceAsync #method:lookupServiceAsync#

#if defined(ENABLE_OVERLOADING)
    ResolverLookupServiceAsyncMethodInfo    ,
#endif
    resolverLookupServiceAsync              ,


-- ** lookupServiceFinish #method:lookupServiceFinish#

#if defined(ENABLE_OVERLOADING)
    ResolverLookupServiceFinishMethodInfo   ,
#endif
    resolverLookupServiceFinish             ,


-- ** setDefault #method:setDefault#

#if defined(ENABLE_OVERLOADING)
    ResolverSetDefaultMethodInfo            ,
#endif
    resolverSetDefault                      ,




 -- * Signals
-- ** reload #signal:reload#

    C_ResolverReloadCallback                ,
    ResolverReloadCallback                  ,
#if defined(ENABLE_OVERLOADING)
    ResolverReloadSignalInfo                ,
#endif
    afterResolverReload                     ,
    genClosure_ResolverReload               ,
    mk_ResolverReloadCallback               ,
    noResolverReloadCallback                ,
    onResolverReload                        ,
    wrap_ResolverReloadCallback             ,




    ) 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.GI.Base.Signals as B.Signals
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.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Callbacks as Gio.Callbacks
import {-# SOURCE #-} qualified GI.Gio.Enums as Gio.Enums
import {-# SOURCE #-} qualified GI.Gio.Flags as Gio.Flags
import {-# SOURCE #-} qualified GI.Gio.Interfaces.AsyncResult as Gio.AsyncResult
import {-# SOURCE #-} qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import {-# SOURCE #-} qualified GI.Gio.Objects.InetAddress as Gio.InetAddress
import {-# SOURCE #-} qualified GI.Gio.Structs.SrvTarget as Gio.SrvTarget

-- | Memory-managed wrapper type.
newtype Resolver = Resolver (ManagedPtr Resolver)
    deriving (Resolver -> Resolver -> Bool
(Resolver -> Resolver -> Bool)
-> (Resolver -> Resolver -> Bool) -> Eq Resolver
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Resolver -> Resolver -> Bool
$c/= :: Resolver -> Resolver -> Bool
== :: Resolver -> Resolver -> Bool
$c== :: Resolver -> Resolver -> Bool
Eq)
foreign import ccall "g_resolver_get_type"
    c_g_resolver_get_type :: IO GType

instance GObject Resolver where
    gobjectType :: IO GType
gobjectType = IO GType
c_g_resolver_get_type
    

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

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

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

-- | Cast to `Resolver`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toResolver :: (MonadIO m, IsResolver o) => o -> m Resolver
toResolver :: o -> m Resolver
toResolver = IO Resolver -> m Resolver
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Resolver -> m Resolver)
-> (o -> IO Resolver) -> o -> m Resolver
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr Resolver -> Resolver) -> o -> IO Resolver
forall o o'.
(HasCallStack, GObject o, GObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
unsafeCastTo ManagedPtr Resolver -> Resolver
Resolver

-- | A convenience alias for `Nothing` :: `Maybe` `Resolver`.
noResolver :: Maybe Resolver
noResolver :: Maybe Resolver
noResolver = Maybe Resolver
forall a. Maybe a
Nothing

#if defined(ENABLE_OVERLOADING)
type family ResolveResolverMethod (t :: Symbol) (o :: *) :: * where
    ResolveResolverMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveResolverMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveResolverMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveResolverMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveResolverMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveResolverMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveResolverMethod "lookupByAddress" o = ResolverLookupByAddressMethodInfo
    ResolveResolverMethod "lookupByAddressAsync" o = ResolverLookupByAddressAsyncMethodInfo
    ResolveResolverMethod "lookupByAddressFinish" o = ResolverLookupByAddressFinishMethodInfo
    ResolveResolverMethod "lookupByName" o = ResolverLookupByNameMethodInfo
    ResolveResolverMethod "lookupByNameAsync" o = ResolverLookupByNameAsyncMethodInfo
    ResolveResolverMethod "lookupByNameFinish" o = ResolverLookupByNameFinishMethodInfo
    ResolveResolverMethod "lookupByNameWithFlags" o = ResolverLookupByNameWithFlagsMethodInfo
    ResolveResolverMethod "lookupByNameWithFlagsAsync" o = ResolverLookupByNameWithFlagsAsyncMethodInfo
    ResolveResolverMethod "lookupByNameWithFlagsFinish" o = ResolverLookupByNameWithFlagsFinishMethodInfo
    ResolveResolverMethod "lookupRecords" o = ResolverLookupRecordsMethodInfo
    ResolveResolverMethod "lookupRecordsAsync" o = ResolverLookupRecordsAsyncMethodInfo
    ResolveResolverMethod "lookupRecordsFinish" o = ResolverLookupRecordsFinishMethodInfo
    ResolveResolverMethod "lookupService" o = ResolverLookupServiceMethodInfo
    ResolveResolverMethod "lookupServiceAsync" o = ResolverLookupServiceAsyncMethodInfo
    ResolveResolverMethod "lookupServiceFinish" o = ResolverLookupServiceFinishMethodInfo
    ResolveResolverMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveResolverMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveResolverMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveResolverMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveResolverMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveResolverMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveResolverMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveResolverMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveResolverMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveResolverMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveResolverMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveResolverMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveResolverMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveResolverMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveResolverMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveResolverMethod "setDefault" o = ResolverSetDefaultMethodInfo
    ResolveResolverMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveResolverMethod l o = O.MethodResolutionFailed l o

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

#endif

-- signal Resolver::reload
-- | Emitted when the resolver notices that the system resolver
-- configuration has changed.
type ResolverReloadCallback =
    IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `ResolverReloadCallback`@.
noResolverReloadCallback :: Maybe ResolverReloadCallback
noResolverReloadCallback :: Maybe (IO ())
noResolverReloadCallback = Maybe (IO ())
forall a. Maybe a
Nothing

-- | Type for the callback on the (unwrapped) C side.
type C_ResolverReloadCallback =
    Ptr () ->                               -- object
    Ptr () ->                               -- user_data
    IO ()

-- | Generate a function pointer callable from C code, from a `C_ResolverReloadCallback`.
foreign import ccall "wrapper"
    mk_ResolverReloadCallback :: C_ResolverReloadCallback -> IO (FunPtr C_ResolverReloadCallback)

-- | Wrap the callback into a `GClosure`.
genClosure_ResolverReload :: MonadIO m => ResolverReloadCallback -> m (GClosure C_ResolverReloadCallback)
genClosure_ResolverReload :: IO () -> m (GClosure C_ResolverReloadCallback)
genClosure_ResolverReload cb :: IO ()
cb = IO (GClosure C_ResolverReloadCallback)
-> m (GClosure C_ResolverReloadCallback)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (GClosure C_ResolverReloadCallback)
 -> m (GClosure C_ResolverReloadCallback))
-> IO (GClosure C_ResolverReloadCallback)
-> m (GClosure C_ResolverReloadCallback)
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_ResolverReloadCallback
cb' = IO () -> C_ResolverReloadCallback
wrap_ResolverReloadCallback IO ()
cb
    C_ResolverReloadCallback -> IO (FunPtr C_ResolverReloadCallback)
mk_ResolverReloadCallback C_ResolverReloadCallback
cb' IO (FunPtr C_ResolverReloadCallback)
-> (FunPtr C_ResolverReloadCallback
    -> IO (GClosure C_ResolverReloadCallback))
-> IO (GClosure C_ResolverReloadCallback)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= FunPtr C_ResolverReloadCallback
-> IO (GClosure C_ResolverReloadCallback)
forall (m :: * -> *) a. MonadIO m => FunPtr a -> m (GClosure a)
B.GClosure.newGClosure


-- | Wrap a `ResolverReloadCallback` into a `C_ResolverReloadCallback`.
wrap_ResolverReloadCallback ::
    ResolverReloadCallback ->
    C_ResolverReloadCallback
wrap_ResolverReloadCallback :: IO () -> C_ResolverReloadCallback
wrap_ResolverReloadCallback _cb :: IO ()
_cb _ _ = do
    IO ()
_cb 


-- | Connect a signal handler for the [reload](#signal:reload) signal, to be run before the default handler.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Signals.on' resolver #reload callback
-- @
-- 
-- 
onResolverReload :: (IsResolver a, MonadIO m) => a -> ResolverReloadCallback -> m SignalHandlerId
onResolverReload :: a -> IO () -> m SignalHandlerId
onResolverReload obj :: a
obj cb :: IO ()
cb = IO SignalHandlerId -> m SignalHandlerId
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SignalHandlerId -> m SignalHandlerId)
-> IO SignalHandlerId -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_ResolverReloadCallback
cb' = IO () -> C_ResolverReloadCallback
wrap_ResolverReloadCallback IO ()
cb
    FunPtr C_ResolverReloadCallback
cb'' <- C_ResolverReloadCallback -> IO (FunPtr C_ResolverReloadCallback)
mk_ResolverReloadCallback C_ResolverReloadCallback
cb'
    a
-> Text
-> FunPtr C_ResolverReloadCallback
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
forall o a.
GObject o =>
o
-> Text
-> FunPtr a
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
connectSignalFunPtr a
obj "reload" FunPtr C_ResolverReloadCallback
cb'' SignalConnectMode
SignalConnectBefore Maybe Text
forall a. Maybe a
Nothing

-- | Connect a signal handler for the [reload](#signal:reload) signal, to be run after the default handler.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Signals.after' resolver #reload callback
-- @
-- 
-- 
afterResolverReload :: (IsResolver a, MonadIO m) => a -> ResolverReloadCallback -> m SignalHandlerId
afterResolverReload :: a -> IO () -> m SignalHandlerId
afterResolverReload obj :: a
obj cb :: IO ()
cb = IO SignalHandlerId -> m SignalHandlerId
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SignalHandlerId -> m SignalHandlerId)
-> IO SignalHandlerId -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_ResolverReloadCallback
cb' = IO () -> C_ResolverReloadCallback
wrap_ResolverReloadCallback IO ()
cb
    FunPtr C_ResolverReloadCallback
cb'' <- C_ResolverReloadCallback -> IO (FunPtr C_ResolverReloadCallback)
mk_ResolverReloadCallback C_ResolverReloadCallback
cb'
    a
-> Text
-> FunPtr C_ResolverReloadCallback
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
forall o a.
GObject o =>
o
-> Text
-> FunPtr a
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
connectSignalFunPtr a
obj "reload" FunPtr C_ResolverReloadCallback
cb'' SignalConnectMode
SignalConnectAfter Maybe Text
forall a. Maybe a
Nothing


#if defined(ENABLE_OVERLOADING)
data ResolverReloadSignalInfo
instance SignalInfo ResolverReloadSignalInfo where
    type HaskellCallbackType ResolverReloadSignalInfo = ResolverReloadCallback
    connectSignal obj cb connectMode detail = do
        let cb' = wrap_ResolverReloadCallback cb
        cb'' <- mk_ResolverReloadCallback cb'
        connectSignalFunPtr obj "reload" cb'' connectMode detail

#endif

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

#if defined(ENABLE_OVERLOADING)
#endif

#if defined(ENABLE_OVERLOADING)
type instance O.SignalList Resolver = ResolverSignalList
type ResolverSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo), '("reload", ResolverReloadSignalInfo)] :: [(Symbol, *)])

#endif

-- method Resolver::lookup_by_address
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "resolver"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "Resolver" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GResolver" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "address"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "InetAddress" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the address to reverse-resolve"
--                 , 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 "a #GCancellable, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : True
-- Skip return : False

foreign import ccall "g_resolver_lookup_by_address" g_resolver_lookup_by_address :: 
    Ptr Resolver ->                         -- resolver : TInterface (Name {namespace = "Gio", name = "Resolver"})
    Ptr Gio.InetAddress.InetAddress ->      -- address : TInterface (Name {namespace = "Gio", name = "InetAddress"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CString

-- | Synchronously reverse-resolves /@address@/ to determine its
-- associated hostname.
-- 
-- If the DNS resolution fails, /@error@/ (if non-'P.Nothing') will be set to
-- a value from t'GI.Gio.Enums.ResolverError'.
-- 
-- If /@cancellable@/ is non-'P.Nothing', it can be used to cancel the
-- operation, in which case /@error@/ (if non-'P.Nothing') will be set to
-- 'GI.Gio.Enums.IOErrorEnumCancelled'.
-- 
-- /Since: 2.22/
resolverLookupByAddress ::
    (B.CallStack.HasCallStack, MonadIO m, IsResolver a, Gio.InetAddress.IsInetAddress b, Gio.Cancellable.IsCancellable c) =>
    a
    -- ^ /@resolver@/: a t'GI.Gio.Objects.Resolver.Resolver'
    -> b
    -- ^ /@address@/: the address to reverse-resolve
    -> Maybe (c)
    -- ^ /@cancellable@/: a t'GI.Gio.Objects.Cancellable.Cancellable', or 'P.Nothing'
    -> m T.Text
    -- ^ __Returns:__ a hostname (either ASCII-only, or in ASCII-encoded
    --     form), or 'P.Nothing' on error. /(Can throw 'Data.GI.Base.GError.GError')/
resolverLookupByAddress :: a -> b -> Maybe c -> m Text
resolverLookupByAddress resolver :: a
resolver address :: b
address cancellable :: Maybe c
cancellable = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    Ptr Resolver
resolver' <- a -> IO (Ptr Resolver)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
resolver
    Ptr InetAddress
address' <- b -> IO (Ptr InetAddress)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
address
    Ptr Cancellable
maybeCancellable <- case Maybe c
cancellable of
        Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just jCancellable :: c
jCancellable -> do
            Ptr Cancellable
jCancellable' <- c -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr c
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    IO Text -> IO () -> IO Text
forall a b. IO a -> IO b -> IO a
onException (do
        CString
result <- (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CString) -> IO CString)
-> (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a b. (a -> b) -> a -> b
$ Ptr Resolver
-> Ptr InetAddress
-> Ptr Cancellable
-> Ptr (Ptr GError)
-> IO CString
g_resolver_lookup_by_address Ptr Resolver
resolver' Ptr InetAddress
address' Ptr Cancellable
maybeCancellable
        Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "resolverLookupByAddress" CString
result
        Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
resolver
        b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
address
        Maybe c -> (c -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe c
cancellable c -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

#if defined(ENABLE_OVERLOADING)
data ResolverLookupByAddressMethodInfo
instance (signature ~ (b -> Maybe (c) -> m T.Text), MonadIO m, IsResolver a, Gio.InetAddress.IsInetAddress b, Gio.Cancellable.IsCancellable c) => O.MethodInfo ResolverLookupByAddressMethodInfo a signature where
    overloadedMethod = resolverLookupByAddress

#endif

-- method Resolver::lookup_by_address_async
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "resolver"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "Resolver" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GResolver" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "address"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "InetAddress" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the address to reverse-resolve"
--                 , 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 "a #GCancellable, or %NULL"
--                 , 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 "callback to call after resolution completes"
--                 , 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 "data for @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_resolver_lookup_by_address_async" g_resolver_lookup_by_address_async :: 
    Ptr Resolver ->                         -- resolver : TInterface (Name {namespace = "Gio", name = "Resolver"})
    Ptr Gio.InetAddress.InetAddress ->      -- address : TInterface (Name {namespace = "Gio", name = "InetAddress"})
    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 ()

-- | Begins asynchronously reverse-resolving /@address@/ to determine its
-- associated hostname, and eventually calls /@callback@/, which must
-- call 'GI.Gio.Objects.Resolver.resolverLookupByAddressFinish' to get the final result.
-- 
-- /Since: 2.22/
resolverLookupByAddressAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsResolver a, Gio.InetAddress.IsInetAddress b, Gio.Cancellable.IsCancellable c) =>
    a
    -- ^ /@resolver@/: a t'GI.Gio.Objects.Resolver.Resolver'
    -> b
    -- ^ /@address@/: the address to reverse-resolve
    -> Maybe (c)
    -- ^ /@cancellable@/: a t'GI.Gio.Objects.Cancellable.Cancellable', or 'P.Nothing'
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    -- ^ /@callback@/: callback to call after resolution completes
    -> m ()
resolverLookupByAddressAsync :: a -> b -> Maybe c -> Maybe AsyncReadyCallback -> m ()
resolverLookupByAddressAsync resolver :: a
resolver address :: b
address cancellable :: Maybe c
cancellable callback :: Maybe AsyncReadyCallback
callback = 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 Resolver
resolver' <- a -> IO (Ptr Resolver)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
resolver
    Ptr InetAddress
address' <- b -> IO (Ptr InetAddress)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
address
    Ptr Cancellable
maybeCancellable <- case Maybe c
cancellable of
        Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just jCancellable :: c
jCancellable -> do
            Ptr Cancellable
jCancellable' <- c -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr c
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    FunPtr C_AsyncReadyCallback
maybeCallback <- case Maybe AsyncReadyCallback
callback of
        Nothing -> FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr C_AsyncReadyCallback
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
        Just jCallback :: AsyncReadyCallback
jCallback -> do
            Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
            FunPtr C_AsyncReadyCallback
jCallback' <- C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
Gio.Callbacks.mk_AsyncReadyCallback (Maybe (Ptr (FunPtr C_AsyncReadyCallback))
-> AsyncReadyCallback_WithClosures -> C_AsyncReadyCallback
Gio.Callbacks.wrap_AsyncReadyCallback (Ptr (FunPtr C_AsyncReadyCallback)
-> Maybe (Ptr (FunPtr C_AsyncReadyCallback))
forall a. a -> Maybe a
Just Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback) (AsyncReadyCallback -> AsyncReadyCallback_WithClosures
Gio.Callbacks.drop_closures_AsyncReadyCallback AsyncReadyCallback
jCallback))
            Ptr (FunPtr C_AsyncReadyCallback)
-> FunPtr C_AsyncReadyCallback -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback FunPtr C_AsyncReadyCallback
jCallback'
            FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
jCallback'
    let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
    Ptr Resolver
-> Ptr InetAddress
-> Ptr Cancellable
-> FunPtr C_AsyncReadyCallback
-> Ptr ()
-> IO ()
g_resolver_lookup_by_address_async Ptr Resolver
resolver' Ptr InetAddress
address' Ptr Cancellable
maybeCancellable FunPtr C_AsyncReadyCallback
maybeCallback Ptr ()
forall a. Ptr a
userData
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
resolver
    b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
address
    Maybe c -> (c -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe c
cancellable c -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data ResolverLookupByAddressAsyncMethodInfo
instance (signature ~ (b -> Maybe (c) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsResolver a, Gio.InetAddress.IsInetAddress b, Gio.Cancellable.IsCancellable c) => O.MethodInfo ResolverLookupByAddressAsyncMethodInfo a signature where
    overloadedMethod = resolverLookupByAddressAsync

#endif

-- method Resolver::lookup_by_address_finish
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "resolver"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "Resolver" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GResolver" , 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 "the result passed to your #GAsyncReadyCallback"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : True
-- Skip return : False

foreign import ccall "g_resolver_lookup_by_address_finish" g_resolver_lookup_by_address_finish :: 
    Ptr Resolver ->                         -- resolver : TInterface (Name {namespace = "Gio", name = "Resolver"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO CString

-- | Retrieves the result of a previous call to
-- 'GI.Gio.Objects.Resolver.resolverLookupByAddressAsync'.
-- 
-- If the DNS resolution failed, /@error@/ (if non-'P.Nothing') will be set to
-- a value from t'GI.Gio.Enums.ResolverError'. If the operation was cancelled,
-- /@error@/ will be set to 'GI.Gio.Enums.IOErrorEnumCancelled'.
-- 
-- /Since: 2.22/
resolverLookupByAddressFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsResolver a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    -- ^ /@resolver@/: a t'GI.Gio.Objects.Resolver.Resolver'
    -> b
    -- ^ /@result@/: the result passed to your t'GI.Gio.Callbacks.AsyncReadyCallback'
    -> m T.Text
    -- ^ __Returns:__ a hostname (either ASCII-only, or in ASCII-encoded
    -- form), or 'P.Nothing' on error. /(Can throw 'Data.GI.Base.GError.GError')/
resolverLookupByAddressFinish :: a -> b -> m Text
resolverLookupByAddressFinish resolver :: a
resolver result_ :: b
result_ = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    Ptr Resolver
resolver' <- a -> IO (Ptr Resolver)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
resolver
    Ptr AsyncResult
result_' <- b -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
result_
    IO Text -> IO () -> IO Text
forall a b. IO a -> IO b -> IO a
onException (do
        CString
result <- (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CString) -> IO CString)
-> (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a b. (a -> b) -> a -> b
$ Ptr Resolver -> Ptr AsyncResult -> Ptr (Ptr GError) -> IO CString
g_resolver_lookup_by_address_finish Ptr Resolver
resolver' Ptr AsyncResult
result_'
        Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "resolverLookupByAddressFinish" CString
result
        Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
resolver
        b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
result_
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

#if defined(ENABLE_OVERLOADING)
data ResolverLookupByAddressFinishMethodInfo
instance (signature ~ (b -> m T.Text), MonadIO m, IsResolver a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo ResolverLookupByAddressFinishMethodInfo a signature where
    overloadedMethod = resolverLookupByAddressFinish

#endif

-- method Resolver::lookup_by_name
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "resolver"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "Resolver" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GResolver" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "hostname"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the hostname to look up"
--                 , 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 "a #GCancellable, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TGList
--                  (TInterface Name { namespace = "Gio" , name = "InetAddress" }))
-- throws : True
-- Skip return : False

foreign import ccall "g_resolver_lookup_by_name" g_resolver_lookup_by_name :: 
    Ptr Resolver ->                         -- resolver : TInterface (Name {namespace = "Gio", name = "Resolver"})
    CString ->                              -- hostname : TBasicType TUTF8
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr (GList (Ptr Gio.InetAddress.InetAddress)))

-- | Synchronously resolves /@hostname@/ to determine its associated IP
-- address(es). /@hostname@/ may be an ASCII-only or UTF-8 hostname, or
-- the textual form of an IP address (in which case this just becomes
-- a wrapper around 'GI.Gio.Objects.InetAddress.inetAddressNewFromString').
-- 
-- On success, 'GI.Gio.Objects.Resolver.resolverLookupByName' will return a non-empty t'GI.GLib.Structs.List.List' of
-- t'GI.Gio.Objects.InetAddress.InetAddress', sorted in order of preference and guaranteed to not
-- contain duplicates. That is, if using the result to connect to
-- /@hostname@/, you should attempt to connect to the first address
-- first, then the second if the first fails, etc. If you are using
-- the result to listen on a socket, it is appropriate to add each
-- result using e.g. 'GI.Gio.Objects.SocketListener.socketListenerAddAddress'.
-- 
-- If the DNS resolution fails, /@error@/ (if non-'P.Nothing') will be set to a
-- value from t'GI.Gio.Enums.ResolverError' and 'P.Nothing' will be returned.
-- 
-- If /@cancellable@/ is non-'P.Nothing', it can be used to cancel the
-- operation, in which case /@error@/ (if non-'P.Nothing') will be set to
-- 'GI.Gio.Enums.IOErrorEnumCancelled'.
-- 
-- If you are planning to connect to a socket on the resolved IP
-- address, it may be easier to create a t'GI.Gio.Objects.NetworkAddress.NetworkAddress' and use its
-- t'GI.Gio.Interfaces.SocketConnectable.SocketConnectable' interface.
-- 
-- /Since: 2.22/
resolverLookupByName ::
    (B.CallStack.HasCallStack, MonadIO m, IsResolver a, Gio.Cancellable.IsCancellable b) =>
    a
    -- ^ /@resolver@/: a t'GI.Gio.Objects.Resolver.Resolver'
    -> T.Text
    -- ^ /@hostname@/: the hostname to look up
    -> Maybe (b)
    -- ^ /@cancellable@/: a t'GI.Gio.Objects.Cancellable.Cancellable', or 'P.Nothing'
    -> m [Gio.InetAddress.InetAddress]
    -- ^ __Returns:__ a non-empty t'GI.GLib.Structs.List.List'
    -- of t'GI.Gio.Objects.InetAddress.InetAddress', or 'P.Nothing' on error. You
    -- must unref each of the addresses and free the list when you are
    -- done with it. (You can use @/g_resolver_free_addresses()/@ to do this.) /(Can throw 'Data.GI.Base.GError.GError')/
resolverLookupByName :: a -> Text -> Maybe b -> m [InetAddress]
resolverLookupByName resolver :: a
resolver hostname :: Text
hostname cancellable :: Maybe b
cancellable = IO [InetAddress] -> m [InetAddress]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [InetAddress] -> m [InetAddress])
-> IO [InetAddress] -> m [InetAddress]
forall a b. (a -> b) -> a -> b
$ do
    Ptr Resolver
resolver' <- a -> IO (Ptr Resolver)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
resolver
    CString
hostname' <- Text -> IO CString
textToCString Text
hostname
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just jCancellable :: b
jCancellable -> do
            Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    IO [InetAddress] -> IO () -> IO [InetAddress]
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr (GList (Ptr InetAddress))
result <- (Ptr (Ptr GError) -> IO (Ptr (GList (Ptr InetAddress))))
-> IO (Ptr (GList (Ptr InetAddress)))
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr (GList (Ptr InetAddress))))
 -> IO (Ptr (GList (Ptr InetAddress))))
-> (Ptr (Ptr GError) -> IO (Ptr (GList (Ptr InetAddress))))
-> IO (Ptr (GList (Ptr InetAddress)))
forall a b. (a -> b) -> a -> b
$ Ptr Resolver
-> CString
-> Ptr Cancellable
-> Ptr (Ptr GError)
-> IO (Ptr (GList (Ptr InetAddress)))
g_resolver_lookup_by_name Ptr Resolver
resolver' CString
hostname' Ptr Cancellable
maybeCancellable
        [Ptr InetAddress]
result' <- Ptr (GList (Ptr InetAddress)) -> IO [Ptr InetAddress]
forall a. Ptr (GList (Ptr a)) -> IO [Ptr a]
unpackGList Ptr (GList (Ptr InetAddress))
result
        [InetAddress]
result'' <- (Ptr InetAddress -> IO InetAddress)
-> [Ptr InetAddress] -> IO [InetAddress]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((ManagedPtr InetAddress -> InetAddress)
-> Ptr InetAddress -> IO InetAddress
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr InetAddress -> InetAddress
Gio.InetAddress.InetAddress) [Ptr InetAddress]
result'
        Ptr (GList (Ptr InetAddress)) -> IO ()
forall a. Ptr (GList a) -> IO ()
g_list_free Ptr (GList (Ptr InetAddress))
result
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
resolver
        Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
hostname'
        [InetAddress] -> IO [InetAddress]
forall (m :: * -> *) a. Monad m => a -> m a
return [InetAddress]
result''
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
hostname'
     )

#if defined(ENABLE_OVERLOADING)
data ResolverLookupByNameMethodInfo
instance (signature ~ (T.Text -> Maybe (b) -> m [Gio.InetAddress.InetAddress]), MonadIO m, IsResolver a, Gio.Cancellable.IsCancellable b) => O.MethodInfo ResolverLookupByNameMethodInfo a signature where
    overloadedMethod = resolverLookupByName

#endif

-- method Resolver::lookup_by_name_async
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "resolver"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "Resolver" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GResolver" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "hostname"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the hostname to look up the address of"
--                 , 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 "a #GCancellable, or %NULL"
--                 , 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 "callback to call after resolution completes"
--                 , 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 "data for @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_resolver_lookup_by_name_async" g_resolver_lookup_by_name_async :: 
    Ptr Resolver ->                         -- resolver : TInterface (Name {namespace = "Gio", name = "Resolver"})
    CString ->                              -- hostname : TBasicType TUTF8
    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 ()

-- | Begins asynchronously resolving /@hostname@/ to determine its
-- associated IP address(es), and eventually calls /@callback@/, which
-- must call 'GI.Gio.Objects.Resolver.resolverLookupByNameFinish' to get the result.
-- See 'GI.Gio.Objects.Resolver.resolverLookupByName' for more details.
-- 
-- /Since: 2.22/
resolverLookupByNameAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsResolver a, Gio.Cancellable.IsCancellable b) =>
    a
    -- ^ /@resolver@/: a t'GI.Gio.Objects.Resolver.Resolver'
    -> T.Text
    -- ^ /@hostname@/: the hostname to look up the address of
    -> Maybe (b)
    -- ^ /@cancellable@/: a t'GI.Gio.Objects.Cancellable.Cancellable', or 'P.Nothing'
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    -- ^ /@callback@/: callback to call after resolution completes
    -> m ()
resolverLookupByNameAsync :: a -> Text -> Maybe b -> Maybe AsyncReadyCallback -> m ()
resolverLookupByNameAsync resolver :: a
resolver hostname :: Text
hostname cancellable :: Maybe b
cancellable callback :: Maybe AsyncReadyCallback
callback = 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 Resolver
resolver' <- a -> IO (Ptr Resolver)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
resolver
    CString
hostname' <- Text -> IO CString
textToCString Text
hostname
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just jCancellable :: b
jCancellable -> do
            Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    FunPtr C_AsyncReadyCallback
maybeCallback <- case Maybe AsyncReadyCallback
callback of
        Nothing -> FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr C_AsyncReadyCallback
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
        Just jCallback :: AsyncReadyCallback
jCallback -> do
            Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
            FunPtr C_AsyncReadyCallback
jCallback' <- C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
Gio.Callbacks.mk_AsyncReadyCallback (Maybe (Ptr (FunPtr C_AsyncReadyCallback))
-> AsyncReadyCallback_WithClosures -> C_AsyncReadyCallback
Gio.Callbacks.wrap_AsyncReadyCallback (Ptr (FunPtr C_AsyncReadyCallback)
-> Maybe (Ptr (FunPtr C_AsyncReadyCallback))
forall a. a -> Maybe a
Just Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback) (AsyncReadyCallback -> AsyncReadyCallback_WithClosures
Gio.Callbacks.drop_closures_AsyncReadyCallback AsyncReadyCallback
jCallback))
            Ptr (FunPtr C_AsyncReadyCallback)
-> FunPtr C_AsyncReadyCallback -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback FunPtr C_AsyncReadyCallback
jCallback'
            FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
jCallback'
    let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
    Ptr Resolver
-> CString
-> Ptr Cancellable
-> FunPtr C_AsyncReadyCallback
-> Ptr ()
-> IO ()
g_resolver_lookup_by_name_async Ptr Resolver
resolver' CString
hostname' Ptr Cancellable
maybeCancellable FunPtr C_AsyncReadyCallback
maybeCallback Ptr ()
forall a. Ptr a
userData
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
resolver
    Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
hostname'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data ResolverLookupByNameAsyncMethodInfo
instance (signature ~ (T.Text -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsResolver a, Gio.Cancellable.IsCancellable b) => O.MethodInfo ResolverLookupByNameAsyncMethodInfo a signature where
    overloadedMethod = resolverLookupByNameAsync

#endif

-- method Resolver::lookup_by_name_finish
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "resolver"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "Resolver" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GResolver" , 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 "the result passed to your #GAsyncReadyCallback"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TGList
--                  (TInterface Name { namespace = "Gio" , name = "InetAddress" }))
-- throws : True
-- Skip return : False

foreign import ccall "g_resolver_lookup_by_name_finish" g_resolver_lookup_by_name_finish :: 
    Ptr Resolver ->                         -- resolver : TInterface (Name {namespace = "Gio", name = "Resolver"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr (GList (Ptr Gio.InetAddress.InetAddress)))

-- | Retrieves the result of a call to
-- 'GI.Gio.Objects.Resolver.resolverLookupByNameAsync'.
-- 
-- If the DNS resolution failed, /@error@/ (if non-'P.Nothing') will be set to
-- a value from t'GI.Gio.Enums.ResolverError'. If the operation was cancelled,
-- /@error@/ will be set to 'GI.Gio.Enums.IOErrorEnumCancelled'.
-- 
-- /Since: 2.22/
resolverLookupByNameFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsResolver a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    -- ^ /@resolver@/: a t'GI.Gio.Objects.Resolver.Resolver'
    -> b
    -- ^ /@result@/: the result passed to your t'GI.Gio.Callbacks.AsyncReadyCallback'
    -> m [Gio.InetAddress.InetAddress]
    -- ^ __Returns:__ a t'GI.GLib.Structs.List.List'
    -- of t'GI.Gio.Objects.InetAddress.InetAddress', or 'P.Nothing' on error. See 'GI.Gio.Objects.Resolver.resolverLookupByName'
    -- for more details. /(Can throw 'Data.GI.Base.GError.GError')/
resolverLookupByNameFinish :: a -> b -> m [InetAddress]
resolverLookupByNameFinish resolver :: a
resolver result_ :: b
result_ = IO [InetAddress] -> m [InetAddress]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [InetAddress] -> m [InetAddress])
-> IO [InetAddress] -> m [InetAddress]
forall a b. (a -> b) -> a -> b
$ do
    Ptr Resolver
resolver' <- a -> IO (Ptr Resolver)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
resolver
    Ptr AsyncResult
result_' <- b -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
result_
    IO [InetAddress] -> IO () -> IO [InetAddress]
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr (GList (Ptr InetAddress))
result <- (Ptr (Ptr GError) -> IO (Ptr (GList (Ptr InetAddress))))
-> IO (Ptr (GList (Ptr InetAddress)))
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr (GList (Ptr InetAddress))))
 -> IO (Ptr (GList (Ptr InetAddress))))
-> (Ptr (Ptr GError) -> IO (Ptr (GList (Ptr InetAddress))))
-> IO (Ptr (GList (Ptr InetAddress)))
forall a b. (a -> b) -> a -> b
$ Ptr Resolver
-> Ptr AsyncResult
-> Ptr (Ptr GError)
-> IO (Ptr (GList (Ptr InetAddress)))
g_resolver_lookup_by_name_finish Ptr Resolver
resolver' Ptr AsyncResult
result_'
        [Ptr InetAddress]
result' <- Ptr (GList (Ptr InetAddress)) -> IO [Ptr InetAddress]
forall a. Ptr (GList (Ptr a)) -> IO [Ptr a]
unpackGList Ptr (GList (Ptr InetAddress))
result
        [InetAddress]
result'' <- (Ptr InetAddress -> IO InetAddress)
-> [Ptr InetAddress] -> IO [InetAddress]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((ManagedPtr InetAddress -> InetAddress)
-> Ptr InetAddress -> IO InetAddress
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr InetAddress -> InetAddress
Gio.InetAddress.InetAddress) [Ptr InetAddress]
result'
        Ptr (GList (Ptr InetAddress)) -> IO ()
forall a. Ptr (GList a) -> IO ()
g_list_free Ptr (GList (Ptr InetAddress))
result
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
resolver
        b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
result_
        [InetAddress] -> IO [InetAddress]
forall (m :: * -> *) a. Monad m => a -> m a
return [InetAddress]
result''
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

#if defined(ENABLE_OVERLOADING)
data ResolverLookupByNameFinishMethodInfo
instance (signature ~ (b -> m [Gio.InetAddress.InetAddress]), MonadIO m, IsResolver a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo ResolverLookupByNameFinishMethodInfo a signature where
    overloadedMethod = resolverLookupByNameFinish

#endif

-- method Resolver::lookup_by_name_with_flags
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "resolver"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "Resolver" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GResolver" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "hostname"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the hostname to look up"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "flags"
--           , argType =
--               TInterface
--                 Name { namespace = "Gio" , name = "ResolverNameLookupFlags" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "extra #GResolverNameLookupFlags for the lookup"
--                 , 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 "a #GCancellable, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TGList
--                  (TInterface Name { namespace = "Gio" , name = "InetAddress" }))
-- throws : True
-- Skip return : False

foreign import ccall "g_resolver_lookup_by_name_with_flags" g_resolver_lookup_by_name_with_flags :: 
    Ptr Resolver ->                         -- resolver : TInterface (Name {namespace = "Gio", name = "Resolver"})
    CString ->                              -- hostname : TBasicType TUTF8
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "ResolverNameLookupFlags"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr (GList (Ptr Gio.InetAddress.InetAddress)))

-- | This differs from 'GI.Gio.Objects.Resolver.resolverLookupByName' in that you can modify
-- the lookup behavior with /@flags@/. For example this can be used to limit
-- results with @/G_RESOLVER_NAME_LOOKUP_FLAGS_IPV4_ONLY/@.
-- 
-- /Since: 2.60/
resolverLookupByNameWithFlags ::
    (B.CallStack.HasCallStack, MonadIO m, IsResolver a, Gio.Cancellable.IsCancellable b) =>
    a
    -- ^ /@resolver@/: a t'GI.Gio.Objects.Resolver.Resolver'
    -> T.Text
    -- ^ /@hostname@/: the hostname to look up
    -> [Gio.Flags.ResolverNameLookupFlags]
    -- ^ /@flags@/: extra t'GI.Gio.Flags.ResolverNameLookupFlags' for the lookup
    -> Maybe (b)
    -- ^ /@cancellable@/: a t'GI.Gio.Objects.Cancellable.Cancellable', or 'P.Nothing'
    -> m [Gio.InetAddress.InetAddress]
    -- ^ __Returns:__ a non-empty t'GI.GLib.Structs.List.List'
    -- of t'GI.Gio.Objects.InetAddress.InetAddress', or 'P.Nothing' on error. You
    -- must unref each of the addresses and free the list when you are
    -- done with it. (You can use @/g_resolver_free_addresses()/@ to do this.) /(Can throw 'Data.GI.Base.GError.GError')/
resolverLookupByNameWithFlags :: a
-> Text -> [ResolverNameLookupFlags] -> Maybe b -> m [InetAddress]
resolverLookupByNameWithFlags resolver :: a
resolver hostname :: Text
hostname flags :: [ResolverNameLookupFlags]
flags cancellable :: Maybe b
cancellable = IO [InetAddress] -> m [InetAddress]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [InetAddress] -> m [InetAddress])
-> IO [InetAddress] -> m [InetAddress]
forall a b. (a -> b) -> a -> b
$ do
    Ptr Resolver
resolver' <- a -> IO (Ptr Resolver)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
resolver
    CString
hostname' <- Text -> IO CString
textToCString Text
hostname
    let flags' :: CUInt
flags' = [ResolverNameLookupFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [ResolverNameLookupFlags]
flags
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just jCancellable :: b
jCancellable -> do
            Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    IO [InetAddress] -> IO () -> IO [InetAddress]
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr (GList (Ptr InetAddress))
result <- (Ptr (Ptr GError) -> IO (Ptr (GList (Ptr InetAddress))))
-> IO (Ptr (GList (Ptr InetAddress)))
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr (GList (Ptr InetAddress))))
 -> IO (Ptr (GList (Ptr InetAddress))))
-> (Ptr (Ptr GError) -> IO (Ptr (GList (Ptr InetAddress))))
-> IO (Ptr (GList (Ptr InetAddress)))
forall a b. (a -> b) -> a -> b
$ Ptr Resolver
-> CString
-> CUInt
-> Ptr Cancellable
-> Ptr (Ptr GError)
-> IO (Ptr (GList (Ptr InetAddress)))
g_resolver_lookup_by_name_with_flags Ptr Resolver
resolver' CString
hostname' CUInt
flags' Ptr Cancellable
maybeCancellable
        [Ptr InetAddress]
result' <- Ptr (GList (Ptr InetAddress)) -> IO [Ptr InetAddress]
forall a. Ptr (GList (Ptr a)) -> IO [Ptr a]
unpackGList Ptr (GList (Ptr InetAddress))
result
        [InetAddress]
result'' <- (Ptr InetAddress -> IO InetAddress)
-> [Ptr InetAddress] -> IO [InetAddress]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((ManagedPtr InetAddress -> InetAddress)
-> Ptr InetAddress -> IO InetAddress
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr InetAddress -> InetAddress
Gio.InetAddress.InetAddress) [Ptr InetAddress]
result'
        Ptr (GList (Ptr InetAddress)) -> IO ()
forall a. Ptr (GList a) -> IO ()
g_list_free Ptr (GList (Ptr InetAddress))
result
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
resolver
        Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
hostname'
        [InetAddress] -> IO [InetAddress]
forall (m :: * -> *) a. Monad m => a -> m a
return [InetAddress]
result''
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
hostname'
     )

#if defined(ENABLE_OVERLOADING)
data ResolverLookupByNameWithFlagsMethodInfo
instance (signature ~ (T.Text -> [Gio.Flags.ResolverNameLookupFlags] -> Maybe (b) -> m [Gio.InetAddress.InetAddress]), MonadIO m, IsResolver a, Gio.Cancellable.IsCancellable b) => O.MethodInfo ResolverLookupByNameWithFlagsMethodInfo a signature where
    overloadedMethod = resolverLookupByNameWithFlags

#endif

-- method Resolver::lookup_by_name_with_flags_async
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "resolver"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "Resolver" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GResolver" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "hostname"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the hostname to look up the address of"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "flags"
--           , argType =
--               TInterface
--                 Name { namespace = "Gio" , name = "ResolverNameLookupFlags" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "extra #GResolverNameLookupFlags for the lookup"
--                 , 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 "a #GCancellable, or %NULL"
--                 , 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 "callback to call after resolution completes"
--                 , 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 "data for @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_resolver_lookup_by_name_with_flags_async" g_resolver_lookup_by_name_with_flags_async :: 
    Ptr Resolver ->                         -- resolver : TInterface (Name {namespace = "Gio", name = "Resolver"})
    CString ->                              -- hostname : TBasicType TUTF8
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "ResolverNameLookupFlags"})
    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 ()

-- | Begins asynchronously resolving /@hostname@/ to determine its
-- associated IP address(es), and eventually calls /@callback@/, which
-- must call 'GI.Gio.Objects.Resolver.resolverLookupByNameWithFlagsFinish' to get the result.
-- See 'GI.Gio.Objects.Resolver.resolverLookupByName' for more details.
-- 
-- /Since: 2.60/
resolverLookupByNameWithFlagsAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsResolver a, Gio.Cancellable.IsCancellable b) =>
    a
    -- ^ /@resolver@/: a t'GI.Gio.Objects.Resolver.Resolver'
    -> T.Text
    -- ^ /@hostname@/: the hostname to look up the address of
    -> [Gio.Flags.ResolverNameLookupFlags]
    -- ^ /@flags@/: extra t'GI.Gio.Flags.ResolverNameLookupFlags' for the lookup
    -> Maybe (b)
    -- ^ /@cancellable@/: a t'GI.Gio.Objects.Cancellable.Cancellable', or 'P.Nothing'
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    -- ^ /@callback@/: callback to call after resolution completes
    -> m ()
resolverLookupByNameWithFlagsAsync :: a
-> Text
-> [ResolverNameLookupFlags]
-> Maybe b
-> Maybe AsyncReadyCallback
-> m ()
resolverLookupByNameWithFlagsAsync resolver :: a
resolver hostname :: Text
hostname flags :: [ResolverNameLookupFlags]
flags cancellable :: Maybe b
cancellable callback :: Maybe AsyncReadyCallback
callback = 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 Resolver
resolver' <- a -> IO (Ptr Resolver)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
resolver
    CString
hostname' <- Text -> IO CString
textToCString Text
hostname
    let flags' :: CUInt
flags' = [ResolverNameLookupFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [ResolverNameLookupFlags]
flags
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just jCancellable :: b
jCancellable -> do
            Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    FunPtr C_AsyncReadyCallback
maybeCallback <- case Maybe AsyncReadyCallback
callback of
        Nothing -> FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr C_AsyncReadyCallback
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
        Just jCallback :: AsyncReadyCallback
jCallback -> do
            Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
            FunPtr C_AsyncReadyCallback
jCallback' <- C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
Gio.Callbacks.mk_AsyncReadyCallback (Maybe (Ptr (FunPtr C_AsyncReadyCallback))
-> AsyncReadyCallback_WithClosures -> C_AsyncReadyCallback
Gio.Callbacks.wrap_AsyncReadyCallback (Ptr (FunPtr C_AsyncReadyCallback)
-> Maybe (Ptr (FunPtr C_AsyncReadyCallback))
forall a. a -> Maybe a
Just Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback) (AsyncReadyCallback -> AsyncReadyCallback_WithClosures
Gio.Callbacks.drop_closures_AsyncReadyCallback AsyncReadyCallback
jCallback))
            Ptr (FunPtr C_AsyncReadyCallback)
-> FunPtr C_AsyncReadyCallback -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback FunPtr C_AsyncReadyCallback
jCallback'
            FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
jCallback'
    let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
    Ptr Resolver
-> CString
-> CUInt
-> Ptr Cancellable
-> FunPtr C_AsyncReadyCallback
-> Ptr ()
-> IO ()
g_resolver_lookup_by_name_with_flags_async Ptr Resolver
resolver' CString
hostname' CUInt
flags' Ptr Cancellable
maybeCancellable FunPtr C_AsyncReadyCallback
maybeCallback Ptr ()
forall a. Ptr a
userData
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
resolver
    Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
hostname'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data ResolverLookupByNameWithFlagsAsyncMethodInfo
instance (signature ~ (T.Text -> [Gio.Flags.ResolverNameLookupFlags] -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsResolver a, Gio.Cancellable.IsCancellable b) => O.MethodInfo ResolverLookupByNameWithFlagsAsyncMethodInfo a signature where
    overloadedMethod = resolverLookupByNameWithFlagsAsync

#endif

-- method Resolver::lookup_by_name_with_flags_finish
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "resolver"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "Resolver" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GResolver" , 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 "the result passed to your #GAsyncReadyCallback"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TGList
--                  (TInterface Name { namespace = "Gio" , name = "InetAddress" }))
-- throws : True
-- Skip return : False

foreign import ccall "g_resolver_lookup_by_name_with_flags_finish" g_resolver_lookup_by_name_with_flags_finish :: 
    Ptr Resolver ->                         -- resolver : TInterface (Name {namespace = "Gio", name = "Resolver"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr (GList (Ptr Gio.InetAddress.InetAddress)))

-- | Retrieves the result of a call to
-- 'GI.Gio.Objects.Resolver.resolverLookupByNameWithFlagsAsync'.
-- 
-- If the DNS resolution failed, /@error@/ (if non-'P.Nothing') will be set to
-- a value from t'GI.Gio.Enums.ResolverError'. If the operation was cancelled,
-- /@error@/ will be set to 'GI.Gio.Enums.IOErrorEnumCancelled'.
-- 
-- /Since: 2.60/
resolverLookupByNameWithFlagsFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsResolver a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    -- ^ /@resolver@/: a t'GI.Gio.Objects.Resolver.Resolver'
    -> b
    -- ^ /@result@/: the result passed to your t'GI.Gio.Callbacks.AsyncReadyCallback'
    -> m [Gio.InetAddress.InetAddress]
    -- ^ __Returns:__ a t'GI.GLib.Structs.List.List'
    -- of t'GI.Gio.Objects.InetAddress.InetAddress', or 'P.Nothing' on error. See 'GI.Gio.Objects.Resolver.resolverLookupByName'
    -- for more details. /(Can throw 'Data.GI.Base.GError.GError')/
resolverLookupByNameWithFlagsFinish :: a -> b -> m [InetAddress]
resolverLookupByNameWithFlagsFinish resolver :: a
resolver result_ :: b
result_ = IO [InetAddress] -> m [InetAddress]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [InetAddress] -> m [InetAddress])
-> IO [InetAddress] -> m [InetAddress]
forall a b. (a -> b) -> a -> b
$ do
    Ptr Resolver
resolver' <- a -> IO (Ptr Resolver)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
resolver
    Ptr AsyncResult
result_' <- b -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
result_
    IO [InetAddress] -> IO () -> IO [InetAddress]
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr (GList (Ptr InetAddress))
result <- (Ptr (Ptr GError) -> IO (Ptr (GList (Ptr InetAddress))))
-> IO (Ptr (GList (Ptr InetAddress)))
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr (GList (Ptr InetAddress))))
 -> IO (Ptr (GList (Ptr InetAddress))))
-> (Ptr (Ptr GError) -> IO (Ptr (GList (Ptr InetAddress))))
-> IO (Ptr (GList (Ptr InetAddress)))
forall a b. (a -> b) -> a -> b
$ Ptr Resolver
-> Ptr AsyncResult
-> Ptr (Ptr GError)
-> IO (Ptr (GList (Ptr InetAddress)))
g_resolver_lookup_by_name_with_flags_finish Ptr Resolver
resolver' Ptr AsyncResult
result_'
        [Ptr InetAddress]
result' <- Ptr (GList (Ptr InetAddress)) -> IO [Ptr InetAddress]
forall a. Ptr (GList (Ptr a)) -> IO [Ptr a]
unpackGList Ptr (GList (Ptr InetAddress))
result
        [InetAddress]
result'' <- (Ptr InetAddress -> IO InetAddress)
-> [Ptr InetAddress] -> IO [InetAddress]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((ManagedPtr InetAddress -> InetAddress)
-> Ptr InetAddress -> IO InetAddress
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr InetAddress -> InetAddress
Gio.InetAddress.InetAddress) [Ptr InetAddress]
result'
        Ptr (GList (Ptr InetAddress)) -> IO ()
forall a. Ptr (GList a) -> IO ()
g_list_free Ptr (GList (Ptr InetAddress))
result
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
resolver
        b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
result_
        [InetAddress] -> IO [InetAddress]
forall (m :: * -> *) a. Monad m => a -> m a
return [InetAddress]
result''
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

#if defined(ENABLE_OVERLOADING)
data ResolverLookupByNameWithFlagsFinishMethodInfo
instance (signature ~ (b -> m [Gio.InetAddress.InetAddress]), MonadIO m, IsResolver a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo ResolverLookupByNameWithFlagsFinishMethodInfo a signature where
    overloadedMethod = resolverLookupByNameWithFlagsFinish

#endif

-- method Resolver::lookup_records
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "resolver"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "Resolver" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GResolver" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "rrname"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the DNS name to lookup the record for"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "record_type"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "ResolverRecordType" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the type of DNS record to lookup"
--                 , 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 "a #GCancellable, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TGList TVariant)
-- throws : True
-- Skip return : False

foreign import ccall "g_resolver_lookup_records" g_resolver_lookup_records :: 
    Ptr Resolver ->                         -- resolver : TInterface (Name {namespace = "Gio", name = "Resolver"})
    CString ->                              -- rrname : TBasicType TUTF8
    CUInt ->                                -- record_type : TInterface (Name {namespace = "Gio", name = "ResolverRecordType"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr (GList (Ptr GVariant)))

-- | Synchronously performs a DNS record lookup for the given /@rrname@/ and returns
-- a list of records as t'GVariant' tuples. See t'GI.Gio.Enums.ResolverRecordType' for
-- information on what the records contain for each /@recordType@/.
-- 
-- If the DNS resolution fails, /@error@/ (if non-'P.Nothing') will be set to
-- a value from t'GI.Gio.Enums.ResolverError' and 'P.Nothing' will be returned.
-- 
-- If /@cancellable@/ is non-'P.Nothing', it can be used to cancel the
-- operation, in which case /@error@/ (if non-'P.Nothing') will be set to
-- 'GI.Gio.Enums.IOErrorEnumCancelled'.
-- 
-- /Since: 2.34/
resolverLookupRecords ::
    (B.CallStack.HasCallStack, MonadIO m, IsResolver a, Gio.Cancellable.IsCancellable b) =>
    a
    -- ^ /@resolver@/: a t'GI.Gio.Objects.Resolver.Resolver'
    -> T.Text
    -- ^ /@rrname@/: the DNS name to lookup the record for
    -> Gio.Enums.ResolverRecordType
    -- ^ /@recordType@/: the type of DNS record to lookup
    -> Maybe (b)
    -- ^ /@cancellable@/: a t'GI.Gio.Objects.Cancellable.Cancellable', or 'P.Nothing'
    -> m [GVariant]
    -- ^ __Returns:__ a non-empty t'GI.GLib.Structs.List.List' of
    -- t'GVariant', or 'P.Nothing' on error. You must free each of the records and the list
    -- when you are done with it. (You can use @/g_list_free_full()/@ with
    -- 'GI.GLib.Structs.Variant.variantUnref' to do this.) /(Can throw 'Data.GI.Base.GError.GError')/
resolverLookupRecords :: a -> Text -> ResolverRecordType -> Maybe b -> m [GVariant]
resolverLookupRecords resolver :: a
resolver rrname :: Text
rrname recordType :: ResolverRecordType
recordType cancellable :: Maybe b
cancellable = IO [GVariant] -> m [GVariant]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [GVariant] -> m [GVariant]) -> IO [GVariant] -> m [GVariant]
forall a b. (a -> b) -> a -> b
$ do
    Ptr Resolver
resolver' <- a -> IO (Ptr Resolver)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
resolver
    CString
rrname' <- Text -> IO CString
textToCString Text
rrname
    let recordType' :: CUInt
recordType' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt)
-> (ResolverRecordType -> Int) -> ResolverRecordType -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ResolverRecordType -> Int
forall a. Enum a => a -> Int
fromEnum) ResolverRecordType
recordType
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just jCancellable :: b
jCancellable -> do
            Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    IO [GVariant] -> IO () -> IO [GVariant]
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr (GList (Ptr GVariant))
result <- (Ptr (Ptr GError) -> IO (Ptr (GList (Ptr GVariant))))
-> IO (Ptr (GList (Ptr GVariant)))
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr (GList (Ptr GVariant))))
 -> IO (Ptr (GList (Ptr GVariant))))
-> (Ptr (Ptr GError) -> IO (Ptr (GList (Ptr GVariant))))
-> IO (Ptr (GList (Ptr GVariant)))
forall a b. (a -> b) -> a -> b
$ Ptr Resolver
-> CString
-> CUInt
-> Ptr Cancellable
-> Ptr (Ptr GError)
-> IO (Ptr (GList (Ptr GVariant)))
g_resolver_lookup_records Ptr Resolver
resolver' CString
rrname' CUInt
recordType' Ptr Cancellable
maybeCancellable
        [Ptr GVariant]
result' <- Ptr (GList (Ptr GVariant)) -> IO [Ptr GVariant]
forall a. Ptr (GList (Ptr a)) -> IO [Ptr a]
unpackGList Ptr (GList (Ptr GVariant))
result
        [GVariant]
result'' <- (Ptr GVariant -> IO GVariant) -> [Ptr GVariant] -> IO [GVariant]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Ptr GVariant -> IO GVariant
B.GVariant.wrapGVariantPtr [Ptr GVariant]
result'
        Ptr (GList (Ptr GVariant)) -> IO ()
forall a. Ptr (GList a) -> IO ()
g_list_free Ptr (GList (Ptr GVariant))
result
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
resolver
        Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
rrname'
        [GVariant] -> IO [GVariant]
forall (m :: * -> *) a. Monad m => a -> m a
return [GVariant]
result''
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
rrname'
     )

#if defined(ENABLE_OVERLOADING)
data ResolverLookupRecordsMethodInfo
instance (signature ~ (T.Text -> Gio.Enums.ResolverRecordType -> Maybe (b) -> m [GVariant]), MonadIO m, IsResolver a, Gio.Cancellable.IsCancellable b) => O.MethodInfo ResolverLookupRecordsMethodInfo a signature where
    overloadedMethod = resolverLookupRecords

#endif

-- method Resolver::lookup_records_async
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "resolver"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "Resolver" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GResolver" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "rrname"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the DNS name to lookup the record for"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "record_type"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "ResolverRecordType" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the type of DNS record to lookup"
--                 , 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 "a #GCancellable, or %NULL"
--                 , 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 "callback to call after resolution completes"
--                 , 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 "data for @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_resolver_lookup_records_async" g_resolver_lookup_records_async :: 
    Ptr Resolver ->                         -- resolver : TInterface (Name {namespace = "Gio", name = "Resolver"})
    CString ->                              -- rrname : TBasicType TUTF8
    CUInt ->                                -- record_type : TInterface (Name {namespace = "Gio", name = "ResolverRecordType"})
    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 ()

-- | Begins asynchronously performing a DNS lookup for the given
-- /@rrname@/, and eventually calls /@callback@/, which must call
-- 'GI.Gio.Objects.Resolver.resolverLookupRecordsFinish' to get the final result. See
-- 'GI.Gio.Objects.Resolver.resolverLookupRecords' for more details.
-- 
-- /Since: 2.34/
resolverLookupRecordsAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsResolver a, Gio.Cancellable.IsCancellable b) =>
    a
    -- ^ /@resolver@/: a t'GI.Gio.Objects.Resolver.Resolver'
    -> T.Text
    -- ^ /@rrname@/: the DNS name to lookup the record for
    -> Gio.Enums.ResolverRecordType
    -- ^ /@recordType@/: the type of DNS record to lookup
    -> Maybe (b)
    -- ^ /@cancellable@/: a t'GI.Gio.Objects.Cancellable.Cancellable', or 'P.Nothing'
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    -- ^ /@callback@/: callback to call after resolution completes
    -> m ()
resolverLookupRecordsAsync :: a
-> Text
-> ResolverRecordType
-> Maybe b
-> Maybe AsyncReadyCallback
-> m ()
resolverLookupRecordsAsync resolver :: a
resolver rrname :: Text
rrname recordType :: ResolverRecordType
recordType cancellable :: Maybe b
cancellable callback :: Maybe AsyncReadyCallback
callback = 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 Resolver
resolver' <- a -> IO (Ptr Resolver)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
resolver
    CString
rrname' <- Text -> IO CString
textToCString Text
rrname
    let recordType' :: CUInt
recordType' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt)
-> (ResolverRecordType -> Int) -> ResolverRecordType -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ResolverRecordType -> Int
forall a. Enum a => a -> Int
fromEnum) ResolverRecordType
recordType
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just jCancellable :: b
jCancellable -> do
            Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    FunPtr C_AsyncReadyCallback
maybeCallback <- case Maybe AsyncReadyCallback
callback of
        Nothing -> FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr C_AsyncReadyCallback
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
        Just jCallback :: AsyncReadyCallback
jCallback -> do
            Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
            FunPtr C_AsyncReadyCallback
jCallback' <- C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
Gio.Callbacks.mk_AsyncReadyCallback (Maybe (Ptr (FunPtr C_AsyncReadyCallback))
-> AsyncReadyCallback_WithClosures -> C_AsyncReadyCallback
Gio.Callbacks.wrap_AsyncReadyCallback (Ptr (FunPtr C_AsyncReadyCallback)
-> Maybe (Ptr (FunPtr C_AsyncReadyCallback))
forall a. a -> Maybe a
Just Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback) (AsyncReadyCallback -> AsyncReadyCallback_WithClosures
Gio.Callbacks.drop_closures_AsyncReadyCallback AsyncReadyCallback
jCallback))
            Ptr (FunPtr C_AsyncReadyCallback)
-> FunPtr C_AsyncReadyCallback -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback FunPtr C_AsyncReadyCallback
jCallback'
            FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
jCallback'
    let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
    Ptr Resolver
-> CString
-> CUInt
-> Ptr Cancellable
-> FunPtr C_AsyncReadyCallback
-> Ptr ()
-> IO ()
g_resolver_lookup_records_async Ptr Resolver
resolver' CString
rrname' CUInt
recordType' Ptr Cancellable
maybeCancellable FunPtr C_AsyncReadyCallback
maybeCallback Ptr ()
forall a. Ptr a
userData
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
resolver
    Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
rrname'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data ResolverLookupRecordsAsyncMethodInfo
instance (signature ~ (T.Text -> Gio.Enums.ResolverRecordType -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsResolver a, Gio.Cancellable.IsCancellable b) => O.MethodInfo ResolverLookupRecordsAsyncMethodInfo a signature where
    overloadedMethod = resolverLookupRecordsAsync

#endif

-- method Resolver::lookup_records_finish
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "resolver"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "Resolver" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GResolver" , 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 "the result passed to your #GAsyncReadyCallback"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TGList TVariant)
-- throws : True
-- Skip return : False

foreign import ccall "g_resolver_lookup_records_finish" g_resolver_lookup_records_finish :: 
    Ptr Resolver ->                         -- resolver : TInterface (Name {namespace = "Gio", name = "Resolver"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr (GList (Ptr GVariant)))

-- | Retrieves the result of a previous call to
-- 'GI.Gio.Objects.Resolver.resolverLookupRecordsAsync'. Returns a non-empty list of records as
-- t'GVariant' tuples. See t'GI.Gio.Enums.ResolverRecordType' for information on what the
-- records contain.
-- 
-- If the DNS resolution failed, /@error@/ (if non-'P.Nothing') will be set to
-- a value from t'GI.Gio.Enums.ResolverError'. If the operation was cancelled,
-- /@error@/ will be set to 'GI.Gio.Enums.IOErrorEnumCancelled'.
-- 
-- /Since: 2.34/
resolverLookupRecordsFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsResolver a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    -- ^ /@resolver@/: a t'GI.Gio.Objects.Resolver.Resolver'
    -> b
    -- ^ /@result@/: the result passed to your t'GI.Gio.Callbacks.AsyncReadyCallback'
    -> m [GVariant]
    -- ^ __Returns:__ a non-empty t'GI.GLib.Structs.List.List' of
    -- t'GVariant', or 'P.Nothing' on error. You must free each of the records and the list
    -- when you are done with it. (You can use @/g_list_free_full()/@ with
    -- 'GI.GLib.Structs.Variant.variantUnref' to do this.) /(Can throw 'Data.GI.Base.GError.GError')/
resolverLookupRecordsFinish :: a -> b -> m [GVariant]
resolverLookupRecordsFinish resolver :: a
resolver result_ :: b
result_ = IO [GVariant] -> m [GVariant]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [GVariant] -> m [GVariant]) -> IO [GVariant] -> m [GVariant]
forall a b. (a -> b) -> a -> b
$ do
    Ptr Resolver
resolver' <- a -> IO (Ptr Resolver)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
resolver
    Ptr AsyncResult
result_' <- b -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
result_
    IO [GVariant] -> IO () -> IO [GVariant]
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr (GList (Ptr GVariant))
result <- (Ptr (Ptr GError) -> IO (Ptr (GList (Ptr GVariant))))
-> IO (Ptr (GList (Ptr GVariant)))
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr (GList (Ptr GVariant))))
 -> IO (Ptr (GList (Ptr GVariant))))
-> (Ptr (Ptr GError) -> IO (Ptr (GList (Ptr GVariant))))
-> IO (Ptr (GList (Ptr GVariant)))
forall a b. (a -> b) -> a -> b
$ Ptr Resolver
-> Ptr AsyncResult
-> Ptr (Ptr GError)
-> IO (Ptr (GList (Ptr GVariant)))
g_resolver_lookup_records_finish Ptr Resolver
resolver' Ptr AsyncResult
result_'
        [Ptr GVariant]
result' <- Ptr (GList (Ptr GVariant)) -> IO [Ptr GVariant]
forall a. Ptr (GList (Ptr a)) -> IO [Ptr a]
unpackGList Ptr (GList (Ptr GVariant))
result
        [GVariant]
result'' <- (Ptr GVariant -> IO GVariant) -> [Ptr GVariant] -> IO [GVariant]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Ptr GVariant -> IO GVariant
B.GVariant.wrapGVariantPtr [Ptr GVariant]
result'
        Ptr (GList (Ptr GVariant)) -> IO ()
forall a. Ptr (GList a) -> IO ()
g_list_free Ptr (GList (Ptr GVariant))
result
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
resolver
        b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
result_
        [GVariant] -> IO [GVariant]
forall (m :: * -> *) a. Monad m => a -> m a
return [GVariant]
result''
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

#if defined(ENABLE_OVERLOADING)
data ResolverLookupRecordsFinishMethodInfo
instance (signature ~ (b -> m [GVariant]), MonadIO m, IsResolver a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo ResolverLookupRecordsFinishMethodInfo a signature where
    overloadedMethod = resolverLookupRecordsFinish

#endif

-- method Resolver::lookup_service
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "resolver"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "Resolver" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GResolver" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "service"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the service type to look up (eg, \"ldap\")"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "protocol"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "the networking protocol to use for @service (eg, \"tcp\")"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "domain"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the DNS domain to look up the service in"
--                 , 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 "a #GCancellable, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TGList
--                  (TInterface Name { namespace = "Gio" , name = "SrvTarget" }))
-- throws : True
-- Skip return : False

foreign import ccall "g_resolver_lookup_service" g_resolver_lookup_service :: 
    Ptr Resolver ->                         -- resolver : TInterface (Name {namespace = "Gio", name = "Resolver"})
    CString ->                              -- service : TBasicType TUTF8
    CString ->                              -- protocol : TBasicType TUTF8
    CString ->                              -- domain : TBasicType TUTF8
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr (GList (Ptr Gio.SrvTarget.SrvTarget)))

-- | Synchronously performs a DNS SRV lookup for the given /@service@/ and
-- /@protocol@/ in the given /@domain@/ and returns an array of t'GI.Gio.Structs.SrvTarget.SrvTarget'.
-- /@domain@/ may be an ASCII-only or UTF-8 hostname. Note also that the
-- /@service@/ and /@protocol@/ arguments do not include the leading underscore
-- that appears in the actual DNS entry.
-- 
-- On success, 'GI.Gio.Objects.Resolver.resolverLookupService' will return a non-empty t'GI.GLib.Structs.List.List' of
-- t'GI.Gio.Structs.SrvTarget.SrvTarget', sorted in order of preference. (That is, you should
-- attempt to connect to the first target first, then the second if
-- the first fails, etc.)
-- 
-- If the DNS resolution fails, /@error@/ (if non-'P.Nothing') will be set to
-- a value from t'GI.Gio.Enums.ResolverError' and 'P.Nothing' will be returned.
-- 
-- If /@cancellable@/ is non-'P.Nothing', it can be used to cancel the
-- operation, in which case /@error@/ (if non-'P.Nothing') will be set to
-- 'GI.Gio.Enums.IOErrorEnumCancelled'.
-- 
-- If you are planning to connect to the service, it is usually easier
-- to create a t'GI.Gio.Objects.NetworkService.NetworkService' and use its t'GI.Gio.Interfaces.SocketConnectable.SocketConnectable'
-- interface.
-- 
-- /Since: 2.22/
resolverLookupService ::
    (B.CallStack.HasCallStack, MonadIO m, IsResolver a, Gio.Cancellable.IsCancellable b) =>
    a
    -- ^ /@resolver@/: a t'GI.Gio.Objects.Resolver.Resolver'
    -> T.Text
    -- ^ /@service@/: the service type to look up (eg, \"ldap\")
    -> T.Text
    -- ^ /@protocol@/: the networking protocol to use for /@service@/ (eg, \"tcp\")
    -> T.Text
    -- ^ /@domain@/: the DNS domain to look up the service in
    -> Maybe (b)
    -- ^ /@cancellable@/: a t'GI.Gio.Objects.Cancellable.Cancellable', or 'P.Nothing'
    -> m [Gio.SrvTarget.SrvTarget]
    -- ^ __Returns:__ a non-empty t'GI.GLib.Structs.List.List' of
    -- t'GI.Gio.Structs.SrvTarget.SrvTarget', or 'P.Nothing' on error. You must free each of the targets and the
    -- list when you are done with it. (You can use @/g_resolver_free_targets()/@ to do
    -- this.) /(Can throw 'Data.GI.Base.GError.GError')/
resolverLookupService :: a -> Text -> Text -> Text -> Maybe b -> m [SrvTarget]
resolverLookupService resolver :: a
resolver service :: Text
service protocol :: Text
protocol domain :: Text
domain cancellable :: Maybe b
cancellable = IO [SrvTarget] -> m [SrvTarget]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [SrvTarget] -> m [SrvTarget])
-> IO [SrvTarget] -> m [SrvTarget]
forall a b. (a -> b) -> a -> b
$ do
    Ptr Resolver
resolver' <- a -> IO (Ptr Resolver)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
resolver
    CString
service' <- Text -> IO CString
textToCString Text
service
    CString
protocol' <- Text -> IO CString
textToCString Text
protocol
    CString
domain' <- Text -> IO CString
textToCString Text
domain
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just jCancellable :: b
jCancellable -> do
            Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    IO [SrvTarget] -> IO () -> IO [SrvTarget]
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr (GList (Ptr SrvTarget))
result <- (Ptr (Ptr GError) -> IO (Ptr (GList (Ptr SrvTarget))))
-> IO (Ptr (GList (Ptr SrvTarget)))
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr (GList (Ptr SrvTarget))))
 -> IO (Ptr (GList (Ptr SrvTarget))))
-> (Ptr (Ptr GError) -> IO (Ptr (GList (Ptr SrvTarget))))
-> IO (Ptr (GList (Ptr SrvTarget)))
forall a b. (a -> b) -> a -> b
$ Ptr Resolver
-> CString
-> CString
-> CString
-> Ptr Cancellable
-> Ptr (Ptr GError)
-> IO (Ptr (GList (Ptr SrvTarget)))
g_resolver_lookup_service Ptr Resolver
resolver' CString
service' CString
protocol' CString
domain' Ptr Cancellable
maybeCancellable
        [Ptr SrvTarget]
result' <- Ptr (GList (Ptr SrvTarget)) -> IO [Ptr SrvTarget]
forall a. Ptr (GList (Ptr a)) -> IO [Ptr a]
unpackGList Ptr (GList (Ptr SrvTarget))
result
        [SrvTarget]
result'' <- (Ptr SrvTarget -> IO SrvTarget)
-> [Ptr SrvTarget] -> IO [SrvTarget]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((ManagedPtr SrvTarget -> SrvTarget)
-> Ptr SrvTarget -> IO SrvTarget
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr SrvTarget -> SrvTarget
Gio.SrvTarget.SrvTarget) [Ptr SrvTarget]
result'
        Ptr (GList (Ptr SrvTarget)) -> IO ()
forall a. Ptr (GList a) -> IO ()
g_list_free Ptr (GList (Ptr SrvTarget))
result
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
resolver
        Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
service'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
protocol'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
domain'
        [SrvTarget] -> IO [SrvTarget]
forall (m :: * -> *) a. Monad m => a -> m a
return [SrvTarget]
result''
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
service'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
protocol'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
domain'
     )

#if defined(ENABLE_OVERLOADING)
data ResolverLookupServiceMethodInfo
instance (signature ~ (T.Text -> T.Text -> T.Text -> Maybe (b) -> m [Gio.SrvTarget.SrvTarget]), MonadIO m, IsResolver a, Gio.Cancellable.IsCancellable b) => O.MethodInfo ResolverLookupServiceMethodInfo a signature where
    overloadedMethod = resolverLookupService

#endif

-- method Resolver::lookup_service_async
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "resolver"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "Resolver" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GResolver" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "service"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the service type to look up (eg, \"ldap\")"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "protocol"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "the networking protocol to use for @service (eg, \"tcp\")"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "domain"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the DNS domain to look up the service in"
--                 , 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 "a #GCancellable, or %NULL"
--                 , 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 "callback to call after resolution completes"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeAsync
--           , argClosure = 6
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "user_data"
--           , argType = TBasicType TPtr
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "data for @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_resolver_lookup_service_async" g_resolver_lookup_service_async :: 
    Ptr Resolver ->                         -- resolver : TInterface (Name {namespace = "Gio", name = "Resolver"})
    CString ->                              -- service : TBasicType TUTF8
    CString ->                              -- protocol : TBasicType TUTF8
    CString ->                              -- domain : TBasicType TUTF8
    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 ()

-- | Begins asynchronously performing a DNS SRV lookup for the given
-- /@service@/ and /@protocol@/ in the given /@domain@/, and eventually calls
-- /@callback@/, which must call 'GI.Gio.Objects.Resolver.resolverLookupServiceFinish' to
-- get the final result. See 'GI.Gio.Objects.Resolver.resolverLookupService' for more
-- details.
-- 
-- /Since: 2.22/
resolverLookupServiceAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsResolver a, Gio.Cancellable.IsCancellable b) =>
    a
    -- ^ /@resolver@/: a t'GI.Gio.Objects.Resolver.Resolver'
    -> T.Text
    -- ^ /@service@/: the service type to look up (eg, \"ldap\")
    -> T.Text
    -- ^ /@protocol@/: the networking protocol to use for /@service@/ (eg, \"tcp\")
    -> T.Text
    -- ^ /@domain@/: the DNS domain to look up the service in
    -> Maybe (b)
    -- ^ /@cancellable@/: a t'GI.Gio.Objects.Cancellable.Cancellable', or 'P.Nothing'
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    -- ^ /@callback@/: callback to call after resolution completes
    -> m ()
resolverLookupServiceAsync :: a
-> Text
-> Text
-> Text
-> Maybe b
-> Maybe AsyncReadyCallback
-> m ()
resolverLookupServiceAsync resolver :: a
resolver service :: Text
service protocol :: Text
protocol domain :: Text
domain cancellable :: Maybe b
cancellable callback :: Maybe AsyncReadyCallback
callback = 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 Resolver
resolver' <- a -> IO (Ptr Resolver)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
resolver
    CString
service' <- Text -> IO CString
textToCString Text
service
    CString
protocol' <- Text -> IO CString
textToCString Text
protocol
    CString
domain' <- Text -> IO CString
textToCString Text
domain
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just jCancellable :: b
jCancellable -> do
            Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    FunPtr C_AsyncReadyCallback
maybeCallback <- case Maybe AsyncReadyCallback
callback of
        Nothing -> FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr C_AsyncReadyCallback
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
        Just jCallback :: AsyncReadyCallback
jCallback -> do
            Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
            FunPtr C_AsyncReadyCallback
jCallback' <- C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
Gio.Callbacks.mk_AsyncReadyCallback (Maybe (Ptr (FunPtr C_AsyncReadyCallback))
-> AsyncReadyCallback_WithClosures -> C_AsyncReadyCallback
Gio.Callbacks.wrap_AsyncReadyCallback (Ptr (FunPtr C_AsyncReadyCallback)
-> Maybe (Ptr (FunPtr C_AsyncReadyCallback))
forall a. a -> Maybe a
Just Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback) (AsyncReadyCallback -> AsyncReadyCallback_WithClosures
Gio.Callbacks.drop_closures_AsyncReadyCallback AsyncReadyCallback
jCallback))
            Ptr (FunPtr C_AsyncReadyCallback)
-> FunPtr C_AsyncReadyCallback -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback FunPtr C_AsyncReadyCallback
jCallback'
            FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
jCallback'
    let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
    Ptr Resolver
-> CString
-> CString
-> CString
-> Ptr Cancellable
-> FunPtr C_AsyncReadyCallback
-> Ptr ()
-> IO ()
g_resolver_lookup_service_async Ptr Resolver
resolver' CString
service' CString
protocol' CString
domain' Ptr Cancellable
maybeCancellable FunPtr C_AsyncReadyCallback
maybeCallback Ptr ()
forall a. Ptr a
userData
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
resolver
    Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
service'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
protocol'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
domain'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data ResolverLookupServiceAsyncMethodInfo
instance (signature ~ (T.Text -> T.Text -> T.Text -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsResolver a, Gio.Cancellable.IsCancellable b) => O.MethodInfo ResolverLookupServiceAsyncMethodInfo a signature where
    overloadedMethod = resolverLookupServiceAsync

#endif

-- method Resolver::lookup_service_finish
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "resolver"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "Resolver" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GResolver" , 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 "the result passed to your #GAsyncReadyCallback"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TGList
--                  (TInterface Name { namespace = "Gio" , name = "SrvTarget" }))
-- throws : True
-- Skip return : False

foreign import ccall "g_resolver_lookup_service_finish" g_resolver_lookup_service_finish :: 
    Ptr Resolver ->                         -- resolver : TInterface (Name {namespace = "Gio", name = "Resolver"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr (GList (Ptr Gio.SrvTarget.SrvTarget)))

-- | Retrieves the result of a previous call to
-- 'GI.Gio.Objects.Resolver.resolverLookupServiceAsync'.
-- 
-- If the DNS resolution failed, /@error@/ (if non-'P.Nothing') will be set to
-- a value from t'GI.Gio.Enums.ResolverError'. If the operation was cancelled,
-- /@error@/ will be set to 'GI.Gio.Enums.IOErrorEnumCancelled'.
-- 
-- /Since: 2.22/
resolverLookupServiceFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsResolver a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    -- ^ /@resolver@/: a t'GI.Gio.Objects.Resolver.Resolver'
    -> b
    -- ^ /@result@/: the result passed to your t'GI.Gio.Callbacks.AsyncReadyCallback'
    -> m [Gio.SrvTarget.SrvTarget]
    -- ^ __Returns:__ a non-empty t'GI.GLib.Structs.List.List' of
    -- t'GI.Gio.Structs.SrvTarget.SrvTarget', or 'P.Nothing' on error. See 'GI.Gio.Objects.Resolver.resolverLookupService' for more
    -- details. /(Can throw 'Data.GI.Base.GError.GError')/
resolverLookupServiceFinish :: a -> b -> m [SrvTarget]
resolverLookupServiceFinish resolver :: a
resolver result_ :: b
result_ = IO [SrvTarget] -> m [SrvTarget]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [SrvTarget] -> m [SrvTarget])
-> IO [SrvTarget] -> m [SrvTarget]
forall a b. (a -> b) -> a -> b
$ do
    Ptr Resolver
resolver' <- a -> IO (Ptr Resolver)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
resolver
    Ptr AsyncResult
result_' <- b -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
result_
    IO [SrvTarget] -> IO () -> IO [SrvTarget]
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr (GList (Ptr SrvTarget))
result <- (Ptr (Ptr GError) -> IO (Ptr (GList (Ptr SrvTarget))))
-> IO (Ptr (GList (Ptr SrvTarget)))
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr (GList (Ptr SrvTarget))))
 -> IO (Ptr (GList (Ptr SrvTarget))))
-> (Ptr (Ptr GError) -> IO (Ptr (GList (Ptr SrvTarget))))
-> IO (Ptr (GList (Ptr SrvTarget)))
forall a b. (a -> b) -> a -> b
$ Ptr Resolver
-> Ptr AsyncResult
-> Ptr (Ptr GError)
-> IO (Ptr (GList (Ptr SrvTarget)))
g_resolver_lookup_service_finish Ptr Resolver
resolver' Ptr AsyncResult
result_'
        [Ptr SrvTarget]
result' <- Ptr (GList (Ptr SrvTarget)) -> IO [Ptr SrvTarget]
forall a. Ptr (GList (Ptr a)) -> IO [Ptr a]
unpackGList Ptr (GList (Ptr SrvTarget))
result
        [SrvTarget]
result'' <- (Ptr SrvTarget -> IO SrvTarget)
-> [Ptr SrvTarget] -> IO [SrvTarget]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((ManagedPtr SrvTarget -> SrvTarget)
-> Ptr SrvTarget -> IO SrvTarget
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr SrvTarget -> SrvTarget
Gio.SrvTarget.SrvTarget) [Ptr SrvTarget]
result'
        Ptr (GList (Ptr SrvTarget)) -> IO ()
forall a. Ptr (GList a) -> IO ()
g_list_free Ptr (GList (Ptr SrvTarget))
result
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
resolver
        b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
result_
        [SrvTarget] -> IO [SrvTarget]
forall (m :: * -> *) a. Monad m => a -> m a
return [SrvTarget]
result''
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

#if defined(ENABLE_OVERLOADING)
data ResolverLookupServiceFinishMethodInfo
instance (signature ~ (b -> m [Gio.SrvTarget.SrvTarget]), MonadIO m, IsResolver a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo ResolverLookupServiceFinishMethodInfo a signature where
    overloadedMethod = resolverLookupServiceFinish

#endif

-- method Resolver::set_default
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "resolver"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "Resolver" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the new default #GResolver"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_resolver_set_default" g_resolver_set_default :: 
    Ptr Resolver ->                         -- resolver : TInterface (Name {namespace = "Gio", name = "Resolver"})
    IO ()

-- | Sets /@resolver@/ to be the application\'s default resolver (reffing
-- /@resolver@/, and unreffing the previous default resolver, if any).
-- Future calls to 'GI.Gio.Objects.Resolver.resolverGetDefault' will return this resolver.
-- 
-- This can be used if an application wants to perform any sort of DNS
-- caching or \"pinning\"; it can implement its own t'GI.Gio.Objects.Resolver.Resolver' that
-- calls the original default resolver for DNS operations, and
-- implements its own cache policies on top of that, and then set
-- itself as the default resolver for all later code to use.
-- 
-- /Since: 2.22/
resolverSetDefault ::
    (B.CallStack.HasCallStack, MonadIO m, IsResolver a) =>
    a
    -- ^ /@resolver@/: the new default t'GI.Gio.Objects.Resolver.Resolver'
    -> m ()
resolverSetDefault :: a -> m ()
resolverSetDefault resolver :: a
resolver = 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 Resolver
resolver' <- a -> IO (Ptr Resolver)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
resolver
    Ptr Resolver -> IO ()
g_resolver_set_default Ptr Resolver
resolver'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
resolver
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data ResolverSetDefaultMethodInfo
instance (signature ~ (m ()), MonadIO m, IsResolver a) => O.MethodInfo ResolverSetDefaultMethodInfo a signature where
    overloadedMethod = resolverSetDefault

#endif

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

foreign import ccall "g_resolver_get_default" g_resolver_get_default :: 
    IO (Ptr Resolver)

-- | Gets the default t'GI.Gio.Objects.Resolver.Resolver'. You should unref it when you are done
-- with it. t'GI.Gio.Objects.Resolver.Resolver' may use its reference count as a hint about how
-- many threads it should allocate for concurrent DNS resolutions.
-- 
-- /Since: 2.22/
resolverGetDefault ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Resolver
    -- ^ __Returns:__ the default t'GI.Gio.Objects.Resolver.Resolver'.
resolverGetDefault :: m Resolver
resolverGetDefault  = IO Resolver -> m Resolver
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Resolver -> m Resolver) -> IO Resolver -> m Resolver
forall a b. (a -> b) -> a -> b
$ do
    Ptr Resolver
result <- IO (Ptr Resolver)
g_resolver_get_default
    Text -> Ptr Resolver -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "resolverGetDefault" Ptr Resolver
result
    Resolver
result' <- ((ManagedPtr Resolver -> Resolver) -> Ptr Resolver -> IO Resolver
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Resolver -> Resolver
Resolver) Ptr Resolver
result
    Resolver -> IO Resolver
forall (m :: * -> *) a. Monad m => a -> m a
return Resolver
result'

#if defined(ENABLE_OVERLOADING)
#endif