From 9080a6583fc0515c4a8a086cf5f23d08ec2dc260 Mon Sep 17 00:00:00 2001 From: joe Date: Sun, 7 Jul 2013 00:21:34 -0400 Subject: getters for three new lists: others,pending,solicited. --- Presence/ConfigFiles.hs | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/Presence/ConfigFiles.hs b/Presence/ConfigFiles.hs index 6d36f4cd..d0d2ef63 100644 --- a/Presence/ConfigFiles.hs +++ b/Presence/ConfigFiles.hs @@ -18,16 +18,16 @@ type User = ByteString configDir = ".presence" buddyFile = "buddies" subscriberFile = "subscribers" +otherFile = "others" +pendingFile = "pending" +solicitedFile = "solicited" -buddyPath :: User -> IO String -buddyPath user = do - ue <- getUserEntryForName (unpack user) - return $ (++("/"++configDir++"/"++buddyFile)) $ homeDirectory ue -subscriberPath :: User -> IO String -subscriberPath user = do +configPath :: User -> String -> IO String +configPath user filename = do ue <- getUserEntryForName (unpack user) - return $ (++("/"++configDir++"/"++subscriberFile)) $ homeDirectory ue + return $ (++("/"++configDir++"/"++filename)) $ homeDirectory ue + createConfigFile tag path = do let dir = dropFileName path @@ -47,11 +47,11 @@ addItem item tag path = addBuddy :: User -> ByteString -> IO () addBuddy user buddy = - buddyPath user >>= addItem buddy "" + configPath user buddyFile >>= addItem buddy "" addSubscriber :: User -> ByteString -> IO () addSubscriber user subscriber = - subscriberPath user >>= addItem subscriber "" + configPath user subscriberFile >>= addItem subscriber "" getConfigList path = handle (\e -> if isDoesNotExistError e then (return []) else throw e) @@ -61,7 +61,16 @@ getConfigList path = >=> (\a -> seq (rnf a) (return a)) getBuddies :: User -> IO [ByteString] -getBuddies user = buddyPath user >>= getConfigList +getBuddies user = configPath user buddyFile >>= getConfigList getSubscribers :: User -> IO [ByteString] -getSubscribers user = subscriberPath user >>= getConfigList +getSubscribers user = configPath user subscriberFile >>= getConfigList + +getOthers :: User -> IO [ByteString] +getOthers user = configPath user otherFile >>= getConfigList + +getPending :: User -> IO [ByteString] +getPending user = configPath user pendingFile >>= getConfigList + +getSolicited :: User -> IO [ByteString] +getSolicited user = configPath user solicitedFile >>= getConfigList -- cgit v1.2.3