{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- This t'GI.Gio.Objects.SocketControlMessage.SocketControlMessage' contains a t'GI.Gio.Objects.Credentials.Credentials' instance.  It
-- may be sent using 'GI.Gio.Objects.Socket.socketSendMessage' and received using
-- 'GI.Gio.Objects.Socket.socketReceiveMessage' over UNIX sockets (ie: sockets in the
-- 'GI.Gio.Enums.SocketFamilyUnix' family).
-- 
-- For an easier way to send and receive credentials over
-- stream-oriented UNIX sockets, see
-- 'GI.Gio.Objects.UnixConnection.unixConnectionSendCredentials' and
-- 'GI.Gio.Objects.UnixConnection.unixConnectionReceiveCredentials'. To receive credentials of
-- a foreign process connected to a socket, use
-- 'GI.Gio.Objects.Socket.socketGetCredentials'.
-- 
-- /Since: 2.26/

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

module GI.Gio.Objects.UnixCredentialsMessage
    ( 

-- * Exported types
    UnixCredentialsMessage(..)              ,
    IsUnixCredentialsMessage                ,
    toUnixCredentialsMessage                ,
    noUnixCredentialsMessage                ,


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

#if defined(ENABLE_OVERLOADING)
    ResolveUnixCredentialsMessageMethod     ,
#endif


-- ** getCredentials #method:getCredentials#

#if defined(ENABLE_OVERLOADING)
    UnixCredentialsMessageGetCredentialsMethodInfo,
#endif
    unixCredentialsMessageGetCredentials    ,


-- ** isSupported #method:isSupported#

    unixCredentialsMessageIsSupported       ,


-- ** new #method:new#

    unixCredentialsMessageNew               ,


-- ** newWithCredentials #method:newWithCredentials#

    unixCredentialsMessageNewWithCredentials,




 -- * Properties
-- ** credentials #attr:credentials#
-- | The credentials stored in the message.
-- 
-- /Since: 2.26/

#if defined(ENABLE_OVERLOADING)
    UnixCredentialsMessageCredentialsPropertyInfo,
#endif
    constructUnixCredentialsMessageCredentials,
    getUnixCredentialsMessageCredentials    ,
#if defined(ENABLE_OVERLOADING)
    unixCredentialsMessageCredentials       ,
#endif




    ) 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.GI.Base.Signals as B.Signals
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.SocketControlMessage as Gio.SocketControlMessage

-- | Memory-managed wrapper type.
newtype UnixCredentialsMessage = UnixCredentialsMessage (ManagedPtr UnixCredentialsMessage)
    deriving (UnixCredentialsMessage -> UnixCredentialsMessage -> Bool
(UnixCredentialsMessage -> UnixCredentialsMessage -> Bool)
-> (UnixCredentialsMessage -> UnixCredentialsMessage -> Bool)
-> Eq UnixCredentialsMessage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UnixCredentialsMessage -> UnixCredentialsMessage -> Bool
$c/= :: UnixCredentialsMessage -> UnixCredentialsMessage -> Bool
== :: UnixCredentialsMessage -> UnixCredentialsMessage -> Bool
$c== :: UnixCredentialsMessage -> UnixCredentialsMessage -> Bool
Eq)
foreign import ccall "g_unix_credentials_message_get_type"
    c_g_unix_credentials_message_get_type :: IO GType

instance GObject UnixCredentialsMessage where
    gobjectType :: IO GType
gobjectType = IO GType
c_g_unix_credentials_message_get_type
    

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

-- | Type class for types which can be safely cast to `UnixCredentialsMessage`, for instance with `toUnixCredentialsMessage`.
class (GObject o, O.IsDescendantOf UnixCredentialsMessage o) => IsUnixCredentialsMessage o
instance (GObject o, O.IsDescendantOf UnixCredentialsMessage o) => IsUnixCredentialsMessage o

instance O.HasParentTypes UnixCredentialsMessage
type instance O.ParentTypes UnixCredentialsMessage = '[Gio.SocketControlMessage.SocketControlMessage, GObject.Object.Object]

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

-- | A convenience alias for `Nothing` :: `Maybe` `UnixCredentialsMessage`.
noUnixCredentialsMessage :: Maybe UnixCredentialsMessage
noUnixCredentialsMessage :: Maybe UnixCredentialsMessage
noUnixCredentialsMessage = Maybe UnixCredentialsMessage
forall a. Maybe a
Nothing

#if defined(ENABLE_OVERLOADING)
type family ResolveUnixCredentialsMessageMethod (t :: Symbol) (o :: *) :: * where
    ResolveUnixCredentialsMessageMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveUnixCredentialsMessageMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveUnixCredentialsMessageMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveUnixCredentialsMessageMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveUnixCredentialsMessageMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveUnixCredentialsMessageMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveUnixCredentialsMessageMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveUnixCredentialsMessageMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveUnixCredentialsMessageMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveUnixCredentialsMessageMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveUnixCredentialsMessageMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveUnixCredentialsMessageMethod "serialize" o = Gio.SocketControlMessage.SocketControlMessageSerializeMethodInfo
    ResolveUnixCredentialsMessageMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveUnixCredentialsMessageMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveUnixCredentialsMessageMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveUnixCredentialsMessageMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveUnixCredentialsMessageMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveUnixCredentialsMessageMethod "getCredentials" o = UnixCredentialsMessageGetCredentialsMethodInfo
    ResolveUnixCredentialsMessageMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveUnixCredentialsMessageMethod "getLevel" o = Gio.SocketControlMessage.SocketControlMessageGetLevelMethodInfo
    ResolveUnixCredentialsMessageMethod "getMsgType" o = Gio.SocketControlMessage.SocketControlMessageGetMsgTypeMethodInfo
    ResolveUnixCredentialsMessageMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveUnixCredentialsMessageMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveUnixCredentialsMessageMethod "getSize" o = Gio.SocketControlMessage.SocketControlMessageGetSizeMethodInfo
    ResolveUnixCredentialsMessageMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveUnixCredentialsMessageMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveUnixCredentialsMessageMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveUnixCredentialsMessageMethod l o = O.MethodResolutionFailed l o

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

#endif

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

-- | Get the value of the “@credentials@” property.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.get' unixCredentialsMessage #credentials
-- @
getUnixCredentialsMessageCredentials :: (MonadIO m, IsUnixCredentialsMessage o) => o -> m Gio.Credentials.Credentials
getUnixCredentialsMessageCredentials :: o -> m Credentials
getUnixCredentialsMessageCredentials obj :: o
obj = IO Credentials -> m Credentials
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Credentials -> m Credentials)
-> IO Credentials -> m Credentials
forall a b. (a -> b) -> a -> b
$ Text -> IO (Maybe Credentials) -> IO Credentials
forall a. HasCallStack => Text -> IO (Maybe a) -> IO a
checkUnexpectedNothing "getUnixCredentialsMessageCredentials" (IO (Maybe Credentials) -> IO Credentials)
-> IO (Maybe Credentials) -> IO Credentials
forall a b. (a -> b) -> a -> b
$ o
-> String
-> (ManagedPtr Credentials -> Credentials)
-> IO (Maybe Credentials)
forall a b.
(GObject a, GObject b) =>
a -> String -> (ManagedPtr b -> b) -> IO (Maybe b)
B.Properties.getObjectPropertyObject o
obj "credentials" ManagedPtr Credentials -> Credentials
Gio.Credentials.Credentials

