From 794661caa80061d8d20988497867d36c46397f96 Mon Sep 17 00:00:00 2001 From: joe Date: Mon, 28 Apr 2014 16:43:30 -0400 Subject: StreamInfo type, wip --- KeyRing.hs | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/KeyRing.hs b/KeyRing.hs index ecb6021..ac92b14 100644 --- a/KeyRing.hs +++ b/KeyRing.hs @@ -148,6 +148,7 @@ home = HomeDir , optfile_alts = ["keys.conf","gpg.conf-2","gpg.conf"] } +-- TODO: Pipe Fd Fd data InputFile = HomeSec | HomePub | ArgFile FilePath @@ -158,11 +159,30 @@ type UsageTag = String type Initializer = String type PassWordFile = InputFile +-- TODO: This should become a simple enum. +-- The parameter to PEMFile will be subsumed by +-- the KF_Match fill/spill KeyFilter styles. The parameter +-- to KeyRingFile will be subsumbed by kPassphrases data FileType = KeyRingFile (Maybe PassWordFile) | PEMFile UsageTag | WalletFile -- (Maybe UsageTag) | Hosts +data Access = AutoAccess -- ^ secret or public as appropriate based on existing content + | Sec -- ^ secret information + | Pub -- ^ public information + +data KeyFilter = KF_None | KF_Match String | KF_Subkeys | KF_Authentic | KF_All + +-- | TODO: This should replace the element type of kFiles +-- and kImports will be obsolete. +data StreamInfo = StreamInfo + { access :: Access + , typ :: FileType + , fill :: KeyFilter + , spill :: KeyFilter + , initializer :: Maybe String } + -- | RefType is perhaps not a good name for this... -- It is sort of like a read/write flag, although -- semantically, it is indicating the intention of @@ -192,9 +212,9 @@ iswallet :: FileType -> Bool iswallet (WalletFile {}) = True iswallet _ = False -initializer :: RefType -> Maybe Initializer -initializer (MutableRef x) = x -initializer _ = Nothing +rtyp_initializer :: RefType -> Maybe Initializer +rtyp_initializer (MutableRef x) = x +rtyp_initializer _ = Nothing getUsage :: MonadPlus m => FileType -> m UsageTag @@ -210,7 +230,7 @@ data KeyRingRuntime = KeyRingRuntime , rtKeyDB :: KeyDB } --- | TODO: Packet Update should have deletiong action +-- | TODO: Packet Update should have deletion action -- and any other kind of roster-entry level -- action. data PacketUpdate = InducerSignature String [SignatureSubpacket] @@ -992,7 +1012,7 @@ buildKeyDB doDecrypt secring pubring grip0 keyring = do (topspec,subspec) <- fmap (parseSpec grip) $ getUsage ftyp n <- resolveInputFile secring pubring n let ms = map fst $ filterMatches topspec (Map.toList db) - cmd = initializer rtyp + cmd = rtyp_initializer rtyp return (n,subspec,ms,cmd) imports <- filterM (\(n,_,_,_) -> doesFileExist n) pems db <- foldM (importPEMKey doDecrypt) (KikiSuccess (db,[])) imports @@ -1565,7 +1585,7 @@ initializeMissingPEMFiles operation secring pubring grip decrypt db = do ns = do (kk,kd) <- filterMatches topspec $ Map.toList db return (kk , subkeysForExport subspec kd) - return (fname,subspec,ns,initializer rtyp) + return (fname,subspec,ns,rtyp_initializer rtyp) (exports0,ambiguous) = partition (\(_,_,ns,_)->null $ drop 1 $ (ns>>=snd)) notmissing exports = map (\(f,subspec,ns,cmd) -> (f,subspec,ns >>= snd,cmd)) exports0 -- cgit v1.2.3