{- |
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.DBusServer.DBusServer' is a helper for listening to and accepting D-Bus
connections. This can be used to create a new D-Bus server, allowing two
peers to use the D-Bus protocol for their own specialized communication.
A server instance provided in this way will not perform message routing or
implement the org.freedesktop.DBus interface.

To just export an object on a well-known name on a message bus, such as the
session or system bus, you should instead use @/g_bus_own_name()/@.

An example of peer-to-peer communication with G-DBus can be found
in <https://git.gnome.org/browse/glib/tree/gio/tests/gdbus-example-peer.c gdbus-example-peer.c>.

Note that a minimal 'GI.Gio.Objects.DBusServer.DBusServer' will accept connections from any
peer. In many use-cases it will be necessary to add a 'GI.Gio.Objects.DBusAuthObserver.DBusAuthObserver'
that only accepts connections that have successfully authenticated
as the same user that is running the 'GI.Gio.Objects.DBusServer.DBusServer'.

/Since: 2.26/
-}

#define ENABLE_OVERLOADING \
       (!defined(__HADDOCK_VERSION__))

module GI.Gio.Objects.DBusServer
    ( 

-- * Exported types
    DBusServer(..)                          ,
    IsDBusServer                            ,
    toDBusServer                            ,
    noDBusServer                            ,


 -- * Methods
-- ** getClientAddress #method:getClientAddress#

#if ENABLE_OVERLOADING
    DBusServerGetClientAddressMethodInfo    ,
#endif
    dBusServerGetClientAddress              ,


-- ** getFlags #method:getFlags#

#if ENABLE_OVERLOADING
    DBusServerGetFlagsMethodInfo            ,
#endif
    dBusServerGetFlags                      ,


-- ** getGuid #method:getGuid#

#if ENABLE_OVERLOADING
    DBusServerGetGuidMethodInfo             ,
#endif
    dBusServerGetGuid                       ,


-- ** isActive #method:isActive#

#if ENABLE_OVERLOADING
    DBusServerIsActiveMethodInfo            ,
#endif
    dBusServerIsActive                      ,


-- ** newSync #method:newSync#

    dBusServerNewSync                       ,


-- ** start #method:start#

#if ENABLE_OVERLOADING
    DBusServerStartMethodInfo               ,
#endif
    dBusServerStart                         ,


-- ** stop #method:stop#

#if ENABLE_OVERLOADING
    DBusServerStopMethodInfo                ,
#endif
    dBusServerStop                          ,




 -- * Properties
-- ** active #attr:active#
{- | Whether the server is currently active.

/Since: 2.26/
-}
#if ENABLE_OVERLOADING
    DBusServerActivePropertyInfo            ,
#endif
#if ENABLE_OVERLOADING
    dBusServerActive                        ,
#endif
    getDBusServerActive                     ,


-- ** address #attr:address#
{- | The D-Bus address to listen on.

/Since: 2.26/
-}
#if ENABLE_OVERLOADING
    DBusServerAddressPropertyInfo           ,
#endif
    constructDBusServerAddress              ,
#if ENABLE_OVERLOADING
    dBusServerAddress                       ,
#endif
    getDBusServerAddress                    ,


-- ** authenticationObserver #attr:authenticationObserver#
{- | A 'GI.Gio.Objects.DBusAuthObserver.DBusAuthObserver' object to assist in the authentication process or 'Nothing'.

/Since: 2.26/
-}
#if ENABLE_OVERLOADING
    DBusServerAuthenticationObserverPropertyInfo,
#endif
    constructDBusServerAuthenticationObserver,
#if ENABLE_OVERLOADING
    dBusServerAuthenticationObserver        ,
#endif
    getDBusServerAuthenticationObserver     ,


-- ** clientAddress #attr:clientAddress#
{- | The D-Bus address that clients can use.

/Since: 2.26/
-}
#if ENABLE_OVERLOADING
    DBusServerClientAddressPropertyInfo     ,
#endif
#if ENABLE_OVERLOADING
    dBusServerClientAddress                 ,
#endif
    getDBusServerClientAddress              ,


-- ** flags #attr:flags#
{- | Flags from the 'GI.Gio.Flags.DBusServerFlags' enumeration.

/Since: 2.26/
-}
#if ENABLE_OVERLOADING
    DBusServerFlagsPropertyInfo             ,
#endif
    constructDBusServerFlags                ,
#if ENABLE_OVERLOADING
    dBusServerFlags                         ,
#endif
    getDBusServerFlags                      ,


-- ** guid #attr:guid#
{- | The guid of the server.

/Since: 2.26/
-}
#if ENABLE_OVERLOADING
    DBusServerGuidPropertyInfo              ,
#endif
    constructDBusServerGuid                 ,
#if ENABLE_OVERLOADING
    dBusServerGuid                          ,
#endif
    getDBusServerGuid                       ,




 -- * Signals
-- ** newConnection #signal:newConnection#

    C_DBusServerNewConnectionCallback       ,
    DBusServerNewConnectionCallback         ,
#if ENABLE_OVERLOADING
    DBusServerNewConnectionSignalInfo       ,
#endif
    afterDBusServerNewConnection            ,
    genClosure_DBusServerNewConnection      ,
    mk_DBusServerNewConnectionCallback      ,
    noDBusServerNewConnectionCallback       ,
    onDBusServerNewConnection               ,
    wrap_DBusServerNewConnectionCallback    ,




    ) 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.Flags as Gio.Flags
