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>
Public Member Functions | |
FileStore (const G::Path &dir, bool optimise=false, unsigned long max_size=0UL) | |
Constructor. More... | |
unsigned long | newSeq () |
Hands out a new non-zero sequence number. More... | |
std::auto_ptr< std::ostream > | stream (const G::Path &path) |
Returns a stream to the given content. More... | |
G::Path | contentPath (unsigned long seq) const |
Returns the path for a content file. More... | |
G::Path | envelopePath (unsigned long seq) const |
Returns the path for an envelope file. More... | |
G::Path | envelopeWorkingPath (unsigned long seq) const |
Returns the path for an envelope file which is in the process of being written. More... | |
virtual bool | empty () const |
Final override from GSmtp::MessageStore. More... | |
virtual std::auto_ptr< StoredMessage > | get (unsigned long id) |
Final override from GSmtp::MessageStore. More... | |
virtual MessageStore::Iterator | iterator (bool lock) |
Final override from GSmtp::MessageStore. More... | |
virtual MessageStore::Iterator | failures () |
Final override from GSmtp::MessageStore. More... | |
virtual std::auto_ptr< NewMessage > | newMessage (const std::string &from) |
Final override from GSmtp::MessageStore. More... | |
virtual void | repoll () |
Final override from GSmtp::MessageStore. More... | |
virtual void | unfailAll () |
Final override from GSmtp::MessageStore. More... | |
virtual void | updated () |
Final override from GSmtp::MessageStore. More... | |
virtual G::Signal1< bool > & | signal () |
Final override from GSmtp::MessageStore. More... | |
![]() | |
virtual | ~MessageStore () |
Destructor. More... | |
Static Public Member Functions | |
static std::string | x () |
Returns the prefix for envelope header lines. More... | |
static std::string | format () |
Returns an identifier for the storage format implemented by this class. More... | |
static bool | knownFormat (const std::string &format) |
Returns true if the storage format string is recognised and supported for reading. More... | |
![]() | |
static G::Path | defaultDirectory () |
Returns a default spool directory, such as "/usr/local/var/spool/emailrelay". More... | |
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.
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().
G::Path GSmtp::FileStore::contentPath | ( | unsigned long | seq | ) | const |
Returns the path for a content file.
Definition at line 161 of file gfilestore.cpp.
Referenced by GSmtp::NewFile::NewFile().
|
virtual |
Final override from GSmtp::MessageStore.
Implements GSmtp::MessageStore.
Definition at line 199 of file gfilestore.cpp.
G::Path GSmtp::FileStore::envelopePath | ( | unsigned long | seq | ) | const |
Returns the path for an envelope file.
Definition at line 166 of file gfilestore.cpp.
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 171 of file gfilestore.cpp.
|
virtual |
Final override from GSmtp::MessageStore.
Implements GSmtp::MessageStore.
Definition at line 227 of file gfilestore.cpp.
|
static |
Returns an identifier for the storage format implemented by this class.
Definition at line 115 of file gfilestore.cpp.
|
virtual |
Final override from GSmtp::MessageStore.
Implements GSmtp::MessageStore.
Definition at line 232 of file gfilestore.cpp.
References G_LOG, and G::Path::str().
|
virtual |
Final override from GSmtp::MessageStore.
Implements GSmtp::MessageStore.
Definition at line 222 of file gfilestore.cpp.
|
static |
Returns true if the storage format string is recognised and supported for reading.
Definition at line 120 of file gfilestore.cpp.
|
virtual |
Final override from GSmtp::MessageStore.
Implements GSmtp::MessageStore.
Definition at line 255 of file gfilestore.cpp.
unsigned long GSmtp::FileStore::newSeq | ( | ) |
Hands out a new non-zero sequence number.
Definition at line 191 of file gfilestore.cpp.
Referenced by GSmtp::NewFile::NewFile().
|
virtual |
Final override from GSmtp::MessageStore.
Implements GSmtp::MessageStore.
Definition at line 274 of file gfilestore.cpp.
|
virtual |
Final override from GSmtp::MessageStore.
Implements GSmtp::MessageStore.
Definition at line 269 of file gfilestore.cpp.
std::auto_ptr< std::ostream > GSmtp::FileStore::stream | ( | const G::Path & | path | ) |
Returns a stream to the given content.
Definition at line 152 of file gfilestore.cpp.
References G::Path::str().
Referenced by GSmtp::NewFile::NewFile().
|
virtual |
Final override from GSmtp::MessageStore.
Implements GSmtp::MessageStore.
Definition at line 279 of file gfilestore.cpp.
References G_DEBUG, and GSmtp::MessageStore::Iterator::next().
|
virtual |
Final override from GSmtp::MessageStore.
Implements GSmtp::MessageStore.
Definition at line 261 of file gfilestore.cpp.
References G_DEBUG.
|
static |
Returns the prefix for envelope header lines.
Definition at line 110 of file gfilestore.cpp.