E-MailRelay

Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
GStore::FileStore Class Reference

A concrete implementation of the MessageStore interface dealing in paired flat files. More...

`#include <gfilestore.h>`

Inheritance diagram for GStore::FileStore:
[legend]
Collaboration diagram for GStore::FileStore:
[legend]

## Classes
struct | Config
| Configuration structure for GStore::FileStore. More...
struct | FileOp
| Low-level file-system operations for GStore::FileStore. More...

## Public Types
enum class | State { New , Normal , Locked , Bad }
Public Types inherited from GStore::MessageStore
enum class | AddressStyle { Invalid , Ascii , Utf8Mailbox , Utf8Domain , Utf8Both }
enum class | BodyType { Unknown = -1 , SevenBit , EightBitMime , BinaryMime }

## Public Member Functions
| FileStore (const G::Path &spool_dir, const G::Path &delivery_dir, const Config &config)
| Constructor. More...
G::Path | directory () const
| Returns the spool directory path, as passed in to the constructor. More...
G::Path | deliveryDir () const
| Returns the base directory for local delivery. More...
MessageId | newId ()
| Hands out a new unique message id. More...
G::Path | contentPath (const MessageId &id) const
| Returns the path for a content file. More...
G::Path | envelopePath (const MessageId &id, State=State::Normal) const
| Returns the path for an envelope file. More...
| FileStore (const FileStore &)=delete
| FileStore (FileStore &&)=delete
FileStore & | operator= (const FileStore &)=delete
FileStore & | operator= (FileStore &&)=delete
Public Member Functions inherited from GStore::MessageStore
virtual | ~MessageStore ()=default
| Destructor.
virtual std::unique_ptr< NewMessage > | newMessage (const std::string &from, const SmtpInfo &smtp_info, const std::string &from_auth_out)=0
| Creates a new message.
virtual bool | empty () const =0
| Returns true if the message store is empty.
virtual std::string | location (const MessageId &) const =0
| Returns the location of the given message.
virtual std::unique_ptr< StoredMessage > | get (const MessageId &id)=0
| Pulls the specified message out of the store. More...
virtual std::unique_ptr< Iterator > | iterator (bool lock)=0
| Returns an iterator for stored messages. More...
virtual std::vector< MessageId > | ids ()=0
| Returns a list of spooled message ids (excluding new or locked messages).
virtual std::vector< MessageId > | failures ()=0
| Returns a list of failed message ids.
virtual void | unfailAll ()=0
| Unfails all failed messages.
virtual void | rescan ()=0
| Requests that a messageStoreRescanSignal() is emitted.
virtual void | updated ()=0
| Called by associated classes to indicate that the store has changed. More...
virtual G::Slot::Signal & | messageStoreUpdateSignal () noexcept=0
| Provides a signal which is emitted when something might have changed in the store.
virtual G::Slot::Signal & | messageStoreRescanSignal () noexcept=0
| Provides a signal which is emitted when rescan() is called.

