-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | An efficient IMAP client library, with SSL and streaming -- -- This is an IMAP library for Haskell that aims to be efficient, easy to -- use, transparent when it comes to underlying libraries and support -- results streaming. To this end it employs ListT, so you can use -- it with any concurrency management library of your choosing. -- -- It tries to implement RFC-3501 as faithfully as possible, -- diverging from it where we noticed that servers have different ideas. -- If you want to understand this library, it's highly recommended to -- skim through that RFC first. -- -- Usage -- -- For a description of types used in this tutorial or an in-depth -- description of functions presented, please check the documentation or -- the source code. -- -- All of the commands will output their results in ListT and -- MonadIO. Results consist of a list of UntaggedResults -- followed by a single TaggedResult that describes the command -- state (if it succeeded or failed). -- -- We provide a helper function that simplifies the output types for the -- cases when you don't care about the streaming and just want a list of -- UntaggedResults or an error message. Depending on your needs -- you will probably use it for all the commands that are not -- FETCH. -- -- Also, remember that you probably have to keep the connection alive so -- that the server doesn't disconnect you. Send a noop from time -- to time to achieve that. -- -- Simple, no streaming -- -- You need a connection object first, so that you can execute commands -- on it. It's produced by connectServer, which accepts parameters -- from Network.Connection. Say you want to connect to gmail: -- --
--   import Network.Connection
--   import Network.IMAP
--   import Network.IMAP.Types
--   
-- --
--   let tls = TLSSettingsSimple False False False
--   let params = ConnectionParams "imap.gmail.com" 993 (Just tls) Nothing
--   conn <- connectServer params Nothing
--   
-- -- From now on you can run commands on this connection. The second -- parameter to connectServer is `Maybe IMAPSettings`. If settings -- are not provided, sane defaults will be used. We will use the -- simpleFormat helper function to convert from ListT to -- IO. Let's log in: -- --
--   simpleFormat $ login conn "mylogin" "mypass"
--    Right [Capabilities [CIMAP4,CUnselect,CIdle,CNamespace,CQuota,CId,CExperimental "XLIST",CChildren,CExperimental "X-GM-EXT-1",CUIDPlus,CCompress "DEFLATE",CEnable,CMove,CCondstore,CEsearch,CUtf8 "ACCEPT",CListExtended,CListStatus,CAppendLimit 35882577]]
--   
-- -- You can see that the server replied with a CAPABILITIES reply -- and the login was successful. Next, let's select an inbox: -- --
--   simpleFormat $ select conn "inbox2"
--    Left "[NONEXISTENT] Unknown Mailbox: inbox2 (Failure)"
--   
-- -- Oh, let's fix that -- --
--   simpleFormat $ select conn "inbox"
--    Right [Flags [FAnswered,FFlagged,FDraft,FDeleted,FSeen,FOther "$NotPhishing",FOther "$Phishing",FOther "NonJunk"],PermanentFlags [FAnswered,FFlagged,FDraft,FDeleted,FSeen,FOther "$NotPhishing",FOther "$Phishing",FOther "NonJunk",FAny],UIDValidity 1,Exists 65,Recent 0,UIDNext 1050,HighestModSeq 251971]
--   
-- -- Again you can use the metadata if you wish to. Let's see what messages -- we have (consult the RFC if you're unsure about the parameter -- to uidSearch): -- --
--   simpleFormat $ uidSearch conn "ALL"
--    Right [Search [105,219,411,424,425,748,763,770,774,819,824,825,..]]
--   
-- -- Fetching a message is straigtforward as well: -- --
--   simpleFormat $ uidFetch conn "219"
--   Right [Fetch [MessageId 2,UID 219,Body "Delivered-To: michal@monad.cat\r\nReceived: by...
--   
-- -- If you need more control on the parameters of fetch, there is a more -- general function available: -- --
--   simpleFormat $ uidFetchG conn "219 ALL"
--   
-- -- Do you want multiple messages in one reply? That's easy with UID -- ranges! -- --
--   simpleFormat $ uidFetchG conn "219:9000 RFC822.SIZE"
--   Right [Fetch [MessageId 2,UID 219,Size 4880],Fetch [MessageId 3,UID 411,Size 7392],...]
--   
-- -- That's where streaming comes in handy - if these were message bodies -- you would probably like to do something with them before all are -- downloaded. -- -- Replies we didn't expect -- -- IMAP protocol allows for messages pushed to the client at any time, -- even when they're not requested. This is used to notify the client -- that a new message had arrived, or as status of a message had changed -- as it was read by another client. These server messages wait for you -- in a bounded message queue and you can read them like: -- --
--   import qualified Data.STM.RollingQueue as RQ
--   msgs <- atomically . RQ.read . untaggedQueue $ conn
--   
-- -- Where conn is the connection from previous step. -- -- Streaming -- -- There's an excellent article by Gabriel Gonzalez you should -- read :) @package imap @version 0.3.0.2 module Network.IMAP.Types -- | A type alias used for an error message type ErrorMessage = Text -- | Each command sent to the server is identified by a random id. this -- alias helps noticing where this happens type CommandId = ByteString -- | Connection with the server can be in one of these states data ConnectionState UndefinedState :: ConnectionState Connected :: ConnectionState Disconnected :: ConnectionState data IMAPConnection IMAPConnection :: TVar ConnectionState -> RollingQueue UntaggedResult -> IMAPState -> IMAPConnection -- | The current connection state [connectionState] :: IMAPConnection -> TVar ConnectionState -- | Contains commands sent by the server which we didn't expect. Probably -- message and mailbox state updates [untaggedQueue] :: IMAPConnection -> RollingQueue UntaggedResult -- | Internal state of the library [imapState] :: IMAPConnection -> IMAPState data IMAPState IMAPState :: !Connection -> ConnectionContext -> TQueue ResponseRequest -> TVar (Maybe ThreadId) -> TVar [ResponseRequest] -> IMAPSettings -> IMAPState -- | The actual connection with the server from Network.Connection. Only -- use if you know what you're doing [rawConnection] :: IMAPState -> !Connection -- | Context from Network.Connection [connectionContext] :: IMAPState -> ConnectionContext -- | Contains requests for response that weren't yet read by the watcher -- thread. [responseRequests] :: IMAPState -> TQueue ResponseRequest -- | Id of the thread the watcher executes on [serverWatcherThread] :: IMAPState -> TVar (Maybe ThreadId) -- | All the unfulfilled requests the watcher thread knows about [outstandingReqs] :: IMAPState -> TVar [ResponseRequest] -- | Configuration settings [imapSettings] :: IMAPState -> IMAPSettings type ParseResult = Either ErrorMessage CommandResult data ResponseRequest ResponseRequest :: TQueue CommandResult -> CommandId -> ResponseRequest -- | Thread that posted the request should watch this queue for responses -- to the request. [responseQueue] :: ResponseRequest -> TQueue CommandResult -- | Id of the request, which is the same as the id sent to the server. [respRequestId] :: ResponseRequest -> CommandId data IMAPSettings IMAPSettings :: Int -> Int -> IMAPSettings [imapTimeout] :: IMAPSettings -> Int [untaggedQueueLength] :: IMAPSettings -> Int data EmailAddress EmailAddress :: Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> EmailAddress [emailLabel] :: EmailAddress -> Maybe Text [emailRoute] :: EmailAddress -> Maybe Text [emailUsername] :: EmailAddress -> Maybe Text [emailDomain] :: EmailAddress -> Maybe Text data Flag FSeen :: Flag FAnswered :: Flag FFlagged :: Flag FDeleted :: Flag FDraft :: Flag FRecent :: Flag FAny :: Flag FOther :: Text -> Flag data Capability CIMAP4 :: Capability CUnselect :: Capability CIdle :: Capability CNamespace :: Capability CQuota :: Capability CId :: Capability CExperimental :: Text -> Capability CChildren :: Capability CUIDPlus :: Capability CCompress :: Text -> Capability CEnable :: Capability CMove :: Capability CCondstore :: Capability CEsearch :: Capability CUtf8 :: Text -> Capability CAuth :: Text -> Capability CListExtended :: Capability CListStatus :: Capability CAppendLimit :: Int -> Capability -- | First parameter is the name of a capability and the second can contain -- a value, if the capability is of the form `NAME=VALUE` COther :: Text -> (Maybe Text) -> Capability -- | Always the last result of the command, contains it's metadata data TaggedResult TaggedResult :: CommandId -> !ResultState -> Text -> TaggedResult -- | Id of the command that completes [commandId] :: TaggedResult -> CommandId -- | State returned by the server side [resultState] :: TaggedResult -> !ResultState -- | Rest of the result, usually the human-readable part [resultRest] :: TaggedResult -> Text -- | Tagged results can be in on of these three states data ResultState OK :: ResultState NO :: ResultState BAD :: ResultState -- | Untagged replies are the actual data returned in response to the -- commands. data UntaggedResult -- | A list of flags a mailbox has Flags :: [Flag] -> UntaggedResult -- | How many messages exist in a mailbox Exists :: Integer -> UntaggedResult -- | Sequence id of a deleted message Expunge :: Integer -> UntaggedResult -- | Returned by the server when it cleanly disconnects Bye :: UntaggedResult HighestModSeq :: Integer -> UntaggedResult -- | Number of recent messages Recent :: Integer -> UntaggedResult -- | Number of messages in a mailbox Messages :: Integer -> UntaggedResult -- | Number of unseen messages Unseen :: Integer -> UntaggedResult PermanentFlags :: [Flag] -> UntaggedResult -- | UID of a message UID :: Integer -> UntaggedResult -- | A sequence id of a message |UID that will be given to the next message -- added to this mailbox MessageId :: Integer -> UntaggedResult UIDNext :: Integer -> UntaggedResult -- | A triple of mailbox name, it's UIDValidity value and message UID is -- always unique for a given message UIDValidity :: Integer -> UntaggedResult -- | Result of an OK response OKResult :: Text -> UntaggedResult -- | What server advertises that it supports |Response to the LIST -- command Capabilities :: [Capability] -> UntaggedResult ListR :: [NameAttribute] -> Text -> Text -> UntaggedResult -- | flags that a mailbox has |Character sequence that marks a new level of -- hierarchy in the inbox name (usually a slash) [flags] :: UntaggedResult -> [NameAttribute] [hierarchyDelimiter] :: UntaggedResult -> Text -- | Name of the mailbox [inboxName] :: UntaggedResult -> Text -- | Fetch response, contains many responses |Status of a mailbox, will -- contain many different responses inside Fetch :: [UntaggedResult] -> UntaggedResult StatusR :: Text -> [UntaggedResult] -> UntaggedResult -- | A list of message IDs or UIDs fullfilling the search criterions Search :: [Integer] -> UntaggedResult -- | A parsed ENVELOPE reply, prefixed to avoid name clashes Envelope :: Maybe Text -> Maybe Text -> Maybe [EmailAddress] -> Maybe [EmailAddress] -> Maybe [EmailAddress] -> Maybe [EmailAddress] -> Maybe [EmailAddress] -> Maybe [EmailAddress] -> Maybe Text -> Maybe Text -> UntaggedResult [eDate] :: UntaggedResult -> Maybe Text [eSubject] :: UntaggedResult -> Maybe Text [eFrom] :: UntaggedResult -> Maybe [EmailAddress] [eSender] :: UntaggedResult -> Maybe [EmailAddress] [eReplyTo] :: UntaggedResult -> Maybe [EmailAddress] [eTo] :: UntaggedResult -> Maybe [EmailAddress] [eCC] :: UntaggedResult -> Maybe [EmailAddress] [eBCC] :: UntaggedResult -> Maybe [EmailAddress] [eInReplyTo] :: UntaggedResult -> Maybe Text [eMessageId] :: UntaggedResult -> Maybe Text InternalDate :: Text -> UntaggedResult -- | Message size Size :: Integer -> UntaggedResult -- | An unsupported value Unknown :: ByteString -> UntaggedResult -- | Message body, or headers Body :: ByteString -> UntaggedResult -- | An unparsed bodystructure BodyStructure :: ByteString -> UntaggedResult data NameAttribute Noinferiors :: NameAttribute Noselect :: NameAttribute Marked :: NameAttribute Unmarked :: NameAttribute HasNoChildren :: NameAttribute OtherNameAttr :: Text -> NameAttribute -- | Command result consits of a sequence of untagged results followed by a -- single tagged result that specifies if the command overall succeeded. -- This is a sum type to bind those two types together data CommandResult Tagged :: TaggedResult -> CommandResult Untagged :: UntaggedResult -> CommandResult -- | If you don't care about streaming you will get results in this -- simplified data type, in which the ErrorMessage comes from -- TaggedResult if it failed. type SimpleResult = Either ErrorMessage [UntaggedResult] -- | Every function that communicates with the outside world should run in -- the Universe monad, which provides an ability to use mocks when -- testing class Monad m => Universe m connectionPut' :: Universe m => Connection -> ByteString -> m () connectionGetChunk'' :: Universe m => Connection -> (ByteString -> (a, ByteString)) -> m a defaultImapSettings :: IMAPSettings isFOther :: Flag -> Bool isFAny :: Flag -> Bool isFRecent :: Flag -> Bool isFDraft :: Flag -> Bool isFDeleted :: Flag -> Bool isFFlagged :: Flag -> Bool isFAnswered :: Flag -> Bool isFSeen :: Flag -> Bool isBodyStructure :: UntaggedResult -> Bool isBody :: UntaggedResult -> Bool isUnknown :: UntaggedResult -> Bool isSize :: UntaggedResult -> Bool isInternalDate :: UntaggedResult -> Bool isEnvelope :: UntaggedResult -> Bool isSearch :: UntaggedResult -> Bool isStatusR :: UntaggedResult -> Bool isFetch :: UntaggedResult -> Bool isListR :: UntaggedResult -> Bool isCapabilities :: UntaggedResult -> Bool isOKResult :: UntaggedResult -> Bool isUIDValidity :: UntaggedResult -> Bool isUIDNext :: UntaggedResult -> Bool isMessageId :: UntaggedResult -> Bool isUID :: UntaggedResult -> Bool isPermanentFlags :: UntaggedResult -> Bool isUnseen :: UntaggedResult -> Bool isMessages :: UntaggedResult -> Bool isRecent :: UntaggedResult -> Bool isHighestModSeq :: UntaggedResult -> Bool isBye :: UntaggedResult -> Bool isExpunge :: UntaggedResult -> Bool isExists :: UntaggedResult -> Bool isFlags :: UntaggedResult -> Bool isUntagged :: CommandResult -> Bool isTagged :: CommandResult -> Bool isDisconnected :: ConnectionState -> Bool isConnected :: ConnectionState -> Bool isUndefinedState :: ConnectionState -> Bool instance GHC.Classes.Eq Network.IMAP.Types.ResponseRequest instance GHC.Classes.Eq Network.IMAP.Types.CommandResult instance GHC.Show.Show Network.IMAP.Types.CommandResult instance GHC.Classes.Eq Network.IMAP.Types.UntaggedResult instance GHC.Show.Show Network.IMAP.Types.UntaggedResult instance GHC.Classes.Ord Network.IMAP.Types.NameAttribute instance GHC.Classes.Eq Network.IMAP.Types.NameAttribute instance GHC.Show.Show Network.IMAP.Types.NameAttribute instance GHC.Classes.Eq Network.IMAP.Types.TaggedResult instance GHC.Show.Show Network.IMAP.Types.TaggedResult instance GHC.Classes.Eq Network.IMAP.Types.ResultState instance GHC.Show.Show Network.IMAP.Types.ResultState instance GHC.Classes.Ord Network.IMAP.Types.Capability instance GHC.Classes.Eq Network.IMAP.Types.Capability instance GHC.Show.Show Network.IMAP.Types.Capability instance GHC.Classes.Ord Network.IMAP.Types.Flag instance GHC.Classes.Eq Network.IMAP.Types.Flag instance GHC.Show.Show Network.IMAP.Types.Flag instance GHC.Classes.Eq Network.IMAP.Types.EmailAddress instance GHC.Show.Show Network.IMAP.Types.EmailAddress instance GHC.Show.Show Network.IMAP.Types.ConnectionState instance Network.IMAP.Types.Universe GHC.Types.IO instance Network.IMAP.Types.Universe (ListT.ListT GHC.Types.IO) instance Network.IMAP.Types.Universe (Pipes.ListT GHC.Types.IO) module Network.IMAP.Utils genRequestId :: IO ByteString readResults :: (MonadPlus m, MonadIO m, Universe m) => IMAPState -> ResponseRequest -> m CommandResult escapeText :: Text -> Text ifNotDisconnected :: (MonadPlus m, MonadIO m) => IMAPConnection -> m CommandResult -> m CommandResult flagsToText :: [Flag] -> ByteString module Network.IMAP.Parsers.Utils eatUntilClosingParen :: Parser ByteString hadClosedAllParens :: Int -> Char -> Maybe Int parseEmailList :: Parser [EmailAddress] parseNString :: Parser Text parseEmail :: Parser EmailAddress nilOrValue :: Parser a -> Parser (Maybe a) parseQuotedText :: Parser Text parseNameAttribute :: Parser NameAttribute parseListLikeResp :: ByteString -> Parser UntaggedResult atomSpecials :: Set Char isAtomChar :: Char -> Bool toInt :: ByteString -> Either ErrorMessage Integer parseNumber :: (Integer -> a) -> ByteString -> ByteString -> Parser (Either ErrorMessage a) module Network.IMAP.Parsers.Untagged parseOk :: Parser UntaggedResult parseFlag :: Parser Flag parseFlagKeyword :: Parser Flag parseFlagList :: Parser [Flag] parseFlags :: Parser (Either ErrorMessage UntaggedResult) parseExists :: Parser (Either ErrorMessage UntaggedResult) parseBye :: Parser UntaggedResult parseRecent :: Parser (Either ErrorMessage UntaggedResult) parseOkResp :: Parser a -> Parser a parseUnseen :: Parser (Either ErrorMessage UntaggedResult) parsePermanentFlags :: Parser UntaggedResult parseUidNext :: Parser (Either ErrorMessage UntaggedResult) parseUidValidity :: Parser (Either ErrorMessage UntaggedResult) parseHighestModSeq :: Parser (Either ErrorMessage UntaggedResult) parseStatusItem :: Parser (Either ErrorMessage UntaggedResult) parseStatus :: Parser (Either ErrorMessage UntaggedResult) parseCapabilityList :: Parser (Either ErrorMessage UntaggedResult) parseCapabilityWithValue :: Parser (Either ErrorMessage Capability) parseNamedCapability :: Parser (Either ErrorMessage Capability) parseExpunge :: Parser (Either ErrorMessage UntaggedResult) parseSearchResult :: Parser (Either ErrorMessage UntaggedResult) module Network.IMAP.Parsers.Fetch parseFetch :: Parser (Either ErrorMessage CommandResult) parseSpecifiers :: Parser [Either ErrorMessage UntaggedResult] parseInternalDate :: Parser UntaggedResult parseBody :: Parser (Either ErrorMessage UntaggedResult) parseBodyStructure :: Parser UntaggedResult parseEnvelope :: Parser UntaggedResult module Network.IMAP.Parsers parseReply :: Parser (Either ErrorMessage CommandResult) parseLine :: Parser (Either ErrorMessage CommandResult) parseTagged :: Parser (Either ErrorMessage CommandResult) parseUntagged :: Parser (Either ErrorMessage CommandResult) module Network.IMAP.RequestWatcher requestWatcher :: (MonadIO m, Universe m, MonadCatch m) => IMAPConnection -> m () -- | Usage: -- --
--   import Network.Connection
--   import Network.IMAP
--   
--   let tls = TLSSettingsSimple False False False
--   let params = ConnectionParams "imap.gmail.com" 993 (Just tls) Nothing
--   conn <- connectServer params
--   simpleFormat $ login conn "mylogin" "mypass"
--   
-- -- For more usage examples, please see the readme module Network.IMAP -- | Connects to the server and gives you a connection object that needs to -- be passed to any other command. You should only call it once for every -- connection you wish to create connectServer :: ConnectionParams -> Maybe IMAPSettings -> IO IMAPConnection -- | An escape hatch, gives you the ability to send any command to the -- server, even one not implemented by this library sendCommand :: (MonadPlus m, MonadIO m, Universe m) => IMAPConnection -> ByteString -> m CommandResult -- |

Connected state commands

-- -- Upgrade a connection to a TLS connection from an insecure one. Accepts -- TLS settings you wish your connection to use startTLS :: (MonadPlus m, MonadIO m, Universe m) => IMAPConnection -> TLSSettings -> m CommandResult capability :: (MonadPlus m, MonadIO m, Universe m) => IMAPConnection -> m CommandResult noop :: (MonadPlus m, MonadIO m, Universe m) => IMAPConnection -> m CommandResult logout :: (MonadPlus m, MonadIO m, Universe m) => IMAPConnection -> m CommandResult -- | A simple authentication method, with user and password. Probably -- what's needed in 90% of cases. login :: (MonadPlus m, MonadIO m, Universe m) => IMAPConnection -> Text -> Text -> m CommandResult -- | Authenticate with the server. During the authentication control is -- given to the library user and is returned to the library at the end of -- authentication authenticate :: (MonadPlus m, MonadIO m, Universe m) => IMAPConnection -> ByteString -> (IMAPConnection -> m ()) -> m () -- |

Authenticated state commands

select :: (MonadPlus m, MonadIO m, Universe m) => IMAPConnection -> Text -> m CommandResult examine :: (MonadPlus m, MonadIO m, Universe m) => IMAPConnection -> Text -> m CommandResult create :: (MonadPlus m, MonadIO m, Universe m) => IMAPConnection -> Text -> m CommandResult delete :: (MonadPlus m, MonadIO m, Universe m) => IMAPConnection -> Text -> m CommandResult rename :: (MonadPlus m, MonadIO m, Universe m) => IMAPConnection -> Text -> Text -> m CommandResult subscribe :: (MonadPlus m, MonadIO m, Universe m) => IMAPConnection -> Text -> m CommandResult unsubscribe :: (MonadPlus m, MonadIO m, Universe m) => IMAPConnection -> Text -> m CommandResult list :: (MonadPlus m, MonadIO m, Universe m) => IMAPConnection -> Text -> m CommandResult lsub :: (MonadPlus m, MonadIO m, Universe m) => IMAPConnection -> Text -> m CommandResult status :: (MonadPlus m, MonadIO m, Universe m) => IMAPConnection -> Text -> m CommandResult append :: (MonadPlus m, MonadIO m, Universe m) => IMAPConnection -> Text -> ByteString -> Maybe [Flag] -> Maybe Text -> m CommandResult -- |

Selected state commands

check :: (MonadPlus m, MonadIO m, Universe m) => IMAPConnection -> m CommandResult close :: (MonadPlus m, MonadIO m, Universe m) => IMAPConnection -> m CommandResult expunge :: (MonadPlus m, MonadIO m, Universe m) => IMAPConnection -> m CommandResult search :: (MonadPlus m, MonadIO m, Universe m) => IMAPConnection -> Text -> m CommandResult uidSearch :: (MonadPlus m, MonadIO m, Universe m) => IMAPConnection -> Text -> m CommandResult -- | Fetch message body by message sequence id fetch :: (MonadPlus m, MonadIO m, Universe m) => IMAPConnection -> Text -> m CommandResult -- | Fetch message body my message UID uidFetch :: (MonadPlus m, MonadIO m, Universe m) => IMAPConnection -> Text -> m CommandResult -- | A general fetch, you have to specify everything that goes after the -- FETCH keyword fetchG :: (MonadPlus m, MonadIO m, Universe m) => IMAPConnection -> Text -> m CommandResult -- | A general fetch using UIDs uidFetchG :: (MonadPlus m, MonadIO m, Universe m) => IMAPConnection -> Text -> m CommandResult store :: (MonadPlus m, MonadIO m, Universe m) => IMAPConnection -> Text -> Text -> [Flag] -> m CommandResult copy :: (MonadPlus m, MonadIO m, Universe m) => IMAPConnection -> Text -> Text -> m CommandResult -- | Return the untagged replies or an error message if the tagged reply is -- of type NO or BAD. Also return all untagged replies received if -- replies list contains a BYE response (when the server decided to -- cleanly disconnect) simpleFormat :: (MonadIO m) => ListT m CommandResult -> m SimpleResult