{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)
-}

module GI.Gio.Objects.SocketControlMessage
    ( 

-- * Exported types
    SocketControlMessage(..)                ,
    SocketControlMessageK                   ,
    toSocketControlMessage                  ,
    noSocketControlMessage                  ,


 -- * Methods
-- ** socketControlMessageDeserialize
    socketControlMessageDeserialize         ,


-- ** socketControlMessageGetLevel
    socketControlMessageGetLevel            ,


-- ** socketControlMessageGetMsgType
    socketControlMessageGetMsgType          ,


-- ** socketControlMessageGetSize
    socketControlMessageGetSize             ,


-- ** socketControlMessageSerialize
    socketControlMessageSerialize           ,




    ) where

import Prelude ()
import Data.GI.Base.ShortPrelude

import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map

import GI.Gio.Types
import GI.Gio.Callbacks
import qualified GI.GObject as GObject

newtype SocketControlMessage = SocketControlMessage (ForeignPtr SocketControlMessage)
foreign import ccall "g_socket_control_message_get_type"
    c_g_socket_control_message_get_type :: IO GType

type instance ParentTypes SocketControlMessage = SocketControlMessageParentTypes
type SocketControlMessageParentTypes = '[GObject.Object]

instance GObject SocketControlMessage where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_g_socket_control_message_get_type
    

class GObject o => SocketControlMessageK o
instance (GObject o, IsDescendantOf SocketControlMessage o) => SocketControlMessageK o

toSocketControlMessage :: SocketControlMessageK o => o -> IO SocketControlMessage
toSocketControlMessage = unsafeCastTo SocketControlMessage

noSocketControlMessage :: Maybe SocketControlMessage
noSocketControlMessage = Nothing

type instance AttributeList SocketControlMessage = SocketControlMessageAttributeList
type SocketControlMessageAttributeList = ('[ ] :: [(Symbol, *)])

type instance SignalList SocketControlMessage = SocketControlMessageSignalList
type SocketControlMessageSignalList = ('[ '("notify", GObject.ObjectNotifySignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)])

-- method SocketControlMessage::get_level
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "SocketControlMessage", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "SocketControlMessage", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TInt32
-- throws : False
-- Skip return : False

foreign import ccall "g_socket_control_message_get_level" g_socket_control_message_get_level :: 
    Ptr SocketControlMessage ->             -- _obj : TInterface "Gio" "SocketControlMessage"
    IO Int32


socketControlMessageGetLevel ::
    (MonadIO m, SocketControlMessageK a) =>
    a ->                                    -- _obj
    m Int32
socketControlMessageGetLevel _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_socket_control_message_get_level _obj'
    touchManagedPtr _obj
    return result

-- method SocketControlMessage::get_msg_type
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "SocketControlMessage", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "SocketControlMessage", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TInt32
-- throws : False
-- Skip return : False

foreign import ccall "g_socket_control_message_get_msg_type" g_socket_control_message_get_msg_type :: 
    Ptr SocketControlMessage ->             -- _obj : TInterface "Gio" "SocketControlMessage"
    IO Int32


socketControlMessageGetMsgType ::
    (MonadIO m, SocketControlMessageK a) =>
    a ->                                    -- _obj
    m Int32
socketControlMessageGetMsgType _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_socket_control_message_get_msg_type _obj'
    touchManagedPtr _obj
    return result

-- method SocketControlMessage::get_size
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "SocketControlMessage", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "SocketControlMessage", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUInt64
-- throws : False
-- Skip return : False

foreign import ccall "g_socket_control_message_get_size" g_socket_control_message_get_size :: 
    Ptr SocketControlMessage ->             -- _obj : TInterface "Gio" "SocketControlMessage"
    IO Word64


socketControlMessageGetSize ::
    (MonadIO m, SocketControlMessageK a) =>
    a ->                                    -- _obj
    m Word64
socketControlMessageGetSize _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_socket_control_message_get_size _obj'
    touchManagedPtr _obj
    return result

-- method SocketControlMessage::serialize
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "SocketControlMessage", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "data", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "SocketControlMessage", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "data", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_socket_control_message_serialize" g_socket_control_message_serialize :: 
    Ptr SocketControlMessage ->             -- _obj : TInterface "Gio" "SocketControlMessage"
    Ptr () ->                               -- data : TBasicType TVoid
    IO ()


socketControlMessageSerialize ::
    (MonadIO m, SocketControlMessageK a) =>
    a ->                                    -- _obj
    Ptr () ->                               -- data
    m ()
socketControlMessageSerialize _obj data_ = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    g_socket_control_message_serialize _obj' data_
    touchManagedPtr _obj
    return ()

-- method SocketControlMessage::deserialize
-- method type : MemberFunction
-- Args : [Arg {argName = "level", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "type", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "data", argType = TCArray False (-1) 2 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : [Arg {argName = "size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- hInArgs : [Arg {argName = "level", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "type", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "data", argType = TCArray False (-1) 2 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "SocketControlMessage"
-- throws : False
-- Skip return : False

foreign import ccall "g_socket_control_message_deserialize" g_socket_control_message_deserialize :: 
    Int32 ->                                -- level : TBasicType TInt32
    Int32 ->                                -- type : TBasicType TInt32
    Word64 ->                               -- size : TBasicType TUInt64
    Ptr Word8 ->                            -- data : TCArray False (-1) 2 (TBasicType TUInt8)
    IO (Ptr SocketControlMessage)


socketControlMessageDeserialize ::
    (MonadIO m) =>
    Int32 ->                                -- level
    Int32 ->                                -- type
    ByteString ->                           -- data
    m SocketControlMessage
socketControlMessageDeserialize level type_ data_ = liftIO $ do
    let size = fromIntegral $ B.length data_
    data_' <- packByteString data_
    result <- g_socket_control_message_deserialize level type_ size data_'
    checkUnexpectedReturnNULL "g_socket_control_message_deserialize" result
    result' <- (wrapObject SocketControlMessage) result
    freeMem data_'
    return result'