module GI.Gio.Objects.NetworkAddress
(
NetworkAddress(..) ,
IsNetworkAddress ,
toNetworkAddress ,
noNetworkAddress ,
NetworkAddressGetHostnameMethodInfo ,
networkAddressGetHostname ,
NetworkAddressGetPortMethodInfo ,
networkAddressGetPort ,
NetworkAddressGetSchemeMethodInfo ,
networkAddressGetScheme ,
networkAddressNew ,
networkAddressNewLoopback ,
networkAddressParse ,
networkAddressParseUri ,
NetworkAddressHostnamePropertyInfo ,
constructNetworkAddressHostname ,
getNetworkAddressHostname ,
networkAddressHostname ,
NetworkAddressPortPropertyInfo ,
constructNetworkAddressPort ,
getNetworkAddressPort ,
networkAddressPort ,
NetworkAddressSchemePropertyInfo ,
constructNetworkAddressScheme ,
getNetworkAddressScheme ,
networkAddressScheme ,
) 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.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
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 GI.GObject.Objects.Object as GObject.Object
import 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 => IsNetworkAddress o
#if MIN_VERSION_base(4,9,0)
instance (GObject a, O.UnknownAncestorError NetworkAddress a) =>
IsNetworkAddress a
#endif
instance IsNetworkAddress NetworkAddress
instance GObject.Object.IsObject NetworkAddress
instance Gio.SocketConnectable.IsSocketConnectable NetworkAddress
toNetworkAddress :: IsNetworkAddress o => o -> IO NetworkAddress
toNetworkAddress = unsafeCastTo NetworkAddress
noNetworkAddress :: Maybe NetworkAddress
noNetworkAddress = Nothing
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 "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 "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
ResolveNetworkAddressMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
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 "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
ResolveNetworkAddressMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveNetworkAddressMethod t NetworkAddress, O.MethodInfo info NetworkAddress p) => O.IsLabelProxy t (NetworkAddress -> p) where
fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveNetworkAddressMethod t NetworkAddress, O.MethodInfo info NetworkAddress p) => O.IsLabel t (NetworkAddress -> p) where
fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif
getNetworkAddressHostname :: (MonadIO m, IsNetworkAddress o) => o -> m T.Text
getNetworkAddressHostname obj = liftIO $ checkUnexpectedNothing "getNetworkAddressHostname" $ getObjectPropertyString obj "hostname"
constructNetworkAddressHostname :: (IsNetworkAddress o) => T.Text -> IO (GValueConstruct o)
constructNetworkAddressHostname val = constructObjectPropertyString "hostname" (Just val)
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
getNetworkAddressPort :: (MonadIO m, IsNetworkAddress o) => o -> m Word32
getNetworkAddressPort obj = liftIO $ getObjectPropertyUInt32 obj "port"
constructNetworkAddressPort :: (IsNetworkAddress o) => Word32 -> IO (GValueConstruct o)
constructNetworkAddressPort val = constructObjectPropertyUInt32 "port" val
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
getNetworkAddressScheme :: (MonadIO m, IsNetworkAddress o) => o -> m T.Text
getNetworkAddressScheme obj = liftIO $ checkUnexpectedNothing "getNetworkAddressScheme" $ getObjectPropertyString obj "scheme"
constructNetworkAddressScheme :: (IsNetworkAddress o) => T.Text -> IO (GValueConstruct o)
constructNetworkAddressScheme val = constructObjectPropertyString "scheme" (Just val)
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
instance O.HasAttributeList NetworkAddress
type instance O.AttributeList NetworkAddress = NetworkAddressAttributeList
type NetworkAddressAttributeList = ('[ '("hostname", NetworkAddressHostnamePropertyInfo), '("port", NetworkAddressPortPropertyInfo), '("scheme", NetworkAddressSchemePropertyInfo)] :: [(Symbol, *)])
networkAddressHostname :: AttrLabelProxy "hostname"
networkAddressHostname = AttrLabelProxy
networkAddressPort :: AttrLabelProxy "port"
networkAddressPort = AttrLabelProxy
networkAddressScheme :: AttrLabelProxy "scheme"
networkAddressScheme = AttrLabelProxy
type instance O.SignalList NetworkAddress = NetworkAddressSignalList
type NetworkAddressSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])
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'
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'
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'
data NetworkAddressGetHostnameMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsNetworkAddress a) => O.MethodInfo NetworkAddressGetHostnameMethodInfo a signature where
overloadedMethod _ = networkAddressGetHostname
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
data NetworkAddressGetPortMethodInfo
instance (signature ~ (m Word16), MonadIO m, IsNetworkAddress a) => O.MethodInfo NetworkAddressGetPortMethodInfo a signature where
overloadedMethod _ = networkAddressGetPort
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'
data NetworkAddressGetSchemeMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsNetworkAddress a) => O.MethodInfo NetworkAddressGetSchemeMethodInfo a signature where
overloadedMethod _ = networkAddressGetScheme
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'
)
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'
)