diff options
Diffstat (limited to 'vmime')
-rw-r--r-- | vmime/body.hpp | 5 | ||||
-rw-r--r-- | vmime/bodyPart.hpp | 2 | ||||
-rw-r--r-- | vmime/component.hpp | 10 | ||||
-rw-r--r-- | vmime/exception.hpp | 30 | ||||
-rw-r--r-- | vmime/header.hpp | 2 | ||||
-rw-r--r-- | vmime/headerField.hpp | 2 | ||||
-rw-r--r-- | vmime/headerFieldValue.hpp | 1 | ||||
-rw-r--r-- | vmime/net/smtp/SMTPCommand.hpp | 1 | ||||
-rw-r--r-- | vmime/net/smtp/SMTPTransport.hpp | 4 | ||||
-rw-r--r-- | vmime/stringContentHandler.hpp | 3 | ||||
-rw-r--r-- | vmime/utility/encoder/b64Encoder.hpp | 3 | ||||
-rw-r--r-- | vmime/utility/encoder/defaultEncoder.hpp | 3 | ||||
-rw-r--r-- | vmime/utility/encoder/encoder.hpp | 18 | ||||
-rw-r--r-- | vmime/utility/encoder/qpEncoder.hpp | 3 | ||||
-rw-r--r-- | vmime/utility/encoder/uuEncoder.hpp | 3 |
15 files changed, 86 insertions, 4 deletions
diff --git a/vmime/body.hpp b/vmime/body.hpp index 50d67807..6869bb70 100644 --- a/vmime/body.hpp +++ b/vmime/body.hpp @@ -280,8 +280,13 @@ public: const std::vector <ref <component> > getChildComponents(); + utility::stream::size_type getGeneratedSize(const generationContext& ctx); + private: + text getActualPrologText(const generationContext& ctx) const; + text getActualEpilogText(const generationContext& ctx) const; + void setParentPart(ref <bodyPart> parent); diff --git a/vmime/bodyPart.hpp b/vmime/bodyPart.hpp index e54f7c0a..62365b8b 100644 --- a/vmime/bodyPart.hpp +++ b/vmime/bodyPart.hpp @@ -103,6 +103,8 @@ public: const std::vector <ref <component> > getChildComponents(); + utility::stream::size_type getGeneratedSize(const generationContext& ctx); + private: ref <header> m_header; diff --git a/vmime/component.hpp b/vmime/component.hpp index 6a7ff43c..4c6078f3 100644 --- a/vmime/component.hpp +++ b/vmime/component.hpp @@ -209,6 +209,16 @@ public: */ virtual const std::vector <ref <component> > getChildComponents() = 0; + /** Get the number of bytes that will be used by this component when + * it is generated. This may be a heuristically-derived estimate, + * but such an estimated size should always be larger than the actual + * generated size. + * + * @param ctx generation context + * @return component size when generated + */ + virtual utility::stream::size_type getGeneratedSize(const generationContext& ctx); + protected: void setParsedBounds(const utility::stream::size_type start, const utility::stream::size_type end); diff --git a/vmime/exception.hpp b/vmime/exception.hpp index b3bb02b0..f11079c5 100644 --- a/vmime/exception.hpp +++ b/vmime/exception.hpp @@ -757,6 +757,36 @@ public: }; +/** Transport error: message size exceeds maximum server limits. + */ + +class VMIME_EXPORT message_size_exceeds_max_limits : public net_exception +{ +public: + + message_size_exceeds_max_limits(const string& error = "", const exception& other = NO_EXCEPTION); + ~message_size_exceeds_max_limits() throw(); + + exception* clone() const; + const char* name() const throw(); +}; + + +/** Transport error: message size exceeds current server limits. + */ + +class VMIME_EXPORT message_size_exceeds_cur_limits : public net_exception +{ +public: + + message_size_exceeds_cur_limits(const string& error = "", const exception& other = NO_EXCEPTION); + ~message_size_exceeds_cur_limits() throw(); + + exception* clone() const; + const char* name() const throw(); +}; + + #endif // VMIME_HAVE_MESSAGING_FEATURES diff --git a/vmime/header.hpp b/vmime/header.hpp index 9e3a2f1e..0758e775 100644 --- a/vmime/header.hpp +++ b/vmime/header.hpp @@ -230,6 +230,8 @@ public: const std::vector <ref <component> > getChildComponents(); + utility::stream::size_type getGeneratedSize(const generationContext& ctx); + private: std::vector <ref <headerField> > m_fields; diff --git a/vmime/headerField.hpp b/vmime/headerField.hpp index 8f8c2a1c..5276c84a 100644 --- a/vmime/headerField.hpp +++ b/vmime/headerField.hpp @@ -141,6 +141,8 @@ public: const string::size_type end, string::size_type* newPosition = NULL); + utility::stream::size_type getGeneratedSize(const generationContext& ctx); + protected: void parseImpl diff --git a/vmime/headerFieldValue.hpp b/vmime/headerFieldValue.hpp index 1950abef..2a04a823 100644 --- a/vmime/headerFieldValue.hpp +++ b/vmime/headerFieldValue.hpp @@ -41,6 +41,7 @@ class VMIME_EXPORT headerFieldValue : public component { public: + utility::stream::size_type getGeneratedSize(const generationContext& ctx); }; diff --git a/vmime/net/smtp/SMTPCommand.hpp b/vmime/net/smtp/SMTPCommand.hpp index dcca5f2a..c4001f85 100644 --- a/vmime/net/smtp/SMTPCommand.hpp +++ b/vmime/net/smtp/SMTPCommand.hpp @@ -64,6 +64,7 @@ public: static ref <SMTPCommand> AUTH(const string& mechName); static ref <SMTPCommand> STARTTLS(); static ref <SMTPCommand> MAIL(const mailbox& mbox, const bool utf8); + static ref <SMTPCommand> MAIL(const mailbox& mbox, const bool utf8, const unsigned long size); static ref <SMTPCommand> RCPT(const mailbox& mbox, const bool utf8); static ref <SMTPCommand> RSET(); static ref <SMTPCommand> DATA(); diff --git a/vmime/net/smtp/SMTPTransport.hpp b/vmime/net/smtp/SMTPTransport.hpp index 3629d5d7..962f4406 100644 --- a/vmime/net/smtp/SMTPTransport.hpp +++ b/vmime/net/smtp/SMTPTransport.hpp @@ -99,12 +99,14 @@ private: * @param recipients list of recipient mailboxes * @param sender envelope sender (if empty, expeditor will be used) * @param sendDATACommand if true, the DATA command will be sent + * @param size message size, in bytes (or 0, if not known) */ void sendEnvelope (const mailbox& expeditor, const mailboxList& recipients, const mailbox& sender, - bool sendDATACommand); + bool sendDATACommand, + const utility::stream::size_type size); ref <SMTPConnection> m_connection; diff --git a/vmime/stringContentHandler.hpp b/vmime/stringContentHandler.hpp index 1ab63fcf..20a29157 100644 --- a/vmime/stringContentHandler.hpp +++ b/vmime/stringContentHandler.hpp @@ -58,9 +58,6 @@ public: // encoding/decoding will be performed on generate()/extract()). Note that the // data may be re-encoded (that is, decoded and encoded) if the encoding passed // to generate() is different from this one... - // - // The 'length' parameter is optional (user-defined). You can pass 0 if you want, - // VMime does not make use of it. void setData(const utility::stringProxy& str, const vmime::encoding& enc = NO_ENCODING); void setData(const string& buffer, const vmime::encoding& enc = NO_ENCODING); void setData(const string& buffer, const string::size_type start, const string::size_type end, const vmime::encoding& enc = NO_ENCODING); diff --git a/vmime/utility/encoder/b64Encoder.hpp b/vmime/utility/encoder/b64Encoder.hpp index fec10556..e2bb5780 100644 --- a/vmime/utility/encoder/b64Encoder.hpp +++ b/vmime/utility/encoder/b64Encoder.hpp @@ -47,6 +47,9 @@ public: const std::vector <string> getAvailableProperties() const; + utility::stream::size_type getEncodedSize(const utility::stream::size_type n) const; + utility::stream::size_type getDecodedSize(const utility::stream::size_type n) const; + protected: static const unsigned char sm_alphabet[]; diff --git a/vmime/utility/encoder/defaultEncoder.hpp b/vmime/utility/encoder/defaultEncoder.hpp index 6a11a262..3f7d9111 100644 --- a/vmime/utility/encoder/defaultEncoder.hpp +++ b/vmime/utility/encoder/defaultEncoder.hpp @@ -44,6 +44,9 @@ public: utility::stream::size_type encode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress = NULL); utility::stream::size_type decode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress = NULL); + + utility::stream::size_type getEncodedSize(const utility::stream::size_type n) const; + utility::stream::size_type getDecodedSize(const utility::stream::size_type n) const; }; diff --git a/vmime/utility/encoder/encoder.hpp b/vmime/utility/encoder/encoder.hpp index 9b6bbbe0..65114867 100644 --- a/vmime/utility/encoder/encoder.hpp +++ b/vmime/utility/encoder/encoder.hpp @@ -91,6 +91,24 @@ public: */ const propertySet& getResults() const; + /** Return the encoded size for the specified input (decoded) size. + * If the size is not exact, it may be an estimate which should always + * be larger than the actual encoded size. + * + * @param n count of input (decoded) bytes + * @return count of output (encoded) bytes + */ + virtual utility::stream::size_type getEncodedSize(const utility::stream::size_type n) const = 0; + + /** Return the encoded size for the specified input (encoded) size. + * If the size is not exact, it may be an estimate which should always + * be larger than the actual decoded size. + * + * @param n count of input (encoded) bytes + * @return count of output (decoded) bytes + */ + virtual utility::stream::size_type getDecodedSize(const utility::stream::size_type n) const = 0; + protected: propertySet& getResults(); diff --git a/vmime/utility/encoder/qpEncoder.hpp b/vmime/utility/encoder/qpEncoder.hpp index d4dcc1de..254a38d0 100644 --- a/vmime/utility/encoder/qpEncoder.hpp +++ b/vmime/utility/encoder/qpEncoder.hpp @@ -50,6 +50,9 @@ public: static bool RFC2047_isEncodingNeededForChar(const unsigned char c); static int RFC2047_getEncodedLength(const unsigned char c); + utility::stream::size_type getEncodedSize(const utility::stream::size_type n) const; + utility::stream::size_type getDecodedSize(const utility::stream::size_type n) const; + protected: static const unsigned char sm_hexDigits[17]; diff --git a/vmime/utility/encoder/uuEncoder.hpp b/vmime/utility/encoder/uuEncoder.hpp index 09eb667d..f0bcbb33 100644 --- a/vmime/utility/encoder/uuEncoder.hpp +++ b/vmime/utility/encoder/uuEncoder.hpp @@ -46,6 +46,9 @@ public: utility::stream::size_type decode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress = NULL); const std::vector <string> getAvailableProperties() const; + + utility::stream::size_type getEncodedSize(const utility::stream::size_type n) const; + utility::stream::size_type getDecodedSize(const utility::stream::size_type n) const; }; |