-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | A DCC message parsing and helper library for IRC clients
--   
--   DCC (Direct Client-to-Client) is an IRC sub-protocol for establishing
--   and maintaining direct connections to exchange messages and files.
--   
--   See <a>http://www.irchelp.org/irchelp/rfc/ctcpspec.html</a> for more
--   details.
@package irc-dcc
@version 2.0.1

module Network.IRC.DCC.Internal

-- | CTCP commands that can be parsed and encoded
class CtcpCommand a
toCtcp :: CtcpCommand a => a -> CTCPByteString
fromCtcp :: CtcpCommand a => CTCPByteString -> Either String a
parseCtcp :: Parser a -> CTCPByteString -> Either String a

-- | Offer DCC chat session
data DccChat

-- | Text messages exchange
--   
--   <pre>
--   DCC CHAT chat &lt;ip&gt; &lt;port&gt;
--   </pre>
Chat :: !IPv4 -> !PortNumber -> DccChat

-- | Drawing commands exchange
--   
--   <pre>
--   DCC CHAT wboard &lt;ip&gt; &lt;port&gt;
--   </pre>
ChatWhiteboard :: !IPv4 -> !PortNumber -> DccChat

-- | Signal intent to close DCC chat connection
data DccClose

-- | <pre>
--   DCC CLOSE
--   </pre>
Close :: DccClose

-- | Offer DCC file transfer
data DccSend

-- | As part of the standard DCC protocol, sent by the server
--   
--   <pre>
--   DCC SEND &lt;path&gt; &lt;ip&gt; &lt;port&gt; (&lt;fileSize&gt;)
--   </pre>
Send :: !Path -> !IPv4 -> !PortNumber -> !(Maybe FileOffset) -> DccSend

-- | As part of the Reverse DCC protocol, sent by the server
--   
--   <pre>
--   DCC SEND &lt;path&gt; &lt;ip&gt; 0 &lt;fileSize&gt; &lt;token&gt;
--   </pre>
SendReverseServer :: !Path -> !IPv4 -> !FileOffset -> !Token -> DccSend

-- | Signal intent to resume DCC file transfer at specific position
data DccResume

-- | As part of the standard DCC protocol, sent by the client
--   
--   <pre>
--   DCC RESUME &lt;path&gt; &lt;port&gt; &lt;position&gt;
--   </pre>
Resume :: !Path -> !PortNumber -> !FileOffset -> DccResume

-- | As part of the Reverse DCC protocol, sent by the client
--   
--   <pre>
--   DCC RESUME &lt;path&gt; 0 &lt;position&gt; &lt;token&gt;
--   </pre>
ResumeReverse :: !Path -> !FileOffset -> !Token -> DccResume

-- | Signal acceptance to resume DCC file transfer at specific position
data DccAccept

-- | As part of the standard DCC protocol, sent by the server
--   
--   <pre>
--   DCC ACCEPT &lt;path&gt; &lt;port&gt; &lt;position&gt;
--   </pre>
Accept :: !Path -> !PortNumber -> !FileOffset -> DccAccept

-- | As part of the Reverse DCC protocol, sent by the server
--   
--   <pre>
--   DCC ACCEPT &lt;path&gt; 0 &lt;position&gt; &lt;token&gt;
--   </pre>
AcceptReverse :: !Path -> !FileOffset -> !Token -> DccAccept
acceptedPosition :: DccAccept -> FileOffset

-- | Tell the server to start a DCC file transfer and where it should send
--   the data to.
data DccSendReverseClient

-- | As part of the Reverse DCC protocol, sent by the client
--   
--   <pre>
--   DCC SEND &lt;path&gt; &lt;ip&gt; &lt;port&gt; &lt;fileSize&gt; &lt;token&gt;
--   </pre>
SendReverseClient :: !Path -> !IPv4 -> !PortNumber -> !FileOffset -> !Token -> DccSendReverseClient
data PathType

-- | A file path without spaces
Simple :: PathType

-- | A file path that can include spaces and will be quoted when serialized
Quoted :: PathType
data Path
Rel :: PathType -> (Path Rel File) -> Path
Abs :: PathType -> (Path Abs File) -> Path
fromPath :: Path -> Path Rel File
path :: Parser Path
pathToBS :: Path -> ByteString
wrap :: PathType -> ByteString -> ByteString
newtype FileOffset
FileOffset :: Word64 -> FileOffset
[toWord] :: FileOffset -> Word64
fileOffset :: Parser FileOffset
fileOffsetToBS :: FileOffset -> ByteString

