summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2013-07-07 00:21:34 -0400
committerjoe <joe@jerkface.net>2013-07-07 00:21:34 -0400
commit9080a6583fc0515c4a8a086cf5f23d08ec2dc260 (patch)
treebfb9ccd6b9d408d996c3ff1f4417aa5afa16593c
parentf183eca9bc5b531f32ec9302e7c9a538a88beb9c (diff)
getters for three new lists: others,pending,solicited.
-rw-r--r--Presence/ConfigFiles.hs31
1 files 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
18configDir = ".presence" 18configDir = ".presence"
19buddyFile = "buddies" 19buddyFile = "buddies"
20subscriberFile = "subscribers" 20subscriberFile = "subscribers"
21otherFile = "others"
22pendingFile = "pending"
23solicitedFile = "solicited"
21 24
22buddyPath :: User -> IO String
23buddyPath user = do
24 ue <- getUserEntryForName (unpack user)
25 return $ (++("/"++configDir++"/"++buddyFile)) $ homeDirectory ue
26 25
27subscriberPath :: User -> IO String 26configPath :: User -> String -> IO String
28subscriberPath user = do 27configPath user filename = do
29 ue <- getUserEntryForName (unpack user) 28 ue <- getUserEntryForName (unpack user)
30 return $ (++("/"++configDir++"/"++subscriberFile)) $ homeDirectory ue 29 return $ (++("/"++configDir++"/"++filename)) $ homeDirectory ue
30
31 31
32createConfigFile tag path = do 32createConfigFile tag path = do
33 let dir = dropFileName path 33 let dir = dropFileName path
@@ -47,11 +47,11 @@ addItem item tag path =
47 47
48addBuddy :: User -> ByteString -> IO () 48addBuddy :: User -> ByteString -> IO ()
49addBuddy user buddy = 49addBuddy user buddy =
50 buddyPath user >>= addItem buddy "<? buddies ?>" 50 configPath user buddyFile >>= addItem buddy "<? buddies ?>"
51 51
52addSubscriber :: User -> ByteString -> IO () 52addSubscriber :: User -> ByteString -> IO ()
53addSubscriber user subscriber = 53addSubscriber user subscriber =
54 subscriberPath user >>= addItem subscriber "<? subscribers ?>" 54 configPath user subscriberFile >>= addItem subscriber "<? subscribers ?>"
55 55
56getConfigList path = 56getConfigList path =
57 handle (\e -> if isDoesNotExistError e then (return []) else throw e) 57 handle (\e -> if isDoesNotExistError e then (return []) else throw e)
@@ -61,7 +61,16 @@ getConfigList path =
61 >=> (\a -> seq (rnf a) (return a)) 61 >=> (\a -> seq (rnf a) (return a))
62 62
63getBuddies :: User -> IO [ByteString] 63getBuddies :: User -> IO [ByteString]
64getBuddies user = buddyPath user >>= getConfigList 64getBuddies user = configPath user buddyFile >>= getConfigList
65 65
66getSubscribers :: User -> IO [ByteString] 66getSubscribers :: User -> IO [ByteString]
67getSubscribers user = subscriberPath user >>= getConfigList 67getSubscribers user = configPath user subscriberFile >>= getConfigList
68
69getOthers :: User -> IO [ByteString]
70getOthers user = configPath user otherFile >>= getConfigList
71
72getPending :: User -> IO [ByteString]
73getPending user = configPath user pendingFile >>= getConfigList
74
75getSolicited :: User -> IO [ByteString]
76getSolicited user = configPath user solicitedFile >>= getConfigList