-- | Construct a `GValueConstruct` with valid value for the “@credentials@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
constructUnixCredentialsMessageCredentials :: (IsUnixCredentialsMessage o, Gio.Credentials.IsCredentials a) => a -> IO (GValueConstruct o)
constructUnixCredentialsMessageCredentials :: a -> IO (GValueConstruct o)
constructUnixCredentialsMessageCredentials val :: a
val = String -> Maybe a -> IO (GValueConstruct o)
forall a o.
GObject a =>
String -> Maybe a -> IO (GValueConstruct o)
B.Properties.constructObjectPropertyObject "credentials" (a -> Maybe a
forall a. a -> Maybe a
Just a
val)

#if defined(ENABLE_OVERLOADING)
data UnixCredentialsMessageCredentialsPropertyInfo
instance AttrInfo UnixCredentialsMessageCredentialsPropertyInfo where
    type AttrAllowedOps UnixCredentialsMessageCredentialsPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrBaseTypeConstraint UnixCredentialsMessageCredentialsPropertyInfo = IsUnixCredentialsMessage
    type AttrSetTypeConstraint UnixCredentialsMessageCredentialsPropertyInfo = Gio.Credentials.IsCredentials
    type AttrTransferTypeConstraint UnixCredentialsMessageCredentialsPropertyInfo = Gio.Credentials.IsCredentials
    type AttrTransferType UnixCredentialsMessageCredentialsPropertyInfo = Gio.Credentials.Credentials
    type AttrGetType UnixCredentialsMessageCredentialsPropertyInfo = Gio.Credentials.Credentials
    type AttrLabel UnixCredentialsMessageCredentialsPropertyInfo = "credentials"
    type AttrOrigin UnixCredentialsMessageCredentialsPropertyInfo = UnixCredentialsMessage
    attrGet = getUnixCredentialsMessageCredentials
    attrSet = undefined
    attrTransfer _ v = do
        unsafeCastTo Gio.Credentials.Credentials v
    attrConstruct = constructUnixCredentialsMessageCredentials
    attrClear = undefined
