{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- t'GI.Soup.Objects.Socket.Socket' is libsoup\'s TCP socket type. While it is primarily
-- intended for internal use, t'GI.Soup.Objects.Socket.Socket's are exposed in the
-- API in various places, and some of their methods (eg,
-- 'GI.Soup.Objects.Socket.socketGetRemoteAddress') may be useful to applications.

#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif

module GI.Soup.Objects.Socket
    ( 

-- * Exported types
    Socket(..)                              ,
    IsSocket                                ,
    toSocket                                ,


 -- * Methods
-- | 
-- 
--  === __Click to display all available methods, including inherited ones__
-- ==== Methods
-- [bindProperty]("GI.GObject.Objects.Object#g:method:bindProperty"), [bindPropertyFull]("GI.GObject.Objects.Object#g:method:bindPropertyFull"), [connectAsync]("GI.Soup.Objects.Socket#g:method:connectAsync"), [connectSync]("GI.Soup.Objects.Socket#g:method:connectSync"), [disconnect]("GI.Soup.Objects.Socket#g:method:disconnect"), [forceFloating]("GI.GObject.Objects.Object#g:method:forceFloating"), [freezeNotify]("GI.GObject.Objects.Object#g:method:freezeNotify"), [getv]("GI.GObject.Objects.Object#g:method:getv"), [init]("GI.Gio.Interfaces.Initable#g:method:init"), [isConnected]("GI.Soup.Objects.Socket#g:method:isConnected"), [isFloating]("GI.GObject.Objects.Object#g:method:isFloating"), [isSsl]("GI.Soup.Objects.Socket#g:method:isSsl"), [listen]("GI.Soup.Objects.Socket#g:method:listen"), [notify]("GI.GObject.Objects.Object#g:method:notify"), [notifyByPspec]("GI.GObject.Objects.Object#g:method:notifyByPspec"), [read]("GI.Soup.Objects.Socket#g:method:read"), [readUntil]("GI.Soup.Objects.Socket#g:method:readUntil"), [ref]("GI.GObject.Objects.Object#g:method:ref"), [refSink]("GI.GObject.Objects.Object#g:method:refSink"), [runDispose]("GI.GObject.Objects.Object#g:method:runDispose"), [startProxySsl]("GI.Soup.Objects.Socket#g:method:startProxySsl"), [startSsl]("GI.Soup.Objects.Socket#g:method:startSsl"), [stealData]("GI.GObject.Objects.Object#g:method:stealData"), [stealQdata]("GI.GObject.Objects.Object#g:method:stealQdata"), [thawNotify]("GI.GObject.Objects.Object#g:method:thawNotify"), [unref]("GI.GObject.Objects.Object#g:method:unref"), [watchClosure]("GI.GObject.Objects.Object#g:method:watchClosure"), [write]("GI.Soup.Objects.Socket#g:method:write").
-- 
-- ==== Getters
-- [getData]("GI.GObject.Objects.Object#g:method:getData"), [getFd]("GI.Soup.Objects.Socket#g:method:getFd"), [getLocalAddress]("GI.Soup.Objects.Socket#g:method:getLocalAddress"), [getProperty]("GI.GObject.Objects.Object#g:method:getProperty"), [getQdata]("GI.GObject.Objects.Object#g:method:getQdata"), [getRemoteAddress]("GI.Soup.Objects.Socket#g:method:getRemoteAddress").
-- 
-- ==== Setters
-- [setData]("GI.GObject.Objects.Object#g:method:setData"), [setDataFull]("GI.GObject.Objects.Object#g:method:setDataFull"), [setProperty]("GI.GObject.Objects.Object#g:method:setProperty").

#if defined(ENABLE_OVERLOADING)
    ResolveSocketMethod                     ,
#endif

-- ** connectAsync #method:connectAsync#

#if defined(ENABLE_OVERLOADING)
    SocketConnectAsyncMethodInfo            ,
#endif
    socketConnectAsync                      ,


-- ** connectSync #method:connectSync#

#if defined(ENABLE_OVERLOADING)
    SocketConnectSyncMethodInfo             ,
#endif
    socketConnectSync                       ,


-- ** disconnect #method:disconnect#

#if defined(ENABLE_OVERLOADING)
    SocketDisconnectMethodInfo              ,
#endif
    socketDisconnect                        ,


-- ** getFd #method:getFd#

#if defined(ENABLE_OVERLOADING)
    SocketGetFdMethodInfo                   ,
#endif
    socketGetFd                             ,


-- ** getLocalAddress #method:getLocalAddress#

#if defined(ENABLE_OVERLOADING)
    SocketGetLocalAddressMethodInfo         ,
#endif
    socketGetLocalAddress                   ,


-- ** getRemoteAddress #method:getRemoteAddress#

#if defined(ENABLE_OVERLOADING)
    SocketGetRemoteAddressMethodInfo        ,
#endif
    socketGetRemoteAddress                  ,


-- ** isConnected #method:isConnected#

#if defined(ENABLE_OVERLOADING)
    SocketIsConnectedMethodInfo             ,
#endif
    socketIsConnected                       ,


-- ** isSsl #method:isSsl#

#if defined(ENABLE_OVERLOADING)
    SocketIsSslMethodInfo                   ,
#endif
    socketIsSsl                             ,


-- ** listen #method:listen#

#if defined(ENABLE_OVERLOADING)
    SocketListenMethodInfo                  ,
#endif
    socketListen                            ,


-- ** read #method:read#

#if defined(ENABLE_OVERLOADING)
    SocketReadMethodInfo                    ,
#endif
    socketRead                              ,


-- ** readUntil #method:readUntil#

#if defined(ENABLE_OVERLOADING)
    SocketReadUntilMethodInfo               ,
#endif
    socketReadUntil                         ,


-- ** startProxySsl #method:startProxySsl#

#if defined(ENABLE_OVERLOADING)
    SocketStartProxySslMethodInfo           ,
#endif
    socketStartProxySsl                     ,


-- ** startSsl #method:startSsl#

#if defined(ENABLE_OVERLOADING)
    SocketStartSslMethodInfo                ,
#endif
    socketStartSsl                          ,


-- ** write #method:write#

#if defined(ENABLE_OVERLOADING)
    SocketWriteMethodInfo                   ,
#endif
    socketWrite                             ,




 -- * Properties


-- ** asyncContext #attr:asyncContext#
-- | /No description available in the introspection data./

#if defined(ENABLE_OVERLOADING)
    SocketAsyncContextPropertyInfo          ,
#endif
    constructSocketAsyncContext             ,
    getSocketAsyncContext                   ,
#if defined(ENABLE_OVERLOADING)
    socketAsyncContext                      ,
#endif


-- ** fd #attr:fd#
-- | /No description available in the introspection data./

#if defined(ENABLE_OVERLOADING)
    SocketFdPropertyInfo                    ,
#endif
    constructSocketFd                       ,
    getSocketFd                             ,
#if defined(ENABLE_OVERLOADING)
    socketFd                                ,
#endif


-- ** gsocket #attr:gsocket#
-- | /No description available in the introspection data./

#if defined(ENABLE_OVERLOADING)
    SocketGsocketPropertyInfo               ,
#endif
    constructSocketGsocket                  ,
#if defined(ENABLE_OVERLOADING)
    socketGsocket                           ,
#endif


-- ** iostream #attr:iostream#
-- | /No description available in the introspection data./

#if defined(ENABLE_OVERLOADING)
    SocketIostreamPropertyInfo              ,
#endif
    constructSocketIostream                 ,
#if defined(ENABLE_OVERLOADING)
    socketIostream                          ,
#endif


-- ** ipv6Only #attr:ipv6Only#
-- | /No description available in the introspection data./

#if defined(ENABLE_OVERLOADING)
    SocketIpv6OnlyPropertyInfo              ,
#endif
    constructSocketIpv6Only                 ,
    getSocketIpv6Only                       ,
    setSocketIpv6Only                       ,
#if defined(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
-- [newConnection]("GI.Soup.Objects.Socket#g:signal:newConnection"), but for sockets created by
-- setting t'GI.Soup.Objects.Socket.Socket':@/fd/@, it will only be set for listening
-- sockets.

#if defined(ENABLE_OVERLOADING)
    SocketIsServerPropertyInfo              ,
#endif
    getSocketIsServer                       ,
#if defined(ENABLE_OVERLOADING)
    socketIsServer                          ,
#endif


-- ** localAddress #attr:localAddress#
-- | /No description available in the introspection data./

#if defined(ENABLE_OVERLOADING)
    SocketLocalAddressPropertyInfo          ,
#endif
    constructSocketLocalAddress             ,
    getSocketLocalAddress                   ,
#if defined(ENABLE_OVERLOADING)
    socketLocalAddress                      ,
#endif


-- ** nonBlocking #attr:nonBlocking#
-- | Whether or not the socket uses non-blocking I\/O.
-- 
-- t'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 t'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
-- [readable]("GI.Soup.Objects.Socket#g:signal:readable") signal. Then go back to the
-- reading-as-much-as-you-can loop. Likewise, for writing to a
-- t'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
-- [writable]("GI.Soup.Objects.Socket#g:signal: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 defined(ENABLE_OVERLOADING)
    SocketNonBlockingPropertyInfo           ,
#endif
    constructSocketNonBlocking              ,
    getSocketNonBlocking                    ,
    setSocketNonBlocking                    ,
#if defined(ENABLE_OVERLOADING)
    socketNonBlocking                       ,
#endif


-- ** remoteAddress #attr:remoteAddress#
-- | /No description available in the introspection data./

#if defined(ENABLE_OVERLOADING)
    SocketRemoteAddressPropertyInfo         ,
#endif
    constructSocketRemoteAddress            ,
    getSocketRemoteAddress                  ,
#if defined(ENABLE_OVERLOADING)
    socketRemoteAddress                     ,
#endif


-- ** sslCreds #attr:sslCreds#
-- | /No description available in the introspection data./

#if defined(ENABLE_OVERLOADING)
    SocketSslCredsPropertyInfo              ,
#endif
    constructSocketSslCreds                 ,
    getSocketSslCreds                       ,
    setSocketSslCreds                       ,
#if defined(ENABLE_OVERLOADING)
    socketSslCreds                          ,
#endif


-- ** sslFallback #attr:sslFallback#
-- | /No description available in the introspection data./

#if defined(ENABLE_OVERLOADING)
    SocketSslFallbackPropertyInfo           ,
#endif
    constructSocketSslFallback              ,
    getSocketSslFallback                    ,
#if defined(ENABLE_OVERLOADING)
    socketSslFallback                       ,
#endif


-- ** sslStrict #attr:sslStrict#
-- | /No description available in the introspection data./

#if defined(ENABLE_OVERLOADING)
    SocketSslStrictPropertyInfo             ,
#endif
    constructSocketSslStrict                ,
    getSocketSslStrict                      ,
#if defined(ENABLE_OVERLOADING)
    socketSslStrict                         ,
#endif


-- ** timeout #attr:timeout#
-- | /No description available in the introspection data./

#if defined(ENABLE_OVERLOADING)
    SocketTimeoutPropertyInfo               ,
#endif
    constructSocketTimeout                  ,
    getSocketTimeout                        ,
    setSocketTimeout                        ,
#if defined(ENABLE_OVERLOADING)
    socketTimeout                           ,
#endif


-- ** tlsCertificate #attr:tlsCertificate#
-- | /No description available in the introspection data./

#if defined(ENABLE_OVERLOADING)
    SocketTlsCertificatePropertyInfo        ,
#endif
    getSocketTlsCertificate                 ,
#if defined(ENABLE_OVERLOADING)
    socketTlsCertificate                    ,
#endif


-- ** tlsErrors #attr:tlsErrors#
-- | /No description available in the introspection data./

#if defined(ENABLE_OVERLOADING)
    SocketTlsErrorsPropertyInfo             ,
#endif
    getSocketTlsErrors                      ,
#if defined(ENABLE_OVERLOADING)
    socketTlsErrors                         ,
#endif


-- ** trustedCertificate #attr:trustedCertificate#
-- | /No description available in the introspection data./

#if defined(ENABLE_OVERLOADING)
    SocketTrustedCertificatePropertyInfo    ,
#endif
    getSocketTrustedCertificate             ,
#if defined(ENABLE_OVERLOADING)
    socketTrustedCertificate                ,
#endif


-- ** useThreadContext #attr:useThreadContext#
-- | Use 'GI.GLib.Functions.mainContextGetThreadDefault'.
-- 
-- /Since: 2.38/

#if defined(ENABLE_OVERLOADING)
    SocketUseThreadContextPropertyInfo      ,
#endif
    constructSocketUseThreadContext         ,
    getSocketUseThreadContext               ,
#if defined(ENABLE_OVERLOADING)
    socketUseThreadContext                  ,
#endif




 -- * Signals


-- ** disconnected #signal:disconnected#

    C_SocketDisconnectedCallback            ,
    SocketDisconnectedCallback              ,
#if defined(ENABLE_OVERLOADING)
    SocketDisconnectedSignalInfo            ,
#endif
    afterSocketDisconnected                 ,
    genClosure_SocketDisconnected           ,
    mk_SocketDisconnectedCallback           ,
    noSocketDisconnectedCallback            ,
    onSocketDisconnected                    ,
    wrap_SocketDisconnectedCallback         ,


-- ** event #signal:event#

    C_SocketEventCallback                   ,
    SocketEventCallback                     ,
#if defined(ENABLE_OVERLOADING)
    SocketEventSignalInfo                   ,
#endif
    afterSocketEvent                        ,
    genClosure_SocketEvent                  ,
    mk_SocketEventCallback                  ,
    noSocketEventCallback                   ,
    onSocketEvent                           ,
    wrap_SocketEventCallback                ,


-- ** newConnection #signal:newConnection#

    C_SocketNewConnectionCallback           ,
    SocketNewConnectionCallback             ,
#if defined(ENABLE_OVERLOADING)
    SocketNewConnectionSignalInfo           ,
#endif
    afterSocketNewConnection                ,
    genClosure_SocketNewConnection          ,
    mk_SocketNewConnectionCallback          ,
    noSocketNewConnectionCallback           ,
    onSocketNewConnection                   ,
    wrap_SocketNewConnectionCallback        ,


-- ** readable #signal:readable#

    C_SocketReadableCallback                ,
    SocketReadableCallback                  ,
#if defined(ENABLE_OVERLOADING)
    SocketReadableSignalInfo                ,
#endif
    afterSocketReadable                     ,
    genClosure_SocketReadable               ,
    mk_SocketReadableCallback               ,
    noSocketReadableCallback                ,
    onSocketReadable                        ,
    wrap_SocketReadableCallback             ,


-- ** writable #signal:writable#

    C_SocketWritableCallback                ,
    SocketWritableCallback                  ,
#if defined(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.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GArray as B.GArray
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
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 GHC.Records as R

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 (SP.ManagedPtr Socket)
    deriving (Socket -> Socket -> Bool
(Socket -> Socket -> Bool)
-> (Socket -> Socket -> Bool) -> Eq Socket
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Socket -> Socket -> Bool
$c/= :: Socket -> Socket -> Bool
== :: Socket -> Socket -> Bool
$c== :: Socket -> Socket -> Bool
Eq)

instance SP.ManagedPtrNewtype Socket where
    toManagedPtr :: Socket -> ManagedPtr Socket
toManagedPtr (Socket ManagedPtr Socket
p) = ManagedPtr Socket
p

foreign import ccall "soup_socket_get_type"
    c_soup_socket_get_type :: IO B.Types.GType

instance B.Types.TypedObject Socket where
    glibType :: IO GType
glibType = IO GType
c_soup_socket_get_type

instance B.Types.GObject Socket

-- | Type class for types which can be safely cast to `Socket`, for instance with `toSocket`.
class (SP.GObject o, O.IsDescendantOf Socket o) => IsSocket o
instance (SP.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 :: (MIO.MonadIO m, IsSocket o) => o -> m Socket
toSocket :: forall (m :: * -> *) o. (MonadIO m, IsSocket o) => o -> m Socket
toSocket = IO Socket -> m Socket
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO Socket -> m Socket) -> (o -> IO Socket) -> o -> m Socket
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr Socket -> Socket) -> o -> IO Socket
forall o o'.
(HasCallStack, ManagedPtrNewtype o, TypedObject o,
 ManagedPtrNewtype o', TypedObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
B.ManagedPtr.unsafeCastTo ManagedPtr Socket -> Socket
Socket

-- | Convert 'Socket' to and from 'Data.GI.Base.GValue.GValue'. See 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue (Maybe Socket) where
    gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_soup_socket_get_type
    gvalueSet_ :: Ptr GValue -> Maybe Socket -> IO ()
gvalueSet_ Ptr GValue
gv Maybe Socket
P.Nothing = Ptr GValue -> Ptr Socket -> IO ()
forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv (Ptr Socket
forall a. Ptr a
FP.nullPtr :: FP.Ptr Socket)
    gvalueSet_ Ptr GValue
gv (P.Just Socket
obj) = Socket -> (Ptr Socket -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr Socket
obj (Ptr GValue -> Ptr Socket -> IO ()
forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv)
    gvalueGet_ :: Ptr GValue -> IO (Maybe Socket)
gvalueGet_ Ptr GValue
gv = do
        Ptr Socket
ptr <- Ptr GValue -> IO (Ptr Socket)
forall a. GObject a => Ptr GValue -> IO (Ptr a)
B.GValue.get_object Ptr GValue
gv :: IO (FP.Ptr Socket)
        if Ptr Socket
ptr Ptr Socket -> Ptr Socket -> Bool
forall a. Eq a => a -> a -> Bool
/= Ptr Socket
forall a. Ptr a
FP.nullPtr
        then Socket -> Maybe Socket
forall a. a -> Maybe a
P.Just (Socket -> Maybe Socket) -> IO Socket -> IO (Maybe Socket)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ManagedPtr Socket -> Socket) -> Ptr Socket -> IO Socket
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
B.ManagedPtr.newObject ManagedPtr Socket -> Socket
Socket Ptr Socket
ptr
        else Maybe Socket -> IO (Maybe Socket)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Socket
forall a. Maybe a
P.Nothing
        
    

#if defined(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 "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveSocketMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveSocketMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveSocketMethod t Socket, O.OverloadedMethod info Socket p) => OL.IsLabel t (Socket -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod @info
#else
    fromLabel _ = O.overloadedMethod @info
#endif

#if MIN_VERSION_base(4,13,0)
instance (info ~ ResolveSocketMethod t Socket, O.OverloadedMethod info Socket p, R.HasField t Socket p) => R.HasField t Socket p where
    getField = O.overloadedMethod @info

#endif

instance (info ~ ResolveSocketMethod t Socket, O.OverloadedMethodInfo info Socket) => OL.IsLabel t (O.MethodProxy info Socket) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.MethodProxy
#else
    fromLabel _ = O.MethodProxy
#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 :: Maybe (IO ())
noSocketDisconnectedCallback = Maybe (IO ())
forall a. Maybe a
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 :: forall (m :: * -> *).
MonadIO m =>
IO () -> m (GClosure C_SocketDisconnectedCallback)
genClosure_SocketDisconnected IO ()
cb = IO (GClosure C_SocketDisconnectedCallback)
-> m (GClosure C_SocketDisconnectedCallback)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (GClosure C_SocketDisconnectedCallback)
 -> m (GClosure C_SocketDisconnectedCallback))
-> IO (GClosure C_SocketDisconnectedCallback)
-> m (GClosure C_SocketDisconnectedCallback)
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_SocketDisconnectedCallback
cb' = IO () -> C_SocketDisconnectedCallback
wrap_SocketDisconnectedCallback IO ()
cb
    C_SocketDisconnectedCallback
-> IO (FunPtr C_SocketDisconnectedCallback)
mk_SocketDisconnectedCallback C_SocketDisconnectedCallback
cb' IO (FunPtr C_SocketDisconnectedCallback)
-> (FunPtr C_SocketDisconnectedCallback
    -> IO (GClosure C_SocketDisconnectedCallback))
-> IO (GClosure C_SocketDisconnectedCallback)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= FunPtr C_SocketDisconnectedCallback
-> IO (GClosure C_SocketDisconnectedCallback)
forall (m :: * -> *) a. MonadIO m => FunPtr a -> m (GClosure a)
B.GClosure.newGClosure


-- | Wrap a `SocketDisconnectedCallback` into a `C_SocketDisconnectedCallback`.
wrap_SocketDisconnectedCallback ::
    SocketDisconnectedCallback ->
    C_SocketDisconnectedCallback
wrap_SocketDisconnectedCallback :: IO () -> C_SocketDisconnectedCallback
wrap_SocketDisconnectedCallback IO ()
_cb Ptr ()
_ Ptr ()
_ = do
    IO ()
_cb 


-- | Connect a signal handler for the [disconnected](#signal: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 :: forall a (m :: * -> *).
(IsSocket a, MonadIO m) =>
a -> IO () -> m SignalHandlerId
onSocketDisconnected a
obj IO ()
cb = IO SignalHandlerId -> m SignalHandlerId
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SignalHandlerId -> m SignalHandlerId)
-> IO SignalHandlerId -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_SocketDisconnectedCallback
cb' = IO () -> C_SocketDisconnectedCallback
wrap_SocketDisconnectedCallback IO ()
cb
    FunPtr C_SocketDisconnectedCallback
cb'' <- C_SocketDisconnectedCallback
-> IO (FunPtr C_SocketDisconnectedCallback)
mk_SocketDisconnectedCallback C_SocketDisconnectedCallback
cb'
    a
-> Text
-> FunPtr C_SocketDisconnectedCallback
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
forall o a.
GObject o =>
o
-> Text
-> FunPtr a
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
connectSignalFunPtr a
obj Text
"disconnected" FunPtr C_SocketDisconnectedCallback
cb'' SignalConnectMode
SignalConnectBefore Maybe Text
forall a. Maybe a
Nothing

-- | Connect a signal handler for the [disconnected](#signal: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 :: forall a (m :: * -> *).
(IsSocket a, MonadIO m) =>
a -> IO () -> m SignalHandlerId
afterSocketDisconnected a
obj IO ()
cb = IO SignalHandlerId -> m SignalHandlerId
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SignalHandlerId -> m SignalHandlerId)
-> IO SignalHandlerId -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_SocketDisconnectedCallback
cb' = IO () -> C_SocketDisconnectedCallback
wrap_SocketDisconnectedCallback IO ()
cb
    FunPtr C_SocketDisconnectedCallback
cb'' <- C_SocketDisconnectedCallback
-> IO (FunPtr C_SocketDisconnectedCallback)
mk_SocketDisconnectedCallback C_SocketDisconnectedCallback
cb'
    a
-> Text
-> FunPtr C_SocketDisconnectedCallback
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
forall o a.
GObject o =>
o
-> Text
-> FunPtr a
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
connectSignalFunPtr a
obj Text
"disconnected" FunPtr C_SocketDisconnectedCallback
cb'' SignalConnectMode
SignalConnectAfter Maybe Text
forall a. Maybe a
Nothing


#if defined(ENABLE_OVERLOADING)
data SocketDisconnectedSignalInfo
instance SignalInfo SocketDisconnectedSignalInfo where
    type HaskellCallbackType SocketDisconnectedSignalInfo = SocketDisconnectedCallback
    connectSignal obj cb connectMode detail = do
        let cb' = wrap_SocketDisconnectedCallback cb
        cb'' <- mk_SocketDisconnectedCallback cb'
        connectSignalFunPtr obj "disconnected" cb'' connectMode detail

#endif

-- signal Socket::event
-- | Emitted when a network-related event occurs. See
-- [event]("GI.Gio.Objects.SocketClient#g:signal: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 :: Maybe SocketEventCallback
noSocketEventCallback = Maybe SocketEventCallback
forall a. Maybe a
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 :: forall (m :: * -> *).
MonadIO m =>
SocketEventCallback -> m (GClosure C_SocketEventCallback)
genClosure_SocketEvent SocketEventCallback
cb = IO (GClosure C_SocketEventCallback)
-> m (GClosure C_SocketEventCallback)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (GClosure C_SocketEventCallback)
 -> m (GClosure C_SocketEventCallback))
-> IO (GClosure C_SocketEventCallback)
-> m (GClosure C_SocketEventCallback)
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_SocketEventCallback
cb' = SocketEventCallback -> C_SocketEventCallback
wrap_SocketEventCallback SocketEventCallback
cb
    C_SocketEventCallback -> IO (FunPtr C_SocketEventCallback)
mk_SocketEventCallback C_SocketEventCallback
cb' IO (FunPtr C_SocketEventCallback)
-> (FunPtr C_SocketEventCallback
    -> IO (GClosure C_SocketEventCallback))
-> IO (GClosure C_SocketEventCallback)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= FunPtr C_SocketEventCallback -> IO (GClosure C_SocketEventCallback)
forall (m :: * -> *) a. MonadIO m => FunPtr a -> m (GClosure a)
B.GClosure.newGClosure


-- | Wrap a `SocketEventCallback` into a `C_SocketEventCallback`.
wrap_SocketEventCallback ::
    SocketEventCallback ->
    C_SocketEventCallback
wrap_SocketEventCallback :: SocketEventCallback -> C_SocketEventCallback
wrap_SocketEventCallback SocketEventCallback
_cb Ptr ()
_ CUInt
event Ptr IOStream
connection Ptr ()
_ = do
    let event' :: SocketClientEvent
event' = (Int -> SocketClientEvent
forall a. Enum a => Int -> a
toEnum (Int -> SocketClientEvent)
-> (CUInt -> Int) -> CUInt -> SocketClientEvent
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
event
    IOStream
connection' <- ((ManagedPtr IOStream -> IOStream) -> Ptr IOStream -> IO IOStream
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr IOStream -> IOStream
Gio.IOStream.IOStream) Ptr IOStream
connection
    SocketEventCallback
_cb  SocketClientEvent
event' IOStream
connection'


-- | Connect a signal handler for the [event](#signal: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 :: forall a (m :: * -> *).
(IsSocket a, MonadIO m) =>
a -> SocketEventCallback -> m SignalHandlerId
onSocketEvent a
obj SocketEventCallback
cb = IO SignalHandlerId -> m SignalHandlerId
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SignalHandlerId -> m SignalHandlerId)
-> IO SignalHandlerId -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_SocketEventCallback
cb' = SocketEventCallback -> C_SocketEventCallback
wrap_SocketEventCallback SocketEventCallback
cb
    FunPtr C_SocketEventCallback
cb'' <- C_SocketEventCallback -> IO (FunPtr C_SocketEventCallback)
mk_SocketEventCallback C_SocketEventCallback
cb'
    a
-> Text
-> FunPtr C_SocketEventCallback
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
forall o a.
GObject o =>
o
-> Text
-> FunPtr a
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
connectSignalFunPtr a
obj Text
"event" FunPtr C_SocketEventCallback
cb'' SignalConnectMode
SignalConnectBefore Maybe Text
forall a. Maybe a
Nothing

-- | Connect a signal handler for the [event](#signal: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 :: forall a (m :: * -> *).
(IsSocket a, MonadIO m) =>
a -> SocketEventCallback -> m SignalHandlerId
afterSocketEvent a
obj SocketEventCallback
cb = IO SignalHandlerId -> m SignalHandlerId
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SignalHandlerId -> m SignalHandlerId)
-> IO SignalHandlerId -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_SocketEventCallback
cb' = SocketEventCallback -> C_SocketEventCallback
wrap_SocketEventCallback SocketEventCallback
cb
    FunPtr C_SocketEventCallback
cb'' <- C_SocketEventCallback -> IO (FunPtr C_SocketEventCallback)
mk_SocketEventCallback C_SocketEventCallback
cb'
    a
-> Text
-> FunPtr C_SocketEventCallback
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
forall o a.
GObject o =>
o
-> Text
-> FunPtr a
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
connectSignalFunPtr a
obj Text
"event" FunPtr C_SocketEventCallback
cb'' SignalConnectMode
SignalConnectAfter Maybe Text
forall a. Maybe a
Nothing


#if defined(ENABLE_OVERLOADING)
data SocketEventSignalInfo
instance SignalInfo SocketEventSignalInfo where
    type HaskellCallbackType SocketEventSignalInfo = SocketEventCallback
    connectSignal obj cb connectMode detail = do
        let cb' = wrap_SocketEventCallback cb
        cb'' <- mk_SocketEventCallback cb'
        connectSignalFunPtr obj "event" cb'' connectMode detail

#endif

-- 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 :: Maybe SocketNewConnectionCallback
noSocketNewConnectionCallback = Maybe SocketNewConnectionCallback
forall a. Maybe a
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 :: forall (m :: * -> *).
MonadIO m =>
SocketNewConnectionCallback
-> m (GClosure C_SocketNewConnectionCallback)
genClosure_SocketNewConnection SocketNewConnectionCallback
cb = IO (GClosure C_SocketNewConnectionCallback)
-> m (GClosure C_SocketNewConnectionCallback)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (GClosure C_SocketNewConnectionCallback)
 -> m (GClosure C_SocketNewConnectionCallback))
