{- |
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.SocketListener
    ( 

-- * Exported types
    SocketListener(..)                      ,
    SocketListenerK                         ,
    toSocketListener                        ,
    noSocketListener                        ,


 -- * Methods
-- ** socketListenerAccept
    socketListenerAccept                    ,


-- ** socketListenerAcceptAsync
    socketListenerAcceptAsync               ,


-- ** socketListenerAcceptFinish
    socketListenerAcceptFinish              ,


-- ** socketListenerAcceptSocket
    socketListenerAcceptSocket              ,


-- ** socketListenerAcceptSocketAsync
    socketListenerAcceptSocketAsync         ,


-- ** socketListenerAcceptSocketFinish
    socketListenerAcceptSocketFinish        ,


-- ** socketListenerAddAddress
    socketListenerAddAddress                ,


-- ** socketListenerAddAnyInetPort
    socketListenerAddAnyInetPort            ,


-- ** socketListenerAddInetPort
    socketListenerAddInetPort               ,


-- ** socketListenerAddSocket
    socketListenerAddSocket                 ,


-- ** socketListenerClose
    socketListenerClose                     ,


-- ** socketListenerNew
    socketListenerNew                       ,


-- ** socketListenerSetBacklog
    socketListenerSetBacklog                ,




 -- * Properties
-- ** ListenBacklog
    SocketListenerListenBacklogPropertyInfo ,
    constructSocketListenerListenBacklog    ,
    getSocketListenerListenBacklog          ,
    setSocketListenerListenBacklog          ,




    ) 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 SocketListener = SocketListener (ForeignPtr SocketListener)
foreign import ccall "g_socket_listener_get_type"
    c_g_socket_listener_get_type :: IO GType

type instance ParentTypes SocketListener = SocketListenerParentTypes
type SocketListenerParentTypes = '[GObject.Object]

instance GObject SocketListener where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_g_socket_listener_get_type
    

class GObject o => SocketListenerK o
instance (GObject o, IsDescendantOf SocketListener o) => SocketListenerK o

toSocketListener :: SocketListenerK o => o -> IO SocketListener
toSocketListener = unsafeCastTo SocketListener

noSocketListener :: Maybe SocketListener
noSocketListener = Nothing

-- VVV Prop "listen-backlog"
   -- Type: TBasicType TInt32
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstruct]

getSocketListenerListenBacklog :: (MonadIO m, SocketListenerK o) => o -> m Int32
getSocketListenerListenBacklog obj = liftIO $ getObjectPropertyCInt obj "listen-backlog"

setSocketListenerListenBacklog :: (MonadIO m, SocketListenerK o) => o -> Int32 -> m ()
setSocketListenerListenBacklog obj val = liftIO $ setObjectPropertyCInt obj "listen-backlog" val

constructSocketListenerListenBacklog :: Int32 -> IO ([Char], GValue)
constructSocketListenerListenBacklog val = constructObjectPropertyCInt "listen-backlog" val

data SocketListenerListenBacklogPropertyInfo
instance AttrInfo SocketListenerListenBacklogPropertyInfo where
    type AttrAllowedOps SocketListenerListenBacklogPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint SocketListenerListenBacklogPropertyInfo = (~) Int32
    type AttrBaseTypeConstraint SocketListenerListenBacklogPropertyInfo = SocketListenerK
    type AttrGetType SocketListenerListenBacklogPropertyInfo = Int32
    type AttrLabel SocketListenerListenBacklogPropertyInfo = "SocketListener::listen-backlog"
    attrGet _ = getSocketListenerListenBacklog
    attrSet _ = setSocketListenerListenBacklog
    attrConstruct _ = constructSocketListenerListenBacklog

type instance AttributeList SocketListener = SocketListenerAttributeList
type SocketListenerAttributeList = ('[ '("listen-backlog", SocketListenerListenBacklogPropertyInfo)] :: [(Symbol, *)])

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

-- method SocketListener::new
-- method type : Constructor
-- Args : []
-- Lengths : []
-- hInArgs : []
-- returnType : TInterface "Gio" "SocketListener"
-- throws : False
-- Skip return : False

foreign import ccall "g_socket_listener_new" g_socket_listener_new :: 
    IO (Ptr SocketListener)


socketListenerNew ::
    (MonadIO m) =>
    m SocketListener
