module Holumbus.FileSystem.Node.NodePort
(
NodePort
, newNodePort
)
where
import Holumbus.Common.Debug
import Holumbus.Network.Communication
import Holumbus.FileSystem.Messages
import Holumbus.FileSystem.Node
data NodePort = NodePort ClientPort
deriving (Show)
newNodePort :: ClientPort -> NodePort
newNodePort p = NodePort p
instance NodeClass NodePort where
closeNode _ = return ()
createFile i c (NodePort p)
= do
sendRequestToClient p time30 (NReqCreate i c) $
\rsp ->
do
case rsp of
(NRspSuccess) -> return (Just ())
_ -> return Nothing
createFiles l (NodePort p)
= do
sendRequestToClient p time60 (NReqCreateS l) $
\rsp ->
do
case rsp of
(NRspSuccess) -> return (Just ())
_ -> return Nothing
appendFile i c (NodePort p)
= do
sendRequestToClient p time30 (NReqAppend i c) $
\rsp ->
do
case rsp of
(NRspSuccess) -> return (Just ())
_ -> return Nothing
deleteFile i b (NodePort p)
= do
sendRequestToClient p time30 (NReqDelete i b) $
\rsp ->
do
case rsp of
(NRspSuccess) -> return (Just ())
_ -> return Nothing
copyFile i cp (NodePort p)
= do
sendRequestToClient p time30 (NReqCopy i cp) $
\rsp ->
do
case rsp of
(NRspSuccess) -> return (Just ())
_ -> return Nothing
containsFile i (NodePort p)
= do
sendRequestToClient p time30 (NReqContains i) $
\rsp ->
do
case rsp of
(NRspContains b) -> return (Just b)
_ -> return Nothing
getFileContent i (NodePort p)
= do
sendRequestToClient p time30 (NReqGetFileContent i) $
\rsp ->
do
case rsp of
(NRspGetFileContent c) -> return (Just c)
_ -> return Nothing
getMultiFileContent l (NodePort p)
= do
sendRequestToClient p time30 (NReqGetMultiFileContent l) $
\rsp ->
do
case rsp of
(NRspGetMultiFileContent lc) -> return (Just lc)
_ -> return Nothing
getFileData i (NodePort p)
= do
sendRequestToClient p time30 (NReqGetFileData i) $
\rsp ->
do
case rsp of
(NRspGetFileData d) -> return (Just d)
_ -> return Nothing
getFileIds (NodePort p)
= do
sendRequestToClient p time30 (NReqGetFileIds) $
\rsp ->
do
case rsp of
(NRspGetFileIds ls) -> return (Just ls)
_ -> return Nothing
instance Debug NodePort where
printDebug (NodePort p)
= do
putStrLn "NodePort:"
putStrLn $ show p
getDebug (NodePort p)
= return ("NodePort:\n"++show p++"\n")