{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- The t'GI.Gio.Objects.DBusAuthObserver.DBusAuthObserver' type provides a mechanism for participating
-- in how a t'GI.Gio.Objects.DBusServer.DBusServer' (or a t'GI.Gio.Objects.DBusConnection.DBusConnection') authenticates remote
-- peers. Simply instantiate a t'GI.Gio.Objects.DBusAuthObserver.DBusAuthObserver' and connect to the
-- signals you are interested in. Note that new signals may be added
-- in the future
-- 
-- == Controlling Authentication Mechanisms
-- 
-- By default, a t'GI.Gio.Objects.DBusServer.DBusServer' or server-side t'GI.Gio.Objects.DBusConnection.DBusConnection' will allow
-- any authentication mechanism to be used. If you only
-- want to allow D-Bus connections with the @EXTERNAL@ mechanism,
-- which makes use of credentials passing and is the recommended
-- mechanism for modern Unix platforms such as Linux and the BSD family,
-- you would use a signal handler like this:
-- 
-- 
-- === /C code/
-- >
-- >static gboolean
-- >on_allow_mechanism (GDBusAuthObserver *observer,
-- >                    const gchar       *mechanism,
-- >                    gpointer           user_data)
-- >{
-- >  if (g_strcmp0 (mechanism, "EXTERNAL") == 0)
-- >    {
-- >      return TRUE;
-- >    }
-- >
-- >  return FALSE;
-- >}
-- 
-- 
-- ## Controlling Authorization # {@/auth/@-observer}
-- 
-- By default, a t'GI.Gio.Objects.DBusServer.DBusServer' or server-side t'GI.Gio.Objects.DBusConnection.DBusConnection' will accept
-- connections from any successfully authenticated user (but not from
-- anonymous connections using the @ANONYMOUS@ mechanism). If you only
-- want to allow D-Bus connections from processes owned by the same uid
-- as the server, you would use a signal handler like the following:
-- 
-- 
-- === /C code/
-- >
-- >static gboolean
-- >on_authorize_authenticated_peer (GDBusAuthObserver *observer,
-- >                                 GIOStream         *stream,
-- >                                 GCredentials      *credentials,
-- >                                 gpointer           user_data)
-- >{
-- >  gboolean authorized;
-- >
-- >  authorized = FALSE;
-- >  if (credentials != NULL)
-- >    {
-- >      GCredentials *own_credentials;
-- >      own_credentials = g_credentials_new ();
-- >      if (g_credentials_is_same_user (credentials, own_credentials, NULL))
-- >        authorized = TRUE;
-- >      g_object_unref (own_credentials);
-- >    }
-- >
-- >  return authorized;
-- >}
-- 
-- 
-- /Since: 2.26/

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

module GI.Gio.Objects.DBusAuthObserver
    ( 

-- * Exported types
    DBusAuthObserver(..)                    ,
    IsDBusAuthObserver                      ,
    toDBusAuthObserver                      ,


 -- * Methods
-- ** Overloaded methods #method:Overloaded methods#

#if defined(ENABLE_OVERLOADING)
    ResolveDBusAuthObserverMethod           ,
#endif


-- ** allowMechanism #method:allowMechanism#

#if defined(ENABLE_OVERLOADING)
    DBusAuthObserverAllowMechanismMethodInfo,
#endif
    dBusAuthObserverAllowMechanism          ,


-- ** authorizeAuthenticatedPeer #method:authorizeAuthenticatedPeer#

#if defined(ENABLE_OVERLOADING)
    DBusAuthObserverAuthorizeAuthenticatedPeerMethodInfo,
#endif
    dBusAuthObserverAuthorizeAuthenticatedPeer,


-- ** new #method:new#

    dBusAuthObserverNew                     ,




 -- * Signals
-- ** allowMechanism #signal:allowMechanism#

    C_DBusAuthObserverAllowMechanismCallback,
    DBusAuthObserverAllowMechanismCallback  ,
#if defined(ENABLE_OVERLOADING)
    DBusAuthObserverAllowMechanismSignalInfo,
#endif
    afterDBusAuthObserverAllowMechanism     ,
    genClosure_DBusAuthObserverAllowMechanism,
    mk_DBusAuthObserverAllowMechanismCallback,
    noDBusAuthObserverAllowMechanismCallback,
    onDBusAuthObserverAllowMechanism        ,
    wrap_DBusAuthObserverAllowMechanismCallback,


-- ** authorizeAuthenticatedPeer #signal:authorizeAuthenticatedPeer#

    C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback,
    DBusAuthObserverAuthorizeAuthenticatedPeerCallback,
#if defined(ENABLE_OVERLOADING)
    DBusAuthObserverAuthorizeAuthenticatedPeerSignalInfo,
#endif
    afterDBusAuthObserverAuthorizeAuthenticatedPeer,
    genClosure_DBusAuthObserverAuthorizeAuthenticatedPeer,
    mk_DBusAuthObserverAuthorizeAuthenticatedPeerCallback,
    noDBusAuthObserverAuthorizeAuthenticatedPeerCallback,
    onDBusAuthObserverAuthorizeAuthenticatedPeer,
    wrap_DBusAuthObserverAuthorizeAuthenticatedPeerCallback,




    ) 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.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GClosure as B.GClosure
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.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
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 GHC.OverloadedLabels as OL

import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Gio.Objects.Credentials as Gio.Credentials
import {-# SOURCE #-} qualified GI.Gio.Objects.IOStream as Gio.IOStream

-- | Memory-managed wrapper type.
newtype DBusAuthObserver = DBusAuthObserver (SP.ManagedPtr DBusAuthObserver)
    deriving (DBusAuthObserver -> DBusAuthObserver -> Bool
(DBusAuthObserver -> DBusAuthObserver -> Bool)
-> (DBusAuthObserver -> DBusAuthObserver -> Bool)
-> Eq DBusAuthObserver
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DBusAuthObserver -> DBusAuthObserver -> Bool
$c/= :: DBusAuthObserver -> DBusAuthObserver -> Bool
== :: DBusAuthObserver -> DBusAuthObserver -> Bool
$c== :: DBusAuthObserver -> DBusAuthObserver -> Bool
Eq)

instance SP.ManagedPtrNewtype DBusAuthObserver where
    toManagedPtr :: DBusAuthObserver -> ManagedPtr DBusAuthObserver
toManagedPtr (DBusAuthObserver ManagedPtr DBusAuthObserver
p) = ManagedPtr DBusAuthObserver
p

foreign import ccall "g_dbus_auth_observer_get_type"
    c_g_dbus_auth_observer_get_type :: IO B.Types.GType

instance B.Types.TypedObject DBusAuthObserver where
    glibType :: IO GType
glibType = IO GType
c_g_dbus_auth_observer_get_type

instance B.Types.GObject DBusAuthObserver

-- | Convert 'DBusAuthObserver' to and from 'Data.GI.Base.GValue.GValue' with 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue DBusAuthObserver where
    toGValue :: DBusAuthObserver -> IO GValue
toGValue DBusAuthObserver
o = do
        GType
gtype <- IO GType
c_g_dbus_auth_observer_get_type
        DBusAuthObserver
-> (Ptr DBusAuthObserver -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr DBusAuthObserver
o (GType
-> (GValue -> Ptr DBusAuthObserver -> IO ())
-> Ptr DBusAuthObserver
-> IO GValue
forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
B.GValue.buildGValue GType
gtype GValue -> Ptr DBusAuthObserver -> IO ()
forall a. GObject a => GValue -> Ptr a -> IO ()
B.GValue.set_object)
        
    fromGValue :: GValue -> IO DBusAuthObserver
fromGValue GValue
gv = do
        Ptr DBusAuthObserver
ptr <- GValue -> IO (Ptr DBusAuthObserver)
forall b. GObject b => GValue -> IO (Ptr b)
B.GValue.get_object GValue
gv :: IO (Ptr DBusAuthObserver)
        (ManagedPtr DBusAuthObserver -> DBusAuthObserver)
-> Ptr DBusAuthObserver -> IO DBusAuthObserver
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
B.ManagedPtr.newObject ManagedPtr DBusAuthObserver -> DBusAuthObserver
DBusAuthObserver Ptr DBusAuthObserver
ptr
        
    

-- | Type class for types which can be safely cast to `DBusAuthObserver`, for instance with `toDBusAuthObserver`.
class (SP.GObject o, O.IsDescendantOf DBusAuthObserver o) => IsDBusAuthObserver o
instance (SP.GObject o, O.IsDescendantOf DBusAuthObserver o) => IsDBusAuthObserver o

instance O.HasParentTypes DBusAuthObserver
type instance O.ParentTypes DBusAuthObserver = '[GObject.Object.Object]

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

#if defined(ENABLE_OVERLOADING)
type family ResolveDBusAuthObserverMethod (t :: Symbol) (o :: *) :: * where
    ResolveDBusAuthObserverMethod "allowMechanism" o = DBusAuthObserverAllowMechanismMethodInfo
    ResolveDBusAuthObserverMethod "authorizeAuthenticatedPeer" o = DBusAuthObserverAuthorizeAuthenticatedPeerMethodInfo
    ResolveDBusAuthObserverMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveDBusAuthObserverMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveDBusAuthObserverMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveDBusAuthObserverMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveDBusAuthObserverMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveDBusAuthObserverMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveDBusAuthObserverMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveDBusAuthObserverMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveDBusAuthObserverMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveDBusAuthObserverMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveDBusAuthObserverMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveDBusAuthObserverMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveDBusAuthObserverMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveDBusAuthObserverMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveDBusAuthObserverMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveDBusAuthObserverMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveDBusAuthObserverMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveDBusAuthObserverMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveDBusAuthObserverMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveDBusAuthObserverMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveDBusAuthObserverMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveDBusAuthObserverMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveDBusAuthObserverMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveDBusAuthObserverMethod t DBusAuthObserver, O.MethodInfo info DBusAuthObserver p) => OL.IsLabel t (DBusAuthObserver -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod @info
#else
    fromLabel _ = O.overloadedMethod @info
#endif

#endif

-- signal DBusAuthObserver::allow-mechanism
-- | Emitted to check if /@mechanism@/ is allowed to be used.
-- 
-- /Since: 2.34/
type DBusAuthObserverAllowMechanismCallback =
    T.Text
    -- ^ /@mechanism@/: The name of the mechanism, e.g. @DBUS_COOKIE_SHA1@.
    -> IO Bool
    -- ^ __Returns:__ 'P.True' if /@mechanism@/ can be used to authenticate the other peer, 'P.False' if not.

-- | A convenience synonym for @`Nothing` :: `Maybe` `DBusAuthObserverAllowMechanismCallback`@.
noDBusAuthObserverAllowMechanismCallback :: Maybe DBusAuthObserverAllowMechanismCallback
noDBusAuthObserverAllowMechanismCallback :: Maybe DBusAuthObserverAllowMechanismCallback
noDBusAuthObserverAllowMechanismCallback = Maybe DBusAuthObserverAllowMechanismCallback
forall a. Maybe a
Nothing

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

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

-- | Wrap the callback into a `GClosure`.
genClosure_DBusAuthObserverAllowMechanism :: MonadIO m => DBusAuthObserverAllowMechanismCallback -> m (GClosure C_DBusAuthObserverAllowMechanismCallback)
genClosure_DBusAuthObserverAllowMechanism :: DBusAuthObserverAllowMechanismCallback
-> m (GClosure C_DBusAuthObserverAllowMechanismCallback)
genClosure_DBusAuthObserverAllowMechanism DBusAuthObserverAllowMechanismCallback
cb = IO (GClosure C_DBusAuthObserverAllowMechanismCallback)
-> m (GClosure C_DBusAuthObserverAllowMechanismCallback)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (GClosure C_DBusAuthObserverAllowMechanismCallback)
 -> m (GClosure C_DBusAuthObserverAllowMechanismCallback))
-> IO (GClosure C_DBusAuthObserverAllowMechanismCallback)
-> m (GClosure C_DBusAuthObserverAllowMechanismCallback)
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_DBusAuthObserverAllowMechanismCallback
cb' = DBusAuthObserverAllowMechanismCallback
-> C_DBusAuthObserverAllowMechanismCallback
wrap_DBusAuthObserverAllowMechanismCallback DBusAuthObserverAllowMechanismCallback
cb
    C_DBusAuthObserverAllowMechanismCallback
-> IO (FunPtr C_DBusAuthObserverAllowMechanismCallback)
mk_DBusAuthObserverAllowMechanismCallback C_DBusAuthObserverAllowMechanismCallback
cb' IO (FunPtr C_DBusAuthObserverAllowMechanismCallback)
-> (FunPtr C_DBusAuthObserverAllowMechanismCallback
    -> IO (GClosure C_DBusAuthObserverAllowMechanismCallback))
-> IO (GClosure C_DBusAuthObserverAllowMechanismCallback)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= FunPtr C_DBusAuthObserverAllowMechanismCallback
-> IO (GClosure C_DBusAuthObserverAllowMechanismCallback)
forall (m :: * -> *) a. MonadIO m => FunPtr a -> m (GClosure a)
B.GClosure.newGClosure


-- | Wrap a `DBusAuthObserverAllowMechanismCallback` into a `C_DBusAuthObserverAllowMechanismCallback`.
wrap_DBusAuthObserverAllowMechanismCallback ::
    DBusAuthObserverAllowMechanismCallback ->
    C_DBusAuthObserverAllowMechanismCallback
wrap_DBusAuthObserverAllowMechanismCallback :: DBusAuthObserverAllowMechanismCallback
-> C_DBusAuthObserverAllowMechanismCallback
wrap_DBusAuthObserverAllowMechanismCallback DBusAuthObserverAllowMechanismCallback
_cb Ptr ()
_ CString
mechanism Ptr ()
_ = do
    Text
mechanism' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
mechanism
    Bool
result <- DBusAuthObserverAllowMechanismCallback
_cb  Text
mechanism'
    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 [allowMechanism](#signal:allowMechanism) 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' dBusAuthObserver #allowMechanism callback
-- @
-- 
-- 
onDBusAuthObserverAllowMechanism :: (IsDBusAuthObserver a, MonadIO m) => a -> DBusAuthObserverAllowMechanismCallback -> m SignalHandlerId
onDBusAuthObserverAllowMechanism :: a -> DBusAuthObserverAllowMechanismCallback -> m SignalHandlerId
onDBusAuthObserverAllowMechanism a
obj DBusAuthObserverAllowMechanismCallback
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_DBusAuthObserverAllowMechanismCallback
cb' = DBusAuthObserverAllowMechanismCallback
-> C_DBusAuthObserverAllowMechanismCallback
wrap_DBusAuthObserverAllowMechanismCallback DBusAuthObserverAllowMechanismCallback
cb
    FunPtr C_DBusAuthObserverAllowMechanismCallback
cb'' <- C_DBusAuthObserverAllowMechanismCallback
-> IO (FunPtr C_DBusAuthObserverAllowMechanismCallback)
mk_DBusAuthObserverAllowMechanismCallback C_DBusAuthObserverAllowMechanismCallback
cb'
    a
-> Text
-> FunPtr C_DBusAuthObserverAllowMechanismCallback
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
forall o a.
GObject o =>
o
-> Text
-> FunPtr a
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
connectSignalFunPtr a
obj Text
"allow-mechanism" FunPtr C_DBusAuthObserverAllowMechanismCallback
cb'' SignalConnectMode
SignalConnectBefore Maybe Text
forall a. Maybe a
Nothing

-- | Connect a signal handler for the [allowMechanism](#signal:allowMechanism) 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' dBusAuthObserver #allowMechanism callback
-- @
-- 
-- 
afterDBusAuthObserverAllowMechanism :: (IsDBusAuthObserver a, MonadIO m) => a -> DBusAuthObserverAllowMechanismCallback -> m SignalHandlerId
afterDBusAuthObserverAllowMechanism :: a -> DBusAuthObserverAllowMechanismCallback -> m SignalHandlerId
afterDBusAuthObserverAllowMechanism a
obj DBusAuthObserverAllowMechanismCallback
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_DBusAuthObserverAllowMechanismCallback
cb' = DBusAuthObserverAllowMechanismCallback
-> C_DBusAuthObserverAllowMechanismCallback
wrap_DBusAuthObserverAllowMechanismCallback DBusAuthObserverAllowMechanismCallback
cb
    FunPtr C_DBusAuthObserverAllowMechanismCallback
cb'' <- C_DBusAuthObserverAllowMechanismCallback
-> IO (FunPtr C_DBusAuthObserverAllowMechanismCallback)
mk_DBusAuthObserverAllowMechanismCallback C_DBusAuthObserverAllowMechanismCallback
cb'
    a
-> Text
-> FunPtr C_DBusAuthObserverAllowMechanismCallback
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
forall o a.
GObject o =>
o
-> Text
-> FunPtr a
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
connectSignalFunPtr a
obj Text
"allow-mechanism" FunPtr C_DBusAuthObserverAllowMechanismCallback
cb'' SignalConnectMode
SignalConnectAfter Maybe Text
forall a. Maybe a
Nothing


#if defined(ENABLE_OVERLOADING)
data DBusAuthObserverAllowMechanismSignalInfo
instance SignalInfo DBusAuthObserverAllowMechanismSignalInfo where
    type HaskellCallbackType DBusAuthObserverAllowMechanismSignalInfo = DBusAuthObserverAllowMechanismCallback
    connectSignal obj cb connectMode detail = do
        let cb' = wrap_DBusAuthObserverAllowMechanismCallback cb
        cb'' <- mk_DBusAuthObserverAllowMechanismCallback cb'
        connectSignalFunPtr obj "allow-mechanism" cb'' connectMode detail

#endif

-- signal DBusAuthObserver::authorize-authenticated-peer
-- | Emitted to check if a peer that is successfully authenticated
-- is authorized.
-- 
-- /Since: 2.26/
type DBusAuthObserverAuthorizeAuthenticatedPeerCallback =
    Gio.IOStream.IOStream
    -- ^ /@stream@/: A t'GI.Gio.Objects.IOStream.IOStream' for the t'GI.Gio.Objects.DBusConnection.DBusConnection'.
    -> Maybe Gio.Credentials.Credentials
    -- ^ /@credentials@/: Credentials received from the peer or 'P.Nothing'.
    -> IO Bool
    -- ^ __Returns:__ 'P.True' if the peer is authorized, 'P.False' if not.

-- | A convenience synonym for @`Nothing` :: `Maybe` `DBusAuthObserverAuthorizeAuthenticatedPeerCallback`@.
noDBusAuthObserverAuthorizeAuthenticatedPeerCallback :: Maybe DBusAuthObserverAuthorizeAuthenticatedPeerCallback
noDBusAuthObserverAuthorizeAuthenticatedPeerCallback :: Maybe DBusAuthObserverAuthorizeAuthenticatedPeerCallback
noDBusAuthObserverAuthorizeAuthenticatedPeerCallback = Maybe DBusAuthObserverAuthorizeAuthenticatedPeerCallback
forall a. Maybe a
Nothing

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

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

-- | Wrap the callback into a `GClosure`.
genClosure_DBusAuthObserverAuthorizeAuthenticatedPeer :: MonadIO m => DBusAuthObserverAuthorizeAuthenticatedPeerCallback -> m (GClosure C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback)
genClosure_DBusAuthObserverAuthorizeAuthenticatedPeer :: DBusAuthObserverAuthorizeAuthenticatedPeerCallback
-> m (GClosure
        C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback)
genClosure_DBusAuthObserverAuthorizeAuthenticatedPeer DBusAuthObserverAuthorizeAuthenticatedPeerCallback
cb = IO (GClosure C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback)
-> m (GClosure
        C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (GClosure C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback)
 -> m (GClosure
         C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback))
-> IO
     (GClosure C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback)
-> m (GClosure
        C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback)
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback
cb' = DBusAuthObserverAuthorizeAuthenticatedPeerCallback
-> C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback
wrap_DBusAuthObserverAuthorizeAuthenticatedPeerCallback DBusAuthObserverAuthorizeAuthenticatedPeerCallback
cb
    C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback
-> IO (FunPtr C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback)
mk_DBusAuthObserverAuthorizeAuthenticatedPeerCallback C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback
cb' IO (FunPtr C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback)
-> (FunPtr C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback
    -> IO
         (GClosure C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback))
-> IO
     (GClosure C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= FunPtr C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback
-> IO
     (GClosure C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback)
forall (m :: * -> *) a. MonadIO m => FunPtr a -> m (GClosure a)
B.GClosure.newGClosure


-- | Wrap a `DBusAuthObserverAuthorizeAuthenticatedPeerCallback` into a `C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback`.
wrap_DBusAuthObserverAuthorizeAuthenticatedPeerCallback ::
    DBusAuthObserverAuthorizeAuthenticatedPeerCallback ->
    C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback
wrap_DBusAuthObserverAuthorizeAuthenticatedPeerCallback :: DBusAuthObserverAuthorizeAuthenticatedPeerCallback
-> C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback
wrap_DBusAuthObserverAuthorizeAuthenticatedPeerCallback DBusAuthObserverAuthorizeAuthenticatedPeerCallback
_cb Ptr ()
_ Ptr IOStream
stream Ptr Credentials
credentials Ptr ()
_ = do
    IOStream
stream' <- ((ManagedPtr IOStream -> IOStream) -> Ptr IOStream -> IO IOStream
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr IOStream -> IOStream
Gio.IOStream.IOStream) Ptr IOStream
stream
    Maybe Credentials
maybeCredentials <-
        if Ptr Credentials
credentials Ptr Credentials -> Ptr Credentials -> Bool
forall a. Eq a => a -> a -> Bool
== Ptr Credentials
forall a. Ptr a
nullPtr
        then Maybe Credentials -> IO (Maybe Credentials)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Credentials
forall a. Maybe a
Nothing
        else do
            Credentials
credentials' <- ((ManagedPtr Credentials -> Credentials)
-> Ptr Credentials -> IO Credentials
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr Credentials -> Credentials
Gio.Credentials.Credentials) Ptr Credentials
credentials
            Maybe Credentials -> IO (Maybe Credentials)
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe Credentials -> IO (Maybe Credentials))
-> Maybe Credentials -> IO (Maybe Credentials)
forall a b. (a -> b) -> a -> b
$ Credentials -> Maybe Credentials
forall a. a -> Maybe a
Just Credentials
credentials'
    Bool
result <- DBusAuthObserverAuthorizeAuthenticatedPeerCallback
_cb  IOStream
stream' Maybe Credentials
maybeCredentials
    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 [authorizeAuthenticatedPeer](#signal:authorizeAuthenticatedPeer) 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' dBusAuthObserver #authorizeAuthenticatedPeer callback
-- @
-- 
-- 
onDBusAuthObserverAuthorizeAuthenticatedPeer :: (IsDBusAuthObserver a, MonadIO m) => a -> DBusAuthObserverAuthorizeAuthenticatedPeerCallback -> m SignalHandlerId
onDBusAuthObserverAuthorizeAuthenticatedPeer :: a
-> DBusAuthObserverAuthorizeAuthenticatedPeerCallback
-> m SignalHandlerId
onDBusAuthObserverAuthorizeAuthenticatedPeer a
obj DBusAuthObserverAuthorizeAuthenticatedPeerCallback
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_DBusAuthObserverAuthorizeAuthenticatedPeerCallback
cb' = DBusAuthObserverAuthorizeAuthenticatedPeerCallback
-> C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback
wrap_DBusAuthObserverAuthorizeAuthenticatedPeerCallback DBusAuthObserverAuthorizeAuthenticatedPeerCallback
cb
    FunPtr C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback
cb'' <- C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback
-> IO (FunPtr C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback)
mk_DBusAuthObserverAuthorizeAuthenticatedPeerCallback C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback
cb'
    a
-> Text
-> FunPtr C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
forall o a.
GObject o =>
o
-> Text
-> FunPtr a
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
connectSignalFunPtr a
obj Text
"authorize-authenticated-peer" FunPtr C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback
cb'' SignalConnectMode
SignalConnectBefore Maybe Text
forall a. Maybe a
Nothing

-- | Connect a signal handler for the [authorizeAuthenticatedPeer](#signal:authorizeAuthenticatedPeer) 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' dBusAuthObserver #authorizeAuthenticatedPeer callback
-- @
-- 
-- 
afterDBusAuthObserverAuthorizeAuthenticatedPeer :: (IsDBusAuthObserver a, MonadIO m) => a -> DBusAuthObserverAuthorizeAuthenticatedPeerCallback -> m SignalHandlerId
afterDBusAuthObserverAuthorizeAuthenticatedPeer :: a
-> DBusAuthObserverAuthorizeAuthenticatedPeerCallback
-> m SignalHandlerId
afterDBusAuthObserverAuthorizeAuthenticatedPeer a
obj DBusAuthObserverAuthorizeAuthenticatedPeerCallback
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_DBusAuthObserverAuthorizeAuthenticatedPeerCallback
cb' = DBusAuthObserverAuthorizeAuthenticatedPeerCallback
-> C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback
wrap_DBusAuthObserverAuthorizeAuthenticatedPeerCallback DBusAuthObserverAuthorizeAuthenticatedPeerCallback
cb
    FunPtr C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback
cb'' <- C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback
-> IO (FunPtr C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback)
mk_DBusAuthObserverAuthorizeAuthenticatedPeerCallback C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback
cb'
    a
-> Text
-> FunPtr C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
forall o a.
GObject o =>
o
-> Text
-> FunPtr a
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
connectSignalFunPtr a
obj Text
"authorize-authenticated-peer" FunPtr C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback
cb'' SignalConnectMode
SignalConnectAfter Maybe Text
forall a. Maybe a
Nothing


#if defined(ENABLE_OVERLOADING)
data DBusAuthObserverAuthorizeAuthenticatedPeerSignalInfo
instance SignalInfo DBusAuthObserverAuthorizeAuthenticatedPeerSignalInfo where
    type HaskellCallbackType DBusAuthObserverAuthorizeAuthenticatedPeerSignalInfo = DBusAuthObserverAuthorizeAuthenticatedPeerCallback
    connectSignal obj cb connectMode detail = do
        let cb' = wrap_DBusAuthObserverAuthorizeAuthenticatedPeerCallback cb
        cb'' <- mk_DBusAuthObserverAuthorizeAuthenticatedPeerCallback cb'
        connectSignalFunPtr obj "authorize-authenticated-peer" cb'' connectMode detail

#endif

#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList DBusAuthObserver
type instance O.AttributeList DBusAuthObserver = DBusAuthObserverAttributeList
type DBusAuthObserverAttributeList = ('[ ] :: [(Symbol, *)])
#endif

#if defined(ENABLE_OVERLOADING)
#endif

#if defined(ENABLE_OVERLOADING)
type instance O.SignalList DBusAuthObserver = DBusAuthObserverSignalList
type DBusAuthObserverSignalList = ('[ '("allowMechanism", DBusAuthObserverAllowMechanismSignalInfo), '("authorizeAuthenticatedPeer", DBusAuthObserverAuthorizeAuthenticatedPeerSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

-- method DBusAuthObserver::new
-- method type : Constructor
-- Args: []
-- Lengths: []
-- returnType: Just
--               (TInterface Name { namespace = "Gio" , name = "DBusAuthObserver" })
-- throws : False
-- Skip return : False

foreign import ccall "g_dbus_auth_observer_new" g_dbus_auth_observer_new :: 
    IO (Ptr DBusAuthObserver)

-- | Creates a new t'GI.Gio.Objects.DBusAuthObserver.DBusAuthObserver' object.
-- 
-- /Since: 2.26/
dBusAuthObserverNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m DBusAuthObserver
    -- ^ __Returns:__ A t'GI.Gio.Objects.DBusAuthObserver.DBusAuthObserver'. Free with 'GI.GObject.Objects.Object.objectUnref'.
dBusAuthObserverNew :: m DBusAuthObserver
dBusAuthObserverNew  = IO DBusAuthObserver -> m DBusAuthObserver
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO DBusAuthObserver -> m DBusAuthObserver)
-> IO DBusAuthObserver -> m DBusAuthObserver
forall a b. (a -> b) -> a -> b
$ do
    Ptr DBusAuthObserver
result <- IO (Ptr DBusAuthObserver)
g_dbus_auth_observer_new
    Text -> Ptr DBusAuthObserver -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"dBusAuthObserverNew" Ptr DBusAuthObserver
result
    DBusAuthObserver
result' <- ((ManagedPtr DBusAuthObserver -> DBusAuthObserver)
-> Ptr DBusAuthObserver -> IO DBusAuthObserver
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr DBusAuthObserver -> DBusAuthObserver
DBusAuthObserver) Ptr DBusAuthObserver
result
    DBusAuthObserver -> IO DBusAuthObserver
forall (m :: * -> *) a. Monad m => a -> m a
return DBusAuthObserver
result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method DBusAuthObserver::allow_mechanism
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "observer"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "DBusAuthObserver" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "A #GDBusAuthObserver."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "mechanism"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "The name of the mechanism, e.g. `DBUS_COOKIE_SHA1`."
--                 , 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_auth_observer_allow_mechanism" g_dbus_auth_observer_allow_mechanism :: 
    Ptr DBusAuthObserver ->                 -- observer : TInterface (Name {namespace = "Gio", name = "DBusAuthObserver"})
    CString ->                              -- mechanism : TBasicType TUTF8
    IO CInt

-- | Emits the [allowMechanism]("GI.Gio.Objects.DBusAuthObserver#g:signal:allowMechanism") signal on /@observer@/.
-- 
-- /Since: 2.34/
dBusAuthObserverAllowMechanism ::
    (B.CallStack.HasCallStack, MonadIO m, IsDBusAuthObserver a) =>
    a
    -- ^ /@observer@/: A t'GI.Gio.Objects.DBusAuthObserver.DBusAuthObserver'.
    -> T.Text
    -- ^ /@mechanism@/: The name of the mechanism, e.g. @DBUS_COOKIE_SHA1@.
    -> m Bool
    -- ^ __Returns:__ 'P.True' if /@mechanism@/ can be used to authenticate the other peer, 'P.False' if not.
dBusAuthObserverAllowMechanism :: a -> Text -> m Bool
dBusAuthObserverAllowMechanism a
observer Text
mechanism = 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 DBusAuthObserver
observer' <- a -> IO (Ptr DBusAuthObserver)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
observer
    CString
mechanism' <- Text -> IO CString
textToCString Text
mechanism
    CInt
result <- Ptr DBusAuthObserver -> CString -> IO CInt
g_dbus_auth_observer_allow_mechanism Ptr DBusAuthObserver
observer' CString
mechanism'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
observer
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
mechanism'
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
data DBusAuthObserverAllowMechanismMethodInfo
instance (signature ~ (T.Text -> m Bool), MonadIO m, IsDBusAuthObserver a) => O.MethodInfo DBusAuthObserverAllowMechanismMethodInfo a signature where
    overloadedMethod = dBusAuthObserverAllowMechanism

#endif

-- method DBusAuthObserver::authorize_authenticated_peer
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "observer"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "DBusAuthObserver" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "A #GDBusAuthObserver."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "stream"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "IOStream" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "A #GIOStream for the #GDBusConnection."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "credentials"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "Credentials" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "Credentials received from the peer or %NULL."
--                 , 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_auth_observer_authorize_authenticated_peer" g_dbus_auth_observer_authorize_authenticated_peer :: 
    Ptr DBusAuthObserver ->                 -- observer : TInterface (Name {namespace = "Gio", name = "DBusAuthObserver"})
    Ptr Gio.IOStream.IOStream ->            -- stream : TInterface (Name {namespace = "Gio", name = "IOStream"})
    Ptr Gio.Credentials.Credentials ->      -- credentials : TInterface (Name {namespace = "Gio", name = "Credentials"})
    IO CInt

-- | Emits the [authorizeAuthenticatedPeer]("GI.Gio.Objects.DBusAuthObserver#g:signal:authorizeAuthenticatedPeer") signal on /@observer@/.
-- 
-- /Since: 2.26/
dBusAuthObserverAuthorizeAuthenticatedPeer ::
    (B.CallStack.HasCallStack, MonadIO m, IsDBusAuthObserver a, Gio.IOStream.IsIOStream b, Gio.Credentials.IsCredentials c) =>
    a
    -- ^ /@observer@/: A t'GI.Gio.Objects.DBusAuthObserver.DBusAuthObserver'.
    -> b
    -- ^ /@stream@/: A t'GI.Gio.Objects.IOStream.IOStream' for the t'GI.Gio.Objects.DBusConnection.DBusConnection'.
    -> Maybe (c)
    -- ^ /@credentials@/: Credentials received from the peer or 'P.Nothing'.
    -> m Bool
    -- ^ __Returns:__ 'P.True' if the peer is authorized, 'P.False' if not.
dBusAuthObserverAuthorizeAuthenticatedPeer :: a -> b -> Maybe c -> m Bool
dBusAuthObserverAuthorizeAuthenticatedPeer a
observer b
stream Maybe c
credentials = 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 DBusAuthObserver
observer' <- a -> IO (Ptr DBusAuthObserver)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
observer
    Ptr IOStream
stream' <- b -> IO (Ptr IOStream)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
stream
    Ptr Credentials
maybeCredentials <- case Maybe c
credentials of
        Maybe c
Nothing -> Ptr Credentials -> IO (Ptr Credentials)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Credentials
forall a. Ptr a
nullPtr
        Just c
jCredentials -> do
            Ptr Credentials
jCredentials' <- c -> IO (Ptr Credentials)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr c
jCredentials
            Ptr Credentials -> IO (Ptr Credentials)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Credentials
jCredentials'
    CInt
result <- Ptr DBusAuthObserver -> Ptr IOStream -> Ptr Credentials -> IO CInt
g_dbus_auth_observer_authorize_authenticated_peer Ptr DBusAuthObserver
observer' Ptr IOStream
stream' Ptr Credentials
maybeCredentials
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
observer
    b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
stream
    Maybe c -> (c -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe c
credentials c -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
data DBusAuthObserverAuthorizeAuthenticatedPeerMethodInfo
instance (signature ~ (b -> Maybe (c) -> m Bool), MonadIO m, IsDBusAuthObserver a, Gio.IOStream.IsIOStream b, Gio.Credentials.IsCredentials c) => O.MethodInfo DBusAuthObserverAuthorizeAuthenticatedPeerMethodInfo a signature where
    overloadedMethod = dBusAuthObserverAuthorizeAuthenticatedPeer

#endif