-- | An identifier for knowing which negotiation a request belongs to
newtype Token
Token :: ByteString -> Token
token :: Parser Token
tokenToBS :: Token -> ByteString
socket :: Parser (IPv4, PortNumber)
socketToBS :: (IPv4, PortNumber) -> ByteString
ipBigEndian :: Parser IPv4
ipToBigEndianBS :: IPv4 -> ByteString
fromBigEndianIp :: Integer -> IPv4
toBigEndianIp :: IPv4 -> Integer
tcpPort :: Parser PortNumber
tcpPortToBS :: PortNumber -> ByteString
decimalInRange :: (Integer, Integer) -> Parser Integer
spaced :: Parser a -> Parser a
instance GHC.Show.Show Network.IRC.DCC.Internal.DccSend
instance GHC.Classes.Eq Network.IRC.DCC.Internal.DccSend
instance GHC.Show.Show Network.IRC.DCC.Internal.DccResume
instance GHC.Classes.Eq Network.IRC.DCC.Internal.DccResume
instance GHC.Show.Show Network.IRC.DCC.Internal.DccAccept
instance GHC.Classes.Eq Network.IRC.DCC.Internal.DccAccept
instance GHC.Show.Show Network.IRC.DCC.Internal.DccSendReverseClient
instance GHC.Classes.Eq Network.IRC.DCC.Internal.DccSendReverseClient
instance GHC.Show.Show Network.IRC.DCC.Internal.Token
instance GHC.Classes.Eq Network.IRC.DCC.Internal.Token
instance GHC.Enum.Bounded Network.IRC.DCC.Internal.FileOffset
instance GHC.Real.Real Network.IRC.DCC.Internal.FileOffset
instance GHC.Enum.Enum Network.IRC.DCC.Internal.FileOffset
instance GHC.Real.Integral Network.IRC.DCC.Internal.FileOffset
instance GHC.Num.Num Network.IRC.DCC.Internal.FileOffset
instance GHC.Classes.Ord Network.IRC.DCC.Internal.FileOffset
instance GHC.Classes.Eq Network.IRC.DCC.Internal.FileOffset
instance GHC.Show.Show Network.IRC.DCC.Internal.Path
instance GHC.Classes.Eq Network.IRC.DCC.Internal.Path
instance GHC.Show.Show Network.IRC.DCC.Internal.PathType
instance GHC.Classes.Eq Network.IRC.DCC.Internal.PathType
instance GHC.Show.Show Network.IRC.DCC.Internal.DccClose
instance GHC.Classes.Eq Network.IRC.DCC.Internal.DccClose
instance GHC.Show.Show Network.IRC.DCC.Internal.DccChat
instance GHC.Classes.Eq Network.IRC.DCC.Internal.DccChat
instance Network.IRC.DCC.Internal.CtcpCommand Network.IRC.DCC.Internal.DccChat
instance Network.IRC.DCC.Internal.CtcpCommand Network.IRC.DCC.Internal.DccClose
instance Network.IRC.DCC.Internal.CtcpCommand Network.IRC.DCC.Internal.DccSend
instance Network.IRC.DCC.Internal.CtcpCommand Network.IRC.DCC.Internal.DccResume
instance Network.IRC.DCC.Internal.CtcpCommand Network.IRC.DCC.Internal.DccAccept
instance Network.IRC.DCC.Internal.CtcpCommand Network.IRC.DCC.Internal.DccSendReverseClient
instance GHC.Show.Show Network.IRC.DCC.Internal.FileOffset


-- | DCC command parsing and encoding module.
--   
--   Use the <a>CtcpCommand</a> type class to convert between
--   <tt>CTCPByteString</tt>s and typed values.
--   
--   Try converting a <tt>CTCPByteString</tt> to a <a>DccSend</a> value:
--   
--   <pre>
--   fromCtcp ctcpMessage :: Either String DccSend
--   </pre>
--   
--   Encoding a <a>DccSend</a> value to a <tt>CTCPByteString</tt>:
--   
--   <pre>
--   toCtcp (Send fileName ip port (Just fileSize))
--   </pre>
module Network.IRC.DCC

-- | CTCP commands that can be parsed and encoded
class CtcpCommand a
toCtcp :: CtcpCommand a => a -> CTCPByteString
fromCtcp :: CtcpCommand a => CTCPByteString -> Either String a

-- | Offer DCC chat session
data DccChat

-- | Text messages exchange
--   
--   <pre>
--   DCC CHAT chat &lt;ip&gt; &lt;port&gt;
--   </pre>
Chat :: !IPv4 -> !PortNumber -> DccChat

-- | Drawing commands exchange
--   
--   <pre>
--   DCC CHAT wboard &lt;ip&gt; &lt;port&gt;
--   </pre>
ChatWhiteboard :: !IPv4 -> !PortNumber -> DccChat

-- | Signal intent to close DCC chat connection
data DccClose

-- | <pre>
--   DCC CLOSE
--   </pre>
Close :: DccClose

-- | Offer DCC file transfer
data DccSend

