- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

gnewfile.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_NEW_FILE_H
22 #define G_SMTP_NEW_FILE_H
23
24 #include "gdef.h"
25 #include "gsmtp.h"
26 #include "gfilestore.h"
27 #include "gstrings.h"
28 #include "gnewmessage.h"
29 #include "gexception.h"
30 #include <iostream>
31
33 namespace GSmtp
34 {
35 class NewFile ;
36 }
37
43 class GSmtp::NewFile : public GSmtp::NewMessage
44 {
45 public:
46 G_EXCEPTION( InvalidPath , "invalid path -- must be absolute" ) ;
47
48 NewFile( const std::string & from , FileStore & store , unsigned long max_size = 0UL ) ;
50
51 virtual ~NewFile() ;
54
55 virtual void addTo( const std::string & to , bool local ) ;
57
58 virtual bool addText( const std::string & line ) ;
60
61 virtual std::string prepare( const std::string & auth_id , const std::string & peer_socket_address ,
62 const std::string & peer_socket_name , const std::string & peer_certificate ) ;
70
71 virtual void commit() ;
76
77 virtual unsigned long id() const ;
79
80 G::Path contentPath() const ;
82
83 private:
84 FileStore & m_store ;
85 unsigned long m_seq ;
86 std::string m_from ;
87 G::Strings m_to_local ;
88 G::Strings m_to_remote ;
89 std::auto_ptr<std::ostream> m_content ;
90 G::Path m_content_path ;
91 G::Path m_envelope_path_0 ;
92 G::Path m_envelope_path_1 ;
93 bool m_committed ;
94 bool m_eight_bit ;
95 bool m_saved ;
96 unsigned long m_size ;
97 unsigned long m_max_size ;
98
99 private:
100 void cleanup() ;
101 void flushContent() ;
102 void discardContent() ;
103 bool commitEnvelope() ;
104 void deleteContent() ;
105 void deleteEnvelope() ;
106 static bool isEightBit( const std::string & line ) ;
107 const std::string & crlf() const ;
108 bool saveEnvelope( const std::string & auth_id , const std::string & peer_socket_address ,
109 const std::string & peer_socket_name , const std::string & peer_certificate ) const ;
110 void writeEnvelope( std::ostream & , const std::string & where ,
111 const std::string & auth_id , const std::string & peer_socket_address ,
112 const std::string & peer_socket_name , const std::string & peer_certificate ) const ;
113 void deliver( const G::Strings & , const G::Path & , const G::Path & , const G::Path & ) ;
114 } ;
115
116 #endif
GSmtp::NewFile::contentPath
G::Path contentPath() const
Returns the path of the content file.
Definition: gnewfile.cpp:251
gstrings.h
GSmtp
SMTP and message-store classes.
G::Strings
std::list< std::string > Strings
A std::list of std::strings.
Definition: gstrings.h:39
GSmtp::NewFile::addTo
virtual void addTo(const std::string &to, bool local)
Final override from GSmtp::NewMessage.
Definition: gnewfile.cpp:115
GSmtp::NewFile::~NewFile
virtual ~NewFile()
Destructor.
Definition: gnewfile.cpp:60
gfilestore.h
GSmtp::NewFile::NewFile
NewFile(const std::string &from, FileStore &store, unsigned long max_size=0UL)
Constructor. The FileStore reference is kept.
Definition: gnewfile.cpp:39
GSmtp::NewFile::prepare
virtual std::string prepare(const std::string &auth_id, const std::string &peer_socket_address, const std::string &peer_socket_name, const std::string &peer_certificate)
Final override from GSmtp::NewMessage.
Definition: gnewfile.cpp:83
GSmtp::NewFile
A concrete derived class implementing the NewMessage interface.
Definition: gnewfile.h:43
GSmtp::NewFile::commit
virtual void commit()
Final override from GSmtp::NewMessage.
Definition: gnewfile.cpp:107
gexception.h
GSmtp::NewFile::id
virtual unsigned long id() const
Final override from GSmtp::NewMessage.
Definition: gnewfile.cpp:246
G_EXCEPTION
#define G_EXCEPTION(class_name, description)
define as a function rather than a type if optimising for size
Definition: gexception.h:93
GSmtp::FileStore
A concrete implementation of the MessageStore interface dealing in paired flat files and with an opti...
Definition: gfilestore.h:62
GSmtp::NewMessage
An abstract class to allow the creation of a new message in the message store.
Definition: gnewmessage.h:39
gsmtp.h
GSmtp::NewFile::addText
virtual bool addText(const std::string &line)
Final override from GSmtp::NewMessage.
Definition: gnewfile.cpp:123
gnewmessage.h
G::Path
A Path object represents a file system path.
Definition: gpath.h:44