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

The 'GI.Gio.Objects.DBusAuthObserver.DBusAuthObserver' type provides a mechanism for participating
in how a 'GI.Gio.Objects.DBusServer.DBusServer' (or a 'GI.Gio.Objects.DBusConnection.DBusConnection') authenticates remote
peers. Simply instantiate a '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 # {@/auth/@-observer}

For example, 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;
>}

-}

module GI.Gio.Objects.DBusAuthObserver
    ( 

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


 -- * Methods
-- ** allowMechanism #method:allowMechanism#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DBusAuthObserverAllowMechanismMethodInfo,
#endif
    dBusAuthObserverAllowMechanism          ,


-- ** authorizeAuthenticatedPeer #method:authorizeAuthenticatedPeer#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DBusAuthObserverAuthorizeAuthenticatedPeerMethodInfo,
#endif
    dBusAuthObserverAuthorizeAuthenticatedPeer,


-- ** new #method:new#
    dBusAuthObserverNew                     ,




 -- * Signals
-- ** allowMechanism #signal:allowMechanism#
    C_DBusAuthObserverAllowMechanismCallback,
    DBusAuthObserverAllowMechanismCallback  ,
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DBusAuthObserverAllowMechanismSignalInfo,
#endif
    afterDBusAuthObserverAllowMechanism     ,
    genClosure_DBusAuthObserverAllowMechanism,
    mk_DBusAuthObserverAllowMechanismCallback,
    noDBusAuthObserverAllowMechanismCallback,
    onDBusAuthObserverAllowMechanism        ,
    wrap_DBusAuthObserverAllowMechanismCallback,


-- ** authorizeAuthenticatedPeer #signal:authorizeAuthenticatedPeer#
    C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback,
    DBusAuthObserverAuthorizeAuthenticatedPeerCallback,
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    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.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.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.Objects.Credentials as Gio.Credentials
import {-# SOURCE #-} qualified GI.Gio.Objects.IOStream as Gio.IOStream

newtype DBusAuthObserver = DBusAuthObserver (ManagedPtr DBusAuthObserver)
foreign import ccall "g_dbus_auth_observer_get_type"
    c_g_dbus_auth_observer_get_type :: IO GType

instance GObject DBusAuthObserver where
    gobjectType _ = c_g_dbus_auth_observer_get_type
    

class GObject o => IsDBusAuthObserver o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError DBusAuthObserver a) =>
    IsDBusAuthObserver a
#endif
instance IsDBusAuthObserver DBusAuthObserver
instance GObject.Object.IsObject DBusAuthObserver

toDBusAuthObserver :: (MonadIO m, IsDBusAuthObserver o) => o -> m DBusAuthObserver
toDBusAuthObserver = liftIO . unsafeCastTo DBusAuthObserver

noDBusAuthObserver :: Maybe DBusAuthObserver
noDBusAuthObserver = Nothing

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
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 "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 "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveDBusAuthObserverMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    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 "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveDBusAuthObserverMethod l o = O.MethodResolutionFailed l o

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

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveDBusAuthObserverMethod t DBusAuthObserver, O.MethodInfo info DBusAuthObserver p) => O.IsLabel t (DBusAuthObserver -> 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 DBusAuthObserver::allow-mechanism
type DBusAuthObserverAllowMechanismCallback =
    T.Text ->
    IO Bool

noDBusAuthObserverAllowMechanismCallback :: Maybe DBusAuthObserverAllowMechanismCallback
noDBusAuthObserverAllowMechanismCallback = Nothing

type C_DBusAuthObserverAllowMechanismCallback =
    Ptr () ->                               -- object
    CString ->
    Ptr () ->                               -- user_data
    IO CInt

foreign import ccall "wrapper"
    mk_DBusAuthObserverAllowMechanismCallback :: C_DBusAuthObserverAllowMechanismCallback -> IO (FunPtr C_DBusAuthObserverAllowMechanismCallback)

genClosure_DBusAuthObserverAllowMechanism :: DBusAuthObserverAllowMechanismCallback -> IO Closure
genClosure_DBusAuthObserverAllowMechanism cb = do
    let cb' = wrap_DBusAuthObserverAllowMechanismCallback cb
    mk_DBusAuthObserverAllowMechanismCallback cb' >>= newCClosure


wrap_DBusAuthObserverAllowMechanismCallback ::
    DBusAuthObserverAllowMechanismCallback ->
    Ptr () ->
    CString ->
    Ptr () ->
    IO CInt
wrap_DBusAuthObserverAllowMechanismCallback _cb _ mechanism _ = do
    mechanism' <- cstringToText mechanism
    result <- _cb  mechanism'
    let result' = (fromIntegral . fromEnum) result
    return result'


onDBusAuthObserverAllowMechanism :: (IsDBusAuthObserver a, MonadIO m) => a -> DBusAuthObserverAllowMechanismCallback -> m SignalHandlerId
onDBusAuthObserverAllowMechanism obj cb = liftIO $ do
    let cb' = wrap_DBusAuthObserverAllowMechanismCallback cb
    cb'' <- mk_DBusAuthObserverAllowMechanismCallback cb'
    connectSignalFunPtr obj "allow-mechanism" cb'' SignalConnectBefore

afterDBusAuthObserverAllowMechanism :: (IsDBusAuthObserver a, MonadIO m) => a -> DBusAuthObserverAllowMechanismCallback -> m SignalHandlerId
afterDBusAuthObserverAllowMechanism obj cb = liftIO $ do
    let cb' = wrap_DBusAuthObserverAllowMechanismCallback cb
    cb'' <- mk_DBusAuthObserverAllowMechanismCallback cb'
    connectSignalFunPtr obj "allow-mechanism" cb'' SignalConnectAfter


-- signal DBusAuthObserver::authorize-authenticated-peer
type DBusAuthObserverAuthorizeAuthenticatedPeerCallback =
    Gio.IOStream.IOStream ->
    Maybe Gio.Credentials.Credentials ->
    IO Bool

noDBusAuthObserverAuthorizeAuthenticatedPeerCallback :: Maybe DBusAuthObserverAuthorizeAuthenticatedPeerCallback
noDBusAuthObserverAuthorizeAuthenticatedPeerCallback = Nothing

type C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback =
    Ptr () ->                               -- object
    Ptr Gio.IOStream.IOStream ->
    Ptr Gio.Credentials.Credentials ->
    Ptr () ->                               -- user_data
    IO CInt

foreign import ccall "wrapper"
    mk_DBusAuthObserverAuthorizeAuthenticatedPeerCallback :: C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback -> IO (FunPtr C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback)

genClosure_DBusAuthObserverAuthorizeAuthenticatedPeer :: DBusAuthObserverAuthorizeAuthenticatedPeerCallback -> IO Closure
genClosure_DBusAuthObserverAuthorizeAuthenticatedPeer cb = do
    let cb' = wrap_DBusAuthObserverAuthorizeAuthenticatedPeerCallback cb
    mk_DBusAuthObserverAuthorizeAuthenticatedPeerCallback cb' >>= newCClosure


wrap_DBusAuthObserverAuthorizeAuthenticatedPeerCallback ::
    DBusAuthObserverAuthorizeAuthenticatedPeerCallback ->
    Ptr () ->
    Ptr Gio.IOStream.IOStream ->
    Ptr Gio.Credentials.Credentials ->
    Ptr () ->
    IO CInt
wrap_DBusAuthObserverAuthorizeAuthenticatedPeerCallback _cb _ stream credentials _ = do
    stream' <- (newObject Gio.IOStream.IOStream) stream
    maybeCredentials <-
        if credentials == nullPtr
        then return Nothing
        else do
            credentials' <- (newObject Gio.Credentials.Credentials) credentials
            return $ Just credentials'
    result <- _cb  stream' maybeCredentials
    let result' = (fromIntegral . fromEnum) result
    return result'


onDBusAuthObserverAuthorizeAuthenticatedPeer :: (IsDBusAuthObserver a, MonadIO m) => a -> DBusAuthObserverAuthorizeAuthenticatedPeerCallback -> m SignalHandlerId
onDBusAuthObserverAuthorizeAuthenticatedPeer obj cb = liftIO $ do
    let cb' = wrap_DBusAuthObserverAuthorizeAuthenticatedPeerCallback cb
    cb'' <- mk_DBusAuthObserverAuthorizeAuthenticatedPeerCallback cb'
    connectSignalFunPtr obj "authorize-authenticated-peer" cb'' SignalConnectBefore

afterDBusAuthObserverAuthorizeAuthenticatedPeer :: (IsDBusAuthObserver a, MonadIO m) => a -> DBusAuthObserverAuthorizeAuthenticatedPeerCallback -> m SignalHandlerId
afterDBusAuthObserverAuthorizeAuthenticatedPeer obj cb = liftIO $ do
    let cb' = wrap_DBusAuthObserverAuthorizeAuthenticatedPeerCallback cb
    cb'' <- mk_DBusAuthObserverAuthorizeAuthenticatedPeerCallback cb'
    connectSignalFunPtr obj "authorize-authenticated-peer" cb'' SignalConnectAfter


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

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
#endif

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

data DBusAuthObserverAuthorizeAuthenticatedPeerSignalInfo
instance SignalInfo DBusAuthObserverAuthorizeAuthenticatedPeerSignalInfo where
    type HaskellCallbackType DBusAuthObserverAuthorizeAuthenticatedPeerSignalInfo = DBusAuthObserverAuthorizeAuthenticatedPeerCallback
    connectSignal _ obj cb connectMode = do
        let cb' = wrap_DBusAuthObserverAuthorizeAuthenticatedPeerCallback cb
        cb'' <- mk_DBusAuthObserverAuthorizeAuthenticatedPeerCallback cb'
        connectSignalFunPtr obj "authorize-authenticated-peer" cb'' connectMode

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 'GI.Gio.Objects.DBusAuthObserver.DBusAuthObserver' object.

@since 2.26
-}
dBusAuthObserverNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m DBusAuthObserver
    {- ^ __Returns:__ A 'GI.Gio.Objects.DBusAuthObserver.DBusAuthObserver'. Free with 'GI.GObject.Objects.Object.objectUnref'. -}
