diff --git a/SConstruct b/SConstruct index 2d10a124..6622b128 100644 --- a/SConstruct +++ b/SConstruct @@ -93,15 +93,6 @@ libvmime_sources = [ 'defaultAttachment.cpp', 'defaultAttachment.hpp', 'disposition.cpp', 'disposition.hpp', 'emptyContentHandler.cpp', 'emptyContentHandler.hpp', - 'encoder.cpp', 'encoder.hpp', - 'encoder7bit.cpp', 'encoder7bit.hpp', - 'encoder8bit.cpp', 'encoder8bit.hpp', - 'encoderB64.cpp', 'encoderB64.hpp', - 'encoderBinary.cpp', 'encoderBinary.hpp', - 'encoderDefault.cpp', 'encoderDefault.hpp', - 'encoderFactory.cpp', 'encoderFactory.hpp', - 'encoderQP.cpp', 'encoderQP.hpp', - 'encoderUUE.cpp', 'encoderUUE.hpp', 'encoding.cpp', 'encoding.hpp', 'exception.cpp', 'exception.hpp', 'fileAttachment.cpp', 'fileAttachment.hpp', @@ -157,6 +148,16 @@ libvmime_sources = [ 'utility/stringUtils.cpp', 'utility/stringUtils.hpp', 'utility/url.cpp', 'utility/url.hpp', 'utility/urlUtils.cpp', 'utility/urlUtils.hpp', + # -- encoder + 'utility/encoder/encoder.cpp', 'utility/encoder/encoder.hpp', + 'utility/encoder/sevenBitEncoder.cpp', 'utility/encoder/sevenBitEncoder.hpp', + 'utility/encoder/eightBitEncoder.cpp', 'utility/encoder/eightBitEncoder.hpp', + 'utility/encoder/b64Encoder.cpp', 'utility/encoder/b64Encoder.hpp', + 'utility/encoder/binaryEncoder.cpp', 'utility/encoder/binaryEncoder.hpp', + 'utility/encoder/defaultEncoder.cpp', 'utility/encoder/defaultEncoder.hpp', + 'utility/encoder/encoderFactory.cpp', 'utility/encoder/encoderFactory.hpp', + 'utility/encoder/qpEncoder.cpp', 'utility/encoder/qpEncoder.hpp', + 'utility/encoder/uuEncoder.cpp', 'utility/encoder/uuEncoder.hpp', # =============================== MDN ================================ 'mdn/MDNHelper.cpp', 'mdn/MDNHelper.hpp', 'mdn/MDNInfos.cpp', 'mdn/MDNInfos.hpp', @@ -345,7 +346,6 @@ libvmimetest_sources = [ 'tests/parser/charsetTest.cpp', 'tests/parser/datetimeTest.cpp', 'tests/parser/dispositionTest.cpp', - 'tests/parser/encoderTest.cpp', 'tests/parser/headerTest.cpp', 'tests/parser/htmlTextPartTest.cpp', 'tests/parser/mailboxTest.cpp', @@ -363,6 +363,7 @@ libvmimetest_sources = [ 'tests/utility/pathTest.cpp', 'tests/utility/urlTest.cpp', 'tests/utility/smartPtrTest.cpp', + 'tests/utility/encoderTest.cpp', # =============================== Misc =============================== 'tests/misc/importanceHelperTest.cpp', # ============================= Security ============================= diff --git a/src/base.cpp b/src/base.cpp index afba23d9..71c63cdc 100644 --- a/src/base.cpp +++ b/src/base.cpp @@ -26,9 +26,9 @@ #include "vmime/charset.hpp" #include "vmime/base.hpp" -#include "vmime/encoder.hpp" -#include "vmime/encoderB64.hpp" -#include "vmime/encoderQP.hpp" +#include "vmime/utility/encoder/encoder.hpp" +#include "vmime/utility/encoder/b64Encoder.hpp" +#include "vmime/utility/encoder/qpEncoder.hpp" #include "vmime/text.hpp" @@ -37,7 +37,7 @@ #include "vmime/utility/stringUtils.hpp" // For initializing -#include "vmime/encoderFactory.hpp" +#include "vmime/utility/encoder/encoderFactory.hpp" #include "vmime/headerFieldFactory.hpp" #include "vmime/textPartFactory.hpp" #include "vmime/options.hpp" @@ -140,7 +140,7 @@ public: { options::getInstance(); - encoderFactory::getInstance(); + utility::encoder::encoderFactory::getInstance(); headerFieldFactory::getInstance(); textPartFactory::getInstance(); diff --git a/src/encoding.cpp b/src/encoding.cpp index 202dfe90..a45573de 100644 --- a/src/encoding.cpp +++ b/src/encoding.cpp @@ -22,9 +22,10 @@ // #include "vmime/encoding.hpp" -#include "vmime/encoderFactory.hpp" #include "vmime/contentHandler.hpp" +#include "vmime/utility/encoder/encoderFactory.hpp" + #include @@ -77,9 +78,9 @@ void encoding::generate(utility::outputStream& os, const string::size_type /* ma } -ref encoding::getEncoder() const +ref encoding::getEncoder() const { - return (encoderFactory::getInstance()->create(generate())); + return (utility::encoder::encoderFactory::getInstance()->create(generate())); } diff --git a/src/net/smtp/SMTPTransport.cpp b/src/net/smtp/SMTPTransport.cpp index 0a2e5b9f..3ce8d217 100644 --- a/src/net/smtp/SMTPTransport.cpp +++ b/src/net/smtp/SMTPTransport.cpp @@ -26,7 +26,6 @@ #include "vmime/exception.hpp" #include "vmime/platform.hpp" -#include "vmime/encoderB64.hpp" #include "vmime/mailboxList.hpp" #include "vmime/utility/filteredStream.hpp" diff --git a/src/security/sasl/SASLContext.cpp b/src/security/sasl/SASLContext.cpp index 6de2f25c..fca95c72 100644 --- a/src/security/sasl/SASLContext.cpp +++ b/src/security/sasl/SASLContext.cpp @@ -29,7 +29,8 @@ #include "vmime/security/sasl/SASLMechanism.hpp" #include "vmime/base.hpp" -#include "vmime/encoderFactory.hpp" + +#include "vmime/utility/encoder/encoderFactory.hpp" #include "vmime/utility/stream.hpp" @@ -103,7 +104,8 @@ void SASLContext::decodeB64(const string& input, byte_t** output, int* outputLen utility::inputStreamStringAdapter is(input); utility::outputStreamStringAdapter os(res); - ref dec = encoderFactory::getInstance()->create("base64"); + ref dec = + utility::encoder::encoderFactory::getInstance()->create("base64"); dec->decode(is, os); @@ -123,7 +125,8 @@ const string SASLContext::encodeB64(const byte_t* input, const int inputLen) utility::inputStreamByteBufferAdapter is(input, inputLen); utility::outputStreamStringAdapter os(res); - ref enc = encoderFactory::getInstance()->create("base64"); + ref enc = + utility::encoder::encoderFactory::getInstance()->create("base64"); enc->encode(is, os); diff --git a/src/streamContentHandler.cpp b/src/streamContentHandler.cpp index 386b0e17..b5f02bf0 100644 --- a/src/streamContentHandler.cpp +++ b/src/streamContentHandler.cpp @@ -94,8 +94,8 @@ void streamContentHandler::generate(utility::outputStream& os, const vmime::enco // buffer, and then re-encode to output stream... if (m_encoding != enc) { - ref theDecoder = m_encoding.getEncoder(); - ref theEncoder = enc.getEncoder(); + ref theDecoder = m_encoding.getEncoder(); + ref theEncoder = enc.getEncoder(); theEncoder->getProperties()["maxlinelength"] = maxLineLength; @@ -122,7 +122,7 @@ void streamContentHandler::generate(utility::outputStream& os, const vmime::enco // Need to encode data before else { - ref theEncoder = enc.getEncoder(); + ref theEncoder = enc.getEncoder(); theEncoder->getProperties()["maxlinelength"] = maxLineLength; m_stream->reset(); // may not work... @@ -151,7 +151,7 @@ void streamContentHandler::extract(utility::outputStream& os, // Need to decode data else { - ref theDecoder = m_encoding.getEncoder(); + ref theDecoder = m_encoding.getEncoder(); m_stream->reset(); // may not work... diff --git a/src/stringContentHandler.cpp b/src/stringContentHandler.cpp index 6dd2719b..84cada5f 100644 --- a/src/stringContentHandler.cpp +++ b/src/stringContentHandler.cpp @@ -114,8 +114,8 @@ void stringContentHandler::generate(utility::outputStream& os, // buffer, and then re-encode to output stream... if (m_encoding != enc) { - ref theDecoder = m_encoding.getEncoder(); - ref theEncoder = enc.getEncoder(); + ref theDecoder = m_encoding.getEncoder(); + ref theEncoder = enc.getEncoder(); theEncoder->getProperties()["maxlinelength"] = maxLineLength; @@ -140,7 +140,7 @@ void stringContentHandler::generate(utility::outputStream& os, // Need to encode data before else { - ref theEncoder = enc.getEncoder(); + ref theEncoder = enc.getEncoder(); theEncoder->getProperties()["maxlinelength"] = maxLineLength; utility::inputStreamStringProxyAdapter in(m_string); @@ -161,7 +161,7 @@ void stringContentHandler::extract(utility::outputStream& os, // Need to decode data else { - ref theDecoder = m_encoding.getEncoder(); + ref theDecoder = m_encoding.getEncoder(); utility::inputStreamStringProxyAdapter in(m_string); utility::progressListenerSizeAdapter plsa(progress, getLength()); diff --git a/src/encoderB64.cpp b/src/utility/encoder/b64Encoder.cpp similarity index 94% rename from src/encoderB64.cpp rename to src/utility/encoder/b64Encoder.cpp index 2c16ee75..c4ba2b39 100644 --- a/src/encoderB64.cpp +++ b/src/utility/encoder/b64Encoder.cpp @@ -21,20 +21,21 @@ // the GNU General Public License cover the whole combination. // -#include "vmime/encoderB64.hpp" +#include "vmime/utility/encoder/b64Encoder.hpp" #include "vmime/parserHelpers.hpp" -namespace vmime -{ +namespace vmime { +namespace utility { +namespace encoder { -encoderB64::encoderB64() +b64Encoder::b64Encoder() { } -const std::vector encoderB64::getAvailableProperties() const +const std::vector b64Encoder::getAvailableProperties() const { std::vector list(encoder::getAvailableProperties()); @@ -45,10 +46,10 @@ const std::vector encoderB64::getAvailableProperties() const // 7-bits alphabet used to encode binary data -const unsigned char encoderB64::sm_alphabet[] = +const unsigned char b64Encoder::sm_alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; -const unsigned char encoderB64::sm_decodeMap[256] = +const unsigned char b64Encoder::sm_decodeMap[256] = { 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // 0x00 - 0x0f 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // 0x10 - 0x1f @@ -74,7 +75,7 @@ const unsigned char encoderB64::sm_decodeMap[256] = -utility::stream::size_type encoderB64::encode(utility::inputStream& in, +utility::stream::size_type b64Encoder::encode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress) { in.reset(); // may not work... @@ -189,7 +190,7 @@ utility::stream::size_type encoderB64::encode(utility::inputStream& in, } -utility::stream::size_type encoderB64::decode(utility::inputStream& in, +utility::stream::size_type b64Encoder::decode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress) { in.reset(); // may not work... @@ -302,4 +303,6 @@ utility::stream::size_type encoderB64::decode(utility::inputStream& in, } +} // encoder +} // utility } // vmime diff --git a/src/encoder7bit.cpp b/src/utility/encoder/binaryEncoder.cpp similarity index 86% rename from src/encoder7bit.cpp rename to src/utility/encoder/binaryEncoder.cpp index 4a60950f..2bc77d27 100644 --- a/src/encoder7bit.cpp +++ b/src/utility/encoder/binaryEncoder.cpp @@ -21,16 +21,19 @@ // the GNU General Public License cover the whole combination. // -#include "vmime/encoder7bit.hpp" +#include "vmime/utility/encoder/binaryEncoder.hpp" -namespace vmime -{ +namespace vmime { +namespace utility { +namespace encoder { -encoder7bit::encoder7bit() +binaryEncoder::binaryEncoder() { } +} // encoder +} // utility } // vmime diff --git a/src/encoderDefault.cpp b/src/utility/encoder/defaultEncoder.cpp similarity index 85% rename from src/encoderDefault.cpp rename to src/utility/encoder/defaultEncoder.cpp index 1f2ba859..db833c85 100644 --- a/src/encoderDefault.cpp +++ b/src/utility/encoder/defaultEncoder.cpp @@ -21,19 +21,20 @@ // the GNU General Public License cover the whole combination. // -#include "vmime/encoderDefault.hpp" +#include "vmime/utility/encoder/defaultEncoder.hpp" -namespace vmime -{ +namespace vmime { +namespace utility { +namespace encoder { -encoderDefault::encoderDefault() +defaultEncoder::defaultEncoder() { } -utility::stream::size_type encoderDefault::encode(utility::inputStream& in, +utility::stream::size_type defaultEncoder::encode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress) { in.reset(); // may not work... @@ -50,7 +51,7 @@ utility::stream::size_type encoderDefault::encode(utility::inputStream& in, } -utility::stream::size_type encoderDefault::decode(utility::inputStream& in, +utility::stream::size_type defaultEncoder::decode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress) { in.reset(); // may not work... @@ -67,4 +68,6 @@ utility::stream::size_type encoderDefault::decode(utility::inputStream& in, } +} // encoder +} // utility } // vmime diff --git a/src/encoder8bit.cpp b/src/utility/encoder/eightBitEncoder.cpp similarity index 86% rename from src/encoder8bit.cpp rename to src/utility/encoder/eightBitEncoder.cpp index c85a3804..88f07bc4 100644 --- a/src/encoder8bit.cpp +++ b/src/utility/encoder/eightBitEncoder.cpp @@ -21,16 +21,19 @@ // the GNU General Public License cover the whole combination. // -#include "vmime/encoder8bit.hpp" +#include "vmime/utility/encoder/eightBitEncoder.hpp" -namespace vmime -{ +namespace vmime { +namespace utility { +namespace encoder { -encoder8bit::encoder8bit() +eightBitEncoder::eightBitEncoder() { } +} // encoder +} // utility } // vmime diff --git a/src/encoder.cpp b/src/utility/encoder/encoder.cpp similarity index 92% rename from src/encoder.cpp rename to src/utility/encoder/encoder.cpp index 38c7764a..893ed4fc 100644 --- a/src/encoder.cpp +++ b/src/utility/encoder/encoder.cpp @@ -21,12 +21,13 @@ // the GNU General Public License cover the whole combination. // -#include "vmime/encoder.hpp" +#include "vmime/utility/encoder/encoder.hpp" #include "vmime/exception.hpp" -namespace vmime -{ +namespace vmime { +namespace utility { +namespace encoder { encoder::encoder() @@ -70,4 +71,6 @@ const std::vector encoder::getAvailableProperties() const } +} // encoder +} // utility } // vmime diff --git a/src/encoderFactory.cpp b/src/utility/encoder/encoderFactory.cpp similarity index 77% rename from src/encoderFactory.cpp rename to src/utility/encoder/encoderFactory.cpp index 605286be..9d7c1070 100644 --- a/src/encoderFactory.cpp +++ b/src/utility/encoder/encoderFactory.cpp @@ -21,30 +21,31 @@ // the GNU General Public License cover the whole combination. // -#include "vmime/encoderFactory.hpp" +#include "vmime/utility/encoder/encoderFactory.hpp" #include "vmime/exception.hpp" -#include "vmime/encoderB64.hpp" -#include "vmime/encoderQP.hpp" -#include "vmime/encoderUUE.hpp" -#include "vmime/encoderBinary.hpp" -#include "vmime/encoder7bit.hpp" -#include "vmime/encoder8bit.hpp" +#include "vmime/utility/encoder/b64Encoder.hpp" +#include "vmime/utility/encoder/qpEncoder.hpp" +#include "vmime/utility/encoder/uuEncoder.hpp" +#include "vmime/utility/encoder/binaryEncoder.hpp" +#include "vmime/utility/encoder/sevenBitEncoder.hpp" +#include "vmime/utility/encoder/eightBitEncoder.hpp" -namespace vmime -{ +namespace vmime { +namespace utility { +namespace encoder { encoderFactory::encoderFactory() { // Register some default encoders - registerName ("base64"); - registerName ("quoted-printable"); - registerName ("uuencode"); - registerName ("7bit"); - registerName ("8bit"); - registerName ("binary"); + registerName ("base64"); + registerName ("quoted-printable"); + registerName ("uuencode"); + registerName ("7bit"); + registerName ("8bit"); + registerName ("binary"); } @@ -107,4 +108,6 @@ const std::vector > encoderFactor } +} // encoder +} // utility } // vmime diff --git a/src/encoderQP.cpp b/src/utility/encoder/qpEncoder.cpp similarity index 95% rename from src/encoderQP.cpp rename to src/utility/encoder/qpEncoder.cpp index 95ca331c..737d488a 100644 --- a/src/encoderQP.cpp +++ b/src/utility/encoder/qpEncoder.cpp @@ -21,20 +21,21 @@ // the GNU General Public License cover the whole combination. // -#include "vmime/encoderQP.hpp" +#include "vmime/utility/encoder/qpEncoder.hpp" #include "vmime/parserHelpers.hpp" -namespace vmime -{ +namespace vmime { +namespace utility { +namespace encoder { -encoderQP::encoderQP() +qpEncoder::qpEncoder() { } -const std::vector encoderQP::getAvailableProperties() const +const std::vector qpEncoder::getAvailableProperties() const { std::vector list(encoder::getAvailableProperties()); @@ -51,10 +52,10 @@ const std::vector encoderQP::getAvailableProperties() const // Encoding table -const unsigned char encoderQP::sm_hexDigits[] = "0123456789ABCDEF"; +const unsigned char qpEncoder::sm_hexDigits[] = "0123456789ABCDEF"; // Decoding table -const unsigned char encoderQP::sm_hexDecodeTable[256] = +const unsigned char qpEncoder::sm_hexDecodeTable[256] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -89,7 +90,7 @@ const unsigned char encoderQP::sm_hexDecodeTable[256] = #endif // VMIME_BUILDING_DOC -utility::stream::size_type encoderQP::encode(utility::inputStream& in, +utility::stream::size_type qpEncoder::encode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress) { in.reset(); // may not work... @@ -305,7 +306,7 @@ utility::stream::size_type encoderQP::encode(utility::inputStream& in, } -utility::stream::size_type encoderQP::decode(utility::inputStream& in, +utility::stream::size_type qpEncoder::decode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress) { in.reset(); // may not work... @@ -466,4 +467,6 @@ utility::stream::size_type encoderQP::decode(utility::inputStream& in, } +} // encoder +} // utility } // vmime diff --git a/src/encoderBinary.cpp b/src/utility/encoder/sevenBitEncoder.cpp similarity index 86% rename from src/encoderBinary.cpp rename to src/utility/encoder/sevenBitEncoder.cpp index dd77b072..812afa90 100644 --- a/src/encoderBinary.cpp +++ b/src/utility/encoder/sevenBitEncoder.cpp @@ -21,16 +21,19 @@ // the GNU General Public License cover the whole combination. // -#include "vmime/encoderBinary.hpp" +#include "vmime/utility/encoder/sevenBitEncoder.hpp" -namespace vmime -{ +namespace vmime { +namespace utility { +namespace encoder { -encoderBinary::encoderBinary() +sevenBitEncoder::sevenBitEncoder() { } +} // encoder +} // utility } // vmime diff --git a/src/encoderUUE.cpp b/src/utility/encoder/uuEncoder.cpp similarity index 95% rename from src/encoderUUE.cpp rename to src/utility/encoder/uuEncoder.cpp index ed54ffa7..0e72599b 100644 --- a/src/encoderUUE.cpp +++ b/src/utility/encoder/uuEncoder.cpp @@ -21,15 +21,16 @@ // the GNU General Public License cover the whole combination. // -#include "vmime/encoderUUE.hpp" +#include "vmime/utility/encoder/uuEncoder.hpp" #include "vmime/parserHelpers.hpp" -namespace vmime -{ +namespace vmime { +namespace utility { +namespace encoder { -encoderUUE::encoderUUE() +uuEncoder::uuEncoder() { getProperties()["mode"] = 644; getProperties()["filename"] = "no_name"; @@ -37,7 +38,7 @@ encoderUUE::encoderUUE() } -const std::vector encoderUUE::getAvailableProperties() const +const std::vector uuEncoder::getAvailableProperties() const { std::vector list(encoder::getAvailableProperties()); @@ -63,7 +64,7 @@ static inline unsigned char UUDECODE(const unsigned char c) } -utility::stream::size_type encoderUUE::encode(utility::inputStream& in, +utility::stream::size_type uuEncoder::encode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress) { in.reset(); // may not work... @@ -142,7 +143,7 @@ utility::stream::size_type encoderUUE::encode(utility::inputStream& in, } -utility::stream::size_type encoderUUE::decode(utility::inputStream& in, +utility::stream::size_type uuEncoder::decode(utility::inputStream& in, utility::outputStream& out, utility::progressListener* progress) { in.reset(); // may not work... @@ -325,4 +326,6 @@ utility::stream::size_type encoderUUE::decode(utility::inputStream& in, } +} // encoder +} // utility } // vmime diff --git a/src/word.cpp b/src/word.cpp index b129965d..95adc5c6 100644 --- a/src/word.cpp +++ b/src/word.cpp @@ -28,9 +28,9 @@ #include "vmime/utility/smartPtr.hpp" #include "vmime/parserHelpers.hpp" -#include "vmime/encoder.hpp" -#include "vmime/encoderB64.hpp" -#include "vmime/encoderQP.hpp" +#include "vmime/utility/encoder/encoder.hpp" +#include "vmime/utility/encoder/b64Encoder.hpp" +#include "vmime/utility/encoder/qpEncoder.hpp" #include "vmime/wordEncoder.hpp" @@ -267,17 +267,17 @@ void word::parse(const string& buffer, const string::size_type position, const string::const_iterator dataEnd = p; p += 2; // skip '?=' - encoder* theEncoder = NULL; + utility::encoder::encoder* theEncoder = NULL; // Base-64 encoding if (*encPos == 'B' || *encPos == 'b') { - theEncoder = new encoderB64; + theEncoder = new utility::encoder::b64Encoder(); } // Quoted-Printable encoding else if (*encPos == 'Q' || *encPos == 'q') { - theEncoder = new encoderQP; + theEncoder = new utility::encoder::qpEncoder(); theEncoder->getProperties()["rfc2047"] = true; } diff --git a/src/wordEncoder.cpp b/src/wordEncoder.cpp index 9888c169..ab7c004c 100644 --- a/src/wordEncoder.cpp +++ b/src/wordEncoder.cpp @@ -25,8 +25,9 @@ #include "vmime/exception.hpp" #include "vmime/charsetConverter.hpp" -#include "vmime/encoderB64.hpp" -#include "vmime/encoderQP.hpp" + +#include "vmime/utility/encoder/b64Encoder.hpp" +#include "vmime/utility/encoder/qpEncoder.hpp" #include "vmime/utility/stringUtils.hpp" @@ -62,11 +63,11 @@ wordEncoder::wordEncoder(const string& buffer, const charset& charset, const Enc if (m_encoding == ENCODING_B64) { - m_encoder = vmime::create (); + m_encoder = vmime::create (); } else // ENCODING_QP { - m_encoder = vmime::create (); + m_encoder = vmime::create (); m_encoder->getProperties()["rfc2047"] = true; } } diff --git a/tests/parser/encoderTest.cpp b/tests/utility/encoderTest.cpp similarity index 97% rename from tests/parser/encoderTest.cpp rename to tests/utility/encoderTest.cpp index 180d1296..648af78b 100644 --- a/tests/parser/encoderTest.cpp +++ b/tests/utility/encoderTest.cpp @@ -39,7 +39,8 @@ VMIME_TEST_SUITE_BEGIN // Encoding helper function static const vmime::string encode(const vmime::string& name, const vmime::string& in, int maxLineLength = 0) { - vmime::ref enc = vmime::encoderFactory::getInstance()->create(name); + vmime::ref enc = + vmime::utility::encoder::encoderFactory::getInstance()->create(name); if (maxLineLength != 0) enc->getProperties()["maxlinelength"] = maxLineLength; @@ -57,7 +58,8 @@ VMIME_TEST_SUITE_BEGIN // Decoding helper function static const vmime::string decode(const vmime::string& name, const vmime::string& in, int maxLineLength = 0) { - vmime::ref enc = vmime::encoderFactory::getInstance()->create(name); + vmime::ref enc = + vmime::utility::encoder::encoderFactory::getInstance()->create(name); if (maxLineLength != 0) enc->getProperties()["maxlinelength"] = maxLineLength; diff --git a/vmime/encoding.hpp b/vmime/encoding.hpp index fa5cc183..aa998539 100644 --- a/vmime/encoding.hpp +++ b/vmime/encoding.hpp @@ -27,7 +27,8 @@ #include "vmime/base.hpp" #include "vmime/headerFieldValue.hpp" -#include "vmime/encoder.hpp" + +#include "vmime/utility/encoder/encoder.hpp" namespace vmime @@ -99,7 +100,7 @@ public: * is registered for the encoding * @return a new encoder object for the encoding type */ - ref getEncoder() const; + ref getEncoder() const; private: diff --git a/vmime/net/imap/IMAPParser.hpp b/vmime/net/imap/IMAPParser.hpp index c6e1831d..b3079570 100644 --- a/vmime/net/imap/IMAPParser.hpp +++ b/vmime/net/imap/IMAPParser.hpp @@ -34,8 +34,8 @@ #include "vmime/utility/stringUtils.hpp" #include "vmime/utility/progressListener.hpp" -#include "vmime/encoderB64.hpp" -#include "vmime/encoderQP.hpp" +#include "vmime/utility/encoder/b64Encoder.hpp" +#include "vmime/utility/encoder/qpEncoder.hpp" #include "vmime/platform.hpp" @@ -1233,18 +1233,18 @@ public: delete (theCharset); // Decode text - encoder* theEncoder = NULL; + utility::encoder::encoder* theEncoder = NULL; if (theEncoding->value()[0] == 'q' || theEncoding->value()[0] == 'Q') { // Quoted-printable - theEncoder = new encoderQP; + theEncoder = new utility::encoder::qpEncoder(); theEncoder->getProperties()["rfc2047"] = true; } else if (theEncoding->value()[0] == 'b' || theEncoding->value()[0] == 'B') { // Base64 - theEncoder = new encoderB64; + theEncoder = new utility::encoder::b64Encoder(); } if (theEncoder) diff --git a/vmime/encoderB64.hpp b/vmime/utility/encoder/b64Encoder.hpp similarity index 81% rename from vmime/encoderB64.hpp rename to vmime/utility/encoder/b64Encoder.hpp index 46444a53..831e9f6f 100644 --- a/vmime/encoderB64.hpp +++ b/vmime/utility/encoder/b64Encoder.hpp @@ -21,25 +21,26 @@ // the GNU General Public License cover the whole combination. // -#ifndef VMIME_ENCODERB64_HPP_INCLUDED -#define VMIME_ENCODERB64_HPP_INCLUDED +#ifndef VMIME_UTILITY_ENCODER_B64ENCODER_HPP_INCLUDED +#define VMIME_UTILITY_ENCODER_B64ENCODER_HPP_INCLUDED -#include "vmime/encoder.hpp" +#include "vmime/utility/encoder/encoder.hpp" -namespace vmime -{ +namespace vmime { +namespace utility { +namespace encoder { /** Base64 encoder. */ -class encoderB64 : public encoder +class b64Encoder : public encoder { public: - encoderB64(); + b64Encoder(); 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); @@ -53,7 +54,9 @@ protected: }; +} // encoder +} // utility } // vmime -#endif // VMIME_ENCODERB64_HPP_INCLUDED +#endif // VMIME_UTILITY_ENCODER_B64ENCODER_HPP_INCLUDED diff --git a/vmime/encoderBinary.hpp b/vmime/utility/encoder/binaryEncoder.hpp similarity index 75% rename from vmime/encoderBinary.hpp rename to vmime/utility/encoder/binaryEncoder.hpp index 4708c791..783f8312 100644 --- a/vmime/encoderBinary.hpp +++ b/vmime/utility/encoder/binaryEncoder.hpp @@ -21,29 +21,32 @@ // the GNU General Public License cover the whole combination. // -#ifndef VMIME_ENCODERBINARY_HPP_INCLUDED -#define VMIME_ENCODERBINARY_HPP_INCLUDED +#ifndef VMIME_UTILITY_ENCODER_BINARYENCODER_HPP_INCLUDED +#define VMIME_UTILITY_ENCODER_BINARYENCODER_HPP_INCLUDED -#include "vmime/encoderDefault.hpp" +#include "vmime/utility/encoder/defaultEncoder.hpp" -namespace vmime -{ +namespace vmime { +namespace utility { +namespace encoder { /** Binary encoder. */ -class encoderBinary : public encoderDefault +class binaryEncoder : public defaultEncoder { public: - encoderBinary(); + binaryEncoder(); }; +} // encoder +} // utility } // vmime -#endif // VMIME_ENCODERBINARY_HPP_INCLUDED +#endif // VMIME_UTILITY_ENCODER_BINARYENCODER_HPP_INCLUDED diff --git a/vmime/encoderDefault.hpp b/vmime/utility/encoder/defaultEncoder.hpp similarity index 79% rename from vmime/encoderDefault.hpp rename to vmime/utility/encoder/defaultEncoder.hpp index 71dc9e9f..3ddad1fb 100644 --- a/vmime/encoderDefault.hpp +++ b/vmime/utility/encoder/defaultEncoder.hpp @@ -21,32 +21,35 @@ // the GNU General Public License cover the whole combination. // -#ifndef VMIME_ENCODERDEFAULT_HPP_INCLUDED -#define VMIME_ENCODERDEFAULT_HPP_INCLUDED +#ifndef VMIME_UTILITY_ENCODER_DEFAULTENCODER_HPP_INCLUDED +#define VMIME_UTILITY_ENCODER_DEFAULTENCODER_HPP_INCLUDED -#include "vmime/encoder.hpp" +#include "vmime/utility/encoder/encoder.hpp" -namespace vmime -{ +namespace vmime { +namespace utility { +namespace encoder { /** Default encoder (simple copy, no encoding/decoding is performed). */ -class encoderDefault : public encoder +class defaultEncoder : public encoder { public: - encoderDefault(); + defaultEncoder(); 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); }; +} // encoder +} // utility } // vmime -#endif // VMIME_ENCODERDEFAUL_HPP_INCLUDED +#endif // VMIME_UTILITY_ENCODER_DEFAULTENCODER_HPP_INCLUDED diff --git a/vmime/encoder8bit.hpp b/vmime/utility/encoder/eightBitEncoder.hpp similarity index 74% rename from vmime/encoder8bit.hpp rename to vmime/utility/encoder/eightBitEncoder.hpp index 67722b06..2e9b1381 100644 --- a/vmime/encoder8bit.hpp +++ b/vmime/utility/encoder/eightBitEncoder.hpp @@ -21,29 +21,32 @@ // the GNU General Public License cover the whole combination. // -#ifndef VMIME_ENCODER8BIT_HPP_INCLUDED -#define VMIME_ENCODER8BIT_HPP_INCLUDED +#ifndef VMIME_UTILITY_ENCODER_EIGHTBITENCODER_HPP_INCLUDED +#define VMIME_UTILITY_ENCODER_EIGHTBITENCODER_HPP_INCLUDED -#include "vmime/encoderDefault.hpp" +#include "vmime/utility/encoder/defaultEncoder.hpp" -namespace vmime -{ +namespace vmime { +namespace utility { +namespace encoder { /** 8-bit encoder. */ -class encoder8bit : public encoderDefault +class eightBitEncoder : public defaultEncoder { public: - encoder8bit(); + eightBitEncoder(); }; +} // encoder +} // utility } // vmime -#endif // VMIME_ENCODER8BIT_HPP_INCLUDED +#endif // VMIME_UTILITY_ENCODER_EIGHTBITENCODER_HPP_INCLUDED diff --git a/vmime/encoder.hpp b/vmime/utility/encoder/encoder.hpp similarity index 92% rename from vmime/encoder.hpp rename to vmime/utility/encoder/encoder.hpp index cb5de063..eec00035 100644 --- a/vmime/encoder.hpp +++ b/vmime/utility/encoder/encoder.hpp @@ -21,8 +21,8 @@ // the GNU General Public License cover the whole combination. // -#ifndef VMIME_ENCODER_HPP_INCLUDED -#define VMIME_ENCODER_HPP_INCLUDED +#ifndef VMIME_UTILITY_ENCODER_ENCODER_HPP_INCLUDED +#define VMIME_UTILITY_ENCODER_ENCODER_HPP_INCLUDED #include "vmime/base.hpp" @@ -31,8 +31,9 @@ #include "vmime/utility/progressListener.hpp" -namespace vmime -{ +namespace vmime { +namespace utility { +namespace encoder { /** Encode/decode data in different encodings. @@ -101,7 +102,9 @@ private: }; +} // encoder +} // utility } // vmime -#endif // VMIME_ENCODER_HPP_INCLUDED +#endif // VMIME_UTILITY_ENCODER_ENCODER_HPP_INCLUDED diff --git a/vmime/encoderFactory.hpp b/vmime/utility/encoder/encoderFactory.hpp similarity index 91% rename from vmime/encoderFactory.hpp rename to vmime/utility/encoder/encoderFactory.hpp index 5358ce76..22f28f4b 100644 --- a/vmime/encoderFactory.hpp +++ b/vmime/utility/encoder/encoderFactory.hpp @@ -21,16 +21,17 @@ // the GNU General Public License cover the whole combination. // -#ifndef VMIME_ENCODERFACTORY_HPP_INCLUDED -#define VMIME_ENCODERFACTORY_HPP_INCLUDED +#ifndef VMIME_UTILITY_ENCODER_ENCODERFACTORY_HPP_INCLUDED +#define VMIME_UTILITY_ENCODER_ENCODERFACTORY_HPP_INCLUDED -#include "vmime/encoder.hpp" +#include "vmime/utility/encoder/encoder.hpp" #include "vmime/utility/stringUtils.hpp" -namespace vmime -{ +namespace vmime { +namespace utility { +namespace encoder { /** A factory to create 'encoder' objects for the specified encoding. @@ -143,7 +144,9 @@ public: }; +} // encoder +} // utility } // vmime -#endif // VMIME_ENCODERFACTORY_HPP_INCLUDED +#endif // VMIME_UTILITY_ENCODER_ENCODERFACTORY_HPP_INCLUDED diff --git a/vmime/encoderQP.hpp b/vmime/utility/encoder/qpEncoder.hpp similarity index 82% rename from vmime/encoderQP.hpp rename to vmime/utility/encoder/qpEncoder.hpp index bd604abc..6af3c901 100644 --- a/vmime/encoderQP.hpp +++ b/vmime/utility/encoder/qpEncoder.hpp @@ -21,25 +21,26 @@ // the GNU General Public License cover the whole combination. // -#ifndef VMIME_ENCODERQP_HPP_INCLUDED -#define VMIME_ENCODERQP_HPP_INCLUDED +#ifndef VMIME_UTILITY_ENCODER_QPENCODER_HPP_INCLUDED +#define VMIME_UTILITY_ENCODER_QPENCODER_HPP_INCLUDED -#include "vmime/encoder.hpp" +#include "vmime/utility/encoder/encoder.hpp" -namespace vmime -{ +namespace vmime { +namespace utility { +namespace encoder { /** Quoted-printable encoder. */ -class encoderQP : public encoder +class qpEncoder : public encoder { public: - encoderQP(); + qpEncoder(); 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); @@ -53,7 +54,9 @@ protected: }; +} // encoder +} // utility } // vmime -#endif // VMIME_ENCODERQP_HPP_INCLUDED +#endif // VMIME_UTILITY_ENCODER_QPENCODER_HPP_INCLUDED diff --git a/vmime/encoder7bit.hpp b/vmime/utility/encoder/sevenBitEncoder.hpp similarity index 74% rename from vmime/encoder7bit.hpp rename to vmime/utility/encoder/sevenBitEncoder.hpp index 0b8fd177..98a999aa 100644 --- a/vmime/encoder7bit.hpp +++ b/vmime/utility/encoder/sevenBitEncoder.hpp @@ -21,29 +21,32 @@ // the GNU General Public License cover the whole combination. // -#ifndef VMIME_ENCODER7BIT_HPP_INCLUDED -#define VMIME_ENCODER7BIT_HPP_INCLUDED +#ifndef VMIME_UTILITY_ENCODER_SEVENBITENCODER_HPP_INCLUDED +#define VMIME_UTILITY_ENCODER_SEVENBITENCODER_HPP_INCLUDED -#include "vmime/encoderDefault.hpp" +#include "vmime/utility/encoder/defaultEncoder.hpp" -namespace vmime -{ +namespace vmime { +namespace utility { +namespace encoder { /** 7-bit encoder. */ -class encoder7bit : public encoderDefault +class sevenBitEncoder : public defaultEncoder { public: - encoder7bit(); + sevenBitEncoder(); }; +} // encoder +} // utility } // vmime -#endif // VMIME_ENCODER7BIT_HPP_INCLUDED +#endif // VMIME_UTILITY_ENCODER_SEVENBITENCODER_HPP_INCLUDED diff --git a/vmime/encoderUUE.hpp b/vmime/utility/encoder/uuEncoder.hpp similarity index 81% rename from vmime/encoderUUE.hpp rename to vmime/utility/encoder/uuEncoder.hpp index bdffb101..6cb5fa1e 100644 --- a/vmime/encoderUUE.hpp +++ b/vmime/utility/encoder/uuEncoder.hpp @@ -21,25 +21,26 @@ // the GNU General Public License cover the whole combination. // -#ifndef VMIME_ENCODERUUE_HPP_INCLUDED -#define VMIME_ENCODERUUE_HPP_INCLUDED +#ifndef VMIME_UTILITY_ENCODER_UUENCODER_HPP_INCLUDED +#define VMIME_UTILITY_ENCODER_UUENCODER_HPP_INCLUDED -#include "vmime/encoder.hpp" +#include "vmime/utility/encoder/encoder.hpp" -namespace vmime -{ +namespace vmime { +namespace utility { +namespace encoder { /** UUEncode encoder. */ -class encoderUUE : public encoder +class uuEncoder : public encoder { public: - encoderUUE(); + uuEncoder(); 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); @@ -48,7 +49,9 @@ public: }; +} // encoder +} // utility } // vmime -#endif // VMIME_ENCODERUUE_HPP_INCLUDED +#endif // VMIME_UTILITY_ENCODER_UUENCODER_HPP_INCLUDED diff --git a/vmime/vmime.hpp b/vmime/vmime.hpp index f62e53db..0e54d7b7 100644 --- a/vmime/vmime.hpp +++ b/vmime/vmime.hpp @@ -66,7 +66,7 @@ #include "vmime/parameterizedHeaderField.hpp" // Encoders -#include "vmime/encoderFactory.hpp" +#include "vmime/utility/encoder/encoderFactory.hpp" // Message builder/parser #include "vmime/messageBuilder.hpp" diff --git a/vmime/wordEncoder.hpp b/vmime/wordEncoder.hpp index 98294fa6..09c141d0 100644 --- a/vmime/wordEncoder.hpp +++ b/vmime/wordEncoder.hpp @@ -32,8 +32,14 @@ namespace vmime { +namespace utility { +namespace encoder { + class encoder; +} // encoder +} // utility + /** Encodes words following RFC-2047. */ @@ -83,7 +89,7 @@ private: charset m_charset; Encoding m_encoding; - ref m_encoder; + ref m_encoder; };