-> IO (GClosure C_SocketNewConnectionCallback)
-> m (GClosure C_SocketNewConnectionCallback)
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_SocketNewConnectionCallback
cb' = SocketNewConnectionCallback -> C_SocketNewConnectionCallback
wrap_SocketNewConnectionCallback SocketNewConnectionCallback
cb
    C_SocketNewConnectionCallback
-> IO (FunPtr C_SocketNewConnectionCallback)
mk_SocketNewConnectionCallback C_SocketNewConnectionCallback
cb' IO (FunPtr C_SocketNewConnectionCallback)
-> (FunPtr C_SocketNewConnectionCallback
    -> IO (GClosure C_SocketNewConnectionCallback))
-> IO (GClosure C_SocketNewConnectionCallback)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= FunPtr C_SocketNewConnectionCallback
-> IO (GClosure C_SocketNewConnectionCallback)
forall (m :: * -> *) a. MonadIO m => FunPtr a -> m (GClosure a)
B.GClosure.newGClosure


-- | Wrap a `SocketNewConnectionCallback` into a `C_SocketNewConnectionCallback`.
wrap_SocketNewConnectionCallback ::
    SocketNewConnectionCallback ->
    C_SocketNewConnectionCallback
wrap_SocketNewConnectionCallback :: SocketNewConnectionCallback -> C_SocketNewConnectionCallback
wrap_SocketNewConnectionCallback SocketNewConnectionCallback
_cb Ptr ()
_ Ptr Socket
new Ptr ()
_ = do
    Socket
