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

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

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

module GI.Soup.Objects.Address
    (

-- * Exported types
    Address(..)                             ,
    IsAddress                               ,
    toAddress                               ,
    noAddress                               ,


 -- * Methods
-- ** equalByIp #method:equalByIp#

#if ENABLE_OVERLOADING
    AddressEqualByIpMethodInfo              ,
#endif
    addressEqualByIp                        ,


-- ** equalByName #method:equalByName#

#if ENABLE_OVERLOADING
    AddressEqualByNameMethodInfo            ,
#endif
    addressEqualByName                      ,


-- ** getGsockaddr #method:getGsockaddr#

#if ENABLE_OVERLOADING
    AddressGetGsockaddrMethodInfo           ,
#endif
    addressGetGsockaddr                     ,


-- ** getName #method:getName#

#if ENABLE_OVERLOADING
    AddressGetNameMethodInfo                ,
#endif
    addressGetName                          ,


-- ** getPhysical #method:getPhysical#

#if ENABLE_OVERLOADING
    AddressGetPhysicalMethodInfo            ,
#endif
    addressGetPhysical                      ,


-- ** getPort #method:getPort#

#if ENABLE_OVERLOADING
    AddressGetPortMethodInfo                ,
#endif
    addressGetPort                          ,


-- ** hashByIp #method:hashByIp#

#if ENABLE_OVERLOADING
    AddressHashByIpMethodInfo               ,
#endif
    addressHashByIp                         ,


-- ** hashByName #method:hashByName#

#if ENABLE_OVERLOADING
    AddressHashByNameMethodInfo             ,
#endif
    addressHashByName                       ,


-- ** isResolved #method:isResolved#

#if ENABLE_OVERLOADING
    AddressIsResolvedMethodInfo             ,
#endif
    addressIsResolved                       ,


-- ** new #method:new#

    addressNew                              ,


-- ** newAny #method:newAny#

    addressNewAny                           ,


-- ** newFromSockaddr #method:newFromSockaddr#

    addressNewFromSockaddr                  ,


-- ** resolveAsync #method:resolveAsync#

#if ENABLE_OVERLOADING
    AddressResolveAsyncMethodInfo           ,
#endif
    addressResolveAsync                     ,


-- ** resolveSync #method:resolveSync#

#if ENABLE_OVERLOADING
    AddressResolveSyncMethodInfo            ,
#endif
    addressResolveSync                      ,




 -- * Properties
-- ** family #attr:family#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
    AddressFamilyPropertyInfo               ,
#endif
#if ENABLE_OVERLOADING
    addressFamily                           ,
#endif
    constructAddressFamily                  ,
    getAddressFamily                        ,


-- ** name #attr:name#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
    AddressNamePropertyInfo                 ,
#endif
#if ENABLE_OVERLOADING
    addressName                             ,
#endif
    constructAddressName                    ,
    getAddressName                          ,


-- ** physical #attr:physical#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
    AddressPhysicalPropertyInfo             ,
#endif
#if ENABLE_OVERLOADING
    addressPhysical                         ,
#endif
    getAddressPhysical                      ,


-- ** port #attr:port#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
    AddressPortPropertyInfo                 ,
#endif
#if ENABLE_OVERLOADING
    addressPort                             ,
#endif
    constructAddressPort                    ,
    getAddressPort                          ,


-- ** protocol #attr:protocol#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
    AddressProtocolPropertyInfo             ,
#endif
#if ENABLE_OVERLOADING
    addressProtocol                         ,
#endif
    constructAddressProtocol                ,
    getAddressProtocol                      ,


-- ** sockaddr #attr:sockaddr#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
    AddressSockaddrPropertyInfo             ,
#endif
#if ENABLE_OVERLOADING
    addressSockaddr                         ,
#endif
    constructAddressSockaddr                ,
    getAddressSockaddr                      ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL

import qualified GI.GLib.Structs.MainContext as GLib.MainContext
import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Interfaces.SocketConnectable as Gio.SocketConnectable
import qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import qualified GI.Gio.Objects.SocketAddress as Gio.SocketAddress
import qualified GI.Soup.Callbacks as Soup.Callbacks
import {-# SOURCE #-} qualified GI.Soup.Enums as Soup.Enums

-- | Memory-managed wrapper type.
newtype Address = Address (ManagedPtr Address)
foreign import ccall "soup_address_get_type"
    c_soup_address_get_type :: IO GType

instance GObject Address where
    gobjectType = c_soup_address_get_type


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

instance O.HasParentTypes Address
type instance O.ParentTypes Address = '[GObject.Object.Object, Gio.SocketConnectable.SocketConnectable]

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

-- | A convenience alias for `Nothing` :: `Maybe` `Address`.
noAddress :: Maybe Address
noAddress = Nothing

#if ENABLE_OVERLOADING
type family ResolveAddressMethod (t :: Symbol) (o :: *) :: * where
    ResolveAddressMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveAddressMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveAddressMethod "enumerate" o = Gio.SocketConnectable.SocketConnectableEnumerateMethodInfo
    ResolveAddressMethod "equalByIp" o = AddressEqualByIpMethodInfo
    ResolveAddressMethod "equalByName" o = AddressEqualByNameMethodInfo
    ResolveAddressMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveAddressMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveAddressMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveAddressMethod "hashByIp" o = AddressHashByIpMethodInfo
    ResolveAddressMethod "hashByName" o = AddressHashByNameMethodInfo
    ResolveAddressMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveAddressMethod "isResolved" o = AddressIsResolvedMethodInfo
    ResolveAddressMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveAddressMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveAddressMethod "proxyEnumerate" o = Gio.SocketConnectable.SocketConnectableProxyEnumerateMethodInfo
    ResolveAddressMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveAddressMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveAddressMethod "resolveAsync" o = AddressResolveAsyncMethodInfo
    ResolveAddressMethod "resolveSync" o = AddressResolveSyncMethodInfo
    ResolveAddressMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveAddressMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveAddressMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveAddressMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveAddressMethod "toString" o = Gio.SocketConnectable.SocketConnectableToStringMethodInfo
    ResolveAddressMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveAddressMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveAddressMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveAddressMethod "getGsockaddr" o = AddressGetGsockaddrMethodInfo
    ResolveAddressMethod "getName" o = AddressGetNameMethodInfo
    ResolveAddressMethod "getPhysical" o = AddressGetPhysicalMethodInfo
    ResolveAddressMethod "getPort" o = AddressGetPortMethodInfo
    ResolveAddressMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveAddressMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveAddressMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveAddressMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveAddressMethod l o = O.MethodResolutionFailed l o

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

#endif

-- VVV Prop "family"
   -- Type: TInterface (Name {namespace = "Soup", name = "AddressFamily"})
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Nothing)

{- |
Get the value of the “@family@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' address #family
@
-}
getAddressFamily :: (MonadIO m, IsAddress o) => o -> m Soup.Enums.AddressFamily
getAddressFamily obj = liftIO $ B.Properties.getObjectPropertyEnum obj "family"

{- |
Construct a `GValueConstruct` with valid value for the “@family@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructAddressFamily :: (IsAddress o) => Soup.Enums.AddressFamily -> IO (GValueConstruct o)
constructAddressFamily val = B.Properties.constructObjectPropertyEnum "family" val

#if ENABLE_OVERLOADING
data AddressFamilyPropertyInfo
instance AttrInfo AddressFamilyPropertyInfo where
    type AttrAllowedOps AddressFamilyPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint AddressFamilyPropertyInfo = (~) Soup.Enums.AddressFamily
    type AttrBaseTypeConstraint AddressFamilyPropertyInfo = IsAddress
    type AttrGetType AddressFamilyPropertyInfo = Soup.Enums.AddressFamily
    type AttrLabel AddressFamilyPropertyInfo = "family"
    type AttrOrigin AddressFamilyPropertyInfo = Address
    attrGet _ = getAddressFamily
    attrSet _ = undefined
    attrConstruct _ = constructAddressFamily
    attrClear _ = undefined
#endif

-- VVV Prop "name"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Just True,Nothing)

{- |
Get the value of the “@name@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' address #name
@
-}
getAddressName :: (MonadIO m, IsAddress o) => o -> m (Maybe T.Text)
getAddressName obj = liftIO $ B.Properties.getObjectPropertyString obj "name"

{- |
Construct a `GValueConstruct` with valid value for the “@name@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructAddressName :: (IsAddress o) => T.Text -> IO (GValueConstruct o)
constructAddressName val = B.Properties.constructObjectPropertyString "name" (Just val)

#if ENABLE_OVERLOADING
data AddressNamePropertyInfo
instance AttrInfo AddressNamePropertyInfo where
    type AttrAllowedOps AddressNamePropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint AddressNamePropertyInfo = (~) T.Text
    type AttrBaseTypeConstraint AddressNamePropertyInfo = IsAddress
    type AttrGetType AddressNamePropertyInfo = (Maybe T.Text)
    type AttrLabel AddressNamePropertyInfo = "name"
    type AttrOrigin AddressNamePropertyInfo = Address
    attrGet _ = getAddressName
    attrSet _ = undefined
    attrConstruct _ = constructAddressName
    attrClear _ = undefined
#endif

-- VVV Prop "physical"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable]
   -- Nullable: (Just True,Nothing)

{- |
Get the value of the “@physical@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' address #physical
@
-}
getAddressPhysical :: (MonadIO m, IsAddress o) => o -> m (Maybe T.Text)
getAddressPhysical obj = liftIO $ B.Properties.getObjectPropertyString obj "physical"

#if ENABLE_OVERLOADING
data AddressPhysicalPropertyInfo
instance AttrInfo AddressPhysicalPropertyInfo where
    type AttrAllowedOps AddressPhysicalPropertyInfo = '[ 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint AddressPhysicalPropertyInfo = (~) ()
    type AttrBaseTypeConstraint AddressPhysicalPropertyInfo = IsAddress
    type AttrGetType AddressPhysicalPropertyInfo = (Maybe T.Text)
    type AttrLabel AddressPhysicalPropertyInfo = "physical"
    type AttrOrigin AddressPhysicalPropertyInfo = Address
    attrGet _ = getAddressPhysical
    attrSet _ = undefined
    attrConstruct _ = undefined
    attrClear _ = undefined
#endif

-- VVV Prop "port"
   -- Type: TBasicType TInt
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Nothing)

