{-# LANGUAGE TypeApplications #-}


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

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

module GI.Soup.Objects.Address
    ( 

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


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

#if defined(ENABLE_OVERLOADING)
    ResolveAddressMethod                    ,
#endif


-- ** equalByIp #method:equalByIp#

#if defined(ENABLE_OVERLOADING)
    AddressEqualByIpMethodInfo              ,
#endif
    addressEqualByIp                        ,


-- ** equalByName #method:equalByName#

#if defined(ENABLE_OVERLOADING)
    AddressEqualByNameMethodInfo            ,
#endif
    addressEqualByName                      ,


-- ** getGsockaddr #method:getGsockaddr#

#if defined(ENABLE_OVERLOADING)
    AddressGetGsockaddrMethodInfo           ,
#endif
    addressGetGsockaddr                     ,


-- ** getName #method:getName#

#if defined(ENABLE_OVERLOADING)
    AddressGetNameMethodInfo                ,
#endif
    addressGetName                          ,


-- ** getPhysical #method:getPhysical#

#if defined(ENABLE_OVERLOADING)
    AddressGetPhysicalMethodInfo            ,
#endif
    addressGetPhysical                      ,


-- ** getPort #method:getPort#

#if defined(ENABLE_OVERLOADING)
    AddressGetPortMethodInfo                ,
#endif
    addressGetPort                          ,


-- ** hashByIp #method:hashByIp#

#if defined(ENABLE_OVERLOADING)
    AddressHashByIpMethodInfo               ,
#endif
    addressHashByIp                         ,


-- ** hashByName #method:hashByName#

#if defined(ENABLE_OVERLOADING)
    AddressHashByNameMethodInfo             ,
#endif
    addressHashByName                       ,


-- ** isResolved #method:isResolved#

#if defined(ENABLE_OVERLOADING)
    AddressIsResolvedMethodInfo             ,
#endif
    addressIsResolved                       ,


-- ** new #method:new#

    addressNew                              ,


-- ** newAny #method:newAny#

    addressNewAny                           ,


-- ** newFromSockaddr #method:newFromSockaddr#

    addressNewFromSockaddr                  ,


-- ** resolveAsync #method:resolveAsync#

#if defined(ENABLE_OVERLOADING)
    AddressResolveAsyncMethodInfo           ,
#endif
    addressResolveAsync                     ,


-- ** resolveSync #method:resolveSync#

#if defined(ENABLE_OVERLOADING)
    AddressResolveSyncMethodInfo            ,
#endif
    addressResolveSync                      ,




 -- * Properties
-- ** family #attr:family#
-- | /No description available in the introspection data./

#if defined(ENABLE_OVERLOADING)
    AddressFamilyPropertyInfo               ,
#endif
#if defined(ENABLE_OVERLOADING)
    addressFamily                           ,
#endif
    constructAddressFamily                  ,
    getAddressFamily                        ,


-- ** name #attr:name#
-- | /No description available in the introspection data./

#if defined(ENABLE_OVERLOADING)
    AddressNamePropertyInfo                 ,
#endif
#if defined(ENABLE_OVERLOADING)
    addressName                             ,
#endif
    constructAddressName                    ,
    getAddressName                          ,


-- ** physical #attr:physical#
-- | /No description available in the introspection data./

#if defined(ENABLE_OVERLOADING)
    AddressPhysicalPropertyInfo             ,
#endif
#if defined(ENABLE_OVERLOADING)
    addressPhysical                         ,
#endif
    getAddressPhysical                      ,


-- ** port #attr:port#
-- | /No description available in the introspection data./

#if defined(ENABLE_OVERLOADING)
    AddressPortPropertyInfo                 ,
#endif
#if defined(ENABLE_OVERLOADING)
    addressPort                             ,
#endif
    constructAddressPort                    ,
    getAddressPort                          ,


-- ** protocol #attr:protocol#
-- | /No description available in the introspection data./

#if defined(ENABLE_OVERLOADING)
    AddressProtocolPropertyInfo             ,
#endif
#if defined(ENABLE_OVERLOADING)
    addressProtocol                         ,
#endif
    constructAddressProtocol                ,
    getAddressProtocol                      ,


-- ** sockaddr #attr:sockaddr#
-- | /No description available in the introspection data./

#if defined(ENABLE_OVERLOADING)
    AddressSockaddrPropertyInfo             ,
#endif
#if defined(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.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL

import qualified GI.GLib.Structs.MainContext as GLib.MainContext
import qualified GI.GObject.Objects.Object as GObject.Object
import 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 (SP.ManagedPtr Address)
    deriving (Address -> Address -> Bool
(Address -> Address -> Bool)
-> (Address -> Address -> Bool) -> Eq Address
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Address -> Address -> Bool
$c/= :: Address -> Address -> Bool
== :: Address -> Address -> Bool
$c== :: Address -> Address -> Bool
Eq)

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

foreign import ccall "soup_address_get_type"
    c_soup_address_get_type :: IO B.Types.GType

instance B.Types.TypedObject Address where
    glibType :: IO GType
glibType = IO GType
c_soup_address_get_type

instance B.Types.GObject Address

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

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

#if defined(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 "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    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 @info
#else
    fromLabel _ = O.overloadedMethod @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 :: o -> m AddressFamily
getAddressFamily o
obj = IO AddressFamily -> m AddressFamily
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO AddressFamily -> m AddressFamily)
-> IO AddressFamily -> m AddressFamily
forall a b. (a -> b) -> a -> b
$ o -> String -> IO AddressFamily
forall a b. (GObject a, Enum b, BoxedEnum b) => a -> String -> IO b
B.Properties.getObjectPropertyEnum o
obj String
"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, MIO.MonadIO m) => Soup.Enums.AddressFamily -> m (GValueConstruct o)
constructAddressFamily :: AddressFamily -> m (GValueConstruct o)
constructAddressFamily AddressFamily
val = IO (GValueConstruct o) -> m (GValueConstruct o)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (GValueConstruct o) -> m (GValueConstruct o))
-> IO (GValueConstruct o) -> m (GValueConstruct o)
forall a b. (a -> b) -> a -> b
$ String -> AddressFamily -> IO (GValueConstruct o)
forall a o.
(Enum a, BoxedEnum a) =>
String -> a -> IO (GValueConstruct o)
B.Properties.constructObjectPropertyEnum String
"family" AddressFamily
val