new' <- ((ManagedPtr Socket -> Socket) -> Ptr Socket -> IO Socket
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr Socket -> Socket
Socket) Ptr Socket
new
    SocketNewConnectionCallback
_cb  Socket
new'


-- | Connect a signal handler for the [newConnection](#signal:newConnection) 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 :: forall a (m :: * -> *).
(IsSocket a, MonadIO m) =>
a -> SocketNewConnectionCallback -> m SignalHandlerId
onSocketNewConnection a
obj SocketNewConnectionCallback
cb = IO SignalHandlerId -> m SignalHandlerId
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SignalHandlerId -> m SignalHandlerId)
-> IO SignalHandlerId -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_SocketNewConnectionCallback
cb' = SocketNewConnectionCallback -> C_SocketNewConnectionCallback
wrap_SocketNewConnectionCallback SocketNewConnectionCallback
cb
    FunPtr C_SocketNewConnectionCallback
cb'' <- C_SocketNewConnectionCallback
-> IO (FunPtr C_SocketNewConnectionCallback)
mk_SocketNewConnectionCallback C_SocketNewConnectionCallback
cb'
    a
-> Text
-> FunPtr C_SocketNewConnectionCallback
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
forall o a.
GObject o =>
o
-> Text
-> FunPtr a
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
connectSignalFunPtr a
obj Text
"new-connection" FunPtr C_SocketNewConnectionCallback
cb'' SignalConnectMode
SignalConnectBefore Maybe Text
forall a. Maybe a
Nothing

-- | Connect a signal handler for the [newConnection](#signal:newConnection) 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 :: forall a (m :: * -> *).
(IsSocket a, MonadIO m) =>
a -> SocketNewConnectionCallback -> m SignalHandlerId
afterSocketNewConnection a
obj SocketNewConnectionCallback
cb = IO SignalHandlerId -> m SignalHandlerId
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SignalHandlerId -> m SignalHandlerId)
-> IO SignalHandlerId -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_SocketNewConnectionCallback
cb' = SocketNewConnectionCallback -> C_SocketNewConnectionCallback
wrap_SocketNewConnectionCallback SocketNewConnectionCallback
cb
    FunPtr C_SocketNewConnectionCallback
cb'' <- C_SocketNewConnectionCallback
-> IO (FunPtr C_SocketNewConnectionCallback)
mk_SocketNewConnectionCallback C_SocketNewConnectionCallback
cb'
    a
-> Text
-> FunPtr C_SocketNewConnectionCallback
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
forall o a.
GObject o =>
o
-> Text
-> FunPtr a
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
connectSignalFunPtr a
obj Text
"new-connection" FunPtr C_SocketNewConnectionCallback
cb'' SignalConnectMode
SignalConnectAfter Maybe Text
forall a. Maybe a
Nothing


#if defined(ENABLE_OVERLOADING)
data SocketNewConnectionSignalInfo
instance SignalInfo SocketNewConnectionSignalInfo where
    type HaskellCallbackType SocketNewConnectionSignalInfo = SocketNewConnectionCallback
    connectSignal obj cb connectMode detail = do
        let cb' = wrap_SocketNewConnectionCallback cb
        cb'' <- mk_SocketNewConnectionCallback cb'
        connectSignalFunPtr obj "new-connection" cb'' connectMode detail

#endif

-- signal Socket::readable
-- | Emitted when an async socket is readable. See
-- 'GI.Soup.Objects.Socket.socketRead', 'GI.Soup.Objects.Socket.socketReadUntil' and
-- t'GI.Soup.Objects.Socket.Socket':@/non-blocking/@.
type SocketReadableCallback =
    IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `SocketReadableCallback`@.
noSocketReadableCallback :: Maybe SocketReadableCallback
noSocketReadableCallback :: Maybe (IO ())
noSocketReadableCallback = Maybe (IO ())
forall a. Maybe a
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 :: forall (m :: * -> *).
MonadIO m =>
IO () -> m (GClosure C_SocketDisconnectedCallback)
genClosure_SocketReadable IO ()
cb = IO (GClosure C_SocketDisconnectedCallback)
-> m (GClosure C_SocketDisconnectedCallback)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (GClosure C_SocketDisconnectedCallback)
 -> m (GClosure C_SocketDisconnectedCallback))
-> IO (GClosure C_SocketDisconnectedCallback)
-> m (GClosure C_SocketDisconnectedCallback)
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_SocketDisconnectedCallback
cb' = IO () -> C_SocketDisconnectedCallback
wrap_SocketReadableCallback IO ()
cb
    C_SocketDisconnectedCallback
-> IO (FunPtr C_SocketDisconnectedCallback)
mk_SocketReadableCallback C_SocketDisconnectedCallback
cb' IO (FunPtr C_SocketDisconnectedCallback)
-> (FunPtr C_SocketDisconnectedCallback
    -> IO (GClosure C_SocketDisconnectedCallback))
-> IO (GClosure C_SocketDisconnectedCallback)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= FunPtr C_SocketDisconnectedCallback
-> IO (GClosure C_SocketDisconnectedCallback)
forall (m :: * -> *) a. MonadIO m => FunPtr a -> m (GClosure a)
B.GClosure.newGClosure


-- | Wrap a `SocketReadableCallback` into a `C_SocketReadableCallback`.
wrap_SocketReadableCallback ::
    SocketReadableCallback ->
    C_SocketReadableCallback
wrap_SocketReadableCallback :: IO () -> C_SocketDisconnectedCallback
wrap_SocketReadableCallback IO ()
_cb Ptr ()
_ Ptr ()
_ = do
    IO ()
_cb 


-- | Connect a signal handler for the [readable](#signal: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 :: forall a (m :: * -> *).
(IsSocket a, MonadIO m) =>
a -> IO () -> m SignalHandlerId
onSocketReadable a
obj IO ()
cb = IO SignalHandlerId -> m SignalHandlerId
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SignalHandlerId -> m SignalHandlerId)
-> IO SignalHandlerId -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_SocketDisconnectedCallback
cb' = IO () -> C_SocketDisconnectedCallback
wrap_SocketReadableCallback IO ()
cb
    FunPtr C_SocketDisconnectedCallback
cb'' <- C_SocketDisconnectedCallback
-> IO (FunPtr C_SocketDisconnectedCallback)
mk_SocketReadableCallback C_SocketDisconnectedCallback
cb'
    a
-> Text
-> FunPtr C_SocketDisconnectedCallback
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
forall o a.
GObject o =>
o
-> Text
-> FunPtr a
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
connectSignalFunPtr a
obj Text
"readable" FunPtr C_SocketDisconnectedCallback
cb'' SignalConnectMode
SignalConnectBefore Maybe Text
forall a. Maybe a
Nothing

-- | Connect a signal handler for the [readable](#signal: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 :: forall a (m :: * -> *).
(IsSocket a, MonadIO m) =>
a -> IO () -> m SignalHandlerId
afterSocketReadable a
obj IO ()
cb = IO SignalHandlerId -> m SignalHandlerId
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SignalHandlerId -> m SignalHandlerId)
-> IO SignalHandlerId -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_SocketDisconnectedCallback
cb' = IO () -> C_SocketDisconnectedCallback
wrap_SocketReadableCallback IO ()
cb
    FunPtr C_SocketDisconnectedCallback
cb'' <- C_SocketDisconnectedCallback
-> IO (FunPtr C_SocketDisconnectedCallback)
mk_SocketReadableCallback C_SocketDisconnectedCallback
cb'
    a
-> Text
-> FunPtr C_SocketDisconnectedCallback
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
forall o a.
GObject o =>
o
-> Text
-> FunPtr a
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
connectSignalFunPtr a
obj Text
"readable" FunPtr C_SocketDisconnectedCallback
cb'' SignalConnectMode
SignalConnectAfter Maybe Text
forall a. Maybe a
Nothing


#if defined(ENABLE_OVERLOADING)
data SocketReadableSignalInfo
instance SignalInfo SocketReadableSignalInfo where
    type HaskellCallbackType SocketReadableSignalInfo = SocketReadableCallback
    connectSignal obj cb connectMode detail = do
        let cb' = wrap_SocketReadableCallback cb
        cb'' <- mk_SocketReadableCallback cb'
        connectSignalFunPtr obj "readable" cb'' connectMode detail

#endif

-- signal Socket::writable
-- | Emitted when an async socket is writable. See
-- 'GI.Soup.Objects.Socket.socketWrite' and t'GI.Soup.Objects.Socket.Socket':@/non-blocking/@.
type SocketWritableCallback =
    IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `SocketWritableCallback`@.
noSocketWritableCallback :: Maybe SocketWritableCallback
noSocketWritableCallback :: Maybe (IO ())
noSocketWritableCallback = Maybe (IO ())
forall a. Maybe a
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 :: forall (m :: * -> *).
MonadIO m =>
IO () -> m (GClosure C_SocketDisconnectedCallback)
genClosure_SocketWritable IO ()
cb = IO (GClosure C_SocketDisconnectedCallback)
-> m (GClosure C_SocketDisconnectedCallback)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (GClosure C_SocketDisconnectedCallback)
 -> m (GClosure C_SocketDisconnectedCallback))
-> IO (GClosure C_SocketDisconnectedCallback)
-> m (GClosure C_SocketDisconnectedCallback)
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_SocketDisconnectedCallback
cb' = IO () -> C_SocketDisconnectedCallback
wrap_SocketWritableCallback IO ()
cb
    C_SocketDisconnectedCallback
-> IO (FunPtr C_SocketDisconnectedCallback)
mk_SocketWritableCallback C_SocketDisconnectedCallback
cb' IO (FunPtr C_SocketDisconnectedCallback)
-> (FunPtr C_SocketDisconnectedCallback
    -> IO (GClosure C_SocketDisconnectedCallback))