-- | As part of the standard DCC protocol, sent by the server
--   
--   <pre>
--   DCC SEND &lt;path&gt; &lt;ip&gt; &lt;port&gt; (&lt;fileSize&gt;)
--   </pre>
Send :: !Path -> !IPv4 -> !PortNumber -> !(Maybe FileOffset) -> DccSend

-- | As part of the Reverse DCC protocol, sent by the server
--   
--   <pre>
--   DCC SEND &lt;path&gt; &lt;ip&gt; 0 &lt;fileSize&gt; &lt;token&gt;
--   </pre>
SendReverseServer :: !Path -> !IPv4 -> !FileOffset -> !Token -> DccSend

-- | Signal intent to resume DCC file transfer at specific position
data DccResume

-- | As part of the standard DCC protocol, sent by the client
--   
--   <pre>
--   DCC RESUME &lt;path&gt; &lt;port&gt; &lt;position&gt;
--   </pre>
Resume :: !Path -> !PortNumber -> !FileOffset -> DccResume

-- | As part of the Reverse DCC protocol, sent by the client
--   
--   <pre>
--   DCC RESUME &lt;path&gt; 0 &lt;position&gt; &lt;token&gt;
--   </pre>
ResumeReverse :: !Path -> !FileOffset -> !Token -> DccResume

-- | Signal acceptance to resume DCC file transfer at specific position
data DccAccept

-- | As part of the standard DCC protocol, sent by the server
--   
--   <pre>
--   DCC ACCEPT &lt;path&gt; &lt;port&gt; &lt;position&gt;
--   </pre>
Accept :: !Path -> !PortNumber -> !FileOffset -> DccAccept

-- | As part of the Reverse DCC protocol, sent by the server
--   
--   <pre>
--   DCC ACCEPT &lt;path&gt; 0 &lt;position&gt; &lt;token&gt;
--   </pre>
AcceptReverse :: !Path -> !FileOffset -> !Token -> DccAccept
acceptedPosition :: DccAccept -> FileOffset

-- | Tell the server to start a DCC file transfer and where it should send
--   the data to.
data DccSendReverseClient

-- | As part of the Reverse DCC protocol, sent by the client
--   
--   <pre>
--   DCC SEND &lt;path&gt; &lt;ip&gt; &lt;port&gt; &lt;fileSize&gt; &lt;token&gt;
--   </pre>
SendReverseClient :: !Path -> !IPv4 -> !PortNumber -> !FileOffset -> !Token -> DccSendReverseClient

-- | Try resuming a file offer
resumeFromSend :: DccSend -> FileOffset -> DccResume

-- | Check if a <a>DccSend</a> and a <a>DccAccept</a> command are part of
--   the same negotiation.
matchesSend :: DccAccept -> DccSend -> Bool
data Path
Rel :: PathType -> (Path Rel File) -> Path
Abs :: PathType -> (Path Abs File) -> Path
fromPath :: Path -> Path Rel File
data PathType

-- | A file path without spaces
Simple :: PathType

-- | A file path that can include spaces and will be quoted when serialized
Quoted :: PathType
data FileOffset

-- | An identifier for knowing which negotiation a request belongs to
newtype Token
Token :: ByteString -> Token


-- | Functions for receiving files.
--   
--   Each chunk is acknowledged by sending the total sum of bytes received
--   for a file. See the <a>CTCP specification</a>.
module Network.IRC.DCC.Client.FileTransfer

-- | Accept a DCC file offer
acceptFile :: DccSend -> (PortNumber -> IO ()) -> (FileOffset -> IO ()) -> ReaderT (Maybe PortNumber) IO ()

-- | Accept a DCC file offer for a partially downloaded file
resumeFile :: DccSend -> DccAccept -> (PortNumber -> IO ()) -> (FileOffset -> IO ()) -> ReaderT (Maybe PortNumber) IO ()

-- | A description of a file transfer. You can specify a callback that will
--   be called with the number of bytes transfered for each chunk.
data FileTransfer m
Download :: !(Path Rel File) -> !(ConnectionType m) -> !TransferType -> (FileOffset -> m ()) -> FileTransfer m
[_fileName] :: FileTransfer m -> !(Path Rel File)
[_connectionType] :: FileTransfer m -> !(ConnectionType m)
[_transferType] :: FileTransfer m -> !TransferType
[_onChunk] :: FileTransfer m -> FileOffset -> m ()
data ConnectionType m

-- | Connects to other party on specified port. With callback when socket
--   is ready.
Active :: !IPv4 -> !PortNumber -> (m ()) -> ConnectionType m

-- | Binds to local port and waits for connection by other party. If no
--   port number is provided, one will be provided by the OS. With callback
--   when socket is ready.
Passive :: !IPv4 -> !(Maybe PortNumber) -> (PortNumber -> m ()) -> ConnectionType m
data TransferType
FromStart :: TransferType
ResumeFrom :: !FileOffset -> TransferType
transfer :: (MonadMask m, MonadIO m) => FileTransfer m -> m ()
