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

-- * Exported types
    DBusObjectSkeleton(..)                  ,
    DBusObjectSkeletonK                     ,
    toDBusObjectSkeleton                    ,
    noDBusObjectSkeleton                    ,


 -- * Methods
-- ** dBusObjectSkeletonAddInterface
    dBusObjectSkeletonAddInterface          ,


-- ** dBusObjectSkeletonFlush
    dBusObjectSkeletonFlush                 ,


-- ** dBusObjectSkeletonNew
    dBusObjectSkeletonNew                   ,


-- ** dBusObjectSkeletonRemoveInterface
    dBusObjectSkeletonRemoveInterface       ,


-- ** dBusObjectSkeletonRemoveInterfaceByName
    dBusObjectSkeletonRemoveInterfaceByName ,


-- ** dBusObjectSkeletonSetObjectPath
    dBusObjectSkeletonSetObjectPath         ,




 -- * Properties
-- ** GObjectPath
    DBusObjectSkeletonGObjectPathPropertyInfo,
    constructDBusObjectSkeletonGObjectPath  ,
    getDBusObjectSkeletonGObjectPath        ,
    setDBusObjectSkeletonGObjectPath        ,




 -- * Signals
-- ** AuthorizeMethod
    DBusObjectSkeletonAuthorizeMethodCallback,
    DBusObjectSkeletonAuthorizeMethodCallbackC,
    DBusObjectSkeletonAuthorizeMethodSignalInfo,
    afterDBusObjectSkeletonAuthorizeMethod  ,
    dBusObjectSkeletonAuthorizeMethodCallbackWrapper,
    dBusObjectSkeletonAuthorizeMethodClosure,
    mkDBusObjectSkeletonAuthorizeMethodCallback,
    noDBusObjectSkeletonAuthorizeMethodCallback,
    onDBusObjectSkeletonAuthorizeMethod     ,




    ) 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 DBusObjectSkeleton = DBusObjectSkeleton (ForeignPtr DBusObjectSkeleton)
foreign import ccall "g_dbus_object_skeleton_get_type"
    c_g_dbus_object_skeleton_get_type :: IO GType

type instance ParentTypes DBusObjectSkeleton = DBusObjectSkeletonParentTypes
type DBusObjectSkeletonParentTypes = '[GObject.Object, DBusObject]

instance GObject DBusObjectSkeleton where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_g_dbus_object_skeleton_get_type
    

class GObject o => DBusObjectSkeletonK o
instance (GObject o, IsDescendantOf DBusObjectSkeleton o) => DBusObjectSkeletonK o

toDBusObjectSkeleton :: DBusObjectSkeletonK o => o -> IO DBusObjectSkeleton
toDBusObjectSkeleton = unsafeCastTo DBusObjectSkeleton

noDBusObjectSkeleton :: Maybe DBusObjectSkeleton
noDBusObjectSkeleton = Nothing

-- signal DBusObjectSkeleton::authorize-method
type DBusObjectSkeletonAuthorizeMethodCallback =
    DBusInterfaceSkeleton ->
    DBusMethodInvocation ->
    IO Bool

noDBusObjectSkeletonAuthorizeMethodCallback :: Maybe DBusObjectSkeletonAuthorizeMethodCallback
noDBusObjectSkeletonAuthorizeMethodCallback = Nothing

type DBusObjectSkeletonAuthorizeMethodCallbackC =
    Ptr () ->                               -- object
    Ptr DBusInterfaceSkeleton ->
    Ptr DBusMethodInvocation ->
    Ptr () ->                               -- user_data
    IO CInt

foreign import ccall "wrapper"
    mkDBusObjectSkeletonAuthorizeMethodCallback :: DBusObjectSkeletonAuthorizeMethodCallbackC -> IO (FunPtr DBusObjectSkeletonAuthorizeMethodCallbackC)