import {-# SOURCE #-} qualified GI.Gio.Interfaces.Initable as Gio.Initable
import {-# SOURCE #-} qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import {-# SOURCE #-} qualified GI.Gio.Objects.DBusAuthObserver as Gio.DBusAuthObserver
import {-# SOURCE #-} qualified GI.Gio.Objects.DBusConnection as Gio.DBusConnection

-- | Memory-managed wrapper type.
newtype DBusServer = DBusServer (ManagedPtr DBusServer)
foreign import ccall "g_dbus_server_get_type"
    c_g_dbus_server_get_type :: IO GType

instance GObject DBusServer where
    gobjectType :: DBusServer -> IO GType
gobjectType _ = IO GType
c_g_dbus_server_get_type
    

-- | Type class for types which can be safely cast to `DBusServer`, for instance with `toDBusServer`.
class GObject o => IsDBusServer o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError DBusServer a) =>
    IsDBusServer a
#endif
instance IsDBusServer DBusServer
instance GObject.Object.IsObject DBusServer
instance Gio.Initable.IsInitable DBusServer

-- | Cast to `DBusServer`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toDBusServer :: (MonadIO m, IsDBusServer o) => o -> m DBusServer
toDBusServer :: o -> m DBusServer
toDBusServer = IO DBusServer -> m DBusServer
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO DBusServer -> m DBusServer)
-> (o -> IO DBusServer) -> o -> m DBusServer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr DBusServer -> DBusServer) -> o -> IO DBusServer
forall o o'.
(HasCallStack, GObject o, GObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
unsafeCastTo ManagedPtr DBusServer -> DBusServer
DBusServer

-- | A convenience alias for `Nothing` :: `Maybe` `DBusServer`.
noDBusServer :: Maybe DBusServer
noDBusServer :: Maybe DBusServer
noDBusServer = Maybe DBusServer
forall a. Maybe a
Nothing

#if ENABLE_OVERLOADING
type family ResolveDBusServerMethod (t :: Symbol) (o :: *) :: * where
    ResolveDBusServerMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveDBusServerMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveDBusServerMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveDBusServerMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveDBusServerMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveDBusServerMethod "init" o = Gio.Initable.InitableInitMethodInfo
    ResolveDBusServerMethod "isActive" o = DBusServerIsActiveMethodInfo
    ResolveDBusServerMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveDBusServerMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveDBusServerMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveDBusServerMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveDBusServerMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveDBusServerMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveDBusServerMethod "start" o = DBusServerStartMethodInfo
    ResolveDBusServerMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveDBusServerMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveDBusServerMethod "stop" o = DBusServerStopMethodInfo
    ResolveDBusServerMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveDBusServerMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveDBusServerMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveDBusServerMethod "getClientAddress" o = DBusServerGetClientAddressMethodInfo
    ResolveDBusServerMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveDBusServerMethod "getFlags" o = DBusServerGetFlagsMethodInfo
    ResolveDBusServerMethod "getGuid" o = DBusServerGetGuidMethodInfo
    ResolveDBusServerMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveDBusServerMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveDBusServerMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveDBusServerMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveDBusServerMethod l o = O.MethodResolutionFailed l o

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

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveDBusServerMethod t DBusServer, O.MethodInfo info DBusServer p) => O.IsLabel t (DBusServer -> 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

-- signal DBusServer::new-connection
{- |
Emitted when a new authenticated connection has been made. Use
'GI.Gio.Objects.DBusConnection.dBusConnectionGetPeerCredentials' to figure out what
identity (if any), was authenticated.

If you want to accept the connection, take a reference to the
/@connection@/ object and return 'True'. When you are done with the
connection call 'GI.Gio.Objects.DBusConnection.dBusConnectionClose' and give up your
reference. Note that the other peer may disconnect at any time -
a typical thing to do when accepting a connection is to listen to
the 'GI.Gio.Objects.DBusConnection.DBusConnection'::@/closed/@ signal.

If 'GI.Gio.Objects.DBusServer.DBusServer':@/flags/@ contains 'GI.Gio.Flags.DBusServerFlagsRunInThread'
then the signal is emitted in a new thread dedicated to the
connection. Otherwise the signal is emitted in the
[thread-default main context][g-main-context-push-thread-default]
of the thread that /@server@/ was constructed in.

You are guaranteed that signal handlers for this signal runs
before incoming messages on /@connection@/ are processed. This means
that it\'s suitable to call @/g_dbus_connection_register_object()/@ or
similar from the signal handler.

/Since: 2.26/
-}
type DBusServerNewConnectionCallback =
    Gio.DBusConnection.DBusConnection
    {- ^ /@connection@/: A 'GI.Gio.Objects.DBusConnection.DBusConnection' for the new connection. -}
    -> IO Bool
    {- ^ __Returns:__ 'True' to claim /@connection@/, 'False' to let other handlers
run. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `DBusServerNewConnectionCallback`@.
noDBusServerNewConnectionCallback :: Maybe DBusServerNewConnectionCallback
noDBusServerNewConnectionCallback :: Maybe DBusServerNewConnectionCallback
noDBusServerNewConnectionCallback = Maybe DBusServerNewConnectionCallback
forall a. Maybe a
Nothing

-- | Type for the callback on the (unwrapped) C side.
type C_DBusServerNewConnectionCallback =
    Ptr () ->                               -- object
    Ptr Gio.DBusConnection.DBusConnection ->
    Ptr () ->                               -- user_data
    IO CInt

-- | Generate a function pointer callable from C code, from a `C_DBusServerNewConnectionCallback`.
foreign import ccall "wrapper"
    mk_DBusServerNewConnectionCallback :: C_DBusServerNewConnectionCallback -> IO (FunPtr C_DBusServerNewConnectionCallback)

-- | Wrap the callback into a `Closure`.
genClosure_DBusServerNewConnection :: DBusServerNewConnectionCallback -> IO Closure
genClosure_DBusServerNewConnection :: DBusServerNewConnectionCallback -> IO Closure
genClosure_DBusServerNewConnection cb :: DBusServerNewConnectionCallback
cb = do
    let cb' :: C_DBusServerNewConnectionCallback
cb' = DBusServerNewConnectionCallback
-> C_DBusServerNewConnectionCallback
wrap_DBusServerNewConnectionCallback DBusServerNewConnectionCallback
cb
    C_DBusServerNewConnectionCallback
-> IO (FunPtr C_DBusServerNewConnectionCallback)
mk_DBusServerNewConnectionCallback C_DBusServerNewConnectionCallback
cb' IO (FunPtr C_DBusServerNewConnectionCallback)
-> (FunPtr C_DBusServerNewConnectionCallback -> IO Closure)
-> IO Closure
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= FunPtr C_DBusServerNewConnectionCallback -> IO Closure
forall a. FunPtr a -> IO Closure
newCClosure


-- | Wrap a `DBusServerNewConnectionCallback` into a `C_DBusServerNewConnectionCallback`.
wrap_DBusServerNewConnectionCallback ::
    DBusServerNewConnectionCallback ->
    C_DBusServerNewConnectionCallback
wrap_DBusServerNewConnectionCallback :: DBusServerNewConnectionCallback
-> C_DBusServerNewConnectionCallback
wrap_DBusServerNewConnectionCallback _cb :: DBusServerNewConnectionCallback
_cb _ connection :: Ptr DBusConnection
connection _ = do
    DBusConnection
connection' <- ((ManagedPtr DBusConnection -> DBusConnection)
-> Ptr DBusConnection -> IO DBusConnection
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr DBusConnection -> DBusConnection
Gio.DBusConnection.DBusConnection) Ptr DBusConnection
connection
    Bool
result <- DBusServerNewConnectionCallback
_cb  DBusConnection
connection'
    let result' :: CInt
result' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
fromEnum) Bool
result
    CInt -> IO CInt
