Permalink
Browse files

added comments

  • Loading branch information...
1 parent 515b149 commit 5c85b42821083017eb6298033da9327f271b49fd Andreas-Christoph Bernstein committed Nov 6, 2011
Showing with 6 additions and 4 deletions.
  1. +6 −4 Main.hs
View
10 Main.hs
@@ -93,6 +93,9 @@ processTmsg _ (Tread "/0/name" byteCount offset) = do
return . Rread . B.take (fromIntegral byteCount)
. B.drop (fromIntegral offset) . (`B.append` "\n"). addr
. connection =<< get
+processTmsg _ (Tread {}) = return Rerror
+
+-- process Treaddir
processTmsg _ (Treaddir "/") = do
ks <- (IM.keys . targets . connection) <$> get
let ds = [(".", defaultDirStat) ,
@@ -107,8 +110,6 @@ processTmsg _ (Treaddir _) = do
subDir = zip (map showFilepath subDirFiles) (map fileStat subDirFiles)
return (Rreaddir ds)
-processTmsg _ (Tread {}) = return Rerror
-
-- process Twrite
processTmsg ircoutc (Twrite "/ctl" s offset) = do
-- Todo if a msg is longer than 512 then split it into chunks
@@ -143,6 +144,7 @@ processTmsg _ (Topen p _ _) = return Ropen
-- process Tstat
processTmsg _ (Tstat p) = maybe Rerror Rstat . (`stat` p) <$> get
+-- | Process incommint irc messages.
processIrc :: IrcOut -> I.Message -> Ircfs ()
processIrc ircoutc (I.Message _ I.PING ps) = do
stamp <- timeStamp
@@ -164,14 +166,14 @@ processIrc _ (I.Message p I.JOIN (c:ps)) = do
k <- nextDirName
modify $ L.setL (targetLens k.connectionLens) (Just (Target k TChannel c [] mempty))
modify $ L.setL (targetMapLens' c.connectionLens) (Just k)
- appendEvent . B.pack $ "new " ++ show k ++ "\n"
+ appendEvent . B.pack $ "new " ++ show k ++ " " ++ show c ++ "\n"
processIrc _ (I.Message p I.PART (c:ps)) = do
m <- L.getL (targetMapLens' c.connectionLens) <$> get
maybe (return ()) (\k -> do
modify (L.setL (targetLens k.connectionLens) Nothing)
modify (L.setL (targetMapLens' c.connectionLens) Nothing)
freeDirName k
- appendEvent (B.pack ("del " ++ show k ++ "\n"))
+ appendEvent (B.pack ("del " ++ show k ++ " " ++ show c ++ "\n"))
) m
processIrc _ m = return ()

0 comments on commit 5c85b42

Please sign in to comment.