summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2014-04-14 20:01:02 -0400
committerjoe <joe@jerkface.net>2014-04-14 20:01:02 -0400
commit294cda407d82c6b98b63ac21fea3b937ed1c4bb5 (patch)
tree7e85f3240f268d63f5678674f88a009cc455d45e
parent832e580497558deccca59622e2c2fc395a854130 (diff)
progress on buildKeyDB
-rw-r--r--KeyRing.hs27
1 files changed, 19 insertions, 8 deletions
diff --git a/KeyRing.hs b/KeyRing.hs
index 2a80930..5547673 100644
--- a/KeyRing.hs
+++ b/KeyRing.hs
@@ -277,17 +277,24 @@ data KeySpec =
277 277
278 278
279buildKeyDB :: FilePath -> FilePath -> Maybe String -> KeyRingData 279buildKeyDB :: FilePath -> FilePath -> Maybe String -> KeyRingData
280 -> IO ((KeyDB,String),[(FilePath,KikiReportAction)]) 280 -> IO ((KeyDB,Maybe String),[(FilePath,KikiReportAction)])
281buildKeyDB secring pubring grip0 keyring = do 281buildKeyDB secring pubring grip0 keyring = do
282 let rings = do 282 let isring (KeyRingFile {}) = True
283 isring _ = False
284
285 iswallet WalletFile = True
286 iswallet _ = False
287
288 files isring = do
283 (f,(rtyp,ftyp)) <- Map.toList (kFiles keyring) 289 (f,(rtyp,ftyp)) <- Map.toList (kFiles keyring)
284 let isring (KeyRingFile {}) = True
285 isring _ = False
286 guard (isring ftyp) 290 guard (isring ftyp)
287 resolveInputFile secring pubring f 291 resolveInputFile secring pubring f
292
288 readp n = fmap (n,) (readPacketsFromFile n) 293 readp n = fmap (n,) (readPacketsFromFile n)
294
289 readw wk n = fmap (n,) (readPacketsFromWallet wk n) 295 readw wk n = fmap (n,) (readPacketsFromWallet wk n)
290 ms <- mapM readp rings 296
297 ms <- mapM readp (files isring)
291 let grip = grip0 `mplus` (fingerprint <$> fstkey) 298 let grip = grip0 `mplus` (fingerprint <$> fstkey)
292 where 299 where
293 fstkey = listToMaybe $ mapMaybe isSecringKey ms 300 fstkey = listToMaybe $ mapMaybe isSecringKey ms
@@ -300,8 +307,12 @@ buildKeyDB secring pubring grip0 keyring = do
300 guard $ matchSpec (KeyGrip fp) elm 307 guard $ matchSpec (KeyGrip fp) elm
301 return $ keyPacket (snd elm) 308 return $ keyPacket (snd elm)
302 db0 = foldl' (uncurry . merge) Map.empty ms 309 db0 = foldl' (uncurry . merge) Map.empty ms
303 db <- return db0 -- todo 310
304 return ( (db, todo), todo ) 311 wms <- mapM (readw wk) (files iswallet)
312
313 (db,report) <- return (db0,[]) -- todo
314
315 return ( (db, grip), report )
305 316
306runKeyRing :: KeyRingData -> (KeyRingRuntime -> a) -> IO (KikiResult a) 317runKeyRing :: KeyRingData -> (KeyRingRuntime -> a) -> IO (KikiResult a)
307runKeyRing keyring op = do 318runKeyRing keyring op = do
@@ -325,7 +336,7 @@ runKeyRing keyring op = do
325 , rtSecring = secring 336 , rtSecring = secring
326 , rtRings = [] -- todo secring:pubring:keyringFiles keyring 337 , rtRings = [] -- todo secring:pubring:keyringFiles keyring
327 , rtWallets = [] -- todo walletFiles keyring 338 , rtWallets = [] -- todo walletFiles keyring
328 , rtGrip = grip0 339 , rtGrip = grip
329 , rtKeyDB = db 340 , rtKeyDB = db
330 } 341 }
331 report2 <- todo -- write files 342 report2 <- todo -- write files