forall (m :: * -> *) a. Monad m => a -> m a
return CInt
result'


{- |
Connect a signal handler for the “@new-connection@” signal, to be run before the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.on' dBusServer #newConnection callback
@
-}
onDBusServerNewConnection :: (IsDBusServer a, MonadIO m) => a -> DBusServerNewConnectionCallback -> m SignalHandlerId
onDBusServerNewConnection :: a -> DBusServerNewConnectionCallback -> m SignalHandlerId
onDBusServerNewConnection obj :: a
obj cb :: DBusServerNewConnectionCallback
cb = IO SignalHandlerId -> m SignalHandlerId
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SignalHandlerId -> m SignalHandlerId)
-> IO SignalHandlerId -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_DBusServerNewConnectionCallback
cb' = DBusServerNewConnectionCallback
-> C_DBusServerNewConnectionCallback
wrap_DBusServerNewConnectionCallback DBusServerNewConnectionCallback
cb
    FunPtr C_DBusServerNewConnectionCallback
cb'' <- C_DBusServerNewConnectionCallback
-> IO (FunPtr C_DBusServerNewConnectionCallback)
mk_DBusServerNewConnectionCallback C_DBusServerNewConnectionCallback
cb'
    a
-> String
-> FunPtr C_DBusServerNewConnectionCallback
-> SignalConnectMode
-> IO SignalHandlerId
forall o a.
GObject o =>
o -> String -> FunPtr a -> SignalConnectMode -> IO SignalHandlerId
connectSignalFunPtr a
obj "new-connection" FunPtr C_DBusServerNewConnectionCallback
cb'' SignalConnectMode
SignalConnectBefore

{- |
Connect a signal handler for the “@new-connection@” signal, to be run after the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.after' dBusServer #newConnection callback
@
-}
afterDBusServerNewConnection :: (IsDBusServer a, MonadIO m) => a -> DBusServerNewConnectionCallback -> m SignalHandlerId
afterDBusServerNewConnection :: a -> DBusServerNewConnectionCallback -> m SignalHandlerId
afterDBusServerNewConnection obj :: a
obj cb :: DBusServerNewConnectionCallback
cb = IO SignalHandlerId -> m SignalHandlerId
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SignalHandlerId -> m SignalHandlerId)
-> IO SignalHandlerId -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_DBusServerNewConnectionCallback
cb' = DBusServerNewConnectionCallback
-> C_DBusServerNewConnectionCallback
wrap_DBusServerNewConnectionCallback DBusServerNewConnectionCallback
cb
    FunPtr C_DBusServerNewConnectionCallback
cb'' <- C_DBusServerNewConnectionCallback
-> IO (FunPtr C_DBusServerNewConnectionCallback)
mk_DBusServerNewConnectionCallback C_DBusServerNewConnectionCallback
cb'
    a
