{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- /No description available in the introspection data./

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

module GI.Soup.Objects.WebsocketExtension
    ( 

-- * Exported types
    WebsocketExtension(..)                  ,
    IsWebsocketExtension                    ,
    toWebsocketExtension                    ,


 -- * Methods
-- ** Overloaded methods #method:Overloaded methods#

#if defined(ENABLE_OVERLOADING)
    ResolveWebsocketExtensionMethod         ,
#endif


-- ** configure #method:configure#

#if defined(ENABLE_OVERLOADING)
    WebsocketExtensionConfigureMethodInfo   ,
#endif
    websocketExtensionConfigure             ,


-- ** getRequestParams #method:getRequestParams#

#if defined(ENABLE_OVERLOADING)
    WebsocketExtensionGetRequestParamsMethodInfo,
#endif
    websocketExtensionGetRequestParams      ,


-- ** getResponseParams #method:getResponseParams#

#if defined(ENABLE_OVERLOADING)
    WebsocketExtensionGetResponseParamsMethodInfo,
#endif
    websocketExtensionGetResponseParams     ,


-- ** processIncomingMessage #method:processIncomingMessage#

#if defined(ENABLE_OVERLOADING)
    WebsocketExtensionProcessIncomingMessageMethodInfo,
#endif
    websocketExtensionProcessIncomingMessage,


-- ** processOutgoingMessage #method:processOutgoingMessage#

#if defined(ENABLE_OVERLOADING)
    WebsocketExtensionProcessOutgoingMessageMethodInfo,
#endif
    websocketExtensionProcessOutgoingMessage,




    ) 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.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 GI.GLib.Structs.Bytes as GLib.Bytes
import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Soup.Enums as Soup.Enums

-- | Memory-managed wrapper type.
newtype WebsocketExtension = WebsocketExtension (SP.ManagedPtr WebsocketExtension)
    deriving (WebsocketExtension -> WebsocketExtension -> Bool
(WebsocketExtension -> WebsocketExtension -> Bool)
-> (WebsocketExtension -> WebsocketExtension -> Bool)
-> Eq WebsocketExtension
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WebsocketExtension -> WebsocketExtension -> Bool
$c/= :: WebsocketExtension -> WebsocketExtension -> Bool
== :: WebsocketExtension -> WebsocketExtension -> Bool
$c== :: WebsocketExtension -> WebsocketExtension -> Bool
Eq)

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

foreign import ccall "soup_websocket_extension_get_type"
    c_soup_websocket_extension_get_type :: IO B.Types.GType

instance B.Types.TypedObject WebsocketExtension where
    glibType :: IO GType
glibType = IO GType
c_soup_websocket_extension_get_type

instance B.Types.GObject WebsocketExtension

-- | Convert 'WebsocketExtension' to and from 'Data.GI.Base.GValue.GValue' with 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue WebsocketExtension where
    toGValue :: WebsocketExtension -> IO GValue
toGValue WebsocketExtension
o = do
        GType
gtype <- IO GType
c_soup_websocket_extension_get_type
        WebsocketExtension
-> (Ptr WebsocketExtension -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr WebsocketExtension
o (GType
-> (GValue -> Ptr WebsocketExtension -> IO ())
-> Ptr WebsocketExtension
-> IO GValue
forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
B.GValue.buildGValue GType
gtype GValue -> Ptr WebsocketExtension -> IO ()
forall a. GObject a => GValue -> Ptr a -> IO ()
B.GValue.set_object)
        
    fromGValue :: GValue -> IO WebsocketExtension
fromGValue GValue
gv = do
        Ptr WebsocketExtension
ptr <- GValue -> IO (Ptr WebsocketExtension)
forall b. GObject b => GValue -> IO (Ptr b)
B.GValue.get_object GValue
gv :: IO (Ptr WebsocketExtension)
        (ManagedPtr WebsocketExtension -> WebsocketExtension)
-> Ptr WebsocketExtension -> IO WebsocketExtension
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
B.ManagedPtr.newObject ManagedPtr WebsocketExtension -> WebsocketExtension
WebsocketExtension Ptr WebsocketExtension
ptr
        
    

-- | Type class for types which can be safely cast to `WebsocketExtension`, for instance with `toWebsocketExtension`.
class (SP.GObject o, O.IsDescendantOf WebsocketExtension o) => IsWebsocketExtension o
instance (SP.GObject o, O.IsDescendantOf WebsocketExtension o) => IsWebsocketExtension o

instance O.HasParentTypes WebsocketExtension
type instance O.ParentTypes WebsocketExtension = '[GObject.Object.Object]

-- | Cast to `WebsocketExtension`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toWebsocketExtension :: (MonadIO m, IsWebsocketExtension o) => o -> m WebsocketExtension
toWebsocketExtension :: o -> m WebsocketExtension
toWebsocketExtension = IO WebsocketExtension -> m WebsocketExtension
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO WebsocketExtension -> m WebsocketExtension)
-> (o -> IO WebsocketExtension) -> o -> m WebsocketExtension
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr WebsocketExtension -> WebsocketExtension)
-> o -> IO WebsocketExtension
forall o o'.
(HasCallStack, ManagedPtrNewtype o, TypedObject o,
 ManagedPtrNewtype o', TypedObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
unsafeCastTo ManagedPtr WebsocketExtension -> WebsocketExtension
WebsocketExtension

#if defined(ENABLE_OVERLOADING)
type family ResolveWebsocketExtensionMethod (t :: Symbol) (o :: *) :: * where
    ResolveWebsocketExtensionMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveWebsocketExtensionMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveWebsocketExtensionMethod "configure" o = WebsocketExtensionConfigureMethodInfo
    ResolveWebsocketExtensionMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveWebsocketExtensionMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveWebsocketExtensionMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveWebsocketExtensionMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveWebsocketExtensionMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveWebsocketExtensionMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveWebsocketExtensionMethod "processIncomingMessage" o = WebsocketExtensionProcessIncomingMessageMethodInfo
    ResolveWebsocketExtensionMethod "processOutgoingMessage" o = WebsocketExtensionProcessOutgoingMessageMethodInfo
    ResolveWebsocketExtensionMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveWebsocketExtensionMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveWebsocketExtensionMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveWebsocketExtensionMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveWebsocketExtensionMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveWebsocketExtensionMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveWebsocketExtensionMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveWebsocketExtensionMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveWebsocketExtensionMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveWebsocketExtensionMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveWebsocketExtensionMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveWebsocketExtensionMethod "getRequestParams" o = WebsocketExtensionGetRequestParamsMethodInfo
    ResolveWebsocketExtensionMethod "getResponseParams" o = WebsocketExtensionGetResponseParamsMethodInfo
    ResolveWebsocketExtensionMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveWebsocketExtensionMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveWebsocketExtensionMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveWebsocketExtensionMethod l o = O.MethodResolutionFailed l o

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

#endif

#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList WebsocketExtension
type instance O.AttributeList WebsocketExtension = WebsocketExtensionAttributeList
type WebsocketExtensionAttributeList = ('[ ] :: [(Symbol, *)])
#endif

#if defined(ENABLE_OVERLOADING)
#endif

#if defined(ENABLE_OVERLOADING)
type instance O.SignalList WebsocketExtension = WebsocketExtensionSignalList
type WebsocketExtensionSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

-- method WebsocketExtension::configure
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "extension"
--           , argType =
--               TInterface
--                 Name { namespace = "Soup" , name = "WebsocketExtension" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #SoupWebsocketExtension"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "connection_type"
--           , argType =
--               TInterface
--                 Name { namespace = "Soup" , name = "WebsocketConnectionType" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "either %SOUP_WEBSOCKET_CONNECTION_CLIENT or %SOUP_WEBSOCKET_CONNECTION_SERVER"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "params"
--           , argType = TGHash (TBasicType TPtr) (TBasicType TPtr)
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the parameters, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "soup_websocket_extension_configure" soup_websocket_extension_configure :: 
    Ptr WebsocketExtension ->               -- extension : TInterface (Name {namespace = "Soup", name = "WebsocketExtension"})
    CUInt ->                                -- connection_type : TInterface (Name {namespace = "Soup", name = "WebsocketConnectionType"})
    Ptr (GHashTable (Ptr ()) (Ptr ())) ->   -- params : TGHash (TBasicType TPtr) (TBasicType TPtr)
    Ptr (Ptr GError) ->                     -- error
    IO CInt

-- | Configures /@extension@/ with the given /@params@/
websocketExtensionConfigure ::
    (B.CallStack.HasCallStack, MonadIO m, IsWebsocketExtension a) =>
    a
    -- ^ /@extension@/: a t'GI.Soup.Objects.WebsocketExtension.WebsocketExtension'
    -> Soup.Enums.WebsocketConnectionType
    -- ^ /@connectionType@/: either 'GI.Soup.Enums.WebsocketConnectionTypeClient' or 'GI.Soup.Enums.WebsocketConnectionTypeServer'
    -> Maybe (Map.Map (Ptr ()) (Ptr ()))
    -- ^ /@params@/: the parameters, or 'P.Nothing'
    -> m ()
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
websocketExtensionConfigure :: a
-> WebsocketConnectionType -> Maybe (Map (Ptr ()) (Ptr ())) -> m ()
websocketExtensionConfigure a
extension WebsocketConnectionType
connectionType Maybe (Map (Ptr ()) (Ptr ()))
params = 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 WebsocketExtension
extension' <- a -> IO (Ptr WebsocketExtension)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
extension
    let connectionType' :: CUInt
connectionType' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt)
-> (WebsocketConnectionType -> Int)
-> WebsocketConnectionType
-> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WebsocketConnectionType -> Int
forall a. Enum a => a -> Int
fromEnum) WebsocketConnectionType
connectionType
    Ptr (GHashTable (Ptr ()) (Ptr ()))
maybeParams <- case Maybe (Map (Ptr ()) (Ptr ()))
params of
        Maybe (Map (Ptr ()) (Ptr ()))
Nothing -> Ptr (GHashTable (Ptr ()) (Ptr ()))
-> IO (Ptr (GHashTable (Ptr ()) (Ptr ())))
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr (GHashTable (Ptr ()) (Ptr ()))
forall a. Ptr a
nullPtr
        Just Map (Ptr ()) (Ptr ())
jParams -> do
            let jParams' :: [(Ptr (), Ptr ())]
jParams' = Map (Ptr ()) (Ptr ()) -> [(Ptr (), Ptr ())]
forall k a. Map k a -> [(k, a)]
Map.toList Map (Ptr ()) (Ptr ())
jParams
            let jParams'' :: [(PtrWrapped (Ptr ()), Ptr ())]
jParams'' = (Ptr () -> PtrWrapped (Ptr ()))
-> [(Ptr (), Ptr ())] -> [(PtrWrapped (Ptr ()), Ptr ())]
forall a c b. (a -> c) -> [(a, b)] -> [(c, b)]
mapFirst Ptr () -> PtrWrapped (Ptr ())
forall a. Ptr a -> PtrWrapped (Ptr a)
ptrPackPtr [(Ptr (), Ptr ())]
jParams'
            let jParams''' :: [(PtrWrapped (Ptr ()), PtrWrapped (Ptr ()))]
jParams''' = (Ptr () -> PtrWrapped (Ptr ()))
-> [(PtrWrapped (Ptr ()), Ptr ())]
-> [(PtrWrapped (Ptr ()), PtrWrapped (Ptr ()))]
forall b c a. (b -> c) -> [(a, b)] -> [(a, c)]
mapSecond Ptr () -> PtrWrapped (Ptr ())
forall a. Ptr a -> PtrWrapped (Ptr a)
ptrPackPtr [(PtrWrapped (Ptr ()), Ptr ())]
jParams''
            Ptr (GHashTable (Ptr ()) (Ptr ()))
jParams'''' <- GHashFunc (Ptr ())
-> GEqualFunc (Ptr ())
-> Maybe (GDestroyNotify (Ptr ()))
-> Maybe (GDestroyNotify (Ptr ()))
-> [(PtrWrapped (Ptr ()), PtrWrapped (Ptr ()))]
-> IO (Ptr (GHashTable (Ptr ()) (Ptr ())))
forall a b.
GHashFunc a
-> GEqualFunc a
-> Maybe (GDestroyNotify a)
-> Maybe (GDestroyNotify b)
-> [(PtrWrapped a, PtrWrapped b)]
-> IO (Ptr (GHashTable a b))
packGHashTable GHashFunc (Ptr ())
forall a. GHashFunc (Ptr a)
gDirectHash GEqualFunc (Ptr ())
forall a. GEqualFunc (Ptr a)
gDirectEqual Maybe (GDestroyNotify (Ptr ()))
forall a. Maybe a
Nothing Maybe (GDestroyNotify (Ptr ()))
forall a. Maybe a
Nothing [(PtrWrapped (Ptr ()), PtrWrapped (Ptr ()))]
jParams'''
            Ptr (GHashTable (Ptr ()) (Ptr ()))
-> IO (Ptr (GHashTable (Ptr ()) (Ptr ())))
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr (GHashTable (Ptr ()) (Ptr ()))
jParams''''
    IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr WebsocketExtension
-> CUInt
-> Ptr (GHashTable (Ptr ()) (Ptr ()))
-> Ptr (Ptr GError)
-> IO CInt
soup_websocket_extension_configure Ptr WebsocketExtension
extension' CUInt
connectionType' Ptr (GHashTable (Ptr ()) (Ptr ()))
maybeParams
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
extension
        Ptr (GHashTable (Ptr ()) (Ptr ())) -> IO ()
forall a b. Ptr (GHashTable a b) -> IO ()
unrefGHashTable Ptr (GHashTable (Ptr ()) (Ptr ()))
maybeParams
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        Ptr (GHashTable (Ptr ()) (Ptr ())) -> IO ()
forall a b. Ptr (GHashTable a b) -> IO ()
unrefGHashTable Ptr (GHashTable (Ptr ()) (Ptr ()))
maybeParams
     )

#if defined(ENABLE_OVERLOADING)
data WebsocketExtensionConfigureMethodInfo
instance (signature ~ (Soup.Enums.WebsocketConnectionType -> Maybe (Map.Map (Ptr ()) (Ptr ())) -> m ()), MonadIO m, IsWebsocketExtension a) => O.MethodInfo WebsocketExtensionConfigureMethodInfo a signature where
    overloadedMethod = websocketExtensionConfigure

#endif

-- method WebsocketExtension::get_request_params
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "extension"
--           , argType =
--               TInterface
--                 Name { namespace = "Soup" , name = "WebsocketExtension" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #SoupWebsocketExtension"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "soup_websocket_extension_get_request_params" soup_websocket_extension_get_request_params :: 
    Ptr WebsocketExtension ->               -- extension : TInterface (Name {namespace = "Soup", name = "WebsocketExtension"})
    IO CString

-- | Get the parameters strings to be included in the request header. If the extension
-- doesn\'t include any parameter in the request, this function returns 'P.Nothing'.
-- 
-- /Since: 2.68/
websocketExtensionGetRequestParams ::
    (B.CallStack.HasCallStack, MonadIO m, IsWebsocketExtension a) =>
    a
    -- ^ /@extension@/: a t'GI.Soup.Objects.WebsocketExtension.WebsocketExtension'
    -> m (Maybe T.Text)
    -- ^ __Returns:__ a new allocated string with the parameters
websocketExtensionGetRequestParams :: a -> m (Maybe Text)
websocketExtensionGetRequestParams a
extension = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ do
    Ptr WebsocketExtension
extension' <- a -> IO (Ptr WebsocketExtension)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
extension
    CString
result <- Ptr WebsocketExtension -> IO CString
soup_websocket_extension_get_request_params Ptr WebsocketExtension
extension'
    Maybe Text
maybeResult <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
result ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \CString
result' -> do
        Text
result'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result'
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result''
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
extension
    Maybe Text -> IO (Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
maybeResult

#if defined(ENABLE_OVERLOADING)
data WebsocketExtensionGetRequestParamsMethodInfo
instance (signature ~ (m (Maybe T.Text)), MonadIO m, IsWebsocketExtension a) => O.MethodInfo WebsocketExtensionGetRequestParamsMethodInfo a signature where
    overloadedMethod = websocketExtensionGetRequestParams

#endif

-- method WebsocketExtension::get_response_params
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "extension"
--           , argType =
--               TInterface
--                 Name { namespace = "Soup" , name = "WebsocketExtension" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #SoupWebsocketExtension"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "soup_websocket_extension_get_response_params" soup_websocket_extension_get_response_params :: 
    Ptr WebsocketExtension ->               -- extension : TInterface (Name {namespace = "Soup", name = "WebsocketExtension"})
    IO CString

-- | Get the parameters strings to be included in the response header. If the extension
-- doesn\'t include any parameter in the response, this function returns 'P.Nothing'.
-- 
-- /Since: 2.68/
websocketExtensionGetResponseParams ::
    (B.CallStack.HasCallStack, MonadIO m, IsWebsocketExtension a) =>
    a
    -- ^ /@extension@/: a t'GI.Soup.Objects.WebsocketExtension.WebsocketExtension'
    -> m (Maybe T.Text)
    -- ^ __Returns:__ a new allocated string with the parameters
websocketExtensionGetResponseParams :: a -> m (Maybe Text)
websocketExtensionGetResponseParams a
extension = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ do
    Ptr WebsocketExtension
extension' <- a -> IO (Ptr WebsocketExtension)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
extension
    CString
result <- Ptr WebsocketExtension -> IO CString
soup_websocket_extension_get_response_params Ptr WebsocketExtension
extension'
    Maybe Text
maybeResult <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
result ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \CString
result' -> do
        Text
result'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result'
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result''
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
extension
    Maybe Text -> IO (Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
maybeResult

#if defined(ENABLE_OVERLOADING)
data WebsocketExtensionGetResponseParamsMethodInfo
instance (signature ~ (m (Maybe T.Text)), MonadIO m, IsWebsocketExtension a) => O.MethodInfo WebsocketExtensionGetResponseParamsMethodInfo a signature where
    overloadedMethod = websocketExtensionGetResponseParams

#endif

-- method WebsocketExtension::process_incoming_message
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "extension"
--           , argType =
--               TInterface
--                 Name { namespace = "Soup" , name = "WebsocketExtension" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #SoupWebsocketExtension"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "header"
--           , argType = TBasicType TUInt8
--           , direction = DirectionInout
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the message header" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       , Arg
--           { argCName = "payload"
--           , argType = TInterface Name { namespace = "GLib" , name = "Bytes" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the payload data" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "GLib" , name = "Bytes" })
-- throws : True
-- Skip return : False

foreign import ccall "soup_websocket_extension_process_incoming_message" soup_websocket_extension_process_incoming_message :: 
    Ptr WebsocketExtension ->               -- extension : TInterface (Name {namespace = "Soup", name = "WebsocketExtension"})
    Ptr Word8 ->                            -- header : TBasicType TUInt8
    Ptr GLib.Bytes.Bytes ->                 -- payload : TInterface (Name {namespace = "GLib", name = "Bytes"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr GLib.Bytes.Bytes)

-- | Process a message after it\'s received. If the payload isn\'t changed the given
-- /@payload@/ is just returned, otherwise 'GI.GLib.Structs.Bytes.bytesUnref' is called on the given
-- /@payload@/ and a new t'GI.GLib.Structs.Bytes.Bytes' is returned with the new data.
-- 
-- Extensions using reserved bits of the header will reset them in /@header@/.
-- 
-- /Since: 2.68/
websocketExtensionProcessIncomingMessage ::
    (B.CallStack.HasCallStack, MonadIO m, IsWebsocketExtension a) =>
    a
    -- ^ /@extension@/: a t'GI.Soup.Objects.WebsocketExtension.WebsocketExtension'
    -> Word8
    -- ^ /@header@/: the message header
    -> GLib.Bytes.Bytes
    -- ^ /@payload@/: the payload data
    -> m ((GLib.Bytes.Bytes, Word8))
    -- ^ __Returns:__ the message payload data, or 'P.Nothing' in case of error /(Can throw 'Data.GI.Base.GError.GError')/
websocketExtensionProcessIncomingMessage :: a -> Word8 -> Bytes -> m (Bytes, Word8)
websocketExtensionProcessIncomingMessage a
extension Word8
header Bytes
payload = IO (Bytes, Word8) -> m (Bytes, Word8)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Bytes, Word8) -> m (Bytes, Word8))
-> IO (Bytes, Word8) -> m (Bytes, Word8)
forall a b. (a -> b) -> a -> b
$ do
    Ptr WebsocketExtension
extension' <- a -> IO (Ptr WebsocketExtension)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
extension
    Ptr Word8
header' <- IO (Ptr Word8)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word8)
    Ptr Word8 -> Word8 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr Word8
header' Word8
header
    Ptr Bytes
payload' <- Bytes -> IO (Ptr Bytes)
forall a. (HasCallStack, GBoxed a) => a -> IO (Ptr a)
B.ManagedPtr.disownBoxed Bytes
payload
    IO (Bytes, Word8) -> IO () -> IO (Bytes, Word8)
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr Bytes
result <- (Ptr (Ptr GError) -> IO (Ptr Bytes)) -> IO (Ptr Bytes)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr Bytes)) -> IO (Ptr Bytes))
-> (Ptr (Ptr GError) -> IO (Ptr Bytes)) -> IO (Ptr Bytes)
forall a b. (a -> b) -> a -> b
$ Ptr WebsocketExtension
-> Ptr Word8 -> Ptr Bytes -> Ptr (Ptr GError) -> IO (Ptr Bytes)
soup_websocket_extension_process_incoming_message Ptr WebsocketExtension
extension' Ptr Word8
header' Ptr Bytes
payload'
        Text -> Ptr Bytes -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"websocketExtensionProcessIncomingMessage" Ptr Bytes
result
        Bytes
result' <- ((ManagedPtr Bytes -> Bytes) -> Ptr Bytes -> IO Bytes
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Bytes -> Bytes
GLib.Bytes.Bytes) Ptr Bytes
result
        Word8
header'' <- Ptr Word8 -> IO Word8
forall a. Storable a => Ptr a -> IO a
peek Ptr Word8
header'
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
extension
        Bytes -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Bytes
payload
        Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
header'
        (Bytes, Word8) -> IO (Bytes, Word8)
forall (m :: * -> *) a. Monad m => a -> m a
return (Bytes
result', Word8
header'')
     ) (do
        Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
header'
     )

#if defined(ENABLE_OVERLOADING)
data WebsocketExtensionProcessIncomingMessageMethodInfo
instance (signature ~ (Word8 -> GLib.Bytes.Bytes -> m ((GLib.Bytes.Bytes, Word8))), MonadIO m, IsWebsocketExtension a) => O.MethodInfo WebsocketExtensionProcessIncomingMessageMethodInfo a signature where
    overloadedMethod = websocketExtensionProcessIncomingMessage

#endif

-- method WebsocketExtension::process_outgoing_message
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "extension"
--           , argType =
--               TInterface
--                 Name { namespace = "Soup" , name = "WebsocketExtension" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #SoupWebsocketExtension"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "header"
--           , argType = TBasicType TUInt8
--           , direction = DirectionInout
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the message header" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       , Arg
--           { argCName = "payload"
--           , argType = TInterface Name { namespace = "GLib" , name = "Bytes" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the payload data" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "GLib" , name = "Bytes" })
-- throws : True
-- Skip return : False

foreign import ccall "soup_websocket_extension_process_outgoing_message" soup_websocket_extension_process_outgoing_message :: 
    Ptr WebsocketExtension ->               -- extension : TInterface (Name {namespace = "Soup", name = "WebsocketExtension"})
    Ptr Word8 ->                            -- header : TBasicType TUInt8
    Ptr GLib.Bytes.Bytes ->                 -- payload : TInterface (Name {namespace = "GLib", name = "Bytes"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr GLib.Bytes.Bytes)

-- | Process a message before it\'s sent. If the payload isn\'t changed the given
-- /@payload@/ is just returned, otherwise 'GI.GLib.Structs.Bytes.bytesUnref' is called on the given
-- /@payload@/ and a new t'GI.GLib.Structs.Bytes.Bytes' is returned with the new data.
-- 
-- Extensions using reserved bits of the header will change them in /@header@/.
-- 
-- /Since: 2.68/
websocketExtensionProcessOutgoingMessage ::
    (B.CallStack.HasCallStack, MonadIO m, IsWebsocketExtension a) =>
    a
    -- ^ /@extension@/: a t'GI.Soup.Objects.WebsocketExtension.WebsocketExtension'
    -> Word8
    -- ^ /@header@/: the message header
    -> GLib.Bytes.Bytes
    -- ^ /@payload@/: the payload data
    -> m ((GLib.Bytes.Bytes, Word8))
    -- ^ __Returns:__ the message payload data, or 'P.Nothing' in case of error /(Can throw 'Data.GI.Base.GError.GError')/
websocketExtensionProcessOutgoingMessage :: a -> Word8 -> Bytes -> m (Bytes, Word8)
websocketExtensionProcessOutgoingMessage a
extension Word8
header Bytes
payload = IO (Bytes, Word8) -> m (Bytes, Word8)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Bytes, Word8) -> m (Bytes, Word8))
-> IO (Bytes, Word8) -> m (Bytes, Word8)
forall a b. (a -> b) -> a -> b
$ do
    Ptr WebsocketExtension
extension' <- a -> IO (Ptr WebsocketExtension)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
extension
    Ptr Word8
header' <- IO (Ptr Word8)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word8)
    Ptr Word8 -> Word8 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr Word8
header' Word8
header
    Ptr Bytes
payload' <- Bytes -> IO (Ptr Bytes)
forall a. (HasCallStack, GBoxed a) => a -> IO (Ptr a)
B.ManagedPtr.disownBoxed Bytes
payload
    IO (Bytes, Word8) -> IO () -> IO (Bytes, Word8)
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr Bytes
result <- (Ptr (Ptr GError) -> IO (Ptr Bytes)) -> IO (Ptr Bytes)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr Bytes)) -> IO (Ptr Bytes))
-> (Ptr (Ptr GError) -> IO (Ptr Bytes)) -> IO (Ptr Bytes)
forall a b. (a -> b) -> a -> b
$ Ptr WebsocketExtension
-> Ptr Word8 -> Ptr Bytes -> Ptr (Ptr GError) -> IO (Ptr Bytes)
soup_websocket_extension_process_outgoing_message Ptr WebsocketExtension
extension' Ptr Word8
header' Ptr Bytes
payload'
        Text -> Ptr Bytes -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"websocketExtensionProcessOutgoingMessage" Ptr Bytes
result
        Bytes
result' <- ((ManagedPtr Bytes -> Bytes) -> Ptr Bytes -> IO Bytes
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Bytes -> Bytes
GLib.Bytes.Bytes) Ptr Bytes
result
        Word8
header'' <- Ptr Word8 -> IO Word8
forall a. Storable a => Ptr a -> IO a
peek Ptr Word8
header'
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
extension
        Bytes -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Bytes
payload
        Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
header'
        (Bytes, Word8) -> IO (Bytes, Word8)
forall (m :: * -> *) a. Monad m => a -> m a
return (Bytes
result', Word8
header'')
     ) (do
        Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
header'
     )

#if defined(ENABLE_OVERLOADING)
data WebsocketExtensionProcessOutgoingMessageMethodInfo
instance (signature ~ (Word8 -> GLib.Bytes.Bytes -> m ((GLib.Bytes.Bytes, Word8))), MonadIO m, IsWebsocketExtension a) => O.MethodInfo WebsocketExtensionProcessOutgoingMessageMethodInfo a signature where
    overloadedMethod = websocketExtensionProcessOutgoingMessage

#endif