#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
&& !defined(__HADDOCK_VERSION__))
module GI.Gio.Objects.SocketConnection
(
SocketConnection(..) ,
IsSocketConnection ,
toSocketConnection ,
noSocketConnection ,
#if ENABLE_OVERLOADING
SocketConnectionConnectMethodInfo ,
#endif
socketConnectionConnect ,
#if ENABLE_OVERLOADING
SocketConnectionConnectAsyncMethodInfo ,
#endif
socketConnectionConnectAsync ,
#if ENABLE_OVERLOADING
SocketConnectionConnectFinishMethodInfo ,
#endif
socketConnectionConnectFinish ,
socketConnectionFactoryLookupType ,
socketConnectionFactoryRegisterType ,
#if ENABLE_OVERLOADING
SocketConnectionGetLocalAddressMethodInfo,
#endif
socketConnectionGetLocalAddress ,
#if ENABLE_OVERLOADING
SocketConnectionGetRemoteAddressMethodInfo,
#endif
socketConnectionGetRemoteAddress ,
#if ENABLE_OVERLOADING
SocketConnectionGetSocketMethodInfo ,
#endif
socketConnectionGetSocket ,
#if ENABLE_OVERLOADING
SocketConnectionIsConnectedMethodInfo ,
#endif
socketConnectionIsConnected ,
#if ENABLE_OVERLOADING
SocketConnectionSocketPropertyInfo ,
#endif
constructSocketConnectionSocket ,
getSocketConnectionSocket ,
#if ENABLE_OVERLOADING
socketConnectionSocket ,
#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 qualified GI.Gio.Callbacks as Gio.Callbacks
import {-# SOURCE #-} qualified GI.Gio.Enums as Gio.Enums
import {-# SOURCE #-} qualified GI.Gio.Interfaces.AsyncResult as Gio.AsyncResult
import {-# SOURCE #-} qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import {-# SOURCE #-} qualified GI.Gio.Objects.IOStream as Gio.IOStream
import {-# SOURCE #-} qualified GI.Gio.Objects.Socket as Gio.Socket
import {-# SOURCE #-} qualified GI.Gio.Objects.SocketAddress as Gio.SocketAddress
newtype SocketConnection = SocketConnection (ManagedPtr SocketConnection)
foreign import ccall "g_socket_connection_get_type"
c_g_socket_connection_get_type :: IO GType
instance GObject SocketConnection where
gobjectType = c_g_socket_connection_get_type
class (GObject o, O.IsDescendantOf SocketConnection o) => IsSocketConnection o
instance (GObject o, O.IsDescendantOf SocketConnection o) => IsSocketConnection o
instance O.HasParentTypes SocketConnection
type instance O.ParentTypes SocketConnection = '[Gio.IOStream.IOStream, GObject.Object.Object]
toSocketConnection :: (MonadIO m, IsSocketConnection o) => o -> m SocketConnection
toSocketConnection = liftIO . unsafeCastTo SocketConnection
noSocketConnection :: Maybe SocketConnection
noSocketConnection = Nothing
#if ENABLE_OVERLOADING
type family ResolveSocketConnectionMethod (t :: Symbol) (o :: *) :: * where
ResolveSocketConnectionMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
ResolveSocketConnectionMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
ResolveSocketConnectionMethod "clearPending" o = Gio.IOStream.IOStreamClearPendingMethodInfo
ResolveSocketConnectionMethod "close" o = Gio.IOStream.IOStreamCloseMethodInfo
ResolveSocketConnectionMethod "closeAsync" o = Gio.IOStream.IOStreamCloseAsyncMethodInfo
ResolveSocketConnectionMethod "closeFinish" o = Gio.IOStream.IOStreamCloseFinishMethodInfo
ResolveSocketConnectionMethod "connect" o = SocketConnectionConnectMethodInfo
ResolveSocketConnectionMethod "connectAsync" o = SocketConnectionConnectAsyncMethodInfo
ResolveSocketConnectionMethod "connectFinish" o = SocketConnectionConnectFinishMethodInfo
ResolveSocketConnectionMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
ResolveSocketConnectionMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
ResolveSocketConnectionMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
ResolveSocketConnectionMethod "hasPending" o = Gio.IOStream.IOStreamHasPendingMethodInfo
ResolveSocketConnectionMethod "isClosed" o = Gio.IOStream.IOStreamIsClosedMethodInfo
ResolveSocketConnectionMethod "isConnected" o = SocketConnectionIsConnectedMethodInfo
ResolveSocketConnectionMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
ResolveSocketConnectionMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
ResolveSocketConnectionMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
ResolveSocketConnectionMethod "ref" o = GObject.Object.ObjectRefMethodInfo
ResolveSocketConnectionMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
ResolveSocketConnectionMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
ResolveSocketConnectionMethod "spliceAsync" o = Gio.IOStream.IOStreamSpliceAsyncMethodInfo
ResolveSocketConnectionMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
ResolveSocketConnectionMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
ResolveSocketConnectionMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
ResolveSocketConnectionMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
ResolveSocketConnectionMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
ResolveSocketConnectionMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
ResolveSocketConnectionMethod "getInputStream" o = Gio.IOStream.IOStreamGetInputStreamMethodInfo
ResolveSocketConnectionMethod "getLocalAddress" o = SocketConnectionGetLocalAddressMethodInfo
ResolveSocketConnectionMethod "getOutputStream" o = Gio.IOStream.IOStreamGetOutputStreamMethodInfo
ResolveSocketConnectionMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
ResolveSocketConnectionMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
ResolveSocketConnectionMethod "getRemoteAddress" o = SocketConnectionGetRemoteAddressMethodInfo
ResolveSocketConnectionMethod "getSocket" o = SocketConnectionGetSocketMethodInfo
ResolveSocketConnectionMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
ResolveSocketConnectionMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
ResolveSocketConnectionMethod "setPending" o = Gio.IOStream.IOStreamSetPendingMethodInfo
ResolveSocketConnectionMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
ResolveSocketConnectionMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveSocketConnectionMethod t SocketConnection, O.MethodInfo info SocketConnection p) => OL.IsLabel t (SocketConnection -> 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
getSocketConnectionSocket :: (MonadIO m, IsSocketConnection o) => o -> m Gio.Socket.Socket
getSocketConnectionSocket obj = liftIO $ checkUnexpectedNothing "getSocketConnectionSocket" $ B.Properties.getObjectPropertyObject obj "socket" Gio.Socket.Socket
constructSocketConnectionSocket :: (IsSocketConnection o, Gio.Socket.IsSocket a) => a -> IO (GValueConstruct o)
constructSocketConnectionSocket val = B.Properties.constructObjectPropertyObject "socket" (Just val)
#if ENABLE_OVERLOADING
data SocketConnectionSocketPropertyInfo
instance AttrInfo SocketConnectionSocketPropertyInfo where
type AttrAllowedOps SocketConnectionSocketPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
type AttrSetTypeConstraint SocketConnectionSocketPropertyInfo = Gio.Socket.IsSocket
type AttrBaseTypeConstraint SocketConnectionSocketPropertyInfo = IsSocketConnection
type AttrGetType SocketConnectionSocketPropertyInfo = Gio.Socket.Socket
type AttrLabel SocketConnectionSocketPropertyInfo = "socket"
type AttrOrigin SocketConnectionSocketPropertyInfo = SocketConnection
attrGet _ = getSocketConnectionSocket
attrSet _ = undefined
attrConstruct _ = constructSocketConnectionSocket
attrClear _ = undefined
#endif
#if ENABLE_OVERLOADING
instance O.HasAttributeList SocketConnection
type instance O.AttributeList SocketConnection = SocketConnectionAttributeList
type SocketConnectionAttributeList = ('[ '("closed", Gio.IOStream.IOStreamClosedPropertyInfo), '("inputStream", Gio.IOStream.IOStreamInputStreamPropertyInfo), '("outputStream", Gio.IOStream.IOStreamOutputStreamPropertyInfo), '("socket", SocketConnectionSocketPropertyInfo)] :: [(Symbol, *)])
#endif
#if ENABLE_OVERLOADING
socketConnectionSocket :: AttrLabelProxy "socket"
socketConnectionSocket = AttrLabelProxy
#endif
#if ENABLE_OVERLOADING
type instance O.SignalList SocketConnection = SocketConnectionSignalList
type SocketConnectionSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])
#endif
foreign import ccall "g_socket_connection_connect" g_socket_connection_connect ::
Ptr SocketConnection ->
Ptr Gio.SocketAddress.SocketAddress ->
Ptr Gio.Cancellable.Cancellable ->
Ptr (Ptr GError) ->
IO CInt
socketConnectionConnect ::
(B.CallStack.HasCallStack, MonadIO m, IsSocketConnection a, Gio.SocketAddress.IsSocketAddress b, Gio.Cancellable.IsCancellable c) =>
a
-> b
-> Maybe (c)
-> m ()
socketConnectionConnect connection address cancellable = liftIO $ do
connection' <- unsafeManagedPtrCastPtr connection
address' <- unsafeManagedPtrCastPtr address
maybeCancellable <- case cancellable of
Nothing -> return nullPtr
Just jCancellable -> do
jCancellable' <- unsafeManagedPtrCastPtr jCancellable
return jCancellable'
onException (do
_ <- propagateGError $ g_socket_connection_connect connection' address' maybeCancellable
touchManagedPtr connection
touchManagedPtr address
whenJust cancellable touchManagedPtr
return ()
) (do
return ()
)
#if ENABLE_OVERLOADING
data SocketConnectionConnectMethodInfo
instance (signature ~ (b -> Maybe (c) -> m ()), MonadIO m, IsSocketConnection a, Gio.SocketAddress.IsSocketAddress b, Gio.Cancellable.IsCancellable c) => O.MethodInfo SocketConnectionConnectMethodInfo a signature where
overloadedMethod _ = socketConnectionConnect
#endif
foreign import ccall "g_socket_connection_connect_async" g_socket_connection_connect_async ::
Ptr SocketConnection ->
Ptr Gio.SocketAddress.SocketAddress ->
Ptr Gio.Cancellable.Cancellable ->
FunPtr Gio.Callbacks.C_AsyncReadyCallback ->
Ptr () ->
IO ()
socketConnectionConnectAsync ::
(B.CallStack.HasCallStack, MonadIO m, IsSocketConnection a, Gio.SocketAddress.IsSocketAddress b, Gio.Cancellable.IsCancellable c) =>
a
-> b
-> Maybe (c)
-> Maybe (Gio.Callbacks.AsyncReadyCallback)
-> m ()
socketConnectionConnectAsync connection address cancellable callback = liftIO $ do
connection' <- unsafeManagedPtrCastPtr connection
address' <- unsafeManagedPtrCastPtr address
maybeCancellable <- case cancellable of
Nothing -> return nullPtr
Just jCancellable -> do
jCancellable' <- unsafeManagedPtrCastPtr jCancellable
return jCancellable'
maybeCallback <- case callback of
Nothing -> return (castPtrToFunPtr nullPtr)
Just jCallback -> do
ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
poke ptrcallback jCallback'
return jCallback'
let userData = nullPtr
g_socket_connection_connect_async connection' address' maybeCancellable maybeCallback userData
touchManagedPtr connection
touchManagedPtr address
whenJust cancellable touchManagedPtr
return ()
#if ENABLE_OVERLOADING
data SocketConnectionConnectAsyncMethodInfo
instance (signature ~ (b -> Maybe (c) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsSocketConnection a, Gio.SocketAddress.IsSocketAddress b, Gio.Cancellable.IsCancellable c) => O.MethodInfo SocketConnectionConnectAsyncMethodInfo a signature where
overloadedMethod _ = socketConnectionConnectAsync
#endif
foreign import ccall "g_socket_connection_connect_finish" g_socket_connection_connect_finish ::
Ptr SocketConnection ->
Ptr Gio.AsyncResult.AsyncResult ->
Ptr (Ptr GError) ->
IO CInt
socketConnectionConnectFinish ::
(B.CallStack.HasCallStack, MonadIO m, IsSocketConnection a, Gio.AsyncResult.IsAsyncResult b) =>
a
-> b
-> m ()
socketConnectionConnectFinish connection result_ = liftIO $ do
connection' <- unsafeManagedPtrCastPtr connection
result_' <- unsafeManagedPtrCastPtr result_
onException (do
_ <- propagateGError $ g_socket_connection_connect_finish connection' result_'
touchManagedPtr connection
touchManagedPtr result_
return ()
) (do
return ()
)
#if ENABLE_OVERLOADING
data SocketConnectionConnectFinishMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsSocketConnection a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo SocketConnectionConnectFinishMethodInfo a signature where
overloadedMethod _ = socketConnectionConnectFinish
#endif
foreign import ccall "g_socket_connection_get_local_address" g_socket_connection_get_local_address ::
Ptr SocketConnection ->
Ptr (Ptr GError) ->
IO (Ptr Gio.SocketAddress.SocketAddress)
socketConnectionGetLocalAddress ::
(B.CallStack.HasCallStack, MonadIO m, IsSocketConnection a) =>
a
-> m Gio.SocketAddress.SocketAddress
socketConnectionGetLocalAddress connection = liftIO $ do
connection' <- unsafeManagedPtrCastPtr connection
onException (do
result <- propagateGError $ g_socket_connection_get_local_address connection'
checkUnexpectedReturnNULL "socketConnectionGetLocalAddress" result
result' <- (wrapObject Gio.SocketAddress.SocketAddress) result
touchManagedPtr connection
return result'
) (do
return ()
)
#if ENABLE_OVERLOADING
data SocketConnectionGetLocalAddressMethodInfo
instance (signature ~ (m Gio.SocketAddress.SocketAddress), MonadIO m, IsSocketConnection a) => O.MethodInfo SocketConnectionGetLocalAddressMethodInfo a signature where
overloadedMethod _ = socketConnectionGetLocalAddress
#endif
foreign import ccall "g_socket_connection_get_remote_address" g_socket_connection_get_remote_address ::
Ptr SocketConnection ->
Ptr (Ptr GError) ->
IO (Ptr Gio.SocketAddress.SocketAddress)
socketConnectionGetRemoteAddress ::
(B.CallStack.HasCallStack, MonadIO m, IsSocketConnection a) =>
a
-> m Gio.SocketAddress.SocketAddress
socketConnectionGetRemoteAddress connection = liftIO $ do
connection' <- unsafeManagedPtrCastPtr connection
onException (do
result <- propagateGError $ g_socket_connection_get_remote_address connection'
checkUnexpectedReturnNULL "socketConnectionGetRemoteAddress" result
result' <- (wrapObject Gio.SocketAddress.SocketAddress) result
touchManagedPtr connection
return result'
) (do
return ()
)
#if ENABLE_OVERLOADING
data SocketConnectionGetRemoteAddressMethodInfo
instance (signature ~ (m Gio.SocketAddress.SocketAddress), MonadIO m, IsSocketConnection a) => O.MethodInfo SocketConnectionGetRemoteAddressMethodInfo a signature where
overloadedMethod _ = socketConnectionGetRemoteAddress
#endif
foreign import ccall "g_socket_connection_get_socket" g_socket_connection_get_socket ::
Ptr SocketConnection ->
IO (Ptr Gio.Socket.Socket)
socketConnectionGetSocket ::
(B.CallStack.HasCallStack, MonadIO m, IsSocketConnection a) =>
a
-> m Gio.Socket.Socket
socketConnectionGetSocket connection = liftIO $ do
connection' <- unsafeManagedPtrCastPtr connection
result <- g_socket_connection_get_socket connection'
checkUnexpectedReturnNULL "socketConnectionGetSocket" result
result' <- (newObject Gio.Socket.Socket) result
touchManagedPtr connection
return result'
#if ENABLE_OVERLOADING
data SocketConnectionGetSocketMethodInfo
instance (signature ~ (m Gio.Socket.Socket), MonadIO m, IsSocketConnection a) => O.MethodInfo SocketConnectionGetSocketMethodInfo a signature where
overloadedMethod _ = socketConnectionGetSocket
#endif
foreign import ccall "g_socket_connection_is_connected" g_socket_connection_is_connected ::
Ptr SocketConnection ->
IO CInt
socketConnectionIsConnected ::
(B.CallStack.HasCallStack, MonadIO m, IsSocketConnection a) =>
a
-> m Bool
socketConnectionIsConnected connection = liftIO $ do
connection' <- unsafeManagedPtrCastPtr connection
result <- g_socket_connection_is_connected connection'
let result' = (/= 0) result
touchManagedPtr connection
return result'
#if ENABLE_OVERLOADING
data SocketConnectionIsConnectedMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsSocketConnection a) => O.MethodInfo SocketConnectionIsConnectedMethodInfo a signature where
overloadedMethod _ = socketConnectionIsConnected
#endif
foreign import ccall "g_socket_connection_factory_lookup_type" g_socket_connection_factory_lookup_type ::
CUInt ->
CUInt ->
Int32 ->
IO CGType
socketConnectionFactoryLookupType ::
(B.CallStack.HasCallStack, MonadIO m) =>
Gio.Enums.SocketFamily
-> Gio.Enums.SocketType
-> Int32
-> m GType
socketConnectionFactoryLookupType family type_ protocolId = liftIO $ do
let family' = (fromIntegral . fromEnum) family
let type_' = (fromIntegral . fromEnum) type_
result <- g_socket_connection_factory_lookup_type family' type_' protocolId
let result' = GType result
return result'
#if ENABLE_OVERLOADING
#endif
foreign import ccall "g_socket_connection_factory_register_type" g_socket_connection_factory_register_type ::
CGType ->
CUInt ->
CUInt ->
Int32 ->
IO ()
socketConnectionFactoryRegisterType ::
(B.CallStack.HasCallStack, MonadIO m) =>
GType
-> Gio.Enums.SocketFamily
-> Gio.Enums.SocketType
-> Int32
-> m ()
socketConnectionFactoryRegisterType gType family type_ protocol = liftIO $ do
let gType' = gtypeToCGType gType
let family' = (fromIntegral . fromEnum) family
let type_' = (fromIntegral . fromEnum) type_
g_socket_connection_factory_register_type gType' family' type_' protocol
return ()
#if ENABLE_OVERLOADING
#endif