dBusAuthObserverNew  = liftIO $ do
    result <- g_dbus_auth_observer_new
    checkUnexpectedReturnNULL "dBusAuthObserverNew" result
    result' <- (wrapObject DBusAuthObserver) result
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
#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 'GI.Gio.Objects.DBusAuthObserver.DBusAuthObserver'::@/allow-mechanism/@ signal on /@observer@/.

@since 2.34
-}
dBusAuthObserverAllowMechanism ::
    (B.CallStack.HasCallStack, MonadIO m, IsDBusAuthObserver a) =>
    a
    {- ^ /@observer@/: A 'GI.Gio.Objects.DBusAuthObserver.DBusAuthObserver'. -}
    -> T.Text
    {- ^ /@mechanism@/: The name of the mechanism, e.g. @DBUS_COOKIE_SHA1@. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@mechanism@/ can be used to authenticate the other peer, 'False' if not. -}
dBusAuthObserverAllowMechanism observer mechanism = liftIO $ do
    observer' <- unsafeManagedPtrCastPtr observer
    mechanism' <- textToCString mechanism
    result <- g_dbus_auth_observer_allow_mechanism observer' mechanism'
    let result' = (/= 0) result
    touchManagedPtr observer
    freeMem mechanism'
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
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 'GI.Gio.Objects.DBusAuthObserver.DBusAuthObserver'::@/authorize-authenticated-peer/@ 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 'GI.Gio.Objects.DBusAuthObserver.DBusAuthObserver'. -}
    -> b
    {- ^ /@stream@/: A 'GI.Gio.Objects.IOStream.IOStream' for the 'GI.Gio.Objects.DBusConnection.DBusConnection'. -}
    -> Maybe (c)
    {- ^ /@credentials@/: Credentials received from the peer or 'Nothing'. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the peer is authorized, 'False' if not. -}
dBusAuthObserverAuthorizeAuthenticatedPeer observer stream credentials = liftIO $ do
    observer' <- unsafeManagedPtrCastPtr observer
    stream' <- unsafeManagedPtrCastPtr stream
    maybeCredentials <- case credentials of
        Nothing -> return nullPtr
        Just jCredentials -> do
            jCredentials' <- unsafeManagedPtrCastPtr jCredentials
            return jCredentials'
    result <- g_dbus_auth_observer_authorize_authenticated_peer observer' stream' maybeCredentials
    let result' = (/= 0) result
    touchManagedPtr observer
    touchManagedPtr stream
    whenJust credentials touchManagedPtr
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
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