49 G_EXCEPTION( InvalidDirectory ,
tx(
"invalid spool directory") )
52 bool allow_delete {
true} ;
53 bool by_name {
false} ;
54 bool by_name_mkdir {
false} ;
56 Config & set_allow_delete(
bool =
true ) noexcept ;
57 Config & set_by_name(
bool =
true ) noexcept ;
58 Config & set_by_name_mkdir(
bool =
true ) noexcept ;
64 void prepare(
const std::string & user ) ;
87 static bool accessible(
const G::Path &
dir ,
bool ) ;
100 using Size =
unsigned long ;
101 StoreMessage(
const std::string & name , Size size ,
bool in_parent ) ;
105 std::string uidl()
const ;
112 bool deleted {
false} ;
137 std::vector<StoreMessage> m_list ;
149 G_EXCEPTION( CannotDelete ,
tx(
"cannot delete message file") )
150 G_EXCEPTION( CannotRead ,
tx(
"cannot read message file") )
151 using Size = StoreMessage::Size ;
152 using List = std::vector<StoreMessage> ;
160 List::const_iterator
cbegin()
const ;
163 List::const_iterator
cend()
const ;
166 List::value_type
get(
int id )
const ;
175 std::string
uidl(
int id )
const ;
178 bool valid(
int id )
const ;
184 std::unique_ptr<std::istream>
content(
int id )
const ;
206 void deleteFile(
const G::Path & ,
bool & )
const ;
210 bool m_allow_delete {
false} ;
213 std::vector<StoreMessage> m_list ;
216inline GPop::Store::Config & GPop::Store::Config::set_allow_delete(
bool b )
noexcept { allow_delete = b ;
return *this ; }
217inline GPop::Store::Config & GPop::Store::Config::set_by_name(
bool b )
noexcept { by_name = b ;
return *this ; }
218inline GPop::Store::Config & GPop::Store::Config::set_by_name_mkdir(
bool b )
noexcept { by_name_mkdir = b ;
return *this ; }
Represents the protocol's view of the pop store having 1-based message ids.
Size messageCount() const
Returns the store's message count.
std::string uidl(int id) const
Returns a message's unique 1-based id.
void rollback()
Rolls back remove()als.
Size byteCount(int id) const
Returns the message size.
bool valid(int id) const
Validates a message id.
StoreList()
Constructor for an empty list.
List::const_iterator cbegin() const
Returns the begin iterator.
std::unique_ptr< std::istream > content(int id) const
Retrieves the message content.
Size totalByteCount() const
Returns the store's total byte count.
void remove(int)
Marks the message files for deletion.
void commit()
Commits remove()als.
List::const_iterator cend() const
Returns the end iterator.
List::value_type get(int id) const
Returns the item with index id-1.
A structure representing a pop message.
Holds the list of messages available to a particular pop user.
StoreUser(Store &, const std::string &user)
Constructor.
bool allowDelete() const
Returns true if files can be deleted.
void prepare(const std::string &user)
Prepares the store for the newly-authenticated user.
bool byName() const
Returns true if the spool directory is affected by the user name.
Store(const G::Path &spool_dir, const Config &)
Constructor. Throws InvalidDirectory.
G::Path dir() const
Returns the spool directory path.
A Path object represents a file system path.
constexpr const char * tx(const char *p) noexcept
A briefer alternative to G::gettext_noop().
Configuration structure for GPop::Store.