From f9913fa28a27f23fde2d4956c62cbb2fb2bc2ee8 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Thu, 21 Nov 2013 22:16:57 +0100 Subject: Boost/C++11 shared pointers. --- src/net/maildir/format/courierMaildirFormat.cpp | 50 ++--- src/net/maildir/format/kmailMaildirFormat.cpp | 46 ++--- src/net/maildir/maildirFolder.cpp | 238 ++++++++++++------------ src/net/maildir/maildirFolderStatus.cpp | 4 +- src/net/maildir/maildirFormat.cpp | 20 +- src/net/maildir/maildirMessage.cpp | 66 +++---- src/net/maildir/maildirMessagePart.cpp | 18 +- src/net/maildir/maildirMessageStructure.cpp | 16 +- src/net/maildir/maildirStore.cpp | 38 ++-- src/net/maildir/maildirUtils.cpp | 6 +- 10 files changed, 250 insertions(+), 252 deletions(-) (limited to 'src/net/maildir') diff --git a/src/net/maildir/format/courierMaildirFormat.cpp b/src/net/maildir/format/courierMaildirFormat.cpp index 346b9c67..a948de3e 100644 --- a/src/net/maildir/format/courierMaildirFormat.cpp +++ b/src/net/maildir/format/courierMaildirFormat.cpp @@ -41,7 +41,7 @@ namespace maildir { namespace format { -courierMaildirFormat::courierMaildirFormat(ref ctx) +courierMaildirFormat::courierMaildirFormat(shared_ptr ctx) : maildirFormat(ctx) { } @@ -55,19 +55,19 @@ const string courierMaildirFormat::getName() const void courierMaildirFormat::createFolder(const folder::path& path) { - ref fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr fsf = platform::getHandler()->getFileSystemFactory(); if (!fsf->isValidPath(folderPathToFileSystemPath(path, ROOT_DIRECTORY))) throw exceptions::invalid_folder_name(); - ref rootDir = fsf->create + shared_ptr rootDir = fsf->create (folderPathToFileSystemPath(path, ROOT_DIRECTORY)); - ref newDir = fsf->create + shared_ptr newDir = fsf->create (folderPathToFileSystemPath(path, NEW_DIRECTORY)); - ref tmpDir = fsf->create + shared_ptr tmpDir = fsf->create (folderPathToFileSystemPath(path, TMP_DIRECTORY)); - ref curDir = fsf->create + shared_ptr curDir = fsf->create (folderPathToFileSystemPath(path, CUR_DIRECTORY)); rootDir->createDirectory(true); @@ -76,7 +76,7 @@ void courierMaildirFormat::createFolder(const folder::path& path) tmpDir->createDirectory(false); curDir->createDirectory(false); - ref maildirFile = fsf->create + shared_ptr maildirFile = fsf->create (folderPathToFileSystemPath(path, ROOT_DIRECTORY) / utility::file::path::component("maildirfolder")); @@ -86,7 +86,7 @@ void courierMaildirFormat::createFolder(const folder::path& path) void courierMaildirFormat::destroyFolder(const folder::path& path) { - ref fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr fsf = platform::getHandler()->getFileSystemFactory(); // Recursively delete directories of subfolders const std::vector folders = listFolders(path, true); @@ -125,7 +125,7 @@ void courierMaildirFormat::renameFolder void courierMaildirFormat::renameFolderImpl (const folder::path& oldPath, const folder::path& newPath) { - ref fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr fsf = platform::getHandler()->getFileSystemFactory(); const utility::file::path oldFSPath = folderPathToFileSystemPath(oldPath, ROOT_DIRECTORY); @@ -133,26 +133,26 @@ void courierMaildirFormat::renameFolderImpl const utility::file::path newFSPath = folderPathToFileSystemPath(newPath, ROOT_DIRECTORY); - ref rootDir = fsf->create(oldFSPath); + shared_ptr rootDir = fsf->create(oldFSPath); rootDir->rename(newFSPath); } bool courierMaildirFormat::folderExists(const folder::path& path) const { - ref fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr fsf = platform::getHandler()->getFileSystemFactory(); - ref rootDir = fsf->create + shared_ptr rootDir = fsf->create (folderPathToFileSystemPath(path, ROOT_DIRECTORY)); - ref newDir = fsf->create + shared_ptr newDir = fsf->create (folderPathToFileSystemPath(path, NEW_DIRECTORY)); - ref tmpDir = fsf->create + shared_ptr tmpDir = fsf->create (folderPathToFileSystemPath(path, TMP_DIRECTORY)); - ref curDir = fsf->create + shared_ptr curDir = fsf->create (folderPathToFileSystemPath(path, CUR_DIRECTORY)); - ref maildirFile = fsf->create + shared_ptr maildirFile = fsf->create (folderPathToFileSystemPath(path, ROOT_DIRECTORY) / utility::file::path::component("maildirfolder")); @@ -260,9 +260,9 @@ const std::vector courierMaildirFormat::listFolders bool courierMaildirFormat::listDirectories(const folder::path& root, std::vector & dirs, const bool onlyTestForExistence) const { - ref fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr fsf = platform::getHandler()->getFileSystemFactory(); - ref rootDir = fsf->create + shared_ptr rootDir = fsf->create (getContext()->getStore()->getFileSystemPath()); if (rootDir->exists()) @@ -278,11 +278,11 @@ bool courierMaildirFormat::listDirectories(const folder::path& root, } // Enumerate directories - ref it = rootDir->getFiles(); + shared_ptr it = rootDir->getFiles(); while (it->hasMoreElements()) { - ref file = it->nextElement(); + shared_ptr file = it->nextElement(); if (isSubfolderDirectory(*file)) { @@ -502,24 +502,24 @@ const folder::path::component courierMaildirFormat::fromModifiedUTF7(const strin bool courierMaildirFormat::supports() const { - ref fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr fsf = platform::getHandler()->getFileSystemFactory(); - ref rootDir = fsf->create + shared_ptr rootDir = fsf->create (getContext()->getStore()->getFileSystemPath()); if (rootDir->exists()) { // Try to find a file named "maildirfolder", which indicates // the Maildir is in Courier format - ref it = rootDir->getFiles(); + shared_ptr it = rootDir->getFiles(); while (it->hasMoreElements()) { - ref file = it->nextElement(); + shared_ptr file = it->nextElement(); if (isSubfolderDirectory(*file)) { - ref folderFile = fsf->create + shared_ptr folderFile = fsf->create (file->getFullPath() / utility::file::path::component("maildirfolder")); if (folderFile->exists() && folderFile->isFile()) diff --git a/src/net/maildir/format/kmailMaildirFormat.cpp b/src/net/maildir/format/kmailMaildirFormat.cpp index 0f81b10a..70c9b909 100644 --- a/src/net/maildir/format/kmailMaildirFormat.cpp +++ b/src/net/maildir/format/kmailMaildirFormat.cpp @@ -41,7 +41,7 @@ namespace maildir { namespace format { -kmailMaildirFormat::kmailMaildirFormat(ref ctx) +kmailMaildirFormat::kmailMaildirFormat(shared_ptr ctx) : maildirFormat(ctx) { } @@ -55,19 +55,19 @@ const string kmailMaildirFormat::getName() const void kmailMaildirFormat::createFolder(const folder::path& path) { - ref fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr fsf = platform::getHandler()->getFileSystemFactory(); if (!fsf->isValidPath(folderPathToFileSystemPath(path, ROOT_DIRECTORY))) throw exceptions::invalid_folder_name(); - ref rootDir = fsf->create + shared_ptr rootDir = fsf->create (folderPathToFileSystemPath(path, ROOT_DIRECTORY)); - ref newDir = fsf->create + shared_ptr newDir = fsf->create (folderPathToFileSystemPath(path, NEW_DIRECTORY)); - ref tmpDir = fsf->create + shared_ptr tmpDir = fsf->create (folderPathToFileSystemPath(path, TMP_DIRECTORY)); - ref curDir = fsf->create + shared_ptr curDir = fsf->create (folderPathToFileSystemPath(path, CUR_DIRECTORY)); rootDir->createDirectory(true); @@ -81,7 +81,7 @@ void kmailMaildirFormat::createFolder(const folder::path& path) void kmailMaildirFormat::destroyFolder(const folder::path& path) { // Delete 'folder' and '.folder.directory' directories - ref fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr fsf = platform::getHandler()->getFileSystemFactory(); maildirUtils::recursiveFSDelete(fsf->create (folderPathToFileSystemPath(path, ROOT_DIRECTORY))); // root @@ -93,16 +93,16 @@ void kmailMaildirFormat::destroyFolder(const folder::path& path) bool kmailMaildirFormat::folderExists(const folder::path& path) const { - ref fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr fsf = platform::getHandler()->getFileSystemFactory(); - ref rootDir = fsf->create + shared_ptr rootDir = fsf->create (folderPathToFileSystemPath(path, ROOT_DIRECTORY)); - ref newDir = fsf->create + shared_ptr newDir = fsf->create (folderPathToFileSystemPath(path, NEW_DIRECTORY)); - ref tmpDir = fsf->create + shared_ptr tmpDir = fsf->create (folderPathToFileSystemPath(path, TMP_DIRECTORY)); - ref curDir = fsf->create + shared_ptr curDir = fsf->create (folderPathToFileSystemPath(path, CUR_DIRECTORY)); return rootDir->exists() && rootDir->isDirectory() && @@ -183,18 +183,18 @@ const std::vector kmailMaildirFormat::listFolders void kmailMaildirFormat::listFoldersImpl (std::vector & list, const folder::path& root, const bool recursive) const { - ref fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr fsf = platform::getHandler()->getFileSystemFactory(); - ref rootDir = fsf->create(folderPathToFileSystemPath(root, + shared_ptr rootDir = fsf->create(folderPathToFileSystemPath(root, root.isEmpty() ? ROOT_DIRECTORY : CONTAINER_DIRECTORY)); if (rootDir->exists()) { - ref it = rootDir->getFiles(); + shared_ptr it = rootDir->getFiles(); while (it->hasMoreElements()) { - ref file = it->nextElement(); + shared_ptr file = it->nextElement(); if (isSubfolderDirectory(*file)) { @@ -232,11 +232,11 @@ bool kmailMaildirFormat::isSubfolderDirectory(const utility::file& file) void kmailMaildirFormat::renameFolder(const folder::path& oldPath, const folder::path& newPath) { - ref fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr fsf = platform::getHandler()->getFileSystemFactory(); - ref rootDir = fsf->create + shared_ptr rootDir = fsf->create (folderPathToFileSystemPath(oldPath, ROOT_DIRECTORY)); - ref contDir = fsf->create + shared_ptr contDir = fsf->create (folderPathToFileSystemPath(oldPath, CONTAINER_DIRECTORY)); try @@ -283,16 +283,16 @@ void kmailMaildirFormat::renameFolder(const folder::path& oldPath, const folder: bool kmailMaildirFormat::folderHasSubfolders(const folder::path& path) const { - ref fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr fsf = platform::getHandler()->getFileSystemFactory(); - ref rootDir = fsf->create + shared_ptr rootDir = fsf->create (folderPathToFileSystemPath(path, CONTAINER_DIRECTORY)); - ref it = rootDir->getFiles(); + shared_ptr it = rootDir->getFiles(); while (it->hasMoreElements()) { - ref file = it->nextElement(); + shared_ptr file = it->nextElement(); if (isSubfolderDirectory(*file)) return true; diff --git a/src/net/maildir/maildirFolder.cpp b/src/net/maildir/maildirFolder.cpp index ae4c17e0..f476d98a 100644 --- a/src/net/maildir/maildirFolder.cpp +++ b/src/net/maildir/maildirFolder.cpp @@ -35,8 +35,6 @@ #include "vmime/net/maildir/maildirFormat.hpp" #include "vmime/net/maildir/maildirFolderStatus.hpp" -#include "vmime/utility/smartPtr.hpp" - #include "vmime/message.hpp" #include "vmime/exception.hpp" @@ -51,7 +49,7 @@ namespace net { namespace maildir { -maildirFolder::maildirFolder(const folder::path& path, ref store) +maildirFolder::maildirFolder(const folder::path& path, shared_ptr store) : m_store(store), m_path(path), m_name(path.isEmpty() ? folder::path::component("") : path.getLastComponent()), m_mode(-1), m_open(false), m_unreadMessageCount(0), m_messageCount(0) @@ -62,7 +60,7 @@ maildirFolder::maildirFolder(const folder::path& path, ref store) maildirFolder::~maildirFolder() { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (store) { @@ -80,7 +78,7 @@ maildirFolder::~maildirFolder() void maildirFolder::onStoreDisconnected() { - m_store = NULL; + m_store.reset(); } @@ -106,7 +104,7 @@ int maildirFolder::getFlags() { int flags = 0; - if (m_store.acquire()->getFormat()->folderHasSubfolders(m_path)) + if (m_store.lock()->getFormat()->folderHasSubfolders(m_path)) flags |= FLAG_CHILDREN; // Contains at least one sub-folder return (flags); @@ -127,7 +125,7 @@ const folder::path maildirFolder::getFullPath() const void maildirFolder::open(const int mode, bool /* failIfModeIsNotAvailable */) { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); @@ -145,7 +143,7 @@ void maildirFolder::open(const int mode, bool /* failIfModeIsNotAvailable */) void maildirFolder::close(const bool expunge) { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); @@ -193,7 +191,7 @@ void maildirFolder::unregisterMessage(maildirMessage* msg) void maildirFolder::create(const int /* type */) { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); @@ -215,9 +213,9 @@ void maildirFolder::create(const int /* type */) } // Notify folder created - ref event = - vmime::create - (thisRef().dynamicCast (), + shared_ptr event = + make_shared + (dynamicCast (shared_from_this()), events::folderEvent::TYPE_CREATED, m_path, m_path); notifyFolder(event); @@ -226,7 +224,7 @@ void maildirFolder::create(const int /* type */) void maildirFolder::destroy() { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); @@ -244,9 +242,9 @@ void maildirFolder::destroy() } // Notify folder deleted - ref event = - vmime::create - (thisRef().dynamicCast (), + shared_ptr event = + make_shared + (dynamicCast (shared_from_this()), events::folderEvent::TYPE_DELETED, m_path, m_path); notifyFolder(event); @@ -255,7 +253,7 @@ void maildirFolder::destroy() bool maildirFolder::exists() { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); return store->getFormat()->folderExists(m_path); } @@ -269,42 +267,42 @@ bool maildirFolder::isOpen() const void maildirFolder::scanFolder() { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); try { m_messageCount = 0; m_unreadMessageCount = 0; - ref fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr fsf = platform::getHandler()->getFileSystemFactory(); utility::file::path newDirPath = store->getFormat()->folderPathToFileSystemPath (m_path, maildirFormat::NEW_DIRECTORY); - ref newDir = fsf->create(newDirPath); + shared_ptr newDir = fsf->create(newDirPath); utility::file::path curDirPath = store->getFormat()->folderPathToFileSystemPath (m_path, maildirFormat::CUR_DIRECTORY); - ref curDir = fsf->create(curDirPath); + shared_ptr curDir = fsf->create(curDirPath); // New received messages (new/) - ref nit = newDir->getFiles(); + shared_ptr nit = newDir->getFiles(); std::vector newMessageFilenames; while (nit->hasMoreElements()) { - ref file = nit->nextElement(); + shared_ptr file = nit->nextElement(); if (maildirUtils::isMessageFile(*file)) newMessageFilenames.push_back(file->getFullPath().getLastComponent()); } // Current messages (cur/) - ref cit = curDir->getFiles(); + shared_ptr cit = curDir->getFiles(); std::vector curMessageFilenames; while (cit->hasMoreElements()) { - ref file = cit->nextElement(); + shared_ptr file = cit->nextElement(); if (maildirUtils::isMessageFile(*file)) curMessageFilenames.push_back(file->getFullPath().getLastComponent()); @@ -354,7 +352,7 @@ void maildirFolder::scanFolder() maildirUtils::buildFilename(maildirUtils::extractId(*it), 0); // Move messages from 'new' to 'cur' - ref file = fsf->create(newDirPath / *it); + shared_ptr file = fsf->create(newDirPath / *it); file->rename(curDirPath / newFilename); // Append to message list @@ -406,7 +404,7 @@ void maildirFolder::scanFolder() } -ref maildirFolder::getMessage(const int num) +shared_ptr maildirFolder::getMessage(const int num) { if (!isOpen()) throw exceptions::illegal_state("Folder not open"); @@ -414,12 +412,12 @@ ref maildirFolder::getMessage(const int num) if (num < 1 || num > m_messageCount) throw exceptions::message_not_found(); - return vmime::create - (thisRef().dynamicCast (), num); + return make_shared + (dynamicCast (shared_from_this()), num); } -std::vector > maildirFolder::getMessages(const messageSet& msgs) +std::vector > maildirFolder::getMessages(const messageSet& msgs) { if (!isOpen()) throw exceptions::illegal_state("Folder not open"); @@ -428,15 +426,15 @@ std::vector > maildirFolder::getMessages(const messageSet& msgs) { const std::vector numbers = maildirUtils::messageSetToNumberList(msgs); - std::vector > messages; - ref thisFolder = thisRef().dynamicCast (); + std::vector > messages; + shared_ptr thisFolder = dynamicCast (shared_from_this()); for (std::vector ::const_iterator it = numbers.begin() ; it != numbers.end() ; ++it) { if (*it < 1|| *it > m_messageCount) throw exceptions::message_not_found(); - messages.push_back(vmime::create (thisFolder, *it)); + messages.push_back(make_shared (thisFolder, *it)); } return messages; @@ -454,25 +452,25 @@ int maildirFolder::getMessageCount() } -ref maildirFolder::getFolder(const folder::path::component& name) +shared_ptr maildirFolder::getFolder(const folder::path::component& name) { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); - return vmime::create (m_path / name, store); + return make_shared (m_path / name, store); } -std::vector > maildirFolder::getFolders(const bool recursive) +std::vector > maildirFolder::getFolders(const bool recursive) { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!isOpen() && !store) throw exceptions::illegal_state("Store disconnected"); - std::vector > list; + std::vector > list; listFolders(list, recursive); @@ -480,9 +478,9 @@ std::vector > maildirFolder::getFolders(const bool recursive) } -void maildirFolder::listFolders(std::vector >& list, const bool recursive) +void maildirFolder::listFolders(std::vector >& list, const bool recursive) { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); try { @@ -493,8 +491,8 @@ void maildirFolder::listFolders(std::vector >& list, const bool re for (std::vector ::size_type i = 0, n = pathList.size() ; i < n ; ++i) { - ref subFolder = - vmime::create (pathList[i], store); + shared_ptr subFolder = + make_shared (pathList[i], store); list.push_back(subFolder); } @@ -508,7 +506,7 @@ void maildirFolder::listFolders(std::vector >& list, const bool re void maildirFolder::rename(const folder::path& newPath) { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); @@ -533,9 +531,9 @@ void maildirFolder::rename(const folder::path& newPath) m_path = newPath; m_name = newPath.getLastComponent(); - ref event = - vmime::create - (thisRef().dynamicCast (), + shared_ptr event = + make_shared + (dynamicCast (shared_from_this()), events::folderEvent::TYPE_RENAMED, oldPath, newPath); notifyFolder(event); @@ -549,9 +547,9 @@ void maildirFolder::rename(const folder::path& newPath) (*it)->m_path = newPath; (*it)->m_name = newPath.getLastComponent(); - ref event = - vmime::create - ((*it)->thisRef().dynamicCast (), + shared_ptr event = + make_shared + (dynamicCast ((*it)->shared_from_this()), events::folderEvent::TYPE_RENAMED, oldPath, newPath); (*it)->notifyFolder(event); @@ -562,9 +560,9 @@ void maildirFolder::rename(const folder::path& newPath) (*it)->m_path.renameParent(oldPath, newPath); - ref event = - vmime::create - ((*it)->thisRef().dynamicCast (), + shared_ptr event = + make_shared + (dynamicCast ((*it)->shared_from_this()), events::folderEvent::TYPE_RENAMED, oldPath, (*it)->m_path); (*it)->notifyFolder(event); @@ -583,7 +581,7 @@ void maildirFolder::deleteMessages(const messageSet& msgs) void maildirFolder::setMessageFlags (const messageSet& msgs, const int flags, const int mode) { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); @@ -597,7 +595,7 @@ void maildirFolder::setMessageFlags const std::vector nums = maildirUtils::messageSetToNumberList(msgs); // Change message flags - ref fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr fsf = platform::getHandler()->getFileSystemFactory(); utility::file::path curDirPath = store->getFormat()-> folderPathToFileSystemPath(m_path, maildirFormat::CUR_DIRECTORY); @@ -610,7 +608,7 @@ void maildirFolder::setMessageFlags try { const utility::file::path::component path = m_messageInfos[num].path; - ref file = fsf->create(curDirPath / path); + shared_ptr file = fsf->create(curDirPath / path); int newFlags = maildirUtils::extractFlags(path); @@ -690,9 +688,9 @@ void maildirFolder::setMessageFlags } // Notify message flags changed - ref event = - vmime::create - (thisRef().dynamicCast (), + shared_ptr event = + make_shared + (dynamicCast (shared_from_this()), events::messageChangedEvent::TYPE_FLAGS, nums); notifyMessageChanged(event); @@ -706,7 +704,7 @@ void maildirFolder::setMessageFlags } -void maildirFolder::addMessage(ref msg, const int flags, +void maildirFolder::addMessage(shared_ptr msg, const int flags, vmime::datetime* date, utility::progressListener* progress) { std::ostringstream oss; @@ -724,7 +722,7 @@ void maildirFolder::addMessage(ref msg, const int flags, void maildirFolder::addMessage(utility::inputStream& is, const int size, const int flags, vmime::datetime* /* date */, utility::progressListener* progress) { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); @@ -733,7 +731,7 @@ void maildirFolder::addMessage(utility::inputStream& is, const int size, else if (m_mode == MODE_READ_ONLY) throw exceptions::illegal_state("Folder is read-only"); - ref fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr fsf = platform::getHandler()->getFileSystemFactory(); utility::file::path tmpDirPath = store->getFormat()-> folderPathToFileSystemPath(m_path,maildirFormat::TMP_DIRECTORY); @@ -749,7 +747,7 @@ void maildirFolder::addMessage(utility::inputStream& is, const int size, try { - ref tmpDir = fsf->create(tmpDirPath); + shared_ptr tmpDir = fsf->create(tmpDirPath); tmpDir->createDirectory(true); } catch (exceptions::filesystem_exception&) @@ -759,7 +757,7 @@ void maildirFolder::addMessage(utility::inputStream& is, const int size, try { - ref curDir = fsf->create(dstDirPath); + shared_ptr curDir = fsf->create(dstDirPath); curDir->createDirectory(true); } catch (exceptions::filesystem_exception&) @@ -785,9 +783,9 @@ void maildirFolder::addMessage(utility::inputStream& is, const int size, std::vector nums; nums.push_back(m_messageCount); - ref event = - vmime::create - (thisRef().dynamicCast (), + shared_ptr event = + make_shared + (dynamicCast (shared_from_this()), events::messageCountEvent::TYPE_ADDED, nums); notifyMessageCount(event); @@ -804,9 +802,9 @@ void maildirFolder::addMessage(utility::inputStream& is, const int size, (*it)->m_messageInfos.resize(m_messageInfos.size()); std::copy(m_messageInfos.begin(), m_messageInfos.end(), (*it)->m_messageInfos.begin()); - ref event = - vmime::create - ((*it)->thisRef().dynamicCast (), + shared_ptr event = + make_shared + (dynamicCast ((*it)->shared_from_this()), events::messageCountEvent::TYPE_ADDED, nums); (*it)->notifyMessageCount(event); @@ -821,9 +819,9 @@ void maildirFolder::copyMessageImpl(const utility::file::path& tmpDirPath, utility::inputStream& is, const utility::stream::size_type size, utility::progressListener* progress) { - ref fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr fsf = platform::getHandler()->getFileSystemFactory(); - ref file = fsf->create(tmpDirPath / filename); + shared_ptr file = fsf->create(tmpDirPath / filename); if (progress) progress->start(size); @@ -833,8 +831,8 @@ void maildirFolder::copyMessageImpl(const utility::file::path& tmpDirPath, { file->createFile(); - ref fw = file->getFileWriter(); - ref os = fw->getOutputStream(); + shared_ptr fw = file->getFileWriter(); + shared_ptr os = fw->getOutputStream(); utility::stream::value_type buffer[65536]; utility::stream::size_type total = 0; @@ -863,7 +861,7 @@ void maildirFolder::copyMessageImpl(const utility::file::path& tmpDirPath, // Delete temporary file try { - ref file = fsf->create(tmpDirPath / filename); + shared_ptr file = fsf->create(tmpDirPath / filename); file->remove(); } catch (exceptions::filesystem_exception&) @@ -888,7 +886,7 @@ void maildirFolder::copyMessageImpl(const utility::file::path& tmpDirPath, try { file->remove(); - ref file = fsf->create(dstDirPath / filename); + shared_ptr file = fsf->create(dstDirPath / filename); file->remove(); } catch (exceptions::filesystem_exception&) @@ -906,14 +904,14 @@ void maildirFolder::copyMessageImpl(const utility::file::path& tmpDirPath, void maildirFolder::copyMessages(const folder::path& dest, const messageSet& msgs) { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); - ref fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr fsf = platform::getHandler()->getFileSystemFactory(); utility::file::path curDirPath = store->getFormat()->folderPathToFileSystemPath (m_path, maildirFormat::CUR_DIRECTORY); @@ -926,7 +924,7 @@ void maildirFolder::copyMessages(const folder::path& dest, const messageSet& msg // Create destination directories try { - ref destTmpDir = fsf->create(destTmpDirPath); + shared_ptr destTmpDir = fsf->create(destTmpDirPath); destTmpDir->createDirectory(true); } catch (exceptions::filesystem_exception&) @@ -936,7 +934,7 @@ void maildirFolder::copyMessages(const folder::path& dest, const messageSet& msg try { - ref destCurDir = fsf->create(destCurDirPath); + shared_ptr destCurDir = fsf->create(destCurDirPath); destCurDir->createDirectory(true); } catch (exceptions::filesystem_exception&) @@ -959,9 +957,9 @@ void maildirFolder::copyMessages(const folder::path& dest, const messageSet& msg const utility::file::path::component filename = maildirUtils::buildFilename(maildirUtils::generateId(), flags); - ref file = fsf->create(curDirPath / msg.path); - ref fr = file->getFileReader(); - ref is = fr->getInputStream(); + shared_ptr file = fsf->create(curDirPath / msg.path); + shared_ptr fr = file->getFileReader(); + shared_ptr is = fr->getInputStream(); copyMessageImpl(destTmpDirPath, destCurDirPath, filename, *is, file->getLength(), NULL); @@ -979,7 +977,7 @@ void maildirFolder::copyMessages(const folder::path& dest, const messageSet& msg void maildirFolder::notifyMessagesCopied(const folder::path& dest) { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); for (std::list ::iterator it = store->m_folders.begin() ; it != store->m_folders.end() ; ++it) @@ -1002,22 +1000,22 @@ void maildirFolder::status(int& count, int& unseen) count = 0; unseen = 0; - ref status = getStatus(); + shared_ptr status = getStatus(); count = status->getMessageCount(); unseen = status->getUnseenCount(); } -ref maildirFolder::getStatus() +shared_ptr maildirFolder::getStatus() { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); const int oldCount = m_messageCount; scanFolder(); - ref status = vmime::create (); + shared_ptr status = make_shared (); status->setMessageCount(m_messageCount); status->setUnseenCount(m_unreadMessageCount); @@ -1031,9 +1029,9 @@ ref maildirFolder::getStatus() for (int i = oldCount + 1, j = 0 ; i <= m_messageCount ; ++i, ++j) nums[j] = i; - ref event = - vmime::create - (thisRef().dynamicCast (), + shared_ptr event = + make_shared + (dynamicCast (shared_from_this()), events::messageCountEvent::TYPE_ADDED, nums); notifyMessageCount(event); @@ -1050,9 +1048,9 @@ ref maildirFolder::getStatus() (*it)->m_messageInfos.resize(m_messageInfos.size()); std::copy(m_messageInfos.begin(), m_messageInfos.end(), (*it)->m_messageInfos.begin()); - ref event = - vmime::create - ((*it)->thisRef().dynamicCast (), + shared_ptr event = + make_shared + (dynamicCast ((*it)->shared_from_this()), events::messageCountEvent::TYPE_ADDED, nums); (*it)->notifyMessageCount(event); @@ -1066,7 +1064,7 @@ ref maildirFolder::getStatus() void maildirFolder::expunge() { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); @@ -1075,7 +1073,7 @@ void maildirFolder::expunge() else if (m_mode == MODE_READ_ONLY) throw exceptions::illegal_state("Folder is read-only"); - ref fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr fsf = platform::getHandler()->getFileSystemFactory(); utility::file::path curDirPath = store->getFormat()-> folderPathToFileSystemPath(m_path, maildirFormat::CUR_DIRECTORY); @@ -1106,7 +1104,7 @@ void maildirFolder::expunge() // Delete file from file system try { - ref file = fsf->create(curDirPath / infos.path); + shared_ptr file = fsf->create(curDirPath / infos.path); file->remove(); } catch (exceptions::filesystem_exception& e) @@ -1126,9 +1124,9 @@ void maildirFolder::expunge() m_unreadMessageCount -= unreadCount; // Notify message expunged - ref event = - vmime::create - (thisRef().dynamicCast (), + shared_ptr event = + make_shared + (dynamicCast (shared_from_this()), events::messageCountEvent::TYPE_REMOVED, nums); notifyMessageCount(event); @@ -1145,9 +1143,9 @@ void maildirFolder::expunge() (*it)->m_messageInfos.resize(m_messageInfos.size()); std::copy(m_messageInfos.begin(), m_messageInfos.end(), (*it)->m_messageInfos.begin()); - ref event = - vmime::create - ((*it)->thisRef().dynamicCast (), + shared_ptr event = + make_shared + (dynamicCast ((*it)->shared_from_this()), events::messageCountEvent::TYPE_REMOVED, nums); (*it)->notifyMessageCount(event); @@ -1156,31 +1154,31 @@ void maildirFolder::expunge() } -ref maildirFolder::getParent() +shared_ptr maildirFolder::getParent() { if (m_path.isEmpty()) - return NULL; + return null; else - return vmime::create (m_path.getParent(), m_store.acquire()); + return make_shared (m_path.getParent(), m_store.lock()); } -ref maildirFolder::getStore() const +shared_ptr maildirFolder::getStore() const { - return m_store.acquire(); + return m_store.lock(); } -ref maildirFolder::getStore() +shared_ptr maildirFolder::getStore() { - return m_store.acquire(); + return m_store.lock(); } -void maildirFolder::fetchMessages(std::vector >& msg, +void maildirFolder::fetchMessages(std::vector >& msg, const fetchAttributes& options, utility::progressListener* progress) { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); @@ -1193,12 +1191,12 @@ void maildirFolder::fetchMessages(std::vector >& msg, if (progress) progress->start(total); - ref thisFolder = thisRef().dynamicCast (); + shared_ptr thisFolder = dynamicCast (shared_from_this()); - for (std::vector >::iterator it = msg.begin() ; + for (std::vector >::iterator it = msg.begin() ; it != msg.end() ; ++it) { - (*it).dynamicCast ()->fetch(thisFolder, options); + dynamicCast (*it)->fetch(thisFolder, options); if (progress) progress->progress(++current, total); @@ -1209,17 +1207,17 @@ void maildirFolder::fetchMessages(std::vector >& msg, } -void maildirFolder::fetchMessage(ref msg, const fetchAttributes& options) +void maildirFolder::fetchMessage(shared_ptr msg, const fetchAttributes& options) { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); - msg.dynamicCast ()->fetch - (thisRef().dynamicCast (), options); + dynamicCast (msg)->fetch + (dynamicCast (shared_from_this()), options); } @@ -1234,7 +1232,7 @@ int maildirFolder::getFetchCapabilities() const const utility::file::path maildirFolder::getMessageFSPath(const int number) const { - utility::file::path curDirPath = m_store.acquire()->getFormat()-> + utility::file::path curDirPath = m_store.lock()->getFormat()-> folderPathToFileSystemPath(m_path, maildirFormat::CUR_DIRECTORY); return (curDirPath / m_messageInfos[number - 1].path); diff --git a/src/net/maildir/maildirFolderStatus.cpp b/src/net/maildir/maildirFolderStatus.cpp index bc00ba28..9ee84dba 100644 --- a/src/net/maildir/maildirFolderStatus.cpp +++ b/src/net/maildir/maildirFolderStatus.cpp @@ -74,9 +74,9 @@ void maildirFolderStatus::setUnseenCount(const unsigned int unseen) } -ref maildirFolderStatus::clone() const +shared_ptr maildirFolderStatus::clone() const { - return vmime::create (*this); + return make_shared (*this); } diff --git a/src/net/maildir/maildirFormat.cpp b/src/net/maildir/maildirFormat.cpp index f1e9c66e..f7a3c8fe 100644 --- a/src/net/maildir/maildirFormat.cpp +++ b/src/net/maildir/maildirFormat.cpp @@ -50,15 +50,15 @@ const utility::file::path::component maildirFormat::NEW_DIR("new", vmime::charse // maildirFormat::context // -maildirFormat::context::context(ref store) +maildirFormat::context::context(shared_ptr store) : m_store(store) { } -ref maildirFormat::context::getStore() const +shared_ptr maildirFormat::context::getStore() const { - return m_store.acquire().constCast (); + return constCast (m_store.lock()); } @@ -66,37 +66,37 @@ ref maildirFormat::context::getStore() const // maildirFormat // -maildirFormat::maildirFormat(ref ctx) +maildirFormat::maildirFormat(shared_ptr ctx) : m_context(ctx) { } -ref maildirFormat::getContext() +shared_ptr maildirFormat::getContext() { return m_context; } -ref maildirFormat::getContext() const +shared_ptr maildirFormat::getContext() const { return m_context; } // static -ref maildirFormat::detect(ref store) +shared_ptr maildirFormat::detect(shared_ptr store) { - ref ctx = create (store); + shared_ptr ctx = make_shared (store); // Try Courier format - ref fmt = create (ctx); + shared_ptr fmt = make_shared (ctx); if (fmt->supports()) return fmt; // Default is KMail format - return create (ctx); + return make_shared (ctx); } diff --git a/src/net/maildir/maildirMessage.cpp b/src/net/maildir/maildirMessage.cpp index d20481d4..88d743b2 100644 --- a/src/net/maildir/maildirMessage.cpp +++ b/src/net/maildir/maildirMessage.cpp @@ -47,9 +47,9 @@ namespace net { namespace maildir { -maildirMessage::maildirMessage(ref folder, const int num) +maildirMessage::maildirMessage(shared_ptr folder, const int num) : m_folder(folder), m_num(num), m_size(-1), m_flags(FLAG_UNDEFINED), - m_expunged(false), m_structure(NULL) + m_expunged(false), m_structure(null) { folder->registerMessage(this); } @@ -57,7 +57,7 @@ maildirMessage::maildirMessage(ref folder, const int num) maildirMessage::~maildirMessage() { - ref folder = m_folder.acquire(); + shared_ptr folder = m_folder.lock(); if (folder) folder->unregisterMessage(this); @@ -66,7 +66,7 @@ maildirMessage::~maildirMessage() void maildirMessage::onFolderClosed() { - m_folder = NULL; + m_folder.reset(); } @@ -97,7 +97,7 @@ bool maildirMessage::isExpunged() const } -ref maildirMessage::getStructure() const +shared_ptr maildirMessage::getStructure() const { if (m_structure == NULL) throw exceptions::unfetched_object(); @@ -106,7 +106,7 @@ ref maildirMessage::getStructure() const } -ref maildirMessage::getStructure() +shared_ptr maildirMessage::getStructure() { if (m_structure == NULL) throw exceptions::unfetched_object(); @@ -115,7 +115,7 @@ ref maildirMessage::getStructure() } -ref maildirMessage::getHeader() const +shared_ptr maildirMessage::getHeader() const { if (m_header == NULL) throw exceptions::unfetched_object(); @@ -135,7 +135,7 @@ int maildirMessage::getFlags() const void maildirMessage::setFlags(const int flags, const int mode) { - ref folder = m_folder.acquire(); + shared_ptr folder = m_folder.lock(); if (!folder) throw exceptions::folder_not_found(); @@ -152,11 +152,11 @@ void maildirMessage::extract(utility::outputStream& os, } -void maildirMessage::extractPart(ref p, utility::outputStream& os, +void maildirMessage::extractPart(shared_ptr p, utility::outputStream& os, utility::progressListener* progress, const int start, const int length, const bool peek) const { - ref mp = p.dynamicCast (); + shared_ptr mp = dynamicCast (p); extractImpl(os, progress, mp->getBodyParsedOffset(), mp->getBodyParsedLength(), start, length, peek); @@ -167,15 +167,15 @@ 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 folder = m_folder.acquire(); + shared_ptr folder = m_folder.lock(); - ref fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr fsf = platform::getHandler()->getFileSystemFactory(); const utility::file::path path = folder->getMessageFSPath(m_num); - ref file = fsf->create(path); + shared_ptr file = fsf->create(path); - ref reader = file->getFileReader(); - ref is = reader->getInputStream(); + shared_ptr reader = file->getFileReader(); + shared_ptr is = reader->getInputStream(); is->skip(start + partialStart); @@ -210,19 +210,19 @@ void maildirMessage::extractImpl(utility::outputStream& os, utility::progressLis } -void maildirMessage::fetchPartHeader(ref p) +void maildirMessage::fetchPartHeader(shared_ptr p) { - ref folder = m_folder.acquire(); + shared_ptr folder = m_folder.lock(); - ref mp = p.dynamicCast (); + shared_ptr mp = dynamicCast (p); - ref fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr fsf = platform::getHandler()->getFileSystemFactory(); const utility::file::path path = folder->getMessageFSPath(m_num); - ref file = fsf->create(path); + shared_ptr file = fsf->create(path); - ref reader = file->getFileReader(); - ref is = reader->getInputStream(); + shared_ptr reader = file->getFileReader(); + shared_ptr is = reader->getInputStream(); is->skip(mp->getHeaderParsedOffset()); @@ -246,17 +246,17 @@ void maildirMessage::fetchPartHeader(ref p) } -void maildirMessage::fetch(ref msgFolder, const fetchAttributes& options) +void maildirMessage::fetch(shared_ptr msgFolder, const fetchAttributes& options) { - ref folder = m_folder.acquire(); + shared_ptr folder = m_folder.lock(); if (folder != msgFolder) throw exceptions::folder_not_found(); - ref fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr fsf = platform::getHandler()->getFileSystemFactory(); const utility::file::path path = folder->getMessageFSPath(m_num); - ref file = fsf->create(path); + shared_ptr file = fsf->create(path); if (options.has(fetchAttributes::FLAGS)) m_flags = maildirUtils::extractFlags(path.getLastComponent()); @@ -273,8 +273,8 @@ void maildirMessage::fetch(ref msgFolder, const fetchAttributes& { string contents; - ref reader = file->getFileReader(); - ref is = reader->getInputStream(); + shared_ptr reader = file->getFileReader(); + shared_ptr is = reader->getInputStream(); // Need whole message contents for structure if (options.has(fetchAttributes::STRUCTURE)) @@ -323,7 +323,7 @@ void maildirMessage::fetch(ref msgFolder, const fetchAttributes& // Extract structure if (options.has(fetchAttributes::STRUCTURE)) { - m_structure = vmime::create (null, msg); + m_structure = make_shared (shared_ptr (), msg); } // Extract some header fields or whole header @@ -338,23 +338,23 @@ void maildirMessage::fetch(ref msgFolder, const fetchAttributes& } -ref
maildirMessage::getOrCreateHeader() +shared_ptr
maildirMessage::getOrCreateHeader() { if (m_header != NULL) return (m_header); else - return (m_header = vmime::create
()); + return (m_header = make_shared
()); } -ref maildirMessage::getParsedMessage() +shared_ptr maildirMessage::getParsedMessage() { std::ostringstream oss; utility::outputStreamAdapter os(oss); extract(os); - vmime::ref msg = vmime::create (); + shared_ptr msg = make_shared (); msg->parse(oss.str()); return msg; diff --git a/src/net/maildir/maildirMessagePart.cpp b/src/net/maildir/maildirMessagePart.cpp index 75086ec3..683e259e 100644 --- a/src/net/maildir/maildirMessagePart.cpp +++ b/src/net/maildir/maildirMessagePart.cpp @@ -36,8 +36,8 @@ namespace net { namespace maildir { -maildirMessagePart::maildirMessagePart(ref parent, const int number, const bodyPart& part) - : m_parent(parent), m_header(NULL), m_number(number) +maildirMessagePart::maildirMessagePart(shared_ptr 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(); @@ -59,17 +59,17 @@ maildirMessagePart::~maildirMessagePart() void maildirMessagePart::initStructure(const bodyPart& part) { if (part.getBody()->getPartList().size() == 0) - m_structure = NULL; + m_structure = null; else { - m_structure = vmime::create - (thisRef().dynamicCast (), + m_structure = make_shared + (dynamicCast (shared_from_this()), part.getBody()->getPartList()); } } -ref maildirMessagePart::getStructure() const +shared_ptr maildirMessagePart::getStructure() const { if (m_structure != NULL) return m_structure; @@ -78,7 +78,7 @@ ref maildirMessagePart::getStructure() const } -ref maildirMessagePart::getStructure() +shared_ptr maildirMessagePart::getStructure() { if (m_structure != NULL) return m_structure; @@ -105,7 +105,7 @@ int maildirMessagePart::getNumber() const } -ref maildirMessagePart::getHeader() const +shared_ptr maildirMessagePart::getHeader() const { if (m_header == NULL) throw exceptions::unfetched_object(); @@ -119,7 +119,7 @@ header& maildirMessagePart::getOrCreateHeader() if (m_header != NULL) return *m_header; else - return *(m_header = vmime::create
()); + return *(m_header = make_shared
()); } diff --git a/src/net/maildir/maildirMessageStructure.cpp b/src/net/maildir/maildirMessageStructure.cpp index a0473f9e..f3b7cf59 100644 --- a/src/net/maildir/maildirMessageStructure.cpp +++ b/src/net/maildir/maildirMessageStructure.cpp @@ -36,7 +36,7 @@ namespace net { namespace maildir { -ref maildirMessageStructure::m_emptyStructure = vmime::create (); +shared_ptr maildirMessageStructure::m_emptyStructure = make_shared (); maildirMessageStructure::maildirMessageStructure() @@ -44,20 +44,20 @@ maildirMessageStructure::maildirMessageStructure() } -maildirMessageStructure::maildirMessageStructure(ref parent, const bodyPart& part) +maildirMessageStructure::maildirMessageStructure(shared_ptr parent, const bodyPart& part) { - vmime::ref mpart = vmime::create (parent, 0, part); + shared_ptr mpart = make_shared (parent, 0, part); mpart->initStructure(part); m_parts.push_back(mpart); } -maildirMessageStructure::maildirMessageStructure(ref parent, const std::vector >& list) +maildirMessageStructure::maildirMessageStructure(shared_ptr parent, const std::vector >& list) { for (unsigned int i = 0 ; i < list.size() ; ++i) { - vmime::ref mpart = vmime::create (parent, i, *list[i]); + shared_ptr mpart = make_shared (parent, i, *list[i]); mpart->initStructure(*list[i]); m_parts.push_back(mpart); @@ -65,13 +65,13 @@ maildirMessageStructure::maildirMessageStructure(ref parent } -ref maildirMessageStructure::getPartAt(const size_t x) const +shared_ptr maildirMessageStructure::getPartAt(const size_t x) const { return m_parts[x]; } -ref maildirMessageStructure::getPartAt(const size_t x) +shared_ptr maildirMessageStructure::getPartAt(const size_t x) { return m_parts[x]; } @@ -84,7 +84,7 @@ size_t maildirMessageStructure::getPartCount() const // static -ref maildirMessageStructure::emptyStructure() +shared_ptr maildirMessageStructure::emptyStructure() { return m_emptyStructure; } diff --git a/src/net/maildir/maildirStore.cpp b/src/net/maildir/maildirStore.cpp index 0fad6831..c7ceb6fa 100644 --- a/src/net/maildir/maildirStore.cpp +++ b/src/net/maildir/maildirStore.cpp @@ -32,8 +32,6 @@ #include "vmime/net/maildir/maildirFolder.hpp" #include "vmime/net/maildir/maildirFormat.hpp" -#include "vmime/utility/smartPtr.hpp" - #include "vmime/exception.hpp" #include "vmime/platform.hpp" @@ -54,7 +52,7 @@ namespace net { namespace maildir { -maildirStore::maildirStore(ref sess, ref auth) +maildirStore::maildirStore(shared_ptr sess, shared_ptr auth) : store(sess, getInfosInstance(), auth), m_connected(false) { } @@ -80,33 +78,35 @@ const string maildirStore::getProtocolName() const } -ref maildirStore::getRootFolder() +shared_ptr maildirStore::getRootFolder() { if (!isConnected()) throw exceptions::illegal_state("Not connected"); - return vmime::create (folder::path(), - thisRef().dynamicCast ()); + return make_shared + (folder::path(), + dynamicCast (shared_from_this())); } -ref maildirStore::getDefaultFolder() +shared_ptr maildirStore::getDefaultFolder() { if (!isConnected()) throw exceptions::illegal_state("Not connected"); - return vmime::create (folder::path::component("inbox"), - thisRef().dynamicCast ()); + return make_shared + (folder::path::component("inbox"), + dynamicCast (shared_from_this())); } -ref maildirStore::getFolder(const folder::path& path) +shared_ptr maildirStore::getFolder(const folder::path& path) { if (!isConnected()) throw exceptions::illegal_state("Not connected"); - return vmime::create (path, - thisRef().dynamicCast ()); + return make_shared + (path, dynamicCast (shared_from_this())); } @@ -138,11 +138,11 @@ void maildirStore::connect() throw exceptions::already_connected(); // Get root directory - ref fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr fsf = platform::getHandler()->getFileSystemFactory(); m_fsPath = fsf->stringToPath(GET_PROPERTY(string, PROPERTY_SERVER_ROOTPATH)); - ref rootDir = fsf->create(m_fsPath); + shared_ptr rootDir = fsf->create(m_fsPath); // Try to create the root directory if it does not exist if (!(rootDir->exists() && rootDir->isDirectory())) @@ -157,7 +157,7 @@ void maildirStore::connect() } } - m_format = maildirFormat::detect(thisRef().dynamicCast ()); + m_format = maildirFormat::detect(dynamicCast (shared_from_this())); m_connected = true; } @@ -175,9 +175,9 @@ bool maildirStore::isSecuredConnection() const } -ref maildirStore::getConnectionInfos() const +shared_ptr maildirStore::getConnectionInfos() const { - return vmime::create ("localhost", static_cast (0)); + return make_shared ("localhost", static_cast (0)); } @@ -201,13 +201,13 @@ void maildirStore::noop() } -ref maildirStore::getFormat() +shared_ptr maildirStore::getFormat() { return m_format; } -ref maildirStore::getFormat() const +shared_ptr maildirStore::getFormat() const { return m_format; } diff --git a/src/net/maildir/maildirUtils.cpp b/src/net/maildir/maildirUtils.cpp index c4ba2857..5a5ac90f 100644 --- a/src/net/maildir/maildirUtils.cpp +++ b/src/net/maildir/maildirUtils.cpp @@ -175,14 +175,14 @@ const utility::file::path::component maildirUtils::generateId() } -void maildirUtils::recursiveFSDelete(ref dir) +void maildirUtils::recursiveFSDelete(shared_ptr dir) { - ref files = dir->getFiles(); + shared_ptr files = dir->getFiles(); // First, delete files and subdirectories in this directory while (files->hasMoreElements()) { - ref file = files->nextElement(); + shared_ptr file = files->nextElement(); if (file->isDirectory()) { -- cgit