#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
&& !defined(__HADDOCK_VERSION__))
module GI.Gio.Objects.NetworkAddress
(
NetworkAddress(..) ,
IsNetworkAddress ,
toNetworkAddress ,
noNetworkAddress ,
#if ENABLE_OVERLOADING
NetworkAddressGetHostnameMethodInfo ,
#endif
networkAddressGetHostname ,
#if ENABLE_OVERLOADING
NetworkAddressGetPortMethodInfo ,
#endif
networkAddressGetPort ,
#if ENABLE_OVERLOADING
NetworkAddressGetSchemeMethodInfo ,
#endif
networkAddressGetScheme ,
networkAddressNew ,
networkAddressNewLoopback ,
networkAddressParse ,
networkAddressParseUri ,
#if ENABLE_OVERLOADING
NetworkAddressHostnamePropertyInfo ,
#endif
constructNetworkAddressHostname ,
getNetworkAddressHostname ,
#if ENABLE_OVERLOADING
networkAddressHostname ,
#endif
#if ENABLE_OVERLOADING
NetworkAddressPortPropertyInfo ,
#endif
constructNetworkAddressPort ,
getNetworkAddressPort ,
#if ENABLE_OVERLOADING
networkAddressPort ,
#endif
#if ENABLE_OVERLOADING
NetworkAddressSchemePropertyInfo ,
#endif
constructNetworkAddressScheme ,
getNetworkAddressScheme ,
#if 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.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)
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
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 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 (O.MethodProxy :: O.MethodProxy info)
#else
fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy 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 ENABLE_OVERLOADING
data NetworkAddressHostnamePropertyInfo
instance AttrInfo NetworkAddressHostnamePropertyInfo where
type AttrAllowedOps NetworkAddressHostnamePropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
type AttrSetTypeConstraint NetworkAddressHostnamePropertyInfo = (~) T.Text
type AttrBaseTypeConstraint NetworkAddressHostnamePropertyInfo = IsNetworkAddress
type AttrGetType NetworkAddressHostnamePropertyInfo = T.Text
type AttrLabel NetworkAddressHostnamePropertyInfo = "hostname"
type AttrOrigin NetworkAddressHostnamePropertyInfo = NetworkAddress
attrGet _ = getNetworkAddressHostname
attrSet _ = undefined
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 ENABLE_OVERLOADING
data NetworkAddressPortPropertyInfo
instance AttrInfo NetworkAddressPortPropertyInfo where
type AttrAllowedOps NetworkAddressPortPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
type AttrSetTypeConstraint NetworkAddressPortPropertyInfo = (~) Word32
type AttrBaseTypeConstraint NetworkAddressPortPropertyInfo = IsNetworkAddress
type AttrGetType NetworkAddressPortPropertyInfo = Word32
type AttrLabel NetworkAddressPortPropertyInfo = "port"
type AttrOrigin NetworkAddressPortPropertyInfo = NetworkAddress
attrGet _ = getNetworkAddressPort
attrSet _ = undefined
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 ENABLE_OVERLOADING
data NetworkAddressSchemePropertyInfo
instance AttrInfo NetworkAddressSchemePropertyInfo where
type AttrAllowedOps NetworkAddressSchemePropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
type AttrSetTypeConstraint NetworkAddressSchemePropertyInfo = (~) T.Text
type AttrBaseTypeConstraint NetworkAddressSchemePropertyInfo = IsNetworkAddress
type AttrGetType NetworkAddressSchemePropertyInfo = T.Text
type AttrLabel NetworkAddressSchemePropertyInfo = "scheme"
type AttrOrigin NetworkAddressSchemePropertyInfo = NetworkAddress
attrGet _ = getNetworkAddressScheme
attrSet _ = undefined
attrConstruct _ = constructNetworkAddressScheme
attrClear _ = undefined
#endif
#if ENABLE_OVERLOADING
instance O.HasAttributeList NetworkAddress
type instance O.AttributeList NetworkAddress = NetworkAddressAttributeList
type NetworkAddressAttributeList = ('[ '("hostname", NetworkAddressHostnamePropertyInfo), '("port", NetworkAddressPortPropertyInfo), '("scheme", NetworkAddressSchemePropertyInfo)] :: [(Symbol, *)])
#endif
#if ENABLE_OVERLOADING
networkAddressHostname :: AttrLabelProxy "hostname"
networkAddressHostname = AttrLabelProxy
networkAddressPort :: AttrLabelProxy "port"
networkAddressPort = AttrLabelProxy
networkAddressScheme :: AttrLabelProxy "scheme"
networkAddressScheme = AttrLabelProxy
#endif
#if 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 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 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 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 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 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 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 ENABLE_OVERLOADING
#endif