{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (garetxe@gmail.com) Struct used in g_dbus_error_register_error_domain(). -} module GI.Gio.Structs.DBusErrorEntry ( -- * Exported types DBusErrorEntry(..) , newZeroDBusErrorEntry , noDBusErrorEntry , -- * Properties -- ** DbusErrorName dBusErrorEntryReadDbusErrorName , -- ** ErrorCode dBusErrorEntryReadErrorCode , ) where import Prelude () import Data.GI.Base.ShortPrelude import qualified Data.Text as T import qualified Data.ByteString.Char8 as B import qualified Data.Map as Map import GI.Gio.Types import GI.Gio.Callbacks newtype DBusErrorEntry = DBusErrorEntry (ForeignPtr DBusErrorEntry) -- | Construct a `DBusErrorEntry` struct initialized to zero. newZeroDBusErrorEntry :: MonadIO m => m DBusErrorEntry newZeroDBusErrorEntry = liftIO $ callocBytes 16 >>= wrapPtr DBusErrorEntry noDBusErrorEntry :: Maybe DBusErrorEntry noDBusErrorEntry = Nothing dBusErrorEntryReadErrorCode :: DBusErrorEntry -> IO Int32 dBusErrorEntryReadErrorCode s = withManagedPtr s $ \ptr -> do val <- peek (ptr `plusPtr` 0) :: IO Int32 return val dBusErrorEntryReadDbusErrorName :: DBusErrorEntry -> IO T.Text dBusErrorEntryReadDbusErrorName s = withManagedPtr s $ \ptr -> do val <- peek (ptr `plusPtr` 8) :: IO CString val' <- cstringToText val return val' type family ResolveDBusErrorEntryMethod (t :: Symbol) (o :: *) :: * where ResolveDBusErrorEntryMethod l o = MethodResolutionFailed l o instance (info ~ ResolveDBusErrorEntryMethod t DBusErrorEntry, MethodInfo info DBusErrorEntry p) => IsLabelProxy t (DBusErrorEntry -> p) where fromLabelProxy _ = overloadedMethod (MethodProxy :: MethodProxy info) #if MIN_VERSION_base(4,9,0) instance (info ~ ResolveDBusErrorEntryMethod t DBusErrorEntry, MethodInfo info DBusErrorEntry p) => IsLabel t (DBusErrorEntry -> p) where fromLabel _ = overloadedMethod (MethodProxy :: MethodProxy info) #endif