E-MailRelay
|
A concete class implementing the GStore::StoredMessage interface for separate envelope and content files in a spool directory. More...
#include <gstoredfile.h>
Public Types | |
using | State = FileStore::State |
Public Member Functions | |
StoredFile (FileStore &store, const MessageId &, State=State::Normal) | |
Constructor. More... | |
~StoredFile () override | |
Destructor. More... | |
bool | lock () |
Locks the file by renaming the envelope file. More... | |
bool | readEnvelope (std::string &reason) |
Reads the envelope. More... | |
bool | openContent (std::string &reason) |
Opens the content file. Returns false on error. More... | |
MessageId | id () const override |
Override from GStore::StoredMessage. More... | |
void | noUnlock () |
Disable unlocking in the destructor. More... | |
void | editEnvelope (std::function< void(Envelope &)>, std::istream *headers=nullptr) |
Edits the envelope and updates it in the file store. More... | |
StoredFile (const StoredFile &)=delete | |
StoredFile (StoredFile &&)=delete | |
StoredFile & | operator= (const StoredFile &)=delete |
StoredFile & | operator= (StoredFile &&)=delete |
![]() | |
virtual MessageId | id () const =0 |
Returns the message identifier. More... | |
virtual std::string | location () const =0 |
Returns the message location. | |
virtual std::string | from () const =0 |
Returns the envelope 'from' field. | |
virtual std::string | to (std::size_t) const =0 |
Returns the requested envelope non-local recipient or the empty string if out of range. | |
virtual std::size_t | toCount () const =0 |
Returns the number of non-local recipients. | |
virtual std::size_t | contentSize () const =0 |
Returns the content size. | |
virtual std::istream & | contentStream ()=0 |
Returns a reference to the content stream. | |
virtual void | close ()=0 |
Releases the message to allow external editing. | |
virtual std::string | reopen ()=0 |
Reverses a close(), returning the empty string on success or an error reason. | |
virtual void | destroy ()=0 |
Deletes the message within the store. | |
virtual void | fail (const std::string &reason, int reason_code)=0 |
Marks the message as failed within the store. | |
virtual MessageStore::BodyType | bodyType () const =0 |
Returns the message body type. | |
virtual std::string | authentication () const =0 |
Returns the original session authentication id. | |
virtual std::string | fromAuthIn () const =0 |
Returns the incoming "mail from" auth parameter, either empty, xtext-encoded or "<>". | |
virtual std::string | fromAuthOut () const =0 |
Returns the outgoing "mail from" auth parameter, either empty, xtext-encoded or "<>". | |
virtual std::string | forwardTo () const =0 |
Returns the routing override or the empty string. | |
virtual std::string | forwardToAddress () const =0 |
Returns the forwardTo() address or the empty string. | |
virtual std::string | clientAccountSelector () const =0 |
Returns the client account selector or the empty string. | |
virtual bool | utf8Mailboxes () const =0 |
Returns true if the mail-from command should have SMTPUTF8 (RFC-6531). | |
virtual void | editRecipients (const G::StringArray &)=0 |
Updates the message's remote recipients, typically to the sub-set that have not received it successfully. | |
virtual | ~StoredMessage ()=default |
Destructor. | |
A concete class implementing the GStore::StoredMessage interface for separate envelope and content files in a spool directory.
The GStore::MessageStore::Iterator interface is normally used to retrieve StoredFile instances.
Definition at line 51 of file gstoredfile.h.
using GStore::StoredFile::State = FileStore::State |
Definition at line 58 of file gstoredfile.h.
GStore::StoredFile::StoredFile | ( | FileStore & | store, |
const MessageId & | id, | ||
State | state = State::Normal |
||
) |
Constructor.
Definition at line 35 of file gstoredfile.cpp.
|
override |
Destructor.
Unlocks the file if it has been lock()ed but not destroy()ed or fail()ed or noUnlock()ed.
Definition at line 42 of file gstoredfile.cpp.
void GStore::StoredFile::editEnvelope | ( | std::function< void(Envelope &)> | edit_fn, |
std::istream * | headers = nullptr |
||
) |
Edits the envelope and updates it in the file store.
Optionally adds more trailing headers.
Definition at line 171 of file gstoredfile.cpp.
|
overridevirtual |
Override from GStore::StoredMessage.
Implements GStore::StoredMessage.
Definition at line 63 of file gstoredfile.cpp.
bool GStore::StoredFile::lock | ( | ) |
Locks the file by renaming the envelope file.
Definition at line 146 of file gstoredfile.cpp.
void GStore::StoredFile::noUnlock | ( | ) |
Disable unlocking in the destructor.
Definition at line 58 of file gstoredfile.cpp.
bool GStore::StoredFile::openContent | ( | std::string & | reason | ) |
Opens the content file. Returns false on error.
Definition at line 116 of file gstoredfile.cpp.
bool GStore::StoredFile::readEnvelope | ( | std::string & | reason | ) |
Reads the envelope.
Returns false on error with a reason; does not throw.
Definition at line 102 of file gstoredfile.cpp.