summaryrefslogtreecommitdiff
path: root/src/Data/Torrent
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2013-11-23 02:14:13 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2013-11-23 02:14:13 +0400
commit41f229b5746501738800d721fb19083e32516f8c (patch)
tree8a469cf08a3d5d377fb8679bba759393cc7d8ef2 /src/Data/Torrent
parent923abc9ee7576f2d3e1b7e2b2d5a32ed5d2f21c9 (diff)
Remove ClientVersion newtype
Diffstat (limited to 'src/Data/Torrent')
-rw-r--r--src/Data/Torrent/Client.hs30
1 files changed, 10 insertions, 20 deletions
diff --git a/src/Data/Torrent/Client.hs b/src/Data/Torrent/Client.hs
index 0246e29a..a7e94513 100644
--- a/src/Data/Torrent/Client.hs
+++ b/src/Data/Torrent/Client.hs
@@ -21,15 +21,9 @@
21-- done using 'Network.BitTorrent.Extension'! 21-- done using 'Network.BitTorrent.Extension'!
22-- 22--
23module Data.Torrent.Client 23module Data.Torrent.Client
24 ( -- * Client implementation 24 ( ClientImpl (..)
25 ClientImpl (..)
26 , ppClientImpl 25 , ppClientImpl
27 26 , ppVersion
28 -- * Client version
29 , ClientVersion (..)
30 , ppClientVersion
31
32 -- * Client information
33 , ClientInfo (..) 27 , ClientInfo (..)
34 , ppClientInfo 28 , ppClientInfo
35 , libClientInfo 29 , libClientInfo
@@ -122,23 +116,19 @@ instance Default ClientImpl where
122ppClientImpl :: ClientImpl -> Doc 116ppClientImpl :: ClientImpl -> Doc
123ppClientImpl = text . L.tail . show 117ppClientImpl = text . L.tail . show
124 118
125-- | Version of client software, normally extracted from peer id.
126newtype ClientVersion = ClientVersion { getClientVersion :: Version }
127 deriving (Show, Eq, Ord)
128
129-- | Just the '0' version. 119-- | Just the '0' version.
130instance Default ClientVersion where 120instance Default Version where
131 def = ClientVersion $ Version [0] [] 121 def = Version [0] []
132 122
133-- | Format client implementation version in human-readable form. 123-- | Format client implementation version in human-readable form.
134ppClientVersion :: ClientVersion -> Doc 124ppVersion :: Version -> Doc
135ppClientVersion = text . showVersion . getClientVersion 125ppVersion = text . showVersion
136 126
137-- | The all sensible infomation that can be obtained from a peer 127-- | The all sensible infomation that can be obtained from a peer
138-- identifier or torrent /createdBy/ field. 128-- identifier or torrent /createdBy/ field.
139data ClientInfo = ClientInfo { 129data ClientInfo = ClientInfo {
140 ciImpl :: ClientImpl 130 ciImpl :: ClientImpl
141 , ciVersion :: ClientVersion 131 , ciVersion :: Version
142 } deriving (Show, Eq, Ord) 132 } deriving (Show, Eq, Ord)
143 133
144-- | Unrecognized client implementation. 134-- | Unrecognized client implementation.
@@ -148,14 +138,14 @@ instance Default ClientInfo where
148-- | Format client info in human-readable form. 138-- | Format client info in human-readable form.
149ppClientInfo :: ClientInfo -> Doc 139ppClientInfo :: ClientInfo -> Doc
150ppClientInfo ClientInfo {..} = 140ppClientInfo ClientInfo {..} =
151 ppClientImpl ciImpl <+> "version" <+> ppClientVersion ciVersion 141 ppClientImpl ciImpl <+> "version" <+> ppVersion ciVersion
152 142
153-- | Client info of this (the bittorrent library) package. Normally, 143-- | Client info of this (the bittorrent library) package. Normally,
154-- applications should introduce its own idenitifiers, otherwise they 144-- applications should introduce its own idenitifiers, otherwise they
155-- can use 'libClientInfo' value. 145-- can use 'libClientInfo' value.
156-- 146--
157libClientInfo :: ClientInfo 147libClientInfo :: ClientInfo
158libClientInfo = ClientInfo IlibHSbittorrent (ClientVersion version) 148libClientInfo = ClientInfo IlibHSbittorrent version
159 149
160{----------------------------------------------------------------------- 150{-----------------------------------------------------------------------
161-- For torrent file 151-- For torrent file
@@ -164,7 +154,7 @@ libClientInfo = ClientInfo IlibHSbittorrent (ClientVersion version)
164renderImpl :: ClientImpl -> Text 154renderImpl :: ClientImpl -> Text
165renderImpl = T.pack . L.tail . show 155renderImpl = T.pack . L.tail . show
166 156
167renderVersion :: ClientVersion -> Text 157renderVersion :: Version -> Text
168renderVersion = undefined 158renderVersion = undefined
169 159
170renderClientInfo :: ClientInfo -> Text 160renderClientInfo :: ClientInfo -> Text