dBusObjectSkeletonAuthorizeMethodClosure :: DBusObjectSkeletonAuthorizeMethodCallback -> IO Closure
dBusObjectSkeletonAuthorizeMethodClosure cb = newCClosure =<< mkDBusObjectSkeletonAuthorizeMethodCallback wrapped
    where wrapped = dBusObjectSkeletonAuthorizeMethodCallbackWrapper cb

dBusObjectSkeletonAuthorizeMethodCallbackWrapper ::
    DBusObjectSkeletonAuthorizeMethodCallback ->
    Ptr () ->
    Ptr DBusInterfaceSkeleton ->
    Ptr DBusMethodInvocation ->
    Ptr () ->
    IO CInt
dBusObjectSkeletonAuthorizeMethodCallbackWrapper _cb _ interface invocation _ = do
    interface' <- (newObject DBusInterfaceSkeleton) interface
    invocation' <- (newObject DBusMethodInvocation) invocation
    result <- _cb  interface' invocation'
    let result' = (fromIntegral . fromEnum) result
    return result'

onDBusObjectSkeletonAuthorizeMethod :: (GObject a, MonadIO m) => a -> DBusObjectSkeletonAuthorizeMethodCallback -> m SignalHandlerId
onDBusObjectSkeletonAuthorizeMethod obj cb = liftIO $ connectDBusObjectSkeletonAuthorizeMethod obj cb SignalConnectBefore
afterDBusObjectSkeletonAuthorizeMethod :: (GObject a, MonadIO m) => a -> DBusObjectSkeletonAuthorizeMethodCallback -> m SignalHandlerId
afterDBusObjectSkeletonAuthorizeMethod obj cb = connectDBusObjectSkeletonAuthorizeMethod obj cb SignalConnectAfter

connectDBusObjectSkeletonAuthorizeMethod :: (GObject a, MonadIO m) =>
                                            a -> DBusObjectSkeletonAuthorizeMethodCallback -> SignalConnectMode -> m SignalHandlerId
connectDBusObjectSkeletonAuthorizeMethod obj cb after = liftIO $ do
    cb' <- mkDBusObjectSkeletonAuthorizeMethodCallback (dBusObjectSkeletonAuthorizeMethodCallbackWrapper cb)
    connectSignalFunPtr obj "authorize-method" cb' after

-- VVV Prop "g-object-path"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstruct]

getDBusObjectSkeletonGObjectPath :: (MonadIO m, DBusObjectSkeletonK o) => o -> m T.Text
getDBusObjectSkeletonGObjectPath obj = liftIO $ getObjectPropertyString obj "g-object-path"

setDBusObjectSkeletonGObjectPath :: (MonadIO m, DBusObjectSkeletonK o) => o -> T.Text -> m ()
setDBusObjectSkeletonGObjectPath obj val = liftIO $ setObjectPropertyString obj "g-object-path" val

constructDBusObjectSkeletonGObjectPath :: T.Text -> IO ([Char], GValue)
constructDBusObjectSkeletonGObjectPath val = constructObjectPropertyString "g-object-path" val

data DBusObjectSkeletonGObjectPathPropertyInfo
instance AttrInfo DBusObjectSkeletonGObjectPathPropertyInfo where
    type AttrAllowedOps DBusObjectSkeletonGObjectPathPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint DBusObjectSkeletonGObjectPathPropertyInfo = (~) T.Text
    type AttrBaseTypeConstraint DBusObjectSkeletonGObjectPathPropertyInfo = DBusObjectSkeletonK
    type AttrGetType DBusObjectSkeletonGObjectPathPropertyInfo = T.Text
    type AttrLabel DBusObjectSkeletonGObjectPathPropertyInfo = "DBusObjectSkeleton::g-object-path"
    attrGet _ = getDBusObjectSkeletonGObjectPath
    attrSet _ = setDBusObjectSkeletonGObjectPath
    attrConstruct _ = constructDBusObjectSkeletonGObjectPath