#if defined(ENABLE_OVERLOADING)
data AddressFamilyPropertyInfo
instance AttrInfo AddressFamilyPropertyInfo where
    type AttrAllowedOps AddressFamilyPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrBaseTypeConstraint AddressFamilyPropertyInfo = IsAddress
    type AttrSetTypeConstraint AddressFamilyPropertyInfo = (~) Soup.Enums.AddressFamily
    type AttrTransferTypeConstraint AddressFamilyPropertyInfo = (~) Soup.Enums.AddressFamily
    type AttrTransferType AddressFamilyPropertyInfo = Soup.Enums.AddressFamily
    type AttrGetType AddressFamilyPropertyInfo = Soup.Enums.AddressFamily
    type AttrLabel AddressFamilyPropertyInfo = "family"
    type AttrOrigin AddressFamilyPropertyInfo = Address
    attrGet = getAddressFamily
    attrSet = undefined
    attrTransfer _ v = do
        return v
    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 :: o -> m (Maybe Text)
getAddressName o
obj = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ o -> String -> IO (Maybe Text)
forall a. GObject a => a -> String -> IO (Maybe Text)
B.Properties.getObjectPropertyString o
obj String
"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, MIO.MonadIO m) => T.Text -> m (GValueConstruct o)
constructAddressName :: Text -> m (GValueConstruct o)
constructAddressName Text
val = IO (GValueConstruct o) -> m (GValueConstruct o)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (GValueConstruct o) -> m (GValueConstruct o))
-> IO (GValueConstruct o) -> m (GValueConstruct o)
forall a b. (a -> b) -> a -> b
$ String -> Maybe Text -> IO (GValueConstruct o)
forall o. String -> Maybe Text -> IO (GValueConstruct o)
B.Properties.constructObjectPropertyString String
"name" (Text -> Maybe Text
forall a. a -> Maybe a
P.Just Text
val)

