Bincimap 2.0.16
Easy Imapping
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | Friends
MaildirMessage Class Reference

The MaildirMessage class provides an interface for IMAP messages. More...

#include <maildirmessage.h>

Public Types

enum  Flags {
  None = 0x00 , Expunged = 0x01 , FlagsChanged = 0x02 , JustArrived = 0x04 , WasWrittenTo = 0x08 ,
  Committed = 0x10 , CustomFlagsChanged = 0x20
}
 
- Public Types inherited from Message
enum  Flags {
  F_NONE = 0x00 , F_SEEN = 0x01 , F_ANSWERED = 0x02 , F_DELETED = 0x04 , F_DRAFT = 0x08 ,
  F_RECENT = 0x10 , F_FLAGGED = 0x20 , F_EXPUNGED = 0x40 , F_PASSED = 0x80
}
 

Public Member Functions

void setUID (unsigned int uid)
 
unsigned int getUID (void) const
 
void setSize (unsigned int size)
 
unsigned int getSize (bool determine=false) const
 
void setStdFlag (unsigned char flags)
 
void resetStdFlags (void)
 
unsigned char getStdFlags (void) const
 
void setCustomFlag (const std::string &flag)
 
void removeCustomFlag (const std::string &flag)
 
void resetCustomFlags (void)
 
std::vector< std::string > getCustomFlags (void) const
 
void setInternalFlag (unsigned char flags)
 
void clearInternalFlag (unsigned char flags)
 
unsigned char getInternalFlags (void) const
 
void setFlagsUnchanged (void)
 
bool hasFlagsChanged (void) const
 
void setInternalDate (time_t internaldate)
 
time_t getInternalDate (void) const
 
int readChunk (std::string &chunk)
 
bool appendChunk (const std::string &chunk)
 
void close (void)
 
void setExpunged (void)
 
void setUnExpunged (void)
 
bool isExpunged (void) const
 
const std::string & getHeader (const std::string &header)
 
bool headerContains (const std::string &header, const std::string &text)
 
bool bodyContains (const std::string &text)
 
bool textContains (const std::string &text)
 
bool printBodyStructure (bool extended=true) const
 
bool printEnvelope (void) const
 
bool printHeader (const std::string &section, std::vector< std::string > headers, bool includeHeaders=false, unsigned int startOffset=0, unsigned int length=UINTMAX, bool mime=false) const
 
unsigned int getHeaderSize (const std::string &section, std::vector< std::string > headers, bool includeHeaders=false, unsigned int startOffset=0, unsigned int length=UINTMAX, bool mime=false) const
 
bool printBody (const std::string &section="", unsigned int startOffset=0, unsigned int length=UINTMAX) const
 
unsigned int getBodySize (const std::string &section, unsigned int startOffset=0, unsigned int length=UINTMAX) const
 
bool printDoc (unsigned int startOffset=0, unsigned int length=UINTMAX, bool onlyText=false) const
 
unsigned int getDocSize (unsigned int startOffset=0, unsigned int length=UINTMAX, bool onlyText=false) const
 
void setUnique (const std::string &s_in)
 
const std::string & getUnique (void) const
 
 MaildirMessage (Maildir &home)
 
 ~MaildirMessage (void)
 
bool operator< (const MaildirMessage &a) const
 
 MaildirMessage (const MaildirMessage &copy)
 
MaildirMessageoperator= (const MaildirMessage &copy)
 
- Public Member Functions inherited from Message
virtual void setUID (unsigned int)=0
 
virtual unsigned int getUID (void) const =0
 
virtual void setSize (unsigned int)=0
 
virtual unsigned int getSize (bool render=false) const =0
 
virtual void setStdFlag (unsigned char)=0
 
virtual void resetStdFlags (void)=0
 
virtual unsigned char getStdFlags (void) const =0
 
virtual void setCustomFlag (const std::string &flag)=0
 
virtual void removeCustomFlag (const std::string &flag)=0
 
virtual void resetCustomFlags (void)=0
 
virtual std::vector< std::string > getCustomFlags (void) const =0
 
virtual void setFlagsUnchanged (void)=0
 
virtual bool hasFlagsChanged (void) const =0
 
virtual void setInternalDate (time_t)=0
 
virtual time_t getInternalDate (void) const =0
 
virtual int readChunk (std::string &)=0
 
virtual bool appendChunk (const std::string &)=0
 
virtual void close (void)=0
 
virtual void setExpunged (void)=0
 
