4
// $Id: //poco/1.2/Net/include/Poco/Net/MailStream.h#1 $
10
// Definition of the MailStream class.
12
// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
15
// Permission is hereby granted, free of charge, to any person or organization
16
// obtaining a copy of the software and accompanying documentation covered by
17
// this license (the "Software") to use, reproduce, display, distribute,
18
// execute, and transmit the Software, and to prepare derivative works of the
19
// Software, and to permit third-parties to whom the Software is furnished to
20
// do so, all subject to the following:
22
// The copyright notices in the Software and this entire statement, including
23
// the above license grant, this restriction and the following disclaimer,
24
// must be included in all copies of the Software, in whole or in part, and
25
// all derivative works of the Software, unless such copies or derivative
26
// works are solely in the form of machine-executable object code generated by
27
// a source language processor.
29
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
32
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
33
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
34
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
35
// DEALINGS IN THE SOFTWARE.
39
#ifndef Net_MailStream_INCLUDED
40
#define Net_MailStream_INCLUDED
43
#include "Poco/Net/Net.h"
44
#include "Poco/UnbufferedStreamBuf.h"
53
class Net_API MailStreamBuf: public Poco::UnbufferedStreamBuf
54
/// The sole purpose of this stream buffer is to replace
55
/// a "\r\n.\r\n" character sequence with a "\r\n..\r\n" sequence for
56
/// output streams and vice-versa for input streams.
58
/// This is used when sending mail messages to SMTP servers, or
59
/// receiving mail messages from POP servers.
61
/// See RFC 2181 (Simple Mail Transfer Protocol) and RFC 1939
62
/// (Post Office Protocol - Version 3) for more information.
65
MailStreamBuf(std::istream& istr);
66
/// Creates the MailStreamBuf and connects it
67
/// to the given input stream.
69
MailStreamBuf(std::ostream& ostr);
70
/// Creates the MailStreamBuf and connects it
71
/// to the given output stream.
74
/// Destroys the MailStreamBuf.
77
/// Writes the terminating period, followed by
82
int writeToDevice(char c);
104
class Net_API MailIOS: public virtual std::ios
105
/// The base class for MailInputStream and MailOutputStream.
107
/// This class provides common methods and is also needed to ensure
108
/// the correct initialization order of the stream buffer and base classes.
111
MailIOS(std::istream& istr);
112
/// Creates the MailIOS and connects it
113
/// to the given input stream.
115
MailIOS(std::ostream& ostr);
116
/// Creates the MailIOS and connects it
117
/// to the given output stream.
120
/// Destroys the stream.
123
/// Writes the terminating period, followed by
126
MailStreamBuf* rdbuf();
127
/// Returns a pointer to the underlying streambuf.
134
class Net_API MailInputStream: public MailIOS, public std::istream
135
/// This class is used for reading E-Mail messages from a
136
/// POP3 server. All occurences of "\r\n..\r\n" are replaced with
137
/// "\r\n.\r\n". The first occurence of "\r\n.\r\n" denotes the end
141
MailInputStream(std::istream& istr);
142
/// Creates the MailInputStream and connects it
143
/// to the given input stream.
146
/// Destroys the MailInputStream.
150
class Net_API MailOutputStream: public MailIOS, public std::ostream
151
/// This class is used for writing E-Mail messages to a
152
/// SMTP server. All occurences of "\r\n.\r\n" are replaced with
156
MailOutputStream(std::ostream& ostr);
157
/// Creates the MailOutputStream and connects it
158
/// to the given input stream.
161
/// Destroys the MailOutputStream.
165
} } // namespace Poco::Net
168
#endif // Net_MailStream_INCLUDED