diff options
Diffstat (limited to 'vmime')
-rw-r--r-- | vmime/exception.hpp | 15 | ||||
-rw-r--r-- | vmime/messaging/folder.hpp | 10 | ||||
-rw-r--r-- | vmime/messaging/imap/IMAPFolder.hpp | 6 | ||||
-rw-r--r-- | vmime/messaging/imap/IMAPMessage.hpp | 6 | ||||
-rw-r--r-- | vmime/messaging/imap/IMAPParser.hpp | 16 | ||||
-rw-r--r-- | vmime/messaging/maildir/maildirFolder.hpp | 8 | ||||
-rw-r--r-- | vmime/messaging/maildir/maildirMessage.hpp | 6 | ||||
-rw-r--r-- | vmime/messaging/message.hpp | 7 | ||||
-rw-r--r-- | vmime/messaging/pop3/POP3Folder.hpp | 6 | ||||
-rw-r--r-- | vmime/messaging/pop3/POP3Message.hpp | 4 | ||||
-rw-r--r-- | vmime/messaging/pop3/POP3Store.hpp | 4 | ||||
-rw-r--r-- | vmime/messaging/sendmail/sendmailTransport.hpp | 98 | ||||
-rw-r--r-- | vmime/messaging/service.hpp | 4 | ||||
-rw-r--r-- | vmime/messaging/serviceFactory.hpp | 3 | ||||
-rw-r--r-- | vmime/messaging/session.hpp | 2 | ||||
-rw-r--r-- | vmime/messaging/smtp/SMTPTransport.hpp | 2 | ||||
-rw-r--r-- | vmime/messaging/transport.hpp | 4 | ||||
-rw-r--r-- | vmime/utility/filteredStream.hpp | 116 | ||||
-rw-r--r-- | vmime/utility/progressionListener.hpp (renamed from vmime/messaging/progressionListener.hpp) | 16 | ||||
-rw-r--r-- | vmime/utility/stream.hpp | 47 | ||||
-rw-r--r-- | vmime/vmime.hpp | 1 |
21 files changed, 331 insertions, 50 deletions
diff --git a/vmime/exception.hpp b/vmime/exception.hpp index 85f0a3ff..396ae5b3 100644 --- a/vmime/exception.hpp +++ b/vmime/exception.hpp @@ -311,6 +311,21 @@ public: }; +/** Underlying operating system error. + */ + +class system_error : public vmime::exception +{ +public: + + system_error(const string& what, const exception& other = NO_EXCEPTION); + ~system_error() throw(); + + exception* clone() const; + const string name() const; +}; + + #if VMIME_HAVE_MESSAGING_FEATURES diff --git a/vmime/messaging/folder.hpp b/vmime/messaging/folder.hpp index 9a8a1155..610e55af 100644 --- a/vmime/messaging/folder.hpp +++ b/vmime/messaging/folder.hpp @@ -25,11 +25,13 @@ #include "vmime/types.hpp" #include "vmime/dateTime.hpp" -#include "vmime/messaging/progressionListener.hpp" + #include "vmime/messaging/message.hpp" #include "vmime/messaging/events.hpp" + #include "vmime/utility/path.hpp" #include "vmime/utility/stream.hpp" +#include "vmime/utility/progressionListener.hpp" namespace vmime { @@ -244,7 +246,7 @@ public: * @param date date/time for the new message (if NULL, the current time is used) * @param progress progression listener, or NULL if not used */ - virtual void addMessage(vmime::message* msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, progressionListener* progress = NULL) = 0; + virtual void addMessage(vmime::message* msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressionListener* progress = NULL) = 0; /** Add a message to this folder. * @@ -254,7 +256,7 @@ public: * @param date date/time for the new message (if NULL, the current time is used) * @param progress progression listener, or NULL if not used */ - virtual void addMessage(utility::inputStream& is, const int size, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, progressionListener* progress = NULL) = 0; + virtual void addMessage(utility::inputStream& is, const int size, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressionListener* progress = NULL) = 0; /** Copy a message from this folder to another folder. * @@ -328,7 +330,7 @@ public: * @param options objects to fetch (combination of folder::FetchOptions flags) * @param progress progression listener, or NULL if not used */ - virtual void fetchMessages(std::vector <message*>& msg, const int options, progressionListener* progress = NULL) = 0; + virtual void fetchMessages(std::vector <message*>& msg, const int options, utility::progressionListener* progress = NULL) = 0; /** Fetch objects for the specified message. * diff --git a/vmime/messaging/imap/IMAPFolder.hpp b/vmime/messaging/imap/IMAPFolder.hpp index 4df20e44..128fea3c 100644 --- a/vmime/messaging/imap/IMAPFolder.hpp +++ b/vmime/messaging/imap/IMAPFolder.hpp @@ -91,8 +91,8 @@ public: void setMessageFlags(const int from, const int to, const int flags, const int mode = message::FLAG_MODE_SET); void setMessageFlags(const std::vector <int>& nums, const int flags, const int mode = message::FLAG_MODE_SET); - void addMessage(vmime::message* msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, progressionListener* progress = NULL); - void addMessage(utility::inputStream& is, const int size, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, progressionListener* progress = NULL); + void addMessage(vmime::message* msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressionListener* progress = NULL); + void addMessage(utility::inputStream& is, const int size, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressionListener* progress = NULL); void copyMessage(const folder::path& dest, const int num); void copyMessages(const folder::path& dest, const int from = 1, const int to = -1); @@ -108,7 +108,7 @@ public: store* getStore(); - void fetchMessages(std::vector <message*>& msg, const int options, progressionListener* progress = NULL); + void fetchMessages(std::vector <message*>& msg, const int options, utility::progressionListener* progress = NULL); void fetchMessage(message* msg, const int options); const int getFetchCapabilities() const; diff --git a/vmime/messaging/imap/IMAPMessage.hpp b/vmime/messaging/imap/IMAPMessage.hpp index b3c10562..f9c22a75 100644 --- a/vmime/messaging/imap/IMAPMessage.hpp +++ b/vmime/messaging/imap/IMAPMessage.hpp @@ -64,8 +64,8 @@ public: const int getFlags() const; void setFlags(const int flags, const int mode = FLAG_MODE_SET); - void extract(utility::outputStream& os, progressionListener* progress = NULL, const int start = 0, const int length = -1) const; - void extractPart(const part& p, utility::outputStream& os, progressionListener* progress = NULL, const int start = 0, const int length = -1) const; + void extract(utility::outputStream& os, utility::progressionListener* progress = NULL, const int start = 0, const int length = -1) const; + void extractPart(const part& p, utility::outputStream& os, utility::progressionListener* progress = NULL, const int start = 0, const int length = -1) const; void fetchPartHeader(part& p); @@ -75,7 +75,7 @@ private: void processFetchResponse(const int options, const IMAPParser::msg_att* msgAtt); - void extract(const part* p, utility::outputStream& os, progressionListener* progress, const int start, const int length, const bool headerOnly) const; + void extract(const part* p, utility::outputStream& os, utility::progressionListener* progress, const int start, const int length, const bool headerOnly) const; void convertAddressList(const IMAPParser::address_list& src, mailboxList& dest); diff --git a/vmime/messaging/imap/IMAPParser.hpp b/vmime/messaging/imap/IMAPParser.hpp index 4a4c8f59..368215b0 100644 --- a/vmime/messaging/imap/IMAPParser.hpp +++ b/vmime/messaging/imap/IMAPParser.hpp @@ -28,13 +28,13 @@ #include "vmime/utility/smartPtr.hpp" #include "vmime/utility/stringUtils.hpp" +#include "vmime/utility/progressionListener.hpp" #include "vmime/encoderB64.hpp" #include "vmime/encoderQP.hpp" #include "vmime/platformDependant.hpp" -#include "vmime/messaging/progressionListener.hpp" #include "vmime/messaging/timeoutHandler.hpp" #include "vmime/messaging/socket.hpp" @@ -135,7 +135,7 @@ public: { protected: - target(class progressionListener* progress) : m_progress(progress) {} + target(utility::progressionListener* progress) : m_progress(progress) {} target(const target&) {} public: @@ -143,13 +143,13 @@ public: virtual ~target() { } - class progressionListener* progressionListener() { return (m_progress); } + utility::progressionListener* progressionListener() { return (m_progress); } virtual void putData(const string& chunk) = 0; private: - class progressionListener* m_progress; + utility::progressionListener* m_progress; }; @@ -158,7 +158,7 @@ public: { public: - targetString(class progressionListener* progress, vmime::string& str) + targetString(utility::progressionListener* progress, vmime::string& str) : target(progress), m_string(str) { } const vmime::string& string() const { return (m_string); } @@ -181,7 +181,7 @@ public: { public: - targetStream(class progressionListener* progress, utility::outputStream& stream) + targetStream(utility::progressionListener* progress, utility::outputStream& stream) : target(progress), m_stream(stream) { } const utility::outputStream& stream() const { return (m_stream); } @@ -809,7 +809,7 @@ public: m_value = "[literal-handler]"; const string::size_type length = text->value().length(); - progressionListener* progress = target->progressionListener(); + utility::progressionListener* progress = target->progressionListener(); if (progress) { @@ -4914,7 +4914,7 @@ private: IMAPTag* m_tag; socket* m_socket; - progressionListener* m_progress; + utility::progressionListener* m_progress; literalHandler* m_literalHandler; diff --git a/vmime/messaging/maildir/maildirFolder.hpp b/vmime/messaging/maildir/maildirFolder.hpp index 0b880f15..8eaaf333 100644 --- a/vmime/messaging/maildir/maildirFolder.hpp +++ b/vmime/messaging/maildir/maildirFolder.hpp @@ -91,8 +91,8 @@ public: void setMessageFlags(const int from, const int to, const int flags, const int mode = message::FLAG_MODE_SET); void setMessageFlags(const std::vector <int>& nums, const int flags, const int mode = message::FLAG_MODE_SET); - void addMessage(vmime::message* msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, progressionListener* progress = NULL); - void addMessage(utility::inputStream& is, const int size, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, progressionListener* progress = NULL); + void addMessage(vmime::message* msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressionListener* progress = NULL); + void addMessage(utility::inputStream& is, const int size, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressionListener* progress = NULL); void copyMessage(const folder::path& dest, const int num); void copyMessages(const folder::path& dest, const int from = 1, const int to = -1); @@ -108,7 +108,7 @@ public: store* getStore(); - void fetchMessages(std::vector <message*>& msg, const int options, progressionListener* progress = NULL); + void fetchMessages(std::vector <message*>& msg, const int options, utility::progressionListener* progress = NULL); void fetchMessage(message* msg, const int options); const int getFetchCapabilities() const; @@ -132,7 +132,7 @@ private: void setMessageFlagsImpl(const std::vector <int>& nums, const int flags, const int mode); void copyMessagesImpl(const folder::path& dest, const std::vector <int>& nums); - void copyMessageImpl(const utility::file::path& tmpDirPath, const utility::file::path& curDirPath, const utility::file::path::component& filename, utility::inputStream& is, const utility::stream::size_type size, progressionListener* progress); + void copyMessageImpl(const utility::file::path& tmpDirPath, const utility::file::path& curDirPath, const utility::file::path::component& filename, utility::inputStream& is, const utility::stream::size_type size, utility::progressionListener* progress); void notifyMessagesCopied(const folder::path& dest); diff --git a/vmime/messaging/maildir/maildirMessage.hpp b/vmime/messaging/maildir/maildirMessage.hpp index ffbc1ca2..cd345784 100644 --- a/vmime/messaging/maildir/maildirMessage.hpp +++ b/vmime/messaging/maildir/maildirMessage.hpp @@ -65,8 +65,8 @@ public: const int getFlags() const; void setFlags(const int flags, const int mode = FLAG_MODE_SET); - void extract(utility::outputStream& os, progressionListener* progress = NULL, const int start = 0, const int length = -1) const; - void extractPart(const part& p, utility::outputStream& os, progressionListener* progress = NULL, const int start = 0, const int length = -1) const; + void extract(utility::outputStream& os, utility::progressionListener* progress = NULL, const int start = 0, const int length = -1) const; + void extractPart(const part& p, utility::outputStream& os, utility::progressionListener* progress = NULL, const int start = 0, const int length = -1) const; void fetchPartHeader(part& p); @@ -78,7 +78,7 @@ private: header& getOrCreateHeader(); - void extractImpl(utility::outputStream& os, progressionListener* progress, const int start, const int length, const int partialStart, const int partialLength) const; + void extractImpl(utility::outputStream& os, utility::progressionListener* progress, const int start, const int length, const int partialStart, const int partialLength) const; maildirFolder* m_folder; diff --git a/vmime/messaging/message.hpp b/vmime/messaging/message.hpp index ee32c753..47cc6b76 100644 --- a/vmime/messaging/message.hpp +++ b/vmime/messaging/message.hpp @@ -22,7 +22,8 @@ #include "vmime/header.hpp" -#include "vmime/messaging/progressionListener.hpp" + +#include "vmime/utility/progressionListener.hpp" #include "vmime/utility/stream.hpp" @@ -257,7 +258,7 @@ public: * @param length number of bytes to retrieve (used for partial fetch) */ - virtual void extract(utility::outputStream& os, progressionListener* progress = NULL, const int start = 0, const int length = -1) const = 0; + virtual void extract(utility::outputStream& os, utility::progressionListener* progress = NULL, const int start = 0, const int length = -1) const = 0; /** Extract the specified (MIME) part of the message (header + contents). * @@ -269,7 +270,7 @@ public: * @param start index of the first byte to retrieve (used for partial fetch) * @param length number of bytes to retrieve (used for partial fetch) */ - virtual void extractPart(const part& p, utility::outputStream& os, progressionListener* progress = NULL, const int start = 0, const int length = -1) const = 0; + virtual void extractPart(const part& p, utility::outputStream& os, utility::progressionListener* progress = NULL, const int start = 0, const int length = -1) const = 0; /** Fetch the MIME header for the specified part. * diff --git a/vmime/messaging/pop3/POP3Folder.hpp b/vmime/messaging/pop3/POP3Folder.hpp index 3cf9855d..8cfe12db 100644 --- a/vmime/messaging/pop3/POP3Folder.hpp +++ b/vmime/messaging/pop3/POP3Folder.hpp @@ -90,8 +90,8 @@ public: void setMessageFlags(const int from, const int to, const int flags, const int mode = message::FLAG_MODE_SET); void setMessageFlags(const std::vector <int>& nums, const int flags, const int mode = message::FLAG_MODE_SET); - void addMessage(vmime::message* msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, progressionListener* progress = NULL); - void addMessage(utility::inputStream& is, const int size, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, progressionListener* progress = NULL); + void addMessage(vmime::message* msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressionListener* progress = NULL); + void addMessage(utility::inputStream& is, const int size, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressionListener* progress = NULL); void copyMessage(const folder::path& dest, const int num); void copyMessages(const folder::path& dest, const int from = 1, const int to = -1); @@ -107,7 +107,7 @@ public: store* getStore(); - void fetchMessages(std::vector <message*>& msg, const int options, progressionListener* progress = NULL); + void fetchMessages(std::vector <message*>& msg, const int options, utility::progressionListener* progress = NULL); void fetchMessage(message* msg, const int options); const int getFetchCapabilities() const; diff --git a/vmime/messaging/pop3/POP3Message.hpp b/vmime/messaging/pop3/POP3Message.hpp index 82b5b132..c19d7579 100644 --- a/vmime/messaging/pop3/POP3Message.hpp +++ b/vmime/messaging/pop3/POP3Message.hpp @@ -64,8 +64,8 @@ public: const int getFlags() const; void setFlags(const int flags, const int mode = FLAG_MODE_SET); - void extract(utility::outputStream& os, progressionListener* progress = NULL, const int start = 0, const int length = -1) const; - void extractPart(const part& p, utility::outputStream& os, progressionListener* progress = NULL, const int start = 0, const int length = -1) const; + void extract(utility::outputStream& os, utility::progressionListener* progress = NULL, const int start = 0, const int length = -1) const; + void extractPart(const part& p, utility::outputStream& os, utility::progressionListener* progress = NULL, const int start = 0, const int length = -1) const; void fetchPartHeader(part& p); diff --git a/vmime/messaging/pop3/POP3Store.hpp b/vmime/messaging/pop3/POP3Store.hpp index 598025ca..c7528f9c 100644 --- a/vmime/messaging/pop3/POP3Store.hpp +++ b/vmime/messaging/pop3/POP3Store.hpp @@ -74,8 +74,8 @@ private: static void stripResponseCode(const string& buffer, string& result); void sendRequest(const string& buffer, const bool end = true); - void readResponse(string& buffer, const bool multiLine, progressionListener* progress = NULL); - void readResponse(utility::outputStream& os, progressionListener* progress = NULL, const int predictedSize = 0); + void readResponse(string& buffer, const bool multiLine, utility::progressionListener* progress = NULL); + void readResponse(utility::outputStream& os, utility::progressionListener* progress = NULL, const int predictedSize = 0); static const bool checkTerminator(string& buffer, const bool multiLine); static const bool checkOneTerminator(string& buffer, const string& term); diff --git a/vmime/messaging/sendmail/sendmailTransport.hpp b/vmime/messaging/sendmail/sendmailTransport.hpp new file mode 100644 index 00000000..e3ee78c5 --- /dev/null +++ b/vmime/messaging/sendmail/sendmailTransport.hpp @@ -0,0 +1,98 @@ +// +// VMime library (http://www.vmime.org) +// Copyright (C) 2002-2005 Vincent Richard <[email protected]> +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License as +// published by the Free Software Foundation; either version 2 of +// the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// + +#ifndef VMIME_MESSAGING_SENDMAIL_SENDMAILTRANSPORT_HPP_INCLUDED +#define VMIME_MESSAGING_SENDMAIL_SENDMAILTRANSPORT_HPP_INCLUDED + + +#include "vmime/config.hpp" + +#include "vmime/messaging/transport.hpp" +#include "vmime/messaging/socket.hpp" +#include "vmime/messaging/timeoutHandler.hpp" + + +#if VMIME_BUILTIN_PLATFORM_POSIX + + +namespace vmime { +namespace messaging { +namespace sendmail { + + +/** Sendmail local transport service. + */ + +class sendmailTransport : public transport +{ +public: + + sendmailTransport(session* sess, authenticator* auth); + ~sendmailTransport(); + + const string getProtocolName() const; + + static const serviceInfos& getInfosInstance(); + const serviceInfos& getInfos() const; + + void connect(); + const bool isConnected() const; + void disconnect(); + + void noop(); + + void send(const mailbox& expeditor, const mailboxList& recipients, utility::inputStream& is, const utility::stream::size_type size, utility::progressionListener* progress = NULL); + +private: + + void internalDisconnect(); + + void internalSend(const std::vector <string> args, utility::inputStream& is, + const utility::stream::size_type size, utility::progressionListener* progress); + + + string m_sendmailPath; + + bool m_connected; + + + // Service infos + class _infos : public serviceInfos + { + public: + + const port_t getDefaultPort() const; + + const string getPropertyPrefix() const; + const std::vector <string> getAvailableProperties() const; + }; + + static _infos sm_infos; +}; + + +} // sendmail +} // messaging +} // vmime + + +#endif // VMIME_BUILTIN_PLATFORM_POSIX + + +#endif // VMIME_MESSAGING_SENDMAIL_SENDMAILTRANSPORT_HPP_INCLUDED diff --git a/vmime/messaging/service.hpp b/vmime/messaging/service.hpp index 212e2c55..cf12e213 100644 --- a/vmime/messaging/service.hpp +++ b/vmime/messaging/service.hpp @@ -24,13 +24,13 @@ #include "vmime/types.hpp" #include "vmime/messaging/session.hpp" - #include "vmime/messaging/authenticator.hpp" -#include "vmime/messaging/progressionListener.hpp" #include "vmime/messaging/serviceFactory.hpp" #include "vmime/messaging/serviceInfos.hpp" +#include "vmime/utility/progressionListener.hpp" + namespace vmime { namespace messaging { diff --git a/vmime/messaging/serviceFactory.hpp b/vmime/messaging/serviceFactory.hpp index 5c17afcc..782e4c75 100644 --- a/vmime/messaging/serviceFactory.hpp +++ b/vmime/messaging/serviceFactory.hpp @@ -31,9 +31,10 @@ #include "vmime/messaging/serviceInfos.hpp" #include "vmime/messaging/authenticator.hpp" -#include "vmime/messaging/progressionListener.hpp" #include "vmime/messaging/timeoutHandler.hpp" +#include "vmime/utility/progressionListener.hpp" + namespace vmime { namespace messaging { diff --git a/vmime/messaging/session.hpp b/vmime/messaging/session.hpp index 958ee448..bce4a2c0 100644 --- a/vmime/messaging/session.hpp +++ b/vmime/messaging/session.hpp @@ -22,7 +22,7 @@ #include "vmime/messaging/authenticator.hpp" -#include "vmime/messaging/progressionListener.hpp" + #include "vmime/utility/url.hpp" #include "vmime/propertySet.hpp" diff --git a/vmime/messaging/smtp/SMTPTransport.hpp b/vmime/messaging/smtp/SMTPTransport.hpp index 9b2eaa9b..3ccfdd49 100644 --- a/vmime/messaging/smtp/SMTPTransport.hpp +++ b/vmime/messaging/smtp/SMTPTransport.hpp @@ -54,7 +54,7 @@ public: void noop(); - void send(const mailbox& expeditor, const mailboxList& recipients, utility::inputStream& is, const utility::stream::size_type size, progressionListener* progress = NULL); + void send(const mailbox& expeditor, const mailboxList& recipients, utility::inputStream& is, const utility::stream::size_type size, utility::progressionListener* progress = NULL); private: diff --git a/vmime/messaging/transport.hpp b/vmime/messaging/transport.hpp index 8ffe8ad2..272fdb32 100644 --- a/vmime/messaging/transport.hpp +++ b/vmime/messaging/transport.hpp @@ -51,7 +51,7 @@ public: * @param msg message to send * @param progress progression listener, or NULL if not used */ - virtual void send(vmime::message* msg, progressionListener* progress = NULL); + virtual void send(vmime::message* msg, utility::progressionListener* progress = NULL); /** Send a message over this transport service. * @@ -61,7 +61,7 @@ public: * @param size size of the message data * @param progress progression listener, or NULL if not used */ - virtual void send(const mailbox& expeditor, const mailboxList& recipients, utility::inputStream& is, const utility::stream::size_type size, progressionListener* progress = NULL) = 0; + virtual void send(const mailbox& expeditor, const mailboxList& recipients, utility::inputStream& is, const utility::stream::size_type size, utility::progressionListener* progress = NULL) = 0; const Type getType() const; diff --git a/vmime/utility/filteredStream.hpp b/vmime/utility/filteredStream.hpp new file mode 100644 index 00000000..fc014e4e --- /dev/null +++ b/vmime/utility/filteredStream.hpp @@ -0,0 +1,116 @@ +// +// VMime library (http://www.vmime.org) +// Copyright (C) 2002-2005 Vincent Richard <[email protected]> +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License as +// published by the Free Software Foundation; either version 2 of +// the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// + +#ifndef VMIME_UTILITY_FILTEREDSTREAM_HPP_INCLUDED +#define VMIME_UTILITY_FILTEREDSTREAM_HPP_INCLUDED + + +#include "vmime/utility/stream.hpp" + + +namespace vmime { +namespace utility { + + +/** A stream whose input is filtered. + */ + +class filteredInputStream : public inputStream +{ +public: + + /** Return a reference to the stream being filtered. + * + * @return stream being filtered + */ + virtual inputStream& getPreviousInputStream() = 0; +}; + + +/** A stream whose output is filtered. + */ + +class filteredOutputStream : public outputStream +{ +public: + + /** Return a reference to the stream being filtered. + * + * @return destination stream for filtered data + */ + virtual outputStream& getNextOutputStream() = 0; +}; + + +/** A filtered output stream which replaces "\n." + * sequences with "\n.." sequences. + */ + +class dotFilteredOutputStream : public filteredOutputStream +{ +public: + + /** Construct a new filter for the specified output stream. + * + * @param os stream into which write filtered data + */ + dotFilteredOutputStream(outputStream& os); + + outputStream& getNextOutputStream(); + + void write(const value_type* const data, const size_type count); + +private: + + outputStream& m_stream; + value_type m_previousChar; +}; + + +/** A filtered output stream which replaces CRLF sequences + * with single LF characters. + */ + +class CRLFToLFFilteredOutputStream : public filteredOutputStream +{ +public: + + /** Construct a new filter for the specified output stream. + * + * @param os stream into which write filtered data + */ + CRLFToLFFilteredOutputStream(outputStream& os); + + outputStream& getNextOutputStream(); + + void write(const value_type* const data, const size_type count); + +private: + + outputStream& m_stream; + value_type m_previousChar; +}; + + +} // utility +} // vmime + + +#endif // VMIME_UTILITY_FILTEREDSTREAM_HPP_INCLUDED + diff --git a/vmime/messaging/progressionListener.hpp b/vmime/utility/progressionListener.hpp index a1008d16..24c2f35c 100644 --- a/vmime/messaging/progressionListener.hpp +++ b/vmime/utility/progressionListener.hpp @@ -17,12 +17,12 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // -#ifndef VMIME_MESSAGING_PROGRESSIONLISTENER_HPP_INCLUDED -#define VMIME_MESSAGING_PROGRESSIONLISTENER_HPP_INCLUDED +#ifndef VMIME_UTILITY_PROGRESSIONLISTENER_HPP_INCLUDED +#define VMIME_UTILITY_PROGRESSIONLISTENER_HPP_INCLUDED namespace vmime { -namespace messaging { +namespace utility { /** An interface to implement if you want to be notified @@ -39,8 +39,8 @@ public: /** Allow the caller object to cancel the current operation. * - * @warning WARNING: this is implementation-dependant: the underlying - * messaging protocol may not support this). + * @warning WARNING: this is implementation-dependant: cancelling + * may not be supported by the notifier object. * * @return true to cancel the operation, false otherwise */ @@ -49,7 +49,7 @@ public: /** Called at the beginning of the operation. * * @param predictedTotal predicted amount of units (this has - * no concrete meaning: they are not bytes, nor percentage...) + * no concrete meaning: these are not bytes, nor percentage...) */ virtual void start(const int predictedTotal) = 0; @@ -68,8 +68,8 @@ public: }; -} // messaging +} // utility } // vmime -#endif // VMIME_MESSAGING_PROGRESSIONLISTENER_HPP_INCLUDED +#endif // VMIME_UTILITY_PROGRESSIONLISTENER_HPP_INCLUDED diff --git a/vmime/utility/stream.hpp b/vmime/utility/stream.hpp index 91f3f573..c9967496 100644 --- a/vmime/utility/stream.hpp +++ b/vmime/utility/stream.hpp @@ -25,8 +25,20 @@ #include <ostream> #include <sstream> +#include "vmime/config.hpp" #include "vmime/types.hpp" +#include "vmime/utility/progressionListener.hpp" + + +#if VMIME_HAVE_MESSAGING_FEATURES + namespace vmime { + namespace messaging { + class socket; // forward reference + } // messaging + } // vmime +#endif + #if defined(_MSC_VER) && (_MSC_VER <= 1200) // VC++6 # include <cstring> #endif @@ -160,6 +172,18 @@ outputStream& operator<<(outputStream& os, const T& t) const stream::size_type bufferedStreamCopy(inputStream& is, outputStream& os); +/** Copy data from one stream into another stream using a buffered method + * and notify progression of the operation. + * + * @param is input stream (source data) + * @param os output stream (destination for data) + * @param length predicted number of bytes to copy + * @param progress listener to notify + * @return number of bytes copied + */ + +const stream::size_type bufferedStreamCopy(inputStream& is, outputStream& os, + const stream::size_type length, progressionListener* progress); // Adapters @@ -296,6 +320,29 @@ private: }; +#if VMIME_HAVE_MESSAGING_FEATURES + + +/** An output stream that is connected to a socket. + */ + +class outputStreamSocketAdapter : public outputStream +{ +public: + + outputStreamSocketAdapter(messaging::socket& sok); + + void write(const value_type* const data, const size_type count); + +private: + + messaging::socket& m_socket; +}; + + +#endif // VMIME_HAVE_MESSAGING_FEATURES + + } // utility } // vmime diff --git a/vmime/vmime.hpp b/vmime/vmime.hpp index c0e52d3b..b5cac466 100644 --- a/vmime/vmime.hpp +++ b/vmime/vmime.hpp @@ -84,6 +84,7 @@ // Utilities #include "vmime/utility/datetimeUtils.hpp" +#include "vmime/utility/filteredStream.hpp" // Messaging features #if VMIME_HAVE_MESSAGING_FEATURES |