virtual void setUnExpunged (void)=0
 
virtual bool isExpunged (void) const =0
 
virtual const std::string & getHeader (const std::string &header)=0
 
virtual bool headerContains (const std::string &header, const std::string &text)=0
 
virtual bool bodyContains (const std::string &text)=0
 
virtual bool textContains (const std::string &text)=0
 
virtual bool printBodyStructure (bool extended=true) const =0
 
virtual bool printEnvelope (void) const =0
 
virtual bool printHeader (const std::string &section, std::vector< std::string > headers, bool includeHeaders=false, unsigned int startOffset=0, unsigned int length=UINTMAX, bool mime=false) const =0
 
virtual unsigned int getHeaderSize (const std::string &section, std::vector< std::string > headers, bool includeHeaders=false, unsigned int startOffset=0, unsigned int length=UINTMAX, bool mime=false) const =0
 
virtual bool printBody (const std::string &section, unsigned int startOffset=0, unsigned int length=UINTMAX) const =0
 
virtual unsigned int getBodySize (const std::string &section, unsigned int startOffset=0, unsigned int length=UINTMAX) const =0
 
virtual bool printDoc (unsigned int startOffset=0, unsigned int length=UINTMAX, bool onlyText=false) const =0
 
virtual unsigned int getDocSize (unsigned int startOffset=0, unsigned int length=UINTMAX, bool onlyText=false) const =0
 
 Message (void)
 
virtual ~Message (void)
 
void setLastError (const std::string &) const
 
const std::string & getLastError (void) const
 

Protected Member Functions

bool parseFull (void) const
 
bool parseHeaders (void) const
 
std::string getFixedFilename (void) const
 
std::string getFileName (void) const
 
void setFile (int fd)
 
int getFile (void) const
 
void setSafeName (const std::string &name)
 
const std::string & getSafeName (void) const
 

Friends

class Maildir
 

Detailed Description

The MaildirMessage class provides an interface for IMAP messages.

Mailbox independent operations and properties are available through this interface.

See also
Message

Definition at line 37 of file maildirmessage.h.

Member Enumeration Documentation

◆ Flags

enum Flags
Enumerator
None 
Expunged 
FlagsChanged 
JustArrived 
WasWrittenTo 
Committed 
CustomFlagsChanged 

Definition at line 243 of file maildirmessage.h.

Constructor & Destructor Documentation

◆ MaildirMessage() [1/2]

MaildirMessage ( Maildir home)

Definition at line 383 of file maildirmessage.cc.

◆ ~MaildirMessage()

~MaildirMessage ( void  )

Definition at line 406 of file maildirmessage.cc.

◆ MaildirMessage() [2/2]

MaildirMessage ( const MaildirMessage copy)

Definition at line 391 of file maildirmessage.cc.

Member Function Documentation

◆ appendChunk()

bool appendChunk ( const std::string &  chunk)
virtual

Appends a chunk of bytes to a message. appendChunk() is used for copying or appending a message to a mailbox.

Parameters
chunkThe content of this string is appended to the message.

Implements Message.

Definition at line 679 of file maildirmessage.cc.

Here is the call graph for this function:

◆ bodyContains()

bool bodyContains ( const std::string &  text)
virtual

Implements Message.

Definition at line 927 of file maildirmessage.cc.

Here is the call graph for this function:

◆ clearInternalFlag()

void clearInternalFlag ( unsigned char  flags)

Removes the internal flags.

Parameters
flagsa bitmask of the Flags enum.

Definition at line 1097 of file maildirmessage.cc.

Here is the caller graph for this function:

◆ close()

void close ( void  )
virtual

Resets a message and frees all allocated resources.

Implements Message.

Definition at line 441 of file maildirmessage.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getBodySize()

unsigned int getBodySize ( const std::string &  section,
unsigned int  startOffset = 0,
unsigned int  length = UINTMAX 
) const
virtual

Implements Message.

Definition at line 851 of file maildirmessage.cc.

Here is the call graph for this function:

◆ getCustomFlags()

vector< string > getCustomFlags ( void  ) const
virtual

Implements Message.

Definition at line 1147 of file maildirmessage.cc.

Here is the caller graph for this function:

◆ getDocSize()

unsigned int getDocSize ( unsigned int  startOffset = 0,
unsigned int  length = UINTMAX,
bool  onlyText = false 
) const
virtual

Implements Message.

Definition at line 891 of file maildirmessage.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFile()

int getFile ( void  ) const
protected

Definition at line 583 of file maildirmessage.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFileName()

