gi-soup-2.4.18: GI/Soup/Objects/Socket.hs
{- |
Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License : LGPL-2.1
Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc)
/No description available in the introspection data./
-}
#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
&& !defined(__HADDOCK_VERSION__))
module GI.Soup.Objects.Socket
(
-- * Exported types
Socket(..) ,
IsSocket ,
toSocket ,
noSocket ,
-- * Methods
-- ** connectAsync #method:connectAsync#
#if ENABLE_OVERLOADING
SocketConnectAsyncMethodInfo ,
#endif
socketConnectAsync ,
-- ** connectSync #method:connectSync#
#if ENABLE_OVERLOADING
SocketConnectSyncMethodInfo ,
#endif
socketConnectSync ,
-- ** disconnect #method:disconnect#
#if ENABLE_OVERLOADING
SocketDisconnectMethodInfo ,
#endif
socketDisconnect ,
-- ** getFd #method:getFd#
#if ENABLE_OVERLOADING
SocketGetFdMethodInfo ,
#endif
socketGetFd ,
-- ** getLocalAddress #method:getLocalAddress#
#if ENABLE_OVERLOADING
SocketGetLocalAddressMethodInfo ,
#endif
socketGetLocalAddress ,
-- ** getRemoteAddress #method:getRemoteAddress#
#if ENABLE_OVERLOADING
SocketGetRemoteAddressMethodInfo ,
#endif
socketGetRemoteAddress ,
-- ** isConnected #method:isConnected#
#if ENABLE_OVERLOADING
SocketIsConnectedMethodInfo ,
#endif
socketIsConnected ,
-- ** isSsl #method:isSsl#
#if ENABLE_OVERLOADING
SocketIsSslMethodInfo ,
#endif
socketIsSsl ,
-- ** listen #method:listen#
#if ENABLE_OVERLOADING
SocketListenMethodInfo ,
#endif
socketListen ,
-- ** read #method:read#
#if ENABLE_OVERLOADING
SocketReadMethodInfo ,
#endif
socketRead ,
-- ** readUntil #method:readUntil#
#if ENABLE_OVERLOADING
SocketReadUntilMethodInfo ,
#endif
socketReadUntil ,
-- ** startProxySsl #method:startProxySsl#
#if ENABLE_OVERLOADING
SocketStartProxySslMethodInfo ,
#endif
socketStartProxySsl ,
-- ** startSsl #method:startSsl#
#if ENABLE_OVERLOADING
SocketStartSslMethodInfo ,
#endif
socketStartSsl ,
-- ** write #method:write#
#if ENABLE_OVERLOADING
SocketWriteMethodInfo ,
#endif
socketWrite ,
-- * Properties
-- ** asyncContext #attr:asyncContext#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
SocketAsyncContextPropertyInfo ,
#endif
constructSocketAsyncContext ,
getSocketAsyncContext ,
#if ENABLE_OVERLOADING
socketAsyncContext ,
#endif
-- ** fd #attr:fd#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
SocketFdPropertyInfo ,
#endif
constructSocketFd ,
getSocketFd ,
#if ENABLE_OVERLOADING
socketFd ,
#endif
-- ** gsocket #attr:gsocket#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
SocketGsocketPropertyInfo ,
#endif
constructSocketGsocket ,
#if ENABLE_OVERLOADING
socketGsocket ,
#endif
-- ** iostream #attr:iostream#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
SocketIostreamPropertyInfo ,
#endif
constructSocketIostream ,
#if ENABLE_OVERLOADING
socketIostream ,
#endif
-- ** ipv6Only #attr:ipv6Only#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
SocketIpv6OnlyPropertyInfo ,
#endif
constructSocketIpv6Only ,
getSocketIpv6Only ,
setSocketIpv6Only ,
#if ENABLE_OVERLOADING
socketIpv6Only ,
#endif
-- ** isServer #attr:isServer#
{- | Whether or not the socket is a server socket.
Note that for \"ordinary\" @/SoupSockets/@ this will be set for
both listening sockets and the sockets emitted by
'GI.Soup.Objects.Socket.Socket'::@/new-connection/@, but for sockets created by
setting 'GI.Soup.Objects.Socket.Socket':@/fd/@, it will only be set for listening
sockets.
-}
#if ENABLE_OVERLOADING
SocketIsServerPropertyInfo ,
#endif
getSocketIsServer ,
#if ENABLE_OVERLOADING
socketIsServer ,
#endif
-- ** localAddress #attr:localAddress#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
SocketLocalAddressPropertyInfo ,
#endif
constructSocketLocalAddress ,
getSocketLocalAddress ,
#if ENABLE_OVERLOADING
socketLocalAddress ,
#endif
-- ** nonBlocking #attr:nonBlocking#
{- | Whether or not the socket uses non-blocking I\/O.
'GI.Soup.Objects.Socket.Socket'\'s I\/O methods are designed around the idea of
using a single codepath for both synchronous and
asynchronous I\/O. If you want to read off a 'GI.Soup.Objects.Socket.Socket',
the \"correct\" way to do it is to call 'GI.Soup.Objects.Socket.socketRead' or
'GI.Soup.Objects.Socket.socketReadUntil' repeatedly until you have read
everything you want. If it returns 'GI.Soup.Enums.SocketIOStatusWouldBlock'
at any point, stop reading and wait for it to emit the
'GI.Soup.Objects.Socket.Socket'::@/readable/@ signal. Then go back to the
reading-as-much-as-you-can loop. Likewise, for writing to a
'GI.Soup.Objects.Socket.Socket', you should call 'GI.Soup.Objects.Socket.socketWrite' either
until you have written everything, or it returns
'GI.Soup.Enums.SocketIOStatusWouldBlock' (in which case you wait for
'GI.Soup.Objects.Socket.Socket'::@/writable/@ and then go back into the loop).
Code written this way will work correctly with both
blocking and non-blocking sockets; blocking sockets will
simply never return 'GI.Soup.Enums.SocketIOStatusWouldBlock', and so the
code that handles that case just won\'t get used for them.
-}
#if ENABLE_OVERLOADING
SocketNonBlockingPropertyInfo ,
#endif
constructSocketNonBlocking ,
getSocketNonBlocking ,
setSocketNonBlocking ,
#if ENABLE_OVERLOADING
socketNonBlocking ,
#endif
-- ** remoteAddress #attr:remoteAddress#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
SocketRemoteAddressPropertyInfo ,
#endif
constructSocketRemoteAddress ,
getSocketRemoteAddress ,
#if ENABLE_OVERLOADING
socketRemoteAddress ,
#endif
-- ** sslCreds #attr:sslCreds#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
SocketSslCredsPropertyInfo ,
#endif
constructSocketSslCreds ,
getSocketSslCreds ,
setSocketSslCreds ,
#if ENABLE_OVERLOADING
socketSslCreds ,
#endif
-- ** sslFallback #attr:sslFallback#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
SocketSslFallbackPropertyInfo ,
#endif
constructSocketSslFallback ,
getSocketSslFallback ,
#if ENABLE_OVERLOADING
socketSslFallback ,
#endif
-- ** sslStrict #attr:sslStrict#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
SocketSslStrictPropertyInfo ,
#endif
constructSocketSslStrict ,
getSocketSslStrict ,
#if ENABLE_OVERLOADING
socketSslStrict ,
#endif
-- ** timeout #attr:timeout#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
SocketTimeoutPropertyInfo ,
#endif
constructSocketTimeout ,
getSocketTimeout ,
setSocketTimeout ,
#if ENABLE_OVERLOADING
socketTimeout ,
#endif
-- ** tlsCertificate #attr:tlsCertificate#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
SocketTlsCertificatePropertyInfo ,
#endif
getSocketTlsCertificate ,
#if ENABLE_OVERLOADING
socketTlsCertificate ,
#endif
-- ** tlsErrors #attr:tlsErrors#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
SocketTlsErrorsPropertyInfo ,
#endif
getSocketTlsErrors ,
#if ENABLE_OVERLOADING
socketTlsErrors ,
#endif
-- ** trustedCertificate #attr:trustedCertificate#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
SocketTrustedCertificatePropertyInfo ,
#endif
getSocketTrustedCertificate ,
#if ENABLE_OVERLOADING
socketTrustedCertificate ,
#endif
-- ** useThreadContext #attr:useThreadContext#
{- | Use 'GI.GLib.Functions.mainContextGetThreadDefault'.
/Since: 2.38/
-}
#if ENABLE_OVERLOADING
SocketUseThreadContextPropertyInfo ,
#endif
constructSocketUseThreadContext ,
getSocketUseThreadContext ,
#if ENABLE_OVERLOADING
socketUseThreadContext ,
#endif
-- * Signals
-- ** disconnected #signal:disconnected#
C_SocketDisconnectedCallback ,
SocketDisconnectedCallback ,
#if ENABLE_OVERLOADING
SocketDisconnectedSignalInfo ,
#endif
afterSocketDisconnected ,
genClosure_SocketDisconnected ,
mk_SocketDisconnectedCallback ,
noSocketDisconnectedCallback ,
onSocketDisconnected ,
wrap_SocketDisconnectedCallback ,
-- ** event #signal:event#
C_SocketEventCallback ,
SocketEventCallback ,
#if ENABLE_OVERLOADING
SocketEventSignalInfo ,
#endif
afterSocketEvent ,
genClosure_SocketEvent ,
mk_SocketEventCallback ,
noSocketEventCallback ,
onSocketEvent ,
wrap_SocketEventCallback ,
-- ** newConnection #signal:newConnection#
C_SocketNewConnectionCallback ,
SocketNewConnectionCallback ,
#if ENABLE_OVERLOADING
SocketNewConnectionSignalInfo ,
#endif
afterSocketNewConnection ,
genClosure_SocketNewConnection ,
mk_SocketNewConnectionCallback ,
noSocketNewConnectionCallback ,
onSocketNewConnection ,
wrap_SocketNewConnectionCallback ,
-- ** readable #signal:readable#
C_SocketReadableCallback ,
SocketReadableCallback ,
#if ENABLE_OVERLOADING
SocketReadableSignalInfo ,
#endif
afterSocketReadable ,
genClosure_SocketReadable ,
mk_SocketReadableCallback ,
noSocketReadableCallback ,
onSocketReadable ,
wrap_SocketReadableCallback ,
-- ** writable #signal:writable#
C_SocketWritableCallback ,
SocketWritableCallback ,
#if ENABLE_OVERLOADING
SocketWritableSignalInfo ,
#endif
afterSocketWritable ,
genClosure_SocketWritable ,
mk_SocketWritableCallback ,
noSocketWritableCallback ,
onSocketWritable ,
wrap_SocketWritableCallback ,
) 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.Enums as Gio.Enums
import qualified GI.Gio.Flags as Gio.Flags
import qualified GI.Gio.Interfaces.Initable as Gio.Initable
import qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import qualified GI.Gio.Objects.IOStream as Gio.IOStream
import qualified GI.Gio.Objects.Socket as Gio.Socket
import qualified GI.Gio.Objects.TlsCertificate as Gio.TlsCertificate
import qualified GI.Soup.Callbacks as Soup.Callbacks
import {-# SOURCE #-} qualified GI.Soup.Enums as Soup.Enums
import {-# SOURCE #-} qualified GI.Soup.Objects.Address as Soup.Address
-- | Memory-managed wrapper type.
newtype Socket = Socket (ManagedPtr Socket)
foreign import ccall "soup_socket_get_type"
c_soup_socket_get_type :: IO GType
instance GObject Socket where
gobjectType = c_soup_socket_get_type
-- | Type class for types which can be safely cast to `Socket`, for instance with `toSocket`.
class (GObject o, O.IsDescendantOf Socket o) => IsSocket o
instance (GObject o, O.IsDescendantOf Socket o) => IsSocket o
instance O.HasParentTypes Socket
type instance O.ParentTypes Socket = '[GObject.Object.Object, Gio.Initable.Initable]
-- | Cast to `Socket`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toSocket :: (MonadIO m, IsSocket o) => o -> m Socket
toSocket = liftIO . unsafeCastTo Socket
-- | A convenience alias for `Nothing` :: `Maybe` `Socket`.
noSocket :: Maybe Socket
noSocket = Nothing
#if ENABLE_OVERLOADING
type family ResolveSocketMethod (t :: Symbol) (o :: *) :: * where
ResolveSocketMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
ResolveSocketMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
ResolveSocketMethod "connectAsync" o = SocketConnectAsyncMethodInfo
ResolveSocketMethod "connectSync" o = SocketConnectSyncMethodInfo
ResolveSocketMethod "disconnect" o = SocketDisconnectMethodInfo
ResolveSocketMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
ResolveSocketMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
ResolveSocketMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
ResolveSocketMethod "init" o = Gio.Initable.InitableInitMethodInfo
ResolveSocketMethod "isConnected" o = SocketIsConnectedMethodInfo
ResolveSocketMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
ResolveSocketMethod "isSsl" o = SocketIsSslMethodInfo
ResolveSocketMethod "listen" o = SocketListenMethodInfo
ResolveSocketMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
ResolveSocketMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
ResolveSocketMethod "read" o = SocketReadMethodInfo
ResolveSocketMethod "readUntil" o = SocketReadUntilMethodInfo
ResolveSocketMethod "ref" o = GObject.Object.ObjectRefMethodInfo
ResolveSocketMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
ResolveSocketMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
ResolveSocketMethod "startProxySsl" o = SocketStartProxySslMethodInfo
ResolveSocketMethod "startSsl" o = SocketStartSslMethodInfo
ResolveSocketMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
ResolveSocketMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
ResolveSocketMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
ResolveSocketMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
ResolveSocketMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
ResolveSocketMethod "write" o = SocketWriteMethodInfo
ResolveSocketMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
ResolveSocketMethod "getFd" o = SocketGetFdMethodInfo
ResolveSocketMethod "getLocalAddress" o = SocketGetLocalAddressMethodInfo
ResolveSocketMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
ResolveSocketMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
ResolveSocketMethod "getRemoteAddress" o = SocketGetRemoteAddressMethodInfo
ResolveSocketMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
ResolveSocketMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
ResolveSocketMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveSocketMethod t Socket, O.MethodInfo info Socket p) => OL.IsLabel t (Socket -> 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
-- signal Socket::disconnected
{- |
Emitted when the socket is disconnected, for whatever
reason.
-}
type SocketDisconnectedCallback =
IO ()
-- | A convenience synonym for @`Nothing` :: `Maybe` `SocketDisconnectedCallback`@.
noSocketDisconnectedCallback :: Maybe SocketDisconnectedCallback
noSocketDisconnectedCallback = Nothing
-- | Type for the callback on the (unwrapped) C side.
type C_SocketDisconnectedCallback =
Ptr () -> -- object
Ptr () -> -- user_data
IO ()
-- | Generate a function pointer callable from C code, from a `C_SocketDisconnectedCallback`.
foreign import ccall "wrapper"
mk_SocketDisconnectedCallback :: C_SocketDisconnectedCallback -> IO (FunPtr C_SocketDisconnectedCallback)
-- | Wrap the callback into a `GClosure`.
genClosure_SocketDisconnected :: MonadIO m => SocketDisconnectedCallback -> m (GClosure C_SocketDisconnectedCallback)
genClosure_SocketDisconnected cb = liftIO $ do
let cb' = wrap_SocketDisconnectedCallback cb
mk_SocketDisconnectedCallback cb' >>= B.GClosure.newGClosure
-- | Wrap a `SocketDisconnectedCallback` into a `C_SocketDisconnectedCallback`.
wrap_SocketDisconnectedCallback ::
SocketDisconnectedCallback ->
C_SocketDisconnectedCallback
wrap_SocketDisconnectedCallback _cb _ _ = do
_cb
{- |
Connect a signal handler for the “@disconnected@” signal, to be run before the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
@
'Data.GI.Base.Signals.on' socket #disconnected callback
@
-}
onSocketDisconnected :: (IsSocket a, MonadIO m) => a -> SocketDisconnectedCallback -> m SignalHandlerId
onSocketDisconnected obj cb = liftIO $ do
let cb' = wrap_SocketDisconnectedCallback cb
cb'' <- mk_SocketDisconnectedCallback cb'
connectSignalFunPtr obj "disconnected" cb'' SignalConnectBefore
{- |
Connect a signal handler for the “@disconnected@” signal, to be run after the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
@
'Data.GI.Base.Signals.after' socket #disconnected callback
@
-}
afterSocketDisconnected :: (IsSocket a, MonadIO m) => a -> SocketDisconnectedCallback -> m SignalHandlerId
afterSocketDisconnected obj cb = liftIO $ do
let cb' = wrap_SocketDisconnectedCallback cb
cb'' <- mk_SocketDisconnectedCallback cb'
connectSignalFunPtr obj "disconnected" cb'' SignalConnectAfter
-- signal Socket::event
{- |
Emitted when a network-related event occurs. See
'GI.Gio.Objects.SocketClient.SocketClient'::@/event/@ for more details.
/Since: 2.38/
-}
type SocketEventCallback =
Gio.Enums.SocketClientEvent
{- ^ /@event@/: the event that occurred -}
-> Gio.IOStream.IOStream
{- ^ /@connection@/: the current connection state -}
-> IO ()
-- | A convenience synonym for @`Nothing` :: `Maybe` `SocketEventCallback`@.
noSocketEventCallback :: Maybe SocketEventCallback
noSocketEventCallback = Nothing
-- | Type for the callback on the (unwrapped) C side.
type C_SocketEventCallback =
Ptr () -> -- object
CUInt ->
Ptr Gio.IOStream.IOStream ->
Ptr () -> -- user_data
IO ()
-- | Generate a function pointer callable from C code, from a `C_SocketEventCallback`.
foreign import ccall "wrapper"
mk_SocketEventCallback :: C_SocketEventCallback -> IO (FunPtr C_SocketEventCallback)
-- | Wrap the callback into a `GClosure`.
genClosure_SocketEvent :: MonadIO m => SocketEventCallback -> m (GClosure C_SocketEventCallback)
genClosure_SocketEvent cb = liftIO $ do
let cb' = wrap_SocketEventCallback cb
mk_SocketEventCallback cb' >>= B.GClosure.newGClosure
-- | Wrap a `SocketEventCallback` into a `C_SocketEventCallback`.
wrap_SocketEventCallback ::
SocketEventCallback ->
C_SocketEventCallback
wrap_SocketEventCallback _cb _ event connection _ = do
let event' = (toEnum . fromIntegral) event
connection' <- (newObject Gio.IOStream.IOStream) connection
_cb event' connection'
{- |
Connect a signal handler for the “@event@” signal, to be run before the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
@
'Data.GI.Base.Signals.on' socket #event callback
@
-}
onSocketEvent :: (IsSocket a, MonadIO m) => a -> SocketEventCallback -> m SignalHandlerId
onSocketEvent obj cb = liftIO $ do
let cb' = wrap_SocketEventCallback cb
cb'' <- mk_SocketEventCallback cb'
connectSignalFunPtr obj "event" cb'' SignalConnectBefore
{- |
Connect a signal handler for the “@event@” signal, to be run after the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
@
'Data.GI.Base.Signals.after' socket #event callback
@
-}
afterSocketEvent :: (IsSocket a, MonadIO m) => a -> SocketEventCallback -> m SignalHandlerId
afterSocketEvent obj cb = liftIO $ do
let cb' = wrap_SocketEventCallback cb
cb'' <- mk_SocketEventCallback cb'
connectSignalFunPtr obj "event" cb'' SignalConnectAfter
-- signal Socket::new-connection
{- |
Emitted when a listening socket (set up with
'GI.Soup.Objects.Socket.socketListen') receives a new connection.
You must ref the /@new@/ if you want to keep it; otherwise it
will be destroyed after the signal is emitted.
-}
type SocketNewConnectionCallback =
Socket
{- ^ /@new@/: the new socket -}
-> IO ()
-- | A convenience synonym for @`Nothing` :: `Maybe` `SocketNewConnectionCallback`@.
noSocketNewConnectionCallback :: Maybe SocketNewConnectionCallback
noSocketNewConnectionCallback = Nothing
-- | Type for the callback on the (unwrapped) C side.
type C_SocketNewConnectionCallback =
Ptr () -> -- object
Ptr Socket ->
Ptr () -> -- user_data
IO ()
-- | Generate a function pointer callable from C code, from a `C_SocketNewConnectionCallback`.
foreign import ccall "wrapper"
mk_SocketNewConnectionCallback :: C_SocketNewConnectionCallback -> IO (FunPtr C_SocketNewConnectionCallback)
-- | Wrap the callback into a `GClosure`.
genClosure_SocketNewConnection :: MonadIO m => SocketNewConnectionCallback -> m (GClosure C_SocketNewConnectionCallback)
genClosure_SocketNewConnection cb = liftIO $ do
let cb' = wrap_SocketNewConnectionCallback cb
mk_SocketNewConnectionCallback cb' >>= B.GClosure.newGClosure
-- | Wrap a `SocketNewConnectionCallback` into a `C_SocketNewConnectionCallback`.
wrap_SocketNewConnectionCallback ::
SocketNewConnectionCallback ->
C_SocketNewConnectionCallback
wrap_SocketNewConnectionCallback _cb _ new _ = do
new' <- (newObject Socket) new
_cb new'
{- |
Connect a signal handler for the “@new-connection@” signal, to be run before the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
@
'Data.GI.Base.Signals.on' socket #newConnection callback
@
-}
onSocketNewConnection :: (IsSocket a, MonadIO m) => a -> SocketNewConnectionCallback -> m SignalHandlerId
onSocketNewConnection obj cb = liftIO $ do
let cb' = wrap_SocketNewConnectionCallback cb
cb'' <- mk_SocketNewConnectionCallback cb'
connectSignalFunPtr obj "new-connection" cb'' SignalConnectBefore
{- |
Connect a signal handler for the “@new-connection@” signal, to be run after the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
@
'Data.GI.Base.Signals.after' socket #newConnection callback
@
-}
afterSocketNewConnection :: (IsSocket a, MonadIO m) => a -> SocketNewConnectionCallback -> m SignalHandlerId
afterSocketNewConnection obj cb = liftIO $ do
let cb' = wrap_SocketNewConnectionCallback cb
cb'' <- mk_SocketNewConnectionCallback cb'
connectSignalFunPtr obj "new-connection" cb'' SignalConnectAfter
-- signal Socket::readable
{- |
Emitted when an async socket is readable. See
'GI.Soup.Objects.Socket.socketRead', 'GI.Soup.Objects.Socket.socketReadUntil' and
'GI.Soup.Objects.Socket.Socket':@/non-blocking/@.
-}
type SocketReadableCallback =
IO ()
-- | A convenience synonym for @`Nothing` :: `Maybe` `SocketReadableCallback`@.
noSocketReadableCallback :: Maybe SocketReadableCallback
noSocketReadableCallback = Nothing
-- | Type for the callback on the (unwrapped) C side.
type C_SocketReadableCallback =
Ptr () -> -- object
Ptr () -> -- user_data
IO ()
-- | Generate a function pointer callable from C code, from a `C_SocketReadableCallback`.
foreign import ccall "wrapper"
mk_SocketReadableCallback :: C_SocketReadableCallback -> IO (FunPtr C_SocketReadableCallback)
-- | Wrap the callback into a `GClosure`.
genClosure_SocketReadable :: MonadIO m => SocketReadableCallback -> m (GClosure C_SocketReadableCallback)
genClosure_SocketReadable cb = liftIO $ do
let cb' = wrap_SocketReadableCallback cb
mk_SocketReadableCallback cb' >>= B.GClosure.newGClosure
-- | Wrap a `SocketReadableCallback` into a `C_SocketReadableCallback`.
wrap_SocketReadableCallback ::
SocketReadableCallback ->
C_SocketReadableCallback
wrap_SocketReadableCallback _cb _ _ = do
_cb
{- |
Connect a signal handler for the “@readable@” signal, to be run before the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
@
'Data.GI.Base.Signals.on' socket #readable callback
@
-}
onSocketReadable :: (IsSocket a, MonadIO m) => a -> SocketReadableCallback -> m SignalHandlerId
onSocketReadable obj cb = liftIO $ do
let cb' = wrap_SocketReadableCallback cb
cb'' <- mk_SocketReadableCallback cb'
connectSignalFunPtr obj "readable" cb'' SignalConnectBefore
{- |
Connect a signal handler for the “@readable@” signal, to be run after the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
@
'Data.GI.Base.Signals.after' socket #readable callback
@
-}
afterSocketReadable :: (IsSocket a, MonadIO m) => a -> SocketReadableCallback -> m SignalHandlerId
afterSocketReadable obj cb = liftIO $ do
let cb' = wrap_SocketReadableCallback cb
cb'' <- mk_SocketReadableCallback cb'
connectSignalFunPtr obj "readable" cb'' SignalConnectAfter
-- signal Socket::writable
{- |
Emitted when an async socket is writable. See
'GI.Soup.Objects.Socket.socketWrite' and 'GI.Soup.Objects.Socket.Socket':@/non-blocking/@.
-}
type SocketWritableCallback =
IO ()
-- | A convenience synonym for @`Nothing` :: `Maybe` `SocketWritableCallback`@.
noSocketWritableCallback :: Maybe SocketWritableCallback
noSocketWritableCallback = Nothing
-- | Type for the callback on the (unwrapped) C side.
type C_SocketWritableCallback =
Ptr () -> -- object
Ptr () -> -- user_data
IO ()
-- | Generate a function pointer callable from C code, from a `C_SocketWritableCallback`.
foreign import ccall "wrapper"
mk_SocketWritableCallback :: C_SocketWritableCallback -> IO (FunPtr C_SocketWritableCallback)
-- | Wrap the callback into a `GClosure`.
genClosure_SocketWritable :: MonadIO m => SocketWritableCallback -> m (GClosure C_SocketWritableCallback)
genClosure_SocketWritable cb = liftIO $ do
let cb' = wrap_SocketWritableCallback cb
mk_SocketWritableCallback cb' >>= B.GClosure.newGClosure
-- | Wrap a `SocketWritableCallback` into a `C_SocketWritableCallback`.
wrap_SocketWritableCallback ::
SocketWritableCallback ->
C_SocketWritableCallback
wrap_SocketWritableCallback _cb _ _ = do
_cb
{- |
Connect a signal handler for the “@writable@” signal, to be run before the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
@
'Data.GI.Base.Signals.on' socket #writable callback
@
-}
onSocketWritable :: (IsSocket a, MonadIO m) => a -> SocketWritableCallback -> m SignalHandlerId
onSocketWritable obj cb = liftIO $ do
let cb' = wrap_SocketWritableCallback cb
cb'' <- mk_SocketWritableCallback cb'
connectSignalFunPtr obj "writable" cb'' SignalConnectBefore
{- |
Connect a signal handler for the “@writable@” signal, to be run after the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
@
'Data.GI.Base.Signals.after' socket #writable callback
@
-}
afterSocketWritable :: (IsSocket a, MonadIO m) => a -> SocketWritableCallback -> m SignalHandlerId
afterSocketWritable obj cb = liftIO $ do
let cb' = wrap_SocketWritableCallback cb
cb'' <- mk_SocketWritableCallback cb'
connectSignalFunPtr obj "writable" cb'' SignalConnectAfter
-- VVV Prop "async-context"
-- Type: TBasicType TPtr
-- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
-- Nullable: (Nothing,Nothing)
{- |
Get the value of the “@async-context@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
@
'Data.GI.Base.Attributes.get' socket #asyncContext
@
-}
getSocketAsyncContext :: (MonadIO m, IsSocket o) => o -> m (Ptr ())
getSocketAsyncContext obj = liftIO $ B.Properties.getObjectPropertyPtr obj "async-context"
{- |
Construct a `GValueConstruct` with valid value for the “@async-context@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructSocketAsyncContext :: (IsSocket o) => Ptr () -> IO (GValueConstruct o)
constructSocketAsyncContext val = B.Properties.constructObjectPropertyPtr "async-context" val
#if ENABLE_OVERLOADING
data SocketAsyncContextPropertyInfo
instance AttrInfo SocketAsyncContextPropertyInfo where
type AttrAllowedOps SocketAsyncContextPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
type AttrSetTypeConstraint SocketAsyncContextPropertyInfo = (~) (Ptr ())
type AttrBaseTypeConstraint SocketAsyncContextPropertyInfo = IsSocket
type AttrGetType SocketAsyncContextPropertyInfo = (Ptr ())
type AttrLabel SocketAsyncContextPropertyInfo = "async-context"
type AttrOrigin SocketAsyncContextPropertyInfo = Socket
attrGet _ = getSocketAsyncContext
attrSet _ = undefined
attrConstruct _ = constructSocketAsyncContext
attrClear _ = undefined
#endif
-- VVV Prop "fd"
-- Type: TBasicType TInt
-- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
-- Nullable: (Just False,Nothing)
{- |
Get the value of the “@fd@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
@
'Data.GI.Base.Attributes.get' socket #fd
@
-}
getSocketFd :: (MonadIO m, IsSocket o) => o -> m Int32
getSocketFd obj = liftIO $ B.Properties.getObjectPropertyInt32 obj "fd"
{- |
Construct a `GValueConstruct` with valid value for the “@fd@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructSocketFd :: (IsSocket o) => Int32 -> IO (GValueConstruct o)
constructSocketFd val = B.Properties.constructObjectPropertyInt32 "fd" val
#if ENABLE_OVERLOADING
data SocketFdPropertyInfo
instance AttrInfo SocketFdPropertyInfo where
type AttrAllowedOps SocketFdPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
type AttrSetTypeConstraint SocketFdPropertyInfo = (~) Int32
type AttrBaseTypeConstraint SocketFdPropertyInfo = IsSocket
type AttrGetType SocketFdPropertyInfo = Int32
type AttrLabel SocketFdPropertyInfo = "fd"
type AttrOrigin SocketFdPropertyInfo = Socket
attrGet _ = getSocketFd
attrSet _ = undefined
attrConstruct _ = constructSocketFd
attrClear _ = undefined
#endif
-- VVV Prop "gsocket"
-- Type: TInterface (Name {namespace = "Gio", name = "Socket"})
-- Flags: [PropertyWritable,PropertyConstructOnly]
-- Nullable: (Nothing,Nothing)
{- |
Construct a `GValueConstruct` with valid value for the “@gsocket@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructSocketGsocket :: (IsSocket o, Gio.Socket.IsSocket a) => a -> IO (GValueConstruct o)
constructSocketGsocket val = B.Properties.constructObjectPropertyObject "gsocket" (Just val)
#if ENABLE_OVERLOADING
data SocketGsocketPropertyInfo
instance AttrInfo SocketGsocketPropertyInfo where
type AttrAllowedOps SocketGsocketPropertyInfo = '[ 'AttrConstruct, 'AttrClear]
type AttrSetTypeConstraint SocketGsocketPropertyInfo = Gio.Socket.IsSocket
type AttrBaseTypeConstraint SocketGsocketPropertyInfo = IsSocket
type AttrGetType SocketGsocketPropertyInfo = ()
type AttrLabel SocketGsocketPropertyInfo = "gsocket"
type AttrOrigin SocketGsocketPropertyInfo = Socket
attrGet _ = undefined
attrSet _ = undefined
attrConstruct _ = constructSocketGsocket
attrClear _ = undefined
#endif
-- VVV Prop "iostream"
-- Type: TInterface (Name {namespace = "Gio", name = "IOStream"})
-- Flags: [PropertyWritable,PropertyConstructOnly]
-- Nullable: (Nothing,Nothing)
{- |
Construct a `GValueConstruct` with valid value for the “@iostream@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructSocketIostream :: (IsSocket o, Gio.IOStream.IsIOStream a) => a -> IO (GValueConstruct o)
constructSocketIostream val = B.Properties.constructObjectPropertyObject "iostream" (Just val)
#if ENABLE_OVERLOADING
data SocketIostreamPropertyInfo
instance AttrInfo SocketIostreamPropertyInfo where
type AttrAllowedOps SocketIostreamPropertyInfo = '[ 'AttrConstruct, 'AttrClear]
type AttrSetTypeConstraint SocketIostreamPropertyInfo = Gio.IOStream.IsIOStream
type AttrBaseTypeConstraint SocketIostreamPropertyInfo = IsSocket
type AttrGetType SocketIostreamPropertyInfo = ()
type AttrLabel SocketIostreamPropertyInfo = "iostream"
type AttrOrigin SocketIostreamPropertyInfo = Socket
attrGet _ = undefined
attrSet _ = undefined
attrConstruct _ = constructSocketIostream
attrClear _ = undefined
#endif
-- VVV Prop "ipv6-only"
-- Type: TBasicType TBoolean
-- Flags: [PropertyReadable,PropertyWritable]
-- Nullable: (Nothing,Nothing)
{- |
Get the value of the “@ipv6-only@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
@
'Data.GI.Base.Attributes.get' socket #ipv6Only
@
-}
getSocketIpv6Only :: (MonadIO m, IsSocket o) => o -> m Bool
getSocketIpv6Only obj = liftIO $ B.Properties.getObjectPropertyBool obj "ipv6-only"
{- |
Set the value of the “@ipv6-only@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
@
'Data.GI.Base.Attributes.set' socket [ #ipv6Only 'Data.GI.Base.Attributes.:=' value ]
@
-}
setSocketIpv6Only :: (MonadIO m, IsSocket o) => o -> Bool -> m ()
setSocketIpv6Only obj val = liftIO $ B.Properties.setObjectPropertyBool obj "ipv6-only" val
{- |
Construct a `GValueConstruct` with valid value for the “@ipv6-only@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructSocketIpv6Only :: (IsSocket o) => Bool -> IO (GValueConstruct o)
constructSocketIpv6Only val = B.Properties.constructObjectPropertyBool "ipv6-only" val
#if ENABLE_OVERLOADING
data SocketIpv6OnlyPropertyInfo
instance AttrInfo SocketIpv6OnlyPropertyInfo where
type AttrAllowedOps SocketIpv6OnlyPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
type AttrSetTypeConstraint SocketIpv6OnlyPropertyInfo = (~) Bool
type AttrBaseTypeConstraint SocketIpv6OnlyPropertyInfo = IsSocket
type AttrGetType SocketIpv6OnlyPropertyInfo = Bool
type AttrLabel SocketIpv6OnlyPropertyInfo = "ipv6-only"
type AttrOrigin SocketIpv6OnlyPropertyInfo = Socket
attrGet _ = getSocketIpv6Only
attrSet _ = setSocketIpv6Only
attrConstruct _ = constructSocketIpv6Only
attrClear _ = undefined
#endif
-- VVV Prop "is-server"
-- Type: TBasicType TBoolean
-- Flags: [PropertyReadable]
-- Nullable: (Nothing,Nothing)
{- |
Get the value of the “@is-server@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
@
'Data.GI.Base.Attributes.get' socket #isServer
@
-}
getSocketIsServer :: (MonadIO m, IsSocket o) => o -> m Bool
getSocketIsServer obj = liftIO $ B.Properties.getObjectPropertyBool obj "is-server"
#if ENABLE_OVERLOADING
data SocketIsServerPropertyInfo
instance AttrInfo SocketIsServerPropertyInfo where
type AttrAllowedOps SocketIsServerPropertyInfo = '[ 'AttrGet]
type AttrSetTypeConstraint SocketIsServerPropertyInfo = (~) ()
type AttrBaseTypeConstraint SocketIsServerPropertyInfo = IsSocket
type AttrGetType SocketIsServerPropertyInfo = Bool
type AttrLabel SocketIsServerPropertyInfo = "is-server"
type AttrOrigin SocketIsServerPropertyInfo = Socket
attrGet _ = getSocketIsServer
attrSet _ = undefined
attrConstruct _ = undefined
attrClear _ = undefined
#endif
-- VVV Prop "local-address"
-- Type: TInterface (Name {namespace = "Soup", name = "Address"})
-- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
-- Nullable: (Just False,Nothing)
{- |
Get the value of the “@local-address@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
@
'Data.GI.Base.Attributes.get' socket #localAddress
@
-}
getSocketLocalAddress :: (MonadIO m, IsSocket o) => o -> m Soup.Address.Address
getSocketLocalAddress obj = liftIO $ checkUnexpectedNothing "getSocketLocalAddress" $ B.Properties.getObjectPropertyObject obj "local-address" Soup.Address.Address
{- |
Construct a `GValueConstruct` with valid value for the “@local-address@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructSocketLocalAddress :: (IsSocket o, Soup.Address.IsAddress a) => a -> IO (GValueConstruct o)
constructSocketLocalAddress val = B.Properties.constructObjectPropertyObject "local-address" (Just val)
#if ENABLE_OVERLOADING
data SocketLocalAddressPropertyInfo
instance AttrInfo SocketLocalAddressPropertyInfo where
type AttrAllowedOps SocketLocalAddressPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
type AttrSetTypeConstraint SocketLocalAddressPropertyInfo = Soup.Address.IsAddress
type AttrBaseTypeConstraint SocketLocalAddressPropertyInfo = IsSocket
type AttrGetType SocketLocalAddressPropertyInfo = Soup.Address.Address
type AttrLabel SocketLocalAddressPropertyInfo = "local-address"
type AttrOrigin SocketLocalAddressPropertyInfo = Socket
attrGet _ = getSocketLocalAddress
attrSet _ = undefined
attrConstruct _ = constructSocketLocalAddress
attrClear _ = undefined
#endif
-- VVV Prop "non-blocking"
-- Type: TBasicType TBoolean
-- Flags: [PropertyReadable,PropertyWritable]
-- Nullable: (Nothing,Nothing)
{- |
Get the value of the “@non-blocking@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
@
'Data.GI.Base.Attributes.get' socket #nonBlocking
@
-}
getSocketNonBlocking :: (MonadIO m, IsSocket o) => o -> m Bool
getSocketNonBlocking obj = liftIO $ B.Properties.getObjectPropertyBool obj "non-blocking"
{- |
Set the value of the “@non-blocking@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
@
'Data.GI.Base.Attributes.set' socket [ #nonBlocking 'Data.GI.Base.Attributes.:=' value ]
@
-}
setSocketNonBlocking :: (MonadIO m, IsSocket o) => o -> Bool -> m ()
setSocketNonBlocking obj val = liftIO $ B.Properties.setObjectPropertyBool obj "non-blocking" val
{- |
Construct a `GValueConstruct` with valid value for the “@non-blocking@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructSocketNonBlocking :: (IsSocket o) => Bool -> IO (GValueConstruct o)
constructSocketNonBlocking val = B.Properties.constructObjectPropertyBool "non-blocking" val
#if ENABLE_OVERLOADING
data SocketNonBlockingPropertyInfo
instance AttrInfo SocketNonBlockingPropertyInfo where
type AttrAllowedOps SocketNonBlockingPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
type AttrSetTypeConstraint SocketNonBlockingPropertyInfo = (~) Bool
type AttrBaseTypeConstraint SocketNonBlockingPropertyInfo = IsSocket
type AttrGetType SocketNonBlockingPropertyInfo = Bool
type AttrLabel SocketNonBlockingPropertyInfo = "non-blocking"
type AttrOrigin SocketNonBlockingPropertyInfo = Socket
attrGet _ = getSocketNonBlocking
attrSet _ = setSocketNonBlocking
attrConstruct _ = constructSocketNonBlocking
attrClear _ = undefined
#endif
-- VVV Prop "remote-address"
-- Type: TInterface (Name {namespace = "Soup", name = "Address"})
-- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
-- Nullable: (Just False,Nothing)
{- |
Get the value of the “@remote-address@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
@
'Data.GI.Base.Attributes.get' socket #remoteAddress
@
-}
getSocketRemoteAddress :: (MonadIO m, IsSocket o) => o -> m Soup.Address.Address
getSocketRemoteAddress obj = liftIO $ checkUnexpectedNothing "getSocketRemoteAddress" $ B.Properties.getObjectPropertyObject obj "remote-address" Soup.Address.Address
{- |
Construct a `GValueConstruct` with valid value for the “@remote-address@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructSocketRemoteAddress :: (IsSocket o, Soup.Address.IsAddress a) => a -> IO (GValueConstruct o)
constructSocketRemoteAddress val = B.Properties.constructObjectPropertyObject "remote-address" (Just val)
#if ENABLE_OVERLOADING
data SocketRemoteAddressPropertyInfo
instance AttrInfo SocketRemoteAddressPropertyInfo where
type AttrAllowedOps SocketRemoteAddressPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
type AttrSetTypeConstraint SocketRemoteAddressPropertyInfo = Soup.Address.IsAddress
type AttrBaseTypeConstraint SocketRemoteAddressPropertyInfo = IsSocket
type AttrGetType SocketRemoteAddressPropertyInfo = Soup.Address.Address
type AttrLabel SocketRemoteAddressPropertyInfo = "remote-address"
type AttrOrigin SocketRemoteAddressPropertyInfo = Socket
attrGet _ = getSocketRemoteAddress
attrSet _ = undefined
attrConstruct _ = constructSocketRemoteAddress
attrClear _ = undefined
#endif
-- VVV Prop "ssl-creds"
-- Type: TBasicType TPtr
-- Flags: [PropertyReadable,PropertyWritable]
-- Nullable: (Nothing,Nothing)
{- |
Get the value of the “@ssl-creds@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
@
'Data.GI.Base.Attributes.get' socket #sslCreds
@
-}
getSocketSslCreds :: (MonadIO m, IsSocket o) => o -> m (Ptr ())
getSocketSslCreds obj = liftIO $ B.Properties.getObjectPropertyPtr obj "ssl-creds"
{- |
Set the value of the “@ssl-creds@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
@
'Data.GI.Base.Attributes.set' socket [ #sslCreds 'Data.GI.Base.Attributes.:=' value ]
@
-}
setSocketSslCreds :: (MonadIO m, IsSocket o) => o -> Ptr () -> m ()
setSocketSslCreds obj val = liftIO $ B.Properties.setObjectPropertyPtr obj "ssl-creds" val
{- |
Construct a `GValueConstruct` with valid value for the “@ssl-creds@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructSocketSslCreds :: (IsSocket o) => Ptr () -> IO (GValueConstruct o)
constructSocketSslCreds val = B.Properties.constructObjectPropertyPtr "ssl-creds" val
#if ENABLE_OVERLOADING
data SocketSslCredsPropertyInfo
instance AttrInfo SocketSslCredsPropertyInfo where
type AttrAllowedOps SocketSslCredsPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
type AttrSetTypeConstraint SocketSslCredsPropertyInfo = (~) (Ptr ())
type AttrBaseTypeConstraint SocketSslCredsPropertyInfo = IsSocket
type AttrGetType SocketSslCredsPropertyInfo = (Ptr ())
type AttrLabel SocketSslCredsPropertyInfo = "ssl-creds"
type AttrOrigin SocketSslCredsPropertyInfo = Socket
attrGet _ = getSocketSslCreds
attrSet _ = setSocketSslCreds
attrConstruct _ = constructSocketSslCreds
attrClear _ = undefined
#endif
-- VVV Prop "ssl-fallback"
-- Type: TBasicType TBoolean
-- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
-- Nullable: (Nothing,Nothing)
{- |
Get the value of the “@ssl-fallback@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
@
'Data.GI.Base.Attributes.get' socket #sslFallback
@
-}
getSocketSslFallback :: (MonadIO m, IsSocket o) => o -> m Bool
getSocketSslFallback obj = liftIO $ B.Properties.getObjectPropertyBool obj "ssl-fallback"
{- |
Construct a `GValueConstruct` with valid value for the “@ssl-fallback@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructSocketSslFallback :: (IsSocket o) => Bool -> IO (GValueConstruct o)
constructSocketSslFallback val = B.Properties.constructObjectPropertyBool "ssl-fallback" val
#if ENABLE_OVERLOADING
data SocketSslFallbackPropertyInfo
instance AttrInfo SocketSslFallbackPropertyInfo where
type AttrAllowedOps SocketSslFallbackPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
type AttrSetTypeConstraint SocketSslFallbackPropertyInfo = (~) Bool
type AttrBaseTypeConstraint SocketSslFallbackPropertyInfo = IsSocket
type AttrGetType SocketSslFallbackPropertyInfo = Bool
type AttrLabel SocketSslFallbackPropertyInfo = "ssl-fallback"
type AttrOrigin SocketSslFallbackPropertyInfo = Socket
attrGet _ = getSocketSslFallback
attrSet _ = undefined
attrConstruct _ = constructSocketSslFallback
attrClear _ = undefined
#endif
-- VVV Prop "ssl-strict"
-- Type: TBasicType TBoolean
-- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
-- Nullable: (Nothing,Nothing)
{- |
Get the value of the “@ssl-strict@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
@
'Data.GI.Base.Attributes.get' socket #sslStrict
@
-}
getSocketSslStrict :: (MonadIO m, IsSocket o) => o -> m Bool
getSocketSslStrict obj = liftIO $ B.Properties.getObjectPropertyBool obj "ssl-strict"
{- |
Construct a `GValueConstruct` with valid value for the “@ssl-strict@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructSocketSslStrict :: (IsSocket o) => Bool -> IO (GValueConstruct o)
constructSocketSslStrict val = B.Properties.constructObjectPropertyBool "ssl-strict" val
#if ENABLE_OVERLOADING
data SocketSslStrictPropertyInfo
instance AttrInfo SocketSslStrictPropertyInfo where
type AttrAllowedOps SocketSslStrictPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
type AttrSetTypeConstraint SocketSslStrictPropertyInfo = (~) Bool
type AttrBaseTypeConstraint SocketSslStrictPropertyInfo = IsSocket
type AttrGetType SocketSslStrictPropertyInfo = Bool
type AttrLabel SocketSslStrictPropertyInfo = "ssl-strict"
type AttrOrigin SocketSslStrictPropertyInfo = Socket
attrGet _ = getSocketSslStrict
attrSet _ = undefined
attrConstruct _ = constructSocketSslStrict
attrClear _ = undefined
#endif
-- VVV Prop "timeout"
-- Type: TBasicType TUInt
-- Flags: [PropertyReadable,PropertyWritable]
-- Nullable: (Nothing,Nothing)
{- |
Get the value of the “@timeout@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
@
'Data.GI.Base.Attributes.get' socket #timeout
@
-}
getSocketTimeout :: (MonadIO m, IsSocket o) => o -> m Word32
getSocketTimeout obj = liftIO $ B.Properties.getObjectPropertyUInt32 obj "timeout"
{- |
Set the value of the “@timeout@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
@
'Data.GI.Base.Attributes.set' socket [ #timeout 'Data.GI.Base.Attributes.:=' value ]
@
-}
setSocketTimeout :: (MonadIO m, IsSocket o) => o -> Word32 -> m ()
setSocketTimeout obj val = liftIO $ B.Properties.setObjectPropertyUInt32 obj "timeout" val
{- |
Construct a `GValueConstruct` with valid value for the “@timeout@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructSocketTimeout :: (IsSocket o) => Word32 -> IO (GValueConstruct o)
constructSocketTimeout val = B.Properties.constructObjectPropertyUInt32 "timeout" val
#if ENABLE_OVERLOADING
data SocketTimeoutPropertyInfo
instance AttrInfo SocketTimeoutPropertyInfo where
type AttrAllowedOps SocketTimeoutPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
type AttrSetTypeConstraint SocketTimeoutPropertyInfo = (~) Word32
type AttrBaseTypeConstraint SocketTimeoutPropertyInfo = IsSocket
type AttrGetType SocketTimeoutPropertyInfo = Word32
type AttrLabel SocketTimeoutPropertyInfo = "timeout"
type AttrOrigin SocketTimeoutPropertyInfo = Socket
attrGet _ = getSocketTimeout
attrSet _ = setSocketTimeout
attrConstruct _ = constructSocketTimeout
attrClear _ = undefined
#endif
-- VVV Prop "tls-certificate"
-- Type: TInterface (Name {namespace = "Gio", name = "TlsCertificate"})
-- Flags: [PropertyReadable]
-- Nullable: (Nothing,Nothing)
{- |
Get the value of the “@tls-certificate@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
@
'Data.GI.Base.Attributes.get' socket #tlsCertificate
@
-}
getSocketTlsCertificate :: (MonadIO m, IsSocket o) => o -> m (Maybe Gio.TlsCertificate.TlsCertificate)
getSocketTlsCertificate obj = liftIO $ B.Properties.getObjectPropertyObject obj "tls-certificate" Gio.TlsCertificate.TlsCertificate
#if ENABLE_OVERLOADING
data SocketTlsCertificatePropertyInfo
instance AttrInfo SocketTlsCertificatePropertyInfo where
type AttrAllowedOps SocketTlsCertificatePropertyInfo = '[ 'AttrGet, 'AttrClear]
type AttrSetTypeConstraint SocketTlsCertificatePropertyInfo = (~) ()
type AttrBaseTypeConstraint SocketTlsCertificatePropertyInfo = IsSocket
type AttrGetType SocketTlsCertificatePropertyInfo = (Maybe Gio.TlsCertificate.TlsCertificate)
type AttrLabel SocketTlsCertificatePropertyInfo = "tls-certificate"
type AttrOrigin SocketTlsCertificatePropertyInfo = Socket
attrGet _ = getSocketTlsCertificate
attrSet _ = undefined
attrConstruct _ = undefined
attrClear _ = undefined
#endif
-- VVV Prop "tls-errors"
-- Type: TInterface (Name {namespace = "Gio", name = "TlsCertificateFlags"})
-- Flags: [PropertyReadable]
-- Nullable: (Nothing,Nothing)
{- |
Get the value of the “@tls-errors@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
@
'Data.GI.Base.Attributes.get' socket #tlsErrors
@
-}
getSocketTlsErrors :: (MonadIO m, IsSocket o) => o -> m [Gio.Flags.TlsCertificateFlags]
getSocketTlsErrors obj = liftIO $ B.Properties.getObjectPropertyFlags obj "tls-errors"
#if ENABLE_OVERLOADING
data SocketTlsErrorsPropertyInfo
instance AttrInfo SocketTlsErrorsPropertyInfo where
type AttrAllowedOps SocketTlsErrorsPropertyInfo = '[ 'AttrGet]
type AttrSetTypeConstraint SocketTlsErrorsPropertyInfo = (~) ()
type AttrBaseTypeConstraint SocketTlsErrorsPropertyInfo = IsSocket
type AttrGetType SocketTlsErrorsPropertyInfo = [Gio.Flags.TlsCertificateFlags]
type AttrLabel SocketTlsErrorsPropertyInfo = "tls-errors"
type AttrOrigin SocketTlsErrorsPropertyInfo = Socket
attrGet _ = getSocketTlsErrors
attrSet _ = undefined
attrConstruct _ = undefined
attrClear _ = undefined
#endif
-- VVV Prop "trusted-certificate"
-- Type: TBasicType TBoolean
-- Flags: [PropertyReadable]
-- Nullable: (Nothing,Nothing)
{- |
Get the value of the “@trusted-certificate@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
@
'Data.GI.Base.Attributes.get' socket #trustedCertificate
@
-}
getSocketTrustedCertificate :: (MonadIO m, IsSocket o) => o -> m Bool
getSocketTrustedCertificate obj = liftIO $ B.Properties.getObjectPropertyBool obj "trusted-certificate"
#if ENABLE_OVERLOADING
data SocketTrustedCertificatePropertyInfo
instance AttrInfo SocketTrustedCertificatePropertyInfo where
type AttrAllowedOps SocketTrustedCertificatePropertyInfo = '[ 'AttrGet]
type AttrSetTypeConstraint SocketTrustedCertificatePropertyInfo = (~) ()
type AttrBaseTypeConstraint SocketTrustedCertificatePropertyInfo = IsSocket
type AttrGetType SocketTrustedCertificatePropertyInfo = Bool
type AttrLabel SocketTrustedCertificatePropertyInfo = "trusted-certificate"
type AttrOrigin SocketTrustedCertificatePropertyInfo = Socket
attrGet _ = getSocketTrustedCertificate
attrSet _ = undefined
attrConstruct _ = undefined
attrClear _ = undefined
#endif
-- VVV Prop "use-thread-context"
-- Type: TBasicType TBoolean
-- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
-- Nullable: (Nothing,Nothing)
{- |
Get the value of the “@use-thread-context@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
@
'Data.GI.Base.Attributes.get' socket #useThreadContext
@
-}
getSocketUseThreadContext :: (MonadIO m, IsSocket o) => o -> m Bool
getSocketUseThreadContext obj = liftIO $ B.Properties.getObjectPropertyBool obj "use-thread-context"
{- |
Construct a `GValueConstruct` with valid value for the “@use-thread-context@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructSocketUseThreadContext :: (IsSocket o) => Bool -> IO (GValueConstruct o)
constructSocketUseThreadContext val = B.Properties.constructObjectPropertyBool "use-thread-context" val
#if ENABLE_OVERLOADING
data SocketUseThreadContextPropertyInfo
instance AttrInfo SocketUseThreadContextPropertyInfo where
type AttrAllowedOps SocketUseThreadContextPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
type AttrSetTypeConstraint SocketUseThreadContextPropertyInfo = (~) Bool
type AttrBaseTypeConstraint SocketUseThreadContextPropertyInfo = IsSocket
type AttrGetType SocketUseThreadContextPropertyInfo = Bool
type AttrLabel SocketUseThreadContextPropertyInfo = "use-thread-context"
type AttrOrigin SocketUseThreadContextPropertyInfo = Socket
attrGet _ = getSocketUseThreadContext
attrSet _ = undefined
attrConstruct _ = constructSocketUseThreadContext
attrClear _ = undefined
#endif
#if ENABLE_OVERLOADING
instance O.HasAttributeList Socket
type instance O.AttributeList Socket = SocketAttributeList
type SocketAttributeList = ('[ '("asyncContext", SocketAsyncContextPropertyInfo), '("fd", SocketFdPropertyInfo), '("gsocket", SocketGsocketPropertyInfo), '("iostream", SocketIostreamPropertyInfo), '("ipv6Only", SocketIpv6OnlyPropertyInfo), '("isServer", SocketIsServerPropertyInfo), '("localAddress", SocketLocalAddressPropertyInfo), '("nonBlocking", SocketNonBlockingPropertyInfo), '("remoteAddress", SocketRemoteAddressPropertyInfo), '("sslCreds", SocketSslCredsPropertyInfo), '("sslFallback", SocketSslFallbackPropertyInfo), '("sslStrict", SocketSslStrictPropertyInfo), '("timeout", SocketTimeoutPropertyInfo), '("tlsCertificate", SocketTlsCertificatePropertyInfo), '("tlsErrors", SocketTlsErrorsPropertyInfo), '("trustedCertificate", SocketTrustedCertificatePropertyInfo), '("useThreadContext", SocketUseThreadContextPropertyInfo)] :: [(Symbol, *)])
#endif
#if ENABLE_OVERLOADING
socketAsyncContext :: AttrLabelProxy "asyncContext"
socketAsyncContext = AttrLabelProxy
socketFd :: AttrLabelProxy "fd"
socketFd = AttrLabelProxy
socketGsocket :: AttrLabelProxy "gsocket"
socketGsocket = AttrLabelProxy
socketIostream :: AttrLabelProxy "iostream"
socketIostream = AttrLabelProxy
socketIpv6Only :: AttrLabelProxy "ipv6Only"
socketIpv6Only = AttrLabelProxy
socketIsServer :: AttrLabelProxy "isServer"
socketIsServer = AttrLabelProxy
socketLocalAddress :: AttrLabelProxy "localAddress"
socketLocalAddress = AttrLabelProxy
socketNonBlocking :: AttrLabelProxy "nonBlocking"
socketNonBlocking = AttrLabelProxy
socketRemoteAddress :: AttrLabelProxy "remoteAddress"
socketRemoteAddress = AttrLabelProxy
socketSslCreds :: AttrLabelProxy "sslCreds"
socketSslCreds = AttrLabelProxy
socketSslFallback :: AttrLabelProxy "sslFallback"
socketSslFallback = AttrLabelProxy
socketSslStrict :: AttrLabelProxy "sslStrict"
socketSslStrict = AttrLabelProxy
socketTimeout :: AttrLabelProxy "timeout"
socketTimeout = AttrLabelProxy
socketTlsCertificate :: AttrLabelProxy "tlsCertificate"
socketTlsCertificate = AttrLabelProxy
socketTlsErrors :: AttrLabelProxy "tlsErrors"
socketTlsErrors = AttrLabelProxy
socketTrustedCertificate :: AttrLabelProxy "trustedCertificate"
socketTrustedCertificate = AttrLabelProxy
socketUseThreadContext :: AttrLabelProxy "useThreadContext"
socketUseThreadContext = AttrLabelProxy
#endif
#if ENABLE_OVERLOADING
data SocketDisconnectedSignalInfo
instance SignalInfo SocketDisconnectedSignalInfo where
type HaskellCallbackType SocketDisconnectedSignalInfo = SocketDisconnectedCallback
connectSignal _ obj cb connectMode = do
let cb' = wrap_SocketDisconnectedCallback cb
cb'' <- mk_SocketDisconnectedCallback cb'
connectSignalFunPtr obj "disconnected" cb'' connectMode
data SocketEventSignalInfo
instance SignalInfo SocketEventSignalInfo where
type HaskellCallbackType SocketEventSignalInfo = SocketEventCallback
connectSignal _ obj cb connectMode = do
let cb' = wrap_SocketEventCallback cb
cb'' <- mk_SocketEventCallback cb'
connectSignalFunPtr obj "event" cb'' connectMode
data SocketNewConnectionSignalInfo
instance SignalInfo SocketNewConnectionSignalInfo where
type HaskellCallbackType SocketNewConnectionSignalInfo = SocketNewConnectionCallback
connectSignal _ obj cb connectMode = do
let cb' = wrap_SocketNewConnectionCallback cb
cb'' <- mk_SocketNewConnectionCallback cb'
connectSignalFunPtr obj "new-connection" cb'' connectMode
data SocketReadableSignalInfo
instance SignalInfo SocketReadableSignalInfo where
type HaskellCallbackType SocketReadableSignalInfo = SocketReadableCallback
connectSignal _ obj cb connectMode = do
let cb' = wrap_SocketReadableCallback cb
cb'' <- mk_SocketReadableCallback cb'
connectSignalFunPtr obj "readable" cb'' connectMode
data SocketWritableSignalInfo
instance SignalInfo SocketWritableSignalInfo where
type HaskellCallbackType SocketWritableSignalInfo = SocketWritableCallback
connectSignal _ obj cb connectMode = do
let cb' = wrap_SocketWritableCallback cb
cb'' <- mk_SocketWritableCallback cb'
connectSignalFunPtr obj "writable" cb'' connectMode
type instance O.SignalList Socket = SocketSignalList
type SocketSignalList = ('[ '("disconnected", SocketDisconnectedSignalInfo), '("event", SocketEventSignalInfo), '("newConnection", SocketNewConnectionSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo), '("readable", SocketReadableSignalInfo), '("writable", SocketWritableSignalInfo)] :: [(Symbol, *)])
#endif
-- method Socket::connect_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "sock", argType = TInterface (Name {namespace = "Soup", name = "Socket"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a client #SoupSocket (which must not already be connected)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GCancellable, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Soup", name = "SocketCallback"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "callback to call after connecting", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 3, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "data to pass to @callback", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False
foreign import ccall "soup_socket_connect_async" soup_socket_connect_async ::
Ptr Socket -> -- sock : TInterface (Name {namespace = "Soup", name = "Socket"})
Ptr Gio.Cancellable.Cancellable -> -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
FunPtr Soup.Callbacks.C_SocketCallback -> -- callback : TInterface (Name {namespace = "Soup", name = "SocketCallback"})
Ptr () -> -- user_data : TBasicType TPtr
IO ()
{- |
Begins asynchronously connecting to /@sock@/\'s remote address. The
socket will call /@callback@/ when it succeeds or fails (but not
before returning from this function).
If /@cancellable@/ is non-'Nothing', it can be used to cancel the
connection. /@callback@/ will still be invoked in this case, with a
status of 'GI.Soup.Enums.StatusCancelled'.
-}
socketConnectAsync ::
(B.CallStack.HasCallStack, MonadIO m, IsSocket a, Gio.Cancellable.IsCancellable b) =>
a
{- ^ /@sock@/: a client 'GI.Soup.Objects.Socket.Socket' (which must not already be connected) -}
-> Maybe (b)
{- ^ /@cancellable@/: a 'GI.Gio.Objects.Cancellable.Cancellable', or 'Nothing' -}
-> Soup.Callbacks.SocketCallback
{- ^ /@callback@/: callback to call after connecting -}
-> m ()
socketConnectAsync sock cancellable callback = liftIO $ do
sock' <- unsafeManagedPtrCastPtr sock
maybeCancellable <- case cancellable of
Nothing -> return nullPtr
Just jCancellable -> do
jCancellable' <- unsafeManagedPtrCastPtr jCancellable
return jCancellable'
ptrcallback <- callocMem :: IO (Ptr (FunPtr Soup.Callbacks.C_SocketCallback))
callback' <- Soup.Callbacks.mk_SocketCallback (Soup.Callbacks.wrap_SocketCallback (Just ptrcallback) (Soup.Callbacks.drop_closures_SocketCallback callback))
poke ptrcallback callback'
let userData = nullPtr
soup_socket_connect_async sock' maybeCancellable callback' userData
touchManagedPtr sock
whenJust cancellable touchManagedPtr
return ()
#if ENABLE_OVERLOADING
data SocketConnectAsyncMethodInfo
instance (signature ~ (Maybe (b) -> Soup.Callbacks.SocketCallback -> m ()), MonadIO m, IsSocket a, Gio.Cancellable.IsCancellable b) => O.MethodInfo SocketConnectAsyncMethodInfo a signature where
overloadedMethod _ = socketConnectAsync
#endif
-- method Socket::connect_sync
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "sock", argType = TInterface (Name {namespace = "Soup", name = "Socket"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a client #SoupSocket (which must not already be connected)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GCancellable, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt)
-- throws : False
-- Skip return : False
foreign import ccall "soup_socket_connect_sync" soup_socket_connect_sync ::
Ptr Socket -> -- sock : TInterface (Name {namespace = "Soup", name = "Socket"})
Ptr Gio.Cancellable.Cancellable -> -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
IO Word32
{- |
Attempt to synchronously connect /@sock@/ to its remote address.
If /@cancellable@/ is non-'Nothing', it can be used to cancel the
connection, in which case 'GI.Soup.Objects.Socket.socketConnectSync' will return
'GI.Soup.Enums.StatusCancelled'.
-}
socketConnectSync ::
(B.CallStack.HasCallStack, MonadIO m, IsSocket a, Gio.Cancellable.IsCancellable b) =>
a
{- ^ /@sock@/: a client 'GI.Soup.Objects.Socket.Socket' (which must not already be connected) -}
-> Maybe (b)
{- ^ /@cancellable@/: a 'GI.Gio.Objects.Cancellable.Cancellable', or 'Nothing' -}
-> m Word32
{- ^ __Returns:__ a success or failure code. -}
socketConnectSync sock cancellable = liftIO $ do
sock' <- unsafeManagedPtrCastPtr sock
maybeCancellable <- case cancellable of
Nothing -> return nullPtr
Just jCancellable -> do
jCancellable' <- unsafeManagedPtrCastPtr jCancellable
return jCancellable'
result <- soup_socket_connect_sync sock' maybeCancellable
touchManagedPtr sock
whenJust cancellable touchManagedPtr
return result
#if ENABLE_OVERLOADING
data SocketConnectSyncMethodInfo
instance (signature ~ (Maybe (b) -> m Word32), MonadIO m, IsSocket a, Gio.Cancellable.IsCancellable b) => O.MethodInfo SocketConnectSyncMethodInfo a signature where
overloadedMethod _ = socketConnectSync
#endif
-- method Socket::disconnect
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "sock", argType = TInterface (Name {namespace = "Soup", name = "Socket"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupSocket", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False
foreign import ccall "soup_socket_disconnect" soup_socket_disconnect ::
Ptr Socket -> -- sock : TInterface (Name {namespace = "Soup", name = "Socket"})
IO ()
{- |
Disconnects /@sock@/. Any further read or write attempts on it will
fail.
-}
socketDisconnect ::
(B.CallStack.HasCallStack, MonadIO m, IsSocket a) =>
a
{- ^ /@sock@/: a 'GI.Soup.Objects.Socket.Socket' -}
-> m ()
socketDisconnect sock = liftIO $ do
sock' <- unsafeManagedPtrCastPtr sock
soup_socket_disconnect sock'
touchManagedPtr sock
return ()
#if ENABLE_OVERLOADING
data SocketDisconnectMethodInfo
instance (signature ~ (m ()), MonadIO m, IsSocket a) => O.MethodInfo SocketDisconnectMethodInfo a signature where
overloadedMethod _ = socketDisconnect
#endif
-- method Socket::get_fd
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "sock", argType = TInterface (Name {namespace = "Soup", name = "Socket"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupSocket", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False
foreign import ccall "soup_socket_get_fd" soup_socket_get_fd ::
Ptr Socket -> -- sock : TInterface (Name {namespace = "Soup", name = "Socket"})
IO Int32
{- |
Gets /@sock@/\'s underlying file descriptor.
Note that fiddling with the file descriptor may break the
'GI.Soup.Objects.Socket.Socket'.
-}
socketGetFd ::
(B.CallStack.HasCallStack, MonadIO m, IsSocket a) =>
a
{- ^ /@sock@/: a 'GI.Soup.Objects.Socket.Socket' -}
-> m Int32
{- ^ __Returns:__ /@sock@/\'s file descriptor. -}
socketGetFd sock = liftIO $ do
sock' <- unsafeManagedPtrCastPtr sock
result <- soup_socket_get_fd sock'
touchManagedPtr sock
return result
#if ENABLE_OVERLOADING
data SocketGetFdMethodInfo
instance (signature ~ (m Int32), MonadIO m, IsSocket a) => O.MethodInfo SocketGetFdMethodInfo a signature where
overloadedMethod _ = socketGetFd
#endif
-- method Socket::get_local_address
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "sock", argType = TInterface (Name {namespace = "Soup", name = "Socket"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupSocket", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Soup", name = "Address"}))
-- throws : False
-- Skip return : False
foreign import ccall "soup_socket_get_local_address" soup_socket_get_local_address ::
Ptr Socket -> -- sock : TInterface (Name {namespace = "Soup", name = "Socket"})
IO (Ptr Soup.Address.Address)
{- |
Returns the 'GI.Soup.Objects.Address.Address' corresponding to the local end of /@sock@/.
Calling this method on an unconnected socket is considered to be
an error, and produces undefined results.
-}
socketGetLocalAddress ::
(B.CallStack.HasCallStack, MonadIO m, IsSocket a) =>
a
{- ^ /@sock@/: a 'GI.Soup.Objects.Socket.Socket' -}
-> m Soup.Address.Address
{- ^ __Returns:__ the 'GI.Soup.Objects.Address.Address' -}
socketGetLocalAddress sock = liftIO $ do
sock' <- unsafeManagedPtrCastPtr sock
result <- soup_socket_get_local_address sock'
checkUnexpectedReturnNULL "socketGetLocalAddress" result
result' <- (newObject Soup.Address.Address) result
touchManagedPtr sock
return result'
#if ENABLE_OVERLOADING
data SocketGetLocalAddressMethodInfo
instance (signature ~ (m Soup.Address.Address), MonadIO m, IsSocket a) => O.MethodInfo SocketGetLocalAddressMethodInfo a signature where
overloadedMethod _ = socketGetLocalAddress
#endif
-- method Socket::get_remote_address
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "sock", argType = TInterface (Name {namespace = "Soup", name = "Socket"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupSocket", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Soup", name = "Address"}))
-- throws : False
-- Skip return : False
foreign import ccall "soup_socket_get_remote_address" soup_socket_get_remote_address ::
Ptr Socket -> -- sock : TInterface (Name {namespace = "Soup", name = "Socket"})
IO (Ptr Soup.Address.Address)
{- |
Returns the 'GI.Soup.Objects.Address.Address' corresponding to the remote end of /@sock@/.
Calling this method on an unconnected socket is considered to be
an error, and produces undefined results.
-}
socketGetRemoteAddress ::
(B.CallStack.HasCallStack, MonadIO m, IsSocket a) =>
a
{- ^ /@sock@/: a 'GI.Soup.Objects.Socket.Socket' -}
-> m Soup.Address.Address
{- ^ __Returns:__ the 'GI.Soup.Objects.Address.Address' -}
socketGetRemoteAddress sock = liftIO $ do
sock' <- unsafeManagedPtrCastPtr sock
result <- soup_socket_get_remote_address sock'
checkUnexpectedReturnNULL "socketGetRemoteAddress" result
result' <- (newObject Soup.Address.Address) result
touchManagedPtr sock
return result'
#if ENABLE_OVERLOADING
data SocketGetRemoteAddressMethodInfo
instance (signature ~ (m Soup.Address.Address), MonadIO m, IsSocket a) => O.MethodInfo SocketGetRemoteAddressMethodInfo a signature where
overloadedMethod _ = socketGetRemoteAddress
#endif
-- method Socket::is_connected
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "sock", argType = TInterface (Name {namespace = "Soup", name = "Socket"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupSocket", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False
foreign import ccall "soup_socket_is_connected" soup_socket_is_connected ::
Ptr Socket -> -- sock : TInterface (Name {namespace = "Soup", name = "Socket"})
IO CInt
{- |
Tests if /@sock@/ is connected to another host
-}
socketIsConnected ::
(B.CallStack.HasCallStack, MonadIO m, IsSocket a) =>
a
{- ^ /@sock@/: a 'GI.Soup.Objects.Socket.Socket' -}
-> m Bool
{- ^ __Returns:__ 'True' or 'False'. -}
socketIsConnected sock = liftIO $ do
sock' <- unsafeManagedPtrCastPtr sock
result <- soup_socket_is_connected sock'
let result' = (/= 0) result
touchManagedPtr sock
return result'
#if ENABLE_OVERLOADING
data SocketIsConnectedMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsSocket a) => O.MethodInfo SocketIsConnectedMethodInfo a signature where
overloadedMethod _ = socketIsConnected
#endif
-- method Socket::is_ssl
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "sock", argType = TInterface (Name {namespace = "Soup", name = "Socket"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupSocket", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False
foreign import ccall "soup_socket_is_ssl" soup_socket_is_ssl ::
Ptr Socket -> -- sock : TInterface (Name {namespace = "Soup", name = "Socket"})
IO CInt
{- |
Tests if /@sock@/ is doing (or has attempted to do) SSL.
-}
socketIsSsl ::
(B.CallStack.HasCallStack, MonadIO m, IsSocket a) =>
a
{- ^ /@sock@/: a 'GI.Soup.Objects.Socket.Socket' -}
-> m Bool
{- ^ __Returns:__ 'True' if /@sock@/ has SSL credentials set -}
socketIsSsl sock = liftIO $ do
sock' <- unsafeManagedPtrCastPtr sock
result <- soup_socket_is_ssl sock'
let result' = (/= 0) result
touchManagedPtr sock
return result'
#if ENABLE_OVERLOADING
data SocketIsSslMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsSocket a) => O.MethodInfo SocketIsSslMethodInfo a signature where
overloadedMethod _ = socketIsSsl
#endif
-- method Socket::listen
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "sock", argType = TInterface (Name {namespace = "Soup", name = "Socket"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a server #SoupSocket (which must not already be connected or\nlistening)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False
foreign import ccall "soup_socket_listen" soup_socket_listen ::
Ptr Socket -> -- sock : TInterface (Name {namespace = "Soup", name = "Socket"})
IO CInt
{- |
Makes /@sock@/ start listening on its local address. When connections
come in, /@sock@/ will emit 'GI.Soup.Objects.Socket.Socket'::@/new_connection/@.
-}
socketListen ::
(B.CallStack.HasCallStack, MonadIO m, IsSocket a) =>
a
{- ^ /@sock@/: a server 'GI.Soup.Objects.Socket.Socket' (which must not already be connected or
listening) -}
-> m Bool
{- ^ __Returns:__ whether or not /@sock@/ is now listening. -}
socketListen sock = liftIO $ do
sock' <- unsafeManagedPtrCastPtr sock
result <- soup_socket_listen sock'
let result' = (/= 0) result
touchManagedPtr sock
return result'
#if ENABLE_OVERLOADING
data SocketListenMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsSocket a) => O.MethodInfo SocketListenMethodInfo a signature where
overloadedMethod _ = socketListen
#endif
-- method Socket::read
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "sock", argType = TInterface (Name {namespace = "Soup", name = "Socket"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the socket", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "buffer", argType = TCArray False (-1) 2 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "buffer to read\n into", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "size of @buffer in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "nread", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "on return, the number of bytes read into @buffer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GCancellable, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "len", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "size of @buffer in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Just (TInterface (Name {namespace = "Soup", name = "SocketIOStatus"}))
-- throws : True
-- Skip return : False
foreign import ccall "soup_socket_read" soup_socket_read ::
Ptr Socket -> -- sock : TInterface (Name {namespace = "Soup", name = "Socket"})
Ptr Word8 -> -- buffer : TCArray False (-1) 2 (TBasicType TUInt8)
Word64 -> -- len : TBasicType TUInt64
Ptr Word64 -> -- nread : TBasicType TUInt64
Ptr Gio.Cancellable.Cancellable -> -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
Ptr (Ptr GError) -> -- error
IO CUInt
{- |
Attempts to read up to /@len@/ bytes from /@sock@/ into /@buffer@/. If some
data is successfully read, 'GI.Soup.Objects.Socket.socketRead' will return
'GI.Soup.Enums.SocketIOStatusOk', and */@nread@/ will contain the number of bytes
actually read (which may be less than /@len@/).
If /@sock@/ is non-blocking, and no data is available, the return
value will be 'GI.Soup.Enums.SocketIOStatusWouldBlock'. In this case, the caller
can connect to the 'GI.Soup.Objects.Socket.Socket'::@/readable/@ signal to know when there
is more data to read. (NB: You MUST read all available data off the
socket first. 'GI.Soup.Objects.Socket.Socket'::@/readable/@ is only emitted after
'GI.Soup.Objects.Socket.socketRead' returns 'GI.Soup.Enums.SocketIOStatusWouldBlock', and it is only
emitted once. See the documentation for 'GI.Soup.Objects.Socket.Socket':@/non-blocking/@.)
-}
socketRead ::
(B.CallStack.HasCallStack, MonadIO m, IsSocket a, Gio.Cancellable.IsCancellable b) =>
a
{- ^ /@sock@/: the socket -}
-> ByteString
{- ^ /@buffer@/: buffer to read
into -}
-> Maybe (b)
{- ^ /@cancellable@/: a 'GI.Gio.Objects.Cancellable.Cancellable', or 'Nothing' -}
-> m ((Soup.Enums.SocketIOStatus, Word64))
{- ^ __Returns:__ a 'GI.Soup.Enums.SocketIOStatus', as described above (or
'GI.Soup.Enums.SocketIOStatusEof' if the socket is no longer connected, or
'GI.Soup.Enums.SocketIOStatusError' on any other error, in which case /@error@/ will
also be set). /(Can throw 'Data.GI.Base.GError.GError')/ -}
socketRead sock buffer cancellable = liftIO $ do
let len = fromIntegral $ B.length buffer
sock' <- unsafeManagedPtrCastPtr sock
buffer' <- packByteString buffer
nread <- allocMem :: IO (Ptr Word64)
maybeCancellable <- case cancellable of
Nothing -> return nullPtr
Just jCancellable -> do
jCancellable' <- unsafeManagedPtrCastPtr jCancellable
return jCancellable'
onException (do
result <- propagateGError $ soup_socket_read sock' buffer' len nread maybeCancellable
let result' = (toEnum . fromIntegral) result
nread' <- peek nread
touchManagedPtr sock
whenJust cancellable touchManagedPtr
freeMem buffer'
freeMem nread
return (result', nread')
) (do
freeMem buffer'
freeMem nread
)
#if ENABLE_OVERLOADING
data SocketReadMethodInfo
instance (signature ~ (ByteString -> Maybe (b) -> m ((Soup.Enums.SocketIOStatus, Word64))), MonadIO m, IsSocket a, Gio.Cancellable.IsCancellable b) => O.MethodInfo SocketReadMethodInfo a signature where
overloadedMethod _ = socketRead
#endif
-- method Socket::read_until
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "sock", argType = TInterface (Name {namespace = "Soup", name = "Socket"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the socket", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "buffer", argType = TCArray False (-1) 2 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "buffer to read\n into", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "size of @buffer in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "boundary", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "boundary to read until", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "boundary_len", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of @boundary in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "nread", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "on return, the number of bytes read into @buffer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "got_boundary", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "on return, whether or not the data in @buffer\nends with the boundary string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GCancellable, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "len", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "size of @buffer in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Just (TInterface (Name {namespace = "Soup", name = "SocketIOStatus"}))
-- throws : True
-- Skip return : False
foreign import ccall "soup_socket_read_until" soup_socket_read_until ::
Ptr Socket -> -- sock : TInterface (Name {namespace = "Soup", name = "Socket"})
Ptr Word8 -> -- buffer : TCArray False (-1) 2 (TBasicType TUInt8)
Word64 -> -- len : TBasicType TUInt64
Ptr () -> -- boundary : TBasicType TPtr
Word64 -> -- boundary_len : TBasicType TUInt64
Ptr Word64 -> -- nread : TBasicType TUInt64
CInt -> -- got_boundary : TBasicType TBoolean
Ptr Gio.Cancellable.Cancellable -> -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
Ptr (Ptr GError) -> -- error
IO CUInt
{- |
Like 'GI.Soup.Objects.Socket.socketRead', but reads no further than the first
occurrence of /@boundary@/. (If the boundary is found, it will be
included in the returned data, and */@gotBoundary@/ will be set to
'True'.) Any data after the boundary will returned in future reads.
'GI.Soup.Objects.Socket.socketReadUntil' will almost always return fewer than /@len@/
bytes: if the boundary is found, then it will only return the bytes
up until the end of the boundary, and if the boundary is not found,
then it will leave the last \<literal>(boundary_len - 1)\<\/literal>
bytes in its internal buffer, in case they form the start of the
boundary string. Thus, /@len@/ normally needs to be at least 1 byte
longer than /@boundaryLen@/ if you want to make any progress at all.
-}
socketReadUntil ::
(B.CallStack.HasCallStack, MonadIO m, IsSocket a, Gio.Cancellable.IsCancellable b) =>
a
{- ^ /@sock@/: the socket -}
-> ByteString
{- ^ /@buffer@/: buffer to read
into -}
-> Ptr ()
{- ^ /@boundary@/: boundary to read until -}
-> Word64
{- ^ /@boundaryLen@/: length of /@boundary@/ in bytes -}
-> Bool
{- ^ /@gotBoundary@/: on return, whether or not the data in /@buffer@/
ends with the boundary string -}
-> Maybe (b)
{- ^ /@cancellable@/: a 'GI.Gio.Objects.Cancellable.Cancellable', or 'Nothing' -}
-> m ((Soup.Enums.SocketIOStatus, Word64))
{- ^ __Returns:__ as for 'GI.Soup.Objects.Socket.socketRead' /(Can throw 'Data.GI.Base.GError.GError')/ -}
socketReadUntil sock buffer boundary boundaryLen gotBoundary cancellable = liftIO $ do
let len = fromIntegral $ B.length buffer
sock' <- unsafeManagedPtrCastPtr sock
buffer' <- packByteString buffer
nread <- allocMem :: IO (Ptr Word64)
let gotBoundary' = (fromIntegral . fromEnum) gotBoundary
maybeCancellable <- case cancellable of
Nothing -> return nullPtr
Just jCancellable -> do
jCancellable' <- unsafeManagedPtrCastPtr jCancellable
return jCancellable'
onException (do
result <- propagateGError $ soup_socket_read_until sock' buffer' len boundary boundaryLen nread gotBoundary' maybeCancellable
let result' = (toEnum . fromIntegral) result
nread' <- peek nread
touchManagedPtr sock
whenJust cancellable touchManagedPtr
freeMem buffer'
freeMem nread
return (result', nread')
) (do
freeMem buffer'
freeMem nread
)
#if ENABLE_OVERLOADING
data SocketReadUntilMethodInfo
instance (signature ~ (ByteString -> Ptr () -> Word64 -> Bool -> Maybe (b) -> m ((Soup.Enums.SocketIOStatus, Word64))), MonadIO m, IsSocket a, Gio.Cancellable.IsCancellable b) => O.MethodInfo SocketReadUntilMethodInfo a signature where
overloadedMethod _ = socketReadUntil
#endif
-- method Socket::start_proxy_ssl
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "sock", argType = TInterface (Name {namespace = "Soup", name = "Socket"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the socket", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "ssl_host", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "hostname of the SSL server", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GCancellable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False
foreign import ccall "soup_socket_start_proxy_ssl" soup_socket_start_proxy_ssl ::
Ptr Socket -> -- sock : TInterface (Name {namespace = "Soup", name = "Socket"})
CString -> -- ssl_host : TBasicType TUTF8
Ptr Gio.Cancellable.Cancellable -> -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
IO CInt
{- |
Starts using SSL on /@socket@/, expecting to find a host named
/@sslHost@/.
-}
socketStartProxySsl ::
(B.CallStack.HasCallStack, MonadIO m, IsSocket a, Gio.Cancellable.IsCancellable b) =>
a
{- ^ /@sock@/: the socket -}
-> T.Text
{- ^ /@sslHost@/: hostname of the SSL server -}
-> Maybe (b)
{- ^ /@cancellable@/: a 'GI.Gio.Objects.Cancellable.Cancellable' -}
-> m Bool
{- ^ __Returns:__ success or failure -}
socketStartProxySsl sock sslHost cancellable = liftIO $ do
sock' <- unsafeManagedPtrCastPtr sock
sslHost' <- textToCString sslHost
maybeCancellable <- case cancellable of
Nothing -> return nullPtr
Just jCancellable -> do
jCancellable' <- unsafeManagedPtrCastPtr jCancellable
return jCancellable'
result <- soup_socket_start_proxy_ssl sock' sslHost' maybeCancellable
let result' = (/= 0) result
touchManagedPtr sock
whenJust cancellable touchManagedPtr
freeMem sslHost'
return result'
#if ENABLE_OVERLOADING
data SocketStartProxySslMethodInfo
instance (signature ~ (T.Text -> Maybe (b) -> m Bool), MonadIO m, IsSocket a, Gio.Cancellable.IsCancellable b) => O.MethodInfo SocketStartProxySslMethodInfo a signature where
overloadedMethod _ = socketStartProxySsl
#endif
-- method Socket::start_ssl
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "sock", argType = TInterface (Name {namespace = "Soup", name = "Socket"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the socket", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GCancellable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False
foreign import ccall "soup_socket_start_ssl" soup_socket_start_ssl ::
Ptr Socket -> -- sock : TInterface (Name {namespace = "Soup", name = "Socket"})
Ptr Gio.Cancellable.Cancellable -> -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
IO CInt
{- |
Starts using SSL on /@socket@/.
-}
socketStartSsl ::
(B.CallStack.HasCallStack, MonadIO m, IsSocket a, Gio.Cancellable.IsCancellable b) =>
a
{- ^ /@sock@/: the socket -}
-> Maybe (b)
{- ^ /@cancellable@/: a 'GI.Gio.Objects.Cancellable.Cancellable' -}
-> m Bool
{- ^ __Returns:__ success or failure -}
socketStartSsl sock cancellable = liftIO $ do
sock' <- unsafeManagedPtrCastPtr sock
maybeCancellable <- case cancellable of
Nothing -> return nullPtr
Just jCancellable -> do
jCancellable' <- unsafeManagedPtrCastPtr jCancellable
return jCancellable'
result <- soup_socket_start_ssl sock' maybeCancellable
let result' = (/= 0) result
touchManagedPtr sock
whenJust cancellable touchManagedPtr
return result'
#if ENABLE_OVERLOADING
data SocketStartSslMethodInfo
instance (signature ~ (Maybe (b) -> m Bool), MonadIO m, IsSocket a, Gio.Cancellable.IsCancellable b) => O.MethodInfo SocketStartSslMethodInfo a signature where
overloadedMethod _ = socketStartSsl
#endif
-- method Socket::write
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "sock", argType = TInterface (Name {namespace = "Soup", name = "Socket"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the socket", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "buffer", argType = TCArray False (-1) 2 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "data to write", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "size of @buffer, in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "nwrote", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "on return, number of bytes written", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GCancellable, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "len", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "size of @buffer, in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Just (TInterface (Name {namespace = "Soup", name = "SocketIOStatus"}))
-- throws : True
-- Skip return : False
foreign import ccall "soup_socket_write" soup_socket_write ::
Ptr Socket -> -- sock : TInterface (Name {namespace = "Soup", name = "Socket"})
Ptr Word8 -> -- buffer : TCArray False (-1) 2 (TBasicType TUInt8)
Word64 -> -- len : TBasicType TUInt64
Ptr Word64 -> -- nwrote : TBasicType TUInt64
Ptr Gio.Cancellable.Cancellable -> -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
Ptr (Ptr GError) -> -- error
IO CUInt
{- |
Attempts to write /@len@/ bytes from /@buffer@/ to /@sock@/. If some data is
successfully written, the return status will be 'GI.Soup.Enums.SocketIOStatusOk',
and */@nwrote@/ will contain the number of bytes actually written
(which may be less than /@len@/).
If /@sock@/ is non-blocking, and no data could be written right away,
the return value will be 'GI.Soup.Enums.SocketIOStatusWouldBlock'. In this case,
the caller can connect to the 'GI.Soup.Objects.Socket.Socket'::@/writable/@ signal to know
when more data can be written. (NB: 'GI.Soup.Objects.Socket.Socket'::@/writable/@ is only
emitted after 'GI.Soup.Objects.Socket.socketWrite' returns 'GI.Soup.Enums.SocketIOStatusWouldBlock',
and it is only emitted once. See the documentation for
'GI.Soup.Objects.Socket.Socket':@/non-blocking/@.)
-}
socketWrite ::
(B.CallStack.HasCallStack, MonadIO m, IsSocket a, Gio.Cancellable.IsCancellable b) =>
a
{- ^ /@sock@/: the socket -}
-> ByteString
{- ^ /@buffer@/: data to write -}
-> Maybe (b)
{- ^ /@cancellable@/: a 'GI.Gio.Objects.Cancellable.Cancellable', or 'Nothing' -}
-> m ((Soup.Enums.SocketIOStatus, Word64))
{- ^ __Returns:__ a 'GI.Soup.Enums.SocketIOStatus', as described above (or
'GI.Soup.Enums.SocketIOStatusEof' or 'GI.Soup.Enums.SocketIOStatusError'. /@error@/ will be set if the
return value is 'GI.Soup.Enums.SocketIOStatusError'.) /(Can throw 'Data.GI.Base.GError.GError')/ -}
socketWrite sock buffer cancellable = liftIO $ do
let len = fromIntegral $ B.length buffer
sock' <- unsafeManagedPtrCastPtr sock
buffer' <- packByteString buffer
nwrote <- allocMem :: IO (Ptr Word64)
maybeCancellable <- case cancellable of
Nothing -> return nullPtr
Just jCancellable -> do
jCancellable' <- unsafeManagedPtrCastPtr jCancellable
return jCancellable'
onException (do
result <- propagateGError $ soup_socket_write sock' buffer' len nwrote maybeCancellable
let result' = (toEnum . fromIntegral) result
nwrote' <- peek nwrote
touchManagedPtr sock
whenJust cancellable touchManagedPtr
freeMem buffer'
freeMem nwrote
return (result', nwrote')
) (do
freeMem buffer'
freeMem nwrote
)
#if ENABLE_OVERLOADING
data SocketWriteMethodInfo
instance (signature ~ (ByteString -> Maybe (b) -> m ((Soup.Enums.SocketIOStatus, Word64))), MonadIO m, IsSocket a, Gio.Cancellable.IsCancellable b) => O.MethodInfo SocketWriteMethodInfo a signature where
overloadedMethod _ = socketWrite
#endif