Renamed net::*{part|structure} to net::*message{Part|Structure}. Splitted code in multiple files.
This commit is contained in:
parent
54084253e6
commit
62828e20d4
@ -275,11 +275,11 @@ libvmime_messaging_proto_sources = [
|
||||
'net/imap/IMAPFolder.cpp', 'net/imap/IMAPFolder.hpp',
|
||||
'net/imap/IMAPFolderStatus.cpp', 'net/imap/IMAPFolderStatus.hpp',
|
||||
'net/imap/IMAPMessage.cpp', 'net/imap/IMAPMessage.hpp',
|
||||
'net/imap/IMAPMessagePart.cpp', 'net/imap/IMAPMessagePart.hpp',
|
||||
'net/imap/IMAPMessagePartContentHandler.cpp', 'net/imap/IMAPMessagePartContentHandler.hpp',
|
||||
'net/imap/IMAPMessageStructure.cpp', 'net/imap/IMAPMessageStructure.hpp',
|
||||
'net/imap/IMAPTag.cpp', 'net/imap/IMAPTag.hpp',
|
||||
'net/imap/IMAPUtils.cpp', 'net/imap/IMAPUtils.hpp',
|
||||
'net/imap/IMAPMessagePartContentHandler.cpp', 'net/imap/IMAPMessagePartContentHandler.hpp',
|
||||
'net/imap/IMAPStructure.cpp', 'net/imap/IMAPStructure.hpp',
|
||||
'net/imap/IMAPPart.cpp', 'net/imap/IMAPPart.hpp',
|
||||
'net/imap/IMAPParser.hpp',
|
||||
]
|
||||
],
|
||||
@ -291,6 +291,8 @@ libvmime_messaging_proto_sources = [
|
||||
'net/maildir/maildirFolder.cpp', 'net/maildir/maildirFolder.hpp',
|
||||
'net/maildir/maildirFolderStatus.cpp', 'net/maildir/maildirFolderStatus.hpp',
|
||||
'net/maildir/maildirMessage.cpp', 'net/maildir/maildirMessage.hpp',
|
||||
'net/maildir/maildirMessagePart.cpp', 'net/maildir/maildirMessagePart.hpp',
|
||||
'net/maildir/maildirMessageStructure.cpp', 'net/maildir/maildirMessageStructure.hpp',
|
||||
'net/maildir/maildirUtils.cpp', 'net/maildir/maildirUtils.hpp',
|
||||
'net/maildir/maildirFormat.cpp', 'net/maildir/maildirFormat.hpp',
|
||||
'net/maildir/format/kmailMaildirFormat.cpp', 'net/maildir/format/kmailMaildirFormat.hpp',
|
||||
|
@ -33,8 +33,8 @@
|
||||
#include "vmime/net/imap/IMAPStore.hpp"
|
||||
#include "vmime/net/imap/IMAPConnection.hpp"
|
||||
#include "vmime/net/imap/IMAPUtils.hpp"
|
||||
#include "vmime/net/imap/IMAPStructure.hpp"
|
||||
#include "vmime/net/imap/IMAPPart.hpp"
|
||||
#include "vmime/net/imap/IMAPMessageStructure.hpp"
|
||||
#include "vmime/net/imap/IMAPMessagePart.hpp"
|
||||
#include "vmime/net/imap/IMAPMessagePartContentHandler.hpp"
|
||||
|
||||
#include "vmime/utility/outputStreamAdapter.hpp"
|
||||
@ -169,7 +169,7 @@ int IMAPMessage::getFlags() const
|
||||
}
|
||||
|
||||
|
||||
ref <const structure> IMAPMessage::getStructure() const
|
||||
ref <const messageStructure> IMAPMessage::getStructure() const
|
||||
{
|
||||
if (m_structure == NULL)
|
||||
throw exceptions::unfetched_object();
|
||||
@ -178,7 +178,7 @@ ref <const structure> IMAPMessage::getStructure() const
|
||||
}
|
||||
|
||||
|
||||
ref <structure> IMAPMessage::getStructure()
|
||||
ref <messageStructure> IMAPMessage::getStructure()
|
||||
{
|
||||
if (m_structure == NULL)
|
||||
throw exceptions::unfetched_object();
|
||||
@ -209,7 +209,7 @@ void IMAPMessage::extract(utility::outputStream& os, utility::progressListener*
|
||||
|
||||
|
||||
void IMAPMessage::extractPart
|
||||
(ref <const part> p, utility::outputStream& os, utility::progressListener* progress,
|
||||
(ref <const messagePart> p, utility::outputStream& os, utility::progressListener* progress,
|
||||
const int start, const int length, const bool peek) const
|
||||
{
|
||||
ref <const IMAPFolder> folder = m_folder.acquire();
|
||||
@ -221,7 +221,7 @@ void IMAPMessage::extractPart
|
||||
}
|
||||
|
||||
|
||||
void IMAPMessage::fetchPartHeader(ref <part> p)
|
||||
void IMAPMessage::fetchPartHeader(ref <messagePart> p)
|
||||
{
|
||||
ref <IMAPFolder> folder = m_folder.acquire();
|
||||
|
||||
@ -233,15 +233,15 @@ void IMAPMessage::fetchPartHeader(ref <part> p)
|
||||
|
||||
extractImpl(p, ossAdapter, NULL, 0, -1, EXTRACT_HEADER | EXTRACT_PEEK);
|
||||
|
||||
p.dynamicCast <IMAPPart>()->getOrCreateHeader().parse(oss.str());
|
||||
p.dynamicCast <IMAPMessagePart>()->getOrCreateHeader().parse(oss.str());
|
||||
}
|
||||
|
||||
|
||||
void IMAPMessage::fetchPartHeaderForStructure(ref <structure> str)
|
||||
void IMAPMessage::fetchPartHeaderForStructure(ref <messageStructure> str)
|
||||
{
|
||||
for (size_t i = 0, n = str->getPartCount() ; i < n ; ++i)
|
||||
{
|
||||
ref <class part> part = str->getPartAt(i);
|
||||
ref <messagePart> part = str->getPartAt(i);
|
||||
|
||||
// Fetch header of current part
|
||||
fetchPartHeader(part);
|
||||
@ -252,7 +252,7 @@ void IMAPMessage::fetchPartHeaderForStructure(ref <structure> str)
|
||||
}
|
||||
|
||||
|
||||
void IMAPMessage::extractImpl(ref <const part> p, utility::outputStream& os,
|
||||
void IMAPMessage::extractImpl(ref <const messagePart> p, utility::outputStream& os,
|
||||
utility::progressListener* progress, const int start,
|
||||
const int length, const int extractFlags) const
|
||||
{
|
||||
@ -266,7 +266,7 @@ void IMAPMessage::extractImpl(ref <const part> p, utility::outputStream& os,
|
||||
|
||||
if (p != NULL)
|
||||
{
|
||||
ref <const IMAPPart> currentPart = p.dynamicCast <const IMAPPart>();
|
||||
ref <const IMAPMessagePart> currentPart = p.dynamicCast <const IMAPMessagePart>();
|
||||
std::vector <int> numbers;
|
||||
|
||||
numbers.push_back(currentPart->getNumber());
|
||||
@ -456,7 +456,7 @@ void IMAPMessage::processFetchResponse
|
||||
}
|
||||
case IMAPParser::msg_att_item::BODY_STRUCTURE:
|
||||
{
|
||||
m_structure = vmime::create <IMAPStructure>((*it)->body());
|
||||
m_structure = vmime::create <IMAPMessageStructure>((*it)->body());
|
||||
break;
|
||||
}
|
||||
case IMAPParser::msg_att_item::RFC822_HEADER:
|
||||
@ -632,11 +632,12 @@ void IMAPMessage::setFlags(const int flags, const int mode)
|
||||
}
|
||||
|
||||
|
||||
void IMAPMessage::constructParsedMessage(ref <bodyPart> parentPart, ref <structure> str, int level)
|
||||
void IMAPMessage::constructParsedMessage
|
||||
(ref <bodyPart> parentPart, ref <messageStructure> str, int level)
|
||||
{
|
||||
if (level == 0)
|
||||
{
|
||||
ref <class part> part = str->getPartAt(0);
|
||||
ref <messagePart> part = str->getPartAt(0);
|
||||
|
||||
// Copy header
|
||||
ref <const header> hdr = part->getHeader();
|
||||
@ -654,7 +655,7 @@ void IMAPMessage::constructParsedMessage(ref <bodyPart> parentPart, ref <structu
|
||||
{
|
||||
for (size_t i = 0, n = str->getPartCount() ; i < n ; ++i)
|
||||
{
|
||||
ref <class part> part = str->getPartAt(i);
|
||||
ref <messagePart> part = str->getPartAt(i);
|
||||
|
||||
ref <bodyPart> childPart = vmime::create <bodyPart>();
|
||||
|
||||
@ -681,7 +682,7 @@ void IMAPMessage::constructParsedMessage(ref <bodyPart> parentPart, ref <structu
|
||||
ref <vmime::message> IMAPMessage::getParsedMessage()
|
||||
{
|
||||
// Fetch structure
|
||||
ref <structure> structure = NULL;
|
||||
ref <messageStructure> structure = NULL;
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -27,8 +27,8 @@
|
||||
#if VMIME_HAVE_MESSAGING_FEATURES && VMIME_HAVE_MESSAGING_PROTO_IMAP
|
||||
|
||||
|
||||
#include "vmime/net/imap/IMAPPart.hpp"
|
||||
#include "vmime/net/imap/IMAPStructure.hpp"
|
||||
#include "vmime/net/imap/IMAPMessagePart.hpp"
|
||||
#include "vmime/net/imap/IMAPMessageStructure.hpp"
|
||||
|
||||
|
||||
namespace vmime {
|
||||
@ -36,7 +36,7 @@ namespace net {
|
||||
namespace imap {
|
||||
|
||||
|
||||
IMAPPart::IMAPPart(ref <IMAPPart> parent, const int number, const IMAPParser::body_type_mpart* mpart)
|
||||
IMAPMessagePart::IMAPMessagePart(ref <IMAPMessagePart> parent, const int number, const IMAPParser::body_type_mpart* mpart)
|
||||
: m_parent(parent), m_header(NULL), m_number(number), m_size(0)
|
||||
{
|
||||
m_mediaType = vmime::mediaType
|
||||
@ -44,7 +44,7 @@ IMAPPart::IMAPPart(ref <IMAPPart> parent, const int number, const IMAPParser::bo
|
||||
}
|
||||
|
||||
|
||||
IMAPPart::IMAPPart(ref <IMAPPart> parent, const int number, const IMAPParser::body_type_1part* part)
|
||||
IMAPMessagePart::IMAPMessagePart(ref <IMAPMessagePart> parent, const int number, const IMAPParser::body_type_1part* part)
|
||||
: m_parent(parent), m_header(NULL), m_number(number), m_size(0)
|
||||
{
|
||||
if (part->body_type_text())
|
||||
@ -74,49 +74,49 @@ IMAPPart::IMAPPart(ref <IMAPPart> parent, const int number, const IMAPParser::bo
|
||||
}
|
||||
|
||||
|
||||
ref <const structure> IMAPPart::getStructure() const
|
||||
ref <const messageStructure> IMAPMessagePart::getStructure() const
|
||||
{
|
||||
if (m_structure != NULL)
|
||||
return m_structure;
|
||||
else
|
||||
return IMAPStructure::emptyStructure();
|
||||
return IMAPMessageStructure::emptyStructure();
|
||||
}
|
||||
|
||||
|
||||
ref <structure> IMAPPart::getStructure()
|
||||
ref <messageStructure> IMAPMessagePart::getStructure()
|
||||
{
|
||||
if (m_structure != NULL)
|
||||
return m_structure;
|
||||
else
|
||||
return IMAPStructure::emptyStructure();
|
||||
return IMAPMessageStructure::emptyStructure();
|
||||
}
|
||||
|
||||
|
||||
ref <const IMAPPart> IMAPPart::getParent() const
|
||||
ref <const IMAPMessagePart> IMAPMessagePart::getParent() const
|
||||
{
|
||||
return m_parent.acquire();
|
||||
}
|
||||
|
||||
|
||||
const mediaType& IMAPPart::getType() const
|
||||
const mediaType& IMAPMessagePart::getType() const
|
||||
{
|
||||
return m_mediaType;
|
||||
}
|
||||
|
||||
|
||||
int IMAPPart::getSize() const
|
||||
int IMAPMessagePart::getSize() const
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
|
||||
|
||||
int IMAPPart::getNumber() const
|
||||
int IMAPMessagePart::getNumber() const
|
||||
{
|
||||
return m_number;
|
||||
}
|
||||
|
||||
|
||||
ref <const header> IMAPPart::getHeader() const
|
||||
ref <const header> IMAPMessagePart::getHeader() const
|
||||
{
|
||||
if (m_header == NULL)
|
||||
throw exceptions::unfetched_object();
|
||||
@ -126,24 +126,24 @@ ref <const header> IMAPPart::getHeader() const
|
||||
|
||||
|
||||
// static
|
||||
ref <IMAPPart> IMAPPart::create
|
||||
(ref <IMAPPart> parent, const int number, const IMAPParser::body* body)
|
||||
ref <IMAPMessagePart> IMAPMessagePart::create
|
||||
(ref <IMAPMessagePart> parent, const int number, const IMAPParser::body* body)
|
||||
{
|
||||
if (body->body_type_mpart())
|
||||
{
|
||||
ref <IMAPPart> part = vmime::create <IMAPPart>(parent, number, body->body_type_mpart());
|
||||
part->m_structure = vmime::create <IMAPStructure>(part, body->body_type_mpart()->list());
|
||||
ref <IMAPMessagePart> part = vmime::create <IMAPMessagePart>(parent, number, body->body_type_mpart());
|
||||
part->m_structure = vmime::create <IMAPMessageStructure>(part, body->body_type_mpart()->list());
|
||||
|
||||
return part;
|
||||
}
|
||||
else
|
||||
{
|
||||
return vmime::create <IMAPPart>(parent, number, body->body_type_1part());
|
||||
return vmime::create <IMAPMessagePart>(parent, number, body->body_type_1part());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
header& IMAPPart::getOrCreateHeader()
|
||||
header& IMAPMessagePart::getOrCreateHeader()
|
||||
{
|
||||
if (m_header != NULL)
|
||||
return *m_header;
|
@ -39,7 +39,7 @@ namespace imap {
|
||||
|
||||
|
||||
IMAPMessagePartContentHandler::IMAPMessagePartContentHandler
|
||||
(ref <IMAPMessage> msg, ref <class part> part, const vmime::encoding& encoding)
|
||||
(ref <IMAPMessage> msg, ref <messagePart> part, const vmime::encoding& encoding)
|
||||
: m_message(msg), m_part(part), m_encoding(encoding)
|
||||
{
|
||||
}
|
||||
@ -49,7 +49,7 @@ ref <contentHandler> IMAPMessagePartContentHandler::clone() const
|
||||
{
|
||||
return create <IMAPMessagePartContentHandler>
|
||||
(m_message.acquire().constCast <IMAPMessage>(),
|
||||
m_part.acquire().constCast <part>(),
|
||||
m_part.acquire().constCast <messagePart>(),
|
||||
m_encoding);
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ void IMAPMessagePartContentHandler::generate
|
||||
(utility::outputStream& os, const vmime::encoding& enc, const string::size_type maxLineLength) const
|
||||
{
|
||||
ref <IMAPMessage> msg = m_message.acquire().constCast <IMAPMessage>();
|
||||
ref <part> part = m_part.acquire().constCast <class part>();
|
||||
ref <messagePart> part = m_part.acquire().constCast <messagePart>();
|
||||
|
||||
// Data is already encoded
|
||||
if (isEncoded())
|
||||
@ -125,7 +125,7 @@ void IMAPMessagePartContentHandler::extract
|
||||
(utility::outputStream& os, utility::progressListener* progress) const
|
||||
{
|
||||
ref <IMAPMessage> msg = m_message.acquire().constCast <IMAPMessage>();
|
||||
ref <part> part = m_part.acquire().constCast <class part>();
|
||||
ref <messagePart> part = m_part.acquire().constCast <messagePart>();
|
||||
|
||||
// No decoding to perform
|
||||
if (!isEncoded())
|
||||
@ -155,7 +155,7 @@ void IMAPMessagePartContentHandler::extractRaw
|
||||
(utility::outputStream& os, utility::progressListener* progress) const
|
||||
{
|
||||
ref <IMAPMessage> msg = m_message.acquire().constCast <IMAPMessage>();
|
||||
ref <part> part = m_part.acquire().constCast <class part>();
|
||||
ref <messagePart> part = m_part.acquire().constCast <messagePart>();
|
||||
|
||||
msg->extractPart(part, os, progress);
|
||||
}
|
||||
|
@ -27,8 +27,8 @@
|
||||
#if VMIME_HAVE_MESSAGING_FEATURES && VMIME_HAVE_MESSAGING_PROTO_IMAP
|
||||
|
||||
|
||||
#include "vmime/net/imap/IMAPStructure.hpp"
|
||||
#include "vmime/net/imap/IMAPPart.hpp"
|
||||
#include "vmime/net/imap/IMAPMessageStructure.hpp"
|
||||
#include "vmime/net/imap/IMAPMessagePart.hpp"
|
||||
|
||||
|
||||
namespace vmime {
|
||||
@ -36,51 +36,51 @@ namespace net {
|
||||
namespace imap {
|
||||
|
||||
|
||||
IMAPStructure::IMAPStructure()
|
||||
IMAPMessageStructure::IMAPMessageStructure()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
IMAPStructure::IMAPStructure(const IMAPParser::body* body)
|
||||
IMAPMessageStructure::IMAPMessageStructure(const IMAPParser::body* body)
|
||||
{
|
||||
m_parts.push_back(IMAPPart::create(NULL, 0, body));
|
||||
m_parts.push_back(IMAPMessagePart::create(NULL, 0, body));
|
||||
}
|
||||
|
||||
|
||||
IMAPStructure::IMAPStructure(ref <IMAPPart> parent, const std::vector <IMAPParser::body*>& list)
|
||||
IMAPMessageStructure::IMAPMessageStructure(ref <IMAPMessagePart> parent, const std::vector <IMAPParser::body*>& list)
|
||||
{
|
||||
int number = 0;
|
||||
|
||||
for (std::vector <IMAPParser::body*>::const_iterator
|
||||
it = list.begin() ; it != list.end() ; ++it, ++number)
|
||||
{
|
||||
m_parts.push_back(IMAPPart::create(parent, number, *it));
|
||||
m_parts.push_back(IMAPMessagePart::create(parent, number, *it));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ref <const part> IMAPStructure::getPartAt(const size_t x) const
|
||||
ref <const messagePart> IMAPMessageStructure::getPartAt(const size_t x) const
|
||||
{
|
||||
return m_parts[x];
|
||||
}
|
||||
|
||||
|
||||
ref <part> IMAPStructure::getPartAt(const size_t x)
|
||||
ref <messagePart> IMAPMessageStructure::getPartAt(const size_t x)
|
||||
{
|
||||
return m_parts[x];
|
||||
}
|
||||
|
||||
|
||||
size_t IMAPStructure::getPartCount() const
|
||||
size_t IMAPMessageStructure::getPartCount() const
|
||||
{
|
||||
return m_parts.size();
|
||||
}
|
||||
|
||||
|
||||
// static
|
||||
ref <IMAPStructure> IMAPStructure::emptyStructure()
|
||||
ref <IMAPMessageStructure> IMAPMessageStructure::emptyStructure()
|
||||
{
|
||||
static ref <IMAPStructure> emptyStructure = vmime::create <IMAPStructure>();
|
||||
static ref <IMAPMessageStructure> emptyStructure = vmime::create <IMAPMessageStructure>();
|
||||
return emptyStructure;
|
||||
}
|
||||
|
@ -28,6 +28,8 @@
|
||||
|
||||
|
||||
#include "vmime/net/maildir/maildirMessage.hpp"
|
||||
#include "vmime/net/maildir/maildirMessagePart.hpp"
|
||||
#include "vmime/net/maildir/maildirMessageStructure.hpp"
|
||||
#include "vmime/net/maildir/maildirFolder.hpp"
|
||||
#include "vmime/net/maildir/maildirUtils.hpp"
|
||||
#include "vmime/net/maildir/maildirStore.hpp"
|
||||
@ -45,193 +47,6 @@ namespace net {
|
||||
namespace maildir {
|
||||
|
||||
|
||||
//
|
||||
// maildirPart
|
||||
//
|
||||
|
||||
class maildirStructure;
|
||||
|
||||
class maildirPart : public part
|
||||
{
|
||||
public:
|
||||
|
||||
maildirPart(ref <maildirPart> parent, const int number, const bodyPart& part);
|
||||
~maildirPart();
|
||||
|
||||
|
||||
ref <const structure> getStructure() const;
|
||||
ref <structure> getStructure();
|
||||
|
||||
weak_ref <const maildirPart> getParent() const { return (m_parent); }
|
||||
|
||||
const mediaType& getType() const { return (m_mediaType); }
|
||||
int getSize() const { return (m_size); }
|
||||
int getNumber() const { return (m_number); }
|
||||
|
||||
ref <const header> getHeader() const
|
||||
{
|
||||
if (m_header == NULL)
|
||||
throw exceptions::unfetched_object();
|
||||
else
|
||||
return m_header;
|
||||
}
|
||||
|
||||
header& getOrCreateHeader()
|
||||
{
|
||||
if (m_header != NULL)
|
||||
return (*m_header);
|
||||
else
|
||||
return (*(m_header = vmime::create <header>()));
|
||||
}
|
||||
|
||||
int getHeaderParsedOffset() const { return (m_headerParsedOffset); }
|
||||
int getHeaderParsedLength() const { return (m_headerParsedLength); }
|
||||
|
||||
int getBodyParsedOffset() const { return (m_bodyParsedOffset); }
|
||||
int getBodyParsedLength() const { return (m_bodyParsedLength); }
|
||||
|
||||
void initStructure(const bodyPart& part);
|
||||
|
||||
private:
|
||||
|
||||
ref <maildirStructure> m_structure;
|
||||
weak_ref <maildirPart> m_parent;
|
||||
ref <header> m_header;
|
||||
|
||||
int m_number;
|
||||
int m_size;
|
||||
mediaType m_mediaType;
|
||||
|
||||
int m_headerParsedOffset;
|
||||
int m_headerParsedLength;
|
||||
|
||||
int m_bodyParsedOffset;
|
||||
int m_bodyParsedLength;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//
|
||||
// maildirStructure
|
||||
//
|
||||
|
||||
class maildirStructure : public structure
|
||||
{
|
||||
public:
|
||||
|
||||
maildirStructure()
|
||||
{
|
||||
}
|
||||
|
||||
maildirStructure(ref <maildirPart> parent, const bodyPart& part)
|
||||
{
|
||||
vmime::ref <maildirPart> mpart = vmime::create <maildirPart>(parent, 0, part);
|
||||
mpart->initStructure(part);
|
||||
|
||||
m_parts.push_back(mpart);
|
||||
}
|
||||
|
||||
maildirStructure(ref <maildirPart> parent, const std::vector <ref <const vmime::bodyPart> >& list)
|
||||
{
|
||||
for (unsigned int i = 0 ; i < list.size() ; ++i)
|
||||
{
|
||||
vmime::ref <maildirPart> mpart = vmime::create <maildirPart>(parent, i, *list[i]);
|
||||
mpart->initStructure(*list[i]);
|
||||
|
||||
m_parts.push_back(mpart);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ref <const part> getPartAt(const size_t x) const
|
||||
{
|
||||
return m_parts[x];
|
||||
}
|
||||
|
||||
ref <part> getPartAt(const size_t x)
|
||||
{
|
||||
return m_parts[x];
|
||||
}
|
||||
|
||||
size_t getPartCount() const
|
||||
{
|
||||
return m_parts.size();
|
||||
}
|
||||
|
||||
|
||||
static ref <maildirStructure> emptyStructure()
|
||||
{
|
||||
return m_emptyStructure;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
static ref <maildirStructure> m_emptyStructure;
|
||||
|
||||
std::vector <ref <maildirPart> > m_parts;
|
||||
};
|
||||
|
||||
|
||||
ref <maildirStructure> maildirStructure::m_emptyStructure = vmime::create <maildirStructure>();
|
||||
|
||||
|
||||
|
||||
maildirPart::maildirPart(ref <maildirPart> parent, const int number, const bodyPart& part)
|
||||
: m_parent(parent), m_header(NULL), m_number(number)
|
||||
{
|
||||
m_headerParsedOffset = part.getHeader()->getParsedOffset();
|
||||
m_headerParsedLength = part.getHeader()->getParsedLength();
|
||||
|
||||
m_bodyParsedOffset = part.getBody()->getParsedOffset();
|
||||
m_bodyParsedLength = part.getBody()->getParsedLength();
|
||||
|
||||
m_size = part.getBody()->getContents()->getLength();
|
||||
|
||||
m_mediaType = part.getBody()->getContentType();
|
||||
}
|
||||
|
||||
|
||||
maildirPart::~maildirPart()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void maildirPart::initStructure(const bodyPart& part)
|
||||
{
|
||||
if (part.getBody()->getPartList().size() == 0)
|
||||
m_structure = NULL;
|
||||
else
|
||||
{
|
||||
m_structure = vmime::create <maildirStructure>
|
||||
(thisRef().dynamicCast <maildirPart>(),
|
||||
part.getBody()->getPartList());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ref <const structure> maildirPart::getStructure() const
|
||||
{
|
||||
if (m_structure != NULL)
|
||||
return m_structure;
|
||||
else
|
||||
return maildirStructure::emptyStructure();
|
||||
}
|
||||
|
||||
|
||||
ref <structure> maildirPart::getStructure()
|
||||
{
|
||||
if (m_structure != NULL)
|
||||
return m_structure;
|
||||
else
|
||||
return maildirStructure::emptyStructure();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// maildirMessage
|
||||
//
|
||||
|
||||
maildirMessage::maildirMessage(ref <maildirFolder> folder, const int num)
|
||||
: m_folder(folder), m_num(num), m_size(-1), m_flags(FLAG_UNDEFINED),
|
||||
m_expunged(false), m_structure(NULL)
|
||||
@ -282,7 +97,7 @@ bool maildirMessage::isExpunged() const
|
||||
}
|
||||
|
||||
|
||||
ref <const structure> maildirMessage::getStructure() const
|
||||
ref <const messageStructure> maildirMessage::getStructure() const
|
||||
{
|
||||
if (m_structure == NULL)
|
||||
throw exceptions::unfetched_object();
|
||||
@ -291,7 +106,7 @@ ref <const structure> maildirMessage::getStructure() const
|
||||
}
|
||||
|
||||
|
||||
ref <structure> maildirMessage::getStructure()
|
||||
ref <messageStructure> maildirMessage::getStructure()
|
||||
{
|
||||
if (m_structure == NULL)
|
||||
throw exceptions::unfetched_object();
|
||||
@ -337,11 +152,11 @@ void maildirMessage::extract(utility::outputStream& os,
|
||||
}
|
||||
|
||||
|
||||
void maildirMessage::extractPart(ref <const part> p, utility::outputStream& os,
|
||||
void maildirMessage::extractPart(ref <const messagePart> p, utility::outputStream& os,
|
||||
utility::progressListener* progress, const int start,
|
||||
const int length, const bool peek) const
|
||||
{
|
||||
ref <const maildirPart> mp = p.dynamicCast <const maildirPart>();
|
||||
ref <const maildirMessagePart> mp = p.dynamicCast <const maildirMessagePart>();
|
||||
|
||||
extractImpl(os, progress, mp->getBodyParsedOffset(), mp->getBodyParsedLength(),
|
||||
start, length, peek);
|
||||
@ -395,11 +210,11 @@ void maildirMessage::extractImpl(utility::outputStream& os, utility::progressLis
|
||||
}
|
||||
|
||||
|
||||
void maildirMessage::fetchPartHeader(ref <part> p)
|
||||
void maildirMessage::fetchPartHeader(ref <messagePart> p)
|
||||
{
|
||||
ref <maildirFolder> folder = m_folder.acquire();
|
||||
|
||||
ref <maildirPart> mp = p.dynamicCast <maildirPart>();
|
||||
ref <maildirMessagePart> mp = p.dynamicCast <maildirMessagePart>();
|
||||
|
||||
ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
|
||||
@ -508,7 +323,7 @@ void maildirMessage::fetch(ref <maildirFolder> msgFolder, const int options)
|
||||
// Extract structure
|
||||
if (options & folder::FETCH_STRUCTURE)
|
||||
{
|
||||
m_structure = vmime::create <maildirStructure>(null, msg);
|
||||
m_structure = vmime::create <maildirMessageStructure>(null, msg);
|
||||
}
|
||||
|
||||
// Extract some header fields or whole header
|
||||
|
155
src/net/maildir/maildirMessagePart.cpp
Normal file
155
src/net/maildir/maildirMessagePart.cpp
Normal file
@ -0,0 +1,155 @@
|
||||
//
|
||||
// VMime library (http://www.vmime.org)
|
||||
// Copyright (C) 2002-2013 Vincent Richard <vincent@vmime.org>
|
||||
//
|
||||
// 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 3 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.,
|
||||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is making
|
||||
// a combined work based on this library. Thus, the terms and conditions of
|
||||
// the GNU General Public License cover the whole combination.
|
||||
//
|
||||
|
||||
#include "vmime/config.hpp"
|
||||
|
||||
|
||||
#if VMIME_HAVE_MESSAGING_FEATURES && VMIME_HAVE_MESSAGING_PROTO_MAILDIR
|
||||
|
||||
|
||||
#include "vmime/net/maildir/maildirMessagePart.hpp"
|
||||
#include "vmime/net/maildir/maildirMessageStructure.hpp"
|
||||
|
||||
|
||||
namespace vmime {
|
||||
namespace net {
|
||||
namespace maildir {
|
||||
|
||||
|
||||
maildirMessagePart::maildirMessagePart(ref <maildirMessagePart> parent, const int number, const bodyPart& part)
|
||||
: m_parent(parent), m_header(NULL), m_number(number)
|
||||
{
|
||||
m_headerParsedOffset = part.getHeader()->getParsedOffset();
|
||||
m_headerParsedLength = part.getHeader()->getParsedLength();
|
||||
|
||||
m_bodyParsedOffset = part.getBody()->getParsedOffset();
|
||||
m_bodyParsedLength = part.getBody()->getParsedLength();
|
||||
|
||||
m_size = part.getBody()->getContents()->getLength();
|
||||
|
||||
m_mediaType = part.getBody()->getContentType();
|
||||
}
|
||||
|
||||
|
||||
maildirMessagePart::~maildirMessagePart()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void maildirMessagePart::initStructure(const bodyPart& part)
|
||||
{
|
||||
if (part.getBody()->getPartList().size() == 0)
|
||||
m_structure = NULL;
|
||||
else
|
||||
{
|
||||
m_structure = vmime::create <maildirMessageStructure>
|
||||
(thisRef().dynamicCast <maildirMessagePart>(),
|
||||
part.getBody()->getPartList());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ref <const messageStructure> maildirMessagePart::getStructure() const
|
||||
{
|
||||
if (m_structure != NULL)
|
||||
return m_structure;
|
||||
else
|
||||
return maildirMessageStructure::emptyStructure();
|
||||
}
|
||||
|
||||
|
||||
ref <messageStructure> maildirMessagePart::getStructure()
|
||||
{
|
||||
if (m_structure != NULL)
|
||||
return m_structure;
|
||||
else
|
||||
return maildirMessageStructure::emptyStructure();
|
||||
}
|
||||
|
||||
|
||||
const mediaType& maildirMessagePart::getType() const
|
||||
{
|
||||
return m_mediaType;
|
||||
}
|
||||
|
||||
|
||||
int maildirMessagePart::getSize() const
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
|
||||
|
||||
int maildirMessagePart::getNumber() const
|
||||
{
|
||||
return m_number;
|
||||
}
|
||||
|
||||
|
||||
ref <const header> maildirMessagePart::getHeader() const
|
||||
{
|
||||
if (m_header == NULL)
|
||||
throw exceptions::unfetched_object();
|
||||
else
|
||||
return m_header;
|
||||
}
|
||||
|
||||
|
||||
header& maildirMessagePart::getOrCreateHeader()
|
||||
{
|
||||
if (m_header != NULL)
|
||||
return *m_header;
|
||||
else
|
||||
return *(m_header = vmime::create <header>());
|
||||
}
|
||||
|
||||
|
||||
int maildirMessagePart::getHeaderParsedOffset() const
|
||||
{
|
||||
return m_headerParsedOffset;
|
||||
}
|
||||
|
||||
|
||||
int maildirMessagePart::getHeaderParsedLength() const
|
||||
{
|
||||
return m_headerParsedLength;
|
||||
}
|
||||
|
||||
|
||||
int maildirMessagePart::getBodyParsedOffset() const
|
||||
{
|
||||
return m_bodyParsedOffset;
|
||||
}
|
||||
|
||||
|
||||
int maildirMessagePart::getBodyParsedLength() const
|
||||
{
|
||||
return m_bodyParsedLength;
|
||||
}
|
||||
|
||||
|
||||
} // maildir
|
||||
} // net
|
||||
} // vmime
|
||||
|
||||
|
||||
#endif // VMIME_HAVE_MESSAGING_FEATURES && VMIME_HAVE_MESSAGING_PROTO_MAILDIR
|
98
src/net/maildir/maildirMessageStructure.cpp
Normal file
98
src/net/maildir/maildirMessageStructure.cpp
Normal file
@ -0,0 +1,98 @@
|
||||
//
|
||||
// VMime library (http://www.vmime.org)
|
||||
// Copyright (C) 2002-2013 Vincent Richard <vincent@vmime.org>
|
||||
//
|
||||
// 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 3 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.,
|
||||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is making
|
||||
// a combined work based on this library. Thus, the terms and conditions of
|
||||
// the GNU General Public License cover the whole combination.
|
||||
//
|
||||
|
||||
#include "vmime/config.hpp"
|
||||
|
||||
|
||||
#if VMIME_HAVE_MESSAGING_FEATURES && VMIME_HAVE_MESSAGING_PROTO_MAILDIR
|
||||
|
||||
|
||||
#include "vmime/net/maildir/maildirMessageStructure.hpp"
|
||||
#include "vmime/net/maildir/maildirMessagePart.hpp"
|
||||
|
||||
|
||||
namespace vmime {
|
||||
namespace net {
|
||||
namespace maildir {
|
||||
|
||||
|
||||
ref <maildirMessageStructure> maildirMessageStructure::m_emptyStructure = vmime::create <maildirMessageStructure>();
|
||||
|
||||
|
||||
maildirMessageStructure::maildirMessageStructure()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
maildirMessageStructure::maildirMessageStructure(ref <maildirMessagePart> parent, const bodyPart& part)
|
||||
{
|
||||
vmime::ref <maildirMessagePart> mpart = vmime::create <maildirMessagePart>(parent, 0, part);
|
||||
mpart->initStructure(part);
|
||||
|
||||
m_parts.push_back(mpart);
|
||||
}
|
||||
|
||||
|
||||
maildirMessageStructure::maildirMessageStructure(ref <maildirMessagePart> parent, const std::vector <ref <const vmime::bodyPart> >& list)
|
||||
{
|
||||
for (unsigned int i = 0 ; i < list.size() ; ++i)
|
||||
{
|
||||
vmime::ref <maildirMessagePart> mpart = vmime::create <maildirMessagePart>(parent, i, *list[i]);
|
||||
mpart->initStructure(*list[i]);
|
||||
|
||||
m_parts.push_back(mpart);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ref <const messagePart> maildirMessageStructure::getPartAt(const size_t x) const
|
||||
{
|
||||
return m_parts[x];
|
||||
}
|
||||
|
||||
|
||||
ref <messagePart> maildirMessageStructure::getPartAt(const size_t x)
|
||||
{
|
||||
return m_parts[x];
|
||||
}
|
||||
|
||||
|
||||
size_t maildirMessageStructure::getPartCount() const
|
||||
{
|
||||
return m_parts.size();
|
||||
}
|
||||
|
||||
|
||||
// static
|
||||
ref <maildirMessageStructure> maildirMessageStructure::emptyStructure()
|
||||
{
|
||||
return m_emptyStructure;
|
||||
}
|
||||
|
||||
|
||||
} // maildir
|
||||
} // net
|
||||
} // vmime
|
||||
|
||||
|
||||
#endif // VMIME_HAVE_MESSAGING_FEATURES && VMIME_HAVE_MESSAGING_PROTO_MAILDIR
|
@ -34,19 +34,19 @@ namespace vmime {
|
||||
namespace net {
|
||||
|
||||
|
||||
ref <const part> part::getPartAt(const size_t pos) const
|
||||
ref <const messagePart> messagePart::getPartAt(const size_t pos) const
|
||||
{
|
||||
return getStructure()->getPartAt(pos);
|
||||
}
|
||||
|
||||
|
||||
ref <part> part::getPartAt(const size_t pos)
|
||||
ref <messagePart> messagePart::getPartAt(const size_t pos)
|
||||
{
|
||||
return getStructure()->getPartAt(pos);
|
||||
}
|
||||
|
||||
|
||||
size_t part::getPartCount() const
|
||||
size_t messagePart::getPartCount() const
|
||||
{
|
||||
return getStructure()->getPartCount();
|
||||
}
|
||||
|
@ -104,13 +104,13 @@ int POP3Message::getFlags() const
|
||||
}
|
||||
|
||||
|
||||
ref <const structure> POP3Message::getStructure() const
|
||||
ref <const messageStructure> POP3Message::getStructure() const
|
||||
{
|
||||
throw exceptions::operation_not_supported();
|
||||
}
|
||||
|
||||
|
||||
ref <structure> POP3Message::getStructure()
|
||||
ref <messageStructure> POP3Message::getStructure()
|
||||
{
|
||||
throw exceptions::operation_not_supported();
|
||||
}
|
||||
@ -157,7 +157,7 @@ void POP3Message::extract(utility::outputStream& os,
|
||||
|
||||
|
||||
void POP3Message::extractPart
|
||||
(ref <const part> /* p */, utility::outputStream& /* os */,
|
||||
(ref <const messagePart> /* p */, utility::outputStream& /* os */,
|
||||
utility::progressListener* /* progress */,
|
||||
const int /* start */, const int /* length */,
|
||||
const bool /* peek */) const
|
||||
@ -166,7 +166,7 @@ void POP3Message::extractPart
|
||||
}
|
||||
|
||||
|
||||
void POP3Message::fetchPartHeader(ref <part> /* p */)
|
||||
void POP3Message::fetchPartHeader(ref <messagePart> /* p */)
|
||||
{
|
||||
throw exceptions::operation_not_supported();
|
||||
}
|
||||
|
@ -84,8 +84,8 @@ public:
|
||||
|
||||
bool isExpunged() const;
|
||||
|
||||
ref <const structure> getStructure() const;
|
||||
ref <structure> getStructure();
|
||||
ref <const messageStructure> getStructure() const;
|
||||
ref <messageStructure> getStructure();
|
||||
|
||||
ref <const header> getHeader() const;
|
||||
|
||||
@ -93,9 +93,9 @@ public:
|
||||
void setFlags(const int flags, const int mode = FLAG_MODE_SET);
|
||||
|
||||
void extract(utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const;
|
||||
void extractPart(ref <const part> p, utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const;
|
||||
void extractPart(ref <const messagePart> p, utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const;
|
||||
|
||||
void fetchPartHeader(ref <part> p);
|
||||
void fetchPartHeader(ref <messagePart> p);
|
||||
|
||||
ref <vmime::message> getParsedMessage();
|
||||
|
||||
@ -107,7 +107,7 @@ private:
|
||||
*
|
||||
* @param str structure for which to fetch parts headers
|
||||
*/
|
||||
void fetchPartHeaderForStructure(ref <structure> str);
|
||||
void fetchPartHeaderForStructure(ref <messageStructure> str);
|
||||
|
||||
/** Recursively contruct parsed message from structure.
|
||||
* Called by getParsedMessage().
|
||||
@ -116,7 +116,7 @@ private:
|
||||
* @param str structure for which to construct part
|
||||
* @param level current nesting level (0 is root)
|
||||
*/
|
||||
void constructParsedMessage(ref <bodyPart> parentPart, ref <structure> str, int level = 0);
|
||||
void constructParsedMessage(ref <bodyPart> parentPart, ref <messageStructure> str, int level = 0);
|
||||
|
||||
|
||||
enum ExtractFlags
|
||||
@ -126,7 +126,7 @@ private:
|
||||
EXTRACT_PEEK = 0x10
|
||||
};
|
||||
|
||||
void extractImpl(ref <const part> p, utility::outputStream& os, utility::progressListener* progress,
|
||||
void extractImpl(ref <const messagePart> p, utility::outputStream& os, utility::progressListener* progress,
|
||||
const int start, const int length, const int extractFlags) const;
|
||||
|
||||
|
||||
@ -145,7 +145,7 @@ private:
|
||||
vmime_uint64 m_modseq;
|
||||
|
||||
ref <header> m_header;
|
||||
ref <structure> m_structure;
|
||||
ref <messageStructure> m_structure;
|
||||
};
|
||||
|
||||
|
||||
|
@ -21,8 +21,8 @@
|
||||
// the GNU General Public License cover the whole combination.
|
||||
//
|
||||
|
||||
#ifndef VMIME_NET_IMAP_IMAPPART_HPP_INCLUDED
|
||||
#define VMIME_NET_IMAP_IMAPPART_HPP_INCLUDED
|
||||
#ifndef VMIME_NET_IMAP_IMAPMESSAGEPART_HPP_INCLUDED
|
||||
#define VMIME_NET_IMAP_IMAPMESSAGEPART_HPP_INCLUDED
|
||||
|
||||
|
||||
#include "vmime/config.hpp"
|
||||
@ -41,24 +41,24 @@ namespace net {
|
||||
namespace imap {
|
||||
|
||||
|
||||
class IMAPStructure;
|
||||
class IMAPMessageStructure;
|
||||
|
||||
|
||||
class VMIME_EXPORT IMAPPart : public part
|
||||
class VMIME_EXPORT IMAPMessagePart : public messagePart
|
||||
{
|
||||
private:
|
||||
|
||||
friend class vmime::creator;
|
||||
|
||||
IMAPPart(ref <IMAPPart> parent, const int number, const IMAPParser::body_type_mpart* mpart);
|
||||
IMAPPart(ref <IMAPPart> parent, const int number, const IMAPParser::body_type_1part* part);
|
||||
IMAPMessagePart(ref <IMAPMessagePart> parent, const int number, const IMAPParser::body_type_mpart* mpart);
|
||||
IMAPMessagePart(ref <IMAPMessagePart> parent, const int number, const IMAPParser::body_type_1part* part);
|
||||
|
||||
public:
|
||||
|
||||
ref <const structure> getStructure() const;
|
||||
ref <structure> getStructure();
|
||||
ref <const messageStructure> getStructure() const;
|
||||
ref <messageStructure> getStructure();
|
||||
|
||||
ref <const IMAPPart> getParent() const;
|
||||
ref <const IMAPMessagePart> getParent() const;
|
||||
|
||||
const mediaType& getType() const;
|
||||
int getSize() const;
|
||||
@ -67,16 +67,16 @@ public:
|
||||
ref <const header> getHeader() const;
|
||||
|
||||
|
||||
static ref <IMAPPart> create
|
||||
(ref <IMAPPart> parent, const int number, const IMAPParser::body* body);
|
||||
static ref <IMAPMessagePart> create
|
||||
(ref <IMAPMessagePart> parent, const int number, const IMAPParser::body* body);
|
||||
|
||||
|
||||
header& getOrCreateHeader();
|
||||
|
||||
private:
|
||||
|
||||
ref <IMAPStructure> m_structure;
|
||||
weak_ref <IMAPPart> m_parent;
|
||||
ref <IMAPMessageStructure> m_structure;
|
||||
weak_ref <IMAPMessagePart> m_parent;
|
||||
ref <header> m_header;
|
||||
|
||||
int m_number;
|
||||
@ -92,5 +92,5 @@ private:
|
||||
|
||||
#endif // VMIME_HAVE_MESSAGING_FEATURES && VMIME_HAVE_MESSAGING_PROTO_IMAP
|
||||
|
||||
#endif // VMIME_NET_IMAP_IMAPPART_HPP_INCLUDED
|
||||
#endif // VMIME_NET_IMAP_IMAPMESSAGEPART_HPP_INCLUDED
|
||||
|
@ -44,7 +44,7 @@ class VMIME_EXPORT IMAPMessagePartContentHandler : public contentHandler
|
||||
{
|
||||
public:
|
||||
|
||||
IMAPMessagePartContentHandler(ref <IMAPMessage> msg, ref <class part> part, const vmime::encoding& encoding);
|
||||
IMAPMessagePartContentHandler(ref <IMAPMessage> msg, ref <messagePart> part, const vmime::encoding& encoding);
|
||||
|
||||
ref <contentHandler> clone() const;
|
||||
|
||||
@ -69,7 +69,7 @@ public:
|
||||
private:
|
||||
|
||||
weak_ref <IMAPMessage> m_message;
|
||||
weak_ref <part> m_part;
|
||||
weak_ref <messagePart> m_part;
|
||||
|
||||
vmime::encoding m_encoding;
|
||||
vmime::mediaType m_contentType;
|
||||
|
@ -21,8 +21,8 @@
|
||||
// the GNU General Public License cover the whole combination.
|
||||
//
|
||||
|
||||
#ifndef VMIME_NET_IMAP_IMAPSTRUCTURE_HPP_INCLUDED
|
||||
#define VMIME_NET_IMAP_IMAPSTRUCTURE_HPP_INCLUDED
|
||||
#ifndef VMIME_NET_IMAP_IMAPMESSAGESTRUCTURE_HPP_INCLUDED
|
||||
#define VMIME_NET_IMAP_IMAPMESSAGESTRUCTURE_HPP_INCLUDED
|
||||
|
||||
|
||||
#include "vmime/config.hpp"
|
||||
@ -41,26 +41,26 @@ namespace net {
|
||||
namespace imap {
|
||||
|
||||
|
||||
class IMAPPart;
|
||||
class IMAPMessagePart;
|
||||
|
||||
|
||||
class VMIME_EXPORT IMAPStructure : public structure
|
||||
class VMIME_EXPORT IMAPMessageStructure : public messageStructure
|
||||
{
|
||||
public:
|
||||
|
||||
IMAPStructure();
|
||||
IMAPStructure(const IMAPParser::body* body);
|
||||
IMAPStructure(ref <IMAPPart> parent, const std::vector <IMAPParser::body*>& list);
|
||||
IMAPMessageStructure();
|
||||
IMAPMessageStructure(const IMAPParser::body* body);
|
||||
IMAPMessageStructure(ref <IMAPMessagePart> parent, const std::vector <IMAPParser::body*>& list);
|
||||
|
||||
ref <const part> getPartAt(const size_t x) const;
|
||||
ref <part> getPartAt(const size_t x);
|
||||
ref <const messagePart> getPartAt(const size_t x) const;
|
||||
ref <messagePart> getPartAt(const size_t x);
|
||||
size_t getPartCount() const;
|
||||
|
||||
static ref <IMAPStructure> emptyStructure();
|
||||
static ref <IMAPMessageStructure> emptyStructure();
|
||||
|
||||
private:
|
||||
|
||||
std::vector <ref <IMAPPart> > m_parts;
|
||||
std::vector <ref <IMAPMessagePart> > m_parts;
|
||||
};
|
||||
|
||||
|
||||
@ -71,5 +71,5 @@ private:
|
||||
|
||||
#endif // VMIME_HAVE_MESSAGING_FEATURES && VMIME_HAVE_MESSAGING_PROTO_IMAP
|
||||
|
||||
#endif // VMIME_NET_IMAP_IMAPSTRUCTURE_HPP_INCLUDED
|
||||
#endif // VMIME_NET_IMAP_IMAPMESSAGESTRUCTURE_HPP_INCLUDED
|
||||
|
@ -68,8 +68,8 @@ public:
|
||||
|
||||
bool isExpunged() const;
|
||||
|
||||
ref <const structure> getStructure() const;
|
||||
ref <structure> getStructure();
|
||||
ref <const messageStructure> getStructure() const;
|
||||
ref <messageStructure> getStructure();
|
||||
|
||||
ref <const header> getHeader() const;
|
||||
|
||||
@ -77,9 +77,9 @@ public:
|
||||
void setFlags(const int flags, const int mode = FLAG_MODE_SET);
|
||||
|
||||
void extract(utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const;
|
||||
void extractPart(ref <const part> p, utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const;
|
||||
void extractPart(ref <const messagePart> p, utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const;
|
||||
|
||||
void fetchPartHeader(ref <part> p);
|
||||
void fetchPartHeader(ref <messagePart> p);
|
||||
|
||||
ref <vmime::message> getParsedMessage();
|
||||
|
||||
@ -103,7 +103,7 @@ private:
|
||||
uid m_uid;
|
||||
|
||||
ref <header> m_header;
|
||||
ref <structure> m_structure;
|
||||
ref <messageStructure> m_structure;
|
||||
};
|
||||
|
||||
|
||||
|
99
vmime/net/maildir/maildirMessagePart.hpp
Normal file
99
vmime/net/maildir/maildirMessagePart.hpp
Normal file
@ -0,0 +1,99 @@
|
||||
//
|
||||
// VMime library (http://www.vmime.org)
|
||||
// Copyright (C) 2002-2013 Vincent Richard <vincent@vmime.org>
|
||||
//
|
||||
// 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 3 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.,
|
||||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is making
|
||||
// a combined work based on this library. Thus, the terms and conditions of
|
||||
// the GNU General Public License cover the whole combination.
|
||||
//
|
||||
|
||||
#ifndef VMIME_NET_MAILDIR_MAILDIRMESSAGEPART_HPP_INCLUDED
|
||||
#define VMIME_NET_MAILDIR_MAILDIRMESSAGEPART_HPP_INCLUDED
|
||||
|
||||
|
||||
#include "vmime/config.hpp"
|
||||
|
||||
|
||||
#if VMIME_HAVE_MESSAGING_FEATURES && VMIME_HAVE_MESSAGING_PROTO_MAILDIR
|
||||
|
||||
|
||||
#include "vmime/net/message.hpp"
|
||||
|
||||
|
||||
namespace vmime {
|
||||
namespace net {
|
||||
namespace maildir {
|
||||
|
||||
|
||||
class maildirMessageStructure;
|
||||
|
||||
|
||||
class maildirMessagePart : public messagePart
|
||||
{
|
||||
public:
|
||||
|
||||
maildirMessagePart(ref <maildirMessagePart> parent, const int number, const bodyPart& part);
|
||||
~maildirMessagePart();
|
||||
|
||||
|
||||
ref <const messageStructure> getStructure() const;
|
||||
ref <messageStructure> getStructure();
|
||||
|
||||
weak_ref <const maildirMessagePart> getParent() const { return (m_parent); }
|
||||
|
||||
const mediaType& getType() const;
|
||||
int getSize() const;
|
||||
int getNumber() const;
|
||||
|
||||
ref <const header> getHeader() const;
|
||||
|
||||
header& getOrCreateHeader();
|
||||
|
||||
int getHeaderParsedOffset() const;
|
||||
int getHeaderParsedLength() const;
|
||||
|
||||
int getBodyParsedOffset() const;
|
||||
int getBodyParsedLength() const;
|
||||
|
||||
void initStructure(const bodyPart& part);
|
||||
|
||||
private:
|
||||
|
||||
ref <maildirMessageStructure> m_structure;
|
||||
weak_ref <maildirMessagePart> m_parent;
|
||||
ref <header> m_header;
|
||||
|
||||
int m_number;
|
||||
int m_size;
|
||||
mediaType m_mediaType;
|
||||
|
||||
int m_headerParsedOffset;
|
||||
int m_headerParsedLength;
|
||||
|
||||
int m_bodyParsedOffset;
|
||||
int m_bodyParsedLength;
|
||||
};
|
||||
|
||||
|
||||
} // maildir
|
||||
} // net
|
||||
} // vmime
|
||||
|
||||
|
||||
#endif // VMIME_HAVE_MESSAGING_FEATURES && VMIME_HAVE_MESSAGING_PROTO_MAILDIR
|
||||
|
||||
#endif // VMIME_NET_MAILDIR_MAILDIRMESSAGEPART_HPP_INCLUDED
|
76
vmime/net/maildir/maildirMessageStructure.hpp
Normal file
76
vmime/net/maildir/maildirMessageStructure.hpp
Normal file
@ -0,0 +1,76 @@
|
||||
//
|
||||
// VMime library (http://www.vmime.org)
|
||||
// Copyright (C) 2002-2013 Vincent Richard <vincent@vmime.org>
|
||||
//
|
||||
// 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 3 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.,
|
||||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is making
|
||||
// a combined work based on this library. Thus, the terms and conditions of
|
||||
// the GNU General Public License cover the whole combination.
|
||||
//
|
||||
|
||||
#ifndef VMIME_NET_MAILDIR_MAILDIRMESSAGESTRUCTURE_HPP_INCLUDED
|
||||
#define VMIME_NET_MAILDIR_MAILDIRMESSAGESTRUCTURE_HPP_INCLUDED
|
||||
|
||||
|
||||
#include "vmime/config.hpp"
|
||||
|
||||
|
||||
#if VMIME_HAVE_MESSAGING_FEATURES && VMIME_HAVE_MESSAGING_PROTO_MAILDIR
|
||||
|
||||
|
||||
#include "vmime/net/message.hpp"
|
||||
|
||||
|
||||
namespace vmime {
|
||||
namespace net {
|
||||
namespace maildir {
|
||||
|
||||
|
||||
class maildirMessagePart;
|
||||
|
||||
|
||||
class maildirMessageStructure : public messageStructure
|
||||
{
|
||||
public:
|
||||
|
||||
maildirMessageStructure();
|
||||
maildirMessageStructure(ref <maildirMessagePart> parent, const bodyPart& part);
|
||||
maildirMessageStructure(ref <maildirMessagePart> parent, const std::vector <ref <const vmime::bodyPart> >& list);
|
||||
|
||||
|
||||
ref <const messagePart> getPartAt(const size_t x) const;
|
||||
ref <messagePart> getPartAt(const size_t x);
|
||||
|
||||
size_t getPartCount() const;
|
||||
|
||||
static ref <maildirMessageStructure> emptyStructure();
|
||||
|
||||
private:
|
||||
|
||||
static ref <maildirMessageStructure> m_emptyStructure;
|
||||
|
||||
std::vector <ref <maildirMessagePart> > m_parts;
|
||||
};
|
||||
|
||||
|
||||
} // maildir
|
||||
} // net
|
||||
} // vmime
|
||||
|
||||
|
||||
#endif // VMIME_HAVE_MESSAGING_FEATURES && VMIME_HAVE_MESSAGING_PROTO_MAILDIR
|
||||
|
||||
#endif // VMIME_NET_MAILDIR_MAILDIRMESSAGESTRUCTURE_HPP_INCLUDED
|
@ -44,20 +44,20 @@ namespace vmime {
|
||||
namespace net {
|
||||
|
||||
|
||||
class structure;
|
||||
class messageStructure;
|
||||
|
||||
|
||||
/** A MIME part in a message.
|
||||
*/
|
||||
|
||||
class VMIME_EXPORT part : public object
|
||||
class VMIME_EXPORT messagePart : public object
|
||||
{
|
||||
protected:
|
||||
|
||||
part() { }
|
||||
part(const part&) : object() { }
|
||||
messagePart() { }
|
||||
messagePart(const messagePart&) : object() { }
|
||||
|
||||
virtual ~part() { }
|
||||
virtual ~messagePart() { }
|
||||
|
||||
public:
|
||||
|
||||
@ -65,13 +65,13 @@ public:
|
||||
*
|
||||
* @return structure of the part
|
||||
*/
|
||||
virtual ref <const structure> getStructure() const = 0;
|
||||
virtual ref <const messageStructure> getStructure() const = 0;
|
||||
|
||||
/** Return the structure of this part.
|
||||
*
|
||||
* @return structure of the part
|
||||
*/
|
||||
virtual ref <structure> getStructure() = 0;
|
||||
virtual ref <messageStructure> getStructure() = 0;
|
||||
|
||||
/** Return the header section for this part (you must fetch header
|
||||
* before using this function: see message::fetchPartHeader).
|
||||
@ -105,7 +105,7 @@ public:
|
||||
* @param pos index of the sub-part
|
||||
* @return sub-part at position 'pos'
|
||||
*/
|
||||
ref <const part> getPartAt(const size_t pos) const;
|
||||
ref <const messagePart> getPartAt(const size_t pos) const;
|
||||
|
||||
/** Return the sub-part at the specified position (zero is the
|
||||
* first part).
|
||||
@ -113,7 +113,7 @@ public:
|
||||
* @param pos index of the sub-part
|
||||
* @return sub-part at position 'pos'
|
||||
*/
|
||||
ref <part> getPartAt(const size_t pos);
|
||||
ref <messagePart> getPartAt(const size_t pos);
|
||||
|
||||
/** Return the number of sub-parts in this part.
|
||||
*
|
||||
@ -126,16 +126,16 @@ public:
|
||||
/** Structure of a MIME part/message.
|
||||
*/
|
||||
|
||||
class VMIME_EXPORT structure : public object
|
||||
class VMIME_EXPORT messageStructure : public object
|
||||
{
|
||||
protected:
|
||||
|
||||
structure() { }
|
||||
structure(const structure&) : object() { }
|
||||
messageStructure() { }
|
||||
messageStructure(const messageStructure&) : object() { }
|
||||
|
||||
public:
|
||||
|
||||
virtual ~structure() { }
|
||||
virtual ~messageStructure() { }
|
||||
|
||||
/** Return the part at the specified position (first
|
||||
* part is at position 0).
|
||||
@ -143,7 +143,7 @@ public:
|
||||
* @param pos position
|
||||
* @return part at position 'pos'
|
||||
*/
|
||||
virtual ref <const part> getPartAt(const size_t pos) const = 0;
|
||||
virtual ref <const messagePart> getPartAt(const size_t pos) const = 0;
|
||||
|
||||
/** Return the part at the specified position (first
|
||||
* part is at position 0).
|
||||
@ -151,7 +151,7 @@ public:
|
||||
* @param pos position
|
||||
* @return part at position 'pos'
|
||||
*/
|
||||
virtual ref <part> getPartAt(const size_t pos) = 0;
|
||||
virtual ref <messagePart> getPartAt(const size_t pos) = 0;
|
||||
|
||||
/** Return the number of parts in this part.
|
||||
*
|
||||
@ -183,13 +183,13 @@ public:
|
||||
*
|
||||
* @return MIME structure of the message
|
||||
*/
|
||||
virtual ref <const structure> getStructure() const = 0;
|
||||
virtual ref <const messageStructure> getStructure() const = 0;
|
||||
|
||||
/** Return the MIME structure of the message (must fetch before).
|
||||
*
|
||||
* @return MIME structure of the message
|
||||
*/
|
||||
virtual ref <structure> getStructure() = 0;
|
||||
virtual ref <messageStructure> getStructure() = 0;
|
||||
|
||||
/** Return a reference to the header fields of the message (must fetch before).
|
||||
*
|
||||
@ -289,13 +289,19 @@ public:
|
||||
* be supported by the protocol (IMAP supports this), but it will NOT throw
|
||||
* an exception if not supported.
|
||||
*/
|
||||
virtual void extractPart(ref <const part> p, utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const = 0;
|
||||
virtual void extractPart
|
||||
(ref <const messagePart> p,
|
||||
utility::outputStream& os,
|
||||
utility::progressListener* progress = NULL,
|
||||
const int start = 0,
|
||||
const int length = -1,
|
||||
const bool peek = false) const = 0;
|
||||
|
||||
/** Fetch the MIME header for the specified part.
|
||||
*
|
||||
* @param p the part for which to fetch the header
|
||||
*/
|
||||
virtual void fetchPartHeader(ref <part> p) = 0;
|
||||
virtual void fetchPartHeader(ref <messagePart> p) = 0;
|
||||
|
||||
/** Get the RFC-822 message for this abstract message.
|
||||
* Warning: This may require getting some data (ie: structure and headers) from
|
||||
|
@ -68,8 +68,8 @@ public:
|
||||
|
||||
bool isExpunged() const;
|
||||
|
||||
ref <const structure> getStructure() const;
|
||||
ref <structure> getStructure();
|
||||
ref <const messageStructure> getStructure() const;
|
||||
ref <messageStructure> getStructure();
|
||||
|
||||
ref <const header> getHeader() const;
|
||||
|
||||
@ -77,9 +77,9 @@ public:
|
||||
void setFlags(const int flags, const int mode = FLAG_MODE_SET);
|
||||
|
||||
void extract(utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const;
|
||||
void extractPart(ref <const part> p, utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const;
|
||||
void extractPart(ref <const messagePart> p, utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const;
|
||||
|
||||
void fetchPartHeader(ref <part> p);
|
||||
void fetchPartHeader(ref <messagePart> p);
|
||||
|
||||
ref <vmime::message> getParsedMessage();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user