#endif

#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList UnixCredentialsMessage
type instance O.AttributeList UnixCredentialsMessage = UnixCredentialsMessageAttributeList
type UnixCredentialsMessageAttributeList = ('[ '("credentials", UnixCredentialsMessageCredentialsPropertyInfo)] :: [(Symbol, *)])
#endif

#if defined(ENABLE_OVERLOADING)
unixCredentialsMessageCredentials :: AttrLabelProxy "credentials"
unixCredentialsMessageCredentials = AttrLabelProxy

#endif

#if defined(ENABLE_OVERLOADING)
type instance O.SignalList UnixCredentialsMessage = UnixCredentialsMessageSignalList
type UnixCredentialsMessageSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

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

foreign import ccall "g_unix_credentials_message_new" g_unix_credentials_message_new :: 
    IO (Ptr UnixCredentialsMessage)

-- | Creates a new t'GI.Gio.Objects.UnixCredentialsMessage.UnixCredentialsMessage' with credentials matching the current processes.
-- 
-- /Since: 2.26/
unixCredentialsMessageNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m UnixCredentialsMessage
    -- ^ __Returns:__ a new t'GI.Gio.Objects.UnixCredentialsMessage.UnixCredentialsMessage'
unixCredentialsMessageNew :: m UnixCredentialsMessage
unixCredentialsMessageNew  = IO UnixCredentialsMessage -> m UnixCredentialsMessage
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO UnixCredentialsMessage -> m UnixCredentialsMessage)
-> IO UnixCredentialsMessage -> m UnixCredentialsMessage
forall a b. (a -> b) -> a -> b
$ do
    Ptr UnixCredentialsMessage
result <- IO (Ptr UnixCredentialsMessage)
g_unix_credentials_message_new
    Text -> Ptr UnixCredentialsMessage -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "unixCredentialsMessageNew" Ptr UnixCredentialsMessage
result
    UnixCredentialsMessage
result' <- ((ManagedPtr UnixCredentialsMessage -> UnixCredentialsMessage)
-> Ptr UnixCredentialsMessage -> IO UnixCredentialsMessage
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr UnixCredentialsMessage -> UnixCredentialsMessage
UnixCredentialsMessage) Ptr UnixCredentialsMessage
result
    UnixCredentialsMessage -> IO UnixCredentialsMessage
forall (m :: * -> *) a. Monad m => a -> m a
return UnixCredentialsMessage
result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method UnixCredentialsMessage::new_with_credentials
-- method type : Constructor
-- Args: [ Arg
--           { argCName = "credentials"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "Credentials" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "A #GCredentials object."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface
--                  Name { namespace = "Gio" , name = "UnixCredentialsMessage" })
-- throws : False
-- Skip return : False

foreign import ccall "g_unix_credentials_message_new_with_credentials" g_unix_credentials_message_new_with_credentials :: 
    Ptr Gio.Credentials.Credentials ->      -- credentials : TInterface (Name {namespace = "Gio", name = "Credentials"})
    IO (Ptr UnixCredentialsMessage)

-- | Creates a new t'GI.Gio.Objects.UnixCredentialsMessage.UnixCredentialsMessage' holding /@credentials@/.
-- 
-- /Since: 2.26/
unixCredentialsMessageNewWithCredentials ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.Credentials.IsCredentials a) =>
    a
    -- ^ /@credentials@/: A t'GI.Gio.Objects.Credentials.Credentials' object.
    -> m UnixCredentialsMessage
    -- ^ __Returns:__ a new t'GI.Gio.Objects.UnixCredentialsMessage.UnixCredentialsMessage'
