rtorrent-rpc 0.2.0.0 → 0.2.1.0
raw patch · 6 files changed
+58/−20 lines, 6 filesdep +utf8-stringdep ~haxrPVP ok
version bump matches the API change (PVP)
Dependencies added: utf8-string
Dependency ranges changed: haxr
API changes (from Hackage documentation)
+ Network.RTorrent.Command.Internals: decodeUtf8 :: String -> String
+ Network.RTorrent.Torrent: closeStop :: TorrentId -> TorrentAction Int
+ Network.RTorrent.Torrent: stop :: TorrentId -> TorrentAction Int
Files
- Network/RTorrent/Command/Internals.hs +6/−0
- Network/RTorrent/CommandList.hs +1/−1
- Network/RTorrent/File.hs +3/−3
- Network/RTorrent/RPC.hs +7/−2
- Network/RTorrent/Torrent.hs +13/−3
- rtorrent-rpc.cabal +28/−11
Network/RTorrent/Command/Internals.hs view
@@ -23,6 +23,7 @@ , getArray , getArray' , single+ , decodeUtf8 ) where import Control.Applicative@@ -30,6 +31,8 @@ import Control.Monad.Error import Control.Monad.Identity +import qualified Codec.Binary.UTF8.String as U+ import Data.List.Split (splitPlaces) import Network.XmlRpc.Internals@@ -100,6 +103,9 @@ -- | Parse a value wrapped in two singleton arrays. parseSingle :: (Monad m, XmlRpcType a) => Value -> m a parseSingle = parseValue <=< single <=< single++decodeUtf8 :: String -> String+decodeUtf8 = U.decodeString -- | A newtype wrapper for method calls. --
Network/RTorrent/CommandList.hs view
@@ -102,7 +102,7 @@ -- | Get the default download directory. getDirectory :: Global String-getDirectory = commandSimple "get_directory"+getDirectory = fmap decodeUtf8 $ commandSimple "get_directory" -- | Get the maximum upload rate, in bytes per second. --
Network/RTorrent/File.hs view
@@ -33,7 +33,7 @@ import Network.RTorrent.Action.Internals import Network.RTorrent.Torrent-import Network.RTorrent.Command+import Network.RTorrent.Command.Internals import Network.RTorrent.Priority import Network.XmlRpc.Internals @@ -85,11 +85,11 @@ -- | Get the file name relative to the torrent base directory. getFilePath :: FileId -> FileAction String-getFilePath = simpleAction "f.path" []+getFilePath = fmap decodeUtf8 . simpleAction "f.path" [] -- | Get the absolute path. getFileAbsolutePath :: FileId -> FileAction String-getFileAbsolutePath = simpleAction "f.frozen_path" []+getFileAbsolutePath = fmap decodeUtf8 . simpleAction "f.frozen_path" [] getFileSizeBytes :: FileId -> FileAction Int getFileSizeBytes = simpleAction "f.size_bytes" []
Network/RTorrent/RPC.hs view
@@ -100,6 +100,7 @@ ) where import Control.Monad.Error (ErrorT(..), throwError, strMsg)+import Control.Exception import Data.Monoid import qualified Data.ByteString as BS import qualified Data.ByteString.Lazy as LB@@ -133,5 +134,9 @@ -> a -> IO (Either String (Ret a)) callRTorrent host port command = - runErrorT $ - C.commandValue command =<< callRTorrentRaw host port (C.commandCall command)+ (runErrorT $ do+ ret <- callRTorrentRaw host port (C.commandCall command)+ C.commandValue command ret) + `catches` [ Handler (\e -> return . Left $ show (e :: IOException))+ , Handler (\e -> return . Left $ show (e :: PatternMatchFail))]+
Network/RTorrent/Torrent.hs view
@@ -16,6 +16,8 @@ -- * Functions for handling torrents , start , close+ , stop+ , closeStop , erase , checkHash , getTorrent@@ -46,6 +48,7 @@ import Network.XmlRpc.Internals import Network.RTorrent.Action.Internals+import Network.RTorrent.Command.Internals import Network.RTorrent.Priority -- | A newtype wrapper for torrent identifiers.@@ -112,6 +115,13 @@ close :: TorrentId -> TorrentAction Int close = simpleAction "d.close" [] +-- | Stop a torrent. +stop :: TorrentId -> TorrentAction Int+stop = simpleAction "d.stop" []++closeStop :: TorrentId -> TorrentAction Int+closeStop = fmap (\(a :*: b) -> a + b) . (close <+> stop)+ -- | Erase a torrent. erase :: TorrentId -> TorrentAction Int erase = simpleAction "d.erase" []@@ -128,16 +138,16 @@ getTorrentId = simpleAction "d.hash" [] getTorrentName :: TorrentId -> TorrentAction String-getTorrentName = simpleAction "d.get_name" []+getTorrentName = fmap decodeUtf8 . simpleAction "d.get_name" [] -- | Get the absolute path to the torrent's directory or file. getTorrentPath :: TorrentId -> TorrentAction String-getTorrentPath = simpleAction "d.get_base_path" []+getTorrentPath = fmap decodeUtf8 . simpleAction "d.get_base_path" [] -- | Get the absolute path to the directory in which the torrent's directory or -- file resides. getTorrentDir :: TorrentId -> TorrentAction String-getTorrentDir = simpleAction "d.get_directory" []+getTorrentDir = fmap decodeUtf8 . simpleAction "d.get_directory" [] setTorrentDir :: String -> TorrentId -> TorrentAction Int setTorrentDir dir = simpleAction "d.set_directory" [PString dir]
rtorrent-rpc.cabal view
@@ -1,30 +1,47 @@ name: rtorrent-rpc-version: 0.2.0.0+version: 0.2.1.0 synopsis: A library for communicating with RTorrent over its XML-RPC interface.--- description: +description: + A library for communicating with RTorrent over its XML-RPC interface. license: MIT license-file: LICENSE author: Kai Lindholm maintainer: megantti@gmail.com homepage: https://github.com/megantti/rtorrent-rpc--- copyright: +copyright: (c) Kai Lindholm, 2014 category: Network build-type: Simple -- extra-source-files: cabal-version: >=1.10 library- exposed-modules: Network.RTorrent, Network.RTorrent.RPC, Network.RTorrent.CommandList, - Network.RTorrent.Command, Network.RTorrent.Torrent, Network.RTorrent.File,- Network.RTorrent.Action, Network.RTorrent.Priority, Network.RTorrent.Peer, - Network.RTorrent.Tracker, Network.RTorrent.Command.Internals,+ exposed-modules: Network.RTorrent+ Network.RTorrent.Action Network.RTorrent.Action.Internals+ Network.RTorrent.Command+ Network.RTorrent.Command.Internals+ Network.RTorrent.CommandList + Network.RTorrent.File+ Network.RTorrent.Peer + Network.RTorrent.Priority+ Network.RTorrent.RPC+ Network.RTorrent.Torrent+ Network.RTorrent.Tracker+ other-modules: Network.RTorrent.SCGI other-extensions: TypeFamilies, OverloadedStrings, TypeOperators, ScopedTypeVariables, GADTs, FlexibleContexts, RankNTypes- build-depends: base >=4.7 && <4.8, mtl >=2.1 && < 2.3, bytestring >=0.10 && <0.11, - network >=2.6, haxr >=3000.10 && <3000.11, blaze-builder >=0.3 && <0.4, - blaze-textual >=0.2 && <0.3, attoparsec >=0.12 && <0.13, deepseq >= 1.3.0.0, - split >=0.2.0.0+ build-depends: base >=4.7 && <4.8,+ mtl >=2.1 && <2.3,+ bytestring >=0.10 && <0.11 ,+ network >=2.6,+ haxr >=3000.10.3.1 && <3000.11,+ blaze-builder >=0.3 && <0.4,+ blaze-textual >=0.2 && <0.3,+ attoparsec >=0.12 && <0.13,+ deepseq >= 1.3.0.0,+ split >=0.2.0.0,+ utf8-string >= 0.3 && <0.4 -- hs-source-dirs: default-language: Haskell2010+ ghc-options: -O2