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

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;
>}


/Since: 2.26/
-}

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

module GI.Gio.Objects.DBusAuthObserver
    (

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


 -- * Methods
-- ** allowMechanism #method:allowMechanism#

#if ENABLE_OVERLOADING
    DBusAuthObserverAllowMechanismMethodInfo,
#endif
    dBusAuthObserverAllowMechanism          ,


-- ** authorizeAuthenticatedPeer #method:authorizeAuthenticatedPeer#

#if ENABLE_OVERLOADING
    DBusAuthObserverAuthorizeAuthenticatedPeerMethodInfo,
#endif
    dBusAuthObserverAuthorizeAuthenticatedPeer,


-- ** new #method:new#

    dBusAuthObserverNew                     ,




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

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


-- ** authorizeAuthenticatedPeer #signal:authorizeAuthenticatedPeer#

    C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback,
    DBusAuthObserverAuthorizeAuthenticatedPeerCallback,
#if 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.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.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 (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


-- | Type class for types which can be safely cast to `DBusAuthObserver`, for instance with `toDBusAuthObserver`.
class (GObject o, O.IsDescendantOf DBusAuthObserver o) => IsDBusAuthObserver o
instance (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 = liftIO . unsafeCastTo DBusAuthObserver

-- | A convenience alias for `Nothing` :: `Maybe` `DBusAuthObserver`.
noDBusAuthObserver :: Maybe DBusAuthObserver
noDBusAuthObserver = Nothing

#if 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 (O.MethodProxy :: O.MethodProxy info)
#else
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy 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:__ 'True' if /@mechanism@/ can be used to authenticate the other peer, 'False' if not. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `DBusAuthObserverAllowMechanismCallback`@.
noDBusAuthObserverAllowMechanismCallback :: Maybe DBusAuthObserverAllowMechanismCallback
noDBusAuthObserverAllowMechanismCallback = 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 cb = liftIO $ do
    let cb' = wrap_DBusAuthObserverAllowMechanismCallback cb
    mk_DBusAuthObserverAllowMechanismCallback cb' >>= B.GClosure.newGClosure


-- | Wrap a `DBusAuthObserverAllowMechanismCallback` into a `C_DBusAuthObserverAllowMechanismCallback`.
wrap_DBusAuthObserverAllowMechanismCallback ::
    DBusAuthObserverAllowMechanismCallback ->
    C_DBusAuthObserverAllowMechanismCallback
wrap_DBusAuthObserverAllowMechanismCallback _cb _ mechanism _ = do
    mechanism' <- cstringToText mechanism
    result <- _cb  mechanism'
    let result' = (fromIntegral . fromEnum) result
    return result'


{- |
Connect a signal handler for the “@allow-mechanism@” 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 obj cb = liftIO $ do
    let cb' = wrap_DBusAuthObserverAllowMechanismCallback cb
    cb'' <- mk_DBusAuthObserverAllowMechanismCallback cb'
    connectSignalFunPtr obj "allow-mechanism" cb'' SignalConnectBefore

{- |
Connect a signal handler for the “@allow-mechanism@” 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 obj cb = liftIO $ do
    let cb' = wrap_DBusAuthObserverAllowMechanismCallback cb
    cb'' <- mk_DBusAuthObserverAllowMechanismCallback cb'
    connectSignalFunPtr obj "allow-mechanism" cb'' SignalConnectAfter


-- 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 'GI.Gio.Objects.IOStream.IOStream' for the 'GI.Gio.Objects.DBusConnection.DBusConnection'. -}
    -> Maybe Gio.Credentials.Credentials
    {- ^ /@credentials@/: Credentials received from the peer or 'Nothing'. -}
    -> IO Bool
    {- ^ __Returns:__ 'True' if the peer is authorized, 'False' if not. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `DBusAuthObserverAuthorizeAuthenticatedPeerCallback`@.
noDBusAuthObserverAuthorizeAuthenticatedPeerCallback :: Maybe DBusAuthObserverAuthorizeAuthenticatedPeerCallback
noDBusAuthObserverAuthorizeAuthenticatedPeerCallback = 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 cb = liftIO $ do
    let cb' = wrap_DBusAuthObserverAuthorizeAuthenticatedPeerCallback cb
    mk_DBusAuthObserverAuthorizeAuthenticatedPeerCallback cb' >>= B.GClosure.newGClosure


-- | Wrap a `DBusAuthObserverAuthorizeAuthenticatedPeerCallback` into a `C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback`.
wrap_DBusAuthObserverAuthorizeAuthenticatedPeerCallback ::
    DBusAuthObserverAuthorizeAuthenticatedPeerCallback ->
    C_DBusAuthObserverAuthorizeAuthenticatedPeerCallback
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'


{- |
Connect a signal handler for the “@authorize-authenticated-peer@” 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 obj cb = liftIO $ do
    let cb' = wrap_DBusAuthObserverAuthorizeAuthenticatedPeerCallback cb
    cb'' <- mk_DBusAuthObserverAuthorizeAuthenticatedPeerCallback cb'
    connectSignalFunPtr obj "authorize-authenticated-peer" cb'' SignalConnectBefore

{- |
Connect a signal handler for the “@authorize-authenticated-peer@” 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 obj cb = liftIO $ do
    let cb' = wrap_DBusAuthObserverAuthorizeAuthenticatedPeerCallback cb
    cb'' <- mk_DBusAuthObserverAuthorizeAuthenticatedPeerCallback cb'
    connectSignalFunPtr obj "authorize-authenticated-peer" cb'' SignalConnectAfter


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

#if ENABLE_OVERLOADING
#endif

#if ENABLE_OVERLOADING
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 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 '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 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 '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 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