string getFileName ( void  ) const
protected

Definition at line 645 of file maildirmessage.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFixedFilename()

std::string getFixedFilename ( void  ) const
protected

◆ getHeader()

const std::string & getHeader ( const std::string &  header)
virtual

Returns the first occurrance of a MIME header in a message, counting from the top of the message and downwards, or "" if no such header is found.

Parameters
headerThe name of the header to be fetched.

Implements Message.

Definition at line 995 of file maildirmessage.cc.

Here is the call graph for this function:

◆ getHeaderSize()

unsigned int getHeaderSize ( const std::string &  section,
std::vector< std::string >  headers,
bool  includeHeaders = false,
unsigned int  startOffset = 0,
unsigned int  length = UINTMAX,
bool  mime = false 
) const
virtual

Implements Message.

Definition at line 795 of file maildirmessage.cc.

Here is the call graph for this function:

◆ getInternalDate()

time_t getInternalDate ( void  ) const
virtual

Returns the internal date of the message in seconds since the epoch.

Implements Message.

Definition at line 539 of file maildirmessage.cc.

Here is the caller graph for this function:

◆ getInternalFlags()

unsigned char getInternalFlags ( void  ) const

Returns the internal flags.

Definition at line 1091 of file maildirmessage.cc.

Here is the caller graph for this function:

◆ getSafeName()

const string & getSafeName ( void  ) const
protected

Definition at line 639 of file maildirmessage.cc.

Here is the caller graph for this function:

◆ getSize()

unsigned int getSize ( bool  determine = false) const
virtual

Returns the size of the message, optionally determining the size if it is not yet known.

Parameters
determineIf render is true and the size is unknown, the size will be calculated and stored implicitly. Otherwise if the size is unknown, 0 is returned.

Implements Message.

Definition at line 522 of file maildirmessage.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getStdFlags()

unsigned char getStdFlags ( void  ) const
virtual

Returns the flags that are set on a message.

Implements Message.

Definition at line 504 of file maildirmessage.cc.

Here is the caller graph for this function:

◆ getUID()

unsigned int getUID ( void  ) const
virtual

Returns the UID of a message.

Implements Message.

Definition at line 516 of file maildirmessage.cc.

Here is the caller graph for this function:

◆ getUnique()

const string & getUnique ( void  ) const

Definition at line 533 of file maildirmessage.cc.

Here is the caller graph for this function:

◆ hasFlagsChanged()

bool hasFlagsChanged ( void  ) const
virtual

Returns true if flags have been added or reset since the last call to setFlagsUnchanged(), otherwise returns false.

Implements Message.

Definition at line 498 of file maildirmessage.cc.

◆ headerContains()

bool headerContains ( const std::string &  header,
const std::string &  text 
)
virtual

Implements Message.

Definition at line 909 of file maildirmessage.cc.

Here is the call graph for this function:

◆ isExpunged()

bool isExpunged ( void  ) const
virtual

Returns true if the message is marked as expunged, otherwise returns false.

Implements Message.

Definition at line 510 of file maildirmessage.cc.

Here is the caller graph for this function:

◆ operator<()

bool operator< ( const MaildirMessage a) const

Definition at line 436 of file maildirmessage.cc.

◆ operator=()

MaildirMessage & operator= ( const MaildirMessage copy)

Definition at line 412 of file maildirmessage.cc.

◆ parseFull()

bool parseFull ( void  ) const
protected

Definition at line 717 of file maildirmessage.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parseHeaders()

bool parseHeaders ( void  ) const
protected

Definition at line 739 of file maildirmessage.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ printBody()

bool printBody ( const std::string &  section = "",
unsigned int  startOffset = 0,
unsigned int  length = UINTMAX 
) const
virtual

Implements Message.

Definition at line 828 of file maildirmessage.cc.

Here is the call graph for this function:

◆ printBodyStructure()

bool printBodyStructure ( bool  extended = true) const
virtual

Implements Message.

Definition at line 762 of file maildirmessage.cc.

Here is the call graph for this function:

◆ printDoc()

bool printDoc ( unsigned int  startOffset = 0,
unsigned int  length = UINTMAX,
bool  onlyText = false 
) const
virtual

Implements Message.

Definition at line 872 of file maildirmessage.cc.

Here is the call graph for this function:

◆ printEnvelope()

bool printEnvelope ( void  ) const
virtual

Implements Message.

Definition at line 772 of file maildirmessage.cc.

Here is the call graph for this function:

