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

'GI.Gio.Objects.DBusObjectManagerServer.DBusObjectManagerServer' is used to export 'GI.Gio.Interfaces.DBusObject.DBusObject' instances using
the standardized
<http://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-objectmanager org.freedesktop.DBus.ObjectManager>
interface. For example, remote D-Bus clients can get all objects
and properties in a single call. Additionally, any change in the
object hierarchy is broadcast using signals. This means that D-Bus
clients can keep caches up to date by only listening to D-Bus
signals.

The recommended path to export an object manager at is the path form of the
well-known name of a D-Bus service, or below. For example, if a D-Bus service
is available at the well-known name @net.example.ExampleService1@, the object
manager should typically be exported at @\/net\/example\/ExampleService1@, or
below (to allow for multiple object managers in a service).

It is supported, but not recommended, to export an object manager at the root
path, @\/@.

See 'GI.Gio.Objects.DBusObjectManagerClient.DBusObjectManagerClient' for the client-side code that is
intended to be used with 'GI.Gio.Objects.DBusObjectManagerServer.DBusObjectManagerServer' or any D-Bus
object implementing the org.freedesktop.DBus.ObjectManager
interface.

/Since: 2.30/
-}

#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
       && !defined(__HADDOCK_VERSION__))

module GI.Gio.Objects.DBusObjectManagerServer
    (

-- * Exported types
    DBusObjectManagerServer(..)             ,
    IsDBusObjectManagerServer               ,
    toDBusObjectManagerServer               ,
    noDBusObjectManagerServer               ,


 -- * Methods
-- ** export #method:export#

#if ENABLE_OVERLOADING
    DBusObjectManagerServerExportMethodInfo ,
#endif
    dBusObjectManagerServerExport           ,


-- ** exportUniquely #method:exportUniquely#

#if ENABLE_OVERLOADING
    DBusObjectManagerServerExportUniquelyMethodInfo,
#endif
    dBusObjectManagerServerExportUniquely   ,


-- ** getConnection #method:getConnection#

#if ENABLE_OVERLOADING
    DBusObjectManagerServerGetConnectionMethodInfo,
#endif
    dBusObjectManagerServerGetConnection    ,


-- ** isExported #method:isExported#

#if ENABLE_OVERLOADING
    DBusObjectManagerServerIsExportedMethodInfo,
#endif
    dBusObjectManagerServerIsExported       ,


-- ** new #method:new#

    dBusObjectManagerServerNew              ,


-- ** setConnection #method:setConnection#

#if ENABLE_OVERLOADING
    DBusObjectManagerServerSetConnectionMethodInfo,
#endif
    dBusObjectManagerServerSetConnection    ,


-- ** unexport #method:unexport#

#if ENABLE_OVERLOADING
    DBusObjectManagerServerUnexportMethodInfo,
#endif
    dBusObjectManagerServerUnexport         ,




 -- * Properties
-- ** connection #attr:connection#
{- | The 'GI.Gio.Objects.DBusConnection.DBusConnection' to export objects on.

/Since: 2.30/
-}
#if ENABLE_OVERLOADING
    DBusObjectManagerServerConnectionPropertyInfo,
#endif
    clearDBusObjectManagerServerConnection  ,
    constructDBusObjectManagerServerConnection,
#if ENABLE_OVERLOADING
    dBusObjectManagerServerConnection       ,
#endif
    getDBusObjectManagerServerConnection    ,
    setDBusObjectManagerServerConnection    ,


-- ** objectPath #attr:objectPath#
{- | The object path to register the manager object at.

/Since: 2.30/
-}
#if ENABLE_OVERLOADING
    DBusObjectManagerServerObjectPathPropertyInfo,
#endif
    constructDBusObjectManagerServerObjectPath,
#if ENABLE_OVERLOADING
    dBusObjectManagerServerObjectPath       ,
#endif
    getDBusObjectManagerServerObjectPath    ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Gio.Interfaces.DBusObjectManager as Gio.DBusObjectManager
import {-# SOURCE #-} qualified GI.Gio.Objects.DBusConnection as Gio.DBusConnection
import {-# SOURCE #-} qualified GI.Gio.Objects.DBusObjectSkeleton as Gio.DBusObjectSkeleton

-- | Memory-managed wrapper type.
newtype DBusObjectManagerServer = DBusObjectManagerServer (ManagedPtr DBusObjectManagerServer)
foreign import ccall "g_dbus_object_manager_server_get_type"
    c_g_dbus_object_manager_server_get_type :: IO GType

instance GObject DBusObjectManagerServer where
    gobjectType _ = c_g_dbus_object_manager_server_get_type


-- | Type class for types which can be safely cast to `DBusObjectManagerServer`, for instance with `toDBusObjectManagerServer`.
class GObject o => IsDBusObjectManagerServer o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError DBusObjectManagerServer a) =>
    IsDBusObjectManagerServer a
#endif
instance IsDBusObjectManagerServer DBusObjectManagerServer
instance GObject.Object.IsObject DBusObjectManagerServer
instance Gio.DBusObjectManager.IsDBusObjectManager DBusObjectManagerServer

-- | Cast to `DBusObjectManagerServer`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toDBusObjectManagerServer :: (MonadIO m, IsDBusObjectManagerServer o) => o -> m DBusObjectManagerServer
toDBusObjectManagerServer = liftIO . unsafeCastTo DBusObjectManagerServer

-- | A convenience alias for `Nothing` :: `Maybe` `DBusObjectManagerServer`.
noDBusObjectManagerServer :: Maybe DBusObjectManagerServer
noDBusObjectManagerServer = Nothing

#if ENABLE_OVERLOADING
type family ResolveDBusObjectManagerServerMethod (t :: Symbol) (o :: *) :: * where
    ResolveDBusObjectManagerServerMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveDBusObjectManagerServerMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveDBusObjectManagerServerMethod "export" o = DBusObjectManagerServerExportMethodInfo
    ResolveDBusObjectManagerServerMethod "exportUniquely" o = DBusObjectManagerServerExportUniquelyMethodInfo
    ResolveDBusObjectManagerServerMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveDBusObjectManagerServerMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveDBusObjectManagerServerMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveDBusObjectManagerServerMethod "isExported" o = DBusObjectManagerServerIsExportedMethodInfo
    ResolveDBusObjectManagerServerMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveDBusObjectManagerServerMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveDBusObjectManagerServerMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveDBusObjectManagerServerMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveDBusObjectManagerServerMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveDBusObjectManagerServerMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveDBusObjectManagerServerMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveDBusObjectManagerServerMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveDBusObjectManagerServerMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveDBusObjectManagerServerMethod "unexport" o = DBusObjectManagerServerUnexportMethodInfo
    ResolveDBusObjectManagerServerMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveDBusObjectManagerServerMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveDBusObjectManagerServerMethod "getConnection" o = DBusObjectManagerServerGetConnectionMethodInfo
    ResolveDBusObjectManagerServerMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveDBusObjectManagerServerMethod "getInterface" o = Gio.DBusObjectManager.DBusObjectManagerGetInterfaceMethodInfo
    ResolveDBusObjectManagerServerMethod "getObject" o = Gio.DBusObjectManager.DBusObjectManagerGetObjectMethodInfo
    ResolveDBusObjectManagerServerMethod "getObjectPath" o = Gio.DBusObjectManager.DBusObjectManagerGetObjectPathMethodInfo
    ResolveDBusObjectManagerServerMethod "getObjects" o = Gio.DBusObjectManager.DBusObjectManagerGetObjectsMethodInfo
    ResolveDBusObjectManagerServerMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveDBusObjectManagerServerMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveDBusObjectManagerServerMethod "setConnection" o = DBusObjectManagerServerSetConnectionMethodInfo
    ResolveDBusObjectManagerServerMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveDBusObjectManagerServerMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveDBusObjectManagerServerMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveDBusObjectManagerServerMethod t DBusObjectManagerServer, O.MethodInfo info DBusObjectManagerServer p) => O.IsLabelProxy t (DBusObjectManagerServer -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveDBusObjectManagerServerMethod t DBusObjectManagerServer, O.MethodInfo info DBusObjectManagerServer p) => O.IsLabel t (DBusObjectManagerServer -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif
#endif

#endif

-- VVV Prop "connection"
   -- Type: TInterface (Name {namespace = "Gio", name = "DBusConnection"})
   -- Flags: [PropertyReadable,PropertyWritable]
   -- Nullable: (Nothing,Just True)

{- |
Get the value of the “@connection@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' dBusObjectManagerServer #connection
@
-}
getDBusObjectManagerServerConnection :: (MonadIO m, IsDBusObjectManagerServer o) => o -> m (Maybe Gio.DBusConnection.DBusConnection)
getDBusObjectManagerServerConnection obj = liftIO $ getObjectPropertyObject obj "connection" Gio.DBusConnection.DBusConnection

{- |
Set the value of the “@connection@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' dBusObjectManagerServer [ #connection 'Data.GI.Base.Attributes.:=' value ]
@
-}
setDBusObjectManagerServerConnection :: (MonadIO m, IsDBusObjectManagerServer o, Gio.DBusConnection.IsDBusConnection a) => o -> a -> m ()
setDBusObjectManagerServerConnection obj val = liftIO $ setObjectPropertyObject obj "connection" (Just val)

{- |
Construct a `GValueConstruct` with valid value for the “@connection@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructDBusObjectManagerServerConnection :: (IsDBusObjectManagerServer o, Gio.DBusConnection.IsDBusConnection a) => a -> IO (GValueConstruct o)
constructDBusObjectManagerServerConnection val = constructObjectPropertyObject "connection" (Just val)

{- |
Set the value of the “@connection@” property to `Nothing`.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.clear' #connection
@
-}
clearDBusObjectManagerServerConnection :: (MonadIO m, IsDBusObjectManagerServer o) => o -> m ()
clearDBusObjectManagerServerConnection obj = liftIO $ setObjectPropertyObject obj "connection" (Nothing :: Maybe Gio.DBusConnection.DBusConnection)

#if ENABLE_OVERLOADING
data DBusObjectManagerServerConnectionPropertyInfo
instance AttrInfo DBusObjectManagerServerConnectionPropertyInfo where
    type AttrAllowedOps DBusObjectManagerServerConnectionPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint DBusObjectManagerServerConnectionPropertyInfo = Gio.DBusConnection.IsDBusConnection
    type AttrBaseTypeConstraint DBusObjectManagerServerConnectionPropertyInfo = IsDBusObjectManagerServer
    type AttrGetType DBusObjectManagerServerConnectionPropertyInfo = (Maybe Gio.DBusConnection.DBusConnection)
    type AttrLabel DBusObjectManagerServerConnectionPropertyInfo = "connection"
    type AttrOrigin DBusObjectManagerServerConnectionPropertyInfo = DBusObjectManagerServer
    attrGet _ = getDBusObjectManagerServerConnection
    attrSet _ = setDBusObjectManagerServerConnection
    attrConstruct _ = constructDBusObjectManagerServerConnection
    attrClear _ = clearDBusObjectManagerServerConnection
#endif

-- VVV Prop "object-path"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Nothing)

{- |
Get the value of the “@object-path@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' dBusObjectManagerServer #objectPath
@
-}
getDBusObjectManagerServerObjectPath :: (MonadIO m, IsDBusObjectManagerServer o) => o -> m (Maybe T.Text)
getDBusObjectManagerServerObjectPath obj = liftIO $ getObjectPropertyString obj "object-path"

{- |
Construct a `GValueConstruct` with valid value for the “@object-path@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructDBusObjectManagerServerObjectPath :: (IsDBusObjectManagerServer o) => T.Text -> IO (GValueConstruct o)
constructDBusObjectManagerServerObjectPath val = constructObjectPropertyString "object-path" (Just val)

#if ENABLE_OVERLOADING
data DBusObjectManagerServerObjectPathPropertyInfo
instance AttrInfo DBusObjectManagerServerObjectPathPropertyInfo where
    type AttrAllowedOps DBusObjectManagerServerObjectPathPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint DBusObjectManagerServerObjectPathPropertyInfo = (~) T.Text
    type AttrBaseTypeConstraint DBusObjectManagerServerObjectPathPropertyInfo = IsDBusObjectManagerServer
    type AttrGetType DBusObjectManagerServerObjectPathPropertyInfo = (Maybe T.Text)
    type AttrLabel DBusObjectManagerServerObjectPathPropertyInfo = "object-path"
    type AttrOrigin DBusObjectManagerServerObjectPathPropertyInfo = DBusObjectManagerServer
    attrGet _ = getDBusObjectManagerServerObjectPath
    attrSet _ = undefined
    attrConstruct _ = constructDBusObjectManagerServerObjectPath
    attrClear _ = undefined
#endif

#if ENABLE_OVERLOADING
instance O.HasAttributeList DBusObjectManagerServer
type instance O.AttributeList DBusObjectManagerServer = DBusObjectManagerServerAttributeList
type DBusObjectManagerServerAttributeList = ('[ '("connection", DBusObjectManagerServerConnectionPropertyInfo), '("objectPath", DBusObjectManagerServerObjectPathPropertyInfo)] :: [(Symbol, *)])
#endif

#if ENABLE_OVERLOADING
dBusObjectManagerServerConnection :: AttrLabelProxy "connection"
dBusObjectManagerServerConnection = AttrLabelProxy

dBusObjectManagerServerObjectPath :: AttrLabelProxy "objectPath"
dBusObjectManagerServerObjectPath = AttrLabelProxy

#endif

#if ENABLE_OVERLOADING
type instance O.SignalList DBusObjectManagerServer = DBusObjectManagerServerSignalList
type DBusObjectManagerServerSignalList = ('[ '("interfaceAdded", Gio.DBusObjectManager.DBusObjectManagerInterfaceAddedSignalInfo), '("interfaceRemoved", Gio.DBusObjectManager.DBusObjectManagerInterfaceRemovedSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo), '("objectAdded", Gio.DBusObjectManager.DBusObjectManagerObjectAddedSignalInfo), '("objectRemoved", Gio.DBusObjectManager.DBusObjectManagerObjectRemovedSignalInfo)] :: [(Symbol, *)])

#endif

-- method DBusObjectManagerServer::new
-- method type : Constructor
-- Args : [Arg {argCName = "object_path", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The object path to export the manager object at.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "DBusObjectManagerServer"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_dbus_object_manager_server_new" g_dbus_object_manager_server_new ::
    CString ->                              -- object_path : TBasicType TUTF8
    IO (Ptr DBusObjectManagerServer)

{- |
Creates a new 'GI.Gio.Objects.DBusObjectManagerServer.DBusObjectManagerServer' object.

The returned server isn\'t yet exported on any connection. To do so,
use 'GI.Gio.Objects.DBusObjectManagerServer.dBusObjectManagerServerSetConnection'. Normally you
want to export all of your objects before doing so to avoid
<http://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-objectmanager InterfacesAdded>
signals being emitted.

/Since: 2.30/
-}
dBusObjectManagerServerNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@objectPath@/: The object path to export the manager object at. -}
    -> m DBusObjectManagerServer
    {- ^ __Returns:__ A 'GI.Gio.Objects.DBusObjectManagerServer.DBusObjectManagerServer' object. Free with 'GI.GObject.Objects.Object.objectUnref'. -}
dBusObjectManagerServerNew objectPath = liftIO $ do
    objectPath' <- textToCString objectPath
    result <- g_dbus_object_manager_server_new objectPath'
    checkUnexpectedReturnNULL "dBusObjectManagerServerNew" result
    result' <- (wrapObject DBusObjectManagerServer) result
    freeMem objectPath'
    return result'

#if ENABLE_OVERLOADING
#endif

-- method DBusObjectManagerServer::export
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "manager", argType = TInterface (Name {namespace = "Gio", name = "DBusObjectManagerServer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GDBusObjectManagerServer.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "object", argType = TInterface (Name {namespace = "Gio", name = "DBusObjectSkeleton"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GDBusObjectSkeleton.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_dbus_object_manager_server_export" g_dbus_object_manager_server_export ::
    Ptr DBusObjectManagerServer ->          -- manager : TInterface (Name {namespace = "Gio", name = "DBusObjectManagerServer"})
    Ptr Gio.DBusObjectSkeleton.DBusObjectSkeleton -> -- object : TInterface (Name {namespace = "Gio", name = "DBusObjectSkeleton"})
    IO ()

{- |
Exports /@object@/ on /@manager@/.

If there is already a 'GI.Gio.Interfaces.DBusObject.DBusObject' exported at the object path,
then the old object is removed.

The object path for /@object@/ must be in the hierarchy rooted by the
object path for /@manager@/.

Note that /@manager@/ will take a reference on /@object@/ for as long as
it is exported.

/Since: 2.30/
-}
dBusObjectManagerServerExport ::
    (B.CallStack.HasCallStack, MonadIO m, IsDBusObjectManagerServer a, Gio.DBusObjectSkeleton.IsDBusObjectSkeleton b) =>
    a
    {- ^ /@manager@/: A 'GI.Gio.Objects.DBusObjectManagerServer.DBusObjectManagerServer'. -}
    -> b
    {- ^ /@object@/: A 'GI.Gio.Objects.DBusObjectSkeleton.DBusObjectSkeleton'. -}
    -> m ()
dBusObjectManagerServerExport manager object = liftIO $ do
    manager' <- unsafeManagedPtrCastPtr manager
    object' <- unsafeManagedPtrCastPtr object
    g_dbus_object_manager_server_export manager' object'
    touchManagedPtr manager
    touchManagedPtr object
    return ()

#if ENABLE_OVERLOADING
data DBusObjectManagerServerExportMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsDBusObjectManagerServer a, Gio.DBusObjectSkeleton.IsDBusObjectSkeleton b) => O.MethodInfo DBusObjectManagerServerExportMethodInfo a signature where
    overloadedMethod _ = dBusObjectManagerServerExport

#endif

-- method DBusObjectManagerServer::export_uniquely
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "manager", argType = TInterface (Name {namespace = "Gio", name = "DBusObjectManagerServer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GDBusObjectManagerServer.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "object", argType = TInterface (Name {namespace = "Gio", name = "DBusObjectSkeleton"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "An object.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_dbus_object_manager_server_export_uniquely" g_dbus_object_manager_server_export_uniquely ::
    Ptr DBusObjectManagerServer ->          -- manager : TInterface (Name {namespace = "Gio", name = "DBusObjectManagerServer"})
    Ptr Gio.DBusObjectSkeleton.DBusObjectSkeleton -> -- object : TInterface (Name {namespace = "Gio", name = "DBusObjectSkeleton"})
    IO ()

{- |
Like 'GI.Gio.Objects.DBusObjectManagerServer.dBusObjectManagerServerExport' but appends a string of
the form _N (with N being a natural number) to /@object@/\'s object path
if an object with the given path already exists. As such, the
'GI.Gio.Objects.DBusObjectProxy.DBusObjectProxy':@/g-object-path/@ property of /@object@/ may be modified.

/Since: 2.30/
-}
dBusObjectManagerServerExportUniquely ::
    (B.CallStack.HasCallStack, MonadIO m, IsDBusObjectManagerServer a, Gio.DBusObjectSkeleton.IsDBusObjectSkeleton b) =>
    a
    {- ^ /@manager@/: A 'GI.Gio.Objects.DBusObjectManagerServer.DBusObjectManagerServer'. -}
    -> b
    {- ^ /@object@/: An object. -}
    -> m ()
dBusObjectManagerServerExportUniquely manager object = liftIO $ do
    manager' <- unsafeManagedPtrCastPtr manager
    object' <- unsafeManagedPtrCastPtr object
    g_dbus_object_manager_server_export_uniquely manager' object'
    touchManagedPtr manager
    touchManagedPtr object
    return ()

#if ENABLE_OVERLOADING
data DBusObjectManagerServerExportUniquelyMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsDBusObjectManagerServer a, Gio.DBusObjectSkeleton.IsDBusObjectSkeleton b) => O.MethodInfo DBusObjectManagerServerExportUniquelyMethodInfo a signature where
    overloadedMethod _ = dBusObjectManagerServerExportUniquely

#endif

-- method DBusObjectManagerServer::get_connection
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "manager", argType = TInterface (Name {namespace = "Gio", name = "DBusObjectManagerServer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GDBusObjectManagerServer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "DBusConnection"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_dbus_object_manager_server_get_connection" g_dbus_object_manager_server_get_connection ::
    Ptr DBusObjectManagerServer ->          -- manager : TInterface (Name {namespace = "Gio", name = "DBusObjectManagerServer"})
    IO (Ptr Gio.DBusConnection.DBusConnection)

{- |
Gets the 'GI.Gio.Objects.DBusConnection.DBusConnection' used by /@manager@/.

/Since: 2.30/
-}
dBusObjectManagerServerGetConnection ::
    (B.CallStack.HasCallStack, MonadIO m, IsDBusObjectManagerServer a) =>
    a
    {- ^ /@manager@/: A 'GI.Gio.Objects.DBusObjectManagerServer.DBusObjectManagerServer' -}
    -> m Gio.DBusConnection.DBusConnection
    {- ^ __Returns:__ A 'GI.Gio.Objects.DBusConnection.DBusConnection' object or 'Nothing' if
  /@manager@/ isn\'t exported on a connection. The returned object should
  be freed with 'GI.GObject.Objects.Object.objectUnref'. -}
dBusObjectManagerServerGetConnection manager = liftIO $ do
    manager' <- unsafeManagedPtrCastPtr manager
    result <- g_dbus_object_manager_server_get_connection manager'
    checkUnexpectedReturnNULL "dBusObjectManagerServerGetConnection" result
    result' <- (wrapObject Gio.DBusConnection.DBusConnection) result
    touchManagedPtr manager
    return result'

#if ENABLE_OVERLOADING
data DBusObjectManagerServerGetConnectionMethodInfo
instance (signature ~ (m Gio.DBusConnection.DBusConnection), MonadIO m, IsDBusObjectManagerServer a) => O.MethodInfo DBusObjectManagerServerGetConnectionMethodInfo a signature where
    overloadedMethod _ = dBusObjectManagerServerGetConnection

#endif

-- method DBusObjectManagerServer::is_exported
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "manager", argType = TInterface (Name {namespace = "Gio", name = "DBusObjectManagerServer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GDBusObjectManagerServer.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "object", argType = TInterface (Name {namespace = "Gio", name = "DBusObjectSkeleton"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "An object.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_dbus_object_manager_server_is_exported" g_dbus_object_manager_server_is_exported ::
    Ptr DBusObjectManagerServer ->          -- manager : TInterface (Name {namespace = "Gio", name = "DBusObjectManagerServer"})
    Ptr Gio.DBusObjectSkeleton.DBusObjectSkeleton -> -- object : TInterface (Name {namespace = "Gio", name = "DBusObjectSkeleton"})
    IO CInt

{- |
Returns whether /@object@/ is currently exported on /@manager@/.

/Since: 2.34/
-}
dBusObjectManagerServerIsExported ::
    (B.CallStack.HasCallStack, MonadIO m, IsDBusObjectManagerServer a, Gio.DBusObjectSkeleton.IsDBusObjectSkeleton b) =>
    a
    {- ^ /@manager@/: A 'GI.Gio.Objects.DBusObjectManagerServer.DBusObjectManagerServer'. -}
    -> b
    {- ^ /@object@/: An object. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@object@/ is exported -}
dBusObjectManagerServerIsExported manager object = liftIO $ do
    manager' <- unsafeManagedPtrCastPtr manager
    object' <- unsafeManagedPtrCastPtr object
    result <- g_dbus_object_manager_server_is_exported manager' object'
    let result' = (/= 0) result
    touchManagedPtr manager
    touchManagedPtr object
    return result'

#if ENABLE_OVERLOADING
data DBusObjectManagerServerIsExportedMethodInfo
instance (signature ~ (b -> m Bool), MonadIO m, IsDBusObjectManagerServer a, Gio.DBusObjectSkeleton.IsDBusObjectSkeleton b) => O.MethodInfo DBusObjectManagerServerIsExportedMethodInfo a signature where
    overloadedMethod _ = dBusObjectManagerServerIsExported

#endif

-- method DBusObjectManagerServer::set_connection
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "manager", argType = TInterface (Name {namespace = "Gio", name = "DBusObjectManagerServer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GDBusObjectManagerServer.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "connection", argType = TInterface (Name {namespace = "Gio", name = "DBusConnection"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "A #GDBusConnection or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_dbus_object_manager_server_set_connection" g_dbus_object_manager_server_set_connection ::
    Ptr DBusObjectManagerServer ->          -- manager : TInterface (Name {namespace = "Gio", name = "DBusObjectManagerServer"})
    Ptr Gio.DBusConnection.DBusConnection -> -- connection : TInterface (Name {namespace = "Gio", name = "DBusConnection"})
    IO ()

{- |
Exports all objects managed by /@manager@/ on /@connection@/. If
/@connection@/ is 'Nothing', stops exporting objects.
-}
dBusObjectManagerServerSetConnection ::
    (B.CallStack.HasCallStack, MonadIO m, IsDBusObjectManagerServer a, Gio.DBusConnection.IsDBusConnection b) =>
    a
    {- ^ /@manager@/: A 'GI.Gio.Objects.DBusObjectManagerServer.DBusObjectManagerServer'. -}
    -> Maybe (b)
    {- ^ /@connection@/: A 'GI.Gio.Objects.DBusConnection.DBusConnection' or 'Nothing'. -}
    -> m ()
dBusObjectManagerServerSetConnection manager connection = liftIO $ do
    manager' <- unsafeManagedPtrCastPtr manager
    maybeConnection <- case connection of
        Nothing -> return nullPtr
        Just jConnection -> do
            jConnection' <- unsafeManagedPtrCastPtr jConnection
            return jConnection'
    g_dbus_object_manager_server_set_connection manager' maybeConnection
    touchManagedPtr manager
    whenJust connection touchManagedPtr
    return ()

#if ENABLE_OVERLOADING
data DBusObjectManagerServerSetConnectionMethodInfo
instance (signature ~ (Maybe (b) -> m ()), MonadIO m, IsDBusObjectManagerServer a, Gio.DBusConnection.IsDBusConnection b) => O.MethodInfo DBusObjectManagerServerSetConnectionMethodInfo a signature where
    overloadedMethod _ = dBusObjectManagerServerSetConnection

#endif

-- method DBusObjectManagerServer::unexport
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "manager", argType = TInterface (Name {namespace = "Gio", name = "DBusObjectManagerServer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GDBusObjectManagerServer.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "object_path", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "An object path.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_dbus_object_manager_server_unexport" g_dbus_object_manager_server_unexport ::
    Ptr DBusObjectManagerServer ->          -- manager : TInterface (Name {namespace = "Gio", name = "DBusObjectManagerServer"})
    CString ->                              -- object_path : TBasicType TUTF8
    IO CInt

{- |
If /@manager@/ has an object at /@path@/, removes the object. Otherwise
does nothing.

Note that /@objectPath@/ must be in the hierarchy rooted by the
object path for /@manager@/.

/Since: 2.30/
-}
dBusObjectManagerServerUnexport ::
    (B.CallStack.HasCallStack, MonadIO m, IsDBusObjectManagerServer a) =>
    a
    {- ^ /@manager@/: A 'GI.Gio.Objects.DBusObjectManagerServer.DBusObjectManagerServer'. -}
    -> T.Text
    {- ^ /@objectPath@/: An object path. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if object at /@objectPath@/ was removed, 'False' otherwise. -}
dBusObjectManagerServerUnexport manager objectPath = liftIO $ do
    manager' <- unsafeManagedPtrCastPtr manager
    objectPath' <- textToCString objectPath
    result <- g_dbus_object_manager_server_unexport manager' objectPath'
    let result' = (/= 0) result
    touchManagedPtr manager
    freeMem objectPath'
    return result'

#if ENABLE_OVERLOADING
data DBusObjectManagerServerUnexportMethodInfo
instance (signature ~ (T.Text -> m Bool), MonadIO m, IsDBusObjectManagerServer a) => O.MethodInfo DBusObjectManagerServerUnexportMethodInfo a signature where
    overloadedMethod _ = dBusObjectManagerServerUnexport

#endif