VMime
maildirFolder Class Reference

#include <maildirFolder.hpp>

Inheritance diagram for maildirFolder:
Collaboration diagram for maildirFolder:

Public Member Functions

 ~maildirFolder ()
int getMode () const
const folderAttributes getAttributes ()
const folder::path::component getName () const
const folder::path getFullPath () const
void open (const int mode, bool failIfModeIsNotAvailable=false)
void close (const bool expunge)
void create (const folderAttributes &attribs)
bool exists ()
void destroy ()
bool isOpen () const
shared_ptr< messagegetMessage (const size_t num)
std::vector< shared_ptr< message > > getMessages (const messageSet &msgs)
size_t getMessageCount ()
shared_ptr< foldergetFolder (const folder::path::component &name)
std::vector< shared_ptr< folder > > getFolders (const bool recursive=false)
void rename (const folder::path &newPath)
void deleteMessages (const messageSet &msgs)
void setMessageFlags (const messageSet &msgs, const int flags, const int mode=message::FLAG_MODE_SET)
messageSet addMessage (shared_ptr< vmime::message > msg, const int flags=-1, vmime::datetime *date=NULL, utility::progressListener *progress=NULL)
messageSet addMessage (utility::inputStream &is, const size_t size, const int flags=-1, vmime::datetime *date=NULL, utility::progressListener *progress=NULL)
messageSet copyMessages (const folder::path &dest, const messageSet &msgs)
void status (size_t &count, size_t &unseen)
shared_ptr< folderStatusgetStatus ()
void expunge ()
shared_ptr< foldergetParent ()
shared_ptr< const storegetStore () const
shared_ptr< storegetStore ()
void fetchMessages (std::vector< shared_ptr< message > > &msg, const fetchAttributes &options, utility::progressListener *progress=NULL)
void fetchMessage (shared_ptr< message > msg, const fetchAttributes &options)
std::vector< shared_ptr< message > > getAndFetchMessages (const messageSet &msgs, const fetchAttributes &attribs)
int getFetchCapabilities () const
std::vector< size_tgetMessageNumbersStartingOnUID (const message::uid &uid)
Public Member Functions inherited from folder
virtual ~folder ()
int getType ()
int getFlags ()
void addMessageChangedListener (events::messageChangedListener *l)
void removeMessageChangedListener (events::messageChangedListener *l)
void addMessageCountListener (events::messageCountListener *l)
void removeMessageCountListener (events::messageCountListener *l)
void addFolderListener (events::folderListener *l)
void removeFolderListener (events::folderListener *l)

Additional Inherited Members

Public Types inherited from folder
enum  Modes { MODE_READ_ONLY , MODE_READ_WRITE }
typedef vmime::utility::path path
Protected Types inherited from folder
enum  PrivateConstants { TYPE_UNDEFINED = 9999 , FLAG_UNDEFINED = 9999 }
Protected Member Functions inherited from folder
 folder (const folder &)
 folder ()
void notifyMessageChanged (shared_ptr< events::messageChangedEvent > event)
void notifyMessageCount (shared_ptr< events::messageCountEvent > event)
void notifyFolder (shared_ptr< events::folderEvent > event)
void notifyEvent (shared_ptr< events::event > event)
Protected Member Functions inherited from object
 object ()
 object (const object &)
objectoperator= (const object &)
virtual ~object ()

Detailed Description

maildir folder implementation.

Constructor & Destructor Documentation

◆ ~maildirFolder()

~maildirFolder ( )

References close(), and ~maildirFolder().

Referenced by ~maildirFolder().

Member Function Documentation

◆ addMessage() [1/2]

messageSet addMessage ( shared_ptr< vmime::message > msg,
const int flags = -1,
vmime::datetime * date = NULL,
utility::progressListener * progress = NULL )
virtual

Add a message to this folder.

Parameters
msgmessage to add (data: header + body)
flagsflags for the new message (if -1, default flags are used)
datedate/time for the new message (if NULL, the current time is used)
progressprogress listener, or NULL if not used
Returns
a message set containing the number or UID of the new message, or an empty set if the information could not be obtained (ie. the server does not support returning the number or UID of an added message)
Exceptions
exceptions::net_exceptionif an error occurs

Implements folder.

References addMessage().

Referenced by addMessage(), and addMessage().

◆ addMessage() [2/2]

messageSet addMessage ( utility::inputStream & is,
const size_t size,
const int flags = -1,
vmime::datetime * date = NULL,
utility::progressListener * progress = NULL )
virtual

