{- |
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 a ssh interactive credential.
-}

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

module GI.Ggit.Objects.CredSshInteractive
    (

-- * Exported types
    CredSshInteractive(..)                  ,
    IsCredSshInteractive                    ,
    toCredSshInteractive                    ,
    noCredSshInteractive                    ,


 -- * Methods
-- ** getUsername #method:getUsername#

#if ENABLE_OVERLOADING
    CredSshInteractiveGetUsernameMethodInfo ,
#endif
    credSshInteractiveGetUsername           ,


-- ** new #method:new#

    credSshInteractiveNew                   ,




 -- * Properties
-- ** username #attr:username#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
    CredSshInteractiveUsernamePropertyInfo  ,
#endif
    constructCredSshInteractiveUsername     ,
#if ENABLE_OVERLOADING
    credSshInteractiveUsername              ,
#endif
    getCredSshInteractiveUsername           ,




    ) 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.Ggit.Objects.Cred as Ggit.Cred
import {-# SOURCE #-} qualified GI.Ggit.Objects.Native as Ggit.Native
import {-# SOURCE #-} qualified GI.Ggit.Objects.ObjectFactoryBase as Ggit.ObjectFactoryBase
import qualified GI.Gio.Interfaces.Initable as Gio.Initable

-- | Memory-managed wrapper type.
newtype CredSshInteractive = CredSshInteractive (ManagedPtr CredSshInteractive)
foreign import ccall "ggit_cred_ssh_interactive_get_type"
    c_ggit_cred_ssh_interactive_get_type :: IO GType

instance GObject CredSshInteractive where
    gobjectType = c_ggit_cred_ssh_interactive_get_type


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

instance O.HasParentTypes CredSshInteractive
type instance O.ParentTypes CredSshInteractive = '[Ggit.Cred.Cred, Ggit.Native.Native, Ggit.ObjectFactoryBase.ObjectFactoryBase, GObject.Object.Object, Gio.Initable.Initable]

-- | Cast to `CredSshInteractive`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toCredSshInteractive :: (MonadIO m, IsCredSshInteractive o) => o -> m CredSshInteractive
toCredSshInteractive = liftIO . unsafeCastTo CredSshInteractive

-- | A convenience alias for `Nothing` :: `Maybe` `CredSshInteractive`.
noCredSshInteractive :: Maybe CredSshInteractive
noCredSshInteractive = Nothing

#if ENABLE_OVERLOADING
type family ResolveCredSshInteractiveMethod (t :: Symbol) (o :: *) :: * where
    ResolveCredSshInteractiveMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveCredSshInteractiveMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveCredSshInteractiveMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveCredSshInteractiveMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveCredSshInteractiveMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveCredSshInteractiveMethod "init" o = Gio.Initable.InitableInitMethodInfo
    ResolveCredSshInteractiveMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveCredSshInteractiveMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveCredSshInteractiveMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveCredSshInteractiveMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveCredSshInteractiveMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveCredSshInteractiveMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveCredSshInteractiveMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveCredSshInteractiveMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveCredSshInteractiveMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveCredSshInteractiveMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveCredSshInteractiveMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveCredSshInteractiveMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveCredSshInteractiveMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveCredSshInteractiveMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveCredSshInteractiveMethod "getUsername" o = CredSshInteractiveGetUsernameMethodInfo
    ResolveCredSshInteractiveMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveCredSshInteractiveMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveCredSshInteractiveMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveCredSshInteractiveMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveCredSshInteractiveMethod t CredSshInteractive, O.MethodInfo info CredSshInteractive p) => OL.IsLabel t (CredSshInteractive -> 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 "username"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Just False,Nothing)

{- |
Get the value of the “@username@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' credSshInteractive #username
@
-}
getCredSshInteractiveUsername :: (MonadIO m, IsCredSshInteractive o) => o -> m T.Text
getCredSshInteractiveUsername obj = liftIO $ checkUnexpectedNothing "getCredSshInteractiveUsername" $ B.Properties.getObjectPropertyString obj "username"

{- |
Construct a `GValueConstruct` with valid value for the “@username@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructCredSshInteractiveUsername :: (IsCredSshInteractive o) => T.Text -> IO (GValueConstruct o)
constructCredSshInteractiveUsername val = B.Properties.constructObjectPropertyString "username" (Just val)

#if ENABLE_OVERLOADING
data CredSshInteractiveUsernamePropertyInfo
instance AttrInfo CredSshInteractiveUsernamePropertyInfo where
    type AttrAllowedOps CredSshInteractiveUsernamePropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint CredSshInteractiveUsernamePropertyInfo = (~) T.Text
    type AttrBaseTypeConstraint CredSshInteractiveUsernamePropertyInfo = IsCredSshInteractive
    type AttrGetType CredSshInteractiveUsernamePropertyInfo = T.Text
    type AttrLabel CredSshInteractiveUsernamePropertyInfo = "username"
    type AttrOrigin CredSshInteractiveUsernamePropertyInfo = CredSshInteractive
    attrGet _ = getCredSshInteractiveUsername
    attrSet _ = undefined
    attrConstruct _ = constructCredSshInteractiveUsername
    attrClear _ = undefined
#endif

#if ENABLE_OVERLOADING
instance O.HasAttributeList CredSshInteractive
type instance O.AttributeList CredSshInteractive = CredSshInteractiveAttributeList
type CredSshInteractiveAttributeList = ('[ '("native", Ggit.Native.NativeNativePropertyInfo), '("username", CredSshInteractiveUsernamePropertyInfo)] :: [(Symbol, *)])
#endif

#if ENABLE_OVERLOADING
credSshInteractiveUsername :: AttrLabelProxy "username"
credSshInteractiveUsername = AttrLabelProxy

#endif

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

#endif

-- method CredSshInteractive::new
-- method type : Constructor
-- Args : [Arg {argCName = "username", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Ggit", name = "CredSshInteractive"}))
-- throws : True
-- Skip return : False

foreign import ccall "ggit_cred_ssh_interactive_new" ggit_cred_ssh_interactive_new ::
    CString ->                              -- username : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr CredSshInteractive)

{- |
/No description available in the introspection data./
-}
credSshInteractiveNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -> m CredSshInteractive
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
credSshInteractiveNew username = liftIO $ do
    username' <- textToCString username
    onException (do
        result <- propagateGError $ ggit_cred_ssh_interactive_new username'
        checkUnexpectedReturnNULL "credSshInteractiveNew" result
        result' <- (wrapObject CredSshInteractive) result
        freeMem username'
        return result'
     ) (do
        freeMem username'
     )

#if ENABLE_OVERLOADING
#endif

-- method CredSshInteractive::get_username
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "cred", argType = TInterface (Name {namespace = "Ggit", name = "CredSshInteractive"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, 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_cred_ssh_interactive_get_username" ggit_cred_ssh_interactive_get_username ::
    Ptr CredSshInteractive ->               -- cred : TInterface (Name {namespace = "Ggit", name = "CredSshInteractive"})
    IO CString

{- |
/No description available in the introspection data./
-}
credSshInteractiveGetUsername ::
    (B.CallStack.HasCallStack, MonadIO m, IsCredSshInteractive a) =>
    a
    -> m T.Text
credSshInteractiveGetUsername cred = liftIO $ do
    cred' <- unsafeManagedPtrCastPtr cred
    result <- ggit_cred_ssh_interactive_get_username cred'
    checkUnexpectedReturnNULL "credSshInteractiveGetUsername" result
    result' <- cstringToText result
    touchManagedPtr cred
    return result'

#if ENABLE_OVERLOADING
data CredSshInteractiveGetUsernameMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsCredSshInteractive a) => O.MethodInfo CredSshInteractiveGetUsernameMethodInfo a signature where
    overloadedMethod _ = credSshInteractiveGetUsername

#endif