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, 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)
  __ebSpewMessage(self, failure)
  __ebStatus(self, failure, tag, box)
  __ebStore(self, failure, tag)
  _cbSelectWork(self, mbox, cmdName, tag)
  _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)
  _setupChallenge(self, chal, tag)
  _stringLiteral(self, size)
  _unblock(self)
  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)
  spew_body(self, part, id, msg)
  spew_bodystructure(self, id, msg)
  spew_envelope(self, id, msg)
  spew_flags(self, id, msg)
  spew_internaldate(self, id, msg)
  spew_rfc822(self, id, msg)
  spew_rfc822header(self, id, msg)
  spew_rfc822size(self, id, msg)
  spew_rfc822text(self, id, msg)
  spew_uid(self, id, msg)
  spewMessage(self, id, msg, query, uid)
  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 0x87f5ddc>, <funct...
tuple auth_CAPABILITY = (<function do_CAPABILITY at 0x88b4a1c>...
tuple auth_CREATE = (<function do_CREATE at 0x87cf424>, <funct...
tuple auth_DELETE = (<function do_DELETE at 0x87cf45c>, <funct...
tuple auth_EXAMINE = (<function _selectWork at 0x868f68c>, <fu...
tuple auth_LIST = (<function _listWork at 0x86711bc>, <functio...
tuple auth_LOGOUT = (<function do_LOGOUT at 0x88b4a54>,)
tuple auth_LSUB = (<function _listWork at 0x86711bc>, <functio...
tuple auth_NAMESPACE = (<function do_NAMESPACE at 0x868f61c>,)
tuple auth_NOOP = (<function do_NOOP at 0x88b4a8c>,)
tuple auth_RENAME = (<function do_RENAME at 0x87cf494>, <funct...
tuple auth_SELECT = (<function _selectWork at 0x868f68c>, <fun...
tuple auth_STATUS = (<function do_STATUS at 0x86711f4>, <funct...
tuple auth_SUBSCRIBE = (<function do_SUBSCRIBE at 0x867114c>, ...
tuple auth_UNSUBSCRIBE = (<function do_UNSUBSCRIBE at 0x867118...
NoneType blocked = None                                                                  
int canStartTLS = 0                                                                     
NoneType challengers = None                                                                  
str IDENT = 'Twisted IMAP4rev1 Ready'
tuple logout_CAPABILITY = (<function do_CAPABILITY at 0x88b4a1...
tuple logout_LOGOUT = (<function do_LOGOUT at 0x88b4a54>,)
tuple logout_NOOP = (<function do_NOOP at 0x88b4a8c>,)
NoneType mbox = None                                                                  
str parseState = 'command'
NoneType portal = None                                                                  
int POSTAUTH_TIMEOUT = 1800                                                                  
tuple select_APPEND = (<function do_APPEND at 0x87f5ddc>, <fun...
tuple select_CAPABILITY = (<function do_CAPABILITY at 0x88b4a1...
tuple select_CHECK = (<function do_CHECK at 0x85937b4>,)
tuple select_CLOSE = (<function do_CLOSE at 0x879a0d4>,)
tuple select_COPY = (<function do_COPY at 0x8632864>, <functio...
tuple select_CREATE = (<function do_CREATE at 0x87cf424>, <fun...
tuple select_DELETE = (<function do_DELETE at 0x87cf45c>, <fun...
tuple select_EXAMINE = (<function _selectWork at 0x868f68c>, <...
tuple select_EXPUNGE = (<function do_EXPUNGE at 0x85e8834>,)
tuple select_FETCH = (<function do_FETCH at 0x870b9e4>, <funct...
tuple select_LIST = (<function _listWork at 0x86711bc>, <funct...
tuple select_LOGOUT = (<function do_LOGOUT at 0x88b4a54>,)
tuple select_LSUB = (<function _listWork at 0x86711bc>, <funct...
tuple select_NAMESPACE = (<function do_NAMESPACE at 0x868f61c>...
tuple select_NOOP = (<function do_NOOP at 0x88b4a8c>,)
tuple select_RENAME = (<function do_RENAME at 0x87cf494>, <fun...
tuple select_SEARCH = (<function do_SEARCH at 0x85e88dc>, <fun...
tuple select_SELECT = (<function _selectWork at 0x868f68c>, <f...
tuple select_STATUS = (<function do_STATUS at 0x86711f4>, <fun...
tuple select_STORE = (<function do_STORE at 0x86280ec>, <funct...
tuple select_SUBSCRIBE = (<function do_SUBSCRIBE at 0x867114c>...
tuple select_UID = (<function do_UID at 0x8774ba4>, <function ...
tuple select_UNSUBSCRIBE = (<function do_UNSUBSCRIBE at 0x8671...
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 0x87...
tuple unauth_CAPABILITY = (<function do_CAPABILITY at 0x88b4a1...
tuple unauth_LOGIN = (<function do_LOGIN at 0x857af04>, <funct...
tuple unauth_LOGOUT = (<function do_LOGOUT at 0x88b4a54>,)
tuple unauth_NOOP = (<function do_NOOP at 0x88b4a8c>,)
tuple unauth_STARTTLS = (<function do_STARTTLS at 0x8723a4c>,)
    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 0x88a589c>,)       

_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 0x87f5ddc>,
 <function arg_astring at 0x8873cd4>,
 <function opt_plist at 0x887299c>,
 <function opt_datetime at 0x88729d4>,
 <function arg_literal at 0x8873d0c>)                                  

auth_CAPABILITY

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

auth_CREATE

Type:
tuple
Value:
(<function do_CREATE at 0x87cf424>, <function arg_astring at 0x8873cd4\
>)                                                                     

auth_DELETE

Type:
tuple
Value:
(<function do_DELETE at 0x87cf45c>, <function arg_astring at 0x8873cd4\
>)                                                                     

auth_EXAMINE

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

auth_LIST

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

auth_LOGOUT

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

auth_LSUB

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

auth_NAMESPACE

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

auth_NOOP

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

auth_RENAME

Type:
tuple
Value:
(<function do_RENAME at 0x87cf494>,
 <function arg_astring at 0x8873cd4>,
 <function arg_astring at 0x8873cd4>)                                  

auth_SELECT

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

auth_STATUS

Type:
tuple
Value:
(<function do_STATUS at 0x86711f4>,
 <function arg_astring at 0x8873cd4>,
 <function arg_plist at 0x866c1d4>)                                    

auth_SUBSCRIBE

Type:
tuple
Value:
(<function do_SUBSCRIBE at 0x867114c>, <function arg_astring at 0x8873\
cd4>)                                                                  

auth_UNSUBSCRIBE

Type:
tuple
Value:
(<function do_UNSUBSCRIBE at 0x8671184>, <function arg_astring at 0x88\
73cd4>)                                                                

blocked

Type:
NoneType
Value:
None                                                                  

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 0x88b4a1c>,)                               

logout_LOGOUT

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

logout_NOOP

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

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 0x87f5ddc>,
 <function arg_astring at 0x8873cd4>,
 <function opt_plist at 0x887299c>,
 <function opt_datetime at 0x88729d4>,
 <function arg_literal at 0x8873d0c>)                                  

select_CAPABILITY

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

select_CHECK

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

select_CLOSE

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

select_COPY

Type:
tuple
Value:
(<function do_COPY at 0x8632864>,
 <function arg_seqset at 0x8873d7c>,
 <function arg_astring at 0x8873cd4>)                                  

select_CREATE

Type:
tuple
Value:
(<function do_CREATE at 0x87cf424>, <function arg_astring at 0x8873cd4\
>)                                                                     

select_DELETE

Type:
tuple
Value:
(<function do_DELETE at 0x87cf45c>, <function arg_astring at 0x8873cd4\
>)                                                                     

select_EXAMINE

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

select_EXPUNGE

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

select_FETCH

Type:
tuple
Value:
(<function do_FETCH at 0x870b9e4>,
 <function arg_seqset at 0x8873d7c>,
 <function arg_fetchatt at 0x88e04cc>)                                 

select_LIST

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

select_LOGOUT

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

select_LSUB

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

select_NAMESPACE

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

select_NOOP

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

select_RENAME

Type:
tuple
Value:
(<function do_RENAME at 0x87cf494>,
 <function arg_astring at 0x8873cd4>,
 <function arg_astring at 0x8873cd4>)                                  

select_SEARCH

Type:
tuple
Value:
(<function do_SEARCH at 0x85e88dc>,
 <function opt_charset at 0x88771ec>,
 <function arg_searchkeys at 0x8873d44>)                               

select_SELECT

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

select_STATUS

Type:
tuple
Value:
(<function do_STATUS at 0x86711f4>,
 <function arg_astring at 0x8873cd4>,
 <function arg_plist at 0x866c1d4>)                                    

select_STORE

Type:
tuple
Value:
(<function do_STORE at 0x86280ec>,
 <function arg_seqset at 0x8873d7c>,
 <function arg_atom at 0x863078c>,
 <function arg_flaglist at 0x88e0504>)                                 

select_SUBSCRIBE

Type:
tuple
Value:
(<function do_SUBSCRIBE at 0x867114c>, <function arg_astring at 0x8873\
cd4>)                                                                  

select_UID

Type:
tuple
Value:
(<function do_UID at 0x8774ba4>,
 <function arg_atom at 0x863078c>,
 <function arg_line at 0x8872964>)                                     

select_UNSUBSCRIBE

Type:
tuple
Value:
(<function do_UNSUBSCRIBE at 0x8671184>, <function arg_astring at 0x88\
73cd4>)                                                                

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 0x8743c34>, <function arg_atom at 0x8630\
78c>)                                                                  

unauth_CAPABILITY

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

unauth_LOGIN

Type:
tuple
Value:
(<function do_LOGIN at 0x857af04>,
 <function arg_astring at 0x8873cd4>,
 <function arg_astring at 0x8873cd4>)                                  

unauth_LOGOUT

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

unauth_NOOP

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

unauth_STARTTLS

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

Generated by Epydoc 2.0 on Tue Dec 9 17:48:06 2003 http://epydoc.sf.net