socketListenerNew  = liftIO $ do
    result <- g_socket_listener_new
    checkUnexpectedReturnNULL "g_socket_listener_new" result
    result' <- (wrapObject SocketListener) result
    return result'

-- method SocketListener::accept
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "SocketListener", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "source_object", argType = TInterface "GObject" "Object", direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "SocketListener", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "SocketConnection"
-- throws : True
-- Skip return : False

foreign import ccall "g_socket_listener_accept" g_socket_listener_accept :: 
    Ptr SocketListener ->                   -- _obj : TInterface "Gio" "SocketListener"
    Ptr (Ptr GObject.Object) ->             -- source_object : TInterface "GObject" "Object"
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr SocketConnection)


socketListenerAccept ::
    (MonadIO m, SocketListenerK a, CancellableK b) =>
    a ->                                    -- _obj
    Maybe (b) ->                            -- cancellable
    m (SocketConnection,GObject.Object)
socketListenerAccept _obj cancellable = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    source_object <- allocMem :: IO (Ptr (Ptr GObject.Object))
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            let jCancellable' = unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_socket_listener_accept _obj' source_object maybeCancellable
        checkUnexpectedReturnNULL "g_socket_listener_accept" result
        result' <- (wrapObject SocketConnection) result
        source_object' <- peek source_object
        source_object'' <- (newObject GObject.Object) source_object'
        touchManagedPtr _obj
        whenJust cancellable touchManagedPtr
        freeMem source_object
        return (result', source_object'')
     ) (do
        freeMem source_object
     )

-- method SocketListener::accept_async
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "SocketListener", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "callback", argType = TInterface "Gio" "AsyncReadyCallback", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeAsync, argClosure = 3, argDestroy = -1, transfer = TransferNothing},Arg {argName = "user_data", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "SocketListener", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "callback", argType = TInterface "Gio" "AsyncReadyCallback", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeAsync, argClosure = 3, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_socket_listener_accept_async" g_socket_listener_accept_async :: 
    Ptr SocketListener ->                   -- _obj : TInterface "Gio" "SocketListener"
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    FunPtr AsyncReadyCallbackC ->           -- callback : TInterface "Gio" "AsyncReadyCallback"
    Ptr () ->                               -- user_data : TBasicType TVoid
    IO ()


socketListenerAcceptAsync ::
    (MonadIO m, SocketListenerK a, CancellableK b) =>
    a ->                                    -- _obj
    Maybe (b) ->                            -- cancellable
    Maybe (AsyncReadyCallback) ->           -- callback
    m ()
socketListenerAcceptAsync _obj cancellable callback = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            let jCancellable' = unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr AsyncReadyCallbackC))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- mkAsyncReadyCallback (asyncReadyCallbackWrapper (Just ptrcallback) jCallback)
            poke ptrcallback jCallback'
            return jCallback'
    let user_data = nullPtr
    g_socket_listener_accept_async _obj' maybeCancellable maybeCallback user_data
    touchManagedPtr _obj
    whenJust cancellable touchManagedPtr
    return ()

-- method SocketListener::accept_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "SocketListener", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "result", argType = TInterface "Gio" "AsyncResult", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "source_object", argType = TInterface "GObject" "Object", direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "SocketListener", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "result", argType = TInterface "Gio" "AsyncResult", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "SocketConnection"
-- throws : True
-- Skip return : False

foreign import ccall "g_socket_listener_accept_finish" g_socket_listener_accept_finish :: 
    Ptr SocketListener ->                   -- _obj : TInterface "Gio" "SocketListener"
    Ptr AsyncResult ->                      -- result : TInterface "Gio" "AsyncResult"
    Ptr (Ptr GObject.Object) ->             -- source_object : TInterface "GObject" "Object"
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr SocketConnection)


socketListenerAcceptFinish ::
    (MonadIO m, SocketListenerK a, AsyncResultK b) =>
    a ->                                    -- _obj
    b ->                                    -- result
    m (SocketConnection,GObject.Object)
