21#ifndef G_SMTP_FILE_STORE_H
22#define G_SMTP_FILE_STORE_H
41 class DirectoryReader ;
60 G_EXCEPTION( InvalidDirectory ,
"invalid spool directory" ) ;
61 G_EXCEPTION( GetError ,
"error reading specific message" ) ;
63 FileStore(
const G::Path & dir ,
unsigned long max_size ,
bool test_for_eight_bit ) ;
70 std::unique_ptr<std::ofstream>
stream(
const G::Path & path ) ;
79 bool empty()
const override ;
85 std::unique_ptr<StoredMessage>
get(
const MessageId & )
override ;
88 std::shared_ptr<MessageStore::Iterator>
iterator(
bool lock )
override ;
91 std::shared_ptr<MessageStore::Iterator>
failures()
override ;
94 std::unique_ptr<NewMessage>
newMessage(
const std::string & from ,
95 const std::string & from_auth_in ,
const std::string & from_auth_out )
override ;
98 static std::string
x() ;
101 static std::string
format(
int generation = 0 ) ;
119 void rescan()
override ;
120 void unfailAll()
override ;
126 void operator=(
const FileStore & ) = delete ;
127 void operator=(
FileStore && ) = delete ;
130 static void checkPath(
const G::Path & dir ) ;
131 G::Path fullPath(
const std::string & filename )
const ;
132 std::string filePrefix(
unsigned long seq )
const ;
133 std::string getline( std::istream & )
const ;
134 std::string value(
const std::string & )
const ;
135 std::shared_ptr<MessageStore::Iterator> iteratorImp(
bool ) ;
136 void unfailAllImp() ;
137 static const std::string & crlf() ;
138 bool emptyCore()
const ;
142 unsigned long m_seq ;
144 unsigned long m_max_size ;
145 bool m_test_for_eight_bit ;
146 unsigned long m_pid_modifier ;
169 void operator=(
const FileReader & ) = delete ;
213 void operator=(
const FileWriter & ) = delete ;
Used by GSmtp::FileStore, GSmtp::NewFile and GSmtp::StoredFile to claim read permissions for reading ...
~DirectoryReader()
Destructor. Switches identity back.
DirectoryReader()
Default constructor.
Used by GSmtp::FileStore, GSmtp::NewFile and GSmtp::StoredFile to claim read permissions for reading ...
FileReader()
Default constructor.
~FileReader()
Destructor. Switches identity back.
A concrete implementation of the MessageStore interface dealing in paired flat files.
G::Slot::Signal & messageStoreRescanSignal() override
Override from GSmtp::MessageStore.
FileStore(const G::Path &dir, unsigned long max_size, bool test_for_eight_bit)
Constructor.
std::unique_ptr< StoredMessage > get(const MessageId &) override
Override from GSmtp::MessageStore.
std::shared_ptr< MessageStore::Iterator > failures() override
Override from GSmtp::MessageStore.
static bool knownFormat(const std::string &format)
Returns true if the storage format string is recognised and supported for reading.
void updated() override
Override from GSmtp::MessageStore.
std::unique_ptr< std::ofstream > stream(const G::Path &path)
Returns a stream to the given content.
G::Path contentPath(const MessageId &) const
Returns the path for a content file.
std::shared_ptr< MessageStore::Iterator > iterator(bool lock) override
Override from GSmtp::MessageStore.
std::unique_ptr< NewMessage > newMessage(const std::string &from, const std::string &from_auth_in, const std::string &from_auth_out) override
Override from GSmtp::MessageStore.
static std::string x()
Returns the prefix for envelope header lines.
G::Path envelopePath(const MessageId &, const char *modifier="") const
Returns the path for an envelope file.
static std::string format(int generation=0)
Returns an identifier for the storage format implemented by this class, or some older generation of i...
bool empty() const override
Override from GSmtp::MessageStore.
std::string location(const MessageId &) const override
Override from GSmtp::MessageStore.
G::Slot::Signal & messageStoreUpdateSignal() override
Override from GSmtp::MessageStore.
MessageId newId()
Hands out a new message id.
Used by GSmtp::FileStore, GSmtp::NewFile and GSmtp::StoredFile to claim write permissions.
~FileWriter()
Destructor. Switches identity back.
FileWriter()
Default constructor.
A somewhat opaque identifer for a MessageStore message.
A class which allows SMTP messages to be stored and retrieved.
A Path object represents a file system path.
Used to temporarily modify the process umask.
A class which acquires the process's special privileges on construction and releases them on destruct...
SMTP and message-store classes.
A slot holder, with connect() and emit() methods.