type instance AttributeList DBusObjectSkeleton = DBusObjectSkeletonAttributeList
type DBusObjectSkeletonAttributeList = ('[ '("g-object-path", DBusObjectSkeletonGObjectPathPropertyInfo)] :: [(Symbol, *)])

data DBusObjectSkeletonAuthorizeMethodSignalInfo
instance SignalInfo DBusObjectSkeletonAuthorizeMethodSignalInfo where
    type HaskellCallbackType DBusObjectSkeletonAuthorizeMethodSignalInfo = DBusObjectSkeletonAuthorizeMethodCallback
    connectSignal _ = connectDBusObjectSkeletonAuthorizeMethod

type instance SignalList DBusObjectSkeleton = DBusObjectSkeletonSignalList
type DBusObjectSkeletonSignalList = ('[ '("authorize-method", DBusObjectSkeletonAuthorizeMethodSignalInfo), '("interface-added", DBusObjectInterfaceAddedSignalInfo), '("interface-removed", DBusObjectInterfaceRemovedSignalInfo), '("notify", GObject.ObjectNotifySignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)])

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

foreign import ccall "g_dbus_object_skeleton_new" g_dbus_object_skeleton_new :: 
    CString ->                              -- object_path : TBasicType TUTF8
    IO (Ptr DBusObjectSkeleton)


dBusObjectSkeletonNew ::
    (MonadIO m) =>
    T.Text ->                               -- object_path
    m DBusObjectSkeleton
dBusObjectSkeletonNew object_path = liftIO $ do
    object_path' <- textToCString object_path
    result <- g_dbus_object_skeleton_new object_path'
    checkUnexpectedReturnNULL "g_dbus_object_skeleton_new" result
    result' <- (wrapObject DBusObjectSkeleton) result
    freeMem object_path'
    return result'

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


dBusObjectSkeletonAddInterface ::
    (MonadIO m, DBusObjectSkeletonK a, DBusInterfaceSkeletonK b) =>
    a ->                                    -- _obj
    b ->                                    -- interface_
    m ()
dBusObjectSkeletonAddInterface _obj interface_ = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let interface_' = unsafeManagedPtrCastPtr interface_
    g_dbus_object_skeleton_add_interface _obj' interface_'
    touchManagedPtr _obj
    touchManagedPtr interface_
    return ()

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


dBusObjectSkeletonFlush ::
    (MonadIO m, DBusObjectSkeletonK a) =>
    a ->                                    -- _obj
    m ()
dBusObjectSkeletonFlush _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    g_dbus_object_skeleton_flush _obj'
    touchManagedPtr _obj
    return ()

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


dBusObjectSkeletonRemoveInterface ::
    (MonadIO m, DBusObjectSkeletonK a, DBusInterfaceSkeletonK b) =>
    a ->                                    -- _obj
    b ->                                    -- interface_
    m ()
dBusObjectSkeletonRemoveInterface _obj interface_ = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let interface_' = unsafeManagedPtrCastPtr interface_
    g_dbus_object_skeleton_remove_interface _obj' interface_'
    touchManagedPtr _obj
    touchManagedPtr interface_
    return ()

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


dBusObjectSkeletonRemoveInterfaceByName ::
    (MonadIO m, DBusObjectSkeletonK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- interface_name
    m ()
dBusObjectSkeletonRemoveInterfaceByName _obj interface_name = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    interface_name' <- textToCString interface_name
    g_dbus_object_skeleton_remove_interface_by_name _obj' interface_name'
    touchManagedPtr _obj
    freeMem interface_name'
    return ()

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


dBusObjectSkeletonSetObjectPath ::
    (MonadIO m, DBusObjectSkeletonK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- object_path
    m ()
dBusObjectSkeletonSetObjectPath _obj object_path = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    object_path' <- textToCString object_path
    g_dbus_object_skeleton_set_object_path _obj' object_path'
    touchManagedPtr _obj
    freeMem object_path'
    return ()