#if defined(ENABLE_OVERLOADING)
data AddressNamePropertyInfo
instance AttrInfo AddressNamePropertyInfo where
    type AttrAllowedOps AddressNamePropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrBaseTypeConstraint AddressNamePropertyInfo = IsAddress
    type AttrSetTypeConstraint AddressNamePropertyInfo = (~) T.Text
    type AttrTransferTypeConstraint AddressNamePropertyInfo = (~) T.Text
    type AttrTransferType AddressNamePropertyInfo = T.Text
    type AttrGetType AddressNamePropertyInfo = (Maybe T.Text)
    type AttrLabel AddressNamePropertyInfo = "name"
    type AttrOrigin AddressNamePropertyInfo = Address
    attrGet = getAddressName
    attrSet = undefined
    attrTransfer _ v = do
        return v
    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 :: o -> m (Maybe Text)
getAddressPhysical o
obj = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ o -> String -> IO (Maybe Text)
forall a. GObject a => a -> String -> IO (Maybe Text)
B.Properties.getObjectPropertyString o
obj String
"physical"

#if defined(ENABLE_OVERLOADING)
data AddressPhysicalPropertyInfo
instance AttrInfo AddressPhysicalPropertyInfo where
    type AttrAllowedOps AddressPhysicalPropertyInfo = '[ 'AttrGet, 'AttrClear]
    type AttrBaseTypeConstraint AddressPhysicalPropertyInfo = IsAddress
    type AttrSetTypeConstraint AddressPhysicalPropertyInfo = (~) ()
    type AttrTransferTypeConstraint AddressPhysicalPropertyInfo = (~) ()
    type AttrTransferType AddressPhysicalPropertyInfo = ()
    type AttrGetType AddressPhysicalPropertyInfo = (Maybe T.Text)
    type AttrLabel AddressPhysicalPropertyInfo = "physical"
    type AttrOrigin AddressPhysicalPropertyInfo = Address
    attrGet = getAddressPhysical
    attrSet = undefined
    attrTransfer _ = 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 :: o -> m Int32
getAddressPort o
obj = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ o -> String -> IO Int32
forall a. GObject a => a -> String -> IO Int32
B.Properties.getObjectPropertyInt32 o
obj String
"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, MIO.MonadIO m) => Int32 -> m (GValueConstruct o)
constructAddressPort :: Int32 -> m (GValueConstruct o)
constructAddressPort Int32
val = IO (GValueConstruct o) -> m (GValueConstruct o)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (GValueConstruct o) -> m (GValueConstruct o))
-> IO (GValueConstruct o) -> m (GValueConstruct o)
forall a b. (a -> b) -> a -> b
$ String -> Int32 -> IO (GValueConstruct o)
forall o. String -> Int32 -> IO (GValueConstruct o)
B.Properties.constructObjectPropertyInt32 String
"port" Int32
val

#if defined(ENABLE_OVERLOADING)
data AddressPortPropertyInfo
instance AttrInfo AddressPortPropertyInfo where
    type AttrAllowedOps AddressPortPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrBaseTypeConstraint AddressPortPropertyInfo = IsAddress
    type AttrSetTypeConstraint AddressPortPropertyInfo = (~) Int32
    type AttrTransferTypeConstraint AddressPortPropertyInfo = (~) Int32
    type AttrTransferType AddressPortPropertyInfo = Int32
    type AttrGetType AddressPortPropertyInfo = Int32
    type AttrLabel AddressPortPropertyInfo = "port"
    type AttrOrigin AddressPortPropertyInfo = Address
    attrGet = getAddressPort
    attrSet = undefined
    attrTransfer _ v = do
        return v
    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 :: o -> m (Maybe Text)