{- |
Get the value of the “@port@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' address #port
@
-}
getAddressPort :: (MonadIO m, IsAddress o) => o -> m Int32
getAddressPort obj = liftIO $ B.Properties.getObjectPropertyInt32 obj "port"

{- |
Construct a `GValueConstruct` with valid value for the “@port@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructAddressPort :: (IsAddress o) => Int32 -> IO (GValueConstruct o)
constructAddressPort val = B.Properties.constructObjectPropertyInt32 "port" val

#if ENABLE_OVERLOADING
data AddressPortPropertyInfo
instance AttrInfo AddressPortPropertyInfo where
    type AttrAllowedOps AddressPortPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint AddressPortPropertyInfo = (~) Int32
    type AttrBaseTypeConstraint AddressPortPropertyInfo = IsAddress
    type AttrGetType AddressPortPropertyInfo = Int32
    type AttrLabel AddressPortPropertyInfo = "port"
    type AttrOrigin AddressPortPropertyInfo = Address
    attrGet _ = getAddressPort
    attrSet _ = undefined
    attrConstruct _ = constructAddressPort
    attrClear _ = undefined
#endif

-- VVV Prop "protocol"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Nothing)

{- |
Get the value of the “@protocol@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' address #protocol
@
-}
getAddressProtocol :: (MonadIO m, IsAddress o) => o -> m (Maybe T.Text)
getAddressProtocol obj = liftIO $ B.Properties.getObjectPropertyString obj "protocol"

