diff options
Diffstat (limited to 'src/Network/BitTorrent/Client/Handle.hs')
-rw-r--r-- | src/Network/BitTorrent/Client/Handle.hs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/Network/BitTorrent/Client/Handle.hs b/src/Network/BitTorrent/Client/Handle.hs index 2da3b357..a1bc163c 100644 --- a/src/Network/BitTorrent/Client/Handle.hs +++ b/src/Network/BitTorrent/Client/Handle.hs | |||
@@ -14,11 +14,10 @@ module Network.BitTorrent.Client.Handle | |||
14 | 14 | ||
15 | -- * Query | 15 | -- * Query |
16 | , getHandle | 16 | , getHandle |
17 | , HandleState | 17 | , HandleStatus (..) |
18 | , getState | 18 | , getStatus |
19 | ) where | 19 | ) where |
20 | 20 | ||
21 | import Control.Applicative | ||
22 | import Control.Concurrent.Lifted as L | 21 | import Control.Concurrent.Lifted as L |
23 | import Control.Monad | 22 | import Control.Monad |
24 | import Control.Monad.Trans | 23 | import Control.Monad.Trans |
@@ -50,7 +49,7 @@ allocHandle ih m = do | |||
50 | 49 | ||
51 | freeHandle :: InfoHash -> BitTorrent () -> BitTorrent () | 50 | freeHandle :: InfoHash -> BitTorrent () -> BitTorrent () |
52 | freeHandle ih finalizer = do | 51 | freeHandle ih finalizer = do |
53 | c @ Client {..} <- getClient | 52 | Client {..} <- getClient |
54 | modifyMVar_ clientTorrents $ \ handles -> do | 53 | modifyMVar_ clientTorrents $ \ handles -> do |
55 | case HM.lookup ih handles of | 54 | case HM.lookup ih handles of |
56 | Nothing -> return handles | 55 | Nothing -> return handles |
@@ -90,7 +89,7 @@ openTorrent rootPath t @ Torrent {..} = do | |||
90 | 89 | ||
91 | -- | Use 'nullMagnet' to open handle from 'InfoHash'. | 90 | -- | Use 'nullMagnet' to open handle from 'InfoHash'. |
92 | openMagnet :: FilePath -> Magnet -> BitTorrent Handle | 91 | openMagnet :: FilePath -> Magnet -> BitTorrent Handle |
93 | openMagnet rootPath uri @ Magnet {..} = do | 92 | openMagnet rootPath Magnet {..} = do |
94 | allocHandle exactTopic $ do | 93 | allocHandle exactTopic $ do |
95 | tses <- liftIO $ Tracker.newSession exactTopic def | 94 | tses <- liftIO $ Tracker.newSession exactTopic def |
96 | eses <- newExchangeSession rootPath (Left exactTopic) | 95 | eses <- newExchangeSession rootPath (Left exactTopic) |
@@ -149,7 +148,7 @@ stop Handle {..} = do | |||
149 | -- Query | 148 | -- Query |
150 | -----------------------------------------------------------------------} | 149 | -----------------------------------------------------------------------} |
151 | 150 | ||
152 | data HandleState | 151 | data HandleStatus |
153 | = Running | 152 | = Running |
154 | | Paused | 153 | | Paused |
155 | | Stopped | 154 | | Stopped |
@@ -161,5 +160,5 @@ getHandle ih = do | |||
161 | Nothing -> error "should we throw some exception?" | 160 | Nothing -> error "should we throw some exception?" |
162 | Just h -> return h | 161 | Just h -> return h |
163 | 162 | ||
164 | getState :: Handle -> IO HandleState | 163 | getStatus :: Handle -> IO HandleStatus |
165 | getState = undefined \ No newline at end of file | 164 | getStatus = undefined |