getAddressProtocol o
obj = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ o -> String -> IO (Maybe Text)
forall a. GObject a => a -> String -> IO (Maybe Text)
B.Properties.getObjectPropertyString o
obj String
"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, MIO.MonadIO m) => T.Text -> m (GValueConstruct o)
constructAddressProtocol :: Text -> m (GValueConstruct o)
constructAddressProtocol Text
val = IO (GValueConstruct o) -> m (GValueConstruct o)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (GValueConstruct o) -> m (GValueConstruct o))
-> IO (GValueConstruct o) -> m (GValueConstruct o)
forall a b. (a -> b) -> a -> b
$ String -> Maybe Text -> IO (GValueConstruct o)
forall o. String -> Maybe Text -> IO (GValueConstruct o)
B.Properties.constructObjectPropertyString String
"protocol" (Text -> Maybe Text
forall a. a -> Maybe a
P.Just Text
val)

#if defined(ENABLE_OVERLOADING)
data AddressProtocolPropertyInfo
instance AttrInfo AddressProtocolPropertyInfo where
    type AttrAllowedOps AddressProtocolPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrBaseTypeConstraint AddressProtocolPropertyInfo = IsAddress
    type AttrSetTypeConstraint AddressProtocolPropertyInfo = (~) T.Text
    type AttrTransferTypeConstraint AddressProtocolPropertyInfo = (~) T.Text
    type AttrTransferType AddressProtocolPropertyInfo = T.Text
    type AttrGetType AddressProtocolPropertyInfo = (Maybe T.Text)
    type AttrLabel AddressProtocolPropertyInfo = "protocol"
    type AttrOrigin AddressProtocolPropertyInfo = Address
    attrGet = getAddressProtocol
    attrSet = undefined
    attrTransfer _ v = do
        return v
    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 :: o -> m (Ptr ())
getAddressSockaddr o
obj = IO (Ptr ()) -> m (Ptr ())
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
forall a b. (a -> b) -> a -> b
$ o -> String -> IO (Ptr ())
forall a b. GObject a => a -> String -> IO (Ptr b)
B.Properties.getObjectPropertyPtr o
obj String
"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, MIO.MonadIO m) => Ptr () -> m (GValueConstruct o)
constructAddressSockaddr :: Ptr () -> m (GValueConstruct o)
constructAddressSockaddr Ptr ()
val = IO (GValueConstruct o) -> m (GValueConstruct o)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (GValueConstruct o) -> m (GValueConstruct o))
-> IO (GValueConstruct o) -> m (GValueConstruct o)
forall a b. (a -> b) -> a -> b
$ String -> Ptr () -> IO (GValueConstruct o)
forall b o. String -> Ptr b -> IO (GValueConstruct o)
B.Properties.constructObjectPropertyPtr String
"sockaddr" Ptr ()
val

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

#if defined(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 defined(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 defined(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 t'GI.Soup.Objects.Address.Address' from /@name@/ and /@port@/. The t'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 t'GI.Soup.Objects.Address.Address'
addressNew :: Text -> Word32 -> m Address
addressNew Text
name Word32
port = IO Address -> m Address
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Address -> m Address) -> IO Address -> m Address
forall a b. (a -> b) -> a -> b
$ do
    CString
name' <- Text -> IO CString
textToCString Text
name
    Ptr Address
result <- CString -> Word32 -> IO (Ptr Address)
soup_address_new CString
name' Word32
port
    Text -> Ptr Address -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"addressNew" Ptr Address
result
    Address
result' <- ((ManagedPtr Address -> Address) -> Ptr Address -> IO Address
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Address -> Address
Address) Ptr Address
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
name'
    Address -> IO Address
forall (m :: * -> *) a. Monad m => a -> m a
return Address
result'

#if defined(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 t'GI.Soup.Objects.Address.Address' corresponding to the \"any\" address
-- for /@family@/ (or 'P.Nothing' if /@family@/ isn\'t supported), suitable for
-- using as a listening t'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 t'GI.Soup.Objects.Address.Address'
addressNewAny :: AddressFamily -> Word32 -> m (Maybe Address)
addressNewAny AddressFamily
family Word32
port = IO (Maybe Address) -> m (Maybe Address)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Address) -> m (Maybe Address))
-> IO (Maybe Address) -> m (Maybe Address)
forall a b. (a -> b) -> a -> b
$ do
    let family' :: CInt
family' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (AddressFamily -> Int) -> AddressFamily -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AddressFamily -> Int
forall a. Enum a => a -> Int
fromEnum) AddressFamily
family
    Ptr Address
result <- CInt -> Word32 -> IO (Ptr Address)
soup_address_new_any CInt
family' Word32
port
    Maybe Address
maybeResult <- Ptr Address -> (Ptr Address -> IO Address) -> IO (Maybe Address)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Address
result ((Ptr Address -> IO Address) -> IO (Maybe Address))
-> (Ptr Address -> IO Address) -> IO (Maybe Address)
forall a b. (a -> b) -> a -> b
$ \Ptr Address
result' -> do
        Address
result'' <- ((ManagedPtr Address -> Address) -> Ptr Address -> IO Address
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Address -> Address
Address) Ptr Address
result'
        Address -> IO Address
forall (m :: * -> *) a. Monad m => a -> m a
return Address
result''
    Maybe Address -> IO (Maybe Address)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Address
maybeResult

#if defined(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 t'GI.Soup.Objects.Address.Address' equivalent to /@sa@/ (or 'P.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 t'GI.Soup.Objects.Address.Address'
addressNewFromSockaddr :: Ptr () -> Int32 -> m (Maybe Address)
addressNewFromSockaddr Ptr ()
sa Int32
len = IO (Maybe Address) -> m (Maybe Address)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Address) -> m (Maybe Address))
-> IO (Maybe Address) -> m (Maybe Address)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Address
result <- Ptr () -> Int32 -> IO (Ptr Address)
soup_address_new_from_sockaddr Ptr ()
sa Int32
len
    Maybe Address
maybeResult <- Ptr Address -> (Ptr Address -> IO Address) -> IO (Maybe Address)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Address
result ((Ptr Address -> IO Address) -> IO (Maybe Address))
-> (Ptr Address -> IO Address) -> IO (Maybe Address)
forall a b. (a -> b) -> a -> b
$ \Ptr Address
result' -> do
        Address
result'' <- ((ManagedPtr Address -> Address) -> Ptr Address -> IO Address
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Address -> Address
Address) Ptr Address
result'
        Address -> IO Address
forall (m :: * -> *) a. Monad m => a -> m a
return Address
result''
    Maybe Address -> IO (Maybe Address)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Address
maybeResult

#if defined(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
-- t'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 t'GI.Soup.Objects.Address.Address' with a resolved IP
    --   address
    -> b
    -- ^ /@addr2@/: another t'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 :: a -> b -> m Bool
addressEqualByIp a
addr1 b
addr2 = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Address
addr1' <- a -> IO (Ptr Address)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
addr1
    Ptr Address
addr2' <- b -> IO (Ptr Address)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
addr2
    CInt
result <- Ptr Address -> Ptr Address -> IO CInt
soup_address_equal_by_ip Ptr Address
addr1' Ptr Address
addr2'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
addr1
    b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
