Package twisted :: Package protocols :: Module imap4 :: Class IMAP4Server
[frames | no frames]

Class IMAP4Server

BaseProtocol --+        
               |        
        Protocol --+    
                   |    
        LineReceiver --+
                       |
        TimeoutMixin --+
                       |
                      IMAP4Server


Protocol implementation for an IMAP4rev1 server.

The server can be in any of four states:
Method Summary
  __init__(self, chal, contextFactory)
  __cbAppend(self, result, tag, mbox)
  __cbAuthChunk(self, result, chal, tag)
  __cbAuthResp(self, (iface, avatar, logout), tag)
  __cbCheck(self, result, tag)
  __cbClose(self, result, tag)
  __cbCopied(self, deferredIds, ids, failures, tag, mbox)
  __cbCopy(self, messages, tag, mbox)
  __cbDispatch(self, (arg, rest), tag, fn, args, parseargs, uid)
  __cbExpunge(self, result, tag)
  __cbFetch(self, results, tag, query, uid)
  __cbLogin(self, (iface, avatar, logout), tag)
  __cbManualSearch(self, result, tag, mbox, query, uid, searchResults)
  __cbSearch(self, result, tag, mbox, uid)
  __cbStatus(self, status, tag, box)
  __cbStore(self, result, tag, mbox, uid, silent)
  __doCommand(self, tag, handler, args, parseargs, line, uid)
  __ebAppend(self, failure, tag)
  __ebAuthChunk(self, failure, tag)
  __ebAuthResp(self, failure, tag)
  __ebCheck(self, failure, tag)
  __ebClose(self, failure, tag)
  __ebCopy(self, failure, tag)
  __ebDispatch(self, failure, tag)
  __ebExpunge(self, failure, tag)
  __ebFetch(self, failure, tag)
  __ebLogin(self, failure, tag)
  __ebSearch(self, failure, tag)
  __ebStatus(self, failure, tag, box)
  __ebStore(self, failure, tag)
  _cbSelectWork(self, mbox, cmdName, tag)
  _consumeMessageIterable(self, results, tag, query, uid)
  _ebSelectWork(self, failure, cmdName, tag)
  _fileLiteral(self, size)
  _listWork(self, tag, ref, mbox, sub, cmdName)
  _parseMbox(self, name)
  _respond(self, state, tag, message)
  _selectWork(self, tag, name, rw, cmdName)
  _sendMessageFetchResponse(self, msgId, msg, query, uid)
  _setupChallenge(self, chal, tag)
  _stringLiteral(self, size)
  arg_astring(self, line)
Parse an astring from the line, return (arg, rest), possibly via a deferred (to handle literals)
  arg_atom(self, line)
Parse an atom from the line
  arg_fetchatt(self, line)
fetch-att
  arg_flaglist(self, line)
Flag part of store-att-flag
  arg_line(self, line)
Command line of UID command
  arg_literal(self, line)
Parse a literal from the line
  arg_plist(self, line)
Parse a (non-nested) parenthesised list from the line
  arg_searchkeys(self, line)
searchkeys
  arg_seqset(self, line)
sequence-set
  authenticate(self, chal, tag)
  authenticateLogin(self, user, passwd)
Lookup the account associated with the given parameters
  capabilities(self)
  checkpoint(self)
Called when the client issues a CHECK command.
  connectionLost(self, reason)
  connectionMade(self)
Called when a connection is made.
  dispatchCommand(self, tag, cmd, rest, uid)
  do_APPEND(self, tag, mailbox, flags, date, message)
  do_AUTHENTICATE(self, tag, args)
  do_CAPABILITY(self, tag)
  do_CHECK(self, tag)
  do_CLOSE(self, tag)
  do_COPY(self, tag, messages, mailbox, uid)
  do_CREATE(self, tag, name)
  do_DELETE(self, tag, name)
  do_EXPUNGE(self, tag)
  do_FETCH(self, tag, messages, query, uid)
  do_LOGIN(self, tag, user, passwd)
  do_LOGOUT(self, tag)
  do_NAMESPACE(self, tag)
  do_NOOP(self, tag)
  do_RENAME(self, tag, oldname, newname)
  do_SEARCH(self, tag, charset, query, uid)
  do_STARTTLS(self, tag)
  do_STATUS(self, tag, mailbox, names)
  do_STORE(self, tag, messages, mode, flags, uid)
  do_SUBSCRIBE(self, tag, name)
  do_UID(self, tag, command, line)
  do_UNSUBSCRIBE(self, tag, name)
  flagsChanged(self, newFlags)
  lineReceived(self, line)
