{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)
-}

module GI.Gio.Objects.InetSocketAddress
    ( 

-- * Exported types
    InetSocketAddress(..)                   ,
    InetSocketAddressK                      ,
    toInetSocketAddress                     ,
    noInetSocketAddress                     ,


 -- * Methods
-- ** inetSocketAddressGetAddress
    inetSocketAddressGetAddress             ,


-- ** inetSocketAddressGetFlowinfo
    inetSocketAddressGetFlowinfo            ,


-- ** inetSocketAddressGetPort
    inetSocketAddressGetPort                ,


-- ** inetSocketAddressGetScopeId
    inetSocketAddressGetScopeId             ,


-- ** inetSocketAddressNew
    inetSocketAddressNew                    ,


-- ** inetSocketAddressNewFromString
    inetSocketAddressNewFromString          ,




 -- * Properties
-- ** Address
    InetSocketAddressAddressPropertyInfo    ,
    constructInetSocketAddressAddress       ,
    getInetSocketAddressAddress             ,


-- ** Flowinfo
    InetSocketAddressFlowinfoPropertyInfo   ,
    constructInetSocketAddressFlowinfo      ,
    getInetSocketAddressFlowinfo            ,


-- ** Port
    InetSocketAddressPortPropertyInfo       ,
    constructInetSocketAddressPort          ,
    getInetSocketAddressPort                ,


-- ** ScopeId
    InetSocketAddressScopeIdPropertyInfo    ,
    constructInetSocketAddressScopeId       ,
    getInetSocketAddressScopeId             ,




    ) where

import Prelude ()
import Data.GI.Base.ShortPrelude

import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map

import GI.Gio.Types
import GI.Gio.Callbacks
import qualified GI.GObject as GObject

newtype InetSocketAddress = InetSocketAddress (ForeignPtr InetSocketAddress)
foreign import ccall "g_inet_socket_address_get_type"
    c_g_inet_socket_address_get_type :: IO GType

type instance ParentTypes InetSocketAddress = InetSocketAddressParentTypes
type InetSocketAddressParentTypes = '[SocketAddress, GObject.Object, SocketConnectable]

instance GObject InetSocketAddress where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_g_inet_socket_address_get_type
    

class GObject o => InetSocketAddressK o
instance (GObject o, IsDescendantOf InetSocketAddress o) => InetSocketAddressK o

toInetSocketAddress :: InetSocketAddressK o => o -> IO InetSocketAddress
toInetSocketAddress = unsafeCastTo InetSocketAddress

noInetSocketAddress :: Maybe InetSocketAddress
noInetSocketAddress = Nothing

-- VVV Prop "address"
   -- Type: TInterface "Gio" "InetAddress"
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]

getInetSocketAddressAddress :: (MonadIO m, InetSocketAddressK o) => o -> m InetAddress
getInetSocketAddressAddress obj = liftIO $ getObjectPropertyObject obj "address" InetAddress

constructInetSocketAddressAddress :: (InetAddressK a) => a -> IO ([Char], GValue)
constructInetSocketAddressAddress val = constructObjectPropertyObject "address" val

data InetSocketAddressAddressPropertyInfo
instance AttrInfo InetSocketAddressAddressPropertyInfo where
    type AttrAllowedOps InetSocketAddressAddressPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint InetSocketAddressAddressPropertyInfo = InetAddressK
    type AttrBaseTypeConstraint InetSocketAddressAddressPropertyInfo = InetSocketAddressK
    type AttrGetType InetSocketAddressAddressPropertyInfo = InetAddress
    type AttrLabel InetSocketAddressAddressPropertyInfo = "InetSocketAddress::address"
    attrGet _ = getInetSocketAddressAddress
    attrSet _ = undefined
    attrConstruct _ = constructInetSocketAddressAddress

-- VVV Prop "flowinfo"
   -- Type: TBasicType TUInt32
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]

getInetSocketAddressFlowinfo :: (MonadIO m, InetSocketAddressK o) => o -> m Word32
getInetSocketAddressFlowinfo obj = liftIO $ getObjectPropertyCUInt obj "flowinfo"

constructInetSocketAddressFlowinfo :: Word32 -> IO ([Char], GValue)
constructInetSocketAddressFlowinfo val = constructObjectPropertyCUInt "flowinfo" val

