GSmtp::FileStore Class Reference

A concrete implementation of the MessageStore interface dealing in paired flat files and with an optional external preprocessor program which is used to process files once they have been stored. More...

#include <gfilestore.h>

Inheritance diagram for GSmtp::FileStore:

GSmtp::MessageStore

List of all members.

Public Member Functions

 FileStore (const G::Path &dir, bool optimise=false, unsigned long max_size=0UL)
 Constructor.
unsigned long newSeq ()
 Hands out a new non-zero sequence number.
std::auto_ptr< std::ostream > stream (const G::Path &path)
 Returns a stream to the given content.
G::Path contentPath (unsigned long seq) const
 Returns the path for a content file.
G::Path envelopePath (unsigned long seq) const
 Returns the path for an envelope file.
G::Path envelopeWorkingPath (unsigned long seq) const
 Returns the path for an envelope file which is in the process of being written.
virtual bool empty () const
 Final override from GSmtp::MessageStore.
virtual std::auto_ptr
< StoredMessage
get (unsigned long id)
 Final override from GSmtp::MessageStore.
virtual MessageStore::Iterator iterator (bool lock)
 Final override from GSmtp::MessageStore.
virtual std::auto_ptr< NewMessagenewMessage (const std::string &from)
 Final override from GSmtp::MessageStore.
virtual void repoll ()
 Final override from GSmtp::MessageStore.
virtual void updated ()
 Final override from GSmtp::MessageStore.
virtual G::Signal1< bool > & signal ()
 Final override from GSmtp::MessageStore.

Static Public Member Functions

static std::string x ()
 Returns the prefix for envelope header lines.
static std::string format ()
 Returns an identifier for the storage format implemented by this class.


Detailed Description

A concrete implementation of the MessageStore interface dealing in paired flat files and with an optional external preprocessor program which is used to process files once they have been stored.

The implementation puts separate envelope and content files in the spool directory. The content file is written first. The presence of a matching envelope file is used to indicate that the content file is valid and that it has been commited to the care of the SMTP system for delivery.

Passes out unique sequence numbers, filesystem paths and i/o streams to NewMessageImp.

Definition at line 62 of file gfilestore.h.


Constructor & Destructor Documentation

GSmtp::FileStore::FileStore ( const G::Path dir,
bool  optimise = false,
unsigned long  max_size = 0UL 
)

Constructor.

Throws an exception if the storage directory is invalid.

If the optimise flag is set then the implementation of empty() will be efficient for an empty filestore (ignoring failed and local-delivery messages). This might be useful for applications in which the main event loop is used to check for pending jobs. The disadvantage is that this process will not be sensititive to messages deposited into its spool directory by other processes.

Definition at line 98 of file gfilestore.cpp.

References G::DateTime::now().


Member Function Documentation

unsigned long GSmtp::FileStore::newSeq (  ) 

Hands out a new non-zero sequence number.

Definition at line 186 of file gfilestore.cpp.

Referenced by GSmtp::NewFile::NewFile().

std::auto_ptr< std::ostream > GSmtp::FileStore::stream ( const G::Path path  ) 

Returns a stream to the given content.

Definition at line 147 of file gfilestore.cpp.

References G::Path::str().

Referenced by GSmtp::NewFile::NewFile().

G::Path GSmtp::FileStore::contentPath ( unsigned long  seq  )  const

Returns the path for a content file.

Definition at line 156 of file gfilestore.cpp.

Referenced by GSmtp::NewFile::NewFile().

G::Path GSmtp::FileStore::envelopePath ( unsigned long  seq  )  const

Returns the path for an envelope file.

Definition at line 161 of file gfilestore.cpp.

Referenced by get(), and GSmtp::NewFile::prepare().

G::Path GSmtp::FileStore::envelopeWorkingPath ( unsigned long  seq  )  const

Returns the path for an envelope file which is in the process of being written.

Definition at line 166 of file gfilestore.cpp.

Referenced by GSmtp::NewFile::prepare().

bool GSmtp::FileStore::empty (  )  const [virtual]

Final override from GSmtp::MessageStore.

Implements GSmtp::MessageStore.

Definition at line 194 of file gfilestore.cpp.

std::auto_ptr< GSmtp::StoredMessage > GSmtp::FileStore::get ( unsigned long  id  )  [virtual]

Final override from GSmtp::MessageStore.

Implements GSmtp::MessageStore.

Definition at line 222 of file gfilestore.cpp.

References envelopePath(), G_LOG, and G::Path::str().

GSmtp::MessageStore::Iterator GSmtp::FileStore::iterator ( bool  lock  )  [virtual]

Final override from GSmtp::MessageStore.

Implements GSmtp::MessageStore.

Definition at line 217 of file gfilestore.cpp.

std::auto_ptr< GSmtp::NewMessage > GSmtp::FileStore::newMessage ( const std::string &  from  )  [virtual]

Final override from GSmtp::MessageStore.

Implements GSmtp::MessageStore.

Definition at line 245 of file gfilestore.cpp.

std::string GSmtp::FileStore::x (  )  [static]

Returns the prefix for envelope header lines.

Definition at line 110 of file gfilestore.cpp.

std::string GSmtp::FileStore::format (  )  [static]

Returns an identifier for the storage format implemented by this class.

Definition at line 115 of file gfilestore.cpp.

void GSmtp::FileStore::repoll (  )  [virtual]

Final override from GSmtp::MessageStore.

Implements GSmtp::MessageStore.

Definition at line 264 of file gfilestore.cpp.

Referenced by updated().

void GSmtp::FileStore::updated (  )  [virtual]

Final override from GSmtp::MessageStore.

Implements GSmtp::MessageStore.

Definition at line 251 of file gfilestore.cpp.

References G::Signal1< P >::emit(), G_DEBUG, and repoll().

Referenced by GSmtp::StoredFile::lock(), and GSmtp::NewFile::~NewFile().

G::Signal1< bool > & GSmtp::FileStore::signal (  )  [virtual]

Final override from GSmtp::MessageStore.

Implements GSmtp::MessageStore.

Definition at line 259 of file gfilestore.cpp.


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

Generated on Fri Apr 18 15:56:13 2008 for E-MailRelay by  doxygen 1.5.5