- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

gmessagestore.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2001-2013 Graeme Walker <graeme_walker@users.sourceforge.net>
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 // ===
20
21 #ifndef G_SMTP_MESSAGE_STORE_H
22 #define G_SMTP_MESSAGE_STORE_H
23
24 #include "gdef.h"
25 #include "gsmtp.h"
26 #include "gnewmessage.h"
27 #include "gstoredmessage.h"
28 #include "gexception.h"
29 #include "gslot.h"
30 #include "gstrings.h"
31 #include "gpath.h"
32
34 namespace GSmtp
35 {
36 class MessageStore ;
37 }
38
45 class GSmtp::MessageStore
46 {
47 public:
48 G_EXCEPTION( WriteError , "error writing file" ) ;
49 G_EXCEPTION( StorageError , "error storing message" ) ;
50 G_EXCEPTION( FormatError , "format error" ) ;
52 class IteratorImp
53 {
54 public: unsigned long m_ref_count ;
55 public: virtual std::auto_ptr<GSmtp::StoredMessage> next() = 0 ;
56 public: IteratorImp() ;
57 public: virtual ~IteratorImp() ;
58 private: IteratorImp( const IteratorImp & ) ;
59 private: void operator=( const IteratorImp & ) ;
60 } ;
62 class Iterator
63 {
64 public: Iterator() ;
65 public: explicit Iterator( IteratorImp * ) ;
66 public: ~Iterator() ;
67 public: Iterator( const Iterator & ) ;
68 public: Iterator & operator=( const Iterator & ) ;
69 public: std::auto_ptr<StoredMessage> next() ;
70 public: void last() ;
71 private: IteratorImp * m_imp ;
72 } ;
73
74 static G::Path defaultDirectory() ;
78
79 virtual ~MessageStore() ;
81
82 virtual std::auto_ptr<NewMessage> newMessage( const std::string & from ) = 0 ;
84
85 virtual bool empty() const = 0 ;
87
88 virtual std::auto_ptr<StoredMessage> get( unsigned long id ) = 0 ;
97
98 virtual Iterator iterator( bool lock ) = 0 ;
111
112 virtual Iterator failures() = 0 ;
114
115 virtual void repoll() = 0 ;
118
119 virtual void unfailAll() = 0 ;
121
122 virtual void updated() = 0 ;
126
127 virtual G::Signal1<bool> & signal() = 0 ;
131
132 private:
133 void operator=( const MessageStore & ) ; // not implemented
134 } ;
135
136 #endif
137
gstrings.h
GSmtp::MessageStore::IteratorImp::m_ref_count
unsigned long m_ref_count
Definition: gmessagestore.h:54
GSmtp
SMTP and message-store classes.
GSmtp::MessageStore::IteratorImp::next
virtual std::auto_ptr< GSmtp::StoredMessage > next()=0
GSmtp::MessageStore::updated
virtual void updated()=0
Called by associated classes to indicate that the store has changed.
GSmtp::MessageStore::empty
virtual bool empty() const =0
Returns true if the message store is empty.
GSmtp::MessageStore::Iterator::Iterator
Iterator()
Definition: gmessagestore.cpp:44
GSmtp::MessageStore::failures
virtual Iterator failures()=0
Returns an iterator for failed messages.
GSmtp::MessageStore::unfailAll
virtual void unfailAll()=0
Causes messages marked as failed to be unmarked.
G::Signal1< bool >
gslot.h
GSmtp::MessageStore::IteratorImp::~IteratorImp
virtual ~IteratorImp()
Definition: gmessagestore.cpp:38
GSmtp::MessageStore::IteratorImp
A base class for MessageStore::Iterator implementations.
Definition: gmessagestore.h:52
GSmtp::MessageStore::Iterator::next
std::auto_ptr< StoredMessage > next()
Definition: gmessagestore.cpp:55
GSmtp::MessageStore
A class which allows SMTP messages (envelope+content) to be stored and retrieved. ...
Definition: gmessagestore.h:45
GSmtp::MessageStore::IteratorImp::IteratorImp
IteratorImp()
Definition: gmessagestore.cpp:33
GSmtp::MessageStore::defaultDirectory
static G::Path defaultDirectory()
Returns a default spool directory, such as "/usr/local/var/spool/emailrelay".
Definition: gmessagestore_unix.cpp:30
GSmtp::MessageStore::~MessageStore
virtual ~MessageStore()
Destructor.
Definition: gmessagestore.cpp:27
GSmtp::MessageStore::signal
virtual G::Signal1< bool > & signal()=0
Provides a signal which is activated when something might have changed in the store.
GSmtp::MessageStore::repoll
virtual void repoll()=0
Ensures that the next updated() signal() has its parameter set to true.
GSmtp::MessageStore::Iterator::operator=
Iterator & operator=(const Iterator &)
Definition: gmessagestore.cpp:77
GSmtp::MessageStore::Iterator::~Iterator
~Iterator()
Definition: gmessagestore.cpp:60
GSmtp::MessageStore::newMessage
virtual std::auto_ptr< NewMessage > newMessage(const std::string &from)=0
Creates a new message.
gexception.h
GSmtp::MessageStore::Iterator::last
void last()
Definition: gmessagestore.cpp:96
G_EXCEPTION
#define G_EXCEPTION(class_name, description)
define as a function rather than a type if optimising for size
Definition: gexception.h:93
gpath.h
gstoredmessage.h
gsmtp.h
gnewmessage.h
G::Path
A Path object represents a file system path.
Definition: gpath.h:44
GSmtp::MessageStore::iterator
virtual Iterator iterator(bool lock)=0
Returns an iterator for stored messages.
GSmtp::MessageStore::Iterator
An iterator class for GSmtp::MessageStore.
Definition: gmessagestore.h:62