-> String
-> FunPtr C_DBusServerNewConnectionCallback
-> SignalConnectMode
-> IO SignalHandlerId
forall o a.
GObject o =>
o -> String -> FunPtr a -> SignalConnectMode -> IO SignalHandlerId
connectSignalFunPtr a
obj "new-connection" FunPtr C_DBusServerNewConnectionCallback
cb'' SignalConnectMode
SignalConnectAfter


-- VVV Prop "active"
   -- Type: TBasicType TBoolean
   -- Flags: [PropertyReadable]
   -- Nullable: (Nothing,Nothing)

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

@
'Data.GI.Base.Attributes.get' dBusServer #active
@
-}
getDBusServerActive :: (MonadIO m, IsDBusServer o) => o -> m Bool
getDBusServerActive :: o -> m Bool
getDBusServerActive obj :: o
obj = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ o -> String -> IO Bool
forall a. GObject a => a -> String -> IO Bool
getObjectPropertyBool o
obj "active"

#if ENABLE_OVERLOADING
data DBusServerActivePropertyInfo
instance AttrInfo DBusServerActivePropertyInfo where
    type AttrAllowedOps DBusServerActivePropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint DBusServerActivePropertyInfo = (~) ()
    type AttrBaseTypeConstraint DBusServerActivePropertyInfo = IsDBusServer
    type AttrGetType DBusServerActivePropertyInfo = Bool
    type AttrLabel DBusServerActivePropertyInfo = "active"
    type AttrOrigin DBusServerActivePropertyInfo = DBusServer
    attrGet _ = getDBusServerActive
    attrSet _ = undefined
    attrConstruct _ = undefined
    attrClear _ = undefined
#endif

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

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

@
'Data.GI.Base.Attributes.get' dBusServer #address
@
-}
getDBusServerAddress :: (MonadIO m, IsDBusServer o) => o -> m (Maybe T.Text)
getDBusServerAddress :: o -> m (Maybe Text)
getDBusServerAddress obj :: o
obj = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ o -> String -> IO (Maybe Text)
forall a. GObject a => a -> String -> IO (Maybe Text)
getObjectPropertyString o
obj "address"

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

#if ENABLE_OVERLOADING
data DBusServerAddressPropertyInfo
instance AttrInfo DBusServerAddressPropertyInfo where
    type AttrAllowedOps DBusServerAddressPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint DBusServerAddressPropertyInfo = (~) T.Text
    type AttrBaseTypeConstraint DBusServerAddressPropertyInfo = IsDBusServer
    type AttrGetType DBusServerAddressPropertyInfo = (Maybe T.Text)
    type AttrLabel DBusServerAddressPropertyInfo = "address"
    type AttrOrigin DBusServerAddressPropertyInfo = DBusServer
    attrGet _ = getDBusServerAddress
    attrSet _ = undefined
    attrConstruct _ = constructDBusServerAddress
    attrClear _ = undefined
#endif

-- VVV Prop "authentication-observer"
   -- Type: TInterface (Name {namespace = "Gio", name = "DBusAuthObserver"})
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Nothing)

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

@
'Data.GI.Base.Attributes.get' dBusServer #authenticationObserver
@
-}
getDBusServerAuthenticationObserver :: (MonadIO m, IsDBusServer o) => o -> m (Maybe Gio.DBusAuthObserver.DBusAuthObserver)
getDBusServerAuthenticationObserver :: o -> m (Maybe DBusAuthObserver)
getDBusServerAuthenticationObserver obj :: o
obj = IO (Maybe DBusAuthObserver) -> m (Maybe DBusAuthObserver)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe DBusAuthObserver) -> m (Maybe DBusAuthObserver))
-> IO (Maybe DBusAuthObserver) -> m (Maybe DBusAuthObserver)
forall a b. (a -> b) -> a -> b
$ o
-> String
-> (ManagedPtr DBusAuthObserver -> DBusAuthObserver)
-> IO (Maybe DBusAuthObserver)
forall a b.
(GObject a, GObject b) =>
a -> String -> (ManagedPtr b -> b) -> IO (Maybe b)
getObjectPropertyObject o
obj "authentication-observer" ManagedPtr DBusAuthObserver -> DBusAuthObserver
Gio.DBusAuthObserver.DBusAuthObserver

{- |
Construct a `GValueConstruct` with valid value for the “@authentication-observer@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructDBusServerAuthenticationObserver :: (IsDBusServer o, Gio.DBusAuthObserver.IsDBusAuthObserver a) => a -> IO (GValueConstruct o)
constructDBusServerAuthenticationObserver :: a -> IO (GValueConstruct o)
constructDBusServerAuthenticationObserver val :: a
val = String -> Maybe a -> IO (GValueConstruct o)
forall a o.
GObject a =>
String -> Maybe a -> IO (GValueConstruct o)
constructObjectPropertyObject "authentication-observer" (a -> Maybe a
forall a. a -> Maybe a
Just a
val)

#if ENABLE_OVERLOADING
data DBusServerAuthenticationObserverPropertyInfo
instance AttrInfo DBusServerAuthenticationObserverPropertyInfo where
    type AttrAllowedOps DBusServerAuthenticationObserverPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint DBusServerAuthenticationObserverPropertyInfo = Gio.DBusAuthObserver.IsDBusAuthObserver
    type AttrBaseTypeConstraint DBusServerAuthenticationObserverPropertyInfo = IsDBusServer
    type AttrGetType DBusServerAuthenticationObserverPropertyInfo = (Maybe Gio.DBusAuthObserver.DBusAuthObserver)
    type AttrLabel DBusServerAuthenticationObserverPropertyInfo = "authentication-observer"
    type AttrOrigin DBusServerAuthenticationObserverPropertyInfo = DBusServer
    attrGet _ = getDBusServerAuthenticationObserver
    attrSet _ = undefined
    attrConstruct _ = constructDBusServerAuthenticationObserver
    attrClear _ = undefined
#endif

-- VVV Prop "client-address"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable]
   -- Nullable: (Just False,Nothing)

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

