21#ifndef G_SMTP_STORED_FILE_H
22#define G_SMTP_STORED_FILE_H
54 G_EXCEPTION( FormatError ,
tx(
"invalid envelope file") )
55 G_EXCEPTION( FilenameError ,
tx(
"invalid envelope filename") )
56 G_EXCEPTION( EditError ,
tx(
"cannot update envelope file") )
57 G_EXCEPTION( SizeError ,
tx(
"cannot get content file size") )
58 using State = FileStore::State ;
88 void fail(
const std::string & reason ,
int reason_code )
override ;
89 std::string location()
const override ;
90 MessageStore::BodyType bodyType()
const override ;
91 std::string from()
const override ;
92 std::string to( std::size_t )
const override ;
93 std::size_t toCount()
const override ;
94 std::string authentication()
const override ;
95 std::string fromAuthIn()
const override ;
96 std::string fromAuthOut()
const override ;
97 std::string forwardTo()
const override ;
98 std::string forwardToAddress()
const override ;
99 std::string clientAccountSelector()
const override ;
100 bool utf8Mailboxes()
const override ;
101 void close()
override ;
102 std::string reopen()
override ;
103 void destroy()
override ;
104 std::size_t contentSize()
const override ;
105 std::istream & contentStream()
override ;
120 explicit Stream(
const G::Path & ) ;
122 std::streamoff size()
const ;
129 const std::string & eol()
const ;
130 void addReason(
const G::Path & path ,
const std::string & ,
int )
const ;
131 static std::size_t writeEnvelopeImp(
const Envelope & ,
const G::Path & , std::ofstream & ) ;
135 std::unique_ptr<Stream> m_content ;
139 bool m_unlock {
false} ;
A structure containing the contents of an envelope file, with support for file reading,...
A concrete implementation of the MessageStore interface dealing in paired flat files.
A somewhat opaque identifer for a GStore::MessageStore message id.
A concete class implementing the GStore::StoredMessage interface for separate envelope and content fi...
bool openContent(std::string &reason)
Opens the content file. Returns false on error.
bool readEnvelope(std::string &reason)
Reads the envelope.
StoredFile(FileStore &store, const MessageId &, State=State::Normal)
Constructor.
bool lock()
Locks the file by renaming the envelope file.
void editEnvelope(std::function< void(Envelope &)>, std::istream *headers=nullptr)
Edits the envelope and updates it in the file store.
void noUnlock()
Disable unlocking in the destructor.
~StoredFile() override
Destructor.
MessageId id() const override
Override from GStore::StoredMessage.
An abstract interface for messages which have come from the store.
A Path object represents a file system path.
A simple file streambuf using a "file descriptor" and three function pointers for read,...
std::vector< std::string > StringArray
A std::vector of std::strings.
constexpr const char * tx(const char *p) noexcept
A briefer alternative to G::gettext_noop().
Low-level file-system operations for GStore::FileStore.