Add a message to this folder.

Parameters
ismessage to add (data: header + body)
sizesize of the message to add (in bytes)
flagsflags for the new message (if -1, default flags are used)
datedate/time for the new message (if NULL, the current time is used)
progressprogress listener, or NULL if not used
Returns
a message set containing the number or UID of the new message, or an empty set if the information could not be obtained (ie. the server does not support returning the number or UID of an added message)
Exceptions
exceptions::net_exceptionif an error occurs

Implements folder.

References addMessage(), maildirFormat::CUR_DIRECTORY, messageSet::empty(), message::FLAG_RECENT, message::FLAG_SEEN, platform::getHandler(), isOpen(), folder::MODE_READ_ONLY, maildirFormat::NEW_DIRECTORY, folder::notifyMessageCount(), maildirFormat::TMP_DIRECTORY, and messageCountEvent::TYPE_ADDED.

◆ close()

void close ( const bool expunge)
virtual

Close this folder.

Parameters
expungeif set to true, deleted messages are expunged
Exceptions
exceptions::net_exceptionif an error occurs

Implements folder.

References close(), expunge(), and isOpen().

Referenced by close(), and ~maildirFolder().

◆ copyMessages()

messageSet copyMessages ( const folder::path & dest,
const messageSet & msgs )
virtual

Copy messages from this folder to another folder.

Parameters
destdestination folder path
msgsindex set of messages to copy
Returns
a message set containing the number(s) or UID(s) of the copied message(s), or an empty set if the information could not be obtained (ie. the server does not support returning the number or UID of a copied message)
Exceptions
exceptions::net_exceptionif an error occurs

Implements folder.

References copyMessages(), maildirFormat::CUR_DIRECTORY, messageSet::empty(), platform::getHandler(), isOpen(), and maildirFormat::TMP_DIRECTORY.

Referenced by copyMessages().

◆ create()

void create ( const folderAttributes & attribs)
virtual

Create this folder.

Parameters
attribsattributes of the new folder
Exceptions
exceptions::net_exceptionif an error occurs

Implements folder.

References create(), exists(), isOpen(), store::isValidFolderName(), folder::notifyFolder(), and folderEvent::TYPE_CREATED.

Referenced by create().

◆ deleteMessages()

void deleteMessages ( const messageSet & msgs)
virtual

Remove one or more messages from this folder.

Parameters
msgsindex set of messages to delete
Exceptions
exceptions::net_exceptionif an error occurs

Implements folder.

References deleteMessages(), message::FLAG_DELETED, message::FLAG_MODE_ADD, and setMessageFlags().

Referenced by deleteMessages().

◆ destroy()

void destroy ( )
virtual

Delete this folder.

The folder should be closed before attempting to delete it.

Exceptions
exceptions::net_exceptionif an error occurs

Implements folder.

References destroy(), isOpen(), folder::notifyFolder(), and folderEvent::TYPE_DELETED.

Referenced by destroy().

◆ exists()

bool exists ( )
virtual

Test whether this folder exists.

Returns
true if the folder exists, false otherwise

Implements folder.

References exists().

Referenced by create(), exists(), and open().

◆ expunge()

void expunge ( )
virtual

◆ fetchMessage()

void fetchMessage ( shared_ptr< message > msg,
const fetchAttributes & attribs )
virtual

Fetch objects for the specified message.

Parameters
msgthe message
attribsset of attributes to fetch
Exceptions
exceptions::net_exceptionif an error occurs

Implements folder.

References fetchMessage(), and isOpen().

Referenced by fetchMessage().

◆ fetchMessages()

void fetchMessages ( std::vector< shared_ptr< message > > & msg,
const fetchAttributes & attribs,
utility::progressListener * progress = NULL )
virtual

Fetch objects for the specified messages.

Parameters
msglist of message sequence numbers
attribsset of attributes to fetch
progressprogress listener, or NULL if not used
Exceptions
exceptions::net_exceptionif an error occurs

Implements folder.

References fetchMessages(), isOpen(), progressListener::progress(), progressListener::start(), and progressListener::stop().

Referenced by fetchMessages(), and getAndFetchMessages().

◆ getAndFetchMessages()

std::vector< shared_ptr< message > > getAndFetchMessages ( const messageSet & msgs,
const fetchAttributes & attribs )
virtual

Get new references to messages in this folder, given either their sequence numbers or UIDs, and fetch objects for them at the same time.

