{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc) Represents an action signature. -} #define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \ && !defined(__HADDOCK_VERSION__)) module GI.Ggit.Objects.Signature ( -- * Exported types Signature(..) , IsSignature , toSignature , noSignature , -- * Methods -- ** copy #method:copy# #if ENABLE_OVERLOADING SignatureCopyMethodInfo , #endif signatureCopy , -- ** getEmail #method:getEmail# #if ENABLE_OVERLOADING SignatureGetEmailMethodInfo , #endif signatureGetEmail , -- ** getName #method:getName# #if ENABLE_OVERLOADING SignatureGetNameMethodInfo , #endif signatureGetName , -- ** getTime #method:getTime# #if ENABLE_OVERLOADING SignatureGetTimeMethodInfo , #endif signatureGetTime , -- ** getTimeZone #method:getTimeZone# #if ENABLE_OVERLOADING SignatureGetTimeZoneMethodInfo , #endif signatureGetTimeZone , -- ** new #method:new# signatureNew , -- ** newNow #method:newNow# signatureNewNow , -- * Properties -- ** encoding #attr:encoding# {- | /No description available in the introspection data./ -} #if ENABLE_OVERLOADING SignatureEncodingPropertyInfo , #endif constructSignatureEncoding , getSignatureEncoding , #if ENABLE_OVERLOADING signatureEncoding , #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.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.GLib.Structs.DateTime as GLib.DateTime import qualified GI.GLib.Structs.TimeZone as GLib.TimeZone import qualified GI.GObject.Objects.Object as GObject.Object import {-# SOURCE #-} qualified GI.Ggit.Objects.Native as Ggit.Native import {-# SOURCE #-} qualified GI.Ggit.Objects.ObjectFactoryBase as Ggit.ObjectFactoryBase -- | Memory-managed wrapper type. newtype Signature = Signature (ManagedPtr Signature) foreign import ccall "ggit_signature_get_type" c_ggit_signature_get_type :: IO GType instance GObject Signature where gobjectType = c_ggit_signature_get_type -- | Type class for types which can be safely cast to `Signature`, for instance with `toSignature`. class (GObject o, O.IsDescendantOf Signature o) => IsSignature o instance (GObject o, O.IsDescendantOf Signature o) => IsSignature o instance O.HasParentTypes Signature type instance O.ParentTypes Signature = '[Ggit.Native.Native, Ggit.ObjectFactoryBase.ObjectFactoryBase, GObject.Object.Object] -- | Cast to `Signature`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`. toSignature :: (MonadIO m, IsSignature o) => o -> m Signature toSignature = liftIO . unsafeCastTo Signature -- | A convenience alias for `Nothing` :: `Maybe` `Signature`. noSignature :: Maybe Signature noSignature = Nothing #if ENABLE_OVERLOADING type family ResolveSignatureMethod (t :: Symbol) (o :: *) :: * where ResolveSignatureMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo ResolveSignatureMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo ResolveSignatureMethod "copy" o = SignatureCopyMethodInfo ResolveSignatureMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo ResolveSignatureMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo ResolveSignatureMethod "getv" o = GObject.Object.ObjectGetvMethodInfo ResolveSignatureMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo ResolveSignatureMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo ResolveSignatureMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo ResolveSignatureMethod "ref" o = GObject.Object.ObjectRefMethodInfo ResolveSignatureMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo ResolveSignatureMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo ResolveSignatureMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo ResolveSignatureMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo ResolveSignatureMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo ResolveSignatureMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo ResolveSignatureMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo ResolveSignatureMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo ResolveSignatureMethod "getEmail" o = SignatureGetEmailMethodInfo ResolveSignatureMethod "getName" o = SignatureGetNameMethodInfo ResolveSignatureMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo ResolveSignatureMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo ResolveSignatureMethod "getTime" o = SignatureGetTimeMethodInfo ResolveSignatureMethod "getTimeZone" o = SignatureGetTimeZoneMethodInfo ResolveSignatureMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo ResolveSignatureMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo ResolveSignatureMethod l o = O.MethodResolutionFailed l o instance (info ~ ResolveSignatureMethod t Signature, O.MethodInfo info Signature p) => OL.IsLabel t (Signature -> 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 -- VVV Prop "encoding" -- Type: TBasicType TUTF8 -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly] -- Nullable: (Nothing,Nothing) {- | Get the value of the “@encoding@” property. When is enabled, this is equivalent to @ 'Data.GI.Base.Attributes.get' signature #encoding @ -} getSignatureEncoding :: (MonadIO m, IsSignature o) => o -> m (Maybe T.Text) getSignatureEncoding obj = liftIO $ B.Properties.getObjectPropertyString obj "encoding" {- | Construct a `GValueConstruct` with valid value for the “@encoding@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`. -} constructSignatureEncoding :: (IsSignature o) => T.Text -> IO (GValueConstruct o) constructSignatureEncoding val = B.Properties.constructObjectPropertyString "encoding" (Just val) #if ENABLE_OVERLOADING data SignatureEncodingPropertyInfo instance AttrInfo SignatureEncodingPropertyInfo where type AttrAllowedOps SignatureEncodingPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear] type AttrSetTypeConstraint SignatureEncodingPropertyInfo = (~) T.Text type AttrBaseTypeConstraint SignatureEncodingPropertyInfo = IsSignature type AttrGetType SignatureEncodingPropertyInfo = (Maybe T.Text) type AttrLabel SignatureEncodingPropertyInfo = "encoding" type AttrOrigin SignatureEncodingPropertyInfo = Signature attrGet _ = getSignatureEncoding attrSet _ = undefined attrConstruct _ = constructSignatureEncoding attrClear _ = undefined #endif #if ENABLE_OVERLOADING instance O.HasAttributeList Signature type instance O.AttributeList Signature = SignatureAttributeList type SignatureAttributeList = ('[ '("encoding", SignatureEncodingPropertyInfo), '("native", Ggit.Native.NativeNativePropertyInfo)] :: [(Symbol, *)]) #endif #if ENABLE_OVERLOADING signatureEncoding :: AttrLabelProxy "encoding" signatureEncoding = AttrLabelProxy #endif #if ENABLE_OVERLOADING type instance O.SignalList Signature = SignatureSignalList type SignatureSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)]) #endif -- method Signature::new -- method type : Constructor -- Args : [Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the name of the person.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "email", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the email of the person.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "signature_time", argType = TInterface (Name {namespace = "GLib", name = "DateTime"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the time when the action happened.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "Ggit", name = "Signature"})) -- throws : True -- Skip return : False foreign import ccall "ggit_signature_new" ggit_signature_new :: CString -> -- name : TBasicType TUTF8 CString -> -- email : TBasicType TUTF8 Ptr GLib.DateTime.DateTime -> -- signature_time : TInterface (Name {namespace = "GLib", name = "DateTime"}) Ptr (Ptr GError) -> -- error IO (Ptr Signature) {- | Creates a new 'GI.Ggit.Objects.Signature.Signature'. Name and e-mail are assumed to be in UTF-8. -} signatureNew :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@name@/: the name of the person. -} -> T.Text {- ^ /@email@/: the email of the person. -} -> GLib.DateTime.DateTime {- ^ /@signatureTime@/: the time when the action happened. -} -> m (Maybe Signature) {- ^ __Returns:__ a newly allocated 'GI.Ggit.Objects.Signature.Signature' or 'Nothing'. /(Can throw 'Data.GI.Base.GError.GError')/ -} signatureNew name email signatureTime = liftIO $ do name' <- textToCString name email' <- textToCString email signatureTime' <- unsafeManagedPtrGetPtr signatureTime onException (do result <- propagateGError $ ggit_signature_new name' email' signatureTime' maybeResult <- convertIfNonNull result $ \result' -> do result'' <- (wrapObject Signature) result' return result'' touchManagedPtr signatureTime freeMem name' freeMem email' return maybeResult ) (do freeMem name' freeMem email' ) #if ENABLE_OVERLOADING #endif -- method Signature::new_now -- method type : Constructor -- Args : [Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the name of the person.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "email", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the email of the person.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "Ggit", name = "Signature"})) -- throws : True -- Skip return : False foreign import ccall "ggit_signature_new_now" ggit_signature_new_now :: CString -> -- name : TBasicType TUTF8 CString -> -- email : TBasicType TUTF8 Ptr (Ptr GError) -> -- error IO (Ptr Signature) {- | Creates a new 'GI.Ggit.Objects.Signature.Signature' with a timestamp of \'now\'. Name and e-mail are assumed to be in UTF-8. -} signatureNewNow :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@name@/: the name of the person. -} -> T.Text {- ^ /@email@/: the email of the person. -} -> m (Maybe Signature) {- ^ __Returns:__ a newly allocated 'GI.Ggit.Objects.Signature.Signature' or 'Nothing'. /(Can throw 'Data.GI.Base.GError.GError')/ -} signatureNewNow name email = liftIO $ do name' <- textToCString name email' <- textToCString email onException (do result <- propagateGError $ ggit_signature_new_now name' email' maybeResult <- convertIfNonNull result $ \result' -> do result'' <- (wrapObject Signature) result' return result'' freeMem name' freeMem email' return maybeResult ) (do freeMem name' freeMem email' ) #if ENABLE_OVERLOADING #endif -- method Signature::copy -- method type : OrdinaryMethod -- Args : [Arg {argCName = "signature", argType = TInterface (Name {namespace = "Ggit", name = "Signature"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitSignature.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "Ggit", name = "Signature"})) -- throws : False -- Skip return : False foreign import ccall "ggit_signature_copy" ggit_signature_copy :: Ptr Signature -> -- signature : TInterface (Name {namespace = "Ggit", name = "Signature"}) IO (Ptr Signature) {- | Create a copy of the signature. -} signatureCopy :: (B.CallStack.HasCallStack, MonadIO m, IsSignature a) => a {- ^ /@signature@/: a 'GI.Ggit.Objects.Signature.Signature'. -} -> m (Maybe Signature) {- ^ __Returns:__ a 'GI.Ggit.Objects.Signature.Signature' or 'Nothing'. -} signatureCopy signature = liftIO $ do signature' <- unsafeManagedPtrCastPtr signature result <- ggit_signature_copy signature' maybeResult <- convertIfNonNull result $ \result' -> do result'' <- (wrapObject Signature) result' return result'' touchManagedPtr signature return maybeResult #if ENABLE_OVERLOADING data SignatureCopyMethodInfo instance (signature ~ (m (Maybe Signature)), MonadIO m, IsSignature a) => O.MethodInfo SignatureCopyMethodInfo a signature where overloadedMethod _ = signatureCopy #endif -- method Signature::get_email -- method type : OrdinaryMethod -- Args : [Arg {argCName = "signature", argType = TInterface (Name {namespace = "Ggit", name = "Signature"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitSignature.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "ggit_signature_get_email" ggit_signature_get_email :: Ptr Signature -> -- signature : TInterface (Name {namespace = "Ggit", name = "Signature"}) IO CString {- | Gets the email of the person. -} signatureGetEmail :: (B.CallStack.HasCallStack, MonadIO m, IsSignature a) => a {- ^ /@signature@/: a 'GI.Ggit.Objects.Signature.Signature'. -} -> m (Maybe T.Text) {- ^ __Returns:__ the email of the person or 'Nothing'. -} signatureGetEmail signature = liftIO $ do signature' <- unsafeManagedPtrCastPtr signature result <- ggit_signature_get_email signature' maybeResult <- convertIfNonNull result $ \result' -> do result'' <- cstringToText result' return result'' touchManagedPtr signature return maybeResult #if ENABLE_OVERLOADING data SignatureGetEmailMethodInfo instance (signature ~ (m (Maybe T.Text)), MonadIO m, IsSignature a) => O.MethodInfo SignatureGetEmailMethodInfo a signature where overloadedMethod _ = signatureGetEmail #endif -- method Signature::get_name -- method type : OrdinaryMethod -- Args : [Arg {argCName = "signature", argType = TInterface (Name {namespace = "Ggit", name = "Signature"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitSignature.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "ggit_signature_get_name" ggit_signature_get_name :: Ptr Signature -> -- signature : TInterface (Name {namespace = "Ggit", name = "Signature"}) IO CString {- | Gets the name of the person. -} signatureGetName :: (B.CallStack.HasCallStack, MonadIO m, IsSignature a) => a {- ^ /@signature@/: a 'GI.Ggit.Objects.Signature.Signature'. -} -> m (Maybe T.Text) {- ^ __Returns:__ the name of the person or 'Nothing'. -} signatureGetName signature = liftIO $ do signature' <- unsafeManagedPtrCastPtr signature result <- ggit_signature_get_name signature' maybeResult <- convertIfNonNull result $ \result' -> do result'' <- cstringToText result' return result'' touchManagedPtr signature return maybeResult #if ENABLE_OVERLOADING data SignatureGetNameMethodInfo instance (signature ~ (m (Maybe T.Text)), MonadIO m, IsSignature a) => O.MethodInfo SignatureGetNameMethodInfo a signature where overloadedMethod _ = signatureGetName #endif -- method Signature::get_time -- method type : OrdinaryMethod -- Args : [Arg {argCName = "signature", argType = TInterface (Name {namespace = "Ggit", name = "Signature"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitSignature.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "GLib", name = "DateTime"})) -- throws : False -- Skip return : False foreign import ccall "ggit_signature_get_time" ggit_signature_get_time :: Ptr Signature -> -- signature : TInterface (Name {namespace = "Ggit", name = "Signature"}) IO (Ptr GLib.DateTime.DateTime) {- | Gets the time when the action happened. Note that the time is returned in the timezone of the commit (see @/ggit_signature_get_time_zone/@). -} signatureGetTime :: (B.CallStack.HasCallStack, MonadIO m, IsSignature a) => a {- ^ /@signature@/: a 'GI.Ggit.Objects.Signature.Signature'. -} -> m (Maybe GLib.DateTime.DateTime) {- ^ __Returns:__ the time when the action happened or 'Nothing'. -} signatureGetTime signature = liftIO $ do signature' <- unsafeManagedPtrCastPtr signature result <- ggit_signature_get_time signature' maybeResult <- convertIfNonNull result $ \result' -> do result'' <- (wrapBoxed GLib.DateTime.DateTime) result' return result'' touchManagedPtr signature return maybeResult #if ENABLE_OVERLOADING data SignatureGetTimeMethodInfo instance (signature ~ (m (Maybe GLib.DateTime.DateTime)), MonadIO m, IsSignature a) => O.MethodInfo SignatureGetTimeMethodInfo a signature where overloadedMethod _ = signatureGetTime #endif -- method Signature::get_time_zone -- method type : OrdinaryMethod -- Args : [Arg {argCName = "signature", argType = TInterface (Name {namespace = "Ggit", name = "Signature"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitSignature.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "GLib", name = "TimeZone"})) -- throws : False -- Skip return : False foreign import ccall "ggit_signature_get_time_zone" ggit_signature_get_time_zone :: Ptr Signature -> -- signature : TInterface (Name {namespace = "Ggit", name = "Signature"}) IO (Ptr GLib.TimeZone.TimeZone) {- | Gets the timezone in which the action happened. -} signatureGetTimeZone :: (B.CallStack.HasCallStack, MonadIO m, IsSignature a) => a {- ^ /@signature@/: a 'GI.Ggit.Objects.Signature.Signature'. -} -> m (Maybe GLib.TimeZone.TimeZone) {- ^ __Returns:__ the timezone in which the action happened or 'Nothing'. -} signatureGetTimeZone signature = liftIO $ do signature' <- unsafeManagedPtrCastPtr signature result <- ggit_signature_get_time_zone signature' maybeResult <- convertIfNonNull result $ \result' -> do result'' <- (wrapBoxed GLib.TimeZone.TimeZone) result' return result'' touchManagedPtr signature return maybeResult #if ENABLE_OVERLOADING data SignatureGetTimeZoneMethodInfo instance (signature ~ (m (Maybe GLib.TimeZone.TimeZone)), MonadIO m, IsSignature a) => O.MethodInfo SignatureGetTimeZoneMethodInfo a signature where overloadedMethod _ = signatureGetTimeZone #endif