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

Information about nodes in a remote object hierarchy.
-}

module GI.Gio.Structs.DBusNodeInfo
    ( 

-- * Exported types
    DBusNodeInfo(..)                        ,
    noDBusNodeInfo                          ,


 -- * Methods
-- ** dBusNodeInfoGenerateXml
    dBusNodeInfoGenerateXml                 ,


-- ** dBusNodeInfoLookupInterface
    dBusNodeInfoLookupInterface             ,


-- ** dBusNodeInfoNewForXml
    dBusNodeInfoNewForXml                   ,


-- ** dBusNodeInfoRef
    dBusNodeInfoRef                         ,


-- ** dBusNodeInfoUnref
    dBusNodeInfoUnref                       ,




 -- * Properties
-- ** Annotations
    dBusNodeInfoReadAnnotations             ,


-- ** Interfaces
    dBusNodeInfoReadInterfaces              ,


-- ** Nodes
    dBusNodeInfoReadNodes                   ,


-- ** Path
    dBusNodeInfoReadPath                    ,


-- ** RefCount
    dBusNodeInfoReadRefCount                ,




    ) 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.GLib as GLib

newtype DBusNodeInfo = DBusNodeInfo (ForeignPtr DBusNodeInfo)
foreign import ccall "g_dbus_node_info_get_type" c_g_dbus_node_info_get_type :: 
    IO GType

instance BoxedObject DBusNodeInfo where
    boxedType _ = c_g_dbus_node_info_get_type

noDBusNodeInfo :: Maybe DBusNodeInfo
noDBusNodeInfo = Nothing

dBusNodeInfoReadRefCount :: DBusNodeInfo -> IO Int32
dBusNodeInfoReadRefCount s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO Int32
    return val

dBusNodeInfoReadPath :: DBusNodeInfo -> IO T.Text
dBusNodeInfoReadPath s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 8) :: IO CString
    val' <- cstringToText val
    return val'

dBusNodeInfoReadInterfaces :: DBusNodeInfo -> IO [DBusInterfaceInfo]
dBusNodeInfoReadInterfaces s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 16) :: IO (Ptr (Ptr DBusInterfaceInfo))
    val' <- unpackZeroTerminatedPtrArray val
    val'' <- mapM (newBoxed DBusInterfaceInfo) val'
    return val''

dBusNodeInfoReadNodes :: DBusNodeInfo -> IO [DBusNodeInfo]
dBusNodeInfoReadNodes s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 24) :: IO (Ptr (Ptr DBusNodeInfo))
    val' <- unpackZeroTerminatedPtrArray val
    val'' <- mapM (newBoxed DBusNodeInfo) val'
    return val''

dBusNodeInfoReadAnnotations :: DBusNodeInfo -> IO [DBusAnnotationInfo]
dBusNodeInfoReadAnnotations s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 32) :: IO (Ptr (Ptr DBusAnnotationInfo))
    val' <- unpackZeroTerminatedPtrArray val
    val'' <- mapM (newBoxed DBusAnnotationInfo) val'
    return val''

-- method DBusNodeInfo::new_for_xml
-- method type : Constructor
-- Args : [Arg {argName = "xml_data", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "xml_data", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "DBusNodeInfo"
-- throws : True
-- Skip return : False

foreign import ccall "g_dbus_node_info_new_for_xml" g_dbus_node_info_new_for_xml :: 
    CString ->                              -- xml_data : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr DBusNodeInfo)


dBusNodeInfoNewForXml ::
    (MonadIO m) =>
    T.Text ->                               -- xml_data
    m DBusNodeInfo
dBusNodeInfoNewForXml xml_data = liftIO $ do
    xml_data' <- textToCString xml_data
    onException (do
        result <- propagateGError $ g_dbus_node_info_new_for_xml xml_data'
        checkUnexpectedReturnNULL "g_dbus_node_info_new_for_xml" result
        result' <- (wrapBoxed DBusNodeInfo) result
        freeMem xml_data'
        return result'
     ) (do
        freeMem xml_data'
     )

-- method DBusNodeInfo::generate_xml
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "DBusNodeInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "indent", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "string_builder", argType = TInterface "GLib" "String", direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "DBusNodeInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "indent", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_dbus_node_info_generate_xml" g_dbus_node_info_generate_xml :: 
    Ptr DBusNodeInfo ->                     -- _obj : TInterface "Gio" "DBusNodeInfo"
    Word32 ->                               -- indent : TBasicType TUInt32
    Ptr GLib.String ->                      -- string_builder : TInterface "GLib" "String"
    IO ()


dBusNodeInfoGenerateXml ::
    (MonadIO m) =>
    DBusNodeInfo ->                         -- _obj
    Word32 ->                               -- indent
    m (GLib.String)
dBusNodeInfoGenerateXml _obj indent = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    string_builder <- callocBoxedBytes 24 :: IO (Ptr GLib.String)
    g_dbus_node_info_generate_xml _obj' indent string_builder
    string_builder' <- (wrapBoxed GLib.String) string_builder
    touchManagedPtr _obj
    return string_builder'

-- method DBusNodeInfo::lookup_interface
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "DBusNodeInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "DBusNodeInfo", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "name", argType = TBasicType TUTF8, 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_node_info_lookup_interface" g_dbus_node_info_lookup_interface :: 
    Ptr DBusNodeInfo ->                     -- _obj : TInterface "Gio" "DBusNodeInfo"
    CString ->                              -- name : TBasicType TUTF8
    IO (Ptr DBusInterfaceInfo)


dBusNodeInfoLookupInterface ::
    (MonadIO m) =>
    DBusNodeInfo ->                         -- _obj
    T.Text ->                               -- name
    m DBusInterfaceInfo
dBusNodeInfoLookupInterface _obj name = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    name' <- textToCString name
    result <- g_dbus_node_info_lookup_interface _obj' name'
    checkUnexpectedReturnNULL "g_dbus_node_info_lookup_interface" result
    result' <- (newBoxed DBusInterfaceInfo) result
    touchManagedPtr _obj
    freeMem name'
    return result'

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

foreign import ccall "g_dbus_node_info_ref" g_dbus_node_info_ref :: 
    Ptr DBusNodeInfo ->                     -- _obj : TInterface "Gio" "DBusNodeInfo"
    IO (Ptr DBusNodeInfo)


dBusNodeInfoRef ::
    (MonadIO m) =>
    DBusNodeInfo ->                         -- _obj
    m DBusNodeInfo
dBusNodeInfoRef _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    result <- g_dbus_node_info_ref _obj'
    checkUnexpectedReturnNULL "g_dbus_node_info_ref" result
    result' <- (wrapBoxed DBusNodeInfo) result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "g_dbus_node_info_unref" g_dbus_node_info_unref :: 
    Ptr DBusNodeInfo ->                     -- _obj : TInterface "Gio" "DBusNodeInfo"
    IO ()


dBusNodeInfoUnref ::
    (MonadIO m) =>
    DBusNodeInfo ->                         -- _obj
    m ()
dBusNodeInfoUnref _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    g_dbus_node_info_unref _obj'
    touchManagedPtr _obj
    return ()