◆ printHeader()

bool printHeader ( const std::string &  section,
std::vector< std::string >  headers,
bool  includeHeaders = false,
unsigned int  startOffset = 0,
unsigned int  length = UINTMAX,
bool  mime = false 
) const
virtual

Implements Message.

Definition at line 782 of file maildirmessage.cc.

◆ readChunk()

int readChunk ( std::string &  chunk)
virtual

Reads a chunk of up to 4096 bytes from a message. Call close() before readChunk() to read the first chunk from a message.

readChunk() is used for copying or appending a message to a mailbox.

Parameters
chunkThe characters are stored in this string.

Implements Message.

Definition at line 659 of file maildirmessage.cc.

Here is the call graph for this function:

◆ removeCustomFlag()

void removeCustomFlag ( const std::string &  flag)
virtual

Implements Message.

Definition at line 1121 of file maildirmessage.cc.

◆ resetCustomFlags()

void resetCustomFlags ( void  )
virtual

Implements Message.

Definition at line 1138 of file maildirmessage.cc.

Here is the caller graph for this function:

◆ resetStdFlags()

void resetStdFlags ( void  )
virtual

Resets all flags on a message.

Implements Message.

Definition at line 558 of file maildirmessage.cc.

◆ setCustomFlag()

void setCustomFlag ( const std::string &  flag)
virtual

Implements Message.

Definition at line 1103 of file maildirmessage.cc.

Here is the caller graph for this function:

◆ setExpunged()

void setExpunged ( void  )
virtual

Marks the message as expunged. Equivalent to calling setStdFlag() with F_EXPUNGED.

Implements Message.

Definition at line 480 of file maildirmessage.cc.

Here is the caller graph for this function:

◆ setFile()

void setFile ( int  fd)
protected

Definition at line 627 of file maildirmessage.cc.

Here is the caller graph for this function:

◆ setFlagsUnchanged()

void setFlagsUnchanged ( void  )
virtual

Sets a state in a message that indicates that no flags have been changed. Used together with hasFlagsChanged() to check if the flags in this message have been changed.

Implements Message.

Definition at line 492 of file maildirmessage.cc.

Here is the caller graph for this function:

◆ setInternalDate()

void setInternalDate ( time_t  internaldate)
virtual

Sets the internal date of a message. This is usually the date in which the message arrived in the mailbox.

Parameters
internaldateThe internal date of the message in seconds since the epoch.

Implements Message.

Definition at line 545 of file maildirmessage.cc.

Here is the caller graph for this function:

◆ setInternalFlag()

void setInternalFlag ( unsigned char  flags)

Sets the internal flags.

Parameters
flagsa bitmask of the Flags enum.

Definition at line 1085 of file maildirmessage.cc.

Here is the caller graph for this function:

◆ setSafeName()

void setSafeName ( const std::string &  name)
protected

Definition at line 633 of file maildirmessage.cc.

Here is the caller graph for this function:

◆ setSize()

void setSize ( unsigned int  size)
virtual

Sets the size of the message. This size must be consistent with the size reported when fetching the full message.

Parameters
sizeThe size of the message in characters, after any conversion to CRLF.

Implements Message.

Definition at line 571 of file maildirmessage.cc.

Here is the caller graph for this function:

◆ setStdFlag()

void setStdFlag ( unsigned char  flags)
virtual

Adds one or more flags to a message.

Parameters
flagsThis is a bitmask of flags from the Flags enum.

Implements Message.

Definition at line 551 of file maildirmessage.cc.

Here is the caller graph for this function:

◆ setUID()

void setUID ( unsigned int  uid)
virtual

Sets the UID of a message.

Parameters
uidThe UID that will be set.

Implements Message.

Definition at line 565 of file maildirmessage.cc.

Here is the caller graph for this function:

◆ setUnExpunged()

void setUnExpunged ( void  )
virtual

Removes the F_EXPUNGED flag from the message.

Implements Message.

Definition at line 486 of file maildirmessage.cc.

◆ setUnique()

void setUnique ( const std::string &  s_in)

Definition at line 577 of file maildirmessage.cc.

Here is the caller graph for this function:

◆ textContains()

bool textContains ( const std::string &  text)
virtual

Implements Message.

Definition at line 965 of file maildirmessage.cc.

Here is the call graph for this function:

Friends And Related Function Documentation

◆ Maildir

friend class Maildir
friend

Definition at line 236 of file maildirmessage.h.


The documentation for this class was generated from the following files: