{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.Gio.Objects.NetworkAddress
(
NetworkAddress(..) ,
IsNetworkAddress ,
toNetworkAddress ,
noNetworkAddress ,
#if defined(ENABLE_OVERLOADING)
ResolveNetworkAddressMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
NetworkAddressGetHostnameMethodInfo ,
#endif
networkAddressGetHostname ,
#if defined(ENABLE_OVERLOADING)
NetworkAddressGetPortMethodInfo ,
#endif
networkAddressGetPort ,
#if defined(ENABLE_OVERLOADING)
NetworkAddressGetSchemeMethodInfo ,
#endif
networkAddressGetScheme ,
networkAddressNew ,
networkAddressNewLoopback ,
networkAddressParse ,
networkAddressParseUri ,
#if defined(ENABLE_OVERLOADING)
NetworkAddressHostnamePropertyInfo ,
#endif
constructNetworkAddressHostname ,
getNetworkAddressHostname ,
#if defined(ENABLE_OVERLOADING)
networkAddressHostname ,
#endif
#if defined(ENABLE_OVERLOADING)
NetworkAddressPortPropertyInfo ,
#endif
constructNetworkAddressPort ,
getNetworkAddressPort ,
#if defined(ENABLE_OVERLOADING)
networkAddressPort ,
#endif
#if defined(ENABLE_OVERLOADING)
NetworkAddressSchemePropertyInfo ,
#endif
constructNetworkAddressScheme ,
getNetworkAddressScheme ,
#if defined(ENABLE_OVERLOADING)
networkAddressScheme ,
#endif
) where
import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P
import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL
import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Gio.Interfaces.SocketConnectable as Gio.SocketConnectable
newtype NetworkAddress = NetworkAddress (ManagedPtr NetworkAddress)
deriving (Eq)
foreign import ccall "g_network_address_get_type"
c_g_network_address_get_type :: IO GType
instance GObject NetworkAddress where
gobjectType = c_g_network_address_get_type
instance B.GValue.IsGValue NetworkAddress where
toGValue o = do
gtype <- c_g_network_address_get_type
B.ManagedPtr.withManagedPtr o (B.GValue.buildGValue gtype B.GValue.set_object)
fromGValue gv = do
ptr <- B.GValue.get_object gv :: IO (Ptr NetworkAddress)
B.ManagedPtr.newObject NetworkAddress ptr
class (GObject o, O.IsDescendantOf NetworkAddress o) => IsNetworkAddress o
instance (GObject o, O.IsDescendantOf NetworkAddress o) => IsNetworkAddress o
instance O.HasParentTypes NetworkAddress
type instance O.ParentTypes NetworkAddress = '[GObject.Object.Object, Gio.SocketConnectable.SocketConnectable]
toNetworkAddress :: (MonadIO m, IsNetworkAddress o) => o -> m NetworkAddress
toNetworkAddress = liftIO . unsafeCastTo NetworkAddress
noNetworkAddress :: Maybe NetworkAddress
noNetworkAddress = Nothing
#if defined(ENABLE_OVERLOADING)
type family ResolveNetworkAddressMethod (t :: Symbol) (o :: *) :: * where
ResolveNetworkAddressMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
ResolveNetworkAddressMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
ResolveNetworkAddressMethod "enumerate" o = Gio.SocketConnectable.SocketConnectableEnumerateMethodInfo
ResolveNetworkAddressMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
ResolveNetworkAddressMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
ResolveNetworkAddressMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
ResolveNetworkAddressMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
ResolveNetworkAddressMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
ResolveNetworkAddressMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
ResolveNetworkAddressMethod "proxyEnumerate" o = Gio.SocketConnectable.SocketConnectableProxyEnumerateMethodInfo
ResolveNetworkAddressMethod "ref" o = GObject.Object.ObjectRefMethodInfo
ResolveNetworkAddressMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
ResolveNetworkAddressMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
ResolveNetworkAddressMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
ResolveNetworkAddressMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
ResolveNetworkAddressMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
ResolveNetworkAddressMethod "toString" o = Gio.SocketConnectable.SocketConnectableToStringMethodInfo
ResolveNetworkAddressMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
ResolveNetworkAddressMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
ResolveNetworkAddressMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
ResolveNetworkAddressMethod "getHostname" o = NetworkAddressGetHostnameMethodInfo
ResolveNetworkAddressMethod "getPort" o = NetworkAddressGetPortMethodInfo
ResolveNetworkAddressMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
ResolveNetworkAddressMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
ResolveNetworkAddressMethod "getScheme" o = NetworkAddressGetSchemeMethodInfo
ResolveNetworkAddressMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
ResolveNetworkAddressMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
ResolveNetworkAddressMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
ResolveNetworkAddressMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveNetworkAddressMethod t NetworkAddress, O.MethodInfo info NetworkAddress p) => OL.IsLabel t (NetworkAddress -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#endif
getNetworkAddressHostname :: (MonadIO m, IsNetworkAddress o) => o -> m T.Text
getNetworkAddressHostname obj = liftIO $ checkUnexpectedNothing "getNetworkAddressHostname" $ B.Properties.getObjectPropertyString obj "hostname"
constructNetworkAddressHostname :: (IsNetworkAddress o) => T.Text -> IO (GValueConstruct o)
constructNetworkAddressHostname val = B.Properties.constructObjectPropertyString "hostname" (Just val)
#if defined(ENABLE_OVERLOADING)
data NetworkAddressHostnamePropertyInfo
instance AttrInfo NetworkAddressHostnamePropertyInfo where
type AttrAllowedOps NetworkAddressHostnamePropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
type AttrBaseTypeConstraint NetworkAddressHostnamePropertyInfo = IsNetworkAddress
type AttrSetTypeConstraint NetworkAddressHostnamePropertyInfo = (~) T.Text
type AttrTransferTypeConstraint NetworkAddressHostnamePropertyInfo = (~) T.Text
type AttrTransferType NetworkAddressHostnamePropertyInfo = T.Text
type AttrGetType NetworkAddressHostnamePropertyInfo = T.Text
type AttrLabel NetworkAddressHostnamePropertyInfo = "hostname"
type AttrOrigin NetworkAddressHostnamePropertyInfo = NetworkAddress
attrGet = getNetworkAddressHostname
attrSet = undefined
attrTransfer _ v = do
return v
attrConstruct = constructNetworkAddressHostname
attrClear = undefined
#endif
getNetworkAddressPort :: (MonadIO m, IsNetworkAddress o) => o -> m Word32
getNetworkAddressPort obj = liftIO $ B.Properties.getObjectPropertyUInt32 obj "port"
constructNetworkAddressPort :: (IsNetworkAddress o) => Word32 -> IO (GValueConstruct o)
constructNetworkAddressPort val = B.Properties.constructObjectPropertyUInt32 "port" val
#if defined(ENABLE_OVERLOADING)
data NetworkAddressPortPropertyInfo
instance AttrInfo NetworkAddressPortPropertyInfo where
type AttrAllowedOps NetworkAddressPortPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
type AttrBaseTypeConstraint NetworkAddressPortPropertyInfo = IsNetworkAddress
type AttrSetTypeConstraint NetworkAddressPortPropertyInfo = (~) Word32
type AttrTransferTypeConstraint NetworkAddressPortPropertyInfo = (~) Word32
type AttrTransferType NetworkAddressPortPropertyInfo = Word32
type AttrGetType NetworkAddressPortPropertyInfo = Word32
type AttrLabel NetworkAddressPortPropertyInfo = "port"
type AttrOrigin NetworkAddressPortPropertyInfo = NetworkAddress
attrGet = getNetworkAddressPort
attrSet = undefined
attrTransfer _ v = do
return v
attrConstruct = constructNetworkAddressPort
attrClear = undefined
#endif
getNetworkAddressScheme :: (MonadIO m, IsNetworkAddress o) => o -> m T.Text
getNetworkAddressScheme obj = liftIO $ checkUnexpectedNothing "getNetworkAddressScheme" $ B.Properties.getObjectPropertyString obj "scheme"
constructNetworkAddressScheme :: (IsNetworkAddress o) => T.Text -> IO (GValueConstruct o)
constructNetworkAddressScheme val = B.Properties.constructObjectPropertyString "scheme" (Just val)
#if defined(ENABLE_OVERLOADING)
data NetworkAddressSchemePropertyInfo
instance AttrInfo NetworkAddressSchemePropertyInfo where
type AttrAllowedOps NetworkAddressSchemePropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
type AttrBaseTypeConstraint NetworkAddressSchemePropertyInfo = IsNetworkAddress
type AttrSetTypeConstraint NetworkAddressSchemePropertyInfo = (~) T.Text
type AttrTransferTypeConstraint NetworkAddressSchemePropertyInfo = (~) T.Text
type AttrTransferType NetworkAddressSchemePropertyInfo = T.Text
type AttrGetType NetworkAddressSchemePropertyInfo = T.Text
type AttrLabel NetworkAddressSchemePropertyInfo = "scheme"
type AttrOrigin NetworkAddressSchemePropertyInfo = NetworkAddress
attrGet = getNetworkAddressScheme
attrSet = undefined
attrTransfer _ v = do
return v
attrConstruct = constructNetworkAddressScheme
attrClear = undefined
#endif
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList NetworkAddress
type instance O.AttributeList NetworkAddress = NetworkAddressAttributeList
type NetworkAddressAttributeList = ('[ '("hostname", NetworkAddressHostnamePropertyInfo), '("port", NetworkAddressPortPropertyInfo), '("scheme", NetworkAddressSchemePropertyInfo)] :: [(Symbol, *)])
#endif
#if defined(ENABLE_OVERLOADING)
networkAddressHostname :: AttrLabelProxy "hostname"
networkAddressHostname = AttrLabelProxy
networkAddressPort :: AttrLabelProxy "port"
networkAddressPort = AttrLabelProxy
networkAddressScheme :: AttrLabelProxy "scheme"
networkAddressScheme = AttrLabelProxy
#endif
#if defined(ENABLE_OVERLOADING)
type instance O.SignalList NetworkAddress = NetworkAddressSignalList
type NetworkAddressSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])
#endif
foreign import ccall "g_network_address_new" g_network_address_new ::
CString ->
Word16 ->
IO (Ptr NetworkAddress)
networkAddressNew ::
(B.CallStack.HasCallStack, MonadIO m) =>
T.Text
-> Word16
-> m NetworkAddress
networkAddressNew hostname port = liftIO $ do
hostname' <- textToCString hostname
result <- g_network_address_new hostname' port
checkUnexpectedReturnNULL "networkAddressNew" result
result' <- (wrapObject NetworkAddress) result
freeMem hostname'
return result'
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "g_network_address_new_loopback" g_network_address_new_loopback ::
Word16 ->
IO (Ptr NetworkAddress)
networkAddressNewLoopback ::
(B.CallStack.HasCallStack, MonadIO m) =>
Word16
-> m NetworkAddress
networkAddressNewLoopback port = liftIO $ do
result <- g_network_address_new_loopback port
checkUnexpectedReturnNULL "networkAddressNewLoopback" result
result' <- (wrapObject NetworkAddress) result
return result'
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "g_network_address_get_hostname" g_network_address_get_hostname ::
Ptr NetworkAddress ->
IO CString
networkAddressGetHostname ::
(B.CallStack.HasCallStack, MonadIO m, IsNetworkAddress a) =>
a
-> m T.Text
networkAddressGetHostname addr = liftIO $ do
addr' <- unsafeManagedPtrCastPtr addr
result <- g_network_address_get_hostname addr'
checkUnexpectedReturnNULL "networkAddressGetHostname" result
result' <- cstringToText result
touchManagedPtr addr
return result'
#if defined(ENABLE_OVERLOADING)
data NetworkAddressGetHostnameMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsNetworkAddress a) => O.MethodInfo NetworkAddressGetHostnameMethodInfo a signature where
overloadedMethod = networkAddressGetHostname
#endif
foreign import ccall "g_network_address_get_port" g_network_address_get_port ::
Ptr NetworkAddress ->
IO Word16
networkAddressGetPort ::
(B.CallStack.HasCallStack, MonadIO m, IsNetworkAddress a) =>
a
-> m Word16
networkAddressGetPort addr = liftIO $ do
addr' <- unsafeManagedPtrCastPtr addr
result <- g_network_address_get_port addr'
touchManagedPtr addr
return result
#if defined(ENABLE_OVERLOADING)
data NetworkAddressGetPortMethodInfo
instance (signature ~ (m Word16), MonadIO m, IsNetworkAddress a) => O.MethodInfo NetworkAddressGetPortMethodInfo a signature where
overloadedMethod = networkAddressGetPort
#endif
foreign import ccall "g_network_address_get_scheme" g_network_address_get_scheme ::
Ptr NetworkAddress ->
IO CString
networkAddressGetScheme ::
(B.CallStack.HasCallStack, MonadIO m, IsNetworkAddress a) =>
a
-> m T.Text
networkAddressGetScheme addr = liftIO $ do
addr' <- unsafeManagedPtrCastPtr addr
result <- g_network_address_get_scheme addr'
checkUnexpectedReturnNULL "networkAddressGetScheme" result
result' <- cstringToText result
touchManagedPtr addr
return result'
#if defined(ENABLE_OVERLOADING)
data NetworkAddressGetSchemeMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsNetworkAddress a) => O.MethodInfo NetworkAddressGetSchemeMethodInfo a signature where
overloadedMethod = networkAddressGetScheme
#endif
foreign import ccall "g_network_address_parse" g_network_address_parse ::
CString ->
Word16 ->
Ptr (Ptr GError) ->
IO (Ptr NetworkAddress)
networkAddressParse ::
(B.CallStack.HasCallStack, MonadIO m) =>
T.Text
-> Word16
-> m NetworkAddress
networkAddressParse hostAndPort defaultPort = liftIO $ do
hostAndPort' <- textToCString hostAndPort
onException (do
result <- propagateGError $ g_network_address_parse hostAndPort' defaultPort
checkUnexpectedReturnNULL "networkAddressParse" result
result' <- (wrapObject NetworkAddress) result
freeMem hostAndPort'
return result'
) (do
freeMem hostAndPort'
)
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "g_network_address_parse_uri" g_network_address_parse_uri ::
CString ->
Word16 ->
Ptr (Ptr GError) ->
IO (Ptr NetworkAddress)
networkAddressParseUri ::
(B.CallStack.HasCallStack, MonadIO m) =>
T.Text
-> Word16
-> m NetworkAddress
networkAddressParseUri uri defaultPort = liftIO $ do
uri' <- textToCString uri
onException (do
result <- propagateGError $ g_network_address_parse_uri uri' defaultPort
checkUnexpectedReturnNULL "networkAddressParseUri" result
result' <- (wrapObject NetworkAddress) result
freeMem uri'
return result'
) (do
freeMem uri'
)
#if defined(ENABLE_OVERLOADING)
#endif