-> IO (GClosure C_SocketDisconnectedCallback)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= FunPtr C_SocketDisconnectedCallback
-> IO (GClosure C_SocketDisconnectedCallback)
forall (m :: * -> *) a. MonadIO m => FunPtr a -> m (GClosure a)
B.GClosure.newGClosure


-- | Wrap a `SocketWritableCallback` into a `C_SocketWritableCallback`.
wrap_SocketWritableCallback ::
    SocketWritableCallback ->
    C_SocketWritableCallback
wrap_SocketWritableCallback :: IO () -> C_SocketDisconnectedCallback
wrap_SocketWritableCallback IO ()
_cb Ptr ()
_ Ptr ()
_ = do
    IO ()
_cb 


-- | Connect a signal handler for the [writable](#signal: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 :: forall a (m :: * -> *).
(IsSocket a, MonadIO m) =>
a -> IO () -> m SignalHandlerId
onSocketWritable a
obj IO ()
cb = IO SignalHandlerId -> m SignalHandlerId
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SignalHandlerId -> m SignalHandlerId)
-> IO SignalHandlerId -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_SocketDisconnectedCallback
cb' = IO () -> C_SocketDisconnectedCallback
wrap_SocketWritableCallback IO ()
cb
    FunPtr C_SocketDisconnectedCallback
cb'' <- C_SocketDisconnectedCallback
-> IO (FunPtr C_SocketDisconnectedCallback)
mk_SocketWritableCallback C_SocketDisconnectedCallback
cb'
    a
-> Text
-> FunPtr C_SocketDisconnectedCallback
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
forall o a.
GObject o =>
o
-> Text
-> FunPtr a
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
connectSignalFunPtr a
obj Text
"writable" FunPtr C_SocketDisconnectedCallback
cb'' SignalConnectMode
SignalConnectBefore Maybe Text
forall a. Maybe a
Nothing

-- | Connect a signal handler for the [writable](#signal: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 :: forall a (m :: * -> *).
(IsSocket a, MonadIO m) =>
a -> IO () -> m SignalHandlerId
afterSocketWritable a
obj IO ()
cb = IO SignalHandlerId -> m SignalHandlerId
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SignalHandlerId -> m SignalHandlerId)
-> IO SignalHandlerId -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_SocketDisconnectedCallback
cb' = IO () -> C_SocketDisconnectedCallback
wrap_SocketWritableCallback IO ()
cb
    FunPtr C_SocketDisconnectedCallback
cb'' <- C_SocketDisconnectedCallback
-> IO (FunPtr C_SocketDisconnectedCallback)
mk_SocketWritableCallback C_SocketDisconnectedCallback
cb'
    a
-> Text
-> FunPtr C_SocketDisconnectedCallback
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
forall o a.
GObject o =>
o
-> Text
-> FunPtr a
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
connectSignalFunPtr a
obj Text
"writable" FunPtr C_SocketDisconnectedCallback
cb'' SignalConnectMode
SignalConnectAfter Maybe Text
forall a. Maybe a
Nothing


#if defined(ENABLE_OVERLOADING)
data SocketWritableSignalInfo
instance SignalInfo SocketWritableSignalInfo where
    type HaskellCallbackType SocketWritableSignalInfo = SocketWritableCallback
    connectSignal obj cb connectMode detail = do
        let cb' = wrap_SocketWritableCallback cb
        cb'' <- mk_SocketWritableCallback cb'
        connectSignalFunPtr obj "writable" cb'' connectMode detail

#endif

-- 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 :: forall (m :: * -> *) o. (MonadIO m, IsSocket o) => o -> m (Ptr ())
getSocketAsyncContext o
obj = IO (Ptr ()) -> m (Ptr ())
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
forall a b. (a -> b) -> a -> b
$ o -> String -> IO (Ptr ())
forall a b. GObject a => a -> String -> IO (Ptr b)
B.Properties.getObjectPropertyPtr o
obj String
"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, MIO.MonadIO m) => Ptr () -> m (GValueConstruct o)
constructSocketAsyncContext :: forall o (m :: * -> *).
(IsSocket o, MonadIO m) =>
Ptr () -> m (GValueConstruct o)
constructSocketAsyncContext Ptr ()
val = IO (GValueConstruct o) -> m (GValueConstruct o)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (GValueConstruct o) -> m (GValueConstruct o))
-> IO (GValueConstruct o) -> m (GValueConstruct o)
forall a b. (a -> b) -> a -> b
$ do
    IO (GValueConstruct o) -> IO (GValueConstruct o)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (GValueConstruct o) -> IO (GValueConstruct o))
-> IO (GValueConstruct o) -> IO (GValueConstruct o)
forall a b. (a -> b) -> a -> b
$ String -> Ptr () -> IO (GValueConstruct o)
forall b o. String -> Ptr b -> IO (GValueConstruct o)
B.Properties.constructObjectPropertyPtr String
"async-context" Ptr ()
val

#if defined(ENABLE_OVERLOADING)
data SocketAsyncContextPropertyInfo
instance AttrInfo SocketAsyncContextPropertyInfo where
    type AttrAllowedOps SocketAsyncContextPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrBaseTypeConstraint SocketAsyncContextPropertyInfo = IsSocket
    type AttrSetTypeConstraint SocketAsyncContextPropertyInfo = (~) (Ptr ())
    type AttrTransferTypeConstraint SocketAsyncContextPropertyInfo = (~) (Ptr ())
    type AttrTransferType SocketAsyncContextPropertyInfo = Ptr ()
    type AttrGetType SocketAsyncContextPropertyInfo = (Ptr ())
    type AttrLabel SocketAsyncContextPropertyInfo = "async-context"
    type AttrOrigin SocketAsyncContextPropertyInfo = Socket
    attrGet = getSocketAsyncContext
    attrSet = undefined
    attrTransfer _ v = do
        return v
    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 :: forall (m :: * -> *) o. (MonadIO m, IsSocket o) => o -> m Int32
getSocketFd o
obj = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ o -> String -> IO Int32
forall a. GObject a => a -> String -> IO Int32
B.Properties.getObjectPropertyInt32 o
obj String
"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, MIO.MonadIO m) => Int32 -> m (GValueConstruct o)
constructSocketFd :: forall o (m :: * -> *).
(IsSocket o, MonadIO m) =>
Int32 -> m (GValueConstruct o)
constructSocketFd Int32
val = IO (GValueConstruct o) -> m (GValueConstruct o)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (GValueConstruct o) -> m (GValueConstruct o))
-> IO (GValueConstruct o) -> m (GValueConstruct o)
forall a b. (a -> b) -> a -> b
$ do
    IO (GValueConstruct o) -> IO (GValueConstruct o)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (GValueConstruct o) -> IO (GValueConstruct o))
-> IO (GValueConstruct o) -> IO (GValueConstruct o)
forall a b. (a -> b) -> a -> b
$ String -> Int32 -> IO (GValueConstruct o)
forall o. String -> Int32 -> IO (GValueConstruct o)
B.Properties.constructObjectPropertyInt32 String
"fd" Int32
val

#if defined(ENABLE_OVERLOADING)
data SocketFdPropertyInfo
instance AttrInfo SocketFdPropertyInfo where
    type AttrAllowedOps SocketFdPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrBaseTypeConstraint SocketFdPropertyInfo = IsSocket
    type AttrSetTypeConstraint SocketFdPropertyInfo = (~) Int32
    type AttrTransferTypeConstraint SocketFdPropertyInfo = (~) Int32
    type AttrTransferType SocketFdPropertyInfo = Int32
    type AttrGetType SocketFdPropertyInfo = Int32
    type AttrLabel SocketFdPropertyInfo = "fd"
    type AttrOrigin SocketFdPropertyInfo = Socket
    attrGet = getSocketFd
    attrSet = undefined
    attrTransfer _ v = do
        return v
    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, MIO.MonadIO m, Gio.Socket.IsSocket a) => a -> m (GValueConstruct o)
constructSocketGsocket :: forall o (m :: * -> *) a.
(IsSocket o, MonadIO m, IsSocket a) =>
a -> m (GValueConstruct o)
constructSocketGsocket a
val = IO (GValueConstruct o) -> m (GValueConstruct o)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (GValueConstruct o) -> m (GValueConstruct o))
-> IO (GValueConstruct o) -> m (GValueConstruct o)
forall a b. (a -> b) -> a -> b
$ do
    IO (GValueConstruct o) -> IO (GValueConstruct o)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (GValueConstruct o) -> IO (GValueConstruct o))
-> IO (GValueConstruct o) -> IO (GValueConstruct o)
forall a b. (a -> b) -> a -> b
$ String -> Maybe a -> IO (GValueConstruct o)
forall a o.
GObject a =>
String -> Maybe a -> IO (GValueConstruct o)
B.Properties.constructObjectPropertyObject String
"gsocket" (a -> Maybe a
forall a. a -> Maybe a
P.Just a
val)

#if defined(ENABLE_OVERLOADING)
data SocketGsocketPropertyInfo
instance AttrInfo SocketGsocketPropertyInfo where
    type AttrAllowedOps SocketGsocketPropertyInfo = '[ 'AttrConstruct, 'AttrClear]
    type AttrBaseTypeConstraint SocketGsocketPropertyInfo = IsSocket
    type AttrSetTypeConstraint SocketGsocketPropertyInfo = Gio.Socket.IsSocket
    type AttrTransferTypeConstraint SocketGsocketPropertyInfo = Gio.Socket.IsSocket
    type AttrTransferType SocketGsocketPropertyInfo = Gio.Socket.Socket
    type AttrGetType SocketGsocketPropertyInfo = ()
    type AttrLabel SocketGsocketPropertyInfo = "gsocket"
    type AttrOrigin SocketGsocketPropertyInfo = Socket
    attrGet = undefined
    attrSet = undefined
    attrTransfer _ v = do
        unsafeCastTo Gio.Socket.Socket v
    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, MIO.MonadIO m, Gio.IOStream.IsIOStream a) => a -> m (GValueConstruct o)
constructSocketIostream :: forall o (m :: * -> *) a.
(IsSocket o, MonadIO m, IsIOStream a) =>
a -> m (GValueConstruct o)
constructSocketIostream a
val = IO (GValueConstruct o) -> m (GValueConstruct o)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (GValueConstruct o) -> m (GValueConstruct o))
-> IO (GValueConstruct o) -> m (GValueConstruct o)
forall a b. (a -> b) -> a -> b
$ do
    IO (GValueConstruct o) -> IO (GValueConstruct o)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (GValueConstruct o) -> IO (GValueConstruct o))
-> IO (GValueConstruct o) -> IO (GValueConstruct o)
forall a b. (a -> b) -> a -> b
$ String -> Maybe a -> IO (GValueConstruct o)
forall a o.
GObject a =>
String -> Maybe a -> IO (GValueConstruct o)
B.Properties.constructObjectPropertyObject String
"iostream" (a -> Maybe a
forall a. a -> Maybe a
P.Just a
val)

#if defined(ENABLE_OVERLOADING)
data SocketIostreamPropertyInfo
instance AttrInfo SocketIostreamPropertyInfo where
    type AttrAllowedOps SocketIostreamPropertyInfo = '[ 'AttrConstruct, 'AttrClear]
    type AttrBaseTypeConstraint SocketIostreamPropertyInfo = IsSocket
    type AttrSetTypeConstraint SocketIostreamPropertyInfo = Gio.IOStream.IsIOStream
    type AttrTransferTypeConstraint SocketIostreamPropertyInfo = Gio.IOStream.IsIOStream
    type AttrTransferType SocketIostreamPropertyInfo = Gio.IOStream.IOStream
    type AttrGetType SocketIostreamPropertyInfo = ()
    type AttrLabel SocketIostreamPropertyInfo = "iostream"
    type AttrOrigin SocketIostreamPropertyInfo = Socket
    attrGet = undefined
    attrSet = undefined
    attrTransfer _ v = do
        unsafeCastTo Gio.IOStream.IOStream v
    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 :: forall (m :: * -> *) o. (MonadIO m, IsSocket o) => o -> m Bool
getSocketIpv6Only o
obj = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ o -> String -> IO Bool
forall a. GObject a => a -> String -> IO Bool
B.Properties.getObjectPropertyBool o
obj String
"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 :: forall (m :: * -> *) o.
(MonadIO m, IsSocket o) =>
o -> Bool -> m ()
setSocketIpv6Only o
obj Bool
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    o -> String -> Bool -> IO ()
forall a. GObject a => a -> String -> Bool -> IO ()
B.Properties.setObjectPropertyBool o
obj String
"ipv6-only" Bool
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, MIO.MonadIO m) => Bool -> m (GValueConstruct o)
constructSocketIpv6Only :: forall o (m :: * -> *).
(IsSocket o, MonadIO m) =>
Bool -> m (GValueConstruct o)
constructSocketIpv6Only Bool
val = IO (GValueConstruct o) -> m (GValueConstruct o)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (GValueConstruct o) -> m (GValueConstruct o))
-> IO (GValueConstruct o) -> m (GValueConstruct o)
forall a b. (a -> b) -> a -> b
$ do
    IO (GValueConstruct o) -> IO (GValueConstruct o)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (GValueConstruct o) -> IO (GValueConstruct o))
-> IO (GValueConstruct o) -> IO (GValueConstruct o)
forall a b. (a -> b) -> a -> b
$ String -> Bool -> IO (GValueConstruct o)
forall o. String -> Bool -> IO (GValueConstruct o)
B.Properties.constructObjectPropertyBool String
"ipv6-only" Bool
val