data InetSocketAddressFlowinfoPropertyInfo
instance AttrInfo InetSocketAddressFlowinfoPropertyInfo where
    type AttrAllowedOps InetSocketAddressFlowinfoPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint InetSocketAddressFlowinfoPropertyInfo = (~) Word32
    type AttrBaseTypeConstraint InetSocketAddressFlowinfoPropertyInfo = InetSocketAddressK
    type AttrGetType InetSocketAddressFlowinfoPropertyInfo = Word32
    type AttrLabel InetSocketAddressFlowinfoPropertyInfo = "InetSocketAddress::flowinfo"
    attrGet _ = getInetSocketAddressFlowinfo
    attrSet _ = undefined
    attrConstruct _ = constructInetSocketAddressFlowinfo

-- VVV Prop "port"
   -- Type: TBasicType TUInt32
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]

getInetSocketAddressPort :: (MonadIO m, InetSocketAddressK o) => o -> m Word32
getInetSocketAddressPort obj = liftIO $ getObjectPropertyCUInt obj "port"

constructInetSocketAddressPort :: Word32 -> IO ([Char], GValue)
constructInetSocketAddressPort val = constructObjectPropertyCUInt "port" val

data InetSocketAddressPortPropertyInfo
instance AttrInfo InetSocketAddressPortPropertyInfo where
    type AttrAllowedOps InetSocketAddressPortPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint InetSocketAddressPortPropertyInfo = (~) Word32
    type AttrBaseTypeConstraint InetSocketAddressPortPropertyInfo = InetSocketAddressK
    type AttrGetType InetSocketAddressPortPropertyInfo = Word32
    type AttrLabel InetSocketAddressPortPropertyInfo = "InetSocketAddress::port"
    attrGet _ = getInetSocketAddressPort
    attrSet _ = undefined
    attrConstruct _ = constructInetSocketAddressPort

-- VVV Prop "scope-id"
   -- Type: TBasicType TUInt32
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]

getInetSocketAddressScopeId :: (MonadIO m, InetSocketAddressK o) => o -> m Word32
getInetSocketAddressScopeId obj = liftIO $ getObjectPropertyCUInt obj "scope-id"

constructInetSocketAddressScopeId :: Word32 -> IO ([Char], GValue)
constructInetSocketAddressScopeId val = constructObjectPropertyCUInt "scope-id" val

data InetSocketAddressScopeIdPropertyInfo
instance AttrInfo InetSocketAddressScopeIdPropertyInfo where
    type AttrAllowedOps InetSocketAddressScopeIdPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint InetSocketAddressScopeIdPropertyInfo = (~) Word32
    type AttrBaseTypeConstraint InetSocketAddressScopeIdPropertyInfo = InetSocketAddressK
    type AttrGetType InetSocketAddressScopeIdPropertyInfo = Word32
    type AttrLabel InetSocketAddressScopeIdPropertyInfo = "InetSocketAddress::scope-id"
    attrGet _ = getInetSocketAddressScopeId
    attrSet _ = undefined
    attrConstruct _ = constructInetSocketAddressScopeId

type instance AttributeList InetSocketAddress = InetSocketAddressAttributeList
type InetSocketAddressAttributeList = ('[ '("address", InetSocketAddressAddressPropertyInfo), '("family", SocketAddressFamilyPropertyInfo), '("flowinfo", InetSocketAddressFlowinfoPropertyInfo), '("port", InetSocketAddressPortPropertyInfo), '("scope-id", InetSocketAddressScopeIdPropertyInfo)] :: [(Symbol, *)])

type instance SignalList InetSocketAddress = InetSocketAddressSignalList
type InetSocketAddressSignalList = ('[ '("notify", GObject.ObjectNotifySignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)])