## Static Public Member Functions
static G::Path | defaultDirectory ()
| Returns a default spool directory, such as "/var/spool/emailrelay". More...
static std::unique_ptr< std::ofstream > | stream (const G::Path &path)
| Opens an output stream to a message file using the appropriate effective userid and umask. More...
static std::string | x ()
| Returns the prefix for envelope header lines. More...
static std::string | format (int generation=0)
| Returns an identifier for the storage format implemented by this class, or some older generation of it (eg. More...
static bool | knownFormat (const std::string &format)
| Returns true if the storage format string is recognised and supported for reading. More...
static Envelope | readEnvelope (const G::Path &, std::ifstream *=nullptr)
| Used by FileStore sibling classes to read an envelope file. More...
Static Public Member Functions inherited from GStore::MessageStore
static AddressStyle | addressStyle (std::string_view address)
| Parses an address to determine whether it has ASCII or UTF-8 parts. More...

## Detailed Description

A concrete implementation of the MessageStore interface dealing in paired flat files.

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.

Definition at line 55 of file gfilestore.h.

## Member Enumeration Documentation

## ◆ State

enum class GStore::FileStore::State
| strong

Definition at line 61 of file gfilestore.h.

## Constructor & Destructor Documentation

## ◆ FileStore()

GStore::FileStore::FileStore | ( | const G::Path & | spool_dir,
|  | const G::Path & | delivery_dir,
|  | const Config & | config
| ) |  |

Constructor.

Throws an exception if the spool directory is invalid.

Definition at line 109 of file gfilestore.cpp.

## Member Function Documentation

## ◆ contentPath()

G::Path GStore::FileStore::contentPath | ( | const MessageId & | id | ) | const

Returns the path for a content file.

Definition at line 205 of file gfilestore.cpp.

## ◆ defaultDirectory()

G::Path GStore::FileStore::defaultDirectory | ( |  | ) |
| static

Returns a default spool directory, such as "/var/spool/emailrelay".

(Typically with an os-specific implementation.)

Definition at line 30 of file gfilestore_unix.cpp.

## ◆ deliveryDir()

G::Path GStore::FileStore::deliveryDir | ( |  | ) | const

Returns the base directory for local delivery.

Returns directory() by default.

Definition at line 124 of file gfilestore.cpp.

## ◆ directory()

G::Path GStore::FileStore::directory | ( |  | ) | const

Returns the spool directory path, as passed in to the constructor.

Definition at line 119 of file gfilestore.cpp.

## ◆ envelopePath()

G::Path GStore::FileStore::envelopePath | ( | const MessageId & | id,
|  | State | state = `State::Normal`
| ) |  | const

Returns the path for an envelope file.

Definition at line 210 of file gfilestore.cpp.

## ◆ format()

std::string GStore::FileStore::format | ( | int | generation = `0` | ) |
| static

Returns an identifier for the storage format implemented by this class, or some older generation of it (eg.

-1).

Definition at line 134 of file gfilestore.cpp.

## ◆ knownFormat()

bool GStore::FileStore::knownFormat | ( | const std::string & | format | ) |
| static

Returns true if the storage format string is recognised and supported for reading.

Definition at line 151 of file gfilestore.cpp.

## ◆ newId()

GStore::MessageId GStore::FileStore::newId | ( |  | ) |

Hands out a new unique message id.

Definition at line 222 of file gfilestore.cpp.

## ◆ readEnvelope()

GStore::Envelope GStore::FileStore::readEnvelope | ( | const G::Path & | envelope_path,
|  | std::ifstream * | stream_p = `nullptr`
| ) |  |
| static

Used by FileStore sibling classes to read an envelope file.

Optionally returns the newly-opened stream by reference so that any trailing headers can be read. Throws on error.

Definition at line 308 of file gfilestore.cpp.

## ◆ stream()

std::unique_ptr< std::ofstream > GStore::FileStore::stream | ( | const G::Path & | path | ) |
| static

Opens an output stream to a message file using the appropriate effective userid and umask.

Definition at line 198 of file gfilestore.cpp.

## ◆ x()

std::string GStore::FileStore::x | ( |  | ) |
| static

Returns the prefix for envelope header lines.

Definition at line 129 of file gfilestore.cpp.

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

- /tmp/slackdce/slackrepo.HKsbdz/build_emailrelay/emailrelay-2.6/src/gstore/gfilestore.h
- /tmp/slackdce/slackrepo.HKsbdz/build_emailrelay/emailrelay-2.6/src/gstore/gfilestore.cpp
- /tmp/slackdce/slackrepo.HKsbdz/build_emailrelay/emailrelay-2.6/src/gstore/gfilestore_unix.cpp
- /tmp/slackdce/slackrepo.HKsbdz/build_emailrelay/emailrelay-2.6/src/gstore/gfilestore_win32.cpp