From e90dbe0dd308fca3d6387209b50458bdfb2aeaa6 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Fri, 24 Dec 2004 12:37:52 +0000 Subject: Renamed class 'disposition' to 'contentDisposition'. --- ChangeLog | 5 ++ SConstruct | 2 +- src/constants.cpp | 4 +- src/constants.hpp | 4 +- src/contentDisposition.cpp | 126 ++++++++++++++++++++++++++++++++++++++++ src/contentDisposition.hpp | 88 ++++++++++++++++++++++++++++ src/contentDispositionField.cpp | 2 +- src/contentDispositionField.hpp | 4 +- src/defaultAttachment.cpp | 2 +- src/disposition.cpp | 126 ---------------------------------------- src/disposition.hpp | 88 ---------------------------- src/htmlTextPart.cpp | 2 +- src/messageParser.cpp | 2 +- src/vmime | 2 +- 14 files changed, 231 insertions(+), 226 deletions(-) create mode 100644 src/contentDisposition.cpp create mode 100644 src/contentDisposition.hpp delete mode 100644 src/disposition.cpp delete mode 100644 src/disposition.hpp diff --git a/ChangeLog b/ChangeLog index 6220fbe3..a1c06768 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,11 @@ VERSION 0.6.1-cvs ================= +2004-12-24 Vincent Richard + + * Renamed class 'disposition' to 'contentDisposition' and the enum + namespace 'dispositionTypes' to 'contentDispositionTypes'. + 2004-12-23 Vincent Richard * maildir: when connecting to the store, create root directory on the diff --git a/SConstruct b/SConstruct index e47c4f21..1ee4b4da 100644 --- a/SConstruct +++ b/SConstruct @@ -36,12 +36,12 @@ libvmime_sources = [ 'charset.cpp', 'charset.hpp', 'component.cpp', 'component.hpp', 'constants.cpp', 'constants.hpp', + 'contentDisposition.cpp', 'contentDisposition.hpp', 'contentDispositionField.cpp', 'contentDispositionField.hpp', 'contentHandler.cpp', 'contentHandler.hpp', 'contentTypeField.cpp', 'contentTypeField.hpp', 'dateTime.cpp', 'dateTime.hpp', 'defaultAttachment.cpp', 'defaultAttachment.hpp', - 'disposition.cpp', 'disposition.hpp', 'encoder.cpp', 'encoder.hpp', 'encoder7bit.cpp', 'encoder7bit.hpp', 'encoder8bit.cpp', 'encoder8bit.hpp', diff --git a/src/constants.cpp b/src/constants.cpp index f4bccee0..d59fea05 100644 --- a/src/constants.cpp +++ b/src/constants.cpp @@ -75,8 +75,8 @@ namespace encodingTypes } -// Disposition types = "RFC-2183) -namespace dispositionTypes +// Content disposition types +namespace contentDispositionTypes { const string::value_type* const INLINE = "inline"; const string::value_type* const ATTACHMENT = "attachment"; diff --git a/src/constants.hpp b/src/constants.hpp index 4e7d13c0..6dc21790 100644 --- a/src/constants.hpp +++ b/src/constants.hpp @@ -79,8 +79,8 @@ namespace vmime } - /** Constants for disposition types (RFC-2183). */ - namespace dispositionTypes + /** Constants for content disposition types (RFC-2183). */ + namespace contentDispositionTypes { extern const string::value_type* const INLINE; extern const string::value_type* const ATTACHMENT; diff --git a/src/contentDisposition.cpp b/src/contentDisposition.cpp new file mode 100644 index 00000000..74fd42ae --- /dev/null +++ b/src/contentDisposition.cpp @@ -0,0 +1,126 @@ +// +// VMime library (http://vmime.sourceforge.net) +// Copyright (C) 2002-2004 Vincent Richard +// +// 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. +// + +#include "contentDisposition.hpp" +#include "utility/stringUtils.hpp" + + +namespace vmime +{ + + +contentDisposition::contentDisposition() + : m_name(contentDispositionTypes::INLINE) +{ +} + + +contentDisposition::contentDisposition(const string& name) + : m_name(stringUtils::toLower(name)) +{ +} + + +contentDisposition::contentDisposition(const contentDisposition& type) + : component(), m_name(type.m_name) +{ +} + + +void contentDisposition::parse(const string& buffer, const string::size_type position, + const string::size_type end, string::size_type* newPosition) +{ + m_name = stringUtils::toLower(string(buffer.begin() + position, buffer.begin() + end)); + + setParsedBounds(position, end); + + if (newPosition) + *newPosition = end; +} + + +void contentDisposition::generate(utility::outputStream& os, const string::size_type /* maxLineLength */, + const string::size_type curLinePos, string::size_type* newLinePos) const +{ + os << m_name; + + if (newLinePos) + *newLinePos = curLinePos + m_name.length(); +} + + +contentDisposition& contentDisposition::operator=(const string& name) +{ + m_name = stringUtils::toLower(name); + return (*this); +} + + +const bool contentDisposition::operator==(const contentDisposition& value) const +{ + return (stringUtils::toLower(m_name) == value.m_name); +} + + +const bool contentDisposition::operator!=(const contentDisposition& value) const +{ + return !(*this == value); +} + + +contentDisposition* contentDisposition::clone() const +{ + return new contentDisposition(*this); +} + + +void contentDisposition::copyFrom(const component& other) +{ + const contentDisposition& d = dynamic_cast (other); + + m_name = d.m_name; +} + + +contentDisposition& contentDisposition::operator=(const contentDisposition& other) +{ + copyFrom(other); + return (*this); +} + + +const string& contentDisposition::getName() const +{ + return (m_name); +} + + +void contentDisposition::setName(const string& name) +{ + m_name = name; +} + + +const std::vector contentDisposition::getChildComponents() const +{ + return std::vector (); +} + + +} // vmime diff --git a/src/contentDisposition.hpp b/src/contentDisposition.hpp new file mode 100644 index 00000000..cdc036aa --- /dev/null +++ b/src/contentDisposition.hpp @@ -0,0 +1,88 @@ +// +// VMime library (http://vmime.sourceforge.net) +// Copyright (C) 2002-2004 Vincent Richard +// +// 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_CONTENTDISPOSITION_HPP_INCLUDED +#define VMIME_CONTENTDISPOSITION_HPP_INCLUDED + + +#include "base.hpp" +#include "component.hpp" + + +namespace vmime +{ + + +/** Content disposition (basic type). + */ + +class contentDisposition : public component +{ +public: + + contentDisposition(); + contentDisposition(const string& name); + contentDisposition(const contentDisposition& disp); + + + /** Return the content disposition type. + * See the constants in vmime::dispositionTypes. + * + * @return name of the disposition type (eg. "inline") + */ + const string& getName() const; + + /** Set the content disposition type. + * See the constants in vmime::dispositionTypes. + * + * @param name name of the disposition type + */ + void setName(const string& name); + + contentDisposition* clone() const; + void copyFrom(const component& other); + contentDisposition& operator=(const contentDisposition& other); + + const std::vector getChildComponents() const; + + + contentDisposition& operator=(const string& name); + + const bool operator==(const contentDisposition& value) const; + const bool operator!=(const contentDisposition& value) const; + +private: + + string m_name; + +public: + + using component::parse; + using component::generate; + + // Component parsing & assembling + void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL); + void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const; +}; + + +} // vmime + + +#endif // VMIME_CONTENTDISPOSITION_HPP_INCLUDED diff --git a/src/contentDispositionField.cpp b/src/contentDispositionField.cpp index d3b3eb4a..a4a4c623 100644 --- a/src/contentDispositionField.cpp +++ b/src/contentDispositionField.cpp @@ -33,7 +33,7 @@ contentDispositionField::contentDispositionField() contentDispositionField::contentDispositionField(contentDispositionField&) - : headerField(), parameterizedHeaderField(), genericField () + : headerField(), parameterizedHeaderField(), genericField () { } diff --git a/src/contentDispositionField.hpp b/src/contentDispositionField.hpp index 38a7caa2..b896ce3e 100644 --- a/src/contentDispositionField.hpp +++ b/src/contentDispositionField.hpp @@ -24,7 +24,7 @@ #include "parameterizedHeaderField.hpp" #include "genericField.hpp" -#include "disposition.hpp" +#include "contentDisposition.hpp" #include "dateTime.hpp" @@ -32,7 +32,7 @@ namespace vmime { -class contentDispositionField : public parameterizedHeaderField, public genericField +class contentDispositionField : public parameterizedHeaderField, public genericField { friend class headerFieldFactory::registerer ; diff --git a/src/defaultAttachment.cpp b/src/defaultAttachment.cpp index db3f9ca3..48fbcdbb 100644 --- a/src/defaultAttachment.cpp +++ b/src/defaultAttachment.cpp @@ -78,7 +78,7 @@ void defaultAttachment::generatePart(bodyPart& part) const part.getHeader()->ContentType().setValue(m_type); if (!m_desc.isEmpty()) part.getHeader()->ContentDescription().setValue(m_desc); part.getHeader()->ContentTransferEncoding().setValue(m_encoding); - part.getHeader()->ContentDisposition().setValue(disposition(dispositionTypes::ATTACHMENT)); + part.getHeader()->ContentDisposition().setValue(contentDisposition(contentDispositionTypes::ATTACHMENT)); // Set contents part.getBody()->getContents() = m_data; diff --git a/src/disposition.cpp b/src/disposition.cpp deleted file mode 100644 index 17dba56d..00000000 --- a/src/disposition.cpp +++ /dev/null @@ -1,126 +0,0 @@ -// -// VMime library (http://vmime.sourceforge.net) -// Copyright (C) 2002-2004 Vincent Richard -// -// 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. -// - -#include "disposition.hpp" -#include "utility/stringUtils.hpp" - - -namespace vmime -{ - - -disposition::disposition() - : m_name(dispositionTypes::INLINE) -{ -} - - -disposition::disposition(const string& name) - : m_name(stringUtils::toLower(name)) -{ -} - - -disposition::disposition(const disposition& type) - : component(), m_name(type.m_name) -{ -} - - -void disposition::parse(const string& buffer, const string::size_type position, - const string::size_type end, string::size_type* newPosition) -{ - m_name = stringUtils::toLower(string(buffer.begin() + position, buffer.begin() + end)); - - setParsedBounds(position, end); - - if (newPosition) - *newPosition = end; -} - - -void disposition::generate(utility::outputStream& os, const string::size_type /* maxLineLength */, - const string::size_type curLinePos, string::size_type* newLinePos) const -{ - os << m_name; - - if (newLinePos) - *newLinePos = curLinePos + m_name.length(); -} - - -disposition& disposition::operator=(const string& name) -{ - m_name = stringUtils::toLower(name); - return (*this); -} - - -const bool disposition::operator==(const disposition& value) const -{ - return (stringUtils::toLower(m_name) == value.m_name); -} - - -const bool disposition::operator!=(const disposition& value) const -{ - return !(*this == value); -} - - -disposition* disposition::clone() const -{ - return new disposition(*this); -} - - -void disposition::copyFrom(const component& other) -{ - const disposition& d = dynamic_cast (other); - - m_name = d.m_name; -} - - -disposition& disposition::operator=(const disposition& other) -{ - copyFrom(other); - return (*this); -} - - -const string& disposition::getName() const -{ - return (m_name); -} - - -void disposition::setName(const string& name) -{ - m_name = name; -} - - -const std::vector disposition::getChildComponents() const -{ - return std::vector (); -} - - -} // vmime diff --git a/src/disposition.hpp b/src/disposition.hpp deleted file mode 100644 index 15ab4980..00000000 --- a/src/disposition.hpp +++ /dev/null @@ -1,88 +0,0 @@ -// -// VMime library (http://vmime.sourceforge.net) -// Copyright (C) 2002-2004 Vincent Richard -// -// 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_DISPOSITION_HPP_INCLUDED -#define VMIME_DISPOSITION_HPP_INCLUDED - - -#include "base.hpp" -#include "component.hpp" - - -namespace vmime -{ - - -/** Content disposition (basic type). - */ - -class disposition : public component -{ -public: - - disposition(); - disposition(const string& name); - disposition(const disposition& disp); - - - /** Return the disposition type. - * See the constants in vmime::dispositionTypes. - * - * @return name of the encoding (eg. "inline") - */ - const string& getName() const; - - /** Set the disposition type. - * See the constants in vmime::dispositionTypes. - * - * @param name name of the encoding - */ - void setName(const string& name); - - disposition* clone() const; - void copyFrom(const component& other); - disposition& operator=(const disposition& other); - - const std::vector getChildComponents() const; - - - disposition& operator=(const string& name); - - const bool operator==(const disposition& value) const; - const bool operator!=(const disposition& value) const; - -private: - - string m_name; - -public: - - using component::parse; - using component::generate; - - // Component parsing & assembling - void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL); - void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const; -}; - - -} // vmime - - -#endif // VMIME_DISPOSITION_HPP_INCLUDED diff --git a/src/htmlTextPart.cpp b/src/htmlTextPart.cpp index 596d9718..fd39c78b 100644 --- a/src/htmlTextPart.cpp +++ b/src/htmlTextPart.cpp @@ -100,7 +100,7 @@ void htmlTextPart::generateIn(bodyPart& /* message */, bodyPart& parent) const objPart->getHeader()->ContentType().setValue((*it)->getType()); objPart->getHeader()->ContentId().setValue(messageId("<" + id + ">")); - objPart->getHeader()->ContentDisposition().setValue(disposition(dispositionTypes::INLINE)); + objPart->getHeader()->ContentDisposition().setValue(contentDisposition(contentDispositionTypes::INLINE)); objPart->getHeader()->ContentTransferEncoding().setValue((*it)->getEncoding()); //encoding(encodingTypes::BASE64); diff --git a/src/messageParser.cpp b/src/messageParser.cpp index d5338dc6..2834fc18 100644 --- a/src/messageParser.cpp +++ b/src/messageParser.cpp @@ -125,7 +125,7 @@ void messageParser::findAttachments(const bodyPart& part) const contentDispositionField& cdf = dynamic_cast (*hdr.findField(fields::CONTENT_DISPOSITION)); - if (cdf.getValue().getName() != dispositionTypes::INLINE) + if (cdf.getValue().getName() != contentDispositionTypes::INLINE) { contentDispField = &cdf; isAttachment = true; diff --git a/src/vmime b/src/vmime index e837093d..0c417f3a 100644 --- a/src/vmime +++ b/src/vmime @@ -37,7 +37,7 @@ #include "charset.hpp" #include "text.hpp" #include "encoding.hpp" -#include "disposition.hpp" +#include "contentDisposition.hpp" #include "mailbox.hpp" #include "mailboxGroup.hpp" #include "mailboxList.hpp" -- cgit v1.2.3