Copyright | (c) Ruben Astudillo 2019 |
---|---|
License | ISC |
Maintainer | ruben.astud@gmail.com |
Safe Haskell | None |
Language | Haskell2010 |
This module provides ADTs and functions to deal with DCC SEND/ACCEPT request and how start such transfers.
Synopsis
- data DCCState = DCCState {
- _dsOffers :: !(IntMap DCCOffer)
- _dsTransfers :: !(IntMap DCCTransfer)
- dsOffers :: Lens' DCCState (IntMap DCCOffer)
- dsTransfers :: Lens' DCCState (IntMap DCCTransfer)
- emptyDCCState :: DCCState
- data DCCOffer = DCCOffer {
- _dccNetwork :: !Text
- _dccFromInfo :: !UserInfo
- _dccFromIP :: HostName
- _dccPort :: !PortNumber
- _dccFileName :: FilePath
- _dccSize :: !Word32
- _dccOffset :: !Word32
- _dccStatus :: !ConnectionStatus
- dccNetwork :: Lens' DCCOffer Text
- dccFromInfo :: Lens' DCCOffer UserInfo
- dccFromIP :: Lens' DCCOffer HostName
- dccPort :: Lens' DCCOffer PortNumber
- dccFileName :: Lens' DCCOffer FilePath
- dccSize :: Lens' DCCOffer Word32
- dccOffset :: Lens' DCCOffer Word32
- dccStatus :: Lens' DCCOffer ConnectionStatus
- data DCCTransfer = DCCTransfer {
- _dtThread :: !(Maybe (Async ()))
- _dtProgress :: !Word32
- dtThread :: Lens' DCCTransfer (Maybe (Async ()))
- dtProgress :: Lens' DCCTransfer Word32
- data ConnectionStatus
- data DCCUpdate
- = PercentUpdate !Key !Word32
- | Finished !Key
- | SocketInterrupted !Key
- | UserInterrupted !Key
- | Accept !Key !PortNumber !Word32
- supervisedDownload :: FilePath -> Key -> TChan DCCUpdate -> DCCState -> IO DCCState
- parseSEND :: Text -> UserInfo -> Text -> Either String DCCOffer
- parseACCEPT :: DCCState -> UserInfo -> Text -> Maybe DCCUpdate
- resumeMsg :: Word32 -> DCCOffer -> (String, String)
- acceptUpdate :: DCCUpdate -> DCCState -> DCCState
- getFileOffset :: FilePath -> IO (Maybe Word32)
- insertAsNewMax :: DCCOffer -> DCCState -> DCCState
- ctcpToTuple :: IrcMsg -> Maybe (UserInfo, Identifier, Text, Text)
- statusAtKey :: Key -> DCCState -> ConnectionStatus
- reportStopWithStatus :: Key -> ConnectionStatus -> DCCState -> DCCState
- isSend :: Text -> Bool
Documentation
DCCState | |
|
DCC offers
All the necessary information to start the download
DCCOffer | |
|
DCC transfer
data DCCTransfer Source #
Structure with information of a download accepted via "/dcc accept" or "/dcc resume"
DCCTransfer | |
|
data ConnectionStatus Source #
Status of a connection at certain Key
Instances
Eq ConnectionStatus Source # | |
Defined in Client.State.DCC (==) :: ConnectionStatus -> ConnectionStatus -> Bool # (/=) :: ConnectionStatus -> ConnectionStatus -> Bool # | |
Show ConnectionStatus Source # | |
Defined in Client.State.DCC showsPrec :: Int -> ConnectionStatus -> ShowS # show :: ConnectionStatus -> String # showList :: [ConnectionStatus] -> ShowS # |
DCC Update
Transfer a DCCOffer
supervisedDownload :: FilePath -> Key -> TChan DCCUpdate -> DCCState -> IO DCCState Source #
Launch a supervisor thread for downloading the offer referred by Key
and
return the DCCState accordingly.
Parser for DCC request
parseACCEPT :: DCCState -> UserInfo -> Text -> Maybe DCCUpdate Source #
Parse a "DCC RESUME" command.
DCC RESUME functionality
Craft a CTCP message indicating we want to resume a download at the offset.
acceptUpdate :: DCCUpdate -> DCCState -> DCCState Source #
Modify the DCCState
following the corresponding DCCUpdate
Miscellaneous
ctcpToTuple :: IrcMsg -> Maybe (UserInfo, Identifier, Text, Text) Source #
statusAtKey :: Key -> DCCState -> ConnectionStatus Source #
Check the status of a download at Key
by checking the invariants
at DCCState
reportStopWithStatus :: Key -> ConnectionStatus -> DCCState -> DCCState Source #
This function can only be called after a cancel
has been issued
on the supervisor thread at Key