Override this for when each line is received.
  listCapabilities(self)
  lookupCommand(self, cmd)
  modeChanged(self, writeable)
  newMessages(self, exists, recent)
  opt_charset(self, line)
Optional charset of SEARCH command
  opt_datetime(self, line)
Optional date-time string
  opt_plist(self, line)
Optional parenthesised list
  parse_command(self, line)
  parse_pending(self, line)
  rawDataReceived(self, data)
Override this for when raw data is received.
  search_ALL(self, query, id, msg)
  search_ANSWERED(self, query, id, msg)
  search_BCC(self, query, id, msg)
  search_BEFORE(self, query, id, msg)
  search_BODY(self, query, id, msg)
  search_CC(self, query, id, msg)
  search_DELETED(self, query, id, msg)
  search_DRAFT(self, query, id, msg)
  search_FLAGGED(self, query, id, msg)
  search_FROM(self, query, id, msg)
  search_HEADER(self, query, id, msg)
  search_KEYWORD(self, query, id, msg)
  search_LARGER(self, query, id, msg)
  search_NEW(self, query, id, msg)
  search_NOT(self, query, id, msg)
  search_OLD(self, query, id, msg)
  search_ON(self, query, id, msg)
  search_OR(self, query, id, msg)
  search_RECENT(self, query, id, msg)
  search_SEEN(self, query, id, msg)
  search_SENTBEFORE(self, query, id, msg)
  search_SENTON(self, query, id, msg)
  search_SENTSINCE(self, query, id, msg)
  search_SINCE(self, query, id, msg)
  search_SMALLER(self, query, id, msg)
  search_SUBJECT(self, query, id, msg)
  search_TEXT(self, query, id, msg)
  search_TO(self, query, id, msg)
  search_UID(self, query, id, msg)
  search_UNANSWERED(self, query, id, msg)
  search_UNDELETED(self, query, id, msg)
  search_UNDRAFT(self, query, id, msg)
  search_UNFLAGGED(self, query, id, msg)
  search_UNKEYWORD(self, query, id, msg)
  search_UNSEEN(self, query, id, msg)
  searchFilter(self, query, id, msg)
  sendBadResponse(self, tag, message)
  sendContinuationRequest(self, msg)
  sendNegativeResponse(self, tag, message)
  sendPositiveResponse(self, tag, message)
  sendServerGreeting(self)
  sendUntaggedResponse(self, message)
  singleSearchStep(self, query, id, msg)
  timeoutConnection(self)
Called when the connection times out.
    Inherited from LineReceiver
  clearLineBuffer(self)
Clear buffered data.
  dataReceived(self, data)
Protocol.dataReceived.
  lineLengthExceeded(self, line)
Called when the maximum line length has been reached.
  sendLine(self, line)
Sends a line to the other end of the connection.
  setLineMode(self, extra)
Sets the line-mode of this receiver.
  setRawMode(self)
Sets the raw mode of this receiver.
    Inherited from Protocol
  connectionFailed(self)
(Deprecated)
    Inherited from BaseProtocol
  makeConnection(self, transport)
Make a connection to a transport and a server.
    Inherited from TimeoutMixin
  resetTimeout(self)
Reset the timeout count down
  setTimeout(self, period)
Change the timeout period