Parameters
msgsindex set of messages to retrieve
attribsset of attributes to fetch
Returns
new objects referencing the specified messages
Exceptions
exceptions::net_exceptionif an error occurs
See also
folder::getMessages()
folder::fetchMessages()

Implements folder.

References fetchMessages(), getAndFetchMessages(), getMessages(), and messageSet::isEmpty().

Referenced by getAndFetchMessages().

◆ getAttributes()

const folderAttributes getAttributes ( )
virtual

Return the attributes of the folder.

Returns
folder attributes (see folder::Flags)

Implements folder.

References folderAttributes::FLAG_HAS_CHILDREN, getAttributes(), folderAttributes::setFlags(), folderAttributes::setType(), folderAttributes::TYPE_CONTAINS_FOLDERS, and folderAttributes::TYPE_CONTAINS_MESSAGES.

Referenced by getAttributes().

◆ getFetchCapabilities()

int getFetchCapabilities ( ) const
virtual

Return the list of fetchable objects supported by the underlying protocol (see folder::fetchAttributes).

Returns
list of supported fetchable objects

Implements folder.

References fetchAttributes::CONTENT_INFO, fetchAttributes::ENVELOPE, fetchAttributes::FLAGS, fetchAttributes::FULL_HEADER, getFetchCapabilities(), fetchAttributes::IMPORTANCE, fetchAttributes::SIZE, fetchAttributes::STRUCTURE, and fetchAttributes::UID.

Referenced by getFetchCapabilities().

◆ getFolder()

shared_ptr< folder > getFolder ( const folder::path::component & name)
virtual

Get a new reference to a sub-folder in this folder.

Parameters
namesub-folder name
Returns
a new object referencing the specified folder
Exceptions
exceptions::net_exceptionif an error occurs

Implements folder.

References getFolder().

Referenced by getFolder().

◆ getFolders()

std::vector< shared_ptr< folder > > getFolders ( const bool recursive = false)
virtual

Get the list of all sub-folders in this folder.

Parameters
recursiveif set to true, all the descendant are returned. If set to false, only the direct children are returned.
Returns
list of sub-folders
Exceptions
exceptions::net_exceptionif an error occurs

Implements folder.

References getFolders(), and isOpen().

Referenced by getFolders().

◆ getFullPath()

const folder::path getFullPath ( ) const
virtual

Return the fully qualified path name of this folder.

Returns
absolute path of the folder

Implements folder.

References getFullPath().

Referenced by getFullPath().

◆ getMessage()

shared_ptr< message > getMessage ( const size_t num)
virtual

Get a new reference to a message in this folder, given its number.

Parameters
nummessage sequence number
Returns
a new object referencing the specified message
Exceptions
exceptions::net_exceptionif an error occurs

Implements folder.

References getMessage(), and isOpen().

Referenced by getMessage().

◆ getMessageCount()

size_t getMessageCount ( )
virtual

Return the number of messages in this folder.

Returns
number of messages in the folder

Implements folder.

References getMessageCount().

Referenced by getMessageCount().

◆ getMessageNumbersStartingOnUID()

std::vector< size_t > getMessageNumbersStartingOnUID ( const message::uid & uid)
virtual

Return the sequence numbers of messages whose UID equal or greater than the specified UID.

Parameters
uidthe uid of the first message
Exceptions
exceptions::net_exceptionif an error occurs

Implements folder.

References getMessageNumbersStartingOnUID().

Referenced by getMessageNumbersStartingOnUID().

◆ getMessages()

std::vector< shared_ptr< message > > getMessages ( const messageSet & msgs)
virtual

Get new references to messages in this folder, given either their sequence numbers or UIDs.

To retrieve messages by their number, use:

// Get messages from sequence number 5 to sequence number 8 (including)
// Get all messages in the folder, starting from number 42
folder(const folder &)
Definition folder.hpp:66
static messageSet byNumber(const size_t number)
Constructs a new message set and initializes it with a single message represented by its sequence num...
Definition messageSet.cpp:180

Or, to retrieve messages by their UID, use:

// Get messages from UID 1000 to UID 1042 (including)
folder->getMessage(vmime::net::messageSet::byUID(1000, 1042));
// Get message with UID 1042
// Get all messages in the folder, starting from UID 1000
folder->getMessage(vmime::net::messageSet::byUID(1000, "*"));
static messageSet byUID(const message::uid &uid)
Constructs a new message set and initializes it with a single message represented by its UID.
Definition messageSet.cpp:253
Parameters
msgsindex set of messages to retrieve
Returns
new objects referencing the specified messages
Exceptions
exceptions::net_exceptionif an error occurs