unixCredentialsMessageNewWithCredentials :: a -> m UnixCredentialsMessage
unixCredentialsMessageNewWithCredentials credentials :: a
credentials = IO UnixCredentialsMessage -> m UnixCredentialsMessage
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO UnixCredentialsMessage -> m UnixCredentialsMessage)
-> IO UnixCredentialsMessage -> m UnixCredentialsMessage
forall a b. (a -> b) -> a -> b
$ do
    Ptr Credentials
credentials' <- a -> IO (Ptr Credentials)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
credentials
    Ptr UnixCredentialsMessage
result <- Ptr Credentials -> IO (Ptr UnixCredentialsMessage)
g_unix_credentials_message_new_with_credentials Ptr Credentials
credentials'
    Text -> Ptr UnixCredentialsMessage -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "unixCredentialsMessageNewWithCredentials" Ptr UnixCredentialsMessage
result
    UnixCredentialsMessage
result' <- ((ManagedPtr UnixCredentialsMessage -> UnixCredentialsMessage)
-> Ptr UnixCredentialsMessage -> IO UnixCredentialsMessage
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr UnixCredentialsMessage -> UnixCredentialsMessage
UnixCredentialsMessage) Ptr UnixCredentialsMessage
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
credentials
    UnixCredentialsMessage -> IO UnixCredentialsMessage
forall (m :: * -> *) a. Monad m => a -> m a
return UnixCredentialsMessage
result'

#if defined(ENABLE_OVERLOADING)
#endif

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

foreign import ccall "g_unix_credentials_message_get_credentials" g_unix_credentials_message_get_credentials :: 
    Ptr UnixCredentialsMessage ->           -- message : TInterface (Name {namespace = "Gio", name = "UnixCredentialsMessage"})
    IO (Ptr Gio.Credentials.Credentials)

-- | Gets the credentials stored in /@message@/.
-- 
-- /Since: 2.26/
unixCredentialsMessageGetCredentials ::
    (B.CallStack.HasCallStack, MonadIO m, IsUnixCredentialsMessage a) =>
    a
    -- ^ /@message@/: A t'GI.Gio.Objects.UnixCredentialsMessage.UnixCredentialsMessage'.
    -> m Gio.Credentials.Credentials
    -- ^ __Returns:__ A t'GI.Gio.Objects.Credentials.Credentials' instance. Do not free, it is owned by /@message@/.
unixCredentialsMessageGetCredentials :: a -> m Credentials
unixCredentialsMessageGetCredentials message :: a
message = IO Credentials -> m Credentials
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Credentials -> m Credentials)
-> IO Credentials -> m Credentials
forall a b. (a -> b) -> a -> b
$ do
    Ptr UnixCredentialsMessage
message' <- a -> IO (Ptr UnixCredentialsMessage)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
message
    Ptr Credentials
result <- Ptr UnixCredentialsMessage -> IO (Ptr Credentials)
g_unix_credentials_message_get_credentials Ptr UnixCredentialsMessage
message'
    Text -> Ptr Credentials -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "unixCredentialsMessageGetCredentials" Ptr Credentials
result
    Credentials
result' <- ((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
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
message
    Credentials -> IO Credentials
forall (m :: * -> *) a. Monad m => a -> m a
return Credentials
result'

#if defined(ENABLE_OVERLOADING)
data UnixCredentialsMessageGetCredentialsMethodInfo
instance (signature ~ (m Gio.Credentials.Credentials), MonadIO m, IsUnixCredentialsMessage a) => O.MethodInfo UnixCredentialsMessageGetCredentialsMethodInfo a signature where
    overloadedMethod = unixCredentialsMessageGetCredentials

#endif

-- method UnixCredentialsMessage::is_supported
-- method type : MemberFunction
-- Args: []
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_unix_credentials_message_is_supported" g_unix_credentials_message_is_supported :: 
    IO CInt

-- | Checks if passing t'GI.Gio.Objects.Credentials.Credentials' on a t'GI.Gio.Objects.Socket.Socket' is supported on this platform.
-- 
-- /Since: 2.26/
unixCredentialsMessageIsSupported ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Bool
    -- ^ __Returns:__ 'P.True' if supported, 'P.False' otherwise
unixCredentialsMessageIsSupported :: m Bool
unixCredentialsMessageIsSupported  = 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
    CInt
result <- IO CInt
g_unix_credentials_message_is_supported
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
#endif