Class Variable Summary
tuple __implements__ = (<class twisted.protocols.imap4.IMailbo...
int _literalStringLimit = 4096                                                                  
NoneType _onLogout = None                                                                  
NoneType _pendingLiteral = None                                                                  
NoneType account = None                                                                  
SRE_Pattern atomre = ([^\]\(\)\{%\*"\\- €-ÿ]+)( (.*$)|$)
tuple auth_APPEND = (<function do_APPEND at 0x8584e54>, <funct...
tuple auth_CAPABILITY = (<function do_CAPABILITY at 0x87b129c>...
tuple auth_CREATE = (<function do_CREATE at 0x8598f2c>, <funct...
tuple auth_DELETE = (<function do_DELETE at 0x8598f64>, <funct...
tuple auth_EXAMINE = (<function _selectWork at 0x85abdec>, <fu...
tuple auth_LIST = (<function _listWork at 0x87bdf8c>, <functio...
tuple auth_LOGOUT = (<function do_LOGOUT at 0x87b12d4>,)
tuple auth_LSUB = (<function _listWork at 0x87bdf8c>, <functio...
tuple auth_NAMESPACE = (<function do_NAMESPACE at 0x85beb0c>,)
tuple auth_NOOP = (<function do_NOOP at 0x884b2f4>,)
tuple auth_RENAME = (<function do_RENAME at 0x8598f9c>, <funct...
tuple auth_SELECT = (<function _selectWork at 0x85abdec>, <fun...
tuple auth_STATUS = (<function do_STATUS at 0x870a524>, <funct...
tuple auth_SUBSCRIBE = (<function do_SUBSCRIBE at 0x87bdf1c>, ...
tuple auth_UNSUBSCRIBE = (<function do_UNSUBSCRIBE at 0x87bdf5...
int canStartTLS = 0                                                                     
NoneType challengers = None                                                                  
str IDENT = 'Twisted IMAP4rev1 Ready'
tuple logout_CAPABILITY = (<function do_CAPABILITY at 0x87b129...
tuple logout_LOGOUT = (<function do_LOGOUT at 0x87b12d4>,)
tuple logout_NOOP = (<function do_NOOP at 0x884b2f4>,)
NoneType mbox = None                                                                  
str parseState = 'command'
NoneType portal = None                                                                  
int POSTAUTH_TIMEOUT = 1800                                                                  
tuple select_APPEND = (<function do_APPEND at 0x8584e54>, <fun...
tuple select_CAPABILITY = (<function do_CAPABILITY at 0x87b129...
tuple select_CHECK = (<function do_CHECK at 0x877f6bc>,)
tuple select_CLOSE = (<function do_CLOSE at 0x8711a9c>,)
tuple select_COPY = (<function do_COPY at 0x8a8fcf4>, <functio...
tuple select_CREATE = (<function do_CREATE at 0x8598f2c>, <fun...
tuple select_DELETE = (<function do_DELETE at 0x8598f64>, <fun...
tuple select_EXAMINE = (<function _selectWork at 0x85abdec>, <...
tuple select_EXPUNGE = (<function do_EXPUNGE at 0x86b527c>,)
tuple select_FETCH = (<function do_FETCH at 0x8a960fc>, <funct...
tuple select_LIST = (<function _listWork at 0x87bdf8c>, <funct...
tuple select_LOGOUT = (<function do_LOGOUT at 0x87b12d4>,)
tuple select_LSUB = (<function _listWork at 0x87bdf8c>, <funct...
tuple select_NAMESPACE = (<function do_NAMESPACE at 0x85beb0c>...
tuple select_NOOP = (<function do_NOOP at 0x884b2f4>,)
tuple select_RENAME = (<function do_RENAME at 0x8598f9c>, <fun...
tuple select_SEARCH = (<function do_SEARCH at 0x8665684>, <fun...
tuple select_SELECT = (<function _selectWork at 0x85abdec>, <f...
tuple select_STATUS = (<function do_STATUS at 0x870a524>, <fun...
tuple select_STORE = (<function do_STORE at 0x8a8fc4c>, <funct...
tuple select_SUBSCRIBE = (<function do_SUBSCRIBE at 0x87bdf1c>...
tuple select_UID = (<function do_UID at 0x8a93314>, <function ...
tuple select_UNSUBSCRIBE = (<function do_UNSUBSCRIBE at 0x87bd...
int startedTLS = 0                                                                     
str state = 'unauth'
NoneType tags = None                                                                  
NoneType timeOut: The number of seconds after which to timeout the connection.
tuple unauth_AUTHENTICATE = (<function do_AUTHENTICATE at 0x88...
tuple unauth_CAPABILITY = (<function do_CAPABILITY at 0x87b129...
tuple unauth_LOGIN = (<function do_LOGIN at 0x8826c34>, <funct...
tuple unauth_LOGOUT = (<function do_LOGOUT at 0x87b12d4>,)
tuple unauth_NOOP = (<function do_NOOP at 0x884b2f4>,)
tuple unauth_STARTTLS = (<function do_STARTTLS at 0x881f42c>,)
    Inherited from LineReceiver
str _LineReceiver__buffer = ''
str delimiter: The line-ending delimiter to use.
int line_mode = 1                                                                     
int MAX_LENGTH: The maximum length of a line to allow (If a sent line is longer than this, the connection is dropped).
    Inherited from BaseProtocol
int connected = 0                                                                     
NoneType transport = None                                                                  
    Inherited from TimeoutMixin
NoneType _TimeoutMixin__lastReceived = None                                                                  
NoneType _TimeoutMixin__timeoutCall = None                                                                  

Method Details

arg_astring(self, line)

Parse an astring from the line, return (arg, rest), possibly via a deferred (to handle literals)

arg_atom(self, line)

Parse an atom from the line

arg_fetchatt(self, line)

fetch-att

arg_flaglist(self, line)

Flag part of store-att-flag

arg_line(self, line)

Command line of UID command

arg_literal(self, line)

Parse a literal from the line

arg_plist(self, line)

Parse a (non-nested) parenthesised list from the line

arg_searchkeys(self, line)

searchkeys

arg_seqset(self, line)

sequence-set

authenticateLogin(self, user, passwd)

Lookup the account associated with the given parameters

Override this method to define the desired authentication behavior.

The default behavior is to defer authentication to self.portal if it is not None, or to deny the login otherwise.
Parameters:
user - The username to lookup
           (type=str)
passwd - The password to login with
           (type=str)

checkpoint(self)

Called when the client issues a CHECK command.

This should perform any checkpoint operations required by the server. It may be a long running operation, but may not block. If it returns a deferred, the client will only be informed of success (or failure) when the deferred's callback (or errback) is invoked.

connectionMade(self)

Called when a connection is made.

This may be considered the initializer of the protocol, because it is called when the connection is completed. For clients, this is called once the connection to the server has been established; for servers, this is called after an accept() call stops blocking and a socket has been received. If you need to send any greeting or initial message, do it here.
Overrides:
twisted.internet.protocol.BaseProtocol.connectionMade (inherited documentation)

lineReceived(self, line)

Override this for when each line is received.
Overrides:
twisted.protocols.basic.LineReceiver.lineReceived (inherited documentation)

opt_charset(self, line)

Optional charset of SEARCH command

opt_datetime(self, line)

Optional date-time string

opt_plist(self, line)

Optional parenthesised list

rawDataReceived(self, data)

Override this for when raw data is received.
Overrides:
twisted.protocols.basic.LineReceiver.rawDataReceived (inherited documentation)

timeoutConnection(self)

Called when the connection times out. Override to define behavior other than dropping the connection.
Overrides:
twisted.protocols.policies.TimeoutMixin.timeoutConnection (inherited documentation)

Class Variable Details

__implements__

Type:
tuple
Value:
(<class twisted.protocols.imap4.IMailboxListener at 0x868f284>,)       

_literalStringLimit

Type:
int
Value:
4096                                                                  

_onLogout

Type:
NoneType
Value:
None                                                                  

_pendingLiteral

Type:
NoneType
Value:
None                                                                  

account

Type:
NoneType
Value:
None                                                                  

atomre

Type:
SRE_Pattern
Value:
([^\]\(\)\{%\*"\\--ÿ]+)( (.*$)|$)                                   

auth_APPEND

Type:
tuple
Value:
(<function do_APPEND at 0x8584e54>,
 <function arg_astring at 0x86d911c>,
 <function opt_plist at 0x84f317c>,
 <function opt_datetime at 0x8787e24>,
 <function arg_literal at 0x86d6474>)                                  

auth_CAPABILITY

Type:
tuple
Value:
(<function do_CAPABILITY at 0x87b129c>,)                               

auth_CREATE

Type:
tuple
Value:
(<function do_CREATE at 0x8598f2c>, <function arg_astring at 0x86d911c\
>)                                                                     

auth_DELETE

Type:
tuple
Value:
(<function do_DELETE at 0x8598f64>, <function arg_astring at 0x86d911c\
>)                                                                     

auth_EXAMINE

Type:
tuple
Value:
(<function _selectWork at 0x85abdec>,
 <function arg_astring at 0x86d911c>,
 0,
 'EXAMINE')                                                            

auth_LIST

Type:
tuple
Value:
(<function _listWork at 0x87bdf8c>,
 <function arg_astring at 0x86d911c>,
 <function arg_astring at 0x86d911c>,
 0,
 'LIST')                                                               

auth_LOGOUT

Type:
tuple
Value:
(<function do_LOGOUT at 0x87b12d4>,)                                   

auth_LSUB

Type:
tuple
Value:
(<function _listWork at 0x87bdf8c>,
 <function arg_astring at 0x86d911c>,
 <function arg_astring at 0x86d911c>,
 1,
 'LSUB')                                                               

auth_NAMESPACE

Type:
tuple
Value:
(<function do_NAMESPACE at 0x85beb0c>,)                                

auth_NOOP

Type:
tuple
Value:
(<function do_NOOP at 0x884b2f4>,)                                     

auth_RENAME

Type:
tuple
Value:
(<function do_RENAME at 0x8598f9c>,
 <function arg_astring at 0x86d911c>,
 <function arg_astring at 0x86d911c>)                                  

auth_SELECT

Type:
tuple
Value:
(<function _selectWork at 0x85abdec>,
 <function arg_astring at 0x86d911c>,
 1,
 'SELECT')                                                             

auth_STATUS

Type:
tuple
Value:
(<function do_STATUS at 0x870a524>,
 <function arg_astring at 0x86d911c>,
 <function arg_plist at 0x86d918c>)                                    

auth_SUBSCRIBE

Type:
tuple
Value:
(<function do_SUBSCRIBE at 0x87bdf1c>, <function arg_astring at 0x86d9\
11c>)                                                                  

auth_UNSUBSCRIBE

Type:
tuple
Value:
(<function do_UNSUBSCRIBE at 0x87bdf54>, <function arg_astring at 0x86\
d911c>)                                                                

canStartTLS

Type:
int
Value:
0                                                                     

challengers

Type:
NoneType
Value:
None                                                                  

IDENT

Type:
str
Value:
'Twisted IMAP4rev1 Ready'                                              

logout_CAPABILITY

Type:
tuple
Value:
(<function do_CAPABILITY at 0x87b129c>,)                               

logout_LOGOUT

Type:
tuple
Value:
(<function do_LOGOUT at 0x87b12d4>,)                                   

logout_NOOP

Type:
tuple
Value:
(<function do_NOOP at 0x884b2f4>,)                                     

mbox

Type:
NoneType
Value:
None                                                                  

parseState

Type:
str
Value:
'command'                                                              

portal

Type:
NoneType
Value:
None                                                                  

POSTAUTH_TIMEOUT

Type:
int
Value:
1800                                                                  

select_APPEND

Type:
tuple
Value:
(<function do_APPEND at 0x8584e54>,
 <function arg_astring at 0x86d911c>,
 <function opt_plist at 0x84f317c>,
 <function opt_datetime at 0x8787e24>,
 <function arg_literal at 0x86d6474>)                                  

select_CAPABILITY

Type:
tuple
Value:
(<function do_CAPABILITY at 0x87b129c>,)                               

select_CHECK

Type:
tuple
Value:
(<function do_CHECK at 0x877f6bc>,)                                    

select_CLOSE

Type:
tuple
Value:
(<function do_CLOSE at 0x8711a9c>,)                                    

select_COPY

Type:
tuple
Value:
(<function do_COPY at 0x8a8fcf4>,
 <function arg_seqset at 0x86d64e4>,
 <function arg_astring at 0x86d911c>)                                  

select_CREATE

Type:
tuple
Value:
(<function do_CREATE at 0x8598f2c>, <function arg_astring at 0x86d911c\
>)                                                                     

select_DELETE

Type:
tuple
Value:
(<function do_DELETE at 0x8598f64>, <function arg_astring at 0x86d911c\
>)                                                                     

select_EXAMINE

Type:
tuple
Value:
(<function _selectWork at 0x85abdec>,
 <function arg_astring at 0x86d911c>,
 0,
 'EXAMINE')                                                            

select_EXPUNGE

Type:
tuple
Value:
(<function do_EXPUNGE at 0x86b527c>,)                                  

select_FETCH

Type:
tuple
Value:
(<function do_FETCH at 0x8a960fc>,
 <function arg_seqset at 0x86d64e4>,
 <function arg_fetchatt at 0x84f310c>)                                 

select_LIST

Type:
tuple
Value:
(<function _listWork at 0x87bdf8c>,
 <function arg_astring at 0x86d911c>,
 <function arg_astring at 0x86d911c>,
 0,
 'LIST')                                                               

select_LOGOUT

Type:
tuple
Value:
(<function do_LOGOUT at 0x87b12d4>,)                                   

select_LSUB

Type:
tuple
Value:
(<function _listWork at 0x87bdf8c>,
 <function arg_astring at 0x86d911c>,
 <function arg_astring at 0x86d911c>,
 1,
 'LSUB')                                                               

select_NAMESPACE

Type:
tuple
Value:
(<function do_NAMESPACE at 0x85beb0c>,)                                

select_NOOP

Type:
tuple
Value:
(<function do_NOOP at 0x884b2f4>,)                                     

select_RENAME

Type:
tuple
Value:
(<function do_RENAME at 0x8598f9c>,
 <function arg_astring at 0x86d911c>,
 <function arg_astring at 0x86d911c>)                                  

select_SEARCH

Type:
tuple
Value:
(<function do_SEARCH at 0x8665684>,
 <function opt_charset at 0x8787e5c>,
 <function arg_searchkeys at 0x86d64ac>)                               

select_SELECT

Type:
tuple
Value:
(<function _selectWork at 0x85abdec>,
 <function arg_astring at 0x86d911c>,
 1,
 'SELECT')                                                             

select_STATUS

Type:
tuple
Value:
(<function do_STATUS at 0x870a524>,
 <function arg_astring at 0x86d911c>,
 <function arg_plist at 0x86d918c>)                                    

select_STORE

Type:
tuple
Value:
(<function do_STORE at 0x8a8fc4c>,
 <function arg_seqset at 0x86d64e4>,
 <function arg_atom at 0x86d9154>,
 <function arg_flaglist at 0x84f3144>)                                 

select_SUBSCRIBE

Type:
tuple
Value:
(<function do_SUBSCRIBE at 0x87bdf1c>, <function arg_astring at 0x86d9\
11c>)                                                                  

select_UID

Type:
tuple
Value:
(<function do_UID at 0x8a93314>,
 <function arg_atom at 0x86d9154>,
 <function arg_line at 0x8b1a374>)                                     

select_UNSUBSCRIBE

Type:
tuple
Value:
(<function do_UNSUBSCRIBE at 0x87bdf54>, <function arg_astring at 0x86\
d911c>)                                                                

startedTLS

Type:
int
Value:
0                                                                     

state

Type:
str
Value:
'unauth'                                                               

tags

Type:
NoneType
Value:
None                                                                  

timeOut

The number of seconds after which to timeout the connection.
Type:
NoneType
Value:
60                                                                    

unauth_AUTHENTICATE

Type:
tuple
Value:
(<function do_AUTHENTICATE at 0x884b32c>, <function arg_atom at 0x86d9\
154>)                                                                  

unauth_CAPABILITY

Type:
tuple
Value:
(<function do_CAPABILITY at 0x87b129c>,)                               

unauth_LOGIN

Type:
tuple
Value:
(<function do_LOGIN at 0x8826c34>,
 <function arg_astring at 0x86d911c>,
 <function arg_astring at 0x86d911c>)                                  

unauth_LOGOUT

Type:
tuple
Value:
(<function do_LOGOUT at 0x87b12d4>,)                                   

unauth_NOOP

Type:
tuple
Value:
(<function do_NOOP at 0x884b2f4>,)                                     

unauth_STARTTLS

Type:
tuple
Value:
(<function do_STARTTLS at 0x881f42c>,)                                 

Generated by Epydoc 2.0 on Sat Sep 13 04:21:10 2003 http://epydoc.sf.net