socketListenerAcceptFinish _obj result_ = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let result_' = unsafeManagedPtrCastPtr result_
    source_object <- allocMem :: IO (Ptr (Ptr GObject.Object))
    onException (do
        result <- propagateGError $ g_socket_listener_accept_finish _obj' result_' source_object
        checkUnexpectedReturnNULL "g_socket_listener_accept_finish" result
        result' <- (wrapObject SocketConnection) result
        source_object' <- peek source_object
        source_object'' <- (newObject GObject.Object) source_object'
        touchManagedPtr _obj
        touchManagedPtr result_
        freeMem source_object
        return (result', source_object'')
     ) (do
        freeMem source_object
     )

-- method SocketListener::accept_socket
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "SocketListener", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "source_object", argType = TInterface "GObject" "Object", direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "SocketListener", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "Socket"
-- throws : True
-- Skip return : False

foreign import ccall "g_socket_listener_accept_socket" g_socket_listener_accept_socket :: 
    Ptr SocketListener ->                   -- _obj : TInterface "Gio" "SocketListener"
    Ptr (Ptr GObject.Object) ->             -- source_object : TInterface "GObject" "Object"
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Socket)


socketListenerAcceptSocket ::
    (MonadIO m, SocketListenerK a, CancellableK b) =>
    a ->                                    -- _obj
    Maybe (b) ->                            -- cancellable
    m (Socket,GObject.Object)
socketListenerAcceptSocket _obj cancellable = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    source_object <- allocMem :: IO (Ptr (Ptr GObject.Object))
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            let jCancellable' = unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_socket_listener_accept_socket _obj' source_object maybeCancellable
        checkUnexpectedReturnNULL "g_socket_listener_accept_socket" result
        result' <- (wrapObject Socket) result
        source_object' <- peek source_object
        source_object'' <- (newObject GObject.Object) source_object'
        touchManagedPtr _obj
        whenJust cancellable touchManagedPtr
        freeMem source_object
        return (result', source_object'')
     ) (do
        freeMem source_object
     )

-- method SocketListener::accept_socket_async
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "SocketListener", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "callback", argType = TInterface "Gio" "AsyncReadyCallback", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeAsync, argClosure = 3, argDestroy = -1, transfer = TransferNothing},Arg {argName = "user_data", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "SocketListener", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "callback", argType = TInterface "Gio" "AsyncReadyCallback", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeAsync, argClosure = 3, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_socket_listener_accept_socket_async" g_socket_listener_accept_socket_async :: 
    Ptr SocketListener ->                   -- _obj : TInterface "Gio" "SocketListener"
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    FunPtr AsyncReadyCallbackC ->           -- callback : TInterface "Gio" "AsyncReadyCallback"
    Ptr () ->                               -- user_data : TBasicType TVoid
    IO ()


socketListenerAcceptSocketAsync ::
    (MonadIO m, SocketListenerK a, CancellableK b) =>
    a ->                                    -- _obj
    Maybe (b) ->                            -- cancellable
    Maybe (AsyncReadyCallback) ->           -- callback
    m ()
socketListenerAcceptSocketAsync _obj cancellable callback = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            let jCancellable' = unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr AsyncReadyCallbackC))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- mkAsyncReadyCallback (asyncReadyCallbackWrapper (Just ptrcallback) jCallback)
            poke ptrcallback jCallback'
            return jCallback'
    let user_data = nullPtr
    g_socket_listener_accept_socket_async _obj' maybeCancellable maybeCallback user_data
    touchManagedPtr _obj
    whenJust cancellable touchManagedPtr
    return ()

-- method SocketListener::accept_socket_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "SocketListener", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "result", argType = TInterface "Gio" "AsyncResult", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "source_object", argType = TInterface "GObject" "Object", direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "SocketListener", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "result", argType = TInterface "Gio" "AsyncResult", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "Socket"
-- throws : True
-- Skip return : False

foreign import ccall "g_socket_listener_accept_socket_finish" g_socket_listener_accept_socket_finish :: 
    Ptr SocketListener ->                   -- _obj : TInterface "Gio" "SocketListener"
    Ptr AsyncResult ->                      -- result : TInterface "Gio" "AsyncResult"
    Ptr (Ptr GObject.Object) ->             -- source_object : TInterface "GObject" "Object"
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Socket)


socketListenerAcceptSocketFinish ::
    (MonadIO m, SocketListenerK a, AsyncResultK b) =>
    a ->                                    -- _obj
    b ->                                    -- result
    m (Socket,GObject.Object)