-- method InetSocketAddress::new
-- method type : Constructor
-- Args : [Arg {argName = "address", argType = TInterface "Gio" "InetAddress", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "port", argType = TBasicType TUInt16, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "address", argType = TInterface "Gio" "InetAddress", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "port", argType = TBasicType TUInt16, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "InetSocketAddress"
-- throws : False
-- Skip return : False

foreign import ccall "g_inet_socket_address_new" g_inet_socket_address_new :: 
    Ptr InetAddress ->                      -- address : TInterface "Gio" "InetAddress"
    Word16 ->                               -- port : TBasicType TUInt16
    IO (Ptr InetSocketAddress)


inetSocketAddressNew ::
    (MonadIO m, InetAddressK a) =>
    a ->                                    -- address
    Word16 ->                               -- port
    m InetSocketAddress
inetSocketAddressNew address port = liftIO $ do
    let address' = unsafeManagedPtrCastPtr address
    result <- g_inet_socket_address_new address' port
    checkUnexpectedReturnNULL "g_inet_socket_address_new" result
    result' <- (wrapObject InetSocketAddress) result
    touchManagedPtr address
    return result'

-- method InetSocketAddress::new_from_string
-- method type : Constructor
-- Args : [Arg {argName = "address", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "port", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "address", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "port", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "InetSocketAddress"
-- throws : False
-- Skip return : False

foreign import ccall "g_inet_socket_address_new_from_string" g_inet_socket_address_new_from_string :: 
    CString ->                              -- address : TBasicType TUTF8
    Word32 ->                               -- port : TBasicType TUInt32
    IO (Ptr InetSocketAddress)


inetSocketAddressNewFromString ::
    (MonadIO m) =>
    T.Text ->                               -- address
    Word32 ->                               -- port
    m InetSocketAddress
inetSocketAddressNewFromString address port = liftIO $ do
    address' <- textToCString address
    result <- g_inet_socket_address_new_from_string address' port
    checkUnexpectedReturnNULL "g_inet_socket_address_new_from_string" result
    result' <- (wrapObject InetSocketAddress) result
    freeMem address'
    return result'

-- method InetSocketAddress::get_address
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "InetSocketAddress", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "InetSocketAddress", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "InetAddress"
-- throws : False
-- Skip return : False

foreign import ccall "g_inet_socket_address_get_address" g_inet_socket_address_get_address :: 
    Ptr InetSocketAddress ->                -- _obj : TInterface "Gio" "InetSocketAddress"
    IO (Ptr InetAddress)


inetSocketAddressGetAddress ::
    (MonadIO m, InetSocketAddressK a) =>
    a ->                                    -- _obj
    m InetAddress
inetSocketAddressGetAddress _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_inet_socket_address_get_address _obj'
    checkUnexpectedReturnNULL "g_inet_socket_address_get_address" result
    result' <- (newObject InetAddress) result
    touchManagedPtr _obj
    return result'

-- method InetSocketAddress::get_flowinfo
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "InetSocketAddress", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "InetSocketAddress", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUInt32
-- throws : False
-- Skip return : False

foreign import ccall "g_inet_socket_address_get_flowinfo" g_inet_socket_address_get_flowinfo :: 
    Ptr InetSocketAddress ->                -- _obj : TInterface "Gio" "InetSocketAddress"
    IO Word32


inetSocketAddressGetFlowinfo ::
    (MonadIO m, InetSocketAddressK a) =>
    a ->                                    -- _obj
    m Word32
inetSocketAddressGetFlowinfo _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_inet_socket_address_get_flowinfo _obj'
    touchManagedPtr _obj
    return result

-- method InetSocketAddress::get_port
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "InetSocketAddress", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "InetSocketAddress", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUInt16
-- throws : False
-- Skip return : False

foreign import ccall "g_inet_socket_address_get_port" g_inet_socket_address_get_port :: 
    Ptr InetSocketAddress ->                -- _obj : TInterface "Gio" "InetSocketAddress"
    IO Word16


inetSocketAddressGetPort ::
    (MonadIO m, InetSocketAddressK a) =>
    a ->                                    -- _obj
    m Word16
inetSocketAddressGetPort _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_inet_socket_address_get_port _obj'
    touchManagedPtr _obj
    return result

-- method InetSocketAddress::get_scope_id
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "InetSocketAddress", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "InetSocketAddress", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUInt32
-- throws : False
-- Skip return : False

foreign import ccall "g_inet_socket_address_get_scope_id" g_inet_socket_address_get_scope_id :: 
    Ptr InetSocketAddress ->                -- _obj : TInterface "Gio" "InetSocketAddress"
    IO Word32


inetSocketAddressGetScopeId ::
    (MonadIO m, InetSocketAddressK a) =>
    a ->                                    -- _obj
    m Word32
inetSocketAddressGetScopeId _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_inet_socket_address_get_scope_id _obj'
    touchManagedPtr _obj
    return result