@
'Data.GI.Base.Attributes.get' dBusServer #clientAddress
@
-}
getDBusServerClientAddress :: (MonadIO m, IsDBusServer o) => o -> m T.Text
getDBusServerClientAddress :: o -> m Text
getDBusServerClientAddress obj :: o
obj = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ Text -> IO (Maybe Text) -> IO Text
forall a. HasCallStack => Text -> IO (Maybe a) -> IO a
checkUnexpectedNothing "getDBusServerClientAddress" (IO (Maybe Text) -> IO Text) -> IO (Maybe Text) -> IO Text
forall a b. (a -> b) -> a -> b
$ o -> String -> IO (Maybe Text)
forall a. GObject a => a -> String -> IO (Maybe Text)
getObjectPropertyString o
obj "client-address"

#if ENABLE_OVERLOADING
data DBusServerClientAddressPropertyInfo
instance AttrInfo DBusServerClientAddressPropertyInfo where
    type AttrAllowedOps DBusServerClientAddressPropertyInfo = '[ 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint DBusServerClientAddressPropertyInfo = (~) ()
    type AttrBaseTypeConstraint DBusServerClientAddressPropertyInfo = IsDBusServer
    type AttrGetType DBusServerClientAddressPropertyInfo = T.Text
    type AttrLabel DBusServerClientAddressPropertyInfo = "client-address"
    type AttrOrigin DBusServerClientAddressPropertyInfo = DBusServer
    attrGet _ = getDBusServerClientAddress
    attrSet _ = undefined
    attrConstruct _ = undefined
    attrClear _ = undefined
#endif

-- VVV Prop "flags"
   -- Type: TInterface (Name {namespace = "Gio", name = "DBusServerFlags"})
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Just False,Nothing)

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

@
'Data.GI.Base.Attributes.get' dBusServer #flags
@
-}
getDBusServerFlags :: (MonadIO m, IsDBusServer o) => o -> m [Gio.Flags.DBusServerFlags]
getDBusServerFlags :: o -> m [DBusServerFlags]
getDBusServerFlags obj :: o
obj = IO [DBusServerFlags] -> m [DBusServerFlags]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [DBusServerFlags] -> m [DBusServerFlags])
-> IO [DBusServerFlags] -> m [DBusServerFlags]
forall a b. (a -> b) -> a -> b
$ o -> String -> IO [DBusServerFlags]
forall a b.
(GObject a, IsGFlag b, BoxedFlags b) =>
a -> String -> IO [b]
getObjectPropertyFlags o
obj "flags"

{- |
Construct a `GValueConstruct` with valid value for the “@flags@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructDBusServerFlags :: (IsDBusServer o) => [Gio.Flags.DBusServerFlags] -> IO (GValueConstruct o)
constructDBusServerFlags :: [DBusServerFlags] -> IO (GValueConstruct o)
constructDBusServerFlags val :: [DBusServerFlags]
val = String -> [DBusServerFlags] -> IO (GValueConstruct o)
forall a o.
(IsGFlag a, BoxedFlags a) =>
String -> [a] -> IO (GValueConstruct o)
constructObjectPropertyFlags "flags" [DBusServerFlags]
val

#if ENABLE_OVERLOADING
data DBusServerFlagsPropertyInfo
instance AttrInfo DBusServerFlagsPropertyInfo where
    type AttrAllowedOps DBusServerFlagsPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint DBusServerFlagsPropertyInfo = (~) [Gio.Flags.DBusServerFlags]
    type AttrBaseTypeConstraint DBusServerFlagsPropertyInfo = IsDBusServer
    type AttrGetType DBusServerFlagsPropertyInfo = [Gio.Flags.DBusServerFlags]
    type AttrLabel DBusServerFlagsPropertyInfo = "flags"
    type AttrOrigin DBusServerFlagsPropertyInfo = DBusServer
    attrGet _ = getDBusServerFlags
    attrSet _ = undefined
    attrConstruct _ = constructDBusServerFlags
    attrClear _ = undefined
#endif

-- VVV Prop "guid"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Just False,Nothing)

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

@
'Data.GI.Base.Attributes.get' dBusServer #guid
@
-}
getDBusServerGuid :: (MonadIO m, IsDBusServer o) => o -> m T.Text
getDBusServerGuid :: o -> m Text
getDBusServerGuid obj :: o
obj = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ Text -> IO (Maybe Text) -> IO Text
forall a. HasCallStack => Text -> IO (Maybe a) -> IO a
checkUnexpectedNothing "getDBusServerGuid" (IO (Maybe Text) -> IO Text) -> IO (Maybe Text) -> IO Text
forall a b. (a -> b) -> a -> b
$ o -> String -> IO (Maybe Text)
forall a. GObject a => a -> String -> IO (Maybe Text)
getObjectPropertyString o
obj "guid"

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

