diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/net/imap/IMAPMessage.cpp | 72 | ||||
-rw-r--r-- | src/net/maildir/maildirMessage.cpp | 68 | ||||
-rw-r--r-- | src/net/message.cpp | 12 | ||||
-rw-r--r-- | src/net/pop3/POP3Message.cpp | 8 |
4 files changed, 78 insertions, 82 deletions
diff --git a/src/net/imap/IMAPMessage.cpp b/src/net/imap/IMAPMessage.cpp index 3dd6c021..05c37bf7 100644 --- a/src/net/imap/IMAPMessage.cpp +++ b/src/net/imap/IMAPMessage.cpp @@ -50,8 +50,8 @@ private: public: - const structure& getStructure() const; - structure& getStructure(); + ref <const structure> getStructure() const; + ref <structure> getStructure(); weak_ref <const IMAPpart> getParent() const { return (m_parent); } @@ -59,12 +59,12 @@ public: const int getSize() const { return (m_size); } const int getNumber() const { return (m_number); } - const header& getHeader() const + ref <const header> getHeader() const { if (m_header == NULL) throw exceptions::unfetched_object(); else - return (*m_header); + return m_header; } @@ -112,22 +112,20 @@ private: class IMAPstructure : public structure { -private: +public: IMAPstructure() { } -public: - IMAPstructure(const IMAPParser::body* body) { - m_parts.push_back(IMAPpart::create(NULL, 1, body)); + m_parts.push_back(IMAPpart::create(NULL, 0, body)); } IMAPstructure(ref <IMAPpart> parent, const std::vector <IMAPParser::body*>& list) { - int number = 1; + int number = 0; for (std::vector <IMAPParser::body*>::const_iterator it = list.begin() ; it != list.end() ; ++it, ++number) @@ -137,36 +135,36 @@ public: } - const part& operator[](const int x) const + ref <const part> getPartAt(const int x) const { - return (*m_parts[x - 1]); + return m_parts[x]; } - part& operator[](const int x) + ref <part> getPartAt(const int x) { - return (*m_parts[x - 1]); + return m_parts[x]; } - const int getCount() const + const int getPartCount() const { - return (m_parts.size()); + return m_parts.size(); } - static IMAPstructure* emptyStructure() + static ref <IMAPstructure> emptyStructure() { - return (&m_emptyStructure); + return (m_emptyStructure); } private: - static IMAPstructure m_emptyStructure; + static ref <IMAPstructure> m_emptyStructure; std::vector <ref <IMAPpart> > m_parts; }; -IMAPstructure IMAPstructure::m_emptyStructure; +ref <IMAPstructure> IMAPstructure::m_emptyStructure = vmime::create <IMAPstructure>(); @@ -208,21 +206,21 @@ IMAPpart::IMAPpart(ref <IMAPpart> parent, const int number, const IMAPParser::bo } -const class structure& IMAPpart::getStructure() const +ref <const structure> IMAPpart::getStructure() const { if (m_structure != NULL) - return (*m_structure); + return (m_structure); else - return (*IMAPstructure::emptyStructure()); + return (IMAPstructure::emptyStructure()); } -class structure& IMAPpart::getStructure() +ref <structure> IMAPpart::getStructure() { if (m_structure != NULL) - return (*m_structure); + return (m_structure); else - return (*IMAPstructure::emptyStructure()); + return (IMAPstructure::emptyStructure()); } @@ -331,21 +329,21 @@ const int IMAPMessage::getFlags() const } -const structure& IMAPMessage::getStructure() const +ref <const structure> IMAPMessage::getStructure() const { if (m_structure == NULL) throw exceptions::unfetched_object(); - return (*m_structure); + return m_structure; } -structure& IMAPMessage::getStructure() +ref <structure> IMAPMessage::getStructure() { if (m_structure == NULL) throw exceptions::unfetched_object(); - return (*m_structure); + return m_structure; } @@ -369,17 +367,17 @@ void IMAPMessage::extract(utility::outputStream& os, utility::progressionListene void IMAPMessage::extractPart - (const part& p, utility::outputStream& os, utility::progressionListener* progress, + (ref <const part> p, utility::outputStream& os, utility::progressionListener* progress, const int start, const int length, const bool peek) const { if (!m_folder) throw exceptions::folder_not_found(); - extract(&p, os, progress, start, length, false, peek); + extract(p, os, progress, start, length, false, peek); } -void IMAPMessage::fetchPartHeader(part& p) +void IMAPMessage::fetchPartHeader(ref <part> p) { if (!m_folder) throw exceptions::folder_not_found(); @@ -387,13 +385,13 @@ void IMAPMessage::fetchPartHeader(part& p) std::ostringstream oss; utility::outputStreamAdapter ossAdapter(oss); - extract(&p, ossAdapter, NULL, 0, -1, true, true); + extract(p, ossAdapter, NULL, 0, -1, true, true); - static_cast <IMAPpart&>(p).getOrCreateHeader().parse(oss.str()); + p.dynamicCast <IMAPpart>()->getOrCreateHeader().parse(oss.str()); } -void IMAPMessage::extract(const part* p, utility::outputStream& os, +void IMAPMessage::extract(ref <const part> p, utility::outputStream& os, utility::progressionListener* progress, const int start, const int length, const bool headerOnly, const bool peek) const { @@ -404,7 +402,7 @@ void IMAPMessage::extract(const part* p, utility::outputStream& os, if (p != NULL) { - weak_ref <const IMAPpart> currentPart = static_cast <const IMAPpart*>(p); + weak_ref <const IMAPpart> currentPart = p.dynamicCast <const IMAPpart>(); std::vector <int> numbers; numbers.push_back(currentPart->getNumber()); @@ -421,7 +419,7 @@ void IMAPMessage::extract(const part* p, utility::outputStream& os, for (std::vector <int>::reverse_iterator it = numbers.rbegin() ; it != numbers.rend() ; ++it) { if (it != numbers.rbegin()) section << "."; - section << *it; + section << (*it + 1); } } diff --git a/src/net/maildir/maildirMessage.cpp b/src/net/maildir/maildirMessage.cpp index 358b6046..1d596fbd 100644 --- a/src/net/maildir/maildirMessage.cpp +++ b/src/net/maildir/maildirMessage.cpp @@ -47,8 +47,8 @@ public: ~maildirPart(); - const structure& getStructure() const; - structure& getStructure(); + ref <const structure> getStructure() const; + ref <structure> getStructure(); weak_ref <const maildirPart> getParent() const { return (m_parent); } @@ -56,12 +56,12 @@ public: const int getSize() const { return (m_size); } const int getNumber() const { return (m_number); } - const header& getHeader() const + ref <const header> getHeader() const { if (m_header == NULL) throw exceptions::unfetched_object(); else - return (*m_header); + return m_header; } header& getOrCreateHeader() @@ -103,58 +103,56 @@ private: class maildirStructure : public structure { -private: +public: maildirStructure() { } -public: - maildirStructure(weak_ref <maildirPart> parent, const bodyPart& part) { - m_parts.push_back(vmime::create <maildirPart>(parent, 1, part)); + m_parts.push_back(vmime::create <maildirPart>(parent, 0, part)); } maildirStructure(weak_ref <maildirPart> parent, const std::vector <ref <const vmime::bodyPart> >& list) { - int number = 1; + int number = 0; for (unsigned int i = 0 ; i < list.size() ; ++i) m_parts.push_back(vmime::create <maildirPart>(parent, number, *list[i])); } - const part& operator[](const int x) const + ref <const part> getPartAt(const int x) const { - return (*m_parts[x - 1]); + return m_parts[x]; } - part& operator[](const int x) + ref <part> getPartAt(const int x) { - return (*m_parts[x - 1]); + return m_parts[x]; } - const int getCount() const + const int getPartCount() const { - return (m_parts.size()); + return m_parts.size(); } - static maildirStructure* emptyStructure() + static ref <maildirStructure> emptyStructure() { - return (&m_emptyStructure); + return m_emptyStructure; } private: - static maildirStructure m_emptyStructure; + static ref <maildirStructure> m_emptyStructure; std::vector <ref <maildirPart> > m_parts; }; -maildirStructure maildirStructure::m_emptyStructure; +ref <maildirStructure> maildirStructure::m_emptyStructure = vmime::create <maildirStructure>(); @@ -187,21 +185,21 @@ maildirPart::~maildirPart() } -const structure& maildirPart::getStructure() const +ref <const structure> maildirPart::getStructure() const { if (m_structure != NULL) - return (*m_structure); + return m_structure; else - return (*maildirStructure::emptyStructure()); + return maildirStructure::emptyStructure(); } -structure& maildirPart::getStructure() +ref <structure> maildirPart::getStructure() { if (m_structure != NULL) - return (*m_structure); + return m_structure; else - return (*maildirStructure::emptyStructure()); + return maildirStructure::emptyStructure(); } @@ -258,21 +256,21 @@ const bool maildirMessage::isExpunged() const } -const structure& maildirMessage::getStructure() const +ref <const structure> maildirMessage::getStructure() const { if (m_structure == NULL) throw exceptions::unfetched_object(); - return (*m_structure); + return m_structure; } -structure& maildirMessage::getStructure() +ref <structure> maildirMessage::getStructure() { if (m_structure == NULL) throw exceptions::unfetched_object(); - return (*m_structure); + return m_structure; } @@ -311,7 +309,7 @@ void maildirMessage::extract(utility::outputStream& os, } -void maildirMessage::extractPart(const part& p, utility::outputStream& os, +void maildirMessage::extractPart(ref <const part> p, utility::outputStream& os, utility::progressionListener* progress, const int start, const int length, const bool peek) const { @@ -367,9 +365,9 @@ void maildirMessage::extractImpl(utility::outputStream& os, utility::progression } -void maildirMessage::fetchPartHeader(part& p) +void maildirMessage::fetchPartHeader(ref <part> p) { - maildirPart& mp = dynamic_cast <maildirPart&>(p); + ref <maildirPart> mp = p.dynamicCast <maildirPart>(); utility::fileSystemFactory* fsf = platformDependant::getHandler()->getFileSystemFactory(); @@ -379,10 +377,10 @@ void maildirMessage::fetchPartHeader(part& p) ref <utility::fileReader> reader = file->getFileReader(); ref <utility::inputStream> is = reader->getInputStream(); - is->skip(mp.getHeaderParsedOffset()); + is->skip(mp->getHeaderParsedOffset()); utility::stream::value_type buffer[1024]; - utility::stream::size_type remaining = mp.getHeaderParsedLength(); + utility::stream::size_type remaining = mp->getHeaderParsedLength(); string contents; contents.reserve(remaining); @@ -397,7 +395,7 @@ void maildirMessage::fetchPartHeader(part& p) contents.append(buffer, read); } - mp.getOrCreateHeader().parse(contents); + mp->getOrCreateHeader().parse(contents); } diff --git a/src/net/message.cpp b/src/net/message.cpp index 0c55d1da..98ba4228 100644 --- a/src/net/message.cpp +++ b/src/net/message.cpp @@ -24,21 +24,21 @@ namespace vmime { namespace net { -const part& part::operator[](const int x) const +ref <const part> part::getPartAt(const int pos) const { - return (getStructure()[x]); + return getStructure()->getPartAt(pos); } -part& part::operator[](const int x) +ref <part> part::getPartAt(const int pos) { - return (getStructure()[x]); + return getStructure()->getPartAt(pos); } -const int part::getCount() const +const int part::getPartCount() const { - return (getStructure().getCount()); + return getStructure()->getPartCount(); } diff --git a/src/net/pop3/POP3Message.cpp b/src/net/pop3/POP3Message.cpp index b2e2fae4..d9e452be 100644 --- a/src/net/pop3/POP3Message.cpp +++ b/src/net/pop3/POP3Message.cpp @@ -87,13 +87,13 @@ const int POP3Message::getFlags() const } -const structure& POP3Message::getStructure() const +ref <const structure> POP3Message::getStructure() const { throw exceptions::operation_not_supported(); } -structure& POP3Message::getStructure() +ref <structure> POP3Message::getStructure() { throw exceptions::operation_not_supported(); } @@ -145,7 +145,7 @@ void POP3Message::extract(utility::outputStream& os, void POP3Message::extractPart - (const part& /* p */, utility::outputStream& /* os */, + (ref <const part> /* p */, utility::outputStream& /* os */, utility::progressionListener* /* progress */, const int /* start */, const int /* length */, const bool /* peek */) const @@ -154,7 +154,7 @@ void POP3Message::extractPart } -void POP3Message::fetchPartHeader(part& /* p */) +void POP3Message::fetchPartHeader(ref <part> /* p */) { throw exceptions::operation_not_supported(); } |