Implements folder.

References getMessages(), messageSet::isNumberSet(), and isOpen().

Referenced by getAndFetchMessages(), and getMessages().

◆ getMode()

int getMode ( ) const
virtual

Return the mode in which the folder has been open.

Returns
folder opening mode (see folder::Modes)

Implements folder.

References getMode(), and isOpen().

Referenced by getMode().

◆ getName()

const folder::path::component getName ( ) const
virtual

Return the name of this folder.

Returns
folder name

Implements folder.

References getName().

Referenced by getName().

◆ getParent()

shared_ptr< folder > getParent ( )
virtual

Return a new folder object referencing the parent folder of this folder.

Returns
parent folder object

Implements folder.

References getParent().

Referenced by getParent().

◆ getStatus()

shared_ptr< folderStatus > getStatus ( )
virtual

Request folder status without opening it.

Returns
current folder status
Exceptions
exceptions::net_exceptionif an error occurs

Implements folder.

References getStatus(), folder::notifyMessageCount(), status(), and messageCountEvent::TYPE_ADDED.

Referenced by getStatus(), and status().

◆ getStore() [1/2]

shared_ptr< store > getStore ( )
virtual

Return a reference to the store to which this folder belongs.

Returns
the store object to which this folder is attached

Implements folder.

References getStore().

◆ getStore() [2/2]

shared_ptr< const store > getStore ( ) const
virtual

Return a reference to the store to which this folder belongs.

Returns
the store object to which this folder is attached

Implements folder.

References getStore().

Referenced by getStore(), and getStore().

◆ isOpen()

bool isOpen ( ) const
virtual

Test whether this folder is open.

Returns
true if the folder is open, false otherwise

Implements folder.

References isOpen().

Referenced by addMessage(), close(), copyMessages(), create(), destroy(), expunge(), fetchMessage(), fetchMessages(), getFolders(), getMessage(), getMessages(), getMode(), isOpen(), open(), and setMessageFlags().

◆ open()

void open ( const int mode,
bool failIfModeIsNotAvailable = false )
virtual

Open this folder.

Parameters
modeopen mode (see folder::Modes)
failIfModeIsNotAvailableif set to false and if the requested mode is not available, a more restricted mode will be selected automatically. If set to true and if the requested mode is not available, the opening will fail.
Exceptions
exceptions::net_exceptionif an error occurs
exceptions::folder_already_openif the folder is already open in the same session

Implements folder.

References exists(), isOpen(), and open().

Referenced by open().

◆ rename()

void rename ( const folder::path & newPath)
virtual

Rename (move) this folder to another location.

Parameters
newPathnew path of the folder
Exceptions
exceptions::net_exceptionif an error occurs

Implements folder.

References path::getLastComponent(), path::isEmpty(), path::isParentOf(), store::isValidFolderName(), folder::notifyFolder(), rename(), and folderEvent::TYPE_RENAMED.

Referenced by rename().

◆ setMessageFlags()

void setMessageFlags ( const messageSet & msgs,
const int flags,
const int mode = message::FLAG_MODE_SET )
virtual

Change the flags for one or more messages in this folder.

Parameters
msgsindex set of messages on which to set the flags
flagsset of flags (see message::Flags)
modeindicate how to treat old and new flags (see message::FlagsModes)
Exceptions
exceptions::net_exceptionif an error occurs

Implements folder.

References maildirFormat::CUR_DIRECTORY, message::FLAG_DELETED, message::FLAG_MODE_ADD, message::FLAG_MODE_REMOVE, message::FLAG_MODE_SET, message::FLAG_UNDEFINED, platform::getHandler(), messageSet::isNumberSet(), isOpen(), folder::MODE_READ_ONLY, folder::notifyMessageChanged(), setMessageFlags(), and messageChangedEvent::TYPE_FLAGS.

Referenced by deleteMessages(), and setMessageFlags().

◆ status()

void status ( size_t & count,
size_t & unseen )
virtual

Request folder status without opening it.

Deprecated
Use the new getStatus() method
Parameters
countwill receive the number of messages in the folder
unseenwill receive the number of unseen messages in the folder
Exceptions
exceptions::net_exceptionif an error occurs

Implements folder.

References vmime::count(), getStatus(), and status().

Referenced by getStatus(), and status().


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