#if defined(ENABLE_OVERLOADING)
data SocketIpv6OnlyPropertyInfo
instance AttrInfo SocketIpv6OnlyPropertyInfo where
    type AttrAllowedOps SocketIpv6OnlyPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrBaseTypeConstraint SocketIpv6OnlyPropertyInfo = IsSocket
    type AttrSetTypeConstraint SocketIpv6OnlyPropertyInfo = (~) Bool
    type AttrTransferTypeConstraint SocketIpv6OnlyPropertyInfo = (~) Bool
    type AttrTransferType SocketIpv6OnlyPropertyInfo = Bool
    type AttrGetType SocketIpv6OnlyPropertyInfo = Bool
    type AttrLabel SocketIpv6OnlyPropertyInfo = "ipv6-only"
    type AttrOrigin SocketIpv6OnlyPropertyInfo = Socket
    attrGet = getSocketIpv6Only
    attrSet = setSocketIpv6Only
    attrTransfer _ v = do
        return v
    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 :: forall (m :: * -> *) o. (MonadIO m, IsSocket o) => o -> m Bool
getSocketIsServer o
obj = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ o -> String -> IO Bool
forall a. GObject a => a -> String -> IO Bool
B.Properties.getObjectPropertyBool o
obj String
"is-server"

#if defined(ENABLE_OVERLOADING)
data SocketIsServerPropertyInfo
instance AttrInfo SocketIsServerPropertyInfo where
    type AttrAllowedOps SocketIsServerPropertyInfo = '[ 'AttrGet]
    type AttrBaseTypeConstraint SocketIsServerPropertyInfo = IsSocket
    type AttrSetTypeConstraint SocketIsServerPropertyInfo = (~) ()
    type AttrTransferTypeConstraint SocketIsServerPropertyInfo = (~) ()
    type AttrTransferType SocketIsServerPropertyInfo = ()
    type AttrGetType SocketIsServerPropertyInfo = Bool
    type AttrLabel SocketIsServerPropertyInfo = "is-server"
    type AttrOrigin SocketIsServerPropertyInfo = Socket
    attrGet = getSocketIsServer
    attrSet = undefined
    attrTransfer _ = 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 :: forall (m :: * -> *) o. (MonadIO m, IsSocket o) => o -> m Address
getSocketLocalAddress o
obj = IO Address -> m Address
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO Address -> m Address) -> IO Address -> m Address
forall a b. (a -> b) -> a -> b
$ Text -> IO (Maybe Address) -> IO Address
forall a. HasCallStack => Text -> IO (Maybe a) -> IO a
checkUnexpectedNothing Text
"getSocketLocalAddress" (IO (Maybe Address) -> IO Address)
-> IO (Maybe Address) -> IO Address
forall a b. (a -> b) -> a -> b
$ o
-> String -> (ManagedPtr Address -> Address) -> IO (Maybe Address)
forall a b.
(GObject a, GObject b) =>
a -> String -> (ManagedPtr b -> b) -> IO (Maybe b)
B.Properties.getObjectPropertyObject o
obj String
"local-address" ManagedPtr Address -> 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, MIO.MonadIO m, Soup.Address.IsAddress a) => a -> m (GValueConstruct o)
constructSocketLocalAddress :: forall o (m :: * -> *) a.
(IsSocket o, MonadIO m, IsAddress a) =>
a -> m (GValueConstruct o)
constructSocketLocalAddress a
val = IO (GValueConstruct o) -> m (GValueConstruct o)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (GValueConstruct o) -> m (GValueConstruct o))
-> IO (GValueConstruct o) -> m (GValueConstruct o)
forall a b. (a -> b) -> a -> b
$ do
    IO (GValueConstruct o) -> IO (GValueConstruct o)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (GValueConstruct o) -> IO (GValueConstruct o))
-> IO (GValueConstruct o) -> IO (GValueConstruct o)
forall a b. (a -> b) -> a -> b
$ String -> Maybe a -> IO (GValueConstruct o)
forall a o.
GObject a =>
String -> Maybe a -> IO (GValueConstruct o)
B.Properties.constructObjectPropertyObject String
"local-address" (a -> Maybe a
forall a. a -> Maybe a
P.Just a
val)

#if defined(ENABLE_OVERLOADING)
data SocketLocalAddressPropertyInfo
instance AttrInfo SocketLocalAddressPropertyInfo where
    type AttrAllowedOps SocketLocalAddressPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrBaseTypeConstraint SocketLocalAddressPropertyInfo = IsSocket
    type AttrSetTypeConstraint SocketLocalAddressPropertyInfo = Soup.Address.IsAddress
    type AttrTransferTypeConstraint SocketLocalAddressPropertyInfo = Soup.Address.IsAddress
    type AttrTransferType SocketLocalAddressPropertyInfo = Soup.Address.Address
    type AttrGetType SocketLocalAddressPropertyInfo = Soup.Address.Address
    type AttrLabel SocketLocalAddressPropertyInfo = "local-address"
    type AttrOrigin SocketLocalAddressPropertyInfo = Socket
    attrGet = getSocketLocalAddress
    attrSet = undefined
    attrTransfer _ v = do
        unsafeCastTo Soup.Address.Address v
    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 :: forall (m :: * -> *) o. (MonadIO m, IsSocket o) => o -> m Bool
getSocketNonBlocking o
obj = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ o -> String -> IO Bool
forall a. GObject a => a -> String -> IO Bool
B.Properties.getObjectPropertyBool o
obj String
"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 :: forall (m :: * -> *) o.
(MonadIO m, IsSocket o) =>
o -> Bool -> m ()
setSocketNonBlocking o
obj Bool
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    o -> String -> Bool -> IO ()
forall a. GObject a => a -> String -> Bool -> IO ()
B.Properties.setObjectPropertyBool o
obj String
"non-blocking" Bool
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, MIO.MonadIO m) => Bool -> m (GValueConstruct o)
constructSocketNonBlocking :: forall o (m :: * -> *).
(IsSocket o, MonadIO m) =>
Bool -> m (GValueConstruct o)
constructSocketNonBlocking Bool
val = IO (GValueConstruct o) -> m (GValueConstruct o)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (GValueConstruct o) -> m (GValueConstruct o))
-> IO (GValueConstruct o) -> m (GValueConstruct o)
forall a b. (a -> b) -> a -> b
$ do
    IO (GValueConstruct o) -> IO (GValueConstruct o)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (GValueConstruct o) -> IO (GValueConstruct o))
-> IO (GValueConstruct o) -> IO (GValueConstruct o)
forall a b. (a -> b) -> a -> b
$ String -> Bool -> IO (GValueConstruct o)
forall o. String -> Bool -> IO (GValueConstruct o)
B.Properties.constructObjectPropertyBool String
"non-blocking" Bool
val

#if defined(ENABLE_OVERLOADING)
data SocketNonBlockingPropertyInfo
instance AttrInfo SocketNonBlockingPropertyInfo where
    type AttrAllowedOps SocketNonBlockingPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrBaseTypeConstraint SocketNonBlockingPropertyInfo = IsSocket
    type AttrSetTypeConstraint SocketNonBlockingPropertyInfo = (~) Bool
    type AttrTransferTypeConstraint SocketNonBlockingPropertyInfo = (~) Bool
    type AttrTransferType SocketNonBlockingPropertyInfo = Bool
    type AttrGetType SocketNonBlockingPropertyInfo = Bool
    type AttrLabel SocketNonBlockingPropertyInfo = "non-blocking"
    type AttrOrigin SocketNonBlockingPropertyInfo = Socket
    attrGet = getSocketNonBlocking
    attrSet = setSocketNonBlocking
    attrTransfer _ v = do
        return v
    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 :: forall (m :: * -> *) o. (MonadIO m, IsSocket o) => o -> m Address
getSocketRemoteAddress o
obj = IO Address -> m Address
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO Address -> m Address) -> IO Address -> m Address
forall a b. (a -> b) -> a -> b
$ Text -> IO (Maybe Address) -> IO Address
forall a. HasCallStack => Text -> IO (Maybe a) -> IO a
checkUnexpectedNothing Text
"getSocketRemoteAddress" (IO (Maybe Address) -> IO Address)
-> IO (Maybe Address) -> IO Address
forall a b. (a -> b) -> a -> b
$ o
-> String -> (ManagedPtr Address -> Address) -> IO (Maybe Address)
forall a b.
(GObject a, GObject b) =>
a -> String -> (ManagedPtr b -> b) -> IO (Maybe b)
B.Properties.getObjectPropertyObject o
obj String
"remote-address" ManagedPtr Address -> 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, MIO.MonadIO m, Soup.Address.IsAddress a) => a -> m (GValueConstruct o)
constructSocketRemoteAddress :: forall o (m :: * -> *) a.
(IsSocket o, MonadIO m, IsAddress a) =>
a -> m (GValueConstruct o)
constructSocketRemoteAddress a
val = IO (GValueConstruct o) -> m (GValueConstruct o)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (GValueConstruct o) -> m (GValueConstruct o))
-> IO (GValueConstruct o) -> m (GValueConstruct o)
forall a b. (a -> b) -> a -> b
$ do
    IO (GValueConstruct o) -> IO (GValueConstruct o)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (GValueConstruct o) -> IO (GValueConstruct o))
-> IO (GValueConstruct o) -> IO (GValueConstruct o)
forall a b. (a -> b) -> a -> b
$ String -> Maybe a -> IO (GValueConstruct o)
forall a o.
GObject a =>
String -> Maybe a -> IO (GValueConstruct o)
B.Properties.constructObjectPropertyObject String
"remote-address" (a -> Maybe a
forall a. a -> Maybe a
P.Just a
val)

#if defined(ENABLE_OVERLOADING)
data SocketRemoteAddressPropertyInfo
instance AttrInfo SocketRemoteAddressPropertyInfo where
    type AttrAllowedOps SocketRemoteAddressPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrBaseTypeConstraint SocketRemoteAddressPropertyInfo = IsSocket
    type AttrSetTypeConstraint SocketRemoteAddressPropertyInfo = Soup.Address.IsAddress
    type AttrTransferTypeConstraint SocketRemoteAddressPropertyInfo = Soup.Address.IsAddress
    type AttrTransferType SocketRemoteAddressPropertyInfo = Soup.Address.Address
    type AttrGetType SocketRemoteAddressPropertyInfo = Soup.Address.Address
    type AttrLabel SocketRemoteAddressPropertyInfo = "remote-address"
    type AttrOrigin SocketRemoteAddressPropertyInfo = Socket
    attrGet = getSocketRemoteAddress
    attrSet = undefined
    attrTransfer _ v = do
        unsafeCastTo Soup.Address.Address v
    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 :: forall (m :: * -> *) o. (MonadIO m, IsSocket o) => o -> m (Ptr ())
getSocketSslCreds o
obj = IO (Ptr ()) -> m (Ptr ())
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
forall a b. (a -> b) -> a -> b
$ o -> String -> IO (Ptr ())
forall a b. GObject a => a -> String -> IO (Ptr b)
B.Properties.getObjectPropertyPtr o
obj String
"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 :: forall (m :: * -> *) o.
(MonadIO m, IsSocket o) =>
o -> Ptr () -> m ()
setSocketSslCreds o
obj Ptr ()
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    o -> String -> Ptr () -> IO ()
forall a b. GObject a => a -> String -> Ptr b -> IO ()
B.Properties.setObjectPropertyPtr o
obj String
"ssl-creds" Ptr ()
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, MIO.MonadIO m) => Ptr () -> m (GValueConstruct o)
constructSocketSslCreds :: forall o (m :: * -> *).
(IsSocket o, MonadIO m) =>
Ptr () -> m (GValueConstruct o)
constructSocketSslCreds Ptr ()
val = IO (GValueConstruct o) -> m (GValueConstruct o)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (GValueConstruct o) -> m (GValueConstruct o))
-> IO (GValueConstruct o) -> m (GValueConstruct o)
forall a b. (a -> b) -> a -> b
$ do
    IO (GValueConstruct o) -> IO (GValueConstruct o)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (GValueConstruct o) -> IO (GValueConstruct o))
-> IO (GValueConstruct o) -> IO (GValueConstruct o)
forall a b. (a -> b) -> a -> b
$ String -> Ptr () -> IO (GValueConstruct o)
forall b o. String -> Ptr b -> IO (GValueConstruct o)
B.Properties.constructObjectPropertyPtr String
"ssl-creds" Ptr ()
val

#if defined(ENABLE_OVERLOADING)
data SocketSslCredsPropertyInfo
instance AttrInfo SocketSslCredsPropertyInfo where
    type AttrAllowedOps SocketSslCredsPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrBaseTypeConstraint SocketSslCredsPropertyInfo = IsSocket
    type AttrSetTypeConstraint SocketSslCredsPropertyInfo = (~) (Ptr ())
    type AttrTransferTypeConstraint SocketSslCredsPropertyInfo = (~) (Ptr ())
    type AttrTransferType SocketSslCredsPropertyInfo = Ptr ()
    type AttrGetType SocketSslCredsPropertyInfo = (Ptr ())
    type AttrLabel SocketSslCredsPropertyInfo = "ssl-creds"
    type AttrOrigin SocketSslCredsPropertyInfo = Socket
    attrGet = getSocketSslCreds
    attrSet = setSocketSslCreds
    attrTransfer _ v = do
        return v
    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 :: forall (m :: * -> *) o. (MonadIO m, IsSocket o) => o -> m Bool
getSocketSslFallback o
obj = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ o -> String -> IO Bool
forall a. GObject a => a -> String -> IO Bool
B.Properties.getObjectPropertyBool o
obj String
"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, MIO.MonadIO m) => Bool -> m (GValueConstruct o)
constructSocketSslFallback :: forall o (m :: * -> *).
(IsSocket o, MonadIO m) =>
Bool -> m (GValueConstruct o)
constructSocketSslFallback Bool
val = IO (GValueConstruct o) -> m (GValueConstruct o)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (GValueConstruct o) -> m (GValueConstruct o))
-> IO (GValueConstruct o) -> m (GValueConstruct o)
forall a b. (a -> b) -> a -> b
$ do
    IO (GValueConstruct o) -> IO (GValueConstruct o)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (GValueConstruct o) -> IO (GValueConstruct o))
-> IO (GValueConstruct o) -> IO (GValueConstruct o)
forall a b. (a -> b) -> a -> b
$ String -> Bool -> IO (GValueConstruct o)
forall o. String -> Bool -> IO (GValueConstruct o)
B.Properties.constructObjectPropertyBool String
"ssl-fallback" Bool
val

#if defined(ENABLE_OVERLOADING)
data SocketSslFallbackPropertyInfo
instance AttrInfo SocketSslFallbackPropertyInfo where
    type AttrAllowedOps SocketSslFallbackPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrBaseTypeConstraint SocketSslFallbackPropertyInfo = IsSocket
    type AttrSetTypeConstraint SocketSslFallbackPropertyInfo = (~) Bool
    type AttrTransferTypeConstraint SocketSslFallbackPropertyInfo = (~) Bool
    type AttrTransferType SocketSslFallbackPropertyInfo = Bool
    type AttrGetType SocketSslFallbackPropertyInfo = Bool
    type AttrLabel SocketSslFallbackPropertyInfo = "ssl-fallback"
    type AttrOrigin SocketSslFallbackPropertyInfo = Socket
    attrGet = getSocketSslFallback
    attrSet = undefined
    attrTransfer _ v = do
        return v
    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 :: forall (m :: * -> *) o. (MonadIO m, IsSocket o) => o -> m Bool
getSocketSslStrict o
obj = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ o -> String -> IO Bool
forall a. GObject a => a -> String -> IO Bool
B.Properties.getObjectPropertyBool o
obj String
"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, MIO.MonadIO m) => Bool -> m (GValueConstruct o)
constructSocketSslStrict :: forall o (m :: * -> *).
(IsSocket o, MonadIO m) =>
Bool -> m (GValueConstruct o)
constructSocketSslStrict Bool
val = IO (GValueConstruct o) -> m (GValueConstruct o)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (GValueConstruct o) -> m (GValueConstruct o))
-> IO (GValueConstruct o) -> m (GValueConstruct o)
forall a b. (a -> b) -> a -> b
$ do
    IO (GValueConstruct o) -> IO (GValueConstruct o)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (GValueConstruct o) -> IO (GValueConstruct o))
-> IO (GValueConstruct o) -> IO (GValueConstruct o)
forall a b. (a -> b) -> a -> b
$ String -> Bool -> IO (GValueConstruct o)
forall o. String -> Bool -> IO (GValueConstruct o)
B.Properties.constructObjectPropertyBool String
"ssl-strict" Bool
val

#if defined(ENABLE_OVERLOADING)
data SocketSslStrictPropertyInfo
instance AttrInfo SocketSslStrictPropertyInfo where
    type AttrAllowedOps SocketSslStrictPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrBaseTypeConstraint SocketSslStrictPropertyInfo = IsSocket
    type AttrSetTypeConstraint SocketSslStrictPropertyInfo = (~) Bool
    type AttrTransferTypeConstraint SocketSslStrictPropertyInfo = (~) Bool
    type AttrTransferType SocketSslStrictPropertyInfo = Bool
    type AttrGetType SocketSslStrictPropertyInfo = Bool
    type AttrLabel SocketSslStrictPropertyInfo = "ssl-strict"
    type AttrOrigin SocketSslStrictPropertyInfo = Socket
    attrGet = getSocketSslStrict
    attrSet = undefined
    attrTransfer _ v = do
        return v
    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 :: forall (m :: * -> *) o. (MonadIO m, IsSocket o) => o -> m Word32
getSocketTimeout o
obj = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ o -> String -> IO Word32
forall a. GObject a => a -> String -> IO Word32
B.Properties.getObjectPropertyUInt32 o
obj String
"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 :: forall (m :: * -> *) o.
(MonadIO m, IsSocket o) =>
o -> Word32 -> m ()
setSocketTimeout o
obj Word32
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    o -> String -> Word32 -> IO ()
forall a. GObject a => a -> String -> Word32 -> IO ()
B.Properties.setObjectPropertyUInt32 o
obj String
"timeout" Word32
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, MIO.MonadIO m) => Word32 -> m (GValueConstruct o)
constructSocketTimeout :: forall o (m :: * -> *).
(IsSocket o, MonadIO m) =>
Word32 -> m (GValueConstruct o)
constructSocketTimeout Word32
val = IO (GValueConstruct o) -> m (GValueConstruct o)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (GValueConstruct o) -> m (GValueConstruct o))
-> IO (GValueConstruct o) -> m (GValueConstruct o)
forall a b. (a -> b) -> a -> b
$ do
    IO (GValueConstruct o) -> IO (GValueConstruct o)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (GValueConstruct o) -> IO (GValueConstruct o))
-> IO (GValueConstruct o) -> IO (GValueConstruct o)
forall a b. (a -> b) -> a -> b
$ String -> Word32 -> IO (GValueConstruct o)
forall o. String -> Word32 -> IO (GValueConstruct o)
B.Properties.constructObjectPropertyUInt32 String
"timeout" Word32
val

#if defined(ENABLE_OVERLOADING)
data SocketTimeoutPropertyInfo
instance AttrInfo SocketTimeoutPropertyInfo where
    type AttrAllowedOps SocketTimeoutPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrBaseTypeConstraint SocketTimeoutPropertyInfo = IsSocket
    type AttrSetTypeConstraint SocketTimeoutPropertyInfo = (~) Word32
    type AttrTransferTypeConstraint SocketTimeoutPropertyInfo = (~) Word32
    type AttrTransferType SocketTimeoutPropertyInfo = Word32
    type AttrGetType SocketTimeoutPropertyInfo = Word32
    type AttrLabel SocketTimeoutPropertyInfo = "timeout"
    type AttrOrigin SocketTimeoutPropertyInfo = Socket
    attrGet = getSocketTimeout
    attrSet = setSocketTimeout
    attrTransfer _ v = do
        return v
    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 :: forall (m :: * -> *) o.
(MonadIO m, IsSocket o) =>
o -> m (Maybe TlsCertificate)
getSocketTlsCertificate o
obj = IO (Maybe TlsCertificate) -> m (Maybe TlsCertificate)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (Maybe TlsCertificate) -> m (Maybe TlsCertificate))
-> IO (Maybe TlsCertificate) -> m (Maybe TlsCertificate)
forall a b. (a -> b) -> a -> b
$ o
-> String
-> (ManagedPtr TlsCertificate -> TlsCertificate)
-> IO (Maybe TlsCertificate)
forall a b.
(GObject a, GObject b) =>
a -> String -> (ManagedPtr b -> b) -> IO (Maybe b)
B.Properties.getObjectPropertyObject o
obj String
"tls-certificate" ManagedPtr TlsCertificate -> TlsCertificate
Gio.TlsCertificate.TlsCertificate

#if defined(ENABLE_OVERLOADING)
data SocketTlsCertificatePropertyInfo
instance AttrInfo SocketTlsCertificatePropertyInfo where
    type AttrAllowedOps SocketTlsCertificatePropertyInfo = '[ 'AttrGet, 'AttrClear]
    type AttrBaseTypeConstraint SocketTlsCertificatePropertyInfo = IsSocket
    type AttrSetTypeConstraint SocketTlsCertificatePropertyInfo = (~) ()
    type AttrTransferTypeConstraint SocketTlsCertificatePropertyInfo = (~) ()
    type AttrTransferType SocketTlsCertificatePropertyInfo = ()
    type AttrGetType SocketTlsCertificatePropertyInfo = (Maybe Gio.TlsCertificate.TlsCertificate)
    type AttrLabel SocketTlsCertificatePropertyInfo = "tls-certificate"
    type AttrOrigin SocketTlsCertificatePropertyInfo = Socket
    attrGet = getSocketTlsCertificate
    attrSet = undefined
    attrTransfer _ = 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 :: forall (m :: * -> *) o.
(MonadIO m, IsSocket o) =>
o -> m [TlsCertificateFlags]
getSocketTlsErrors o
obj = IO [TlsCertificateFlags] -> m [TlsCertificateFlags]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO [TlsCertificateFlags] -> m [TlsCertificateFlags])
-> IO [TlsCertificateFlags] -> m [TlsCertificateFlags]
forall a b. (a -> b) -> a -> b
$ o -> String -> IO [TlsCertificateFlags]
forall a b.
(GObject a, IsGFlag b, BoxedFlags b) =>
a -> String -> IO [b]
B.Properties.getObjectPropertyFlags o
obj String
"tls-errors"

#if defined(ENABLE_OVERLOADING)
data SocketTlsErrorsPropertyInfo
instance AttrInfo SocketTlsErrorsPropertyInfo where
    type AttrAllowedOps SocketTlsErrorsPropertyInfo = '[ 'AttrGet]
    type AttrBaseTypeConstraint SocketTlsErrorsPropertyInfo = IsSocket
    type AttrSetTypeConstraint SocketTlsErrorsPropertyInfo = (~) ()
    type AttrTransferTypeConstraint SocketTlsErrorsPropertyInfo = (~) ()
    type AttrTransferType SocketTlsErrorsPropertyInfo = ()
    type AttrGetType SocketTlsErrorsPropertyInfo = [Gio.Flags.TlsCertificateFlags]
    type AttrLabel SocketTlsErrorsPropertyInfo = "tls-errors"
    type AttrOrigin SocketTlsErrorsPropertyInfo = Socket
    attrGet = getSocketTlsErrors
    attrSet = undefined
    attrTransfer _ = 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 :: forall (m :: * -> *) o. (MonadIO m, IsSocket o) => o -> m Bool
getSocketTrustedCertificate o
obj = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ o -> String -> IO Bool
forall a. GObject a => a -> String -> IO Bool
B.Properties.getObjectPropertyBool o
obj String
"trusted-certificate"

#if defined(ENABLE_OVERLOADING)
data SocketTrustedCertificatePropertyInfo
instance AttrInfo SocketTrustedCertificatePropertyInfo where
    type AttrAllowedOps SocketTrustedCertificatePropertyInfo = '[ 'AttrGet]
    type AttrBaseTypeConstraint SocketTrustedCertificatePropertyInfo = IsSocket
    type AttrSetTypeConstraint SocketTrustedCertificatePropertyInfo = (~) ()
    type AttrTransferTypeConstraint SocketTrustedCertificatePropertyInfo = (~) ()
    type AttrTransferType SocketTrustedCertificatePropertyInfo = ()
    type AttrGetType SocketTrustedCertificatePropertyInfo = Bool
    type AttrLabel SocketTrustedCertificatePropertyInfo = "trusted-certificate"
    type AttrOrigin SocketTrustedCertificatePropertyInfo = Socket
    attrGet = getSocketTrustedCertificate
    attrSet = undefined
    attrTransfer _ = 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 :: forall (m :: * -> *) o. (MonadIO m, IsSocket o) => o -> m Bool
getSocketUseThreadContext o
obj = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ o -> String -> IO Bool
forall a. GObject a => a -> String -> IO Bool
B.Properties.getObjectPropertyBool o
obj String
"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, MIO.MonadIO m) => Bool -> m (GValueConstruct o)
constructSocketUseThreadContext :: forall o (m :: * -> *).
(IsSocket o, MonadIO m) =>
Bool -> m (GValueConstruct o)
constructSocketUseThreadContext Bool
val = IO (GValueConstruct o) -> m (GValueConstruct o)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (GValueConstruct o) -> m (GValueConstruct o))
-> IO (GValueConstruct o) -> m (GValueConstruct o)
forall a b. (a -> b) -> a -> b
$ do
    IO (GValueConstruct o) -> IO (GValueConstruct o)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (GValueConstruct o) -> IO (GValueConstruct o))
-> IO (GValueConstruct o) -> IO (GValueConstruct o)
forall a b. (a -> b) -> a -> b
$ String -> Bool -> IO (GValueConstruct o)
forall o. String -> Bool -> IO (GValueConstruct o)
B.Properties.constructObjectPropertyBool String
"use-thread-context" Bool
val

#if defined(ENABLE_OVERLOADING)
data SocketUseThreadContextPropertyInfo
instance AttrInfo SocketUseThreadContextPropertyInfo where
    type AttrAllowedOps SocketUseThreadContextPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrBaseTypeConstraint SocketUseThreadContextPropertyInfo = IsSocket
    type AttrSetTypeConstraint SocketUseThreadContextPropertyInfo = (~) Bool
    type AttrTransferTypeConstraint SocketUseThreadContextPropertyInfo = (~) Bool
    type AttrTransferType SocketUseThreadContextPropertyInfo = Bool
    type AttrGetType SocketUseThreadContextPropertyInfo = Bool
    type AttrLabel SocketUseThreadContextPropertyInfo = "use-thread-context"
    type AttrOrigin SocketUseThreadContextPropertyInfo = Socket
    attrGet = getSocketUseThreadContext
    attrSet = undefined
    attrTransfer _ v = do
        return v
    attrConstruct = constructSocketUseThreadContext
    attrClear = undefined
#endif

#if defined(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 defined(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 defined(ENABLE_OVERLOADING)
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-'P.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 t'GI.Soup.Objects.Socket.Socket' (which must not already be connected)
    -> Maybe (b)
    -- ^ /@cancellable@/: a t'GI.Gio.Objects.Cancellable.Cancellable', or 'P.Nothing'
    -> Soup.Callbacks.SocketCallback
    -- ^ /@callback@/: callback to call after connecting
    -> m ()
socketConnectAsync :: forall (m :: * -> *) a b.
(HasCallStack, MonadIO m, IsSocket a, IsCancellable b) =>
a -> Maybe b -> SocketCallback -> m ()
socketConnectAsync a
sock Maybe b
cancellable SocketCallback
callback = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Socket
sock' <- a -> IO (Ptr Socket)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
sock
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Maybe b
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just b
jCancellable -> do
            Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    Ptr (FunPtr C_SocketCallback)
ptrcallback <- IO (Ptr (FunPtr C_SocketCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Soup.Callbacks.C_SocketCallback))
    FunPtr C_SocketCallback
callback' <- C_SocketCallback -> IO (FunPtr C_SocketCallback)
Soup.Callbacks.mk_SocketCallback (Maybe (Ptr (FunPtr C_SocketCallback))
-> SocketCallback_WithClosures -> C_SocketCallback
Soup.Callbacks.wrap_SocketCallback (Ptr (FunPtr C_SocketCallback)
-> Maybe (Ptr (FunPtr C_SocketCallback))
forall a. a -> Maybe a
Just Ptr (FunPtr C_SocketCallback)
ptrcallback) (SocketCallback -> SocketCallback_WithClosures
Soup.Callbacks.drop_closures_SocketCallback SocketCallback
callback))
    Ptr (FunPtr C_SocketCallback) -> FunPtr C_SocketCallback -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_SocketCallback)
ptrcallback FunPtr C_SocketCallback
callback'
    let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
    Ptr Socket
-> Ptr Cancellable -> FunPtr C_SocketCallback -> Ptr () -> IO ()
soup_socket_connect_async Ptr Socket
sock' Ptr Cancellable
maybeCancellable FunPtr C_SocketCallback
callback' Ptr ()
forall a. Ptr a
userData
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
sock
    Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data SocketConnectAsyncMethodInfo
instance (signature ~ (Maybe (b) -> Soup.Callbacks.SocketCallback -> m ()), MonadIO m, IsSocket a, Gio.Cancellable.IsCancellable b) => O.OverloadedMethod SocketConnectAsyncMethodInfo a signature where
    overloadedMethod = socketConnectAsync

instance O.OverloadedMethodInfo SocketConnectAsyncMethodInfo a where
    overloadedMethodInfo = O.MethodInfo {
        O.overloadedMethodName = "GI.Soup.Objects.Socket.socketConnectAsync",
        O.overloadedMethodURL = "https://hackage.haskell.org/package/gi-soup-2.4.24/docs/GI-Soup-Objects-Socket.html#v: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-'P.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 t'GI.Soup.Objects.Socket.Socket' (which must not already be connected)
    -> Maybe (b)
    -- ^ /@cancellable@/: a t'GI.Gio.Objects.Cancellable.Cancellable', or 'P.Nothing'
    -> m Word32
    -- ^ __Returns:__ a success or failure code.
socketConnectSync :: forall (m :: * -> *) a b.
(HasCallStack, MonadIO m, IsSocket a, IsCancellable b) =>
a -> Maybe b -> m Word32
socketConnectSync a
sock Maybe b
cancellable = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Ptr Socket
sock' <- a -> IO (Ptr Socket)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
sock
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Maybe b
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just b
jCancellable -> do
            Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    Word32
result <- Ptr Socket -> Ptr Cancellable -> IO Word32
soup_socket_connect_sync Ptr Socket
sock' Ptr Cancellable
maybeCancellable
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
sock
    Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result

#if defined(ENABLE_OVERLOADING)
data SocketConnectSyncMethodInfo
instance (signature ~ (Maybe (b) -> m Word32), MonadIO m, IsSocket a, Gio.Cancellable.IsCancellable b) => O.OverloadedMethod SocketConnectSyncMethodInfo a signature where
    overloadedMethod = socketConnectSync

instance O.OverloadedMethodInfo SocketConnectSyncMethodInfo a where
    overloadedMethodInfo = O.MethodInfo {
        O.overloadedMethodName = "GI.Soup.Objects.Socket.socketConnectSync",
        O.overloadedMethodURL = "https://hackage.haskell.org/package/gi-soup-2.4.24/docs/GI-Soup-Objects-Socket.html#v: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 t'GI.Soup.Objects.Socket.Socket'
    -> m ()
socketDisconnect :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsSocket a) =>
a -> m ()
socketDisconnect a
sock = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Socket
sock' <- a -> IO (Ptr Socket)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
sock
    Ptr Socket -> IO ()
soup_socket_disconnect Ptr Socket
sock'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
sock
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data SocketDisconnectMethodInfo
instance (signature ~ (m ()), MonadIO m, IsSocket a) => O.OverloadedMethod SocketDisconnectMethodInfo a signature where
    overloadedMethod = socketDisconnect

instance O.OverloadedMethodInfo SocketDisconnectMethodInfo a where
    overloadedMethodInfo = O.MethodInfo {
        O.overloadedMethodName = "GI.Soup.Objects.Socket.socketDisconnect",
        O.overloadedMethodURL = "https://hackage.haskell.org/package/gi-soup-2.4.24/docs/GI-Soup-Objects-Socket.html#v: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
-- t'GI.Soup.Objects.Socket.Socket'.
socketGetFd ::
    (B.CallStack.HasCallStack, MonadIO m, IsSocket a) =>
    a
    -- ^ /@sock@/: a t'GI.Soup.Objects.Socket.Socket'
    -> m Int32
    -- ^ __Returns:__ /@sock@/\'s file descriptor.
socketGetFd :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsSocket a) =>
a -> m Int32
socketGetFd a
sock = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    Ptr Socket
sock' <- a -> IO (Ptr Socket)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
sock
    Int32
result <- Ptr Socket -> IO Int32
soup_socket_get_fd Ptr Socket
sock'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
sock
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
result

#if defined(ENABLE_OVERLOADING)
data SocketGetFdMethodInfo
instance (signature ~ (m Int32), MonadIO m, IsSocket a) => O.OverloadedMethod SocketGetFdMethodInfo a signature where
    overloadedMethod = socketGetFd

instance O.OverloadedMethodInfo SocketGetFdMethodInfo a where
    overloadedMethodInfo = O.MethodInfo {
        O.overloadedMethodName = "GI.Soup.Objects.Socket.socketGetFd",
        O.overloadedMethodURL = "https://hackage.haskell.org/package/gi-soup-2.4.24/docs/GI-Soup-Objects-Socket.html#v: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 t'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 t'GI.Soup.Objects.Socket.Socket'
    -> m Soup.Address.Address
    -- ^ __Returns:__ the t'GI.Soup.Objects.Address.Address'
socketGetLocalAddress :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsSocket a) =>
a -> m Address
socketGetLocalAddress a
sock = IO Address -> m Address
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Address -> m Address) -> IO Address -> m Address
forall a b. (a -> b) -> a -> b
$ do
    Ptr Socket
sock' <- a -> IO (Ptr Socket)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
sock
    Ptr Address
result <- Ptr Socket -> IO (Ptr Address)
soup_socket_get_local_address Ptr Socket
sock'
    Text -> Ptr Address -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"socketGetLocalAddress" Ptr Address
result
    Address
result' <- ((ManagedPtr Address -> Address) -> Ptr Address -> IO Address
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr Address -> Address
Soup.Address.Address) Ptr Address
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
sock
    Address -> IO Address
forall (m :: * -> *) a. Monad m => a -> m a
return Address
result'

#if defined(ENABLE_OVERLOADING)
data SocketGetLocalAddressMethodInfo
instance (signature ~ (m Soup.Address.Address), MonadIO m, IsSocket a) => O.OverloadedMethod SocketGetLocalAddressMethodInfo a signature where
    overloadedMethod = socketGetLocalAddress

instance O.OverloadedMethodInfo SocketGetLocalAddressMethodInfo a where
    overloadedMethodInfo = O.MethodInfo {
        O.overloadedMethodName = "GI.Soup.Objects.Socket.socketGetLocalAddress",
        O.overloadedMethodURL = "https://hackage.haskell.org/package/gi-soup-2.4.24/docs/GI-Soup-Objects-Socket.html#v: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 t'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 t'GI.Soup.Objects.Socket.Socket'
    -> m Soup.Address.Address
    -- ^ __Returns:__ the t'GI.Soup.Objects.Address.Address'
socketGetRemoteAddress :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsSocket a) =>
a -> m Address
socketGetRemoteAddress a
sock = IO Address -> m Address
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Address -> m Address) -> IO Address -> m Address
forall a b. (a -> b) -> a -> b
$ do
    Ptr Socket
sock' <- a -> IO (Ptr Socket)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
sock
    Ptr Address
result <- Ptr Socket -> IO (Ptr Address)
soup_socket_get_remote_address Ptr Socket
sock'
    Text -> Ptr Address -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"socketGetRemoteAddress" Ptr Address
result
    Address
result' <- ((ManagedPtr Address -> Address) -> Ptr Address -> IO Address
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr Address -> Address
Soup.Address.Address) Ptr Address
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
sock
    Address -> IO Address
forall (m :: * -> *) a. Monad m => a -> m a
return Address
result'

#if defined(ENABLE_OVERLOADING)
data SocketGetRemoteAddressMethodInfo
instance (signature ~ (m Soup.Address.Address), MonadIO m, IsSocket a) => O.OverloadedMethod SocketGetRemoteAddressMethodInfo a signature where
    overloadedMethod = socketGetRemoteAddress

instance O.OverloadedMethodInfo SocketGetRemoteAddressMethodInfo a where
    overloadedMethodInfo = O.MethodInfo {
        O.overloadedMethodName = "GI.Soup.Objects.Socket.socketGetRemoteAddress",
        O.overloadedMethodURL = "https://hackage.haskell.org/package/gi-soup-2.4.24/docs/GI-Soup-Objects-Socket.html#v: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 t'GI.Soup.Objects.Socket.Socket'
    -> m Bool
    -- ^ __Returns:__ 'P.True' or 'P.False'.
socketIsConnected :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsSocket a) =>
a -> m Bool
socketIsConnected a
sock = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Socket
sock' <- a -> IO (Ptr Socket)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
sock
    CInt
result <- Ptr Socket -> IO CInt
soup_socket_is_connected Ptr Socket
sock'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
sock
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
data SocketIsConnectedMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsSocket a) => O.OverloadedMethod SocketIsConnectedMethodInfo a signature where
    overloadedMethod = socketIsConnected

instance O.OverloadedMethodInfo SocketIsConnectedMethodInfo a where
    overloadedMethodInfo = O.MethodInfo {
        O.overloadedMethodName = "GI.Soup.Objects.Socket.socketIsConnected",
        O.overloadedMethodURL = "https://hackage.haskell.org/package/gi-soup-2.4.24/docs/GI-Soup-Objects-Socket.html#v: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 t'GI.Soup.Objects.Socket.Socket'
    -> m Bool
    -- ^ __Returns:__ 'P.True' if /@sock@/ has SSL credentials set
socketIsSsl :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsSocket a) =>
a -> m Bool
socketIsSsl a
sock = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Socket
sock' <- a -> IO (Ptr Socket)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
sock
    CInt
result <- Ptr Socket -> IO CInt
soup_socket_is_ssl Ptr Socket
sock'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
sock
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
data SocketIsSslMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsSocket a) => O.OverloadedMethod SocketIsSslMethodInfo a signature where
    overloadedMethod = socketIsSsl

instance O.OverloadedMethodInfo SocketIsSslMethodInfo a where
    overloadedMethodInfo = O.MethodInfo {
        O.overloadedMethodName = "GI.Soup.Objects.Socket.socketIsSsl",
        O.overloadedMethodURL = "https://hackage.haskell.org/package/gi-soup-2.4.24/docs/GI-Soup-Objects-Socket.html#v: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 t'GI.Soup.Objects.Socket.Socket'::@/new_connection/@.
socketListen ::
    (B.CallStack.HasCallStack, MonadIO m, IsSocket a) =>
    a
    -- ^ /@sock@/: a server t'GI.Soup.Objects.Socket.Socket' (which must not already be connected or
    -- listening)
    -> m Bool
    -- ^ __Returns:__ whether or not /@sock@/ is now listening.
socketListen :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsSocket a) =>
a -> m Bool
socketListen a
sock = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Socket
sock' <- a -> IO (Ptr Socket)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
sock
    CInt
result <- Ptr Socket -> IO CInt
soup_socket_listen Ptr Socket
sock'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
sock
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
data SocketListenMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsSocket a) => O.OverloadedMethod SocketListenMethodInfo a signature where
    overloadedMethod = socketListen

instance O.OverloadedMethodInfo SocketListenMethodInfo a where
    overloadedMethodInfo = O.MethodInfo {
        O.overloadedMethodName = "GI.Soup.Objects.Socket.socketListen",
        O.overloadedMethodURL = "https://hackage.haskell.org/package/gi-soup-2.4.24/docs/GI-Soup-Objects-Socket.html#v: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 [readable]("GI.Soup.Objects.Socket#g:signal:readable") signal to know when there
-- is more data to read. (NB: You MUST read all available data off the
-- socket first. [readable]("GI.Soup.Objects.Socket#g:signal: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 t'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 t'GI.Gio.Objects.Cancellable.Cancellable', or 'P.Nothing'
    -> m ((Soup.Enums.SocketIOStatus, Word64))
    -- ^ __Returns:__ a t'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 :: forall (m :: * -> *) a b.
(HasCallStack, MonadIO m, IsSocket a, IsCancellable b) =>
a -> ByteString -> Maybe b -> m (SocketIOStatus, Word64)
socketRead a
sock ByteString
buffer Maybe b
cancellable = IO (SocketIOStatus, Word64) -> m (SocketIOStatus, Word64)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (SocketIOStatus, Word64) -> m (SocketIOStatus, Word64))
-> IO (SocketIOStatus, Word64) -> m (SocketIOStatus, Word64)
forall a b. (a -> b) -> a -> b
$ do
    let len :: Word64
len = Int -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Word64) -> Int -> Word64
forall a b. (a -> b) -> a -> b
$ ByteString -> Int
B.length ByteString
buffer
    Ptr Socket
sock' <- a -> IO (Ptr Socket)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
sock
    Ptr Word8
buffer' <- ByteString -> IO (Ptr Word8)
packByteString ByteString
buffer
    Ptr Word64
nread <- IO (Ptr Word64)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Maybe b
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just b
jCancellable -> do
            Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    IO (SocketIOStatus, Word64) -> IO () -> IO (SocketIOStatus, Word64)
forall a b. IO a -> IO b -> IO a
onException (do
        CUInt
result <- (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CUInt) -> IO CUInt)
-> (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a b. (a -> b) -> a -> b
$ Ptr Socket
-> Ptr Word8
-> Word64
-> Ptr Word64
-> Ptr Cancellable
-> Ptr (Ptr GError)
-> IO CUInt
soup_socket_read Ptr Socket
sock' Ptr Word8
buffer' Word64
len Ptr Word64
nread Ptr Cancellable
maybeCancellable
        let result' :: SocketIOStatus
result' = (Int -> SocketIOStatus
forall a. Enum a => Int -> a
toEnum (Int -> SocketIOStatus)
-> (CUInt -> Int) -> CUInt -> SocketIOStatus
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
result
        Word64
nread' <- Ptr Word64 -> IO Word64
forall a. Storable a => Ptr a -> IO a
peek Ptr Word64
nread
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
sock
        Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
buffer'
        Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
nread
        (SocketIOStatus, Word64) -> IO (SocketIOStatus, Word64)
forall (m :: * -> *) a. Monad m => a -> m a
return (SocketIOStatus
result', Word64
nread')
     ) (do
        Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
buffer'
        Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
nread
     )

#if defined(ENABLE_OVERLOADING)
data SocketReadMethodInfo
instance (signature ~ (ByteString -> Maybe (b) -> m ((Soup.Enums.SocketIOStatus, Word64))), MonadIO m, IsSocket a, Gio.Cancellable.IsCancellable b) => O.OverloadedMethod SocketReadMethodInfo a signature where
    overloadedMethod = socketRead

instance O.OverloadedMethodInfo SocketReadMethodInfo a where
    overloadedMethodInfo = O.MethodInfo {
        O.overloadedMethodName = "GI.Soup.Objects.Socket.socketRead",
        O.overloadedMethodURL = "https://hackage.haskell.org/package/gi-soup-2.4.24/docs/GI-Soup-Objects-Socket.html#v: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
-- 'P.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 t'GI.Gio.Objects.Cancellable.Cancellable', or 'P.Nothing'
    -> m ((Soup.Enums.SocketIOStatus, Word64))
    -- ^ __Returns:__ as for 'GI.Soup.Objects.Socket.socketRead' /(Can throw 'Data.GI.Base.GError.GError')/
socketReadUntil :: forall (m :: * -> *) a b.
(HasCallStack, MonadIO m, IsSocket a, IsCancellable b) =>
a
-> ByteString
-> Ptr ()
-> Word64
-> Bool
-> Maybe b
-> m (SocketIOStatus, Word64)
socketReadUntil a
sock ByteString
buffer Ptr ()
boundary Word64
boundaryLen Bool
gotBoundary Maybe b
cancellable = IO (SocketIOStatus, Word64) -> m (SocketIOStatus, Word64)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (SocketIOStatus, Word64) -> m (SocketIOStatus, Word64))
-> IO (SocketIOStatus, Word64) -> m (SocketIOStatus, Word64)
forall a b. (a -> b) -> a -> b
$ do
    let len :: Word64
len = Int -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Word64) -> Int -> Word64
forall a b. (a -> b) -> a -> b
$ ByteString -> Int
B.length ByteString
buffer
    Ptr Socket
sock' <- a -> IO (Ptr Socket)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
sock
    Ptr Word8
buffer' <- ByteString -> IO (Ptr Word8)
packByteString ByteString
buffer
    Ptr Word64
nread <- IO (Ptr Word64)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
    let gotBoundary' :: CInt
gotBoundary' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
fromEnum) Bool
gotBoundary
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Maybe b
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just b
jCancellable -> do
            Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    IO (SocketIOStatus, Word64) -> IO () -> IO (SocketIOStatus, Word64)
forall a b. IO a -> IO b -> IO a
onException (do
        CUInt
result <- (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CUInt) -> IO CUInt)
-> (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a b. (a -> b) -> a -> b
$ Ptr Socket
-> Ptr Word8
-> Word64
-> Ptr ()
-> Word64
-> Ptr Word64
-> CInt
-> Ptr Cancellable
-> Ptr (Ptr GError)
-> IO CUInt
soup_socket_read_until Ptr Socket
sock' Ptr Word8
buffer' Word64
len Ptr ()
boundary Word64
boundaryLen Ptr Word64
nread CInt
gotBoundary' Ptr Cancellable
maybeCancellable
        let result' :: SocketIOStatus
result' = (Int -> SocketIOStatus
forall a. Enum a => Int -> a
toEnum (Int -> SocketIOStatus)
-> (CUInt -> Int) -> CUInt -> SocketIOStatus
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
result
        Word64
nread' <- Ptr Word64 -> IO Word64
forall a. Storable a => Ptr a -> IO a
peek Ptr Word64
nread
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
sock
        Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
buffer'
        Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
nread
        (SocketIOStatus, Word64) -> IO (SocketIOStatus, Word64)
forall (m :: * -> *) a. Monad m => a -> m a
return (SocketIOStatus
result', Word64
nread')
     ) (do
        Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
buffer'
        Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
nread
     )

#if defined(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.OverloadedMethod SocketReadUntilMethodInfo a signature where
    overloadedMethod = socketReadUntil

instance O.OverloadedMethodInfo SocketReadUntilMethodInfo a where
    overloadedMethodInfo = O.MethodInfo {
        O.overloadedMethodName = "GI.Soup.Objects.Socket.socketReadUntil",
        O.overloadedMethodURL = "https://hackage.haskell.org/package/gi-soup-2.4.24/docs/GI-Soup-Objects-Socket.html#v: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 t'GI.Gio.Objects.Cancellable.Cancellable'
    -> m Bool
    -- ^ __Returns:__ success or failure
socketStartProxySsl :: forall (m :: * -> *) a b.
(HasCallStack, MonadIO m, IsSocket a, IsCancellable b) =>
a -> Text -> Maybe b -> m Bool
socketStartProxySsl a
sock Text
sslHost Maybe b
cancellable = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Socket
sock' <- a -> IO (Ptr Socket)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
sock
    CString
sslHost' <- Text -> IO CString
textToCString Text
sslHost
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Maybe b
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just b
jCancellable -> do
            Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    CInt
result <- Ptr Socket -> CString -> Ptr Cancellable -> IO CInt
soup_socket_start_proxy_ssl Ptr Socket
sock' CString
sslHost' Ptr Cancellable
maybeCancellable
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
sock
    Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
sslHost'
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
data SocketStartProxySslMethodInfo
instance (signature ~ (T.Text -> Maybe (b) -> m Bool), MonadIO m, IsSocket a, Gio.Cancellable.IsCancellable b) => O.OverloadedMethod SocketStartProxySslMethodInfo a signature where
    overloadedMethod = socketStartProxySsl

instance O.OverloadedMethodInfo SocketStartProxySslMethodInfo a where
    overloadedMethodInfo = O.MethodInfo {
        O.overloadedMethodName = "GI.Soup.Objects.Socket.socketStartProxySsl",
        O.overloadedMethodURL = "https://hackage.haskell.org/package/gi-soup-2.4.24/docs/GI-Soup-Objects-Socket.html#v: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 t'GI.Gio.Objects.Cancellable.Cancellable'
    -> m Bool
    -- ^ __Returns:__ success or failure
socketStartSsl :: forall (m :: * -> *) a b.
(HasCallStack, MonadIO m, IsSocket a, IsCancellable b) =>
a -> Maybe b -> m Bool
socketStartSsl a
sock Maybe b
cancellable = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Socket
sock' <- a -> IO (Ptr Socket)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
sock
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Maybe b
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just b
jCancellable -> do
            Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    CInt
result <- Ptr Socket -> Ptr Cancellable -> IO CInt
soup_socket_start_ssl Ptr Socket
sock' Ptr Cancellable
maybeCancellable
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
sock
    Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
data SocketStartSslMethodInfo
instance (signature ~ (Maybe (b) -> m Bool), MonadIO m, IsSocket a, Gio.Cancellable.IsCancellable b) => O.OverloadedMethod SocketStartSslMethodInfo a signature where
    overloadedMethod = socketStartSsl

instance O.OverloadedMethodInfo SocketStartSslMethodInfo a where
    overloadedMethodInfo = O.MethodInfo {
        O.overloadedMethodName = "GI.Soup.Objects.Socket.socketStartSsl",
        O.overloadedMethodURL = "https://hackage.haskell.org/package/gi-soup-2.4.24/docs/GI-Soup-Objects-Socket.html#v: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 [writable]("GI.Soup.Objects.Socket#g:signal:writable") signal to know
-- when more data can be written. (NB: [writable]("GI.Soup.Objects.Socket#g:signal: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
-- t'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 t'GI.Gio.Objects.Cancellable.Cancellable', or 'P.Nothing'
    -> m ((Soup.Enums.SocketIOStatus, Word64))
    -- ^ __Returns:__ a t'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 :: forall (m :: * -> *) a b.
(HasCallStack, MonadIO m, IsSocket a, IsCancellable b) =>
a -> ByteString -> Maybe b -> m (SocketIOStatus, Word64)
socketWrite a
sock ByteString
buffer Maybe b
cancellable = IO (SocketIOStatus, Word64) -> m (SocketIOStatus, Word64)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (SocketIOStatus, Word64) -> m (SocketIOStatus, Word64))
-> IO (SocketIOStatus, Word64) -> m (SocketIOStatus, Word64)
forall a b. (a -> b) -> a -> b
$ do
    let len :: Word64
len = Int -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Word64) -> Int -> Word64
forall a b. (a -> b) -> a -> b
$ ByteString -> Int
B.length ByteString
buffer
    Ptr Socket
sock' <- a -> IO (Ptr Socket)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
sock
    Ptr Word8
buffer' <- ByteString -> IO (Ptr Word8)
packByteString ByteString
buffer
    Ptr Word64
nwrote <- IO (Ptr Word64)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Maybe b
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just b
jCancellable -> do
            Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    IO (SocketIOStatus, Word64) -> IO () -> IO (SocketIOStatus, Word64)
forall a b. IO a -> IO b -> IO a
onException (do
        CUInt
result <- (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CUInt) -> IO CUInt)
-> (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a b. (a -> b) -> a -> b
$ Ptr Socket
-> Ptr Word8
-> Word64
-> Ptr Word64
-> Ptr Cancellable
-> Ptr (Ptr GError)
-> IO CUInt
soup_socket_write Ptr Socket
sock' Ptr Word8
buffer' Word64
len Ptr Word64
nwrote Ptr Cancellable
maybeCancellable
        let result' :: SocketIOStatus
result' = (Int -> SocketIOStatus
forall a. Enum a => Int -> a
toEnum (Int -> SocketIOStatus)
-> (CUInt -> Int) -> CUInt -> SocketIOStatus
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
result
        Word64
nwrote' <- Ptr Word64 -> IO Word64
forall a. Storable a => Ptr a -> IO a
peek Ptr Word64
nwrote
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
sock
        Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
buffer'
        Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
nwrote
        (SocketIOStatus, Word64) -> IO (SocketIOStatus, Word64)
forall (m :: * -> *) a. Monad m => a -> m a
return (SocketIOStatus
result', Word64
nwrote')
     ) (do
        Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
buffer'
        Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
nwrote
     )

#if defined(ENABLE_OVERLOADING)
data SocketWriteMethodInfo
instance (signature ~ (ByteString -> Maybe (b) -> m ((Soup.Enums.SocketIOStatus, Word64))), MonadIO m, IsSocket a, Gio.Cancellable.IsCancellable b) => O.OverloadedMethod SocketWriteMethodInfo a signature where
    overloadedMethod = socketWrite

instance O.OverloadedMethodInfo SocketWriteMethodInfo a where
    overloadedMethodInfo = O.MethodInfo {
        O.overloadedMethodName = "GI.Soup.Objects.Socket.socketWrite",
        O.overloadedMethodURL = "https://hackage.haskell.org/package/gi-soup-2.4.24/docs/GI-Soup-Objects-Socket.html#v:socketWrite"
        }


#endif