summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent.hs
diff options
context:
space:
mode:
authorSam T <pxqr.sta@gmail.com>2013-07-16 07:48:12 +0400
committerSam T <pxqr.sta@gmail.com>2013-07-16 07:48:12 +0400
commit8c6e5818ee6b901efd975392c54aff5cf2721ae4 (patch)
tree85508d873378f3c0bfac21d09107ba6ff6155346 /src/Network/BitTorrent.hs
parent7ad3fd1f6fe3c6719b69f3638542f24b32a3b09c (diff)
~ A few fixes in session.
Diffstat (limited to 'src/Network/BitTorrent.hs')
-rw-r--r--src/Network/BitTorrent.hs26
1 files changed, 9 insertions, 17 deletions
diff --git a/src/Network/BitTorrent.hs b/src/Network/BitTorrent.hs
index 26824724..ad96a1b8 100644
--- a/src/Network/BitTorrent.hs
+++ b/src/Network/BitTorrent.hs
@@ -9,11 +9,11 @@
9module Network.BitTorrent 9module Network.BitTorrent
10 ( module Data.Torrent 10 ( module Data.Torrent
11 11
12 , TorrentLoc(..), Progress(..) 12 , TorrentLoc(..), TorrentMap, Progress(..)
13 , ThreadCount, SessionCount 13 , ThreadCount, SessionCount
14 14
15 , ClientSession( clientPeerId, allowedExtensions ) 15 , ClientSession( clientPeerId, allowedExtensions )
16 , withDefaultClient, defaultThreadCount 16 , withDefaultClient, defaultThreadCount, defaultPorts
17 , addTorrent 17 , addTorrent
18 , removeTorrent 18 , removeTorrent
19 19
@@ -21,6 +21,8 @@ module Network.BitTorrent
21 , getPeerCount 21 , getPeerCount
22 , getSwarmCount 22 , getSwarmCount
23 , getSessionCount 23 , getSessionCount
24 , getSwarm
25 , getStorage
24 26
25 -- * Extensions 27 -- * Extensions
26 , Extension 28 , Extension
@@ -33,6 +35,7 @@ import Data.Torrent
33import Network.BitTorrent.Sessions.Types 35import Network.BitTorrent.Sessions.Types
34import Network.BitTorrent.Sessions 36import Network.BitTorrent.Sessions
35import Network.BitTorrent.Extension 37import Network.BitTorrent.Extension
38import Network.BitTorrent.Tracker
36 39
37-- TODO remove fork from Network.BitTorrent.Exchange 40-- TODO remove fork from Network.BitTorrent.Exchange
38-- TODO make all forks in Internal. 41-- TODO make all forks in Internal.
@@ -46,22 +49,11 @@ withDefaultClient listPort dhtPort action = do
46 Torrent management 49 Torrent management
47-----------------------------------------------------------------------} 50-----------------------------------------------------------------------}
48 51
49-- | Used to check torrent location before register torrent.
50validateLocation :: TorrentLoc -> IO Torrent
51validateLocation TorrentLoc {..} = do
52 t <- fromFile metafilePath
53-- exists <- doesDirectoryExist dataDirPath
54-- unless exists $ do
55-- throw undefined
56 return t
57
58
59-- | Register torrent and start downloading. 52-- | Register torrent and start downloading.
60addTorrent :: ClientSession -> TorrentLoc -> IO () 53addTorrent :: ClientSession -> TorrentLoc -> IO ()
61addTorrent clientSession loc @ TorrentLoc {..} = do 54addTorrent cs loc @ TorrentLoc {..} = do
62 torrent <- validateLocation loc 55 registerTorrent cs loc
63-- registerTorrent loc tInfoHash 56 openSwarmSession cs loc
64-- when (bf is not full)
65 return () 57 return ()
66 58
67-- | Unregister torrent and stop all running sessions. 59-- | Unregister torrent and stop all running sessions.
@@ -73,4 +65,4 @@ removeTorrent ses loc = undefined -- atomically $ unregisterTorrent ses loc
73-- content files. 65-- content files.
74deleteTorrent :: ClientSession -> TorrentLoc -> IO () 66deleteTorrent :: ClientSession -> TorrentLoc -> IO ()
75deleteTorrent ClientSession {..} TorrentLoc {..} = undefined 67deleteTorrent ClientSession {..} TorrentLoc {..} = undefined
76-} \ No newline at end of file 68-}