#if ENABLE_OVERLOADING
data DBusServerGuidPropertyInfo
instance AttrInfo DBusServerGuidPropertyInfo where
    type AttrAllowedOps DBusServerGuidPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint DBusServerGuidPropertyInfo = (~) T.Text
    type AttrBaseTypeConstraint DBusServerGuidPropertyInfo = IsDBusServer
    type AttrGetType DBusServerGuidPropertyInfo = T.Text
    type AttrLabel DBusServerGuidPropertyInfo = "guid"
    type AttrOrigin DBusServerGuidPropertyInfo = DBusServer
    attrGet _ = getDBusServerGuid
    attrSet _ = undefined
    attrConstruct _ = constructDBusServerGuid
    attrClear _ = undefined
#endif

#if ENABLE_OVERLOADING
instance O.HasAttributeList DBusServer
type instance O.AttributeList DBusServer = DBusServerAttributeList
type DBusServerAttributeList = ('[ '("active", DBusServerActivePropertyInfo), '("address", DBusServerAddressPropertyInfo), '("authenticationObserver", DBusServerAuthenticationObserverPropertyInfo), '("clientAddress", DBusServerClientAddressPropertyInfo), '("flags", DBusServerFlagsPropertyInfo), '("guid", DBusServerGuidPropertyInfo)] :: [(Symbol, *)])
#endif

#if ENABLE_OVERLOADING
dBusServerActive :: AttrLabelProxy "active"
dBusServerActive = AttrLabelProxy

dBusServerAddress :: AttrLabelProxy "address"
dBusServerAddress = AttrLabelProxy

dBusServerAuthenticationObserver :: AttrLabelProxy "authenticationObserver"
dBusServerAuthenticationObserver = AttrLabelProxy

dBusServerClientAddress :: AttrLabelProxy "clientAddress"
dBusServerClientAddress = AttrLabelProxy

dBusServerFlags :: AttrLabelProxy "flags"
dBusServerFlags = AttrLabelProxy

dBusServerGuid :: AttrLabelProxy "guid"
dBusServerGuid = AttrLabelProxy

#endif

#if ENABLE_OVERLOADING
data DBusServerNewConnectionSignalInfo
instance SignalInfo DBusServerNewConnectionSignalInfo where
    type HaskellCallbackType DBusServerNewConnectionSignalInfo = DBusServerNewConnectionCallback
    connectSignal _ obj cb connectMode = do
        let cb' = wrap_DBusServerNewConnectionCallback cb
        cb'' <- mk_DBusServerNewConnectionCallback cb'
        connectSignalFunPtr obj "new-connection" cb'' connectMode

type instance O.SignalList DBusServer = DBusServerSignalList
type DBusServerSignalList = ('[ '("newConnection", DBusServerNewConnectionSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

-- method DBusServer::new_sync
-- method type : Constructor
-- Args : [Arg {argCName = "address", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A D-Bus address.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "DBusServerFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Flags from the #GDBusServerFlags enumeration.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "guid", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A D-Bus GUID.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "observer", argType = TInterface (Name {namespace = "Gio", name = "DBusAuthObserver"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "A #GDBusAuthObserver or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "A #GCancellable or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "DBusServer"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_dbus_server_new_sync" g_dbus_server_new_sync :: 
    CString ->                              -- address : TBasicType TUTF8
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "DBusServerFlags"})
    CString ->                              -- guid : TBasicType TUTF8
    Ptr Gio.DBusAuthObserver.DBusAuthObserver -> -- observer : TInterface (Name {namespace = "Gio", name = "DBusAuthObserver"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr DBusServer)

{- |
Creates a new D-Bus server that listens on the first address in
/@address@/ that works.

Once constructed, you can use 'GI.Gio.Objects.DBusServer.dBusServerGetClientAddress' to
get a D-Bus address string that clients can use to connect.

To have control over the available authentication mechanisms and
the users that are authorized to connect, it is strongly recommended
to provide a non-'Nothing' 'GI.Gio.Objects.DBusAuthObserver.DBusAuthObserver'.

Connect to the 'GI.Gio.Objects.DBusServer.DBusServer'::@/new-connection/@ signal to handle
incoming connections.

The returned 'GI.Gio.Objects.DBusServer.DBusServer' isn\'t active - you have to start it with
'GI.Gio.Objects.DBusServer.dBusServerStart'.

'GI.Gio.Objects.DBusServer.DBusServer' is used in this [example][gdbus-peer-to-peer].

This is a synchronous failable constructor. There is currently no
asynchronous version.

/Since: 2.26/
-}
dBusServerNewSync ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.DBusAuthObserver.IsDBusAuthObserver a, Gio.Cancellable.IsCancellable b) =>
    T.Text
    {- ^ /@address@/: A D-Bus address. -}
    -> [Gio.Flags.DBusServerFlags]
    {- ^ /@flags@/: Flags from the 'GI.Gio.Flags.DBusServerFlags' enumeration. -}
    -> T.Text
    {- ^ /@guid@/: A D-Bus GUID. -}
    -> Maybe (a)
    {- ^ /@observer@/: A 'GI.Gio.Objects.DBusAuthObserver.DBusAuthObserver' or 'Nothing'. -}
    -> Maybe (b)
    {- ^ /@cancellable@/: A 'GI.Gio.Objects.Cancellable.Cancellable' or 'Nothing'. -}
    -> m DBusServer
    {- ^ __Returns:__ A 'GI.Gio.Objects.DBusServer.DBusServer' or 'Nothing' if /@error@/ is set. Free with
'GI.GObject.Objects.Object.objectUnref'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
dBusServerNewSync :: Text
-> [DBusServerFlags] -> Text -> Maybe a -> Maybe b -> m DBusServer
dBusServerNewSync address :: Text
address flags :: [DBusServerFlags]
flags guid :: Text
guid observer :: Maybe a
observer cancellable :: Maybe b
cancellable = IO DBusServer -> m DBusServer
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO DBusServer -> m DBusServer) -> IO DBusServer -> m DBusServer
forall a b. (a -> b) -> a -> b
$ do
    CString
address' <- Text -> IO CString
textToCString Text
address
    let flags' :: CUInt
flags' = [DBusServerFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [DBusServerFlags]
flags
    CString
guid' <- Text -> IO CString
textToCString Text
guid
    Ptr DBusAuthObserver
maybeObserver <- case Maybe a
observer of
        Nothing -> Ptr DBusAuthObserver -> IO (Ptr DBusAuthObserver)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr DBusAuthObserver
forall a. Ptr a
nullPtr
        Just jObserver :: a
jObserver -> do
            Ptr DBusAuthObserver
jObserver' <- a -> IO (Ptr DBusAuthObserver)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jObserver
            Ptr DBusAuthObserver -> IO (Ptr DBusAuthObserver)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr DBusAuthObserver
jObserver'
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just jCancellable :: b
jCancellable -> do
            Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    IO DBusServer -> IO () -> IO DBusServer
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr DBusServer
result <- (Ptr (Ptr GError) -> IO (Ptr DBusServer)) -> IO (Ptr DBusServer)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr DBusServer)) -> IO (Ptr DBusServer))
-> (Ptr (Ptr GError) -> IO (Ptr DBusServer)) -> IO (Ptr DBusServer)
forall a b. (a -> b) -> a -> b
$ CString
-> CUInt
-> CString
-> Ptr DBusAuthObserver
-> Ptr Cancellable
-> Ptr (Ptr GError)
-> IO (Ptr DBusServer)
g_dbus_server_new_sync CString
address' CUInt
flags' CString
guid' Ptr DBusAuthObserver
maybeObserver Ptr Cancellable
maybeCancellable
        Text -> Ptr DBusServer -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "dBusServerNewSync" Ptr DBusServer
