{- |
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.Interfaces.DBusInterface
    ( 

-- * Exported types
    DBusInterface(..)                       ,
    noDBusInterface                         ,
    DBusInterfaceK                          ,
    toDBusInterface                         ,


 -- * Methods
-- ** dBusInterfaceGetInfo
    dBusInterfaceGetInfo                    ,


-- ** dBusInterfaceGetObject
    dBusInterfaceGetObject                  ,


-- ** dBusInterfaceSetObject
    dBusInterfaceSetObject                  ,




    ) 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

-- interface DBusInterface 

newtype DBusInterface = DBusInterface (ForeignPtr DBusInterface)
noDBusInterface :: Maybe DBusInterface
noDBusInterface = Nothing

type instance AttributeList DBusInterface = DBusInterfaceAttributeList
type DBusInterfaceAttributeList = ('[ ] :: [(Symbol, *)])

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

foreign import ccall "g_dbus_interface_get_type"
    c_g_dbus_interface_get_type :: IO GType

type instance ParentTypes DBusInterface = DBusInterfaceParentTypes
type DBusInterfaceParentTypes = '[GObject.Object]

instance GObject DBusInterface where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_g_dbus_interface_get_type
    

class GObject o => DBusInterfaceK o
instance (GObject o, IsDescendantOf DBusInterface o) => DBusInterfaceK o

toDBusInterface :: DBusInterfaceK o => o -> IO DBusInterface
toDBusInterface = unsafeCastTo DBusInterface

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

foreign import ccall "g_dbus_interface_dup_object" g_dbus_interface_dup_object :: 
    Ptr DBusInterface ->                    -- _obj : TInterface "Gio" "DBusInterface"
    IO (Ptr DBusObject)


dBusInterfaceGetObject ::
    (MonadIO m, DBusInterfaceK a) =>
    a ->                                    -- _obj
    m DBusObject
dBusInterfaceGetObject _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_dbus_interface_dup_object _obj'
    checkUnexpectedReturnNULL "g_dbus_interface_dup_object" result
    result' <- (wrapObject DBusObject) result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "g_dbus_interface_get_info" g_dbus_interface_get_info :: 
    Ptr DBusInterface ->                    -- _obj : TInterface "Gio" "DBusInterface"
    IO (Ptr DBusInterfaceInfo)


dBusInterfaceGetInfo ::
    (MonadIO m, DBusInterfaceK a) =>
    a ->                                    -- _obj
    m DBusInterfaceInfo
dBusInterfaceGetInfo _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_dbus_interface_get_info _obj'
    checkUnexpectedReturnNULL "g_dbus_interface_get_info" result
    result' <- (newBoxed DBusInterfaceInfo) result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "g_dbus_interface_set_object" g_dbus_interface_set_object :: 
    Ptr DBusInterface ->                    -- _obj : TInterface "Gio" "DBusInterface"
    Ptr DBusObject ->                       -- object : TInterface "Gio" "DBusObject"
    IO ()


dBusInterfaceSetObject ::
    (MonadIO m, DBusInterfaceK a, DBusObjectK b) =>
    a ->                                    -- _obj
    Maybe (b) ->                            -- object
    m ()
dBusInterfaceSetObject _obj object = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    maybeObject <- case object of
        Nothing -> return nullPtr
        Just jObject -> do
            let jObject' = unsafeManagedPtrCastPtr jObject
            return jObject'
    g_dbus_interface_set_object _obj' maybeObject
    touchManagedPtr _obj
    whenJust object touchManagedPtr
    return ()