Skip to content
Browse files

support for npages

  • Loading branch information...
1 parent 1893244 commit 9340e172795ad4c1e124b6e19b25bd5a0e71998e @wavewave committed Jan 5, 2012
View
6 lib/Database/HXournal/IDMap/Client/Command.hs
@@ -6,10 +6,12 @@ import Database.HXournal.IDMap.Client.Config
import Data.Configurator
commandLineProcess :: HXournalIDMapClient -> IO ()
+{-
commandLineProcess (Create cfg mn) = do
putStrLn "create called"
mc <- getHXournalIDMapClientConfiguration =<< load [Required cfg]
maybe (error "cannot parse config") (\x -> startCreate x mn Nothing) mc
+-}
commandLineProcess (Get cfg n) = do
putStrLn "get called"
mc <- getHXournalIDMapClientConfiguration =<< load [Required cfg]
@@ -32,3 +34,7 @@ commandLineProcess (CreateWithFile cfg fn) = do
putStrLn "create called"
mc <- getHXournalIDMapClientConfiguration =<< load [Required cfg]
maybe (error "cannot parse config") (\x -> startCreateWithFile x fn) mc
+commandLineProcess (GetListWithTime cfg t1 t2) = do
+ putStrLn "getlist called"
+ mc <- getHXournalIDMapClientConfiguration =<< load [Required cfg]
+ maybe (error "cannot parse config") (\x -> startGetListWithTime x t1 t2) mc
View
17 lib/Database/HXournal/IDMap/Client/Job.hs
@@ -51,20 +51,19 @@ startCreateWithFile mc fname = do
if not b
then error "no such file"
else do
+ npages <- startAdd (toString uuid) (cwd </> fname )
fstatus <- getFileStatus fname
let etime = modificationTime fstatus
utctime = posixSecondsToUTCTime (realToFrac etime)
let info = HXournalIDMapInfo { hxournal_idmap_uuid = uuid
, hxournal_idmap_name = fname
, hxournal_idmap_creationtime = utctime
+ , hxournal_idmap_numofpages = npages
}
response <- hxournalIDMapToServer url ("uploadhxournalidmap") methodPost info
putStrLn $ show response
-
- startAdd (toString uuid) (cwd </> fname )
-
-
+{-
startCreate :: HXournalIDMapClientConfiguration
-> String
-> Maybe UTCTime
@@ -81,7 +80,7 @@ startCreate mc name mctime = do
}
response <- hxournalIDMapToServer url ("uploadhxournalidmap") methodPost info
putStrLn $ show response
-
+-}
startGet :: HXournalIDMapClientConfiguration -> String -> IO ()
startGet mc idee = do
@@ -124,6 +123,14 @@ startGetList mc = do
r <- jsonFromServer url ("listhxournalidmap") methodGet
putStrLn $ show r
+startGetListWithTime :: HXournalIDMapClientConfiguration -> String -> String -> IO ()
+startGetListWithTime mc t1 t2 = do
+ putStrLn "getlistwithtime"
+ let url = hxournalIDMapServerURL mc
+ r <- jsonFromServer url ("listhxournalidmap" </> t1 </> t2) methodGet
+ putStrLn $ show r
+
+
jsonFromServer :: Url -> String -> Method -> IO (Either String (Result Value))
jsonFromServer url api mthd = do
View
15 lib/Database/HXournal/IDMap/Client/ProgType.hs
@@ -11,18 +11,20 @@ data HXournalIDMapClient = Create { config :: FilePath, modulename :: String }
| Delete { config :: FilePath, name :: String }
| GetList { config :: FilePath }
| CreateWithFile { config :: FilePath, filename :: FilePath }
+ | GetListWithTime { config :: FilePath, time1 :: String, time2 :: String }
deriving (Show,Data,Typeable)
-create :: HXournalIDMapClient
+{- create :: HXournalIDMapClient
create = Create { config = "test.conf"
, modulename = "" &= typ "MODULENAME" &= argPos 0
- }
+ } -}
get :: HXournalIDMapClient
get = Get { config = "test.conf"
, name = "" &= typ "NAME" &= argPos 0
}
+{-
put :: HXournalIDMapClient
put = Put { config = "test.conf"
, name = "" &= typ "NAME" &= argPos 0
@@ -33,14 +35,21 @@ delete :: HXournalIDMapClient
delete = Delete { config = "test.conf"
, name = "" &= typ "NAME" &= argPos 0
}
+-}
getlist :: HXournalIDMapClient
getlist = GetList { config = "test.conf" }
+getlistwithtime :: HXournalIDMapClient
+getlistwithtime = GetListWithTime { config = "test.conf"
+ , time1 = "" &= typ "TIMESTART" &= argPos 0
+ , time2 = "" &= typ "TIMEEND" &= argPos 1
+ }
+
createwithfile :: HXournalIDMapClient
createwithfile = CreateWithFile { config = "test.conf"
, filename = "" &= typ "FILENAME" &= argPos 0 }
-mode = modes [ create, get, put, delete, getlist, createwithfile ]
+mode = modes [ {- create, -} get, {- put, delete, -} getlist, createwithfile, getlistwithtime ]

0 comments on commit 9340e17

Please sign in to comment.
Something went wrong with that request. Please try again.