addr2
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(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 t'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 t'GI.Soup.Objects.Address.Address' with a resolved name
    -> b
    -- ^ /@addr2@/: another t'GI.Soup.Objects.Address.Address' with a resolved
    --   name
    -> m Bool
    -- ^ __Returns:__ whether or not /@addr1@/ and /@addr2@/ have the same name
addressEqualByName :: a -> b -> m Bool
addressEqualByName a
addr1 b
addr2 = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Address
addr1' <- a -> IO (Ptr Address)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
addr1
    Ptr Address
addr2' <- b -> IO (Ptr Address)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
addr2
    CInt
result <- Ptr Address -> Ptr Address -> IO CInt
soup_address_equal_by_name Ptr Address
addr1' Ptr Address
addr2'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
addr1
    b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
addr2
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(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 t'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 t'GI.Soup.Objects.Address.Address'
    -> m Gio.SocketAddress.SocketAddress
    -- ^ __Returns:__ a new t'GI.Gio.Objects.SocketAddress.SocketAddress'
addressGetGsockaddr :: a -> m SocketAddress
addressGetGsockaddr a
addr = IO SocketAddress -> m SocketAddress
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SocketAddress -> m SocketAddress)
-> IO SocketAddress -> m SocketAddress
forall a b. (a -> b) -> a -> b
$ do
    Ptr Address
addr' <- a -> IO (Ptr Address)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
addr
    Ptr SocketAddress
result <- Ptr Address -> IO (Ptr SocketAddress)
soup_address_get_gsockaddr Ptr Address
addr'
    Text -> Ptr SocketAddress -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"addressGetGsockaddr" Ptr SocketAddress
result
    SocketAddress
result' <- ((ManagedPtr SocketAddress -> SocketAddress)
-> Ptr SocketAddress -> IO SocketAddress
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr SocketAddress -> SocketAddress
Gio.SocketAddress.SocketAddress) Ptr SocketAddress
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
addr
    SocketAddress -> IO SocketAddress
forall (m :: * -> *) a. Monad m => a -> m a
return SocketAddress
result'

#if defined(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 t'GI.Soup.Objects.Address.Address'
    -> m (Maybe T.Text)
    -- ^ __Returns:__ the hostname, or 'P.Nothing' if it is not known.
addressGetName :: a -> m (Maybe Text)
addressGetName a
addr = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Address
addr' <- a -> IO (Ptr Address)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
addr
    CString
result <- Ptr Address -> IO CString
soup_address_get_name Ptr Address
addr'
    Maybe Text
maybeResult <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
result ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \CString
result' -> do
        Text
