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 
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 
SMTP and message-store classes.
virtual std::auto_ptr< GSmtp::StoredMessage > next()=0
virtual void updated()=0
Called by associated classes to indicate that the store has changed.
virtual bool empty() const =0
Returns true if the message store is empty.
virtual Iterator failures()=0
Returns an iterator for failed messages.
virtual void unfailAll()=0
Causes messages marked as failed to be unmarked.
A base class for MessageStore::Iterator implementations.
Definition: gmessagestore.h:52
std::auto_ptr< StoredMessage > next()
A class which allows SMTP messages (envelope+content) to be stored and retrieved. ...
Definition: gmessagestore.h:45
static G::Path defaultDirectory()
Returns a default spool directory, such as "/usr/local/var/spool/emailrelay".
virtual ~MessageStore()
Destructor.
virtual G::Signal1< bool > & signal()=0
Provides a signal which is activated when something might have changed in the store.
virtual void repoll()=0
Ensures that the next updated() signal() has its parameter set to true.
Iterator & operator=(const Iterator &)
virtual std::auto_ptr< NewMessage > newMessage(const std::string &from)=0
Creates a new message.
#define G_EXCEPTION(class_name, description)
define as a function rather than a type if optimising for size
Definition: gexception.h:93
A Path object represents a file system path.
Definition: gpath.h:44
virtual Iterator iterator(bool lock)=0
Returns an iterator for stored messages.
An iterator class for GSmtp::MessageStore.
Definition: gmessagestore.h:62