result
        DBusServer
result' <- ((ManagedPtr DBusServer -> DBusServer)
-> Ptr DBusServer -> IO DBusServer
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr DBusServer -> DBusServer
DBusServer) Ptr DBusServer
result
        Maybe a -> (a -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe a
observer a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
address'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
guid'
        DBusServer -> IO DBusServer
forall (m :: * -> *) a. Monad m => a -> m a
return DBusServer
result'
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
address'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
guid'
     )

#if ENABLE_OVERLOADING
#endif

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

foreign import ccall "g_dbus_server_get_client_address" g_dbus_server_get_client_address :: 
    Ptr DBusServer ->                       -- server : TInterface (Name {namespace = "Gio", name = "DBusServer"})
    IO CString

{- |
Gets a
<https://dbus.freedesktop.org/doc/dbus-specification.html#addresses D-Bus address>
string that can be used by clients to connect to /@server@/.

/Since: 2.26/
-}
dBusServerGetClientAddress ::
    (B.CallStack.HasCallStack, MonadIO m, IsDBusServer a) =>
    a
    {- ^ /@server@/: A 'GI.Gio.Objects.DBusServer.DBusServer'. -}
    -> m T.Text
    {- ^ __Returns:__ A D-Bus address string. Do not free, the string is owned
by /@server@/. -}
dBusServerGetClientAddress :: a -> m Text
dBusServerGetClientAddress server :: a
server = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    Ptr DBusServer
server' <- a -> IO (Ptr DBusServer)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
server
    CString
result <- Ptr DBusServer -> IO CString
g_dbus_server_get_client_address Ptr DBusServer
server'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "dBusServerGetClientAddress" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
server
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'

#if ENABLE_OVERLOADING
data DBusServerGetClientAddressMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsDBusServer a) => O.MethodInfo DBusServerGetClientAddressMethodInfo a signature where
    overloadedMethod _ = dBusServerGetClientAddress

#endif

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

foreign import ccall "g_dbus_server_get_flags" g_dbus_server_get_flags :: 
    Ptr DBusServer ->                       -- server : TInterface (Name {namespace = "Gio", name = "DBusServer"})
    IO CUInt

{- |
Gets the flags for /@server@/.

/Since: 2.26/
-}
dBusServerGetFlags ::
    (B.CallStack.HasCallStack, MonadIO m, IsDBusServer a) =>
    a
    {- ^ /@server@/: A 'GI.Gio.Objects.DBusServer.DBusServer'. -}
    -> m [Gio.Flags.DBusServerFlags]
    {- ^ __Returns:__ A set of flags from the 'GI.Gio.Flags.DBusServerFlags' enumeration. -}
dBusServerGetFlags :: a -> m [DBusServerFlags]
dBusServerGetFlags server :: a
server = IO [DBusServerFlags] -> m [DBusServerFlags]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [DBusServerFlags] -> m [DBusServerFlags])
-> IO [DBusServerFlags] -> m [DBusServerFlags]
forall a b. (a -> b) -> a -> b
$ do
    Ptr DBusServer
server' <- a -> IO (Ptr DBusServer)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
server
    CUInt
result <- Ptr DBusServer -> IO CUInt
g_dbus_server_get_flags Ptr DBusServer
server'
    let result' :: [DBusServerFlags]
