imap-0.2.0.2: An efficient IMAP client library, with SSL and streaming

Safe HaskellNone
LanguageHaskell2010

Network.IMAP.Types

Synopsis

Documentation

type ErrorMessage = Text Source

A type alias used for an error message

type CommandId = ByteString Source

Each command sent to the server is identified by a random id. this alias helps noticing where this happens

data ConnectionState Source

Connection with the server can be in one of these states

data IMAPConnection Source

Constructors

IMAPConnection 

Fields

connectionState :: TVar ConnectionState

The current connection state

untaggedQueue :: RollingQueue UntaggedResult

Contains commands sent by the server which we didn't expect. Probably message and mailbox state updates

imapState :: IMAPState

Internal state of the library

data IMAPState Source

Constructors

IMAPState 

Fields

rawConnection :: !Connection

The actual connection with the server from Network.Connection. Only use if you know what you're doing

connectionContext :: ConnectionContext

Context from Network.Connection

responseRequests :: TQueue ResponseRequest

Contains requests for response that weren't yet read by the watcher thread.

serverWatcherThread :: TVar (Maybe ThreadId)

Id of the thread the watcher executes on

outstandingReqs :: TVar [ResponseRequest]

All the unfulfilled requests the watcher thread knows about

imapSettings :: IMAPSettings

Configuration settings

data ResponseRequest Source

Constructors

ResponseRequest 

Fields

responseQueue :: TQueue CommandResult

Thread that posted the request should watch this queue for responses to the request.

respRequestId :: CommandId

Id of the request, which is the same as the id sent to the server.

data IMAPSettings Source

Constructors

IMAPSettings 

Instances

data Capability Source

Constructors

CIMAP4 
CUnselect 
CIdle 
CNamespace 
CQuota 
CId 
CExperimental Text 
CChildren 
CUIDPlus 
CCompress Text 
CEnable 
CMove 
CCondstore 
CEsearch 
CUtf8 Text 
CAuth Text 
CListExtended 
CListStatus 
CAppendLimit Int 
COther Text (Maybe Text)

First parameter is the name of a capability and the second can contain a value, if the capability is of the form `NAME=VALUE`

data TaggedResult Source

Always the last result of the command, contains it's metadata

Constructors

TaggedResult 

Fields

commandId :: CommandId

Id of the command that completes

resultState :: !ResultState

State returned by the serverside

resultRest :: ByteString

Rest of the result, usually a human-readable form of a result

data ResultState Source

Tagged results can be in on of these three states

Constructors

OK 
NO 
BAD 

data UntaggedResult Source

Untagged replies are the actual data returned in response to the commands.

Constructors

Flags [Flag]

A list of flags a mailbox has

Exists Int

How many messages exist in a mailbox

Expunge Int

How many messages are expunged

Bye

Returned by the server when it cleanly disconnects

HighestModSeq Int 
Recent Int

Number of recent messages

Messages Int

Number of messages in a mailbox

Unseen Int

Number of unseen messages

PermanentFlags [Flag] 
UID Int

UID of a message

MessageId Int

A sequence id of a message |UID that will be given to the next message added to this mailbox

UIDNext Int 
UIDValidity Int

A triple of mailbox name, it's UIDValidity value and message UID is always unique for a given message

OKResult Text

Result of an OK response

Capabilities [Capability]

What server advertises that it supports |Response to the LIST command

ListR 

Fields

flags :: [NameAttribute]

flags that a mailbox has |Character sequence that marks a new level of hierarchy in the inbox name (usually a slash)

hierarchyDelimiter :: Text
 
inboxName :: Text

Name of the mailbox

Fetch [UntaggedResult]

Fetch response, contains many responses |Status of a mailbox, will contain many different responses inside

StatusR Text [UntaggedResult] 
Search [Int]

A list of message IDs or UIDs fullfilling the search criterions

Envelope

A parsed ENVELOPE reply, prefixed to avoid name clashes

InternalDate Text 
Size Int

Message size

Unknown ByteString

An unsupported value

Body ByteString

Message body, or headers

BodyStructure ByteString

An unparsed bodystructure

data CommandResult Source

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

type SimpleResult = Either ErrorMessage [UntaggedResult] Source

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.

class Monad m => Universe m where Source

Every function that communicates with the outside world should run in the Universe monad, which provides an ability to use mocks when testing

Methods

connectionPut' :: Connection -> ByteString -> m () Source

connectionGetChunk'' :: Connection -> (ByteString -> (a, ByteString)) -> m a Source

Instances