aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/maildir/maildirMessage.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/net/maildir/maildirMessage.cpp40
1 files changed, 25 insertions, 15 deletions
diff --git a/src/net/maildir/maildirMessage.cpp b/src/net/maildir/maildirMessage.cpp
index 8cfe49be..6c621f21 100644
--- a/src/net/maildir/maildirMessage.cpp
+++ b/src/net/maildir/maildirMessage.cpp
@@ -43,7 +43,7 @@ class maildirPart : public part
{
public:
- maildirPart(weak_ref <maildirPart> parent, const int number, const bodyPart& part);
+ maildirPart(ref <maildirPart> parent, const int number, const bodyPart& part);
~maildirPart();
@@ -111,7 +111,7 @@ public:
{
}
- maildirStructure(weak_ref <maildirPart> parent, const bodyPart& part)
+ maildirStructure(ref <maildirPart> parent, const bodyPart& part)
{
vmime::ref <maildirPart> mpart = vmime::create <maildirPart>(parent, 0, part);
mpart->initStructure(part);
@@ -119,7 +119,7 @@ public:
m_parts.push_back(mpart);
}
- maildirStructure(weak_ref <maildirPart> parent, const std::vector <ref <const vmime::bodyPart> >& list)
+ maildirStructure(ref <maildirPart> parent, const std::vector <ref <const vmime::bodyPart> >& list)
{
for (unsigned int i = 0 ; i < list.size() ; ++i)
{
@@ -164,7 +164,7 @@ ref <maildirStructure> maildirStructure::m_emptyStructure = vmime::create <maild
-maildirPart::maildirPart(weak_ref <maildirPart> parent, const int number, const bodyPart& part)
+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();
@@ -191,7 +191,7 @@ void maildirPart::initStructure(const bodyPart& part)
else
{
m_structure = vmime::create <maildirStructure>
- (thisWeakRef().dynamicCast <maildirPart>(),
+ (thisRef().dynamicCast <maildirPart>(),
part.getBody()->getPartList());
}
}
@@ -220,18 +220,20 @@ ref <structure> maildirPart::getStructure()
// maildirMessage
//
-maildirMessage::maildirMessage(weak_ref <maildirFolder> folder, const int num)
+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)
{
- m_folder->registerMessage(this);
+ folder->registerMessage(this);
}
maildirMessage::~maildirMessage()
{
- if (m_folder)
- m_folder->unregisterMessage(this);
+ ref <maildirFolder> folder = m_folder.acquire();
+
+ if (folder)
+ folder->unregisterMessage(this);
}
@@ -306,10 +308,12 @@ const int maildirMessage::getFlags() const
void maildirMessage::setFlags(const int flags, const int mode)
{
- if (!m_folder)
+ ref <maildirFolder> folder = m_folder.acquire();
+
+ if (!folder)
throw exceptions::folder_not_found();
- m_folder->setMessageFlags(m_num, m_num, flags, mode);
+ folder->setMessageFlags(m_num, m_num, flags, mode);
}
@@ -336,9 +340,11 @@ void maildirMessage::extractImpl(utility::outputStream& os, utility::progressLis
const int start, const int length, const int partialStart, const int partialLength,
const bool /* peek */) const
{
+ ref <const maildirFolder> folder = m_folder.acquire();
+
utility::fileSystemFactory* fsf = platformDependant::getHandler()->getFileSystemFactory();
- const utility::file::path path = m_folder->getMessageFSPath(m_num);
+ const utility::file::path path = folder->getMessageFSPath(m_num);
ref <utility::file> file = fsf->create(path);
ref <utility::fileReader> reader = file->getFileReader();
@@ -379,11 +385,13 @@ void maildirMessage::extractImpl(utility::outputStream& os, utility::progressLis
void maildirMessage::fetchPartHeader(ref <part> p)
{
+ ref <maildirFolder> folder = m_folder.acquire();
+
ref <maildirPart> mp = p.dynamicCast <maildirPart>();
utility::fileSystemFactory* fsf = platformDependant::getHandler()->getFileSystemFactory();
- const utility::file::path path = m_folder->getMessageFSPath(m_num);
+ const utility::file::path path = folder->getMessageFSPath(m_num);
ref <utility::file> file = fsf->create(path);
ref <utility::fileReader> reader = file->getFileReader();
@@ -411,9 +419,11 @@ void maildirMessage::fetchPartHeader(ref <part> p)
}
-void maildirMessage::fetch(weak_ref <maildirFolder> folder, const int options)
+void maildirMessage::fetch(ref <maildirFolder> msgFolder, const int options)
{
- if (m_folder != folder)
+ ref <maildirFolder> folder = m_folder.acquire();
+
+ if (folder != msgFolder)
throw exceptions::folder_not_found();
utility::fileSystemFactory* fsf = platformDependant::getHandler()->getFileSystemFactory();