result'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result'
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result''
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
addr
    Maybe Text -> IO (Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
maybeResult

#if defined(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 'P.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 t'GI.Soup.Objects.Address.Address'
    -> m (Maybe T.Text)
    -- ^ __Returns:__ the physical address, or 'P.Nothing'
addressGetPhysical :: a -> m (Maybe Text)
addressGetPhysical a
addr = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Address
addr' <- a -> IO (Ptr Address)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
addr
    CString
result <- Ptr Address -> IO CString
soup_address_get_physical Ptr Address
addr'
    Maybe Text
maybeResult <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
result ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \CString
result' -> do
        Text
result'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result'
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result''
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
addr
    Maybe Text -> IO (Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
maybeResult

#if defined(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 t'GI.Soup.Objects.Address.Address'
    -> m Word32
    -- ^ __Returns:__ the port
addressGetPort :: a -> m Word32
addressGetPort a
addr = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Ptr Address
addr' <- a -> IO (Ptr Address)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
addr
    Word32
result <- Ptr Address -> IO Word32
soup_address_get_port Ptr Address
addr'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
addr
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result

#if defined(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 t'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 t'GI.Soup.Objects.Address.Address'
    -> m Word32
    -- ^ __Returns:__ the IP-based hash value for /@addr@/.
addressHashByIp :: a -> m Word32
addressHashByIp a
addr = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Ptr Address
addr' <- a -> IO (Ptr Address)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
addr
    Word32
result <- Ptr Address -> IO Word32
soup_address_hash_by_ip Ptr Address
addr'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
addr
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result

#if defined(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 t'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 t'GI.Soup.Objects.Address.Address'
    -> m Word32
    -- ^ __Returns:__ the named-based hash value for /@addr@/.
addressHashByName :: a -> m Word32
addressHashByName a
addr = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Ptr Address
addr' <- a -> IO (Ptr Address)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
addr
    Word32
result <- Ptr Address -> IO Word32
soup_address_hash_by_name Ptr Address
addr'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
addr
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result

#if defined(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
-- t'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 t'GI.Soup.Objects.Address.Address'
    -> m Bool
    -- ^ __Returns:__ 'P.True' if /@addr@/ has been resolved.
addressIsResolved :: a -> m Bool
addressIsResolved a
addr = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Address
addr' <- a -> IO (Ptr Address)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
addr
    CInt
result <- Ptr Address -> IO CInt
soup_address_is_resolved Ptr Address
addr'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
addr
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(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-'P.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 t'GI.Soup.Objects.Address.Address'
    -> Maybe (GLib.MainContext.MainContext)
    -- ^ /@asyncContext@/: the t'GI.GLib.Structs.MainContext.MainContext' to call /@callback@/ from
    -> Maybe (b)
    -- ^ /@cancellable@/: a t'GI.Gio.Objects.Cancellable.Cancellable' object, or 'P.Nothing'
    -> Soup.Callbacks.AddressCallback
    -- ^ /@callback@/: callback to call with the result
    -> m ()
addressResolveAsync :: a -> Maybe MainContext -> Maybe b -> AddressCallback -> m ()
addressResolveAsync a
addr Maybe MainContext
asyncContext Maybe b
cancellable AddressCallback
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 Address
addr' <- a -> IO (Ptr Address)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
addr
    Ptr MainContext
maybeAsyncContext <- case Maybe MainContext
asyncContext of
        Maybe MainContext
Nothing -> Ptr MainContext -> IO (Ptr MainContext)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr MainContext
forall a. Ptr a
nullPtr
        Just MainContext
jAsyncContext -> do
            Ptr MainContext
jAsyncContext' <- MainContext -> IO (Ptr MainContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr MainContext
jAsyncContext
            Ptr MainContext -> IO (Ptr MainContext)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr MainContext
jAsyncContext'
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Maybe b
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just 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'
    Ptr (FunPtr C_AddressCallback)
ptrcallback <- IO (Ptr (FunPtr C_AddressCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Soup.Callbacks.C_AddressCallback))
    FunPtr C_AddressCallback
callback' <- C_AddressCallback -> IO (FunPtr C_AddressCallback)
Soup.Callbacks.mk_AddressCallback (Maybe (Ptr (FunPtr C_AddressCallback))
-> AddressCallback_WithClosures -> C_AddressCallback
Soup.Callbacks.wrap_AddressCallback (Ptr (FunPtr C_AddressCallback)
-> Maybe (Ptr (FunPtr C_AddressCallback))
forall a. a -> Maybe a
Just Ptr (FunPtr C_AddressCallback)
ptrcallback) (AddressCallback -> AddressCallback_WithClosures
Soup.Callbacks.drop_closures_AddressCallback AddressCallback
callback))
    Ptr (FunPtr C_AddressCallback) -> FunPtr C_AddressCallback -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_AddressCallback)
ptrcallback FunPtr C_AddressCallback
callback'
    let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
    Ptr Address
-> Ptr MainContext
-> Ptr Cancellable
-> FunPtr C_AddressCallback
-> Ptr ()
-> IO ()
soup_address_resolve_async Ptr Address
addr' Ptr MainContext
maybeAsyncContext Ptr Cancellable
maybeCancellable FunPtr C_AddressCallback
callback' Ptr ()
forall a. Ptr a
userData
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
addr
    Maybe MainContext -> (MainContext -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe MainContext
asyncContext MainContext -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    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
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(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-'P.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 t'GI.Soup.Objects.Address.Address'
    -> Maybe (b)
    -- ^ /@cancellable@/: a t'GI.Gio.Objects.Cancellable.Cancellable' object, or 'P.Nothing'
    -> m Word32
    -- ^ __Returns:__ 'GI.Soup.Enums.StatusOk', 'GI.Soup.Enums.StatusCantResolve', or
    -- 'GI.Soup.Enums.StatusCancelled'.
addressResolveSync :: a -> Maybe b -> m Word32
addressResolveSync a
addr Maybe b
cancellable = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Ptr Address
addr' <- a -> IO (Ptr Address)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
addr
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Maybe b
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just 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'
    Word32
result <- Ptr Address -> Ptr Cancellable -> IO Word32
soup_address_resolve_sync Ptr Address
addr' Ptr Cancellable
maybeCancellable
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
addr
    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
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result

#if defined(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