{- |
Construct a `GValueConstruct` with valid value for the “@protocol@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructAddressProtocol :: (IsAddress o) => T.Text -> IO (GValueConstruct o)
constructAddressProtocol val = B.Properties.constructObjectPropertyString "protocol" (Just val)

#if ENABLE_OVERLOADING
data AddressProtocolPropertyInfo
instance AttrInfo AddressProtocolPropertyInfo where
    type AttrAllowedOps AddressProtocolPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint AddressProtocolPropertyInfo = (~) T.Text
    type AttrBaseTypeConstraint AddressProtocolPropertyInfo = IsAddress
    type AttrGetType AddressProtocolPropertyInfo = (Maybe T.Text)
    type AttrLabel AddressProtocolPropertyInfo = "protocol"
    type AttrOrigin AddressProtocolPropertyInfo = Address
    attrGet _ = getAddressProtocol
    attrSet _ = undefined
    attrConstruct _ = constructAddressProtocol
    attrClear _ = undefined
#endif

-- VVV Prop "sockaddr"
   -- Type: TBasicType TPtr
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Nothing)

{- |
Get the value of the “@sockaddr@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' address #sockaddr
@
-}
getAddressSockaddr :: (MonadIO m, IsAddress o) => o -> m (Ptr ())
getAddressSockaddr obj = liftIO $ B.Properties.getObjectPropertyPtr obj "sockaddr"