result' = CUInt -> [DBusServerFlags]
forall a b. (Storable a, Integral a, Bits a, IsGFlag b) => a -> [b]
wordToGFlags CUInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
server
    [DBusServerFlags] -> IO [DBusServerFlags]
forall (m :: * -> *) a. Monad m => a -> m a
return [DBusServerFlags]
result'

#if ENABLE_OVERLOADING
data DBusServerGetFlagsMethodInfo
instance (signature ~ (m [Gio.Flags.DBusServerFlags]), MonadIO m, IsDBusServer a) => O.MethodInfo DBusServerGetFlagsMethodInfo a signature where
    overloadedMethod _ = dBusServerGetFlags

#endif

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

foreign import ccall "g_dbus_server_get_guid" g_dbus_server_get_guid :: 
    Ptr DBusServer ->                       -- server : TInterface (Name {namespace = "Gio", name = "DBusServer"})
    IO CString

{- |
Gets the GUID for /@server@/.

/Since: 2.26/
-}
dBusServerGetGuid ::
    (B.CallStack.HasCallStack, MonadIO m, IsDBusServer a) =>
    a
    {- ^ /@server@/: A 'GI.Gio.Objects.DBusServer.DBusServer'. -}
    -> m T.Text
    {- ^ __Returns:__ A D-Bus GUID. Do not free this string, it is owned by /@server@/. -}
dBusServerGetGuid :: a -> m Text
dBusServerGetGuid server :: a
server = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    Ptr DBusServer
server' <- a -> IO (Ptr DBusServer)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
server
    CString
result <- Ptr DBusServer -> IO CString
g_dbus_server_get_guid Ptr DBusServer
server'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "dBusServerGetGuid" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
server
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'

#if ENABLE_OVERLOADING
data DBusServerGetGuidMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsDBusServer a) => O.MethodInfo DBusServerGetGuidMethodInfo a signature where
    overloadedMethod _ = dBusServerGetGuid

#endif

-- method DBusServer::is_active
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "server", argType = TInterface (Name {namespace = "Gio", name = "DBusServer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GDBusServer.", 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_server_is_active" g_dbus_server_is_active :: 
    Ptr DBusServer ->                       -- server : TInterface (Name {namespace = "Gio", name = "DBusServer"})
    IO CInt

{- |
Gets whether /@server@/ is active.

/Since: 2.26/
-}
dBusServerIsActive ::
    (B.CallStack.HasCallStack, MonadIO m, IsDBusServer a) =>
    a
    {- ^ /@server@/: A 'GI.Gio.Objects.DBusServer.DBusServer'. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if server is active, 'False' otherwise. -}
dBusServerIsActive :: a -> m Bool
dBusServerIsActive server :: a
server = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr DBusServer
server' <- a -> IO (Ptr DBusServer)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
server
    CInt
result <- Ptr DBusServer -> IO CInt
g_dbus_server_is_active Ptr DBusServer
server'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
server
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if ENABLE_OVERLOADING
data DBusServerIsActiveMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsDBusServer a) => O.MethodInfo DBusServerIsActiveMethodInfo a signature where
    overloadedMethod _ = dBusServerIsActive

#endif

-- method DBusServer::start
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "server", argType = TInterface (Name {namespace = "Gio", name = "DBusServer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GDBusServer.", 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_server_start" g_dbus_server_start :: 
    Ptr DBusServer ->                       -- server : TInterface (Name {namespace = "Gio", name = "DBusServer"})
    IO ()

{- |
Starts /@server@/.

/Since: 2.26/
-}
dBusServerStart ::
    (B.CallStack.HasCallStack, MonadIO m, IsDBusServer a) =>
    a
    {- ^ /@server@/: A 'GI.Gio.Objects.DBusServer.DBusServer'. -}
    -> m ()
dBusServerStart :: a -> m ()
dBusServerStart server :: a
server = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr DBusServer
server' <- a -> IO (Ptr DBusServer)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
server
    Ptr DBusServer -> IO ()
g_dbus_server_start Ptr DBusServer
server'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
server
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if ENABLE_OVERLOADING
data DBusServerStartMethodInfo
instance (signature ~ (m ()), MonadIO m, IsDBusServer a) => O.MethodInfo DBusServerStartMethodInfo a signature where
    overloadedMethod _ = dBusServerStart

#endif

-- method DBusServer::stop
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "server", argType = TInterface (Name {namespace = "Gio", name = "DBusServer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GDBusServer.", 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_server_stop" g_dbus_server_stop :: 
    Ptr DBusServer ->                       -- server : TInterface (Name {namespace = "Gio", name = "DBusServer"})
    IO ()

{- |
Stops /@server@/.

/Since: 2.26/
-}
dBusServerStop ::
    (B.CallStack.HasCallStack, MonadIO m, IsDBusServer a) =>
    a
    {- ^ /@server@/: A 'GI.Gio.Objects.DBusServer.DBusServer'. -}
    -> m ()
dBusServerStop :: a -> m ()
dBusServerStop server :: a
server = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr DBusServer
server' <- a -> IO (Ptr DBusServer)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
server
    Ptr DBusServer -> IO ()
g_dbus_server_stop Ptr DBusServer
server'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
server
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if ENABLE_OVERLOADING
data DBusServerStopMethodInfo
instance (signature ~ (m ()), MonadIO m, IsDBusServer a) => O.MethodInfo DBusServerStopMethodInfo a signature where
    overloadedMethod _ = dBusServerStop

#endif