diff options
Diffstat (limited to 'src/net/maildir')
-rw-r--r-- | src/net/maildir/format/courierMaildirFormat.cpp | 50 | ||||
-rw-r--r-- | src/net/maildir/format/kmailMaildirFormat.cpp | 46 | ||||
-rw-r--r-- | src/net/maildir/maildirFolder.cpp | 238 | ||||
-rw-r--r-- | src/net/maildir/maildirFolderStatus.cpp | 4 | ||||
-rw-r--r-- | src/net/maildir/maildirFormat.cpp | 20 | ||||
-rw-r--r-- | src/net/maildir/maildirMessage.cpp | 66 | ||||
-rw-r--r-- | src/net/maildir/maildirMessagePart.cpp | 18 | ||||
-rw-r--r-- | src/net/maildir/maildirMessageStructure.cpp | 16 | ||||
-rw-r--r-- | src/net/maildir/maildirStore.cpp | 38 | ||||
-rw-r--r-- | src/net/maildir/maildirUtils.cpp | 6 |
10 files changed, 250 insertions, 252 deletions
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 <context> ctx) +courierMaildirFormat::courierMaildirFormat(shared_ptr <context> ctx) : maildirFormat(ctx) { } @@ -55,19 +55,19 @@ const string courierMaildirFormat::getName() const void courierMaildirFormat::createFolder(const folder::path& path) { - ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); if (!fsf->isValidPath(folderPathToFileSystemPath(path, ROOT_DIRECTORY))) throw exceptions::invalid_folder_name(); - ref <utility::file> rootDir = fsf->create + shared_ptr <utility::file> rootDir = fsf->create (folderPathToFileSystemPath(path, ROOT_DIRECTORY)); - ref <utility::file> newDir = fsf->create + shared_ptr <utility::file> newDir = fsf->create (folderPathToFileSystemPath(path, NEW_DIRECTORY)); - ref <utility::file> tmpDir = fsf->create + shared_ptr <utility::file> tmpDir = fsf->create (folderPathToFileSystemPath(path, TMP_DIRECTORY)); - ref <utility::file> curDir = fsf->create + shared_ptr <utility::file> 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 <utility::file> maildirFile = fsf->create + shared_ptr <utility::file> 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 <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); // Recursively delete directories of subfolders const std::vector <folder::path> folders = listFolders(path, true); @@ -125,7 +125,7 @@ void courierMaildirFormat::renameFolder void courierMaildirFormat::renameFolderImpl (const folder::path& oldPath, const folder::path& newPath) { - ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr <utility::fileSystemFactory> 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 <utility::file> rootDir = fsf->create(oldFSPath); + shared_ptr <utility::file> rootDir = fsf->create(oldFSPath); rootDir->rename(newFSPath); } bool courierMaildirFormat::folderExists(const folder::path& path) const { - ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); - ref <utility::file> rootDir = fsf->create + shared_ptr <utility::file> rootDir = fsf->create (folderPathToFileSystemPath(path, ROOT_DIRECTORY)); - ref <utility::file> newDir = fsf->create + shared_ptr <utility::file> newDir = fsf->create (folderPathToFileSystemPath(path, NEW_DIRECTORY)); - ref <utility::file> tmpDir = fsf->create + shared_ptr <utility::file> tmpDir = fsf->create (folderPathToFileSystemPath(path, TMP_DIRECTORY)); - ref <utility::file> curDir = fsf->create + shared_ptr <utility::file> curDir = fsf->create (folderPathToFileSystemPath(path, CUR_DIRECTORY)); - ref <utility::file> maildirFile = fsf->create + shared_ptr <utility::file> maildirFile = fsf->create (folderPathToFileSystemPath(path, ROOT_DIRECTORY) / utility::file::path::component("maildirfolder")); @@ -260,9 +260,9 @@ const std::vector <folder::path> courierMaildirFormat::listFolders bool courierMaildirFormat::listDirectories(const folder::path& root, std::vector <string>& dirs, const bool onlyTestForExistence) const { - ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); - ref <utility::file> rootDir = fsf->create + shared_ptr <utility::file> rootDir = fsf->create (getContext()->getStore()->getFileSystemPath()); if (rootDir->exists()) @@ -278,11 +278,11 @@ bool courierMaildirFormat::listDirectories(const folder::path& root, } // Enumerate directories - ref <utility::fileIterator> it = rootDir->getFiles(); + shared_ptr <utility::fileIterator> it = rootDir->getFiles(); while (it->hasMoreElements()) { - ref <utility::file> file = it->nextElement(); + shared_ptr <utility::file> file = it->nextElement(); if (isSubfolderDirectory(*file)) { @@ -502,24 +502,24 @@ const folder::path::component courierMaildirFormat::fromModifiedUTF7(const strin bool courierMaildirFormat::supports() const { - ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); - ref <utility::file> rootDir = fsf->create + shared_ptr <utility::file> 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 <utility::fileIterator> it = rootDir->getFiles(); + shared_ptr <utility::fileIterator> it = rootDir->getFiles(); while (it->hasMoreElements()) { - ref <utility::file> file = it->nextElement(); + shared_ptr <utility::file> file = it->nextElement(); if (isSubfolderDirectory(*file)) { - ref <utility::file> folderFile = fsf->create + shared_ptr <utility::file> 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 <context> ctx) +kmailMaildirFormat::kmailMaildirFormat(shared_ptr <context> ctx) : maildirFormat(ctx) { } @@ -55,19 +55,19 @@ const string kmailMaildirFormat::getName() const void kmailMaildirFormat::createFolder(const folder::path& path) { - ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); if (!fsf->isValidPath(folderPathToFileSystemPath(path, ROOT_DIRECTORY))) throw exceptions::invalid_folder_name(); - ref <utility::file> rootDir = fsf->create + shared_ptr <utility::file> rootDir = fsf->create (folderPathToFileSystemPath(path, ROOT_DIRECTORY)); - ref <utility::file> newDir = fsf->create + shared_ptr <utility::file> newDir = fsf->create (folderPathToFileSystemPath(path, NEW_DIRECTORY)); - ref <utility::file> tmpDir = fsf->create + shared_ptr <utility::file> tmpDir = fsf->create (folderPathToFileSystemPath(path, TMP_DIRECTORY)); - ref <utility::file> curDir = fsf->create + shared_ptr <utility::file> 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 <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr <utility::fileSystemFactory> 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 <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); - ref <utility::file> rootDir = fsf->create + shared_ptr <utility::file> rootDir = fsf->create (folderPathToFileSystemPath(path, ROOT_DIRECTORY)); - ref <utility::file> newDir = fsf->create + shared_ptr <utility::file> newDir = fsf->create (folderPathToFileSystemPath(path, NEW_DIRECTORY)); - ref <utility::file> tmpDir = fsf->create + shared_ptr <utility::file> tmpDir = fsf->create (folderPathToFileSystemPath(path, TMP_DIRECTORY)); - ref <utility::file> curDir = fsf->create + shared_ptr <utility::file> curDir = fsf->create (folderPathToFileSystemPath(path, CUR_DIRECTORY)); return rootDir->exists() && rootDir->isDirectory() && @@ -183,18 +183,18 @@ const std::vector <folder::path> kmailMaildirFormat::listFolders void kmailMaildirFormat::listFoldersImpl (std::vector <folder::path>& list, const folder::path& root, const bool recursive) const { - ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); - ref <utility::file> rootDir = fsf->create(folderPathToFileSystemPath(root, + shared_ptr <utility::file> rootDir = fsf->create(folderPathToFileSystemPath(root, root.isEmpty() ? ROOT_DIRECTORY : CONTAINER_DIRECTORY)); if (rootDir->exists()) { - ref <utility::fileIterator> it = rootDir->getFiles(); + shared_ptr <utility::fileIterator> it = rootDir->getFiles(); while (it->hasMoreElements()) { - ref <utility::file> file = it->nextElement(); + shared_ptr <utility::file> 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 <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); - ref <utility::file> rootDir = fsf->create + shared_ptr <utility::file> rootDir = fsf->create (folderPathToFileSystemPath(oldPath, ROOT_DIRECTORY)); - ref <utility::file> contDir = fsf->create + shared_ptr <utility::file> 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 <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); - ref <utility::file> rootDir = fsf->create + shared_ptr <utility::file> rootDir = fsf->create (folderPathToFileSystemPath(path, CONTAINER_DIRECTORY)); - ref <utility::fileIterator> it = rootDir->getFiles(); + shared_ptr <utility::fileIterator> it = rootDir->getFiles(); while (it->hasMoreElements()) { - ref <utility::file> file = it->nextElement(); + shared_ptr <utility::file> 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 <maildirStore> store) +maildirFolder::maildirFolder(const folder::path& path, shared_ptr <maildirStore> 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 <maildirStore> store) maildirFolder::~maildirFolder() { - ref <maildirStore> store = m_store.acquire(); + shared_ptr <maildirStore> 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 <maildirStore> store = m_store.acquire(); + shared_ptr <maildirStore> 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 <maildirStore> store = m_store.acquire(); + shared_ptr <maildirStore> 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 <maildirStore> store = m_store.acquire(); + shared_ptr <maildirStore> 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 <events::folderEvent> event = - vmime::create <events::folderEvent> - (thisRef().dynamicCast <folder>(), + shared_ptr <events::folderEvent> event = + make_shared <events::folderEvent> + (dynamicCast <folder>(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 <maildirStore> store = m_store.acquire(); + shared_ptr <maildirStore> store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); @@ -244,9 +242,9 @@ void maildirFolder::destroy() } // Notify folder deleted - ref <events::folderEvent> event = - vmime::create <events::folderEvent> - (thisRef().dynamicCast <folder>(), + shared_ptr <events::folderEvent> event = + make_shared <events::folderEvent> + (dynamicCast <folder>(shared_from_this()), events::folderEvent::TYPE_DELETED, m_path, m_path); notifyFolder(event); @@ -255,7 +253,7 @@ void maildirFolder::destroy() bool maildirFolder::exists() { - ref <maildirStore> store = m_store.acquire(); + shared_ptr <maildirStore> store = m_store.lock(); return store->getFormat()->folderExists(m_path); } @@ -269,42 +267,42 @@ bool maildirFolder::isOpen() const void maildirFolder::scanFolder() { - ref <maildirStore> store = m_store.acquire(); + shared_ptr <maildirStore> store = m_store.lock(); try { m_messageCount = 0; m_unreadMessageCount = 0; - ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); utility::file::path newDirPath = store->getFormat()->folderPathToFileSystemPath (m_path, maildirFormat::NEW_DIRECTORY); - ref <utility::file> newDir = fsf->create(newDirPath); + shared_ptr <utility::file> newDir = fsf->create(newDirPath); utility::file::path curDirPath = store->getFormat()->folderPathToFileSystemPath (m_path, maildirFormat::CUR_DIRECTORY); - ref <utility::file> curDir = fsf->create(curDirPath); + shared_ptr <utility::file> curDir = fsf->create(curDirPath); // New received messages (new/) - ref <utility::fileIterator> nit = newDir->getFiles(); + shared_ptr <utility::fileIterator> nit = newDir->getFiles(); std::vector <utility::file::path::component> newMessageFilenames; while (nit->hasMoreElements()) { - ref <utility::file> file = nit->nextElement(); + shared_ptr <utility::file> file = nit->nextElement(); if (maildirUtils::isMessageFile(*file)) newMessageFilenames.push_back(file->getFullPath().getLastComponent()); } // Current messages (cur/) - ref <utility::fileIterator> cit = curDir->getFiles(); + shared_ptr <utility::fileIterator> cit = curDir->getFiles(); std::vector <utility::file::path::component> curMessageFilenames; while (cit->hasMoreElements()) { - ref <utility::file> file = cit->nextElement(); + shared_ptr <utility::file> 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 <utility::file> file = fsf->create(newDirPath / *it); + shared_ptr <utility::file> file = fsf->create(newDirPath / *it); file->rename(curDirPath / newFilename); // Append to message list @@ -406,7 +404,7 @@ void maildirFolder::scanFolder() } -ref <message> maildirFolder::getMessage(const int num) +shared_ptr <message> maildirFolder::getMessage(const int num) { if (!isOpen()) throw exceptions::illegal_state("Folder not open"); @@ -414,12 +412,12 @@ ref <message> maildirFolder::getMessage(const int num) if (num < 1 || num > m_messageCount) throw exceptions::message_not_found(); - return vmime::create <maildirMessage> - (thisRef().dynamicCast <maildirFolder>(), num); + return make_shared <maildirMessage> + (dynamicCast <maildirFolder>(shared_from_this()), num); } -std::vector <ref <message> > maildirFolder::getMessages(const messageSet& msgs) +std::vector <shared_ptr <message> > maildirFolder::getMessages(const messageSet& msgs) { if (!isOpen()) throw exceptions::illegal_state("Folder not open"); @@ -428,15 +426,15 @@ std::vector <ref <message> > maildirFolder::getMessages(const messageSet& msgs) { const std::vector <int> numbers = maildirUtils::messageSetToNumberList(msgs); - std::vector <ref <message> > messages; - ref <maildirFolder> thisFolder = thisRef().dynamicCast <maildirFolder>(); + std::vector <shared_ptr <message> > messages; + shared_ptr <maildirFolder> thisFolder = dynamicCast <maildirFolder>(shared_from_this()); for (std::vector <int>::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 <maildirMessage>(thisFolder, *it)); + messages.push_back(make_shared <maildirMessage>(thisFolder, *it)); } return messages; @@ -454,25 +452,25 @@ int maildirFolder::getMessageCount() } -ref <folder> maildirFolder::getFolder(const folder::path::component& name) +shared_ptr <folder> maildirFolder::getFolder(const folder::path::component& name) { - ref <maildirStore> store = m_store.acquire(); + shared_ptr <maildirStore> store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); - return vmime::create <maildirFolder>(m_path / name, store); + return make_shared <maildirFolder>(m_path / name, store); } -std::vector <ref <folder> > maildirFolder::getFolders(const bool recursive) +std::vector <shared_ptr <folder> > maildirFolder::getFolders(const bool recursive) { - ref <maildirStore> store = m_store.acquire(); + shared_ptr <maildirStore> store = m_store.lock(); if (!isOpen() && !store) throw exceptions::illegal_state("Store disconnected"); - std::vector <ref <folder> > list; + std::vector <shared_ptr <folder> > list; listFolders(list, recursive); @@ -480,9 +478,9 @@ std::vector <ref <folder> > maildirFolder::getFolders(const bool recursive) } -void maildirFolder::listFolders(std::vector <ref <folder> >& list, const bool recursive) +void maildirFolder::listFolders(std::vector <shared_ptr <folder> >& list, const bool recursive) { - ref <maildirStore> store = m_store.acquire(); + shared_ptr <maildirStore> store = m_store.lock(); try { @@ -493,8 +491,8 @@ void maildirFolder::listFolders(std::vector <ref <folder> >& list, const bool re for (std::vector <folder::path>::size_type i = 0, n = pathList.size() ; i < n ; ++i) { - ref <maildirFolder> subFolder = - vmime::create <maildirFolder>(pathList[i], store); + shared_ptr <maildirFolder> subFolder = + make_shared <maildirFolder>(pathList[i], store); list.push_back(subFolder); } @@ -508,7 +506,7 @@ void maildirFolder::listFolders(std::vector <ref <folder> >& list, const bool re void maildirFolder::rename(const folder::path& newPath) { - ref <maildirStore> store = m_store.acquire(); + shared_ptr <maildirStore> 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 <events::folderEvent> event = - vmime::create <events::folderEvent> - (thisRef().dynamicCast <folder>(), + shared_ptr <events::folderEvent> event = + make_shared <events::folderEvent> + (dynamicCast <folder>(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 <events::folderEvent> event = - vmime::create <events::folderEvent> - ((*it)->thisRef().dynamicCast <folder>(), + shared_ptr <events::folderEvent> event = + make_shared <events::folderEvent> + (dynamicCast <folder>((*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 <events::folderEvent> event = - vmime::create <events::folderEvent> - ((*it)->thisRef().dynamicCast <folder>(), + shared_ptr <events::folderEvent> event = + make_shared <events::folderEvent> + (dynamicCast <folder>((*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 <maildirStore> store = m_store.acquire(); + shared_ptr <maildirStore> store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); @@ -597,7 +595,7 @@ void maildirFolder::setMessageFlags const std::vector <int> nums = maildirUtils::messageSetToNumberList(msgs); // Change message flags - ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr <utility::fileSystemFactory> 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 <utility::file> file = fsf->create(curDirPath / path); + shared_ptr <utility::file> file = fsf->create(curDirPath / path); int newFlags = maildirUtils::extractFlags(path); @@ -690,9 +688,9 @@ void maildirFolder::setMessageFlags } // Notify message flags changed - ref <events::messageChangedEvent> event = - vmime::create <events::messageChangedEvent> - (thisRef().dynamicCast <folder>(), + shared_ptr <events::messageChangedEvent> event = + make_shared <events::messageChangedEvent> + (dynamicCast <folder>(shared_from_this()), events::messageChangedEvent::TYPE_FLAGS, nums); notifyMessageChanged(event); @@ -706,7 +704,7 @@ void maildirFolder::setMessageFlags } -void maildirFolder::addMessage(ref <vmime::message> msg, const int flags, +void maildirFolder::addMessage(shared_ptr <vmime::message> msg, const int flags, vmime::datetime* date, utility::progressListener* progress) { std::ostringstream oss; @@ -724,7 +722,7 @@ void maildirFolder::addMessage(ref <vmime::message> msg, const int flags, void maildirFolder::addMessage(utility::inputStream& is, const int size, const int flags, vmime::datetime* /* date */, utility::progressListener* progress) { - ref <maildirStore> store = m_store.acquire(); + shared_ptr <maildirStore> 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 <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr <utility::fileSystemFactory> 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 <utility::file> tmpDir = fsf->create(tmpDirPath); + shared_ptr <utility::file> 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 <utility::file> curDir = fsf->create(dstDirPath); + shared_ptr <utility::file> 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 <int> nums; nums.push_back(m_messageCount); - ref <events::messageCountEvent> event = - vmime::create <events::messageCountEvent> - (thisRef().dynamicCast <folder>(), + shared_ptr <events::messageCountEvent> event = + make_shared <events::messageCountEvent> + (dynamicCast <folder>(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 <events::messageCountEvent> event = - vmime::create <events::messageCountEvent> - ((*it)->thisRef().dynamicCast <folder>(), + shared_ptr <events::messageCountEvent> event = + make_shared <events::messageCountEvent> + (dynamicCast <folder>((*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 <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); - ref <utility::file> file = fsf->create(tmpDirPath / filename); + shared_ptr <utility::file> 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 <utility::fileWriter> fw = file->getFileWriter(); - ref <utility::outputStream> os = fw->getOutputStream(); + shared_ptr <utility::fileWriter> fw = file->getFileWriter(); + shared_ptr <utility::outputStream> 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 <utility::file> file = fsf->create(tmpDirPath / filename); + shared_ptr <utility::file> 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 <utility::file> file = fsf->create(dstDirPath / filename); + shared_ptr <utility::file> 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 <maildirStore> store = m_store.acquire(); + shared_ptr <maildirStore> store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); - ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr <utility::fileSystemFactory> 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 <utility::file> destTmpDir = fsf->create(destTmpDirPath); + shared_ptr <utility::file> 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 <utility::file> destCurDir = fsf->create(destCurDirPath); + shared_ptr <utility::file> 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 <utility::file> file = fsf->create(curDirPath / msg.path); - ref <utility::fileReader> fr = file->getFileReader(); - ref <utility::inputStream> is = fr->getInputStream(); + shared_ptr <utility::file> file = fsf->create(curDirPath / msg.path); + shared_ptr <utility::fileReader> fr = file->getFileReader(); + shared_ptr <utility::inputStream> 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 <maildirStore> store = m_store.acquire(); + shared_ptr <maildirStore> store = m_store.lock(); for (std::list <maildirFolder*>::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 <folderStatus> status = getStatus(); + shared_ptr <folderStatus> status = getStatus(); count = status->getMessageCount(); unseen = status->getUnseenCount(); } -ref <folderStatus> maildirFolder::getStatus() +shared_ptr <folderStatus> maildirFolder::getStatus() { - ref <maildirStore> store = m_store.acquire(); + shared_ptr <maildirStore> store = m_store.lock(); const int oldCount = m_messageCount; scanFolder(); - ref <maildirFolderStatus> status = vmime::create <maildirFolderStatus>(); + shared_ptr <maildirFolderStatus> status = make_shared <maildirFolderStatus>(); status->setMessageCount(m_messageCount); status->setUnseenCount(m_unreadMessageCount); @@ -1031,9 +1029,9 @@ ref <folderStatus> maildirFolder::getStatus() for (int i = oldCount + 1, j = 0 ; i <= m_messageCount ; ++i, ++j) nums[j] = i; - ref <events::messageCountEvent> event = - vmime::create <events::messageCountEvent> - (thisRef().dynamicCast <folder>(), + shared_ptr <events::messageCountEvent> event = + make_shared <events::messageCountEvent> + (dynamicCast <folder>(shared_from_this()), events::messageCountEvent::TYPE_ADDED, nums); notifyMessageCount(event); @@ -1050,9 +1048,9 @@ ref <folderStatus> maildirFolder::getStatus() (*it)->m_messageInfos.resize(m_messageInfos.size()); std::copy(m_messageInfos.begin(), m_messageInfos.end(), (*it)->m_messageInfos.begin()); - ref <events::messageCountEvent> event = - vmime::create <events::messageCountEvent> - ((*it)->thisRef().dynamicCast <folder>(), + shared_ptr <events::messageCountEvent> event = + make_shared <events::messageCountEvent> + (dynamicCast <folder>((*it)->shared_from_this()), events::messageCountEvent::TYPE_ADDED, nums); (*it)->notifyMessageCount(event); @@ -1066,7 +1064,7 @@ ref <folderStatus> maildirFolder::getStatus() void maildirFolder::expunge() { - ref <maildirStore> store = m_store.acquire(); + shared_ptr <maildirStore> 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 <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr <utility::fileSystemFactory> 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 <utility::file> file = fsf->create(curDirPath / infos.path); + shared_ptr <utility::file> 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 <events::messageCountEvent> event = - vmime::create <events::messageCountEvent> - (thisRef().dynamicCast <folder>(), + shared_ptr <events::messageCountEvent> event = + make_shared <events::messageCountEvent> + (dynamicCast <folder>(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 <events::messageCountEvent> event = - vmime::create <events::messageCountEvent> - ((*it)->thisRef().dynamicCast <folder>(), + shared_ptr <events::messageCountEvent> event = + make_shared <events::messageCountEvent> + (dynamicCast <folder>((*it)->shared_from_this()), events::messageCountEvent::TYPE_REMOVED, nums); (*it)->notifyMessageCount(event); @@ -1156,31 +1154,31 @@ void maildirFolder::expunge() } -ref <folder> maildirFolder::getParent() +shared_ptr <folder> maildirFolder::getParent() { if (m_path.isEmpty()) - return NULL; + return null; else - return vmime::create <maildirFolder>(m_path.getParent(), m_store.acquire()); + return make_shared <maildirFolder>(m_path.getParent(), m_store.lock()); } -ref <const store> maildirFolder::getStore() const +shared_ptr <const store> maildirFolder::getStore() const { - return m_store.acquire(); + return m_store.lock(); } -ref <store> maildirFolder::getStore() +shared_ptr <store> maildirFolder::getStore() { - return m_store.acquire(); + return m_store.lock(); } -void maildirFolder::fetchMessages(std::vector <ref <message> >& msg, +void maildirFolder::fetchMessages(std::vector <shared_ptr <message> >& msg, const fetchAttributes& options, utility::progressListener* progress) { - ref <maildirStore> store = m_store.acquire(); + shared_ptr <maildirStore> store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); @@ -1193,12 +1191,12 @@ void maildirFolder::fetchMessages(std::vector <ref <message> >& msg, if (progress) progress->start(total); - ref <maildirFolder> thisFolder = thisRef().dynamicCast <maildirFolder>(); + shared_ptr <maildirFolder> thisFolder = dynamicCast <maildirFolder>(shared_from_this()); - for (std::vector <ref <message> >::iterator it = msg.begin() ; + for (std::vector <shared_ptr <message> >::iterator it = msg.begin() ; it != msg.end() ; ++it) { - (*it).dynamicCast <maildirMessage>()->fetch(thisFolder, options); + dynamicCast <maildirMessage>(*it)->fetch(thisFolder, options); if (progress) progress->progress(++current, total); @@ -1209,17 +1207,17 @@ void maildirFolder::fetchMessages(std::vector <ref <message> >& msg, } -void maildirFolder::fetchMessage(ref <message> msg, const fetchAttributes& options) +void maildirFolder::fetchMessage(shared_ptr <message> msg, const fetchAttributes& options) { - ref <maildirStore> store = m_store.acquire(); + shared_ptr <maildirStore> store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); - msg.dynamicCast <maildirMessage>()->fetch - (thisRef().dynamicCast <maildirFolder>(), options); + dynamicCast <maildirMessage>(msg)->fetch + (dynamicCast <maildirFolder>(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 <folderStatus> maildirFolderStatus::clone() const +shared_ptr <folderStatus> maildirFolderStatus::clone() const { - return vmime::create <maildirFolderStatus>(*this); + return make_shared <maildirFolderStatus>(*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 <maildirStore> store) +maildirFormat::context::context(shared_ptr <maildirStore> store) : m_store(store) { } -ref <maildirStore> maildirFormat::context::getStore() const +shared_ptr <maildirStore> maildirFormat::context::getStore() const { - return m_store.acquire().constCast <maildirStore>(); + return constCast <maildirStore>(m_store.lock()); } @@ -66,37 +66,37 @@ ref <maildirStore> maildirFormat::context::getStore() const // maildirFormat // -maildirFormat::maildirFormat(ref <context> ctx) +maildirFormat::maildirFormat(shared_ptr <context> ctx) : m_context(ctx) { } -ref <maildirFormat::context> maildirFormat::getContext() +shared_ptr <maildirFormat::context> maildirFormat::getContext() { return m_context; } -ref <const maildirFormat::context> maildirFormat::getContext() const +shared_ptr <const maildirFormat::context> maildirFormat::getContext() const { return m_context; } // static -ref <maildirFormat> maildirFormat::detect(ref <maildirStore> store) +shared_ptr <maildirFormat> maildirFormat::detect(shared_ptr <maildirStore> store) { - ref <context> ctx = create <context>(store); + shared_ptr <context> ctx = make_shared <context>(store); // Try Courier format - ref <maildirFormat> fmt = create <format::courierMaildirFormat>(ctx); + shared_ptr <maildirFormat> fmt = make_shared <format::courierMaildirFormat>(ctx); if (fmt->supports()) return fmt; // Default is KMail format - return create <format::kmailMaildirFormat>(ctx); + return make_shared <format::kmailMaildirFormat>(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 <maildirFolder> folder, const int num) +maildirMessage::maildirMessage(shared_ptr <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_expunged(false), m_structure(null) { folder->registerMessage(this); } @@ -57,7 +57,7 @@ maildirMessage::maildirMessage(ref <maildirFolder> folder, const int num) maildirMessage::~maildirMessage() { - ref <maildirFolder> folder = m_folder.acquire(); + shared_ptr <maildirFolder> 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 <const messageStructure> maildirMessage::getStructure() const +shared_ptr <const messageStructure> maildirMessage::getStructure() const { if (m_structure == NULL) throw exceptions::unfetched_object(); @@ -106,7 +106,7 @@ ref <const messageStructure> maildirMessage::getStructure() const } -ref <messageStructure> maildirMessage::getStructure() +shared_ptr <messageStructure> maildirMessage::getStructure() { if (m_structure == NULL) throw exceptions::unfetched_object(); @@ -115,7 +115,7 @@ ref <messageStructure> maildirMessage::getStructure() } -ref <const header> maildirMessage::getHeader() const +shared_ptr <const header> 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 <maildirFolder> folder = m_folder.acquire(); + shared_ptr <maildirFolder> 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 <const messagePart> p, utility::outputStream& os, +void maildirMessage::extractPart(shared_ptr <const messagePart> p, utility::outputStream& os, utility::progressListener* progress, const int start, const int length, const bool peek) const { - ref <const maildirMessagePart> mp = p.dynamicCast <const maildirMessagePart>(); + shared_ptr <const maildirMessagePart> mp = dynamicCast <const maildirMessagePart>(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 <const maildirFolder> folder = m_folder.acquire(); + shared_ptr <const maildirFolder> folder = m_folder.lock(); - ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); const utility::file::path path = folder->getMessageFSPath(m_num); - ref <utility::file> file = fsf->create(path); + shared_ptr <utility::file> file = fsf->create(path); - ref <utility::fileReader> reader = file->getFileReader(); - ref <utility::inputStream> is = reader->getInputStream(); + shared_ptr <utility::fileReader> reader = file->getFileReader(); + shared_ptr <utility::inputStream> is = reader->getInputStream(); is->skip(start + partialStart); @@ -210,19 +210,19 @@ void maildirMessage::extractImpl(utility::outputStream& os, utility::progressLis } -void maildirMessage::fetchPartHeader(ref <messagePart> p) +void maildirMessage::fetchPartHeader(shared_ptr <messagePart> p) { - ref <maildirFolder> folder = m_folder.acquire(); + shared_ptr <maildirFolder> folder = m_folder.lock(); - ref <maildirMessagePart> mp = p.dynamicCast <maildirMessagePart>(); + shared_ptr <maildirMessagePart> mp = dynamicCast <maildirMessagePart>(p); - ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); const utility::file::path path = folder->getMessageFSPath(m_num); - ref <utility::file> file = fsf->create(path); + shared_ptr <utility::file> file = fsf->create(path); - ref <utility::fileReader> reader = file->getFileReader(); - ref <utility::inputStream> is = reader->getInputStream(); + shared_ptr <utility::fileReader> reader = file->getFileReader(); + shared_ptr <utility::inputStream> is = reader->getInputStream(); is->skip(mp->getHeaderParsedOffset()); @@ -246,17 +246,17 @@ void maildirMessage::fetchPartHeader(ref <messagePart> p) } -void maildirMessage::fetch(ref <maildirFolder> msgFolder, const fetchAttributes& options) +void maildirMessage::fetch(shared_ptr <maildirFolder> msgFolder, const fetchAttributes& options) { - ref <maildirFolder> folder = m_folder.acquire(); + shared_ptr <maildirFolder> folder = m_folder.lock(); if (folder != msgFolder) throw exceptions::folder_not_found(); - ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); const utility::file::path path = folder->getMessageFSPath(m_num); - ref <utility::file> file = fsf->create(path); + shared_ptr <utility::file> file = fsf->create(path); if (options.has(fetchAttributes::FLAGS)) m_flags = maildirUtils::extractFlags(path.getLastComponent()); @@ -273,8 +273,8 @@ void maildirMessage::fetch(ref <maildirFolder> msgFolder, const fetchAttributes& { string contents; - ref <utility::fileReader> reader = file->getFileReader(); - ref <utility::inputStream> is = reader->getInputStream(); + shared_ptr <utility::fileReader> reader = file->getFileReader(); + shared_ptr <utility::inputStream> is = reader->getInputStream(); // Need whole message contents for structure if (options.has(fetchAttributes::STRUCTURE)) @@ -323,7 +323,7 @@ void maildirMessage::fetch(ref <maildirFolder> msgFolder, const fetchAttributes& // Extract structure if (options.has(fetchAttributes::STRUCTURE)) { - m_structure = vmime::create <maildirMessageStructure>(null, msg); + m_structure = make_shared <maildirMessageStructure>(shared_ptr <maildirMessagePart>(), msg); } // Extract some header fields or whole header @@ -338,23 +338,23 @@ void maildirMessage::fetch(ref <maildirFolder> msgFolder, const fetchAttributes& } -ref <header> maildirMessage::getOrCreateHeader() +shared_ptr <header> maildirMessage::getOrCreateHeader() { if (m_header != NULL) return (m_header); else - return (m_header = vmime::create <header>()); + return (m_header = make_shared <header>()); } -ref <vmime::message> maildirMessage::getParsedMessage() +shared_ptr <vmime::message> maildirMessage::getParsedMessage() { std::ostringstream oss; utility::outputStreamAdapter os(oss); extract(os); - vmime::ref <vmime::message> msg = vmime::create <vmime::message>(); + shared_ptr <vmime::message> msg = make_shared <vmime::message>(); 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 <maildirMessagePart> parent, const int number, const bodyPart& part) - : m_parent(parent), m_header(NULL), m_number(number) +maildirMessagePart::maildirMessagePart(shared_ptr <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(); @@ -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 <maildirMessageStructure> - (thisRef().dynamicCast <maildirMessagePart>(), + m_structure = make_shared <maildirMessageStructure> + (dynamicCast <maildirMessagePart>(shared_from_this()), part.getBody()->getPartList()); } } -ref <const messageStructure> maildirMessagePart::getStructure() const +shared_ptr <const messageStructure> maildirMessagePart::getStructure() const { if (m_structure != NULL) return m_structure; @@ -78,7 +78,7 @@ ref <const messageStructure> maildirMessagePart::getStructure() const } -ref <messageStructure> maildirMessagePart::getStructure() +shared_ptr <messageStructure> maildirMessagePart::getStructure() { if (m_structure != NULL) return m_structure; @@ -105,7 +105,7 @@ int maildirMessagePart::getNumber() const } -ref <const header> maildirMessagePart::getHeader() const +shared_ptr <const header> 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 <header>()); + return *(m_header = make_shared <header>()); } 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> maildirMessageStructure::m_emptyStructure = vmime::create <maildirMessageStructure>(); +shared_ptr <maildirMessageStructure> maildirMessageStructure::m_emptyStructure = make_shared <maildirMessageStructure>(); maildirMessageStructure::maildirMessageStructure() @@ -44,20 +44,20 @@ maildirMessageStructure::maildirMessageStructure() } -maildirMessageStructure::maildirMessageStructure(ref <maildirMessagePart> parent, const bodyPart& part) +maildirMessageStructure::maildirMessageStructure(shared_ptr <maildirMessagePart> parent, const bodyPart& part) { - vmime::ref <maildirMessagePart> mpart = vmime::create <maildirMessagePart>(parent, 0, part); + shared_ptr <maildirMessagePart> mpart = make_shared <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) +maildirMessageStructure::maildirMessageStructure(shared_ptr <maildirMessagePart> parent, const std::vector <shared_ptr <const vmime::bodyPart> >& list) { for (unsigned int i = 0 ; i < list.size() ; ++i) { - vmime::ref <maildirMessagePart> mpart = vmime::create <maildirMessagePart>(parent, i, *list[i]); + shared_ptr <maildirMessagePart> mpart = make_shared <maildirMessagePart>(parent, i, *list[i]); mpart->initStructure(*list[i]); m_parts.push_back(mpart); @@ -65,13 +65,13 @@ maildirMessageStructure::maildirMessageStructure(ref <maildirMessagePart> parent } -ref <const messagePart> maildirMessageStructure::getPartAt(const size_t x) const +shared_ptr <const messagePart> maildirMessageStructure::getPartAt(const size_t x) const { return m_parts[x]; } -ref <messagePart> maildirMessageStructure::getPartAt(const size_t x) +shared_ptr <messagePart> maildirMessageStructure::getPartAt(const size_t x) { return m_parts[x]; } @@ -84,7 +84,7 @@ size_t maildirMessageStructure::getPartCount() const // static -ref <maildirMessageStructure> maildirMessageStructure::emptyStructure() +shared_ptr <maildirMessageStructure> 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 <session> sess, ref <security::authenticator> auth) +maildirStore::maildirStore(shared_ptr <session> sess, shared_ptr <security::authenticator> auth) : store(sess, getInfosInstance(), auth), m_connected(false) { } @@ -80,33 +78,35 @@ const string maildirStore::getProtocolName() const } -ref <folder> maildirStore::getRootFolder() +shared_ptr <folder> maildirStore::getRootFolder() { if (!isConnected()) throw exceptions::illegal_state("Not connected"); - return vmime::create <maildirFolder>(folder::path(), - thisRef().dynamicCast <maildirStore>()); + return make_shared <maildirFolder> + (folder::path(), + dynamicCast <maildirStore>(shared_from_this())); } -ref <folder> maildirStore::getDefaultFolder() +shared_ptr <folder> maildirStore::getDefaultFolder() { if (!isConnected()) throw exceptions::illegal_state("Not connected"); - return vmime::create <maildirFolder>(folder::path::component("inbox"), - thisRef().dynamicCast <maildirStore>()); + return make_shared <maildirFolder> + (folder::path::component("inbox"), + dynamicCast <maildirStore>(shared_from_this())); } -ref <folder> maildirStore::getFolder(const folder::path& path) +shared_ptr <folder> maildirStore::getFolder(const folder::path& path) { if (!isConnected()) throw exceptions::illegal_state("Not connected"); - return vmime::create <maildirFolder>(path, - thisRef().dynamicCast <maildirStore>()); + return make_shared <maildirFolder> + (path, dynamicCast <maildirStore>(shared_from_this())); } @@ -138,11 +138,11 @@ void maildirStore::connect() throw exceptions::already_connected(); // Get root directory - ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory(); m_fsPath = fsf->stringToPath(GET_PROPERTY(string, PROPERTY_SERVER_ROOTPATH)); - ref <utility::file> rootDir = fsf->create(m_fsPath); + shared_ptr <utility::file> 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 <maildirStore>()); + m_format = maildirFormat::detect(dynamicCast <maildirStore>(shared_from_this())); m_connected = true; } @@ -175,9 +175,9 @@ bool maildirStore::isSecuredConnection() const } -ref <connectionInfos> maildirStore::getConnectionInfos() const +shared_ptr <connectionInfos> maildirStore::getConnectionInfos() const { - return vmime::create <defaultConnectionInfos>("localhost", static_cast <port_t>(0)); + return make_shared <defaultConnectionInfos>("localhost", static_cast <port_t>(0)); } @@ -201,13 +201,13 @@ void maildirStore::noop() } -ref <maildirFormat> maildirStore::getFormat() +shared_ptr <maildirFormat> maildirStore::getFormat() { return m_format; } -ref <const maildirFormat> maildirStore::getFormat() const +shared_ptr <const maildirFormat> 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 <utility::file> dir) +void maildirUtils::recursiveFSDelete(shared_ptr <utility::file> dir) { - ref <utility::fileIterator> files = dir->getFiles(); + shared_ptr <utility::fileIterator> files = dir->getFiles(); // First, delete files and subdirectories in this directory while (files->hasMoreElements()) { - ref <utility::file> file = files->nextElement(); + shared_ptr <utility::file> file = files->nextElement(); if (file->isDirectory()) { |