{- |
Construct a `GValueConstruct` with valid value for the “@sockaddr@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructAddressSockaddr :: (IsAddress o) => Ptr () -> IO (GValueConstruct o)
constructAddressSockaddr val = B.Properties.constructObjectPropertyPtr "sockaddr" val

#if ENABLE_OVERLOADING
data AddressSockaddrPropertyInfo
instance AttrInfo AddressSockaddrPropertyInfo where
    type AttrAllowedOps AddressSockaddrPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint AddressSockaddrPropertyInfo = (~) (Ptr ())
    type AttrBaseTypeConstraint AddressSockaddrPropertyInfo = IsAddress
    type AttrGetType AddressSockaddrPropertyInfo = (Ptr ())
    type AttrLabel AddressSockaddrPropertyInfo = "sockaddr"
    type AttrOrigin AddressSockaddrPropertyInfo = Address
    attrGet _ = getAddressSockaddr
    attrSet _ = undefined
    attrConstruct _ = constructAddressSockaddr
    attrClear _ = undefined
#endif

#if ENABLE_OVERLOADING
instance O.HasAttributeList Address
type instance O.AttributeList Address = AddressAttributeList
type AddressAttributeList = ('[ '("family", AddressFamilyPropertyInfo), '("name", AddressNamePropertyInfo), '("physical", AddressPhysicalPropertyInfo), '("port", AddressPortPropertyInfo), '("protocol", AddressProtocolPropertyInfo), '("sockaddr", AddressSockaddrPropertyInfo)] :: [(Symbol, *)])
#endif

#if ENABLE_OVERLOADING
addressFamily :: AttrLabelProxy "family"
addressFamily = AttrLabelProxy

addressName :: AttrLabelProxy "name"
addressName = AttrLabelProxy

addressPhysical :: AttrLabelProxy "physical"
addressPhysical = AttrLabelProxy

addressPort :: AttrLabelProxy "port"
addressPort = AttrLabelProxy

addressProtocol :: AttrLabelProxy "protocol"
addressProtocol = AttrLabelProxy

addressSockaddr :: AttrLabelProxy "sockaddr"
addressSockaddr = AttrLabelProxy

#endif

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

#endif

-- method Address::new
-- method type : Constructor
-- Args : [Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a hostname or physical address", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "port", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a port number", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Soup", name = "Address"}))
-- throws : False
-- Skip return : False

foreign import ccall "soup_address_new" soup_address_new ::
    CString ->                              -- name : TBasicType TUTF8
    Word32 ->                               -- port : TBasicType TUInt
    IO (Ptr Address)

{- |
Creates a 'GI.Soup.Objects.Address.Address' from /@name@/ and /@port@/. The 'GI.Soup.Objects.Address.Address'\'s IP
address may not be available right away; the caller can call
'GI.Soup.Objects.Address.addressResolveAsync' or 'GI.Soup.Objects.Address.addressResolveSync' to
force a DNS resolution.
-}
addressNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@name@/: a hostname or physical address -}
    -> Word32
    {- ^ /@port@/: a port number -}
    -> m Address
    {- ^ __Returns:__ a 'GI.Soup.Objects.Address.Address' -}
addressNew name port = liftIO $ do
    name' <- textToCString name
    result <- soup_address_new name' port
    checkUnexpectedReturnNULL "addressNew" result
    result' <- (wrapObject Address) result
    freeMem name'
    return result'

#if ENABLE_OVERLOADING
#endif

-- method Address::new_any
-- method type : Constructor
-- Args : [Arg {argCName = "family", argType = TInterface (Name {namespace = "Soup", name = "AddressFamily"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the address family", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "port", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the port number (usually %SOUP_ADDRESS_ANY_PORT)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Soup", name = "Address"}))
-- throws : False
-- Skip return : False

foreign import ccall "soup_address_new_any" soup_address_new_any ::
    CInt ->                                 -- family : TInterface (Name {namespace = "Soup", name = "AddressFamily"})
    Word32 ->                               -- port : TBasicType TUInt
    IO (Ptr Address)

{- |
Returns a 'GI.Soup.Objects.Address.Address' corresponding to the \"any\" address
for /@family@/ (or 'Nothing' if /@family@/ isn\'t supported), suitable for
using as a listening 'GI.Soup.Objects.Socket.Socket'.
-}
addressNewAny ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Soup.Enums.AddressFamily
    {- ^ /@family@/: the address family -}
    -> Word32
    {- ^ /@port@/: the port number (usually 'GI.Soup.Constants.ADDRESS_ANY_PORT') -}
    -> m (Maybe Address)
    {- ^ __Returns:__ the new 'GI.Soup.Objects.Address.Address' -}
addressNewAny family port = liftIO $ do
    let family' = (fromIntegral . fromEnum) family
    result <- soup_address_new_any family' port
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapObject Address) result'
        return result''
    return maybeResult

#if ENABLE_OVERLOADING
#endif

-- method Address::new_from_sockaddr
-- method type : Constructor
-- Args : [Arg {argCName = "sa", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a pointer to a sockaddr", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "size of @sa", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Soup", name = "Address"}))
-- throws : False
-- Skip return : False

foreign import ccall "soup_address_new_from_sockaddr" soup_address_new_from_sockaddr ::
    Ptr () ->                               -- sa : TBasicType TPtr
    Int32 ->                                -- len : TBasicType TInt
    IO (Ptr Address)

{- |
Returns a 'GI.Soup.Objects.Address.Address' equivalent to /@sa@/ (or 'Nothing' if /@sa@/\'s
address family isn\'t supported)
-}
addressNewFromSockaddr ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Ptr ()
    {- ^ /@sa@/: a pointer to a sockaddr -}
    -> Int32
    {- ^ /@len@/: size of /@sa@/ -}
    -> m (Maybe Address)
    {- ^ __Returns:__ the new 'GI.Soup.Objects.Address.Address' -}
addressNewFromSockaddr sa len = liftIO $ do
    result <- soup_address_new_from_sockaddr sa len
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapObject Address) result'
        return result''
    return maybeResult

#if ENABLE_OVERLOADING
#endif

-- method Address::equal_by_ip
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "addr1", argType = TInterface (Name {namespace = "Soup", name = "Address"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupAddress with a resolved IP\n  address", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "addr2", argType = TInterface (Name {namespace = "Soup", name = "Address"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "another #SoupAddress with a resolved\n  IP address", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "soup_address_equal_by_ip" soup_address_equal_by_ip ::
    Ptr Address ->                          -- addr1 : TInterface (Name {namespace = "Soup", name = "Address"})
    Ptr Address ->                          -- addr2 : TInterface (Name {namespace = "Soup", name = "Address"})
    IO CInt

{- |
Tests if /@addr1@/ and /@addr2@/ have the same IP address. This method
can be used with 'GI.Soup.Objects.Address.addressHashByIp' to create a
'GI.GLib.Structs.HashTable.HashTable' that hashes on IP address.

This would be used to distinguish hosts in situations where
different virtual hosts on the same IP address should be considered
the same. Eg, if \"www.example.com\" and \"www.example.net\" have the
same IP address, then a single connection can be used to talk
to either of them.

See also 'GI.Soup.Objects.Address.addressEqualByName', which compares by name
rather than by IP address.

/Since: 2.26/
-}
addressEqualByIp ::
    (B.CallStack.HasCallStack, MonadIO m, IsAddress a, IsAddress b) =>
    a
    {- ^ /@addr1@/: a 'GI.Soup.Objects.Address.Address' with a resolved IP
  address -}
    -> b
    {- ^ /@addr2@/: another 'GI.Soup.Objects.Address.Address' with a resolved
  IP address -}
    -> m Bool
    {- ^ __Returns:__ whether or not /@addr1@/ and /@addr2@/ have the same IP
address. -}
addressEqualByIp addr1 addr2 = liftIO $ do
    addr1' <- unsafeManagedPtrCastPtr addr1
    addr2' <- unsafeManagedPtrCastPtr addr2
    result <- soup_address_equal_by_ip addr1' addr2'
    let result' = (/= 0) result
    touchManagedPtr addr1
    touchManagedPtr addr2
    return result'

#if ENABLE_OVERLOADING
data AddressEqualByIpMethodInfo
instance (signature ~ (b -> m Bool), MonadIO m, IsAddress a, IsAddress b) => O.MethodInfo AddressEqualByIpMethodInfo a signature where
    overloadedMethod _ = addressEqualByIp

#endif

-- method Address::equal_by_name
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "addr1", argType = TInterface (Name {namespace = "Soup", name = "Address"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupAddress with a resolved name", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "addr2", argType = TInterface (Name {namespace = "Soup", name = "Address"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "another #SoupAddress with a resolved\n  name", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "soup_address_equal_by_name" soup_address_equal_by_name ::
    Ptr Address ->                          -- addr1 : TInterface (Name {namespace = "Soup", name = "Address"})
    Ptr Address ->                          -- addr2 : TInterface (Name {namespace = "Soup", name = "Address"})
    IO CInt

{- |
Tests if /@addr1@/ and /@addr2@/ have the same \"name\". This method can be
used with 'GI.Soup.Objects.Address.addressHashByName' to create a 'GI.GLib.Structs.HashTable.HashTable' that
hashes on address \"names\".

Comparing by name normally means comparing the addresses by their
hostnames. But if the address was originally created using an IP
address literal, then it will be compared by that instead.

In particular, if \"www.example.com\" has the IP address 10.0.0.1,
and /@addr1@/ was created with the name \"www.example.com\" and /@addr2@/
was created with the name \"10.0.0.1\", then they will compare as
unequal for purposes of 'GI.Soup.Objects.Address.addressEqualByName'.

This would be used to distinguish hosts in situations where
different virtual hosts on the same IP address should be considered
different. Eg, for purposes of HTTP authentication or cookies, two
hosts with the same IP address but different names are considered
to be different hosts.

See also 'GI.Soup.Objects.Address.addressEqualByIp', which compares by IP address
rather than by name.

/Since: 2.26/
-}
addressEqualByName ::
    (B.CallStack.HasCallStack, MonadIO m, IsAddress a, IsAddress b) =>
    a
    {- ^ /@addr1@/: a 'GI.Soup.Objects.Address.Address' with a resolved name -}
    -> b
    {- ^ /@addr2@/: another 'GI.Soup.Objects.Address.Address' with a resolved
  name -}
    -> m Bool
    {- ^ __Returns:__ whether or not /@addr1@/ and /@addr2@/ have the same name -}
addressEqualByName addr1 addr2 = liftIO $ do
    addr1' <- unsafeManagedPtrCastPtr addr1
    addr2' <- unsafeManagedPtrCastPtr addr2
    result <- soup_address_equal_by_name addr1' addr2'
    let result' = (/= 0) result
    touchManagedPtr addr1
    touchManagedPtr addr2
    return result'

#if ENABLE_OVERLOADING
data AddressEqualByNameMethodInfo
instance (signature ~ (b -> m Bool), MonadIO m, IsAddress a, IsAddress b) => O.MethodInfo AddressEqualByNameMethodInfo a signature where
    overloadedMethod _ = addressEqualByName

#endif

-- method Address::get_gsockaddr
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "addr", argType = TInterface (Name {namespace = "Soup", name = "Address"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupAddress", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "SocketAddress"}))
-- throws : False
-- Skip return : False

foreign import ccall "soup_address_get_gsockaddr" soup_address_get_gsockaddr ::
    Ptr Address ->                          -- addr : TInterface (Name {namespace = "Soup", name = "Address"})
    IO (Ptr Gio.SocketAddress.SocketAddress)

{- |
Creates a new 'GI.Gio.Objects.SocketAddress.SocketAddress' corresponding to /@addr@/ (which is assumed
to only have one socket address associated with it).

/Since: 2.32/
-}
addressGetGsockaddr ::
    (B.CallStack.HasCallStack, MonadIO m, IsAddress a) =>
    a
    {- ^ /@addr@/: a 'GI.Soup.Objects.Address.Address' -}
    -> m Gio.SocketAddress.SocketAddress
    {- ^ __Returns:__ a new 'GI.Gio.Objects.SocketAddress.SocketAddress' -}
addressGetGsockaddr addr = liftIO $ do
    addr' <- unsafeManagedPtrCastPtr addr
    result <- soup_address_get_gsockaddr addr'
    checkUnexpectedReturnNULL "addressGetGsockaddr" result
    result' <- (wrapObject Gio.SocketAddress.SocketAddress) result
    touchManagedPtr addr
    return result'

#if ENABLE_OVERLOADING
data AddressGetGsockaddrMethodInfo
instance (signature ~ (m Gio.SocketAddress.SocketAddress), MonadIO m, IsAddress a) => O.MethodInfo AddressGetGsockaddrMethodInfo a signature where
    overloadedMethod _ = addressGetGsockaddr

#endif

-- method Address::get_name
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "addr", argType = TInterface (Name {namespace = "Soup", name = "Address"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupAddress", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "soup_address_get_name" soup_address_get_name ::
    Ptr Address ->                          -- addr : TInterface (Name {namespace = "Soup", name = "Address"})
    IO CString

{- |
Returns the hostname associated with /@addr@/.

This method is not thread-safe; if you call it while /@addr@/ is being
resolved in another thread, it may return garbage. You can use
'GI.Soup.Objects.Address.addressIsResolved' to safely test whether or not an address
is resolved before fetching its name or address.
-}
addressGetName ::
    (B.CallStack.HasCallStack, MonadIO m, IsAddress a) =>
    a
    {- ^ /@addr@/: a 'GI.Soup.Objects.Address.Address' -}
    -> m (Maybe T.Text)
    {- ^ __Returns:__ the hostname, or 'Nothing' if it is not known. -}
addressGetName addr = liftIO $ do
    addr' <- unsafeManagedPtrCastPtr addr
    result <- soup_address_get_name addr'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- cstringToText result'
        return result''
    touchManagedPtr addr
    return maybeResult

#if ENABLE_OVERLOADING
data AddressGetNameMethodInfo
instance (signature ~ (m (Maybe T.Text)), MonadIO m, IsAddress a) => O.MethodInfo AddressGetNameMethodInfo a signature where
    overloadedMethod _ = addressGetName

#endif

-- method Address::get_physical
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "addr", argType = TInterface (Name {namespace = "Soup", name = "Address"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupAddress", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "soup_address_get_physical" soup_address_get_physical ::
    Ptr Address ->                          -- addr : TInterface (Name {namespace = "Soup", name = "Address"})
    IO CString

{- |
Returns the physical address associated with /@addr@/ as a string.
(Eg, \"127.0.0.1\"). If the address is not yet known, returns 'Nothing'.

This method is not thread-safe; if you call it while /@addr@/ is being
resolved in another thread, it may return garbage. You can use
'GI.Soup.Objects.Address.addressIsResolved' to safely test whether or not an address
is resolved before fetching its name or address.
-}
addressGetPhysical ::
    (B.CallStack.HasCallStack, MonadIO m, IsAddress a) =>
    a
    {- ^ /@addr@/: a 'GI.Soup.Objects.Address.Address' -}
    -> m (Maybe T.Text)
    {- ^ __Returns:__ the physical address, or 'Nothing' -}
addressGetPhysical addr = liftIO $ do
    addr' <- unsafeManagedPtrCastPtr addr
    result <- soup_address_get_physical addr'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- cstringToText result'
        return result''
    touchManagedPtr addr
    return maybeResult

#if ENABLE_OVERLOADING
data AddressGetPhysicalMethodInfo
instance (signature ~ (m (Maybe T.Text)), MonadIO m, IsAddress a) => O.MethodInfo AddressGetPhysicalMethodInfo a signature where
    overloadedMethod _ = addressGetPhysical

#endif

-- method Address::get_port
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "addr", argType = TInterface (Name {namespace = "Soup", name = "Address"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupAddress", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "soup_address_get_port" soup_address_get_port ::
    Ptr Address ->                          -- addr : TInterface (Name {namespace = "Soup", name = "Address"})
    IO Word32

{- |
Returns the port associated with /@addr@/.
-}
addressGetPort ::
    (B.CallStack.HasCallStack, MonadIO m, IsAddress a) =>
    a
    {- ^ /@addr@/: a 'GI.Soup.Objects.Address.Address' -}
    -> m Word32
    {- ^ __Returns:__ the port -}
addressGetPort addr = liftIO $ do
    addr' <- unsafeManagedPtrCastPtr addr
    result <- soup_address_get_port addr'
    touchManagedPtr addr
    return result

#if ENABLE_OVERLOADING
data AddressGetPortMethodInfo
instance (signature ~ (m Word32), MonadIO m, IsAddress a) => O.MethodInfo AddressGetPortMethodInfo a signature where
    overloadedMethod _ = addressGetPort

#endif

-- method Address::hash_by_ip
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "addr", argType = TInterface (Name {namespace = "Soup", name = "Address"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupAddress", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "soup_address_hash_by_ip" soup_address_hash_by_ip ::
    Ptr Address ->                          -- addr : TInterface (Name {namespace = "Soup", name = "Address"})
    IO Word32

{- |
A hash function (for 'GI.GLib.Structs.HashTable.HashTable') that corresponds to
'GI.Soup.Objects.Address.addressEqualByIp', qv

/Since: 2.26/
-}
addressHashByIp ::
    (B.CallStack.HasCallStack, MonadIO m, IsAddress a) =>
    a
    {- ^ /@addr@/: a 'GI.Soup.Objects.Address.Address' -}
    -> m Word32
    {- ^ __Returns:__ the IP-based hash value for /@addr@/. -}
addressHashByIp addr = liftIO $ do
    addr' <- unsafeManagedPtrCastPtr addr
    result <- soup_address_hash_by_ip addr'
    touchManagedPtr addr
    return result

#if ENABLE_OVERLOADING
data AddressHashByIpMethodInfo
instance (signature ~ (m Word32), MonadIO m, IsAddress a) => O.MethodInfo AddressHashByIpMethodInfo a signature where
    overloadedMethod _ = addressHashByIp

#endif

-- method Address::hash_by_name
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "addr", argType = TInterface (Name {namespace = "Soup", name = "Address"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupAddress", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "soup_address_hash_by_name" soup_address_hash_by_name ::
    Ptr Address ->                          -- addr : TInterface (Name {namespace = "Soup", name = "Address"})
    IO Word32

{- |
A hash function (for 'GI.GLib.Structs.HashTable.HashTable') that corresponds to
'GI.Soup.Objects.Address.addressEqualByName', qv

/Since: 2.26/
-}
addressHashByName ::
    (B.CallStack.HasCallStack, MonadIO m, IsAddress a) =>
    a
    {- ^ /@addr@/: a 'GI.Soup.Objects.Address.Address' -}
    -> m Word32
    {- ^ __Returns:__ the named-based hash value for /@addr@/. -}
addressHashByName addr = liftIO $ do
    addr' <- unsafeManagedPtrCastPtr addr
    result <- soup_address_hash_by_name addr'
    touchManagedPtr addr
    return result

#if ENABLE_OVERLOADING
data AddressHashByNameMethodInfo
instance (signature ~ (m Word32), MonadIO m, IsAddress a) => O.MethodInfo AddressHashByNameMethodInfo a signature where
    overloadedMethod _ = addressHashByName

#endif

-- method Address::is_resolved
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "addr", argType = TInterface (Name {namespace = "Soup", name = "Address"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupAddress", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "soup_address_is_resolved" soup_address_is_resolved ::
    Ptr Address ->                          -- addr : TInterface (Name {namespace = "Soup", name = "Address"})
    IO CInt

{- |
Tests if /@addr@/ has already been resolved. Unlike the other
'GI.Soup.Objects.Address.Address' \"get\" methods, this is safe to call when /@addr@/ might
be being resolved in another thread.
-}
addressIsResolved ::
    (B.CallStack.HasCallStack, MonadIO m, IsAddress a) =>
    a
    {- ^ /@addr@/: a 'GI.Soup.Objects.Address.Address' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@addr@/ has been resolved. -}
addressIsResolved addr = liftIO $ do
    addr' <- unsafeManagedPtrCastPtr addr
    result <- soup_address_is_resolved addr'
    let result' = (/= 0) result
    touchManagedPtr addr
    return result'

#if ENABLE_OVERLOADING
data AddressIsResolvedMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsAddress a) => O.MethodInfo AddressIsResolvedMethodInfo a signature where
    overloadedMethod _ = addressIsResolved

#endif

-- method Address::resolve_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "addr", argType = TInterface (Name {namespace = "Soup", name = "Address"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupAddress", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "async_context", argType = TInterface (Name {namespace = "GLib", name = "MainContext"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the #GMainContext to call @callback from", 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 object, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Soup", name = "AddressCallback"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "callback to call with the result", 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 "soup_address_resolve_async" soup_address_resolve_async ::
    Ptr Address ->                          -- addr : TInterface (Name {namespace = "Soup", name = "Address"})
    Ptr GLib.MainContext.MainContext ->     -- async_context : TInterface (Name {namespace = "GLib", name = "MainContext"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Soup.Callbacks.C_AddressCallback -> -- callback : TInterface (Name {namespace = "Soup", name = "AddressCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Asynchronously resolves the missing half of /@addr@/ (its IP address
if it was created with 'GI.Soup.Objects.Address.addressNew', or its hostname if it
was created with 'GI.Soup.Objects.Address.addressNewFromSockaddr' or
'GI.Soup.Objects.Address.addressNewAny'.)

If /@cancellable@/ is non-'Nothing', it can be used to cancel the
resolution. /@callback@/ will still be invoked in this case, with a
status of 'GI.Soup.Enums.StatusCancelled'.

It is safe to call this more than once on a given address, from the
same thread, with the same /@asyncContext@/ (and doing so will not
result in redundant DNS queries being made). But it is not safe to
call from multiple threads, or with different /@asyncContexts@/, or
mixed with calls to 'GI.Soup.Objects.Address.addressResolveSync'.
-}
addressResolveAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsAddress a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@addr@/: a 'GI.Soup.Objects.Address.Address' -}
    -> Maybe (GLib.MainContext.MainContext)
    {- ^ /@asyncContext@/: the 'GI.GLib.Structs.MainContext.MainContext' to call /@callback@/ from -}
    -> Maybe (b)
    {- ^ /@cancellable@/: a 'GI.Gio.Objects.Cancellable.Cancellable' object, or 'Nothing' -}
    -> Soup.Callbacks.AddressCallback
    {- ^ /@callback@/: callback to call with the result -}
    -> m ()
addressResolveAsync addr asyncContext cancellable callback = liftIO $ do
    addr' <- unsafeManagedPtrCastPtr addr
    maybeAsyncContext <- case asyncContext of
        Nothing -> return nullPtr
        Just jAsyncContext -> do
            jAsyncContext' <- unsafeManagedPtrGetPtr jAsyncContext
            return jAsyncContext'
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Soup.Callbacks.C_AddressCallback))
    callback' <- Soup.Callbacks.mk_AddressCallback (Soup.Callbacks.wrap_AddressCallback (Just ptrcallback) (Soup.Callbacks.drop_closures_AddressCallback callback))
    poke ptrcallback callback'
    let userData = nullPtr
    soup_address_resolve_async addr' maybeAsyncContext maybeCancellable callback' userData
    touchManagedPtr addr
    whenJust asyncContext touchManagedPtr
    whenJust cancellable touchManagedPtr
    return ()

#if ENABLE_OVERLOADING
data AddressResolveAsyncMethodInfo
instance (signature ~ (Maybe (GLib.MainContext.MainContext) -> Maybe (b) -> Soup.Callbacks.AddressCallback -> m ()), MonadIO m, IsAddress a, Gio.Cancellable.IsCancellable b) => O.MethodInfo AddressResolveAsyncMethodInfo a signature where
    overloadedMethod _ = addressResolveAsync

#endif

-- method Address::resolve_sync
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "addr", argType = TInterface (Name {namespace = "Soup", name = "Address"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupAddress", 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 object, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "soup_address_resolve_sync" soup_address_resolve_sync ::
    Ptr Address ->                          -- addr : TInterface (Name {namespace = "Soup", name = "Address"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    IO Word32

{- |
Synchronously resolves the missing half of /@addr@/, as with
'GI.Soup.Objects.Address.addressResolveAsync'.

If /@cancellable@/ is non-'Nothing', it can be used to cancel the
resolution. 'GI.Soup.Objects.Address.addressResolveSync' will then return a status
of 'GI.Soup.Enums.StatusCancelled'.

It is safe to call this more than once, even from different
threads, but it is not safe to mix calls to
'GI.Soup.Objects.Address.addressResolveSync' with calls to
'GI.Soup.Objects.Address.addressResolveAsync' on the same address.
-}
addressResolveSync ::
    (B.CallStack.HasCallStack, MonadIO m, IsAddress a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@addr@/: a 'GI.Soup.Objects.Address.Address' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: a 'GI.Gio.Objects.Cancellable.Cancellable' object, or 'Nothing' -}
    -> m Word32
    {- ^ __Returns:__ 'GI.Soup.Enums.StatusOk', 'GI.Soup.Enums.StatusCantResolve', or
'GI.Soup.Enums.StatusCancelled'. -}
addressResolveSync addr cancellable = liftIO $ do
    addr' <- unsafeManagedPtrCastPtr addr
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    result <- soup_address_resolve_sync addr' maybeCancellable
    touchManagedPtr addr
    whenJust cancellable touchManagedPtr
    return result

#if ENABLE_OVERLOADING
data AddressResolveSyncMethodInfo
instance (signature ~ (Maybe (b) -> m Word32), MonadIO m, IsAddress a, Gio.Cancellable.IsCancellable b) => O.MethodInfo AddressResolveSyncMethodInfo a signature where
    overloadedMethod _ = addressResolveSync

#endif