socketListenerAcceptSocketFinish _obj result_ = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let result_' = unsafeManagedPtrCastPtr result_
    source_object <- allocMem :: IO (Ptr (Ptr GObject.Object))
    onException (do
        result <- propagateGError $ g_socket_listener_accept_socket_finish _obj' result_' source_object
        checkUnexpectedReturnNULL "g_socket_listener_accept_socket_finish" result
        result' <- (wrapObject Socket) result
        source_object' <- peek source_object
        source_object'' <- (newObject GObject.Object) source_object'
        touchManagedPtr _obj
        touchManagedPtr result_
        freeMem source_object
        return (result', source_object'')
     ) (do
        freeMem source_object
     )

-- method SocketListener::add_address
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "SocketListener", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "address", argType = TInterface "Gio" "SocketAddress", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "type", argType = TInterface "Gio" "SocketType", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "protocol", argType = TInterface "Gio" "SocketProtocol", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "source_object", argType = TInterface "GObject" "Object", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "effective_address", argType = TInterface "Gio" "SocketAddress", direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "SocketListener", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "address", argType = TInterface "Gio" "SocketAddress", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "type", argType = TInterface "Gio" "SocketType", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "protocol", argType = TInterface "Gio" "SocketProtocol", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "source_object", argType = TInterface "GObject" "Object", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : True
-- Skip return : False

foreign import ccall "g_socket_listener_add_address" g_socket_listener_add_address :: 
    Ptr SocketListener ->                   -- _obj : TInterface "Gio" "SocketListener"
    Ptr SocketAddress ->                    -- address : TInterface "Gio" "SocketAddress"
    CUInt ->                                -- type : TInterface "Gio" "SocketType"
    CUInt ->                                -- protocol : TInterface "Gio" "SocketProtocol"
    Ptr GObject.Object ->                   -- source_object : TInterface "GObject" "Object"
    Ptr (Ptr SocketAddress) ->              -- effective_address : TInterface "Gio" "SocketAddress"
    Ptr (Ptr GError) ->                     -- error
    IO CInt


socketListenerAddAddress ::
    (MonadIO m, SocketListenerK a, SocketAddressK b, GObject.ObjectK c) =>
    a ->                                    -- _obj
    b ->                                    -- address
    SocketType ->                           -- type
    SocketProtocol ->                       -- protocol
    Maybe (c) ->                            -- source_object
    m (SocketAddress)
socketListenerAddAddress _obj address type_ protocol source_object = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let address' = unsafeManagedPtrCastPtr address
    let type_' = (fromIntegral . fromEnum) type_
    let protocol' = (fromIntegral . fromEnum) protocol
    maybeSource_object <- case source_object of
        Nothing -> return nullPtr
        Just jSource_object -> do
            let jSource_object' = unsafeManagedPtrCastPtr jSource_object
            return jSource_object'
    effective_address <- allocMem :: IO (Ptr (Ptr SocketAddress))
    onException (do
        _ <- propagateGError $ g_socket_listener_add_address _obj' address' type_' protocol' maybeSource_object effective_address
        effective_address' <- peek effective_address
        effective_address'' <- (wrapObject SocketAddress) effective_address'
        touchManagedPtr _obj
        touchManagedPtr address
        whenJust source_object touchManagedPtr
        freeMem effective_address
        return effective_address''
     ) (do
        freeMem effective_address
     )

-- method SocketListener::add_any_inet_port
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "SocketListener", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "source_object", argType = TInterface "GObject" "Object", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "SocketListener", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "source_object", argType = TInterface "GObject" "Object", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUInt16
-- throws : True
-- Skip return : False

foreign import ccall "g_socket_listener_add_any_inet_port" g_socket_listener_add_any_inet_port :: 
    Ptr SocketListener ->                   -- _obj : TInterface "Gio" "SocketListener"
    Ptr GObject.Object ->                   -- source_object : TInterface "GObject" "Object"
    Ptr (Ptr GError) ->                     -- error
    IO Word16


socketListenerAddAnyInetPort ::
    (MonadIO m, SocketListenerK a, GObject.ObjectK b) =>
    a ->                                    -- _obj
    Maybe (b) ->                            -- source_object
    m Word16
socketListenerAddAnyInetPort _obj source_object = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    maybeSource_object <- case source_object of
        Nothing -> return nullPtr
        Just jSource_object -> do
            let jSource_object' = unsafeManagedPtrCastPtr jSource_object
            return jSource_object'
    onException (do
        result <- propagateGError $ g_socket_listener_add_any_inet_port _obj' maybeSource_object
        touchManagedPtr _obj
        whenJust source_object touchManagedPtr
        return result
     ) (do
        return ()
     )

-- method SocketListener::add_inet_port
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "SocketListener", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "port", argType = TBasicType TUInt16, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "source_object", argType = TInterface "GObject" "Object", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "SocketListener", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "port", argType = TBasicType TUInt16, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "source_object", argType = TInterface "GObject" "Object", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : True
-- Skip return : False

foreign import ccall "g_socket_listener_add_inet_port" g_socket_listener_add_inet_port :: 
    Ptr SocketListener ->                   -- _obj : TInterface "Gio" "SocketListener"
    Word16 ->                               -- port : TBasicType TUInt16
    Ptr GObject.Object ->                   -- source_object : TInterface "GObject" "Object"
    Ptr (Ptr GError) ->                     -- error
    IO CInt


socketListenerAddInetPort ::
    (MonadIO m, SocketListenerK a, GObject.ObjectK b) =>
    a ->                                    -- _obj
    Word16 ->                               -- port
    Maybe (b) ->                            -- source_object
    m ()
socketListenerAddInetPort _obj port source_object = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    maybeSource_object <- case source_object of
        Nothing -> return nullPtr
        Just jSource_object -> do
            let jSource_object' = unsafeManagedPtrCastPtr jSource_object
            return jSource_object'
    onException (do
        _ <- propagateGError $ g_socket_listener_add_inet_port _obj' port maybeSource_object
        touchManagedPtr _obj
        whenJust source_object touchManagedPtr
        return ()
     ) (do
        return ()
     )

-- method SocketListener::add_socket
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "SocketListener", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "socket", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "source_object", argType = TInterface "GObject" "Object", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "SocketListener", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "socket", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "source_object", argType = TInterface "GObject" "Object", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : True
-- Skip return : False

foreign import ccall "g_socket_listener_add_socket" g_socket_listener_add_socket :: 
    Ptr SocketListener ->                   -- _obj : TInterface "Gio" "SocketListener"
    Ptr Socket ->                           -- socket : TInterface "Gio" "Socket"
    Ptr GObject.Object ->                   -- source_object : TInterface "GObject" "Object"
    Ptr (Ptr GError) ->                     -- error
    IO CInt


socketListenerAddSocket ::
    (MonadIO m, SocketListenerK a, SocketK b, GObject.ObjectK c) =>
    a ->                                    -- _obj
    b ->                                    -- socket
    Maybe (c) ->                            -- source_object
    m ()
socketListenerAddSocket _obj socket source_object = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let socket' = unsafeManagedPtrCastPtr socket
    maybeSource_object <- case source_object of
        Nothing -> return nullPtr
        Just jSource_object -> do
            let jSource_object' = unsafeManagedPtrCastPtr jSource_object
            return jSource_object'
    onException (do
        _ <- propagateGError $ g_socket_listener_add_socket _obj' socket' maybeSource_object
        touchManagedPtr _obj
        touchManagedPtr socket
        whenJust source_object touchManagedPtr
        return ()
     ) (do
        return ()
     )

-- method SocketListener::close
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "SocketListener", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "SocketListener", 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_listener_close" g_socket_listener_close :: 
    Ptr SocketListener ->                   -- _obj : TInterface "Gio" "SocketListener"
    IO ()


socketListenerClose ::
    (MonadIO m, SocketListenerK a) =>
    a ->                                    -- _obj
    m ()
socketListenerClose _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    g_socket_listener_close _obj'
    touchManagedPtr _obj
    return ()

-- method SocketListener::set_backlog
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "SocketListener", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "listen_backlog", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "SocketListener", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "listen_backlog", argType = TBasicType TInt32, 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_listener_set_backlog" g_socket_listener_set_backlog :: 
    Ptr SocketListener ->                   -- _obj : TInterface "Gio" "SocketListener"
    Int32 ->                                -- listen_backlog : TBasicType TInt32
    IO ()


socketListenerSetBacklog ::
    (MonadIO m, SocketListenerK a) =>
    a ->                                    -- _obj
    Int32 ->                                -- listen_backlog
    m ()
socketListenerSetBacklog _obj listen_backlog = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    g_socket_listener_set_backlog _obj' listen_backlog
    touchManagedPtr _obj
    return ()