From f9913fa28a27f23fde2d4956c62cbb2fb2bc2ee8 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Thu, 21 Nov 2013 22:16:57 +0100 Subject: [PATCH] Boost/C++11 shared pointers. --- .gitignore | 2 + CMakeLists.txt | 81 ++- README.refcounting | 105 ---- SConstruct | 3 - cmake/cmake-cxx11/.gitignore | 1 + cmake/cmake-cxx11/MERGE-TODO | 7 + .../Modules/CheckCXX11Features.cmake | 142 +++++ .../cxx11-test-__func__.cpp | 8 + .../CheckCXX11Features/cxx11-test-auto.cpp | 12 + .../cxx11-test-auto_fail_compile.cpp | 7 + .../cxx11-test-auto_ret_type.cpp | 8 + .../cxx11-test-class_override_final.cpp | 21 + ...test-class_override_final_fail_compile.cpp | 25 + .../cxx11-test-constexpr.cpp | 19 + .../CheckCXX11Features/cxx11-test-cstdint.cpp | 11 + .../cxx11-test-decltype.cpp | 10 + .../cxx11-test-initializer_list.cpp | 27 + .../CheckCXX11Features/cxx11-test-lambda.cpp | 5 + .../cxx11-test-long_long.cpp | 7 + .../CheckCXX11Features/cxx11-test-nullptr.cpp | 6 + .../cxx11-test-nullptr_fail_compile.cpp | 6 + .../CheckCXX11Features/cxx11-test-regex.cpp | 26 + .../cxx11-test-rvalue-references.cpp | 57 ++ .../cxx11-test-sizeof_member.cpp | 14 + .../cxx11-test-sizeof_member_fail.cpp | 9 + .../cxx11-test-static_assert.cpp | 5 + .../cxx11-test-static_assert_fail_compile.cpp | 5 + .../cxx11-test-variadic_templates.cpp | 23 + .../Tests/Module/CXX11Features/CMakeLists.txt | 33 ++ .../Module/CXX11Features/cxx11features.cxx | 57 ++ cmake/config.hpp.cmake | 2 + doc/book/basics.tex | 110 ++-- doc/book/building.tex | 43 +- doc/book/msg.tex | 88 +-- doc/book/net.tex | 80 +-- examples/example1.cpp | 8 +- examples/example2.cpp | 10 +- examples/example3.cpp | 24 +- examples/example6.cpp | 73 +-- examples/example7.cpp | 10 +- examples/viewer/viewer.cpp | 8 +- src/address.cpp | 13 +- src/addressList.cpp | 66 +-- src/attachmentHelper.cpp | 71 ++- src/base.cpp | 8 +- src/body.cpp | 163 +++--- src/bodyPart.cpp | 70 ++- src/bodyPartAttachment.cpp | 28 +- src/charset.cpp | 12 +- src/charsetConverter.cpp | 4 +- src/charsetConverter_iconv.cpp | 8 +- src/charsetConverter_icu.cpp | 8 +- src/charsetConverter_idna.cpp | 4 +- src/component.cpp | 30 +- src/contentDisposition.cpp | 8 +- src/dateTime.cpp | 8 +- src/defaultAttachment.cpp | 26 +- src/disposition.cpp | 8 +- src/emailAddress.cpp | 14 +- src/emptyContentHandler.cpp | 4 +- src/encoding.cpp | 16 +- src/fileAttachment.cpp | 20 +- src/fileContentHandler.cpp | 8 +- src/generatedMessageAttachment.cpp | 16 +- src/header.cpp | 82 +-- src/headerField.cpp | 34 +- src/headerFieldFactory.cpp | 12 +- src/htmlTextPart.cpp | 106 ++-- src/mailbox.cpp | 8 +- src/mailboxField.cpp | 8 +- src/mailboxGroup.cpp | 54 +- src/mailboxList.cpp | 54 +- src/mdn/MDNHelper.cpp | 82 ++- src/mdn/receivedMDNInfos.cpp | 17 +- src/mdn/sendableMDNInfos.cpp | 4 +- src/mediaType.cpp | 8 +- src/messageBuilder.cpp | 34 +- src/messageId.cpp | 14 +- src/messageIdSequence.cpp | 46 +- src/messageParser.cpp | 64 +- src/misc/importanceHelper.cpp | 26 +- src/net/events.cpp | 24 +- src/net/folder.cpp | 14 +- src/net/imap/IMAPConnection.cpp | 96 +-- src/net/imap/IMAPFolder.cpp | 211 ++++--- src/net/imap/IMAPFolderStatus.cpp | 4 +- src/net/imap/IMAPMessage.cpp | 98 ++-- src/net/imap/IMAPMessagePart.cpp | 32 +- .../imap/IMAPMessagePartContentHandler.cpp | 32 +- src/net/imap/IMAPMessageStructure.cpp | 12 +- src/net/imap/IMAPSStore.cpp | 2 +- src/net/imap/IMAPStore.cpp | 41 +- src/net/imap/IMAPUtils.cpp | 4 +- .../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 +- src/net/message.cpp | 4 +- src/net/messageSet.cpp | 8 +- src/net/pop3/POP3Command.cpp | 40 +- src/net/pop3/POP3Connection.cpp | 104 ++-- src/net/pop3/POP3Folder.cpp | 134 ++--- src/net/pop3/POP3FolderStatus.cpp | 4 +- src/net/pop3/POP3Message.cpp | 32 +- src/net/pop3/POP3Response.cpp | 22 +- src/net/pop3/POP3SStore.cpp | 2 +- src/net/pop3/POP3Store.cpp | 37 +- src/net/pop3/POP3Utils.cpp | 2 +- src/net/sendmail/sendmailTransport.cpp | 9 +- src/net/service.cpp | 32 +- src/net/serviceFactory.cpp | 32 +- src/net/serviceInfos.cpp | 2 +- src/net/serviceRegistration.inl | 10 +- src/net/session.cpp | 57 +- .../smtp/SMTPChunkingOutputStreamAdapter.cpp | 6 +- src/net/smtp/SMTPCommand.cpp | 30 +- src/net/smtp/SMTPCommandSet.cpp | 20 +- src/net/smtp/SMTPConnection.cpp | 82 +-- src/net/smtp/SMTPResponse.cpp | 8 +- src/net/smtp/SMTPSTransport.cpp | 2 +- src/net/smtp/SMTPTransport.cpp | 26 +- src/net/tls/TLSSecuredConnectionInfos.cpp | 4 +- src/net/tls/gnutls/TLSProperties_GnuTLS.cpp | 10 +- src/net/tls/gnutls/TLSSession_GnuTLS.cpp | 12 +- src/net/tls/gnutls/TLSSocket_GnuTLS.cpp | 38 +- src/net/tls/openssl/OpenSSLInitializer.cpp | 4 +- src/net/tls/openssl/TLSProperties_OpenSSL.cpp | 10 +- src/net/tls/openssl/TLSSession_OpenSSL.cpp | 12 +- src/net/tls/openssl/TLSSocket_OpenSSL.cpp | 32 +- src/net/transport.cpp | 52 +- src/object.cpp | 50 -- src/parameter.cpp | 14 +- src/parameterizedHeaderField.cpp | 64 +- src/parsedMessageAttachment.cpp | 20 +- src/path.cpp | 8 +- src/plainTextPart.cpp | 22 +- src/platform.cpp | 14 +- src/platforms/posix/posixChildProcess.cpp | 19 +- src/platforms/posix/posixFile.cpp | 34 +- src/platforms/posix/posixHandler.cpp | 16 +- src/platforms/posix/posixSocket.cpp | 12 +- src/platforms/windows/windowsFile.cpp | 32 +- src/platforms/windows/windowsHandler.cpp | 14 +- src/platforms/windows/windowsSocket.cpp | 12 +- src/propertySet.cpp | 32 +- src/relay.cpp | 8 +- src/security/cert/certificateChain.cpp | 4 +- .../cert/defaultCertificateVerifier.cpp | 32 +- .../cert/gnutls/X509Certificate_GnuTLS.cpp | 28 +- .../cert/openssl/X509Certificate_OpenSSL.cpp | 32 +- src/security/defaultAuthenticator.cpp | 8 +- src/security/digest/messageDigestFactory.cpp | 2 +- src/security/sasl/SASLContext.cpp | 24 +- src/security/sasl/SASLMechanismFactory.cpp | 8 +- src/security/sasl/SASLSession.cpp | 26 +- src/security/sasl/SASLSocket.cpp | 2 +- src/security/sasl/builtinSASLMechanism.cpp | 8 +- .../sasl/defaultSASLAuthenticator.cpp | 24 +- src/streamContentHandler.cpp | 20 +- src/stringContentHandler.cpp | 12 +- src/text.cpp | 70 +-- src/textPartFactory.cpp | 2 +- src/utility/encoder/encoderFactory.cpp | 18 +- src/utility/parserInputStreamAdapter.cpp | 4 +- .../seekableInputStreamRegionAdapter.cpp | 2 +- src/utility/smartPtr.cpp | 41 -- src/utility/smartPtrInt.cpp | 295 ---------- src/word.cpp | 23 +- src/wordEncoder.cpp | 6 +- tests/misc/importanceHelperTest.cpp | 8 +- tests/net/imap/IMAPParserTest.cpp | 13 +- tests/net/imap/IMAPTagTest.cpp | 16 +- tests/net/maildir/maildirStoreTest.cpp | 86 +-- tests/net/pop3/POP3CommandTest.cpp | 47 +- tests/net/pop3/POP3ResponseTest.cpp | 80 +-- tests/net/pop3/POP3StoreTest.cpp | 14 +- tests/net/pop3/POP3TestUtils.hpp | 15 +- tests/net/pop3/POP3UtilsTest.cpp | 10 +- tests/net/smtp/SMTPCommandSetTest.cpp | 28 +- tests/net/smtp/SMTPCommandTest.cpp | 44 +- tests/net/smtp/SMTPResponseTest.cpp | 70 +-- tests/net/smtp/SMTPTransportTest.cpp | 80 +-- tests/net/smtp/SMTPTransportTestUtils.hpp | 22 +- tests/parser/attachmentHelperTest.cpp | 70 +-- tests/parser/bodyPartTest.cpp | 42 +- tests/parser/bodyTest.cpp | 4 +- .../charsetFilteredOutputStreamTest.cpp | 20 +- tests/parser/fileContentHandlerTest.cpp | 6 +- tests/parser/headerFieldTest.cpp | 19 +- tests/parser/headerTest.cpp | 54 +- tests/parser/htmlTextPartTest.cpp | 12 +- tests/parser/mailboxGroupTest.cpp | 4 +- tests/parser/mailboxTest.cpp | 9 +- tests/parser/messageIdSequenceTest.cpp | 6 +- tests/parser/messageTest.cpp | 6 +- tests/parser/parameterTest.cpp | 44 +- tests/parser/streamContentHandlerTest.cpp | 36 +- tests/parser/textTest.cpp | 20 +- tests/security/digest/md5Test.cpp | 2 +- tests/security/digest/sha1Test.cpp | 2 +- tests/testUtils.cpp | 4 +- tests/testUtils.hpp | 10 +- tests/utility/encoder/encoderTestUtils.hpp | 8 +- .../utility/outputStreamSocketAdapterTest.cpp | 6 +- .../seekableInputStreamRegionAdapterTest.cpp | 30 +- tests/utility/smartPtrTest.cpp | 241 -------- vmime/address.hpp | 4 +- vmime/addressList.hpp | 28 +- vmime/attachment.hpp | 8 +- vmime/attachmentHelper.hpp | 22 +- vmime/base.hpp | 133 ++--- vmime/body.hpp | 49 +- vmime/bodyPart.hpp | 49 +- vmime/bodyPartAttachment.hpp | 22 +- vmime/charset.hpp | 4 +- vmime/charsetConverter.hpp | 6 +- vmime/charsetConverter_iconv.hpp | 2 +- vmime/charsetConverter_icu.hpp | 2 +- vmime/charsetConverter_idna.hpp | 2 +- vmime/component.hpp | 12 +- vmime/contentDisposition.hpp | 4 +- vmime/contentDispositionField.hpp | 2 +- vmime/contentHandler.hpp | 3 +- vmime/contentTypeField.hpp | 2 +- vmime/dateTime.hpp | 4 +- vmime/defaultAttachment.hpp | 16 +- vmime/disposition.hpp | 4 +- vmime/emailAddress.hpp | 4 +- vmime/emptyContentHandler.hpp | 2 +- vmime/encoding.hpp | 10 +- vmime/fileAttachment.hpp | 10 +- vmime/fileContentHandler.hpp | 8 +- vmime/generatedMessageAttachment.hpp | 16 +- vmime/header.hpp | 68 ++- vmime/headerField.hpp | 40 +- vmime/headerFieldFactory.hpp | 14 +- vmime/htmlTextPart.hpp | 36 +- vmime/mailbox.hpp | 4 +- vmime/mailboxField.hpp | 2 +- vmime/mailboxGroup.hpp | 26 +- vmime/mailboxList.hpp | 26 +- vmime/mdn/MDNHelper.hpp | 20 +- vmime/mdn/MDNInfos.hpp | 2 +- vmime/mdn/receivedMDNInfos.hpp | 6 +- vmime/mdn/sendableMDNInfos.hpp | 6 +- vmime/mediaType.hpp | 4 +- vmime/messageAttachment.hpp | 2 +- vmime/messageBuilder.hpp | 20 +- vmime/messageId.hpp | 6 +- vmime/messageIdSequence.hpp | 26 +- vmime/messageParser.hpp | 22 +- vmime/misc/importanceHelper.hpp | 12 +- vmime/net/events.hpp | 30 +- vmime/net/folder.hpp | 30 +- vmime/net/folderStatus.hpp | 2 +- vmime/net/imap/IMAPConnection.hpp | 28 +- vmime/net/imap/IMAPFolder.hpp | 37 +- vmime/net/imap/IMAPFolderStatus.hpp | 2 +- vmime/net/imap/IMAPMessage.hpp | 36 +- vmime/net/imap/IMAPMessagePart.hpp | 28 +- .../imap/IMAPMessagePartContentHandler.hpp | 8 +- vmime/net/imap/IMAPMessageStructure.hpp | 10 +- vmime/net/imap/IMAPParser.hpp | 40 +- vmime/net/imap/IMAPSStore.hpp | 2 +- vmime/net/imap/IMAPStore.hpp | 16 +- vmime/net/imap/IMAPUtils.hpp | 4 +- .../maildir/format/courierMaildirFormat.hpp | 2 +- .../net/maildir/format/kmailMaildirFormat.hpp | 2 +- vmime/net/maildir/maildirFolder.hpp | 34 +- vmime/net/maildir/maildirFolderStatus.hpp | 2 +- vmime/net/maildir/maildirFormat.hpp | 16 +- vmime/net/maildir/maildirMessage.hpp | 31 +- vmime/net/maildir/maildirMessagePart.hpp | 16 +- vmime/net/maildir/maildirMessageStructure.hpp | 14 +- vmime/net/maildir/maildirStore.hpp | 16 +- vmime/net/maildir/maildirUtils.hpp | 2 +- vmime/net/message.hpp | 26 +- vmime/net/pop3/POP3Command.hpp | 40 +- vmime/net/pop3/POP3Connection.hpp | 26 +- vmime/net/pop3/POP3Folder.hpp | 34 +- vmime/net/pop3/POP3FolderStatus.hpp | 2 +- vmime/net/pop3/POP3Message.hpp | 27 +- vmime/net/pop3/POP3Response.hpp | 16 +- vmime/net/pop3/POP3SStore.hpp | 2 +- vmime/net/pop3/POP3Store.hpp | 14 +- vmime/net/pop3/POP3Utils.hpp | 2 +- vmime/net/sendmail/sendmailTransport.hpp | 4 +- vmime/net/service.hpp | 36 +- vmime/net/serviceFactory.hpp | 30 +- vmime/net/serviceInfos.hpp | 4 +- vmime/net/session.hpp | 28 +- .../smtp/SMTPChunkingOutputStreamAdapter.hpp | 6 +- vmime/net/smtp/SMTPCommand.hpp | 30 +- vmime/net/smtp/SMTPCommandSet.hpp | 14 +- vmime/net/smtp/SMTPConnection.hpp | 30 +- vmime/net/smtp/SMTPResponse.hpp | 10 +- vmime/net/smtp/SMTPSTransport.hpp | 2 +- vmime/net/smtp/SMTPTransport.hpp | 10 +- vmime/net/socket.hpp | 4 +- vmime/net/store.hpp | 8 +- vmime/net/timeoutHandler.hpp | 2 +- vmime/net/tls/TLSProperties.hpp | 2 +- vmime/net/tls/TLSSecuredConnectionInfos.hpp | 8 +- vmime/net/tls/TLSSession.hpp | 6 +- vmime/net/tls/TLSSocket.hpp | 6 +- vmime/net/tls/gnutls/TLSSession_GnuTLS.hpp | 10 +- vmime/net/tls/gnutls/TLSSocket_GnuTLS.hpp | 14 +- vmime/net/tls/openssl/OpenSSLInitializer.hpp | 4 +- vmime/net/tls/openssl/TLSSession_OpenSSL.hpp | 10 +- vmime/net/tls/openssl/TLSSocket_OpenSSL.hpp | 14 +- vmime/net/transport.hpp | 10 +- vmime/object.hpp | 49 +- vmime/parameter.hpp | 8 +- vmime/parameterizedHeaderField.hpp | 30 +- vmime/parsedMessageAttachment.hpp | 16 +- vmime/path.hpp | 4 +- vmime/plainTextPart.hpp | 10 +- vmime/platform.hpp | 16 +- vmime/platforms/posix/posixChildProcess.hpp | 10 +- vmime/platforms/posix/posixFile.hpp | 16 +- vmime/platforms/posix/posixHandler.hpp | 14 +- vmime/platforms/posix/posixSocket.hpp | 8 +- vmime/platforms/windows/windowsFile.hpp | 16 +- vmime/platforms/windows/windowsHandler.hpp | 12 +- vmime/platforms/windows/windowsSocket.hpp | 8 +- vmime/propertySet.hpp | 18 +- vmime/relay.hpp | 4 +- vmime/security/authenticator.hpp | 2 +- vmime/security/cert/X509Certificate.hpp | 8 +- vmime/security/cert/certificate.hpp | 2 +- vmime/security/cert/certificateChain.hpp | 6 +- vmime/security/cert/certificateVerifier.hpp | 2 +- .../cert/defaultCertificateVerifier.hpp | 12 +- .../cert/gnutls/X509Certificate_GnuTLS.hpp | 12 +- .../cert/openssl/X509Certificate_OpenSSL.hpp | 16 +- vmime/security/defaultAuthenticator.hpp | 6 +- .../security/digest/messageDigestFactory.hpp | 12 +- vmime/security/sasl/SASLAuthenticator.hpp | 10 +- vmime/security/sasl/SASLContext.hpp | 10 +- vmime/security/sasl/SASLMechanism.hpp | 6 +- vmime/security/sasl/SASLMechanismFactory.hpp | 14 +- vmime/security/sasl/SASLSession.hpp | 18 +- vmime/security/sasl/SASLSocket.hpp | 6 +- vmime/security/sasl/builtinSASLMechanism.hpp | 10 +- .../sasl/defaultSASLAuthenticator.hpp | 24 +- vmime/streamContentHandler.hpp | 8 +- vmime/stringContentHandler.hpp | 2 +- vmime/text.hpp | 26 +- vmime/textPart.hpp | 8 +- vmime/textPartFactory.hpp | 8 +- vmime/types.hpp | 56 +- vmime/utility/childProcess.hpp | 6 +- vmime/utility/encoder/encoderFactory.hpp | 28 +- vmime/utility/file.hpp | 16 +- vmime/utility/parserInputStreamAdapter.hpp | 6 +- .../seekableInputStreamRegionAdapter.hpp | 4 +- vmime/utility/smartPtr.hpp | 550 ------------------ vmime/utility/smartPtrInt.hpp | 113 ---- vmime/utility/sync/autoLock.hpp | 4 +- vmime/word.hpp | 8 +- vmime/wordEncoder.hpp | 2 +- 367 files changed, 4424 insertions(+), 5170 deletions(-) delete mode 100644 README.refcounting create mode 100644 cmake/cmake-cxx11/.gitignore create mode 100644 cmake/cmake-cxx11/MERGE-TODO create mode 100644 cmake/cmake-cxx11/Modules/CheckCXX11Features.cmake create mode 100644 cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-__func__.cpp create mode 100644 cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-auto.cpp create mode 100644 cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-auto_fail_compile.cpp create mode 100644 cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-auto_ret_type.cpp create mode 100644 cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-class_override_final.cpp create mode 100644 cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-class_override_final_fail_compile.cpp create mode 100644 cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-constexpr.cpp create mode 100644 cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-cstdint.cpp create mode 100644 cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-decltype.cpp create mode 100644 cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-initializer_list.cpp create mode 100644 cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-lambda.cpp create mode 100644 cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-long_long.cpp create mode 100644 cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-nullptr.cpp create mode 100644 cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-nullptr_fail_compile.cpp create mode 100644 cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-regex.cpp create mode 100644 cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-rvalue-references.cpp create mode 100644 cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-sizeof_member.cpp create mode 100644 cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-sizeof_member_fail.cpp create mode 100644 cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-static_assert.cpp create mode 100644 cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-static_assert_fail_compile.cpp create mode 100644 cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-variadic_templates.cpp create mode 100644 cmake/cmake-cxx11/Tests/Module/CXX11Features/CMakeLists.txt create mode 100644 cmake/cmake-cxx11/Tests/Module/CXX11Features/cxx11features.cxx delete mode 100644 src/utility/smartPtr.cpp delete mode 100644 src/utility/smartPtrInt.cpp delete mode 100644 tests/utility/smartPtrTest.cpp delete mode 100644 vmime/utility/smartPtr.hpp delete mode 100644 vmime/utility/smartPtrInt.hpp diff --git a/.gitignore b/.gitignore index 9976ce0d..8b955403 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,8 @@ cmake_install.cmake /COPYING.txt build/ Makefile +export-shared.hpp +export-static.hpp # Outsourced build test /_build/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e925136..74f6c62f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,7 @@ INCLUDE(CheckFunctionExists) INCLUDE(CheckSymbolExists) INCLUDE(CheckTypeSize) INCLUDE(CheckLibraryExists) +INCLUDE(CheckCXXSourceCompiles) # CMake configuration @@ -795,6 +796,57 @@ ELSE() ENDIF() +############################################################################## +# Language features + +# C++11 +INCLUDE(cmake/cmake-cxx11/Modules/CheckCXX11Features.cmake) + +# Smart pointers +CHECK_CXX_SOURCE_COMPILES( + " + #include + struct A { int foo; }; + int main() { + std::shared_ptr a = std::make_shared (a); + return 0; + } + " + VMIME_HAS_CXX11_SHARED_PTR +) + +IF(CXX11_COMPILER_FLAGS AND VMIME_HAS_CXX11_SHARED_PTR) + + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX11_COMPILER_FLAGS}") + + IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") + ENDIF() + + MESSAGE(STATUS "Checking support for shared_ptr<>: built-in (C++11)") + + SET(VMIME_SHARED_PTR_USE_CXX ON) + SET(VMIME_SHARED_PTR_USE_BOOST OFF) + +ELSE() + + # Depends on Boost library if C++11 is not supported + FIND_PACKAGE(Boost) + + IF(Boost_FOUND) + INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) + ELSE() + MESSAGE(FATAL_ERROR "Boost library is required for shared_ptr<>, unless you compile using C++11") + ENDIF() + + MESSAGE(STATUS "Checking support for shared_ptr<>: boost library") + + SET(VMIME_SHARED_PTR_USE_CXX OFF) + SET(VMIME_SHARED_PTR_USE_BOOST ON) + +ENDIF() + + ############################################################################## # Platform @@ -941,20 +993,27 @@ ENDIF() ############################################################################## # Documentation -FIND_PACKAGE(Doxygen) +OPTION( + VMIME_BUILD_DOCUMENTATION + "Build documentation" + ON +) -IF(DOXYGEN_FOUND) - CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/Doxyfile.in ${CMAKE_BINARY_DIR}/Doxyfile @ONLY) +IF(VMIME_BUILD_DOCUMENTATION) + FIND_PACKAGE(Doxygen) - # Make a target so that documentation can be generated by running "make doc" - ADD_CUSTOM_TARGET( - doc - ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - COMMENT "Generating API documentation with Doxygen" VERBATIM - ) -ENDIF(DOXYGEN_FOUND) + IF(DOXYGEN_FOUND) + CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/Doxyfile.in ${CMAKE_BINARY_DIR}/Doxyfile @ONLY) + # Make a target so that documentation can be generated by running "make doc" + ADD_CUSTOM_TARGET( + doc + ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + COMMENT "Generating API documentation with Doxygen" VERBATIM + ) + ENDIF(DOXYGEN_FOUND) +ENDIF(VMIME_BUILD_DOCUMENTATION) ############################################################################## # Sanity checks diff --git a/README.refcounting b/README.refcounting deleted file mode 100644 index 33dbd74e..00000000 --- a/README.refcounting +++ /dev/null @@ -1,105 +0,0 @@ -============================================== -Reference counting and smart pointers in VMime -============================================== - - -I. Introduction -=============== - -Since version 0.7.2cvs, VMime has been modified to use smart pointers and -reference counting instead of raw pointers. - -This simplifies a lot using VMime objects as you don't have to worry about -freeing memory occupied by objects, or even wondering which of your program -or VMime is responsible for deleting the object. - -This is also convenient when a function returns a list of objects. Before, -you wrote: - - std::vector subFolders = folder->getFolders(); - - ...do something with result... - - for (std::vector ::iterator - it = subFolders.begin() ; it != subFolders.end() ; ++it) - { - delete *it; - } - -Now, you can simply write: - - std::vector > subFolders = folder->getFolders(); - - ...do something with result... - -and nothing more! - -Two new template classes were introduced: - - - vmime::ref <> holds a strong reference to an object. When there is no - more strong reference pointing to an object, the object is deleted. - - - vmime::weak_ref <> holds a weak reference to an object. A weak reference - automatically points to NULL when the last strong reference is released. - It can be used to bypass the problems with circular references: A holds - a strong reference to B, which holds a strong reference back to A. - - -II. Creating objects -==================== - -You should not use 'new' to allocate VMime objects anymore. Instead, you -should use the vmime::create() helper function: - - vmime::ref mbox = - vmime::create ("me@somewhere.com"); - - -III. Casting -============ - -Like raw C++ pointers, you can cast VMime references. Implicit downcast is -also supported. - -To do a dynamic cast, write: - - vmime::ref foo = ... - vmime::ref mbox = foo.dynamicCast () - -then 'mbox' will be set to null ref if the dynamic cast failed (ie. if dynamic -type of 'foo' is not/is not derived from 'vmime::mailbox'). - -The same thing is possible with static cast: - - vmime::ref foo = ... - vmime::ref mbox = foo.staticCast () - -Like in standard C++, if 'foo' is not really a 'vmime::mailbox', the 'mbox' -reference can point to anything (ie. "invalid"), so be careful... - -Finally, const cast is also supported: - - vmime::ref foo_const = ... - vmime::ref foo = foo_const.constCast(); - - -IV. Upgrading your code from version <= 0.7.1 -============================================= - -1. vmime::text --------------- - -In v0.7.1 and below: - - vmime::text t1; - vmime::newFromString("blah blah", vmime::charset(...), &t1); - - vmime::text* t2 = vmime::newFromString("foo", vmime::charset(...)); - -In v0.7.2: - - vmime::text t1; - t1.createFromString("blah blah", vmime::charset(...)); - - vmime::ref t2 = vmime::newFromString("foo", vmime::charset(...)); - diff --git a/SConstruct b/SConstruct index 2da57e1f..88a42154 100644 --- a/SConstruct +++ b/SConstruct @@ -121,8 +121,6 @@ libvmime_sources = [ 'utility/path.cpp', 'utility/path.hpp', 'utility/progressListener.cpp', 'utility/progressListener.hpp', 'utility/random.cpp', 'utility/random.hpp', - 'utility/smartPtr.cpp', 'utility/smartPtr.hpp', - 'utility/smartPtrInt.cpp', 'utility/smartPtrInt.hpp', 'utility/stream.cpp', 'utility/stream.hpp', 'utility/streamUtils.cpp', 'utility/streamUtils.hpp', 'utility/filteredStream.cpp', 'utility/filteredStream.hpp', @@ -406,7 +404,6 @@ libvmimetest_sources = [ 'tests/utility/stringUtilsTest.cpp', 'tests/utility/pathTest.cpp', 'tests/utility/urlTest.cpp', - 'tests/utility/smartPtrTest.cpp', 'tests/utility/encoder/qpEncoderTest.cpp', 'tests/utility/encoder/b64EncoderTest.cpp', 'tests/utility/outputStreamStringAdapterTest.cpp', diff --git a/cmake/cmake-cxx11/.gitignore b/cmake/cmake-cxx11/.gitignore new file mode 100644 index 00000000..378eac25 --- /dev/null +++ b/cmake/cmake-cxx11/.gitignore @@ -0,0 +1 @@ +build diff --git a/cmake/cmake-cxx11/MERGE-TODO b/cmake/cmake-cxx11/MERGE-TODO new file mode 100644 index 00000000..dc2ce480 --- /dev/null +++ b/cmake/cmake-cxx11/MERGE-TODO @@ -0,0 +1,7 @@ +These things need to be changed when this module is merged into CMake: + +-change include(CheckCXXCompilerFlag) in CheckCXX11Features.cmake to + include(${CMAKE_CURRENT_LIST_DIR}/CheckCXXCompilerFlag.cmake) +-remove the setting of CMAKE_MODULE_PATH from the testcase CMakeLists.txt +-change all tabs to spaces in the cpp files + diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features.cmake b/cmake/cmake-cxx11/Modules/CheckCXX11Features.cmake new file mode 100644 index 00000000..05c986ce --- /dev/null +++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features.cmake @@ -0,0 +1,142 @@ +# - Check which parts of the C++11 standard the compiler supports +# +# When found it will set the following variables +# +# CXX11_COMPILER_FLAGS - the compiler flags needed to get C++11 features +# +# HAS_CXX11_AUTO - auto keyword +# HAS_CXX11_AUTO_RET_TYPE - function declaration with deduced return types +# HAS_CXX11_CLASS_OVERRIDE - override and final keywords for classes and methods +# HAS_CXX11_CONSTEXPR - constexpr keyword +# HAS_CXX11_CSTDINT_H - cstdint header +# HAS_CXX11_DECLTYPE - decltype keyword +# HAS_CXX11_FUNC - __func__ preprocessor constant +# HAS_CXX11_INITIALIZER_LIST - initializer list +# HAS_CXX11_LAMBDA - lambdas +# HAS_CXX11_LIB_REGEX - regex library +# HAS_CXX11_LONG_LONG - long long signed & unsigned types +# HAS_CXX11_NULLPTR - nullptr +# HAS_CXX11_RVALUE_REFERENCES - rvalue references +# HAS_CXX11_SIZEOF_MEMBER - sizeof() non-static members +# HAS_CXX11_STATIC_ASSERT - static_assert() +# HAS_CXX11_VARIADIC_TEMPLATES - variadic templates + +#============================================================================= +# Copyright 2011,2012 Rolf Eike Beer +# Copyright 2012 Andreas Weis +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# +# Each feature may have up to 3 checks, every one of them in it's own file +# FEATURE.cpp - example that must build and return 0 when run +# FEATURE_fail.cpp - example that must build, but may not return 0 when run +# FEATURE_fail_compile.cpp - example that must fail compilation +# +# The first one is mandatory, the latter 2 are optional and do not depend on +# each other (i.e. only one may be present). +# + +if (NOT CMAKE_CXX_COMPILER_LOADED) + message(FATAL_ERROR "CheckCXX11Features modules only works if language CXX is enabled") +endif () + +cmake_minimum_required(VERSION 2.8.3) + +# +### Check for needed compiler flags +# +include(CheckCXXCompilerFlag) +check_cxx_compiler_flag("-std=c++11" _HAS_CXX11_FLAG) +if (NOT _HAS_CXX11_FLAG) + check_cxx_compiler_flag("-std=c++0x" _HAS_CXX0X_FLAG) +endif () + +if (_HAS_CXX11_FLAG) + set(CXX11_COMPILER_FLAGS "-std=c++11") +elseif (_HAS_CXX0X_FLAG) + set(CXX11_COMPILER_FLAGS "-std=c++0x") +endif () + +function(cxx11_check_feature FEATURE_NAME RESULT_VAR) + if (NOT DEFINED ${RESULT_VAR}) + set(_bindir "${CMAKE_CURRENT_BINARY_DIR}/cxx11_${FEATURE_NAME}") + + set(_SRCFILE_BASE ${CMAKE_CURRENT_LIST_DIR}/CheckCXX11Features/cxx11-test-${FEATURE_NAME}) + set(_LOG_NAME "\"${FEATURE_NAME}\"") + message(STATUS "Checking C++11 support for ${_LOG_NAME}") + + set(_SRCFILE "${_SRCFILE_BASE}.cpp") + set(_SRCFILE_FAIL "${_SRCFILE_BASE}_fail.cpp") + set(_SRCFILE_FAIL_COMPILE "${_SRCFILE_BASE}_fail_compile.cpp") + + if (CROSS_COMPILING) + try_compile(${RESULT_VAR} "${_bindir}" "${_SRCFILE}" + COMPILE_DEFINITIONS "${CXX11_COMPILER_FLAGS}") + if (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL}) + try_compile(${RESULT_VAR} "${_bindir}_fail" "${_SRCFILE_FAIL}" + COMPILE_DEFINITIONS "${CXX11_COMPILER_FLAGS}") + endif (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL}) + else (CROSS_COMPILING) + try_run(_RUN_RESULT_VAR _COMPILE_RESULT_VAR + "${_bindir}" "${_SRCFILE}" + COMPILE_DEFINITIONS "${CXX11_COMPILER_FLAGS}") + if (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR) + set(${RESULT_VAR} TRUE) + else (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR) + set(${RESULT_VAR} FALSE) + endif (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR) + if (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL}) + try_run(_RUN_RESULT_VAR _COMPILE_RESULT_VAR + "${_bindir}_fail" "${_SRCFILE_FAIL}" + COMPILE_DEFINITIONS "${CXX11_COMPILER_FLAGS}") + if (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR) + set(${RESULT_VAR} TRUE) + else (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR) + set(${RESULT_VAR} FALSE) + endif (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR) + endif (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL}) + endif (CROSS_COMPILING) + if (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL_COMPILE}) + try_compile(_TMP_RESULT "${_bindir}_fail_compile" "${_SRCFILE_FAIL_COMPILE}" + COMPILE_DEFINITIONS "${CXX11_COMPILER_FLAGS}") + if (_TMP_RESULT) + set(${RESULT_VAR} FALSE) + else (_TMP_RESULT) + set(${RESULT_VAR} TRUE) + endif (_TMP_RESULT) + endif (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL_COMPILE}) + + if (${RESULT_VAR}) + message(STATUS "Checking C++11 support for ${_LOG_NAME}: works") + else (${RESULT_VAR}) + message(STATUS "Checking C++11 support for ${_LOG_NAME}: not supported") + endif (${RESULT_VAR}) + set(${RESULT_VAR} ${${RESULT_VAR}} CACHE INTERNAL "C++11 support for ${_LOG_NAME}") + endif (NOT DEFINED ${RESULT_VAR}) +endfunction(cxx11_check_feature) + +cxx11_check_feature("__func__" HAS_CXX11_FUNC) +cxx11_check_feature("auto" HAS_CXX11_AUTO) +cxx11_check_feature("auto_ret_type" HAS_CXX11_AUTO_RET_TYPE) +cxx11_check_feature("class_override_final" HAS_CXX11_CLASS_OVERRIDE) +cxx11_check_feature("constexpr" HAS_CXX11_CONSTEXPR) +cxx11_check_feature("cstdint" HAS_CXX11_CSTDINT_H) +cxx11_check_feature("decltype" HAS_CXX11_DECLTYPE) +cxx11_check_feature("initializer_list" HAS_CXX11_INITIALIZER_LIST) +cxx11_check_feature("lambda" HAS_CXX11_LAMBDA) +cxx11_check_feature("long_long" HAS_CXX11_LONG_LONG) +cxx11_check_feature("nullptr" HAS_CXX11_NULLPTR) +cxx11_check_feature("regex" HAS_CXX11_LIB_REGEX) +cxx11_check_feature("rvalue-references" HAS_CXX11_RVALUE_REFERENCES) +cxx11_check_feature("sizeof_member" HAS_CXX11_SIZEOF_MEMBER) +cxx11_check_feature("static_assert" HAS_CXX11_STATIC_ASSERT) +cxx11_check_feature("variadic_templates" HAS_CXX11_VARIADIC_TEMPLATES) diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-__func__.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-__func__.cpp new file mode 100644 index 00000000..3bfd8a89 --- /dev/null +++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-__func__.cpp @@ -0,0 +1,8 @@ +int main(void) +{ + if (!__func__) + return 1; + if (!(*__func__)) + return 1; + return 0; +} diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-auto.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-auto.cpp new file mode 100644 index 00000000..948648e9 --- /dev/null +++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-auto.cpp @@ -0,0 +1,12 @@ + +int main() +{ + auto i = 5; + auto f = 3.14159f; + auto d = 3.14159; + bool ret = ( + (sizeof(f) < sizeof(d)) && + (sizeof(i) == sizeof(int)) + ); + return ret ? 0 : 1; +} diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-auto_fail_compile.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-auto_fail_compile.cpp new file mode 100644 index 00000000..3c0e3f2e --- /dev/null +++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-auto_fail_compile.cpp @@ -0,0 +1,7 @@ +int main(void) +{ + // must fail because there is no initializer + auto i; + + return 0; +} diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-auto_ret_type.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-auto_ret_type.cpp new file mode 100644 index 00000000..937b6835 --- /dev/null +++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-auto_ret_type.cpp @@ -0,0 +1,8 @@ +auto foo(int i) -> int { + return i - 1; +} + +int main() +{ + return foo(1); +} diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-class_override_final.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-class_override_final.cpp new file mode 100644 index 00000000..f5870b19 --- /dev/null +++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-class_override_final.cpp @@ -0,0 +1,21 @@ +class base { +public: + virtual int foo(int a) + { return 4 + a; } + int bar(int a) final + { return a - 2; } +}; + +class sub final : public base { +public: + virtual int foo(int a) override + { return 8 + 2 * a; }; +}; + +int main(void) +{ + base b; + sub s; + + return (b.foo(2) * 2 == s.foo(2)) ? 0 : 1; +} diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-class_override_final_fail_compile.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-class_override_final_fail_compile.cpp new file mode 100644 index 00000000..bc00b278 --- /dev/null +++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-class_override_final_fail_compile.cpp @@ -0,0 +1,25 @@ +class base { +public: + virtual int foo(int a) + { return 4 + a; } + virtual int bar(int a) final + { return a - 2; } +}; + +class sub final : public base { +public: + virtual int foo(int a) override + { return 8 + 2 * a; }; + virtual int bar(int a) + { return a; } +}; + +class impossible : public sub { }; + +int main(void) +{ + base b; + sub s; + + return 1; +} diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-constexpr.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-constexpr.cpp new file mode 100644 index 00000000..ed624512 --- /dev/null +++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-constexpr.cpp @@ -0,0 +1,19 @@ +constexpr int square(int x) +{ + return x*x; +} + +constexpr int the_answer() +{ + return 42; +} + +int main() +{ + int test_arr[square(3)]; + bool ret = ( + (square(the_answer()) == 1764) && + (sizeof(test_arr)/sizeof(test_arr[0]) == 9) + ); + return ret ? 0 : 1; +} diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-cstdint.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-cstdint.cpp new file mode 100644 index 00000000..ca2c72dd --- /dev/null +++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-cstdint.cpp @@ -0,0 +1,11 @@ +#include + +int main() +{ + bool test = + (sizeof(int8_t) == 1) && + (sizeof(int16_t) == 2) && + (sizeof(int32_t) == 4) && + (sizeof(int64_t) == 8); + return test ? 0 : 1; +} diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-decltype.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-decltype.cpp new file mode 100644 index 00000000..0dbb1cc5 --- /dev/null +++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-decltype.cpp @@ -0,0 +1,10 @@ +bool check_size(int i) +{ + return sizeof(int) == sizeof(decltype(i)); +} + +int main() +{ + bool ret = check_size(42); + return ret ? 0 : 1; +} diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-initializer_list.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-initializer_list.cpp new file mode 100644 index 00000000..35e6c384 --- /dev/null +++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-initializer_list.cpp @@ -0,0 +1,27 @@ +#include + +class seq { +public: + seq(std::initializer_list list); + + int length() const; +private: + std::vector m_v; +}; + +seq::seq(std::initializer_list list) + : m_v(list) +{ +} + +int seq::length() const +{ + return m_v.size(); +} + +int main(void) +{ + seq a = {18, 20, 2, 0, 4, 7}; + + return (a.length() == 6) ? 0 : 1; +} diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-lambda.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-lambda.cpp new file mode 100644 index 00000000..4c33ed58 --- /dev/null +++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-lambda.cpp @@ -0,0 +1,5 @@ +int main() +{ + int ret = 0; + return ([&ret]() -> int { return ret; })(); +} diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-long_long.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-long_long.cpp new file mode 100644 index 00000000..09111275 --- /dev/null +++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-long_long.cpp @@ -0,0 +1,7 @@ +int main(void) +{ + long long l; + unsigned long long ul; + + return ((sizeof(l) >= 8) && (sizeof(ul) >= 8)) ? 0 : 1; +} diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-nullptr.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-nullptr.cpp new file mode 100644 index 00000000..9f410715 --- /dev/null +++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-nullptr.cpp @@ -0,0 +1,6 @@ +int main(void) +{ + void *v = nullptr; + + return v ? 1 : 0; +} diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-nullptr_fail_compile.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-nullptr_fail_compile.cpp new file mode 100644 index 00000000..6a002bcb --- /dev/null +++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-nullptr_fail_compile.cpp @@ -0,0 +1,6 @@ +int main(void) +{ + int i = nullptr; + + return 1; +} diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-regex.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-regex.cpp new file mode 100644 index 00000000..2fe01c4f --- /dev/null +++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-regex.cpp @@ -0,0 +1,26 @@ +#include +#include + +int parse_line(std::string const& line) +{ + std::string tmp; + if(std::regex_search(line, std::regex("(\\s)+(-)?(\\d)+//(-)?(\\d)+(\\s)+"))) { + tmp = std::regex_replace(line, std::regex("(-)?(\\d)+//(-)?(\\d)+"), std::string("V")); + } else if(std::regex_search(line, std::regex("(\\s)+(-)?(\\d)+/(-)?(\\d)+(\\s)+"))) { + tmp = std::regex_replace(line, std::regex("(-)?(\\d)+/(-)?(\\d)+"), std::string("V")); + } else if(std::regex_search(line, std::regex("(\\s)+(-)?(\\d)+/(-)?(\\d)+/(-)?(\\d)+(\\s)+"))) { + tmp = std::regex_replace(line, std::regex("(-)?(\\d)+/(-)?(\\d)+/(-)?(\\d)+"), std::string("V")); + } else { + tmp = std::regex_replace(line, std::regex("(-)?(\\d)+"), std::string("V")); + } + return static_cast(std::count(tmp.begin(), tmp.end(), 'V')); +} + +int main() +{ + bool test = (parse_line("f 7/7/7 -3/3/-3 2/-2/2") == 3) && + (parse_line("f 7//7 3//-3 -2//2") == 3) && + (parse_line("f 7/7 3/-3 -2/2") == 3) && + (parse_line("f 7 3 -2") == 3); + return test ? 0 : 1; +} diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-rvalue-references.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-rvalue-references.cpp new file mode 100644 index 00000000..e6e7e5a9 --- /dev/null +++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-rvalue-references.cpp @@ -0,0 +1,57 @@ +#include + +class rvmove { +public: + void *ptr; + char *array; + + rvmove() + : ptr(0), + array(new char[10]) + { + ptr = this; + } + + rvmove(rvmove &&other) + : ptr(other.ptr), + array(other.array) + { + other.array = 0; + other.ptr = 0; + } + + ~rvmove() + { + assert(((ptr != 0) && (array != 0)) || ((ptr == 0) && (array == 0))); + delete[] array; + } + + rvmove &operator=(rvmove &&other) + { + delete[] array; + ptr = other.ptr; + array = other.array; + other.array = 0; + other.ptr = 0; + return *this; + } + + static rvmove create() + { + return rvmove(); + } +private: + rvmove(const rvmove &); + rvmove &operator=(const rvmove &); +}; + +int main() +{ + rvmove mine; + if (mine.ptr != &mine) + return 1; + mine = rvmove::create(); + if (mine.ptr == &mine) + return 1; + return 0; +} diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-sizeof_member.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-sizeof_member.cpp new file mode 100644 index 00000000..4902fc73 --- /dev/null +++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-sizeof_member.cpp @@ -0,0 +1,14 @@ +struct foo { + char bar; + int baz; +}; + +int main(void) +{ + bool ret = ( + (sizeof(foo::bar) == 1) && + (sizeof(foo::baz) >= sizeof(foo::bar)) && + (sizeof(foo) >= sizeof(foo::bar) + sizeof(foo::baz)) + ); + return ret ? 0 : 1; +} diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-sizeof_member_fail.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-sizeof_member_fail.cpp new file mode 100644 index 00000000..0348c2ce --- /dev/null +++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-sizeof_member_fail.cpp @@ -0,0 +1,9 @@ +struct foo { + int baz; + double bar; +}; + +int main(void) +{ + return (sizeof(foo::bar) == 4) ? 0 : 1; +} diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-static_assert.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-static_assert.cpp new file mode 100644 index 00000000..47c2fefb --- /dev/null +++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-static_assert.cpp @@ -0,0 +1,5 @@ +int main(void) +{ + static_assert(0 < 1, "your ordering of integers is screwed"); + return 0; +} diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-static_assert_fail_compile.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-static_assert_fail_compile.cpp new file mode 100644 index 00000000..362fcdde --- /dev/null +++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-static_assert_fail_compile.cpp @@ -0,0 +1,5 @@ +int main(void) +{ + static_assert(1 < 0, "your ordering of integers is screwed"); + return 0; +} diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-variadic_templates.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-variadic_templates.cpp new file mode 100644 index 00000000..4518e886 --- /dev/null +++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-variadic_templates.cpp @@ -0,0 +1,23 @@ +int Accumulate() +{ + return 0; +} + +template +int Accumulate(T v, Ts... vs) +{ + return v + Accumulate(vs...); +} + +template +int CountElements() +{ + return sizeof...(Is); +} + +int main() +{ + int acc = Accumulate(1, 2, 3, 4, -5); + int count = CountElements<1,2,3,4,5>(); + return ((acc == 5) && (count == 5)) ? 0 : 1; +} diff --git a/cmake/cmake-cxx11/Tests/Module/CXX11Features/CMakeLists.txt b/cmake/cmake-cxx11/Tests/Module/CXX11Features/CMakeLists.txt new file mode 100644 index 00000000..f117eb16 --- /dev/null +++ b/cmake/cmake-cxx11/Tests/Module/CXX11Features/CMakeLists.txt @@ -0,0 +1,33 @@ +cmake_minimum_required(VERSION 2.8.3 FATAL_ERROR) +project(Cxx11Features CXX) + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../Modules") + +include(CheckCXX11Features) + +foreach (flag IN ITEMS + HAS_CXX11_AUTO + HAS_CXX11_AUTO_RET_TYPE + HAS_CXX11_CLASS_OVERRIDE + HAS_CXX11_CONSTEXPR + HAS_CXX11_CSTDINT_H + HAS_CXX11_DECLTYPE + HAS_CXX11_FUNC + HAS_CXX11_INITIALIZER_LIST + HAS_CXX11_LAMBDA + HAS_CXX11_LIB_REGEX + HAS_CXX11_LONG_LONG + HAS_CXX11_NULLPTR + HAS_CXX11_RVALUE_REFERENCES + HAS_CXX11_SIZEOF_MEMBER + HAS_CXX11_STATIC_ASSERT + HAS_CXX11_VARIADIC_TEMPLATES + ) + if (${flag}) + add_definitions("-D${flag}") + message(STATUS "Compiler C++11 support flag ${flag} set") + endif () +endforeach (flag) + +set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${CXX11_COMPILER_FLAGS}) +add_executable(CXX11Features cxx11features.cxx) diff --git a/cmake/cmake-cxx11/Tests/Module/CXX11Features/cxx11features.cxx b/cmake/cmake-cxx11/Tests/Module/CXX11Features/cxx11features.cxx new file mode 100644 index 00000000..c09038fb --- /dev/null +++ b/cmake/cmake-cxx11/Tests/Module/CXX11Features/cxx11features.cxx @@ -0,0 +1,57 @@ +#if defined(HAS_CXX0X_CSTDINT_H) +#include +#endif + +#include + +struct thing { + unsigned char one; +#if defined(HAS_CXX0X_CSTDINT_H) + uint32_t four; +#endif +#if defined(HAS_CXX0X_LONG_LONG) + long long eight; +#endif +}; + +#include + +int main() +{ +#if defined (HAS_CXX0X_NULLPTR) + void *nix = nullptr; +#else /* HAS_CXX0X_NULLPTR */ + void *nix = 0; +#endif /* HAS_CXX0X_NULLPTR */ + +#if defined(HAS_CXX0X_STATIC_ASSERT) + static_assert(1 < 42, "Your C++ compiler is b0rked"); +#endif /* HAS_CXX0X_STATIC_ASSERT */ + +#if defined(HAS_CXX0X_FUNC) + const char *funcname = __func__; + printf("the name of main() function is: %s\n", funcname); +#endif /* HAS_CXX0X_FUNC */ + +#if defined(HAS_CXX0X_SIZEOF_MEMBER) + size_t onesize = sizeof(thing::one); +#if defined(HAS_CXX0X_STATIC_ASSERT) + static_assert(sizeof(thing::one) == 1, "Your char is not one byte long"); +#endif /* HAS_CXX0X_STATIC_ASSERT */ + +#if defined(HAS_CXX0X_CSTDINT_H) + size_t foursize = sizeof(thing::four); +#if defined(HAS_CXX0X_STATIC_ASSERT) + static_assert(sizeof(thing::four) == 4, "Your uint32_t is not 32 bit long"); +#endif /* HAS_CXX0X_STATIC_ASSERT */ +#endif /* HAS_CXX0X_CSTDINT_H */ +#if defined(HAS_CXX0X_LONG_LONG) + size_t eightsize = sizeof(thing::eight); +#if defined(HAS_CXX0X_STATIC_ASSERT) + static_assert(sizeof(thing::eight) == 8, "Your long long is not 64 bit long"); +#endif /* HAS_CXX0X_STATIC_ASSERT */ +#endif /* HAS_CXX0X_LONG_LONG */ +#endif /* HAS_CXX0X_SIZEOF_MEMBER */ + + return 0; +} diff --git a/cmake/config.hpp.cmake b/cmake/config.hpp.cmake index afae3d16..a9edc34f 100644 --- a/cmake/config.hpp.cmake +++ b/cmake/config.hpp.cmake @@ -83,6 +83,8 @@ typedef unsigned @VMIME_64BIT_TYPE@ vmime_uint64; #cmakedefine01 VMIME_HAVE_LOCALTIME_S #cmakedefine01 VMIME_HAVE_LOCALTIME_R #cmakedefine01 VMIME_HAVE_MLANG +#cmakedefine01 VMIME_SHARED_PTR_USE_CXX +#cmakedefine01 VMIME_SHARED_PTR_USE_BOOST #define VMIME_SENDMAIL_PATH "@VMIME_SENDMAIL_PATH@" diff --git a/doc/book/basics.tex b/doc/book/basics.tex index 9c129912..ac66959e 100644 --- a/doc/book/basics.tex +++ b/doc/book/basics.tex @@ -6,7 +6,7 @@ \subsection{Introduction} % -------------------------------------------------- Since version 0.7.2cvs, VMime use smart pointers to simplify memory -management. VMime's smart pointer implementation relies on +management. Smart pointers rely on RAII\footnote{Ressource Allocation is Initialisation} so that we do not need to bother with deleting an object (freeing memory) when it is not used anymore. @@ -21,8 +21,20 @@ An object is destroyed as soon as the last strong reference to it is released. At the same tine, all weak references (if any) are automatically set to point to \vnull. -In VMime, these two types of references are known as {\vcode vmime::ref} -and {\vcode vmime::weak\_ref}, respectively. +In VMime, these two types of references are known as {\vcode vmime::shared\_ptr} +and {\vcode vmime::weak\_ptr}, respectively. + +\vnote{since November 2013, we switched from an old, intrusive implementation +of smart pointers to a more standard one: either Boost {\vcode shared\_ptr<>} +implementation or standard C++ one if we are compiling in C++11. Here are the +changes: + +{\vcode vmime::ref <>} is replaced with {\vcode vmime::shared\_ptr <>} + +{\vcode vmime::weak\_ref <>} is replaced with {\vcode vmime::weak\_ptr <>} + +{\vcode vmime::create <>} is replaced with {\vcode vmime::make\_shared <>} +} \subsection{Instanciating reference-counted objects} % ----------------------- @@ -30,7 +42,7 @@ In VMime, all objects that support reference counting inherit from the {\vcode vmime::object} class, which is responsible for incrementing/decrementing the counter and managing the object's life cycle. If you want to create a smart pointer to a new object instance, you should -use the function {\vcode vmime::create} instead of the {\vcode new} +use the function {\vcode vmime::make\_shared} instead of the {\vcode new} operator. \begin{lstlisting}[caption={Smarts pointers and creating objects}] @@ -55,8 +67,8 @@ private: int main() { - vmime::ref obj = - vmime::create ("world"); + vmime::shared_ptr obj = + vmime::make_shared ("world"); obj->sayHello(); @@ -72,20 +84,20 @@ you would use normal ("raw") C++ pointers (eg. you can write \lstinline{!ptr, ptr != NULL, ptr->method(), *ptr}...). Type safety is also guaranteed, and you can type cast smart pointers using -the {\vcode staticCast()}, {\vcode dynamicCast()} and {\vcode constCast()} -equivalents on {\vcode vmime::ref} and {\vcode vmime::weak\_ref} objects: +the {\vcode static\_cast()}, {\vcode dynamic\_cast()} and {\vcode const\_cast()} +equivalents on {\vcode vmime::shared\_ptr} and {\vcode vmime::weak\_ptr} objects: \begin{lstlisting}[caption={Casting smart pointers}] class myBase : public vmime::object { } class myObject : public myBase { } -vmime::ref obj = vmime::create (); +vmime::shared_ptr obj = vmime::make_shared (); // Implicit downcast -vmime::ref base = obj; +vmime::shared_ptr base = obj; // Explicit upcast -vmime::ref obj2 = base.dynamicCast (); +vmime::shared_ptr obj2 = vmime::dynamicCast (base); \end{lstlisting} Weak references are used to resolve reference cycles (an object which refers @@ -97,34 +109,34 @@ class parent : public vmime::object { public: - void createChild(vmime::ref c) + void createChild(vmime::shared_ptr c) { m_child = c; } private: - vmime::ref m_child; + vmime::shared_ptr m_child; }; class child : public vmime::object { public: - child(vmime::ref p) + child(vmime::shared_ptr p) : m_parent(p) { } private: - vmime::ref m_parent; + vmime::shared_ptr m_parent; }; int main() { - vmime::ref p = vmime::create (); - vmime::ref c = vmime::create (); + vmime::shared_ptr p = vmime::make_shared (); + vmime::shared_ptr c = vmime::make_shared (); p->setChild(c); } @@ -136,7 +148,7 @@ exiting {\vcode main()}. That's because {\vcode p} indirectly points to itself reference to the parent: \begin{lstlisting} -vmime::weak_ref m_parent; +vmime::weak_ptr m_parent; \end{lstlisting} The decision to make the parent or the child a weak reference is purely @@ -216,7 +228,7 @@ provides additional functions to get some information about the parsing process or the structure (methods {\vcode getParsedOffset()}, {\vcode getParsedLength()} and {\vcode getChildComponents()}). -Vmime also provides a set of classes corresponding to the basic types found +VMime also provides a set of classes corresponding to the basic types found in a message; for example a mailbox, a mailbox list, date/time information, media type, etc. They all inherit from {\vcode component} too. @@ -284,12 +296,12 @@ an email address (mandatory) and possibly a name. A mailbox group is simply a named list of mailboxes (see Figure \ref{uml_addr_mbox_mboxgroup}). \begin{lstlisting}[caption={Using mailboxes and mailbox groups}] -vmime::ref mbox1 = vmime::create +vmime::shared_ptr mbox1 = vmime::make_shared (/* name */ vmime::text("John Doe"), /* email */ "john.doe@acme.com"); -vmime::ref mbox2 = vmime::create +vmime::shared_ptr mbox2 = vmime::make_shared (/* no name, email only */ "bill@acme.com"); -vmime::ref grp = vmime::create (); +vmime::shared_ptr grp = vmime::make_shared (); grp->appendMailbox(mbox1); grp->appendMailbox(mbox2); \end{lstlisting} @@ -402,12 +414,11 @@ convert automatically from basic types to text, and \emph{vice versa}. The following example illustrates it: \begin{lstlisting}[caption={Getting and setting parameter value in fields}] -vmime::ref field = - header->findField("X-Field-That-Contains-Parameters") - .dynamicCast (); +vmime::shared_ptr field = + header->findField ("X-Field-That-Contains-Parameters"); // Use setValue() to convert from a basic type to 'text' -vmime::ref prm = field->getParameter("my-date-param"); +vmime::shared_ptr prm = field->getParameter("my-date-param"); prm->setValue(vmime::datetime::now()); // Use getValueAs() to convert from 'text' to a basic type @@ -421,12 +432,11 @@ Table \ref{standard-prm-fields}). This avoids finding the parameter and illustrates how to use it: \begin{lstlisting} -vmime::ref field = - header->getField(vmime::fields::CONTENT_TYPE) - .dynamicCast (); +vmime::shared_ptr field = + header->getField (vmime::fields::CONTENT_TYPE); // 1. First solution: the "hard" way -vmime::ref prm = field->findParameter("charset"); +vmime::shared_ptr prm = field->findParameter("charset"); const charset ch1 = prm->getValueAs (); // 2. Second solution: the simple way @@ -541,11 +551,11 @@ writing it to the standard output with charset conversion: \begin{lstlisting}[caption={Using content handlers to extract body text from a message}] // Suppose we already have a message -vmime::ref msg; +vmime::shared_ptr msg; // Obtains a reference to the body contents -vmime::ref body = msg->getBody(); -vmime::ref cts = body->getContents(); +vmime::shared_ptr body = msg->getBody(); +vmime::shared_ptr cts = body->getContents(); vmime::utility::outputStreamAdapter out(std::cout); cts->extract(out); @@ -563,11 +573,11 @@ if you want to set the contents of a body part. The following code snippet shows how to set the body text of a part from a string: \begin{lstlisting}[caption={Setting the contents of a body part}] -vmime::ref part; // suppose we have a body part +vmime::shared_ptr part; // suppose we have a body part // Create a new content handler from a string -vmime::ref cth = - vmime::create ("Put body contents here"); +vmime::shared_ptr cth = + vmime::make_shared ("Put body contents here"); // Set the contents part->getBody()->setContents(cth); @@ -585,18 +595,18 @@ fileStream->open("/home/vincent/paris.jpg", std::ios::binary); if (!*fileStream) // handle error -vmime::ref dataStream = - vmime::create (fileStream); +vmime::shared_ptr dataStream = + vmime::make_shared (fileStream); // NOTE: 'fileStream' will be automatically deleted // when 'dataStream' is deleted // Create a new content handler -vmime::ref data = - vmime::create (dataStream, 0); +vmime::shared_ptr data = + vmime::make_shared (dataStream, 0); // Now create the attachment -ref att = vmime::create +ref att = vmime::make_shared ( /* attachment data */ data, /* content type */ vmime::mediaType("image/jpeg"), @@ -627,11 +637,11 @@ to UTF-8 charset: \begin{lstlisting}[caption={Extracting and converting body contents to a specified charset}] -vmime::ref msg; // we have a message +vmime::shared_ptr msg; // we have a message // Obtain the content handler first -vmime::ref body = msg->getBody(); -vmime::ref cth = body->getContents(); +vmime::shared_ptr body = msg->getBody(); +vmime::shared_ptr cth = body->getContents(); // Then, extract and convert the contents vmime::utility::outputStreamAdapter out(std::cout); @@ -676,7 +686,7 @@ outText.createFromString(inText, inCharset); // . "téléphone " // . "mobile" -vmime::ref header = myMessage->getHeader(); +vmime::shared_ptr header = myMessage->getHeader(); header->Subject()->setValue(outText); \end{lstlisting} @@ -707,7 +717,7 @@ text stored in the Subject field of a message: \begin{lstlisting}[caption={Converting data in a {\vcode vmime::text} to a specified charset}] -vmime::ref msg; // we have a message +vmime::shared_ptr msg; // we have a message vmime::text subject = msg->getHeader()->Subject()->getValue(); @@ -739,7 +749,7 @@ The following example creates an instance of the Base64 encoder to encode some data: \begin{lstlisting}[caption={A simple example of using an encoder}] -vmime::ref enc = +vmime::shared_ptr enc = vmime::utility::encoder::encoderFactory::getInstance()->create("base64"); vmime::string inString("Some data to encode"); @@ -761,7 +771,7 @@ an excerpt from {\vexample example6}} enumerates available encoders and the supported properties for each of them: \begin{lstlisting}[caption={Enumerating encoders and their properties}] -vmime::utility::encoder::encoderFactory* ef = +vmime::shared_ptr ef = vmime::utility::encoder::encoderFactory::getInstance(); std::cout << "Available encoders:" << std::endl; @@ -769,13 +779,13 @@ std::cout << "Available encoders:" << std::endl; for (int i = 0 ; i < ef->getEncoderCount() ; ++i) { // Output encoder name - vmime::ref + vmime::shared_ptr enc = ef->getEncoderAt(i); std::cout << " * " << enc->getName() << std::endl; // Create an instance of the encoder to get its properties - vmime::ref e = enc->create(); + vmime::shared_ptr e = enc->create(); std::vector props = e->getAvailableProperties(); std::vector ::const_iterator it; diff --git a/doc/book/building.tex b/doc/book/building.tex index c96e95db..a34db5ba 100644 --- a/doc/book/building.tex +++ b/doc/book/building.tex @@ -16,13 +16,16 @@ To build VMime from the sources, you will need the following: \item a working C++ compiler with good STL implementation and also a good support for templates (for example, \href{http://gcc.gnu.org/}{GNU GCC}) ; \item \href{http://www.cmake.org/}{CMake} build system ; -\item an usable iconv() implementation (see +\item either \href{http://www.icu-project.org}{ICU library} or an usable +{\vcode iconv()} implementation (see \href{http://www.gnu.org/software/libiconv/}{libiconv of GNU Project}) ; \item the \href{http://www.gnu.org/software/gsasl/}{GNU SASL Library} if you want SASL\footnote{Simple Authentication and Security Layer} support ; \item either the \href{http://www.openssl.org}{OpenSSL library} or the \href{http://www.gnu.org/software/gnutls/}{GNU TLS Library} if you want SSL and TLS\footnote{Transport Layer Security} support ; +\item the \href{http://www.boost.org}{Boost C++ library} if you are not using +C++11 (or your compiler does not support it), for {\vcode shared\_ptr<>}. \end{itemize} % ============================================================================ @@ -113,3 +116,41 @@ the library into the default location (ie: /usr/lib and /usr/include).} Now, you are done! You can jump to the next chapter to know how to use VMime in your program... +% ============================================================================ +\section{Build options} + +Some options can be given to CMake to control the build: + +\begin{table}[!ht] +\noindent\begin{tabularx}{1.0\textwidth}{|l|X|} +\hline + {\bf Option name} & + {\bf Description} \\ +\hline +\hline +VMIME\_BUILD\_SHARED\_LIBRARY & +Set to ON to build a shared version (.so) of the library (default is ON). \\ +\hline +VMIME\_BUILD\_STATIC\_LIBRARY & +Set to ON to build a static version (.a) of the library (default is ON). \\ +\hline +VMIME\_BUILD\_TESTS & +Set to ON to build unit tests (default is OFF). \\ +\hline +VMIME\_TLS\_SUPPORT\_LIB\_IS\_OPENSSL \\ VMIME\_TLS\_SUPPORT\_LIB\_IS\_GNUTLS & +Set either the one or the other (but not both) to ON to force using either OpenSSL +or GNU TLS as the SSL library (default depends on which libraries are available on +your system). \\ +\hline +VMIME\_CHARSETCONV\_LIB\_IS\_ICONV \\ VMIME\_CHARSETCONV\_LIB\_IS\_ICU & +Set either the one or the other (but not both) to ON to force using either iconv +or ICU as the charset conversion library (default depends on which libraries are +available on your system). \\ +\hline +CMAKE\_BUILD\_TYPE & +Set the build type: either "Release" or "Debug". In Debug build, optimizations +are disabled and debugging information are enabled. \\ +\hline +\end{tabularx} +\caption{CMake build options} +\end{table} diff --git a/doc/book/msg.tex b/doc/book/msg.tex index 384aab74..50344b62 100644 --- a/doc/book/msg.tex +++ b/doc/book/msg.tex @@ -36,22 +36,22 @@ vmime::utility::outputStreamStringAdapter os(data); vmime::utility::bufferedStreamCopy(is, os); // Actually parse the message -vmime::ref msg = vmime::create (); +vmime::shared_ptr msg = vmime::make_shared (); msg->parse(data); -vmime::ref hdr = msg->getHeader(); -vmime::ref bdy = msg->getBody(); +vmime::shared_ptr hdr = msg->getHeader(); +vmime::shared_ptr bdy = msg->getBody(); // Now, you can extract some of its components vmime::charset ch(vmime::charsets::UTF_8); std::cout << "The subject of the message is: " - << hdr->Subject()->getValue().dynamicCast ()->getConvertedText(ch) + << hdr->Subject()->getValue ()->getConvertedText(ch) << std::endl << "It was sent by: " - << hdr->From()->getValue().dynamicCast ()->getName().getConvertedText(ch) - << " (email: " << hdr->From()->getValue().dynamicCast()->getEmail() << ")" + << hdr->From()->getValue ()->getName().getConvertedText(ch) + << " (email: " << hdr->From()->getValue ()->getEmail() << ")" << std::endl; \end{lstlisting} @@ -84,7 +84,7 @@ vmime::utility::outputStreamStringAdapter os(data); vmime::utility::bufferedStreamCopy(is, os); // Actually parse the message -vmime::ref msg = vmime::create (); +vmime::shared_ptr msg = vmime::make_shared (); msg->parse(data); // Here start the differences with the previous example @@ -96,7 +96,7 @@ std::cout << "Message has " << mp.getAttachmentCount() for (int i = 0 ; i < mp.getAttachmentCount() ; ++i) { - vmime::ref att = mp.getAttachmentAt(i); + vmime::shared_ptr att = mp.getAttachmentAt(i); std::cout << " - " << att->getType().generate() << std::endl; } @@ -106,13 +106,13 @@ std::cout << "Message has " << mp.getTextPartCount() for (int i = 0 ; i < mp.getTextPartCount() ; ++i) { - vmime::ref tp = mp.getTextPartAt(i); + vmime::shared_ptr tp = mp.getTextPartAt(i); // text/html if (tp->getType().getSubType() == vmime::mediaTypes::TEXT_HTML) { - vmime::ref htp = - tp.dynamicCast (); + vmime::shared_ptr htp = + vmime::dynamicCast (tp); // HTML text is in tp->getText() // Plain text is in tp->getPlainText() @@ -120,7 +120,7 @@ for (int i = 0 ; i < mp.getTextPartCount() ; ++i) // Enumerate embedded objects for (int j = 0 ; j < htp->getObjectCount() ; ++j) { - vmime::ref obj = + vmime::shared_ptr obj = htp->getObjectAt(j); // Identifier (Content-Id or Content-Location) is obj->getId() @@ -146,51 +146,51 @@ objects that compose it (parts, fields, etc.). The following is an example of how to achieve it: \begin{lstlisting}[caption={Building a simple message from scratch}] -vmime::ref msg = vmime::create (); +vmime::shared_ptr msg = vmime::make_shared (); -vmime::ref hdr = msg->getHeader(); -vmime::ref bdy = msg->getBody(); +vmime::shared_ptr hdr = msg->getHeader(); +vmime::shared_ptr bdy = msg->getBody(); -vmime::headerFieldFactory* hfFactory = +vmime::shared_ptr hfFactory = vmime::headerFieldFactory::getInstance(); // Append a 'Date:' field -vmime::ref dateField = +vmime::shared_ptr dateField = hfFactory->create(vmime::fields::DATE); dateField->setValue(vmime::datetime::now()); hdr->appendField(dateField); // Append a 'Subject:' field -vmime::ref subjectField = +vmime::shared_ptr subjectField = hfFactory->create(vmime::fields::SUBJECT); subjectField->setValue(vmime::text("Message subject")); hdr->appendField(subjectField); // Append a 'From:' field -vmime::ref fromField = +vmime::shared_ptr fromField = hfFactory->create(vmime::fields::FROM); fromField->setValue - (vmime::create ("me@vmime.org")); + (vmime::make_shared ("me@vmime.org")); hdr->appendField(fromField); // Append a 'To:' field -vmime::ref toField = +vmime::shared_ptr toField = hfFactory->create(vmime::fields::TO); -vmime::ref recipients = - vmime::create (); +vmime::shared_ptr recipients = + vmime::make_shared (); recipients->appendMailbox - (vmime::create ("you@vmime.org")); + (vmime::make_shared ("you@vmime.org")); toField->setValue(recipients); hdr->appendField(toField); // Set the body contents -bdy->setContents(vmime::create +bdy->setContents(vmime::make_shared ("This is the text of your message...")); // Output raw message data to standard output @@ -215,14 +215,14 @@ try mb.setSubject(vmime::text("Message subject")); mb.setExpeditor(vmime::mailbox("me@vmime.org")); mb.getRecipients().appendAddress - (vmime::create ("you@vmime.org")); + (vmime::make_shared ("you@vmime.org")); mb.getTextPart()->setCharset(vmime::charsets::ISO8859_15); - mb.getTextPart()->setText(vmime::create + mb.getTextPart()->setText(vmime::make_shared ("This is the text of your message...")); // Message construction - vmime::ref msg = mb.construct(); + vmime::shared_ptr msg = mb.construct(); // Output raw message data to standard output vmime::utility::outputStreamAdapter out(std::cout); @@ -249,8 +249,8 @@ previous example to attach a file to the message: \begin{lstlisting}[caption={Building a message with an attachment using {\vcode vmime::messageBuilder}}] // Create an attachment -vmime::ref att = - vmime::create +vmime::shared_ptr att = + vmime::make_shared ( /* full path to file */ "/home/vincent/paris.jpg", /* content type */ vmime::mediaType("image/jpeg), @@ -284,7 +284,7 @@ using the {\vcode vmime::messageBuilder}}] mb.setSubject(vmime::text("An HTML message")); mb.setExpeditor(vmime::mailbox("me@vmime.org")); mb.getRecipients().appendAddress - (vmime::create ("you@vmime.org")); + (vmime::make_shared ("you@vmime.org")); // Set the content-type to "text/html": a text part factory must be // available for the type you are using. The following code will make @@ -294,8 +294,8 @@ mb.constructTextPart(vmime::mediaType // Set contents of the text parts; the message is available in two formats: // HTML and plain text. The HTML format also includes an embedded image. -vmime::ref textPart = - mb.getTextPart().dynamicCast (); +vmime::shared_ptr textPart = + vmime::dynamicCast (mb.getTextPart()); // -- Add the JPEG image (the returned identifier is used to identify the // -- embedded object in the HTML text, the famous "CID", or "Content-Id"). @@ -306,11 +306,11 @@ const vmime::string id = textPart->addObject("<...image data...>", // -- Set the text textPart->setCharset(vmime::charsets::ISO8859_15); -textPart->setText(vmime::create +textPart->setText(vmime::make_shared ("This is the HTML text, and the image:
" "")); -textPart->setPlainText(vmime::create +textPart->setPlainText(vmime::make_shared ("This is the plain text.")); \end{lstlisting} @@ -332,11 +332,11 @@ input stream, then add an embedded object: vmime::utility::fileSystemFactory* fs = vmime::platform::getHandler()->getFileSystemFactory(); -vmime::ref imageFile = +vmime::shared_ptr imageFile = fs->create(fs->stringToPath("/path/to/image.jpg")); -vmime::ref imageCts = - vmime::create +vmime::shared_ptr imageCts = + vmime::make_shared (imageFile->getFileReader()->getInputStream(), imageFile->getLength()); const vmime::string cid = textPart.addObject(imageCts, @@ -359,12 +359,12 @@ The following code snippet tests if a body part is an attachment, and if so, extract its contents to the standard output: \begin{lstlisting}[caption={Testing if a body part is an attachment}] -vmime::ref part; // suppose we have a body part +vmime::shared_ptr part; // suppose we have a body part if (vmime::attachmentHelper::isBodyPartAnAttachment(part)) { // The body part contains an attachment, get it - vmime::ref attach = + vmime::shared_ptr attach = attachmentHelper::getBodyPartAttachment(part); // Extract attachment data to standard output @@ -376,7 +376,7 @@ if (vmime::attachmentHelper::isBodyPartAnAttachment(part)) You can also easily extract all attachments from a message: \begin{lstlisting}[caption={Extracting all attachments from a message}] -vmime::ref msg; // suppose we have a message +vmime::shared_ptr msg; // suppose we have a message const std::vector > atts = attachmentHelper::findAttachmentsInMessage(msg); @@ -390,11 +390,11 @@ exists in the message). Simply call the {\vcode addAttachment} function: \begin{lstlisting}[caption={Adding an attachment to an existing message}] -vmime::ref msg; // suppose we have a message +vmime::shared_ptr msg; // suppose we have a message // Create an attachment -vmime::ref att = - vmime::create +vmime::shared_ptr att = + vmime::make_shared ( /* full path to file */ "/home/vincent/paris.jpg", /* content type */ vmime::mediaType("image/jpeg), diff --git a/doc/book/net.tex b/doc/book/net.tex index 88249c1c..05145cf5 100644 --- a/doc/book/net.tex +++ b/doc/book/net.tex @@ -68,7 +68,7 @@ services. Before using a messaging service, you must create and initialize a session object: \begin{lstlisting} -vmime::ref theSession = vmime::create (); +vmime::shared_ptr theSession = vmime::make_shared (); \end{lstlisting} Session properties include: @@ -251,14 +251,14 @@ Depending on the type of service, you will use either {\vcode getStore()} or \begin{lstlisting} vmime::utility:url url("imap://user:pass@imap.example.com"); -vmime::ref st = sess->getStore(url); +vmime::shared_ptr st = sess->getStore(url); \end{lstlisting} and for transport services: \begin{lstlisting} vmime::utility:url url("smtp://smtp.example.com"); -vmime::ref tr = sess->getTransport(url); +vmime::shared_ptr tr = sess->getTransport(url); \end{lstlisting} @@ -271,7 +271,7 @@ properties or by using a custom authenticator (callback). \begin{lstlisting}[caption={Setting user credentials using session properties}] -vmime::ref sess; // Suppose we have a session +vmime::shared_ptr sess; // Suppose we have a session sess->getProperties()["store.imap.auth.username"] = "vincent"; sess->getProperties()["store.imap.auth.password"] = "my-password"; @@ -328,13 +328,13 @@ This is how to use it: \begin{lstlisting} // First, create a session -vmime::ref sess = - vmime::create (); +vmime::shared_ptr sess = + vmime::make_shared (); // Next, initialize a service which will use our authenticator -vmime::ref st = +vmime::shared_ptr st = sess->getStore(vmime::utility::url("imap://imap.example.com"), - /* use our authenticator */ vmime::create ()); + /* use our authenticator */ vmime::make_shared ()); \end{lstlisting} \vnote{An authenticator object should be used with one and only one service @@ -359,9 +359,9 @@ class mySASLAuthenticator : public vmime::security::sasl::defaultSASLAuthenticat { typedef vmime::security::sasl::SASLMechanism mechanism; // save us typing - const std::vector getAcceptableMechanisms - (const std::vector >& available, - vmime::ref suggested) const + const std::vector > getAcceptableMechanisms + (const std::vector >& available, + vmime::shared_ptr suggested) const { // Here, you can sort the SASL mechanisms in the order they will be // tried. If no SASL mechanism is acceptable (ie. for example, not @@ -373,7 +373,7 @@ class mySASLAuthenticator : public vmime::security::sasl::defaultSASLAuthenticat getAcceptableMechanisms(available, suggested); } - void setSASLMechanism(vmime::ref mech) + void setSASLMechanism(vmime::shared_ptr mech) { // This is called when the authentication process is going to // try the specified mechanism. @@ -417,11 +417,11 @@ const vmime::string msgData = // Create a new session vmime::utility::url url("smtp://example.com"); -vmime::ref sess = - vmime::create (); +vmime::shared_ptr sess = + vmime::make_shared (); // Create an instance of the transport service -vmime::ref tr = sess->getTransport(url); +vmime::shared_ptr tr = sess->getTransport(url); // Connect it tr->connect(); @@ -431,7 +431,7 @@ vmime::utility::inputStreamStringAdapter is(msgData); vmime::mailbox from("me@example.org"); vmime::mailboxList to; -to.appendMailbox(vmime::create ("you@example.org")); +to.appendMailbox(vmime::make_shared ("you@example.org")); tr->send( /* expeditor */ from, @@ -471,11 +471,11 @@ store service: // Create a new session vmime::utility::url url("imap://vincent:password@imap:example.org"); -vmime::ref sess = - vmime::create (); +vmime::shared_ptr sess = + vmime::make_shared (); // Create an instance of the transport service -vmime::ref store = sess->getStore(url); +vmime::shared_ptr store = sess->getStore(url); // Connect it store->connect(); @@ -514,7 +514,7 @@ vmime::net::folder::path path; path /= vmime::net::folder::path::component("foo"); path /= vmime::net::folder::path::component("bar"); -vmime::ref fld = store->getFolder(path); +vmime::shared_ptr fld = store->getFolder(path); fld->open(vmime::net::folder::MODE_READ_WRITE); \end{lstlisting} @@ -565,7 +565,7 @@ folder->fetchMessages(allMessages, for (unsigned int i = 0 ; i < allMessages.size() ; ++i) { - vmime::ref msg = allMessages[i]; + vmime::shared_ptr msg = allMessages[i]; const int flags = msg->getFlags(); @@ -576,7 +576,7 @@ for (unsigned int i = 0 ; i < allMessages.size() ; ++i) if (flags & vmime::net::message::FLAG_DELETED) std::cout << " - is deleted" << std::endl; - vmime::ref hdr = msg->getHeader(); + vmime::shared_ptr hdr = msg->getHeader(); std::cout << " - sent on " << hdr->Date()->generate() << std::endl; std::cout << " - sent by " << hdr->From()->generate() << std::endl; @@ -606,8 +606,8 @@ following example extracts the first message in the default folder: \begin{lstlisting}[caption={Extracting messages}] // Get a reference to the folder and to its first message -vmime::ref folder = store->getDefaultFolder(); -vmime::ref msg = folder->getMessage(1); +vmime::shared_ptr folder = store->getDefaultFolder(); +vmime::shared_ptr msg = folder->getMessage(1); // Write the message contents to the standard output vmime::utility::outputStreamAdapter out(std::cout); @@ -643,7 +643,7 @@ The following example will delete the second and the third message from the store. \begin{lstlisting}[caption={Deleting messages}] -vmime::ref folder = store->getDefaultFolder(); +vmime::shared_ptr folder = store->getDefaultFolder(); folder->deleteMessages(vmime::net::messageSet::byNumber(/* from */ 2, /* to */ 3)); @@ -785,7 +785,7 @@ public: ref create() { - return vmime::create (); + return vmime::make_shared (); } }; \end{lstlisting} @@ -794,7 +794,7 @@ Then, call the {\vcode setTimeoutHandlerFactory()} method on the service object to set the time-out handler factory to use during the session: \begin{lstlisting} -theService->setTimeoutHandlerFactory(vmime::create ()); +theService->setTimeoutHandlerFactory(vmime::make_shared ()); \end{lstlisting} @@ -846,7 +846,7 @@ to connect to the server (eg. \emph{imaps} instead of \emph{imap}). This is currently available for SMTP, POP3 and IMAP. \begin{lstlisting} -vmime::ref store = +vmime::shared_ptr store = theSession->getStore(vmime::utility::url("imaps://example.org")); \end{lstlisting} @@ -913,7 +913,7 @@ at the current time; First, we need some code to load existing X.509 certificates: \begin{lstlisting}[caption={Reading a X.509 certificate from a file}] -vmime::ref +vmime::shared_ptr loadX509CertificateFromFile(const std::string& path) { std::ifstream certFile; @@ -925,7 +925,7 @@ vmime::ref } vmime::utility::inputStreamAdapter is(certFile); - vmime::ref cert; + vmime::shared_ptr cert; // Try DER format cert = vmime::security::cert::X509Certificate::import @@ -947,11 +947,11 @@ Then, we can use the {\vcode loadX509CertificateFromFile} function to load certificates and initialize the certificate verifier: \begin{lstlisting}[caption={Using the default certificate verifier}] -vmime::ref vrf = - vmime::create (); +vmime::shared_ptr vrf = + vmime::make_shared (); // Load root CAs (such as Verisign or Thawte) -std::vector > rootCAs; +std::vector > rootCAs; rootCAs.push_back(loadX509CertificateFromFile("/path/to/root-ca1.cer"); rootCAs.push_back(loadX509CertificateFromFile("/path/to/root-ca2.cer"); @@ -960,7 +960,7 @@ rootCAs.push_back(loadX509CertificateFromFile("/path/to/root-ca3.cer"); vrf->setX509RootCAs(rootCAs); // Then, load certificates that the user explicitely chose to trust -std::vector > trusted; +std::vector > trusted; trusted.push_back(loadX509CertificateFromFile("/path/to/trusted-site1.cer"); trusted.push_back(loadX509CertificateFromFile("/path/to/trusted-site2.cer"); @@ -988,10 +988,10 @@ class myCertVerifier : public vmime::security::cert::certificateVerifier { public: - void verify(vmime::ref certs) + void verify(vmime::shared_ptr certs) { // Obtain the subject's certificate - vmime::ref cert = chain->getAt(0); + vmime::shared_ptr cert = chain->getAt(0); std::cout << std::endl; std::cout << "Server sent a '" << cert->getType() << "'" @@ -1018,7 +1018,7 @@ a basic cache implementation.} Finally, to make the service use your own certificate verifier, simply write: \begin{lstlisting} -theService->setCertificateVerifier(vmime::create ()); +theService->setCertificateVerifier(vmime::make_shared ()); \end{lstlisting} \subsection{SSL/TLS Properties} % -------------------------------------------- @@ -1032,10 +1032,10 @@ the session), or they will not be used. The following example shows how to set the cipher suite preferences for TLS: \begin{lstlisting}[caption={Setting TLS cipher suite preferences}] -vmime::ref sess = /* ... */; +vmime::shared_ptr sess = /* ... */; -vmime::ref tlsProps = - vmime::create (); +vmime::shared_ptr tlsProps = + vmime::make_shared (); // for OpenSSL tlsProps->setCipherString("HIGH:!ADH:@STRENGTH"); diff --git a/examples/example1.cpp b/examples/example1.cpp index 851f681a..9948d606 100644 --- a/examples/example1.cpp +++ b/examples/example1.cpp @@ -52,24 +52,24 @@ int main() mb.setExpeditor(vmime::mailbox("me@somewhere.com")); vmime::addressList to; - to.appendAddress(vmime::create ("you@elsewhere.com")); + to.appendAddress(vmime::make_shared ("you@elsewhere.com")); mb.setRecipients(to); vmime::addressList bcc; - bcc.appendAddress(vmime::create ("you-bcc@nowhere.com")); + bcc.appendAddress(vmime::make_shared ("you-bcc@nowhere.com")); mb.setBlindCopyRecipients(bcc); mb.setSubject(vmime::text("My first message generated with vmime::messageBuilder")); // Message body - mb.getTextPart()->setText(vmime::create ( + mb.getTextPart()->setText(vmime::make_shared ( "I'm writing this short text to test message construction " \ "using the vmime::messageBuilder component.")); // Construction - vmime::ref msg = mb.construct(); + vmime::shared_ptr msg = mb.construct(); // Raw text generation std::cout << "Generated message:" << std::endl; diff --git a/examples/example2.cpp b/examples/example2.cpp index d09a597c..56f01b03 100644 --- a/examples/example2.cpp +++ b/examples/example2.cpp @@ -52,24 +52,24 @@ int main() mb.setExpeditor(vmime::mailbox("me@somewhere.com")); vmime::addressList to; - to.appendAddress(vmime::create ("you@elsewhere.com")); + to.appendAddress(vmime::make_shared ("you@elsewhere.com")); mb.setRecipients(to); vmime::addressList bcc; - bcc.appendAddress(vmime::create ("you-bcc@nowhere.com")); + bcc.appendAddress(vmime::make_shared ("you-bcc@nowhere.com")); mb.setBlindCopyRecipients(bcc); mb.setSubject(vmime::text("My first message generated with vmime::messageBuilder")); // Message body - mb.getTextPart()->setText(vmime::create ( + mb.getTextPart()->setText(vmime::make_shared ( "I'm writing this short text to test message construction " \ "with attachment, using the vmime::messageBuilder component.")); // Adding an attachment - vmime::ref a = vmime::create + vmime::shared_ptr a = vmime::make_shared ( "./example2.cpp", // full path to file vmime::mediaType("application/octet-stream"), // content type @@ -82,7 +82,7 @@ int main() mb.attach(a); // Construction - vmime::ref msg = mb.construct(); + vmime::shared_ptr msg = mb.construct(); // Raw text generation vmime::string dataToSend = msg->generate(); diff --git a/examples/example3.cpp b/examples/example3.cpp index 31e26534..56b3c7e7 100644 --- a/examples/example3.cpp +++ b/examples/example3.cpp @@ -52,12 +52,12 @@ int main() mb.setExpeditor(vmime::mailbox("me@somewhere.com")); vmime::addressList to; - to.appendAddress(vmime::create ("you@elsewhere.com")); + to.appendAddress(vmime::make_shared ("you@elsewhere.com")); mb.setRecipients(to); vmime::addressList bcc; - bcc.appendAddress(vmime::create ("you-bcc@nowhere.com")); + bcc.appendAddress(vmime::make_shared ("you-bcc@nowhere.com")); mb.setBlindCopyRecipients(bcc); @@ -69,35 +69,35 @@ int main() // Fill in the text part: the message is available in two formats: HTML and plain text. // HTML text part also includes an inline image (embedded into the message). - vmime::htmlTextPart& textPart = *mb.getTextPart().dynamicCast (); + vmime::htmlTextPart& textPart = *vmime::dynamicCast (mb.getTextPart()); // -- embed an image (the returned "CID" (content identifier) is used to reference // -- the image into HTML content). - vmime::ref fs = + vmime::shared_ptr fs = vmime::platform::getHandler()->getFileSystemFactory(); - vmime::ref imageFile = + vmime::shared_ptr imageFile = fs->create(fs->stringToPath("/path/to/image.jpg")); - vmime::ref fileReader = + vmime::shared_ptr fileReader = imageFile->getFileReader(); - vmime::ref imageCts = - vmime::create + vmime::shared_ptr imageCts = + vmime::make_shared (fileReader->getInputStream(), imageFile->getLength()); - vmime::ref obj = textPart.addObject + vmime::shared_ptr obj = textPart.addObject (imageCts, vmime::mediaType(vmime::mediaTypes::IMAGE, vmime::mediaTypes::IMAGE_JPEG)); // -- message text - textPart.setText(vmime::create + textPart.setText(vmime::make_shared (vmime::string("This is the HTML text.
" "getReferenceId() + vmime::string("\"/>"))); - textPart.setPlainText(vmime::create + textPart.setPlainText(vmime::make_shared ("This is the plain text (without HTML formatting).")); // Construction - vmime::ref msg = mb.construct(); + vmime::shared_ptr msg = mb.construct(); // Raw text generation vmime::string dataToSend = msg->generate(); diff --git a/examples/example6.cpp b/examples/example6.cpp index 721f7624..d2206e7a 100644 --- a/examples/example6.cpp +++ b/examples/example6.cpp @@ -31,8 +31,8 @@ // Global session object -static vmime::ref g_session - = vmime::create (); +static vmime::shared_ptr g_session + = vmime::make_shared (); #if VMIME_HAVE_SASL_SUPPORT @@ -40,9 +40,9 @@ static vmime::ref g_session // SASL authentication handler class interactiveAuthenticator : public vmime::security::sasl::defaultSASLAuthenticator { - const std::vector > getAcceptableMechanisms - (const std::vector >& available, - vmime::ref suggested) const + const std::vector > getAcceptableMechanisms + (const std::vector >& available, + vmime::shared_ptr suggested) const { std::cout << std::endl << "Available SASL mechanisms:" << std::endl; @@ -59,7 +59,7 @@ class interactiveAuthenticator : public vmime::security::sasl::defaultSASLAuthen return defaultSASLAuthenticator::getAcceptableMechanisms(available, suggested); } - void setSASLMechanism(vmime::ref mech) + void setSASLMechanism(vmime::shared_ptr mech) { std::cout << "Trying '" << mech->getName() << "' authentication mechanism" << std::endl; @@ -147,7 +147,7 @@ class interactiveCertificateVerifier : public vmime::security::cert::defaultCert { public: - void verify(vmime::ref chain, const vmime::string& hostname) + void verify(vmime::shared_ptr chain, const vmime::string& hostname) { try { @@ -158,7 +158,7 @@ public: catch (vmime::exceptions::certificate_verification_exception&) { // Obtain subject's certificate - vmime::ref cert = chain->getAt(0); + vmime::shared_ptr cert = chain->getAt(0); std::cout << std::endl; std::cout << "Server sent a '" << cert->getType() << "'" << " certificate." << std::endl; @@ -174,8 +174,8 @@ public: // Accept it, and remember user's choice for later if (cert->getType() == "X.509") { - m_trustedCerts.push_back(cert.dynamicCast - ()); + m_trustedCerts.push_back(vmime::dynamicCast + (cert)); setX509TrustedCerts(m_trustedCerts); defaultCertificateVerifier::verify(chain, hostname); @@ -191,11 +191,11 @@ public: private: - static std::vector > m_trustedCerts; + static std::vector > m_trustedCerts; }; -std::vector > +std::vector > interactiveCertificateVerifier::m_trustedCerts; #endif // VMIME_HAVE_TLS_SUPPORT @@ -208,7 +208,8 @@ std::vector > */ static const std::string findAvailableProtocols(const vmime::net::service::Type type) { - vmime::net::serviceFactory* sf = vmime::net::serviceFactory::getInstance(); + vmime::shared_ptr sf = + vmime::net::serviceFactory::getInstance(); std::ostringstream res; int count = 0; @@ -292,11 +293,11 @@ static std::ostream& operator<<(std::ostream& os, const vmime::exception& e) * @param s structure object * @param level current depth */ -static void printStructure(vmime::ref s, const int level = 0) +static void printStructure(vmime::shared_ptr s, const int level = 0) { for (int i = 0 ; i < s->getPartCount() ; ++i) { - vmime::ref part = s->getPartAt(i); + vmime::shared_ptr part = s->getPartAt(i); for (int j = 0 ; j < level * 2 ; ++j) std::cout << " "; @@ -311,7 +312,7 @@ static void printStructure(vmime::ref s, co } -static const vmime::string getFolderPathString(vmime::ref f) +static const vmime::string getFolderPathString(vmime::shared_ptr f) { const vmime::string n = f->getName().getBuffer(); @@ -321,7 +322,7 @@ static const vmime::string getFolderPathString(vmime::ref f } else { - vmime::ref p = f->getParent(); + vmime::shared_ptr p = f->getParent(); return getFolderPathString(p) + n + "/"; } } @@ -331,14 +332,14 @@ static const vmime::string getFolderPathString(vmime::ref f * * @param folder current folder */ -static void printFolders(vmime::ref folder, const int level = 0) +static void printFolders(vmime::shared_ptr folder, const int level = 0) { for (int j = 0 ; j < level * 2 ; ++j) std::cout << " "; std::cout << getFolderPathString(folder) << std::endl; - std::vector > subFolders = folder->getFolders(false); + std::vector > subFolders = folder->getFolders(false); for (unsigned int i = 0 ; i < subFolders.size() ; ++i) printFolders(subFolders[i], level + 1); @@ -395,8 +396,8 @@ static void sendMessage() vmime::utility::url url(urlString); - vmime::ref tr = - g_session->getTransport(url, vmime::create ()); + vmime::shared_ptr tr = + g_session->getTransport(url, vmime::make_shared ()); #if VMIME_HAVE_TLS_SUPPORT @@ -406,7 +407,7 @@ static void sendMessage() // Set the object responsible for verifying certificates, in the // case a secured connection is used (TLS/SSL) tr->setCertificateVerifier - (vmime::create ()); + (vmime::make_shared ()); #endif // VMIME_HAVE_TLS_SUPPORT @@ -435,7 +436,7 @@ static void sendMessage() cont = (toString.size() != 0); if (cont) - to.appendMailbox(vmime::create (toString)); + to.appendMailbox(vmime::make_shared (toString)); } std::cout << "Enter message data, including headers (end with '.' on a single line):" << std::endl; @@ -505,10 +506,10 @@ static void connectStore() // If no authenticator is given in argument to getStore(), a default one // is used. Its behaviour is to get the user credentials from the // session properties "auth.username" and "auth.password". - vmime::ref st; + vmime::shared_ptr st; if (url.getUsername().empty() || url.getPassword().empty()) - st = g_session->getStore(url, vmime::create ()); + st = g_session->getStore(url, vmime::make_shared ()); else st = g_session->getStore(url); @@ -520,7 +521,7 @@ static void connectStore() // Set the object responsible for verifying certificates, in the // case a secured connection is used (TLS/SSL) st->setCertificateVerifier - (vmime::create ()); + (vmime::make_shared ()); #endif // VMIME_HAVE_TLS_SUPPORT @@ -528,15 +529,15 @@ static void connectStore() st->connect(); // Display some information about the connection - vmime::ref ci = st->getConnectionInfos(); + vmime::shared_ptr ci = st->getConnectionInfos(); std::cout << std::endl; std::cout << "Connected to '" << ci->getHost() << "' (port " << ci->getPort() << ")" << std::endl; std::cout << "Connection is " << (st->isSecuredConnection() ? "" : "NOT ") << "secured." << std::endl; // Open the default folder in this store - vmime::ref f = st->getDefaultFolder(); -// vmime::ref f = st->getFolder(vmime::utility::path("a")); + vmime::shared_ptr f = st->getDefaultFolder(); +// vmime::shared_ptr f = st->getFolder(vmime::utility::path("a")); f->open(vmime::net::folder::MODE_READ_WRITE); @@ -547,7 +548,7 @@ static void connectStore() for (bool cont = true ; cont ; ) { - typedef std::map > MessageList; + typedef std::map > MessageList; MessageList msgList; try @@ -567,7 +568,7 @@ static void connectStore() const int choice = printMenu(choices); // Request message number - vmime::ref msg; + vmime::shared_ptr msg; if (choice != 6 && choice != 7 && choice != 8) { @@ -677,7 +678,7 @@ static void connectStore() // List folders case 7: { - vmime::ref + vmime::shared_ptr root = st->getRootFolder(); printFolders(root); @@ -692,7 +693,7 @@ static void connectStore() std::string path; std::getline(std::cin, path); - vmime::ref newFolder = st->getRootFolder(); + vmime::shared_ptr newFolder = st->getRootFolder(); for (std::string::size_type s = 0, p = 0 ; ; s = p + 1) { @@ -744,16 +745,16 @@ static void connectStore() // Folder renaming { - vmime::ref f = st->getFolder(vmime::net::folder::path("c")); + vmime::shared_ptr f = st->getFolder(vmime::net::folder::path("c")); f->rename(vmime::net::folder::path("c2")); - vmime::ref g = st->getFolder(vmime::net::folder::path("c2")); + vmime::shared_ptr g = st->getFolder(vmime::net::folder::path("c2")); g->rename(vmime::net::folder::path("c")); } // Message copy: copy all messages from 'f' to 'g' { - vmime::ref g = st->getFolder(vmime::net::folder::path("TEMP")); + vmime::shared_ptr g = st->getFolder(vmime::net::folder::path("TEMP")); if (!g->exists()) g->create(vmime::net::folder::TYPE_CONTAINS_MESSAGES); diff --git a/examples/example7.cpp b/examples/example7.cpp index ec7d2b86..241b4d33 100644 --- a/examples/example7.cpp +++ b/examples/example7.cpp @@ -43,18 +43,19 @@ int main() vmime::platform::setHandler(); // Enumerate encoders - vmime::utility::encoder::encoderFactory* ef = vmime::utility::encoder::encoderFactory::getInstance(); + vmime::shared_ptr ef = + vmime::utility::encoder::encoderFactory::getInstance(); std::cout << "Available encoders:" << std::endl; for (int i = 0 ; i < ef->getEncoderCount() ; ++i) { - vmime::ref + vmime::shared_ptr enc = ef->getEncoderAt(i); std::cout << " * " << enc->getName() << std::endl; - vmime::ref e = + vmime::shared_ptr e = vmime::utility::encoder::encoderFactory::getInstance()->create(enc->getName()); std::vector props = e->getAvailableProperties(); @@ -66,7 +67,8 @@ int main() std::cout << std::endl; // Enumerate messaging services and their properties - vmime::net::serviceFactory* sf = vmime::net::serviceFactory::getInstance(); + vmime::shared_ptr sf = + vmime::net::serviceFactory::getInstance(); std::cout << "Available messaging services:" << std::endl; diff --git a/examples/viewer/viewer.cpp b/examples/viewer/viewer.cpp index 5290758a..1d6daa05 100644 --- a/examples/viewer/viewer.cpp +++ b/examples/viewer/viewer.cpp @@ -49,18 +49,18 @@ GtkWidget* textArea = NULL; GtkTreeStore* treeModel = NULL; -vmime::ref currentMessage = NULL; +vmime::shared_ptr currentMessage; -void insertRowInModel(GtkTreeStore* model, vmime::ref comp, GtkTreeIter* parent = NULL) +void insertRowInModel(GtkTreeStore* model, vmime::shared_ptr comp, GtkTreeIter* parent = NULL) { GtkTreeIter iter; gtk_tree_store_append(model, &iter, parent); gtk_tree_store_set(model, &iter, 0, typeid(*comp).name(), 1, comp.get(), -1); - const std::vector > children = comp->getChildComponents(); + const std::vector > children = comp->getChildComponents(); for (int i = 0 ; i < children.size() ; ++i) { @@ -139,7 +139,7 @@ void openFile(const std::string& filename) } while (file.gcount()); - vmime::ref msg = vmime::create (); + vmime::shared_ptr msg = vmime::make_shared (); msg->parse(data); currentMessage = msg; diff --git a/src/address.cpp b/src/address.cpp index b57892d5..08a478ec 100644 --- a/src/address.cpp +++ b/src/address.cpp @@ -66,7 +66,7 @@ address-list = (address *("," address)) / obs-addr-list */ -ref
address::parseNext +shared_ptr
address::parseNext (const parsingContext& ctx, const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition, bool *isLastAddressOfGroup) { @@ -196,9 +196,12 @@ ref
address::parseNext // Parse extracted address (mailbox or group) if (pos != start) { - ref
parsedAddress = isGroup - ? create ().dynamicCast
() - : create ().dynamicCast
(); + shared_ptr
parsedAddress; + + if (isGroup) + parsedAddress = make_shared (); + else + parsedAddress = make_shared (); parsedAddress->parse(ctx, buffer, start, pos, NULL); parsedAddress->setParsedBounds(start, pos); @@ -206,7 +209,7 @@ ref
address::parseNext return (parsedAddress); } - return (NULL); + return null; } diff --git a/src/addressList.cpp b/src/addressList.cpp index 326a54e3..957be503 100644 --- a/src/addressList.cpp +++ b/src/addressList.cpp @@ -60,7 +60,7 @@ void addressList::parseImpl while (pos < end) { - ref
parsedAddress = address::parseNext(ctx, buffer, pos, end, &pos, NULL); + shared_ptr
parsedAddress = address::parseNext(ctx, buffer, pos, end, &pos, NULL); if (parsedAddress != NULL) m_list.push_back(parsedAddress); @@ -84,7 +84,7 @@ void addressList::generateImpl if (!m_list.empty()) { - for (std::vector >::const_iterator i = m_list.begin() ; ; ) + for (std::vector >::const_iterator i = m_list.begin() ; ; ) { (*i)->generate(ctx, os, pos, &pos); @@ -107,10 +107,10 @@ void addressList::copyFrom(const component& other) removeAllAddresses(); - for (std::vector >::const_iterator it = addrList.m_list.begin() ; + for (std::vector >::const_iterator it = addrList.m_list.begin() ; it != addrList.m_list.end() ; ++it) { - m_list.push_back((*it)->clone().dynamicCast
()); + m_list.push_back(vmime::clone(*it)); } } @@ -127,27 +127,27 @@ addressList& addressList::operator=(const mailboxList& other) removeAllAddresses(); for (size_t i = 0 ; i < other.getMailboxCount() ; ++i) - m_list.push_back(other.getMailboxAt(i)->clone().dynamicCast
()); + m_list.push_back(dynamicCast
(other.getMailboxAt(i)->clone())); return (*this); } -ref addressList::clone() const +shared_ptr addressList::clone() const { - return vmime::create (*this); + return make_shared (*this); } -void addressList::appendAddress(ref
addr) +void addressList::appendAddress(shared_ptr
addr) { m_list.push_back(addr); } -void addressList::insertAddressBefore(ref
beforeAddress, ref
addr) +void addressList::insertAddressBefore(shared_ptr
beforeAddress, shared_ptr
addr) { - const std::vector >::iterator it = std::find + const std::vector >::iterator it = std::find (m_list.begin(), m_list.end(), beforeAddress); if (it == m_list.end()) @@ -157,15 +157,15 @@ void addressList::insertAddressBefore(ref
beforeAddress, ref
} -void addressList::insertAddressBefore(const size_t pos, ref
addr) +void addressList::insertAddressBefore(const size_t pos, shared_ptr
addr) { m_list.insert(m_list.begin() + pos, addr); } -void addressList::insertAddressAfter(ref
afterAddress, ref
addr) +void addressList::insertAddressAfter(shared_ptr
afterAddress, shared_ptr
addr) { - const std::vector >::iterator it = std::find + const std::vector >::iterator it = std::find (m_list.begin(), m_list.end(), afterAddress); if (it == m_list.end()) @@ -175,15 +175,15 @@ void addressList::insertAddressAfter(ref
afterAddress, ref
a } -void addressList::insertAddressAfter(const size_t pos, ref
addr) +void addressList::insertAddressAfter(const size_t pos, shared_ptr
addr) { m_list.insert(m_list.begin() + pos + 1, addr); } -void addressList::removeAddress(ref
addr) +void addressList::removeAddress(shared_ptr
addr) { - const std::vector >::iterator it = std::find + const std::vector >::iterator it = std::find (m_list.begin(), m_list.end(), addr); if (it == m_list.end()) @@ -195,7 +195,7 @@ void addressList::removeAddress(ref
addr) void addressList::removeAddress(const size_t pos) { - const std::vector >::iterator it = m_list.begin() + pos; + const std::vector >::iterator it = m_list.begin() + pos; m_list.erase(it); } @@ -219,25 +219,25 @@ bool addressList::isEmpty() const } -ref
addressList::getAddressAt(const size_t pos) +shared_ptr
addressList::getAddressAt(const size_t pos) { return (m_list[pos]); } -const ref addressList::getAddressAt(const size_t pos) const +const shared_ptr addressList::getAddressAt(const size_t pos) const { return (m_list[pos]); } -const std::vector > addressList::getAddressList() const +const std::vector > addressList::getAddressList() const { - std::vector > list; + std::vector > list; list.reserve(m_list.size()); - for (std::vector >::const_iterator it = m_list.begin() ; + for (std::vector >::const_iterator it = m_list.begin() ; it != m_list.end() ; ++it) { list.push_back(*it); @@ -247,15 +247,15 @@ const std::vector > addressList::getAddressList() const } -const std::vector > addressList::getAddressList() +const std::vector > addressList::getAddressList() { return (m_list); } -const std::vector > addressList::getChildComponents() +const std::vector > addressList::getChildComponents() { - std::vector > list; + std::vector > list; copy_vector(m_list, list); @@ -263,21 +263,21 @@ const std::vector > addressList::getChildComponents() } -ref addressList::toMailboxList() const +shared_ptr addressList::toMailboxList() const { - ref res = vmime::create (); + shared_ptr res = make_shared (); - for (std::vector >::const_iterator it = m_list.begin() ; + for (std::vector >::const_iterator it = m_list.begin() ; it != m_list.end() ; ++it) { - ref addr = *it; + shared_ptr addr = *it; if (addr->isGroup()) { - const std::vector > mailboxes = - addr.dynamicCast ()->getMailboxList(); + const std::vector > mailboxes = + dynamicCast (addr)->getMailboxList(); - for (std::vector >::const_iterator jt = mailboxes.begin() ; + for (std::vector >::const_iterator jt = mailboxes.begin() ; jt != mailboxes.end() ; ++jt) { res->appendMailbox(vmime::clone(*jt)); @@ -285,7 +285,7 @@ ref addressList::toMailboxList() const } else { - res->appendMailbox(addr->clone().dynamicCast ()); + res->appendMailbox(dynamicCast (addr->clone())); } } diff --git a/src/attachmentHelper.cpp b/src/attachmentHelper.cpp index 16e42bd4..7168fd93 100644 --- a/src/attachmentHelper.cpp +++ b/src/attachmentHelper.cpp @@ -39,15 +39,14 @@ namespace vmime // static bool attachmentHelper::isBodyPartAnAttachment - (ref part, const unsigned int options) + (shared_ptr part, const unsigned int options) { try { - const contentDispositionField& cdf = dynamic_cast - (*part->getHeader()->findField(fields::CONTENT_DISPOSITION)); + const contentDispositionField& cdf = + *part->getHeader()->findField (fields::CONTENT_DISPOSITION); - const contentDisposition disp = *cdf.getValue() - .dynamicCast (); + const contentDisposition disp = *cdf.getValue (); if (disp.getName() != contentDispositionTypes::INLINE) return true; @@ -80,10 +79,10 @@ bool attachmentHelper::isBodyPartAnAttachment try { - const contentTypeField& ctf = dynamic_cast - (*part->getHeader()->findField(fields::CONTENT_TYPE)); + const contentTypeField& ctf = + *part->getHeader()->findField (fields::CONTENT_TYPE); - type = *ctf.getValue().dynamicCast (); + type = *ctf.getValue (); if (ctf.hasParameter("name")) hasContentTypeName = true; @@ -125,20 +124,20 @@ bool attachmentHelper::isBodyPartAnAttachment // static -ref attachmentHelper::getBodyPartAttachment - (ref part, const unsigned int options) +shared_ptr attachmentHelper::getBodyPartAttachment + (shared_ptr part, const unsigned int options) { if (!isBodyPartAnAttachment(part, options)) - return NULL; + return null; mediaType type; try { - const contentTypeField& ctf = dynamic_cast - (*part->getHeader()->findField(fields::CONTENT_TYPE)); + const contentTypeField& ctf = + *part->getHeader()->findField (fields::CONTENT_TYPE); - type = *ctf.getValue().dynamicCast (); + type = *ctf.getValue (); } catch (exceptions::no_such_field&) { @@ -150,30 +149,30 @@ ref attachmentHelper::getBodyPartAttachment if (type.getType() == mediaTypes::MESSAGE && type.getSubType() == mediaTypes::MESSAGE_RFC822) { - return vmime::create (part); + return make_shared (part); } else { - return vmime::create (part); + return make_shared (part); } } // static -const std::vector > +const std::vector > attachmentHelper::findAttachmentsInMessage - (ref msg, const unsigned int options) + (shared_ptr msg, const unsigned int options) { return findAttachmentsInBodyPart(msg, options); } // static -const std::vector > +const std::vector > attachmentHelper::findAttachmentsInBodyPart - (ref part, const unsigned int options) + (shared_ptr part, const unsigned int options) { - std::vector > atts; + std::vector > atts; // Test this part if (isBodyPartAnAttachment(part, options)) @@ -183,11 +182,11 @@ const std::vector > // Find in sub-parts else { - ref bdy = part->getBody(); + shared_ptr bdy = part->getBody(); for (size_t i = 0 ; i < bdy->getPartCount() ; ++i) { - std::vector > partAtts = + std::vector > partAtts = findAttachmentsInBodyPart(bdy->getPartAt(i), options); std::copy(partAtts.begin(), partAtts.end(), std::back_inserter(atts)); @@ -199,7 +198,7 @@ const std::vector > // static -void attachmentHelper::addAttachment(ref msg, ref att) +void attachmentHelper::addAttachment(shared_ptr msg, shared_ptr att) { // We simply search for a "multipart/mixed" part. If no one exists, // create it in the root part. This (very simple) algorithm should @@ -208,7 +207,7 @@ void attachmentHelper::addAttachment(ref msg, ref att) vmime::mediaType mpMixed(vmime::mediaTypes::MULTIPART, vmime::mediaTypes::MULTIPART_MIXED); - ref part = findBodyPart(msg, mpMixed); + shared_ptr part = findBodyPart(msg, mpMixed); if (part == NULL) // create it { @@ -216,7 +215,7 @@ void attachmentHelper::addAttachment(ref msg, ref att) { // Create a new container part for the parts that were in // the root part of the message - ref container = vmime::create (); + shared_ptr container = make_shared (); try { @@ -238,7 +237,7 @@ void attachmentHelper::addAttachment(ref msg, ref att) } // Move parts from the root part to this new part - const std::vector > partList = + const std::vector > partList = msg->getBody()->getPartList(); msg->getBody()->removeAllParts(); @@ -253,7 +252,7 @@ void attachmentHelper::addAttachment(ref msg, ref att) // The message is a simple (RFC-822) message, and do not // contains any MIME part. Move the contents from the // root to a new child part. - ref child = vmime::create (); + shared_ptr child = make_shared (); if (msg->getHeader()->hasField(fields::CONTENT_TYPE)) { @@ -268,7 +267,7 @@ void attachmentHelper::addAttachment(ref msg, ref att) } child->getBody()->setContents(msg->getBody()->getContents()); - msg->getBody()->setContents(vmime::create ()); + msg->getBody()->setContents(make_shared ()); msg->getBody()->appendPart(child); } @@ -288,32 +287,32 @@ void attachmentHelper::addAttachment(ref msg, ref att) // static -ref attachmentHelper::findBodyPart - (ref part, const mediaType& type) +shared_ptr attachmentHelper::findBodyPart + (shared_ptr part, const mediaType& type) { if (part->getBody()->getContentType() == type) return part; // Try in sub-parts - ref bdy = part->getBody(); + shared_ptr bdy = part->getBody(); for (size_t i = 0 ; i < bdy->getPartCount() ; ++i) { - ref found = + shared_ptr found = findBodyPart(bdy->getPartAt(i), type); if (found != NULL) return found; } - return NULL; + return null; } // static -void attachmentHelper::addAttachment(ref msg, ref amsg) +void attachmentHelper::addAttachment(shared_ptr msg, shared_ptr amsg) { - ref att = vmime::create (amsg); + shared_ptr att = make_shared (amsg); addAttachment(msg, att); } diff --git a/src/base.cpp b/src/base.cpp index d5f3e787..f7985376 100644 --- a/src/base.cpp +++ b/src/base.cpp @@ -98,9 +98,13 @@ const string CRLF = "\r\n"; const string SUPPORTED_MIME_VERSION = "1.0"; -/** Null reference. +#ifndef VMIME_BUILDING_DOC + +/** Null shared pointer. */ -const null_ref null = null_ref(); +nullPtrType null; + +#endif // VMIME_BUILDING_DOC // Line length limits diff --git a/src/body.cpp b/src/body.cpp index f1a8cc0f..8d6bab3f 100644 --- a/src/body.cpp +++ b/src/body.cpp @@ -44,7 +44,7 @@ namespace vmime body::body() - : m_contents(create ()), m_part(NULL), m_header(NULL) + : m_contents(make_shared ()) { } @@ -56,7 +56,7 @@ body::~body() // static utility::stream::size_type body::findNextBoundaryPosition - (ref parser, const string& boundary, + (shared_ptr parser, const string& boundary, const utility::stream::size_type position, const utility::stream::size_type end, utility::stream::size_type* boundaryStart, utility::stream::size_type* boundaryEnd) { @@ -129,7 +129,7 @@ utility::stream::size_type body::findNextBoundaryPosition void body::parseImpl (const parsingContext& /* ctx */, - ref parser, + shared_ptr parser, const utility::stream::size_type position, const utility::stream::size_type end, utility::stream::size_type* newPosition) @@ -156,10 +156,10 @@ void body::parseImpl try { - const ref ctf = - m_header.acquire()->findField(fields::CONTENT_TYPE).dynamicCast (); + const shared_ptr ctf = + m_part->getHeader()->findField (fields::CONTENT_TYPE); - const mediaType type = *ctf->getValue().dynamicCast (); + const mediaType type = *ctf->getValue (); if (type.getType() == mediaTypes::MULTIPART) { @@ -302,7 +302,7 @@ void body::parseImpl } else // index > 0 { - ref part = vmime::create (); + shared_ptr part = m_part->createChildPart(); // End before start may happen on empty bodyparts (directly // successive boundaries without even a line-break) @@ -310,7 +310,6 @@ void body::parseImpl std::swap(partStart, partEnd); part->parse(parser, partStart, partEnd, NULL); - part->m_parent = m_part; m_parts.push_back(part); } @@ -322,12 +321,12 @@ void body::parseImpl (parser, boundary, boundaryEnd, end, &boundaryStart, &boundaryEnd); } - m_contents = vmime::create (); + m_contents = make_shared (); // Last part was not found: recover from missing boundary if (!lastPart && pos == utility::stream::npos) { - ref part = vmime::create (); + shared_ptr part = m_part->createChildPart(); try { @@ -338,8 +337,6 @@ void body::parseImpl throw; } - part->m_parent = m_part; - m_parts.push_back(part); } // Treat remaining text as epilog @@ -358,10 +355,10 @@ void body::parseImpl try { - const ref cef = - m_header.acquire()->findField(fields::CONTENT_TRANSFER_ENCODING); + const shared_ptr cef = + m_part->getHeader()->findField(fields::CONTENT_TRANSFER_ENCODING); - enc = *cef->getValue().dynamicCast (); + enc = *cef->getValue (); } catch (exceptions::no_such_field&) { @@ -372,11 +369,11 @@ void body::parseImpl // Extract the (encoded) contents const utility::stream::size_type length = end - position; - ref contentStream = - vmime::create + shared_ptr contentStream = + make_shared (parser->getUnderlyingStream(), position, length); - m_contents = vmime::create (contentStream, length, enc); + m_contents = make_shared (contentStream, length, enc); } setParsedBounds(position, end); @@ -429,7 +426,7 @@ void body::generateImpl { string boundary; - if (m_header.acquire() == NULL) + if (!m_part) { boundary = generateRandomBoundaryString(); } @@ -437,9 +434,8 @@ void body::generateImpl { try { - ref ctf = - m_header.acquire()->findField(fields::CONTENT_TYPE) - .dynamicCast (); + shared_ptr ctf = + m_part->getHeader()->findField (fields::CONTENT_TYPE); boundary = ctf->getBoundary(); } @@ -494,7 +490,7 @@ void body::generateImpl else { // Generate the contents - ref contents = m_contents->clone(); + shared_ptr contents = m_contents->clone(); contents->setContentTypeHint(getContentType()); contents->generate(os, getEncoding(), ctx.getMaxLineLength()); @@ -548,8 +544,8 @@ utility::stream::size_type body::getGeneratedSize(const generationContext& ctx) // Simple body else { - ref srcEncoder = m_contents->getEncoding().getEncoder(); - ref dstEncoder = getEncoding().getEncoder(); + shared_ptr srcEncoder = m_contents->getEncoding().getEncoder(); + shared_ptr dstEncoder = getEncoding().getEncoder(); return dstEncoder->getEncodedSize(srcEncoder->getDecodedSize(m_contents->getLength())); } @@ -646,7 +642,8 @@ bool body::isValidBoundary(const string& boundary) void body::setContentType(const mediaType& type, const charset& chset) { - ref ctf = m_header.acquire()->ContentType().dynamicCast (); + shared_ptr ctf = + dynamicCast (m_part->getHeader()->ContentType()); ctf->setValue(type); ctf->setCharset(chset); @@ -655,7 +652,7 @@ void body::setContentType(const mediaType& type, const charset& chset) void body::setContentType(const mediaType& type) { - m_header.acquire()->ContentType()->setValue(type); + m_part->getHeader()->ContentType()->setValue(type); } @@ -663,10 +660,10 @@ const mediaType body::getContentType() const { try { - ref ctf = - m_header.acquire()->findField(fields::CONTENT_TYPE).dynamicCast (); + shared_ptr ctf = + m_part->getHeader()->findField (fields::CONTENT_TYPE); - return (*ctf->getValue().dynamicCast ()); + return (*ctf->getValue ()); } catch (exceptions::no_such_field&) { @@ -681,8 +678,8 @@ void body::setCharset(const charset& chset) // If a Content-Type field exists, set charset try { - ref ctf = - m_header.acquire()->findField(fields::CONTENT_TYPE).dynamicCast (); + shared_ptr ctf = + m_part->getHeader()->findField (fields::CONTENT_TYPE); ctf->setCharset(chset); } @@ -699,8 +696,8 @@ const charset body::getCharset() const { try { - const ref ctf = - m_header.acquire()->findField(fields::CONTENT_TYPE).dynamicCast (); + const shared_ptr ctf = + m_part->getHeader()->findField (fields::CONTENT_TYPE); return (ctf->getCharset()); } @@ -719,7 +716,7 @@ const charset body::getCharset() const void body::setEncoding(const encoding& enc) { - m_header.acquire()->ContentTransferEncoding()->setValue(enc); + m_part->getHeader()->ContentTransferEncoding()->setValue(enc); } @@ -727,10 +724,10 @@ const encoding body::getEncoding() const { try { - const ref cef = - m_header.acquire()->findField(fields::CONTENT_TRANSFER_ENCODING); + const shared_ptr cef = + m_part->getHeader()->findField(fields::CONTENT_TRANSFER_ENCODING); - return (*cef->getValue().dynamicCast ()); + return *cef->getValue (); } catch (exceptions::no_such_field&) { @@ -747,30 +744,28 @@ const encoding body::getEncoding() const } -void body::setParentPart(ref parent) +void body::setParentPart(bodyPart* parent) { m_part = parent; - m_header = (parent != NULL ? parent->getHeader() : NULL); - for (std::vector >::iterator it = m_parts.begin() ; + for (std::vector >::iterator it = m_parts.begin() ; it != m_parts.end() ; ++it) { - ref childPart = *it; - childPart->m_parent = parent; + shared_ptr childPart = *it; + parent->importChildPart(childPart); } } bool body::isRootPart() const { - ref part = m_part.acquire(); - return (part == NULL || part->getParentPart() == NULL); + return (m_part == NULL || m_part->getParentPart() == NULL); } -ref body::clone() const +shared_ptr body::clone() const { - ref bdy = vmime::create (); + shared_ptr bdy = make_shared (); bdy->copyFrom(*this); @@ -791,9 +786,9 @@ void body::copyFrom(const component& other) for (size_t p = 0 ; p < bdy.getPartCount() ; ++p) { - ref part = bdy.getPartAt(p)->clone().dynamicCast (); + shared_ptr part = m_part->createChildPart(); - part->m_parent = m_part; + part->copyFrom(*bdy.getPartAt(p)); m_parts.push_back(part); } @@ -831,19 +826,19 @@ void body::setEpilogText(const string& epilogText) } -const ref body::getContents() const +const shared_ptr body::getContents() const { return (m_contents); } -void body::setContents(ref contents) +void body::setContents(shared_ptr contents) { m_contents = contents; } -void body::setContents(ref contents, const mediaType& type) +void body::setContents(shared_ptr contents, const mediaType& type) { m_contents = contents; @@ -851,7 +846,7 @@ void body::setContents(ref contents, const mediaType& typ } -void body::setContents(ref contents, const mediaType& type, const charset& chset) +void body::setContents(shared_ptr contents, const mediaType& type, const charset& chset) { m_contents = contents; @@ -859,7 +854,7 @@ void body::setContents(ref contents, const mediaType& typ } -void body::setContents(ref contents, const mediaType& type, +void body::setContents(shared_ptr contents, const mediaType& type, const charset& chset, const encoding& enc) { m_contents = contents; @@ -869,19 +864,25 @@ void body::setContents(ref contents, const mediaType& typ } -void body::initNewPart(ref part) +void body::initNewPart(shared_ptr part) { - part->m_parent = m_part; + // A part can be in only one body at the same time: if part is + // already attached to a parent part, remove it from the current + // parent part + if (part->getParentPart()) + part->getParentPart()->getBody()->removePart(part); - ref
hdr = m_header.acquire(); - - if (hdr != NULL) + if (m_part != NULL) { + m_part->importChildPart(part); + + shared_ptr
hdr = m_part->getHeader(); + // Check whether we have a boundary string try { - ref ctf = - hdr->findField(fields::CONTENT_TYPE).dynamicCast (); + shared_ptr ctf = + hdr->findField (fields::CONTENT_TYPE); try { @@ -896,7 +897,7 @@ void body::initNewPart(ref part) ctf->setBoundary(generateRandomBoundaryString()); } - if (ctf->getValue().dynamicCast ()->getType() != mediaTypes::MULTIPART) + if (ctf->getValue ()->getType() != mediaTypes::MULTIPART) { // Warning: multi-part body but the Content-Type is // not specified as "multipart/..." @@ -906,8 +907,8 @@ void body::initNewPart(ref part) { // No "Content-Type" field: create a new one and generate // a random boundary string. - ref ctf = - hdr->getField(fields::CONTENT_TYPE).dynamicCast (); + shared_ptr ctf = + hdr->getField (fields::CONTENT_TYPE); ctf->setValue(mediaType(mediaTypes::MULTIPART, mediaTypes::MULTIPART_MIXED)); ctf->setBoundary(generateRandomBoundaryString()); @@ -916,7 +917,7 @@ void body::initNewPart(ref part) } -void body::appendPart(ref part) +void body::appendPart(shared_ptr part) { initNewPart(part); @@ -924,11 +925,11 @@ void body::appendPart(ref part) } -void body::insertPartBefore(ref beforePart, ref part) +void body::insertPartBefore(shared_ptr beforePart, shared_ptr part) { initNewPart(part); - const std::vector >::iterator it = std::find + const std::vector >::iterator it = std::find (m_parts.begin(), m_parts.end(), beforePart); if (it == m_parts.end()) @@ -938,7 +939,7 @@ void body::insertPartBefore(ref beforePart, ref part) } -void body::insertPartBefore(const size_t pos, ref part) +void body::insertPartBefore(const size_t pos, shared_ptr part) { initNewPart(part); @@ -946,11 +947,11 @@ void body::insertPartBefore(const size_t pos, ref part) } -void body::insertPartAfter(ref afterPart, ref part) +void body::insertPartAfter(shared_ptr afterPart, shared_ptr part) { initNewPart(part); - const std::vector >::iterator it = std::find + const std::vector >::iterator it = std::find (m_parts.begin(), m_parts.end(), afterPart); if (it == m_parts.end()) @@ -960,7 +961,7 @@ void body::insertPartAfter(ref afterPart, ref part) } -void body::insertPartAfter(const size_t pos, ref part) +void body::insertPartAfter(const size_t pos, shared_ptr part) { initNewPart(part); @@ -968,9 +969,9 @@ void body::insertPartAfter(const size_t pos, ref part) } -void body::removePart(ref part) +void body::removePart(shared_ptr part) { - const std::vector >::iterator it = std::find + const std::vector >::iterator it = std::find (m_parts.begin(), m_parts.end(), part); if (it == m_parts.end()) @@ -1004,25 +1005,25 @@ bool body::isEmpty() const } -ref body::getPartAt(const size_t pos) +shared_ptr body::getPartAt(const size_t pos) { return (m_parts[pos]); } -const ref body::getPartAt(const size_t pos) const +const shared_ptr body::getPartAt(const size_t pos) const { return (m_parts[pos]); } -const std::vector > body::getPartList() const +const std::vector > body::getPartList() const { - std::vector > list; + std::vector > list; list.reserve(m_parts.size()); - for (std::vector >::const_iterator it = m_parts.begin() ; + for (std::vector >::const_iterator it = m_parts.begin() ; it != m_parts.end() ; ++it) { list.push_back(*it); @@ -1032,15 +1033,15 @@ const std::vector > body::getPartList() const } -const std::vector > body::getPartList() +const std::vector > body::getPartList() { return (m_parts); } -const std::vector > body::getChildComponents() +const std::vector > body::getChildComponents() { - std::vector > list; + std::vector > list; copy_vector(m_parts, list); diff --git a/src/bodyPart.cpp b/src/bodyPart.cpp index f63fd670..be5b8e3a 100644 --- a/src/bodyPart.cpp +++ b/src/bodyPart.cpp @@ -29,26 +29,17 @@ namespace vmime bodyPart::bodyPart() - : m_header(vmime::create
()), - m_body(vmime::create ()), - m_parent(NULL) + : m_header(make_shared
()), + m_body(make_shared ()), + m_parent() { - m_body->setParentPart(thisRef().dynamicCast ()); -} - - -bodyPart::bodyPart(weak_ref parentPart) - : m_header(vmime::create
()), - m_body(vmime::create ()), - m_parent(parentPart) -{ - m_body->setParentPart(thisRef().dynamicCast ()); + m_body->setParentPart(this); } void bodyPart::parseImpl (const parsingContext& ctx, - ref parser, + shared_ptr parser, const utility::stream::size_type position, const utility::stream::size_type end, utility::stream::size_type* newPosition) @@ -88,11 +79,11 @@ utility::stream::size_type bodyPart::getGeneratedSize(const generationContext& c } -ref bodyPart::clone() const +shared_ptr bodyPart::clone() const { - ref p = vmime::create (); + shared_ptr p = make_shared (); - p->m_parent = null; + p->m_parent = NULL; p->m_header->copyFrom(*m_header); p->m_body->copyFrom(*m_body); @@ -117,64 +108,79 @@ bodyPart& bodyPart::operator=(const bodyPart& other) } -const ref bodyPart::getHeader() const +const shared_ptr bodyPart::getHeader() const { return (m_header); } -ref
bodyPart::getHeader() +shared_ptr
bodyPart::getHeader() { return (m_header); } -void bodyPart::setHeader(ref
h) +void bodyPart::setHeader(shared_ptr
h) { m_header = h; } -const ref bodyPart::getBody() const +const shared_ptr bodyPart::getBody() const { return (m_body); } -ref bodyPart::getBody() +shared_ptr bodyPart::getBody() { return (m_body); } -void bodyPart::setBody(ref b) +void bodyPart::setBody(shared_ptr b) { - ref oldPart = b->m_part.acquire(); + bodyPart* oldPart = b->m_part; m_body = b; - m_body->setParentPart(thisRef().dynamicCast ()); + m_body->setParentPart(this); // A body is associated to one and only one part if (oldPart != NULL) - oldPart->setBody(vmime::create ()); + oldPart->setBody(make_shared ()); } -ref bodyPart::getParentPart() +bodyPart* bodyPart::getParentPart() { - return m_parent.acquire(); + return m_parent; } -ref bodyPart::getParentPart() const +const bodyPart* bodyPart::getParentPart() const { - return m_parent.acquire(); + return m_parent; } -const std::vector > bodyPart::getChildComponents() +shared_ptr bodyPart::createChildPart() { - std::vector > list; + shared_ptr part = make_shared (); + part->m_parent = this; + + return part; +} + + +void bodyPart::importChildPart(shared_ptr part) +{ + part->m_parent = this; +} + + +const std::vector > bodyPart::getChildComponents() +{ + std::vector > list; list.push_back(m_header); list.push_back(m_body); diff --git a/src/bodyPartAttachment.cpp b/src/bodyPartAttachment.cpp index 5ae433ad..c8361238 100644 --- a/src/bodyPartAttachment.cpp +++ b/src/bodyPartAttachment.cpp @@ -28,7 +28,7 @@ namespace vmime { -bodyPartAttachment::bodyPartAttachment(ref part) +bodyPartAttachment::bodyPartAttachment(shared_ptr part) : m_part(part) { } @@ -40,7 +40,7 @@ const mediaType bodyPartAttachment::getType() const try { - type = *getContentType()->getValue().dynamicCast (); + type = *getContentType()->getValue (); } catch (exceptions::no_such_field&) { @@ -76,7 +76,7 @@ const word bodyPartAttachment::getName() const { try { - ref prm = getContentType()->findParameter("name"); + shared_ptr prm = getContentType()->findParameter("name"); if (prm != NULL) name = prm->getValue(); @@ -101,10 +101,10 @@ const text bodyPartAttachment::getDescription() const try { - ref cd = + shared_ptr cd = getHeader()->findField(fields::CONTENT_DESCRIPTION); - description = *cd->getValue().dynamicCast (); + description = *cd->getValue (); } catch (exceptions::no_such_field&) { @@ -121,39 +121,37 @@ const encoding bodyPartAttachment::getEncoding() const } -const ref bodyPartAttachment::getData() const +const shared_ptr bodyPartAttachment::getData() const { return m_part->getBody()->getContents(); } -ref bodyPartAttachment::getPart() const +shared_ptr bodyPartAttachment::getPart() const { return m_part; } -ref bodyPartAttachment::getHeader() const +shared_ptr bodyPartAttachment::getHeader() const { return m_part->getHeader(); } -ref bodyPartAttachment::getContentDisposition() const +shared_ptr bodyPartAttachment::getContentDisposition() const { - return getHeader()->findField(fields::CONTENT_DISPOSITION). - dynamicCast (); + return getHeader()->findField (fields::CONTENT_DISPOSITION); } -ref bodyPartAttachment::getContentType() const +shared_ptr bodyPartAttachment::getContentType() const { - return getHeader()->findField(fields::CONTENT_TYPE). - dynamicCast (); + return getHeader()->findField (fields::CONTENT_TYPE); } -void bodyPartAttachment::generateIn(ref /* parent */) const +void bodyPartAttachment::generateIn(shared_ptr /* parent */) const { // Not used } diff --git a/src/charset.cpp b/src/charset.cpp index f68c7c4f..03c7b6a9 100644 --- a/src/charset.cpp +++ b/src/charset.cpp @@ -90,7 +90,7 @@ void charset::convert(utility::inputStream& in, utility::outputStream& out, const charset& source, const charset& dest, const charsetConverterOptions& opts) { - ref conv = charsetConverter::create(source, dest, opts); + shared_ptr conv = charsetConverter::create(source, dest, opts); conv->convert(in, out); } @@ -104,7 +104,7 @@ void charset::convert(const string& in, string& out, const charset& source, cons return; } - ref conv = charsetConverter::create(source, dest, opts); + shared_ptr conv = charsetConverter::create(source, dest, opts); conv->convert(in, out); } @@ -134,9 +134,9 @@ bool charset::operator!=(const charset& value) const } -ref charset::clone() const +shared_ptr charset::clone() const { - return vmime::create (m_name); + return make_shared (m_name); } @@ -152,9 +152,9 @@ void charset::copyFrom(const component& other) } -const std::vector > charset::getChildComponents() +const std::vector > charset::getChildComponents() { - return std::vector >(); + return std::vector >(); } diff --git a/src/charsetConverter.cpp b/src/charsetConverter.cpp index 5d3ab626..87886823 100644 --- a/src/charsetConverter.cpp +++ b/src/charsetConverter.cpp @@ -31,12 +31,12 @@ namespace vmime // static -ref charsetConverter::create +shared_ptr charsetConverter::create (const charset& source, const charset& dest, const charsetConverterOptions& opts) { if (source == "idna" || dest == "idna") - return vmime::create (source, dest, opts); + return make_shared (source, dest, opts); else return createGenericConverter(source, dest, opts); } diff --git a/src/charsetConverter_iconv.cpp b/src/charsetConverter_iconv.cpp index 43556298..0efa8445 100644 --- a/src/charsetConverter_iconv.cpp +++ b/src/charsetConverter_iconv.cpp @@ -89,11 +89,11 @@ namespace vmime // static -ref charsetConverter::createGenericConverter +shared_ptr charsetConverter::createGenericConverter (const charset& source, const charset& dest, const charsetConverterOptions& opts) { - return vmime::create (source, dest, opts); + return make_shared (source, dest, opts); } @@ -222,9 +222,9 @@ void charsetConverter_iconv::convert(const string& in, string& out) } -ref charsetConverter_iconv::getFilteredOutputStream(utility::outputStream& os) +shared_ptr charsetConverter_iconv::getFilteredOutputStream(utility::outputStream& os) { - return vmime::create (m_source, m_dest, &os); + return make_shared (m_source, m_dest, &os); } diff --git a/src/charsetConverter_icu.cpp b/src/charsetConverter_icu.cpp index 581d933b..a641d5ee 100644 --- a/src/charsetConverter_icu.cpp +++ b/src/charsetConverter_icu.cpp @@ -53,11 +53,11 @@ namespace vmime // static -ref charsetConverter::createGenericConverter +shared_ptr charsetConverter::createGenericConverter (const charset& source, const charset& dest, const charsetConverterOptions& opts) { - return vmime::create (source, dest, opts); + return make_shared (source, dest, opts); } @@ -195,9 +195,9 @@ void charsetConverter_icu::convert(const string& in, string& out) } -ref charsetConverter_icu::getFilteredOutputStream(utility::outputStream& os) +shared_ptr charsetConverter_icu::getFilteredOutputStream(utility::outputStream& os) { - return vmime::create (m_source, m_dest, &os); + return make_shared (m_source, m_dest, &os); } diff --git a/src/charsetConverter_idna.cpp b/src/charsetConverter_idna.cpp index cde2209a..a6b339b6 100644 --- a/src/charsetConverter_idna.cpp +++ b/src/charsetConverter_idna.cpp @@ -159,9 +159,9 @@ void charsetConverter_idna::convert(const string& in, string& out) } -ref charsetConverter_idna::getFilteredOutputStream(utility::outputStream& /* os */) +shared_ptr charsetConverter_idna::getFilteredOutputStream(utility::outputStream& /* os */) { - return NULL; + return null; } diff --git a/src/component.cpp b/src/component.cpp index d2138b60..cb013899 100644 --- a/src/component.cpp +++ b/src/component.cpp @@ -47,14 +47,14 @@ component::~component() void component::parse - (ref inputStream, const utility::stream::size_type length) + (shared_ptr inputStream, const utility::stream::size_type length) { parse(inputStream, 0, length, NULL); } void component::parse - (ref inputStream, const utility::stream::size_type position, + (shared_ptr inputStream, const utility::stream::size_type position, const utility::stream::size_type end, utility::stream::size_type* newPosition) { parse(parsingContext::getDefaultContext(), inputStream, position, end, newPosition); @@ -63,13 +63,13 @@ void component::parse void component::parse (const parsingContext& ctx, - ref inputStream, const utility::stream::size_type position, + shared_ptr inputStream, const utility::stream::size_type position, const utility::stream::size_type end, utility::stream::size_type* newPosition) { m_parsedOffset = m_parsedLength = 0; - ref seekableStream = - inputStream.dynamicCast (); + shared_ptr seekableStream = + dynamicCast (inputStream); if (seekableStream == NULL || end == 0) { @@ -84,8 +84,8 @@ void component::parse } else { - ref parser = - vmime::create (seekableStream); + shared_ptr parser = + make_shared (seekableStream); parseImpl(ctx, parser, position, end, newPosition); } @@ -136,7 +136,7 @@ void component::offsetParsedBounds(const utility::stream::size_type offset) m_parsedOffset += offset; // Offset parsed bounds of our children - std::vector > children = getChildComponents(); + std::vector > children = getChildComponents(); for (size_t i = 0, n = children.size() ; i < n ; ++i) children[i]->offsetParsedBounds(offset); @@ -144,7 +144,7 @@ void component::offsetParsedBounds(const utility::stream::size_type offset) void component::parseImpl - (const parsingContext& ctx, ref parser, + (const parsingContext& ctx, shared_ptr parser, const utility::stream::size_type position, const utility::stream::size_type end, utility::stream::size_type* newPosition) { @@ -169,11 +169,11 @@ void component::parseImpl // This is the default implementation for parsing from a string: // actually, we encapsulate the string buffer in an input stream, then use // the "parse from input stream" implementation - ref stream = - vmime::create (buffer); + shared_ptr stream = + make_shared (buffer); - ref parser = - vmime::create (stream); + shared_ptr parser = + make_shared (stream); parseImpl(ctx, parser, position, end, newPosition); } @@ -235,10 +235,10 @@ void component::setParsedBounds(const string::size_type start, const string::siz utility::stream::size_type component::getGeneratedSize(const generationContext& ctx) { - std::vector > children = getChildComponents(); + std::vector > children = getChildComponents(); utility::stream::size_type totalSize = 0; - for (std::vector >::iterator it = children.begin() ; it != children.end() ; ++it) + for (std::vector >::iterator it = children.begin() ; it != children.end() ; ++it) totalSize += (*it)->getGeneratedSize(ctx); return totalSize; diff --git a/src/contentDisposition.cpp b/src/contentDisposition.cpp index 300d4ee3..aa9b4fe3 100644 --- a/src/contentDisposition.cpp +++ b/src/contentDisposition.cpp @@ -91,9 +91,9 @@ bool contentDisposition::operator!=(const contentDisposition& value) const } -ref contentDisposition::clone() const +shared_ptr contentDisposition::clone() const { - return vmime::create (*this); + return make_shared (*this); } @@ -124,9 +124,9 @@ void contentDisposition::setName(const string& name) } -const std::vector > contentDisposition::getChildComponents() +const std::vector > contentDisposition::getChildComponents() { - return std::vector >(); + return std::vector >(); } diff --git a/src/dateTime.cpp b/src/dateTime.cpp index a0c03ede..2c045e6d 100644 --- a/src/dateTime.cpp +++ b/src/dateTime.cpp @@ -776,15 +776,15 @@ const datetime datetime::now() } -ref datetime::clone() const +shared_ptr datetime::clone() const { - return vmime::create (*this); + return make_shared (*this); } -const std::vector > datetime::getChildComponents() +const std::vector > datetime::getChildComponents() { - return std::vector >(); + return std::vector >(); } diff --git a/src/defaultAttachment.cpp b/src/defaultAttachment.cpp index 9076fdb3..8f8ad453 100644 --- a/src/defaultAttachment.cpp +++ b/src/defaultAttachment.cpp @@ -37,14 +37,14 @@ defaultAttachment::defaultAttachment() } -defaultAttachment::defaultAttachment(ref data, +defaultAttachment::defaultAttachment(shared_ptr data, const encoding& enc, const mediaType& type, const text& desc, const word& name) : m_type(type), m_desc(desc), m_data(data), m_encoding(enc), m_name(name) { } -defaultAttachment::defaultAttachment(ref data, +defaultAttachment::defaultAttachment(shared_ptr data, const mediaType& type, const text& desc, const word& name) : m_type(type), m_desc(desc), m_data(data), m_encoding(encoding::decide(data)), m_name(name) @@ -54,7 +54,7 @@ defaultAttachment::defaultAttachment(ref data, defaultAttachment::defaultAttachment(const defaultAttachment& attach) : attachment(), m_type(attach.m_type), m_desc(attach.m_desc), - m_data(attach.m_data->clone().dynamicCast ()), + m_data(vmime::clone(attach.m_data)), m_encoding(attach.m_encoding), m_name(attach.m_name) { } @@ -70,31 +70,31 @@ defaultAttachment& defaultAttachment::operator=(const defaultAttachment& attach) m_type = attach.m_type; m_desc = attach.m_desc; m_name = attach.m_name; - m_data = attach.m_data->clone().dynamicCast (); + m_data = vmime::clone(attach.m_data); m_encoding = attach.m_encoding; return (*this); } -void defaultAttachment::generateIn(ref parent) const +void defaultAttachment::generateIn(shared_ptr parent) const { // Create and append a new part for this attachment - ref part = vmime::create (); + shared_ptr part = make_shared (); parent->getBody()->appendPart(part); generatePart(part); } -void defaultAttachment::generatePart(ref part) const +void defaultAttachment::generatePart(shared_ptr part) const { // Set header fields part->getHeader()->ContentType()->setValue(m_type); if (!m_desc.isEmpty()) part->getHeader()->ContentDescription()->setValue(m_desc); part->getHeader()->ContentTransferEncoding()->setValue(m_encoding); part->getHeader()->ContentDisposition()->setValue(contentDisposition(contentDispositionTypes::ATTACHMENT)); - part->getHeader()->ContentDisposition().dynamicCast ()->setFilename(m_name); + dynamicCast (part->getHeader()->ContentDisposition())->setFilename(m_name); // Set contents part->getBody()->setContents(m_data); @@ -119,7 +119,7 @@ const word defaultAttachment::getName() const } -const ref defaultAttachment::getData() const +const shared_ptr defaultAttachment::getData() const { return m_data; } @@ -131,15 +131,15 @@ const encoding defaultAttachment::getEncoding() const } -ref defaultAttachment::getPart() const +shared_ptr defaultAttachment::getPart() const { - return NULL; + return null; } -ref defaultAttachment::getHeader() const +shared_ptr defaultAttachment::getHeader() const { - return NULL; + return null; } diff --git a/src/disposition.cpp b/src/disposition.cpp index c5da6e30..08e34afc 100644 --- a/src/disposition.cpp +++ b/src/disposition.cpp @@ -44,9 +44,9 @@ disposition::disposition(const string& actionMode, const string& sendingMode, } -ref disposition::clone() const +shared_ptr disposition::clone() const { - ref disp = vmime::create (); + shared_ptr disp = make_shared (); disp->m_actionMode = m_actionMode; disp->m_sendingMode = m_sendingMode; @@ -79,9 +79,9 @@ disposition& disposition::operator=(const disposition& other) } -const std::vector > disposition::getChildComponents() +const std::vector > disposition::getChildComponents() { - return std::vector >(); + return std::vector >(); } diff --git a/src/emailAddress.cpp b/src/emailAddress.cpp index c4119aba..eb76e16d 100644 --- a/src/emailAddress.cpp +++ b/src/emailAddress.cpp @@ -469,9 +469,9 @@ emailAddress& emailAddress::operator=(const emailAddress& other) } -ref emailAddress::clone() const +shared_ptr emailAddress::clone() const { - return vmime::create (*this); + return make_shared (*this); } @@ -499,9 +499,9 @@ void emailAddress::setDomainName(const word& domainName) } -const std::vector > emailAddress::getChildComponents() +const std::vector > emailAddress::getChildComponents() { - return std::vector >(); + return std::vector >(); } @@ -528,9 +528,9 @@ const string emailAddress::toString() const const text emailAddress::toText() const { text txt; - txt.appendWord(vmime::create (m_localName)); - txt.appendWord(vmime::create ("@", vmime::charsets::US_ASCII)); - txt.appendWord(vmime::create (m_domainName)); + txt.appendWord(make_shared (m_localName)); + txt.appendWord(make_shared ("@", vmime::charsets::US_ASCII)); + txt.appendWord(make_shared (m_domainName)); return txt; } diff --git a/src/emptyContentHandler.cpp b/src/emptyContentHandler.cpp index 07b53391..f6cdee95 100644 --- a/src/emptyContentHandler.cpp +++ b/src/emptyContentHandler.cpp @@ -33,9 +33,9 @@ emptyContentHandler::emptyContentHandler() } -ref emptyContentHandler::clone() const +shared_ptr emptyContentHandler::clone() const { - return vmime::create (); + return make_shared (); } diff --git a/src/encoding.cpp b/src/encoding.cpp index 53f88531..317d441f 100644 --- a/src/encoding.cpp +++ b/src/encoding.cpp @@ -92,9 +92,9 @@ void encoding::generateImpl } -ref encoding::getEncoder() const +shared_ptr encoding::getEncoder() const { - ref encoder = + shared_ptr encoder = utility::encoder::encoderFactory::getInstance()->create(generate()); // FIXME: this should not be here (move me into QP encoder instead?) @@ -200,7 +200,7 @@ bool encoding::shouldReencode() const const encoding encoding::decide - (ref data, const EncodingUsage usage) + (shared_ptr data, const EncodingUsage usage) { // Do not re-encode data if it is already encoded if (data->isEncoded() && !data->getEncoding().shouldReencode()) @@ -231,7 +231,7 @@ const encoding encoding::decide } -const encoding encoding::decide(ref data, +const encoding encoding::decide(shared_ptr data, const charset& chset, const EncodingUsage usage) { // Do not re-encode data if it is already encoded @@ -253,9 +253,9 @@ const encoding encoding::decide(ref data, } -ref encoding::clone() const +shared_ptr encoding::clone() const { - return vmime::create (*this); + return make_shared (*this); } @@ -291,9 +291,9 @@ void encoding::setUsage(const EncodingUsage usage) } -const std::vector > encoding::getChildComponents() +const std::vector > encoding::getChildComponents() { - return std::vector >(); + return std::vector >(); } diff --git a/src/fileAttachment.cpp b/src/fileAttachment.cpp index 4f4a87d3..1db1a1a8 100644 --- a/src/fileAttachment.cpp +++ b/src/fileAttachment.cpp @@ -79,7 +79,7 @@ fileAttachment::fileAttachment(const string& filepath, const mediaType& type, } -fileAttachment::fileAttachment(ref cts, const word& filename, const mediaType& type) +fileAttachment::fileAttachment(shared_ptr cts, const word& filename, const mediaType& type) { if (!filename.isEmpty()) m_fileInfo.setFilename(filename); @@ -92,7 +92,7 @@ fileAttachment::fileAttachment(ref cts, const word& filename, c } -fileAttachment::fileAttachment(ref cts, const word& filename, +fileAttachment::fileAttachment(shared_ptr cts, const word& filename, const mediaType& type, const text& desc) { if (!filename.isEmpty()) @@ -107,7 +107,7 @@ fileAttachment::fileAttachment(ref cts, const word& filename, } -fileAttachment::fileAttachment(ref cts, const word& filename, +fileAttachment::fileAttachment(shared_ptr cts, const word& filename, const mediaType& type, const text& desc, const encoding& enc) { if (!filename.isEmpty()) @@ -123,15 +123,15 @@ fileAttachment::fileAttachment(ref cts, const word& filename, void fileAttachment::setData(const string& filepath) { - ref fsf = platform::getHandler()->getFileSystemFactory(); + shared_ptr fsf = platform::getHandler()->getFileSystemFactory(); utility::file::path path = fsf->stringToPath(filepath); - ref file = fsf->create(path); + shared_ptr file = fsf->create(path); if (!file->isFile()) throw exceptions::open_file_error(); - m_data = vmime::create + m_data = make_shared (file->getFileReader()->getInputStream(), file->getLength()); m_fileInfo.setFilename(path.getLastComponent()); @@ -139,7 +139,7 @@ void fileAttachment::setData(const string& filepath) } -void fileAttachment::setData(ref cts) +void fileAttachment::setData(shared_ptr cts) { m_data = cts; @@ -147,12 +147,12 @@ void fileAttachment::setData(ref cts) } -void fileAttachment::generatePart(ref part) const +void fileAttachment::generatePart(shared_ptr part) const { defaultAttachment::generatePart(part); - ref cdf = part->getHeader()->ContentDisposition(). - dynamicCast (); + shared_ptr cdf = + dynamicCast (part->getHeader()->ContentDisposition()); if (m_fileInfo.hasSize()) cdf->setSize(utility::stringUtils::toString(m_fileInfo.getSize())); if (m_fileInfo.hasFilename() && !m_fileInfo.getFilename().isEmpty()) cdf->setFilename(m_fileInfo.getFilename()); diff --git a/src/fileContentHandler.cpp b/src/fileContentHandler.cpp index 295bc887..53ec9f69 100644 --- a/src/fileContentHandler.cpp +++ b/src/fileContentHandler.cpp @@ -35,7 +35,7 @@ fileContentHandler::fileContentHandler() fileContentHandler::fileContentHandler - (ref file, const vmime::encoding& enc) + (shared_ptr file, const vmime::encoding& enc) { setData(file, enc); } @@ -61,14 +61,14 @@ fileContentHandler& fileContentHandler::operator=(const fileContentHandler& cts) } -ref fileContentHandler::clone() const +shared_ptr fileContentHandler::clone() const { - return vmime::create (*this); + return make_shared (*this); } void fileContentHandler::setData - (ref file, const vmime::encoding& enc) + (shared_ptr file, const vmime::encoding& enc) { m_file = file; m_encoding = enc; diff --git a/src/generatedMessageAttachment.cpp b/src/generatedMessageAttachment.cpp index 927d3d43..0473d247 100644 --- a/src/generatedMessageAttachment.cpp +++ b/src/generatedMessageAttachment.cpp @@ -30,8 +30,8 @@ namespace vmime { -generatedMessageAttachment::generatedMessageAttachment(ref part) - : m_bpa(vmime::create (part)) +generatedMessageAttachment::generatedMessageAttachment(shared_ptr part) + : m_bpa(make_shared (part)) { } @@ -54,7 +54,7 @@ const word generatedMessageAttachment::getName() const } -const ref generatedMessageAttachment::getData() const +const shared_ptr generatedMessageAttachment::getData() const { return m_bpa->getData(); } @@ -66,19 +66,19 @@ const encoding generatedMessageAttachment::getEncoding() const } -ref generatedMessageAttachment::getPart() const +shared_ptr generatedMessageAttachment::getPart() const { return m_bpa->getPart(); } -ref generatedMessageAttachment::getHeader() const +shared_ptr generatedMessageAttachment::getHeader() const { return m_bpa->getHeader(); } -ref generatedMessageAttachment::getMessage() const +shared_ptr generatedMessageAttachment::getMessage() const { if (m_msg == NULL) { @@ -89,7 +89,7 @@ ref generatedMessageAttachment::getMessage() const getData()->extract(os); // Parse message - m_msg = vmime::create (); + m_msg = make_shared (); m_msg->parse(oss.str()); } @@ -97,7 +97,7 @@ ref generatedMessageAttachment::getMessage() const } -void generatedMessageAttachment::generateIn(ref /* parent */) const +void generatedMessageAttachment::generateIn(shared_ptr /* parent */) const { // Not used (see 'parsedMessageAttachment') } diff --git a/src/header.cpp b/src/header.cpp index ec98976f..8e04cadc 100644 --- a/src/header.cpp +++ b/src/header.cpp @@ -72,7 +72,7 @@ void header::parseImpl while (pos < end) { - ref field = headerField::parseNext(ctx, buffer, pos, end, &pos); + shared_ptr field = headerField::parseNext(ctx, buffer, pos, end, &pos); if (field == NULL) break; m_fields.push_back(field); @@ -90,7 +90,7 @@ void header::generateImpl const string::size_type /* curLinePos */, string::size_type* newLinePos) const { // Generate the fields - for (std::vector >::const_iterator it = m_fields.begin() ; + for (std::vector >::const_iterator it = m_fields.begin() ; it != m_fields.end() ; ++it) { (*it)->generate(ctx, os); @@ -108,16 +108,16 @@ utility::stream::size_type header::getGeneratedSize(const generationContext& ctx } -ref header::clone() const +shared_ptr header::clone() const { - ref
hdr = vmime::create
(); + shared_ptr
hdr = make_shared
(); hdr->m_fields.reserve(m_fields.size()); - for (std::vector >::const_iterator it = m_fields.begin() ; + for (std::vector >::const_iterator it = m_fields.begin() ; it != m_fields.end() ; ++it) { - hdr->m_fields.push_back((*it)->clone().dynamicCast ()); + hdr->m_fields.push_back(vmime::clone(*it)); } return (hdr); @@ -128,14 +128,14 @@ void header::copyFrom(const component& other) { const header& h = dynamic_cast (other); - std::vector > fields; + std::vector > fields; fields.reserve(h.m_fields.size()); - for (std::vector >::const_iterator it = h.m_fields.begin() ; + for (std::vector >::const_iterator it = h.m_fields.begin() ; it != h.m_fields.end() ; ++it) { - fields.push_back((*it)->clone().dynamicCast ()); + fields.push_back(vmime::clone(*it)); } m_fields.clear(); @@ -154,7 +154,7 @@ header& header::operator=(const header& other) bool header::hasField(const string& fieldName) const { - std::vector >::const_iterator pos = + std::vector >::const_iterator pos = std::find_if(m_fields.begin(), m_fields.end(), fieldHasName(utility::stringUtils::toLower(fieldName))); @@ -162,10 +162,10 @@ bool header::hasField(const string& fieldName) const } -ref header::findField(const string& fieldName) const +shared_ptr header::findField(const string& fieldName) const { // Find the first field that matches the specified name - std::vector >::const_iterator pos = + std::vector >::const_iterator pos = std::find_if(m_fields.begin(), m_fields.end(), fieldHasName(utility::stringUtils::toLower(fieldName))); @@ -182,10 +182,10 @@ ref header::findField(const string& fieldName) const } -std::vector > header::findAllFields(const string& fieldName) +std::vector > header::findAllFields(const string& fieldName) { - std::vector > result; - std::back_insert_iterator > > back(result); + std::vector > result; + std::back_insert_iterator > > back(result); std::remove_copy_if(m_fields.begin(), m_fields.end(), back, fieldHasNotName(utility::stringUtils::toLower(fieldName))); @@ -194,13 +194,13 @@ std::vector > header::findAllFields(const string& fieldName) } -ref header::getField(const string& fieldName) +shared_ptr header::getField(const string& fieldName) { const string name = utility::stringUtils::toLower(fieldName); // Find the first field that matches the specified name - std::vector >::const_iterator pos = m_fields.begin(); - const std::vector >::const_iterator end = m_fields.end(); + std::vector >::const_iterator pos = m_fields.begin(); + const std::vector >::const_iterator end = m_fields.end(); while (pos != end && utility::stringUtils::toLower((*pos)->getName()) != name) ++pos; @@ -208,7 +208,7 @@ ref header::getField(const string& fieldName) // If no field with this name can be found, create a new one if (pos == end) { - ref field = headerFieldFactory::getInstance()->create(fieldName); + shared_ptr field = headerFieldFactory::getInstance()->create(fieldName); appendField(field); @@ -223,15 +223,15 @@ ref header::getField(const string& fieldName) } -void header::appendField(ref field) +void header::appendField(shared_ptr field) { m_fields.push_back(field); } -void header::insertFieldBefore(ref beforeField, ref field) +void header::insertFieldBefore(shared_ptr beforeField, shared_ptr field) { - const std::vector >::iterator it = std::find + const std::vector >::iterator it = std::find (m_fields.begin(), m_fields.end(), beforeField); if (it == m_fields.end()) @@ -241,15 +241,15 @@ void header::insertFieldBefore(ref beforeField, ref } -void header::insertFieldBefore(const size_t pos, ref field) +void header::insertFieldBefore(const size_t pos, shared_ptr field) { m_fields.insert(m_fields.begin() + pos, field); } -void header::insertFieldAfter(ref afterField, ref field) +void header::insertFieldAfter(shared_ptr afterField, shared_ptr field) { - const std::vector >::iterator it = std::find + const std::vector >::iterator it = std::find (m_fields.begin(), m_fields.end(), afterField); if (it == m_fields.end()) @@ -259,15 +259,15 @@ void header::insertFieldAfter(ref afterField, ref fi } -void header::insertFieldAfter(const size_t pos, ref field) +void header::insertFieldAfter(const size_t pos, shared_ptr field) { m_fields.insert(m_fields.begin() + pos + 1, field); } -void header::removeField(ref field) +void header::removeField(shared_ptr field) { - const std::vector >::iterator it = std::find + const std::vector >::iterator it = std::find (m_fields.begin(), m_fields.end(), field); if (it == m_fields.end()) @@ -279,13 +279,13 @@ void header::removeField(ref field) void header::removeField(const size_t pos) { - const std::vector >::iterator it = m_fields.begin() + pos; + const std::vector >::iterator it = m_fields.begin() + pos; m_fields.erase(it); } -void header::replaceField(ref field, ref newField) +void header::replaceField(shared_ptr field, shared_ptr newField) { insertFieldBefore(field, newField); removeField(field); @@ -300,7 +300,7 @@ void header::removeAllFields() void header::removeAllFields(const string& fieldName) { - std::vector > fields = findAllFields(fieldName); + std::vector > fields = findAllFields(fieldName); for (unsigned int i = 0 ; i < fields.size() ; ++i) removeField(fields[i]); @@ -319,25 +319,25 @@ bool header::isEmpty() const } -const ref header::getFieldAt(const size_t pos) +const shared_ptr header::getFieldAt(const size_t pos) { return (m_fields[pos]); } -const ref header::getFieldAt(const size_t pos) const +const shared_ptr header::getFieldAt(const size_t pos) const { return (m_fields[pos]); } -const std::vector > header::getFieldList() const +const std::vector > header::getFieldList() const { - std::vector > list; + std::vector > list; list.reserve(m_fields.size()); - for (std::vector >::const_iterator it = m_fields.begin() ; + for (std::vector >::const_iterator it = m_fields.begin() ; it != m_fields.end() ; ++it) { list.push_back(*it); @@ -347,15 +347,15 @@ const std::vector > header::getFieldList() const } -const std::vector > header::getFieldList() +const std::vector > header::getFieldList() { return (m_fields); } -const std::vector > header::getChildComponents() +const std::vector > header::getChildComponents() { - std::vector > list; + std::vector > list; copy_vector(m_fields, list); @@ -372,7 +372,7 @@ header::fieldHasName::fieldHasName(const string& name) { } -bool header::fieldHasName::operator() (const ref & field) +bool header::fieldHasName::operator() (const shared_ptr & field) { return utility::stringUtils::toLower(field->getName()) == m_name; } @@ -383,7 +383,7 @@ header::fieldHasNotName::fieldHasNotName(const string& name) { } -bool header::fieldHasNotName::operator() (const ref & field) +bool header::fieldHasNotName::operator() (const shared_ptr & field) { return utility::stringUtils::toLower(field->getName()) != m_name; } diff --git a/src/headerField.cpp b/src/headerField.cpp index 7f24e176..c6baa32e 100644 --- a/src/headerField.cpp +++ b/src/headerField.cpp @@ -50,9 +50,9 @@ headerField::~headerField() } -ref headerField::clone() const +shared_ptr headerField::clone() const { - ref field = headerFieldFactory::getInstance()->create(m_name); + shared_ptr field = headerFieldFactory::getInstance()->create(m_name); field->copyFrom(*this); @@ -75,7 +75,7 @@ headerField& headerField::operator=(const headerField& other) } -ref headerField::parseNext +shared_ptr headerField::parseNext (const parsingContext& ctx, const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition) { @@ -93,14 +93,14 @@ ref headerField::parseNext if (newPosition) *newPosition = pos + 1; // LF: illegal - return (NULL); + return null; } else if (c == '\r' && pos + 1 < end && buffer[pos + 1] == '\n') { if (newPosition) *newPosition = pos + 2; // CR+LF - return (NULL); + return null; } // This line may be a field description @@ -230,7 +230,7 @@ ref headerField::parseNext } // Return a new field - ref field = headerFieldFactory::getInstance()->create(name); + shared_ptr field = headerFieldFactory::getInstance()->create(name); field->parse(ctx, buffer, contentsStart, contentsEnd, NULL); field->setParsedBounds(nameStart, pos); @@ -253,14 +253,14 @@ ref headerField::parseNext if (newPosition) *newPosition = pos + 1; // LF: illegal - return NULL; + return null; } else if (pos + 1 < end && buffer[pos] == '\r' && buffer[pos + 1] == '\n') { if (newPosition) *newPosition = pos + 2; // CR+LF - return NULL; + return null; } // Skip this error and advance to the next line @@ -275,7 +275,7 @@ ref headerField::parseNext if (newPosition) *newPosition = pos; - return (NULL); + return null; } @@ -321,9 +321,9 @@ bool headerField::isCustom() const } -const std::vector > headerField::getChildComponents() +const std::vector > headerField::getChildComponents() { - std::vector > list; + std::vector > list; if (m_value) list.push_back(m_value); @@ -332,19 +332,19 @@ const std::vector > headerField::getChildComponents() } -ref headerField::getValue() const +shared_ptr headerField::getValue() const { return m_value; } -ref headerField::getValue() +shared_ptr headerField::getValue() { return m_value; } -void headerField::setValue(ref value) +void headerField::setValue(shared_ptr value) { if (!headerFieldFactory::getInstance()->isValueTypeValid(*this, *value)) throw exceptions::bad_field_value_type(getName()); @@ -354,12 +354,12 @@ void headerField::setValue(ref value) } -void headerField::setValueConst(ref value) +void headerField::setValueConst(shared_ptr value) { if (!headerFieldFactory::getInstance()->isValueTypeValid(*this, *value)) throw exceptions::bad_field_value_type(getName()); - m_value = value->clone().dynamicCast (); + m_value = vmime::clone(value); } @@ -368,7 +368,7 @@ void headerField::setValue(const headerFieldValue& value) if (!headerFieldFactory::getInstance()->isValueTypeValid(*this, value)) throw exceptions::bad_field_value_type(getName()); - m_value = value.clone().dynamicCast (); + m_value = vmime::clone(value); } diff --git a/src/headerFieldFactory.cpp b/src/headerFieldFactory.cpp index 7e021f59..5c60543e 100644 --- a/src/headerFieldFactory.cpp +++ b/src/headerFieldFactory.cpp @@ -90,18 +90,18 @@ headerFieldFactory::~headerFieldFactory() } -headerFieldFactory* headerFieldFactory::getInstance() +shared_ptr headerFieldFactory::getInstance() { static headerFieldFactory instance; - return (&instance); + return shared_ptr (&instance, noop_shared_ptr_deleter ()); } -ref headerFieldFactory::create +shared_ptr headerFieldFactory::create (const string& name, const string& body) { NameMap::const_iterator pos = m_nameMap.find(utility::stringUtils::toLower(name)); - ref field = NULL; + shared_ptr field; if (pos != m_nameMap.end()) field = ((*pos).second)(); @@ -118,12 +118,12 @@ ref headerFieldFactory::create } -ref headerFieldFactory::createValue(const string& fieldName) +shared_ptr headerFieldFactory::createValue(const string& fieldName) { ValueMap::const_iterator pos = m_valueMap.find (utility::stringUtils::toLower(fieldName)); - ref value = NULL; + shared_ptr value; if (pos != m_valueMap.end()) value = ((*pos).second.allocFunc)(); diff --git a/src/htmlTextPart.cpp b/src/htmlTextPart.cpp index ebb6587c..0aabbdc4 100644 --- a/src/htmlTextPart.cpp +++ b/src/htmlTextPart.cpp @@ -39,8 +39,8 @@ namespace vmime htmlTextPart::htmlTextPart() - : m_plainText(vmime::create ()), - m_text(vmime::create ()) + : m_plainText(make_shared ()), + m_text(make_shared ()) { } @@ -62,13 +62,13 @@ size_t htmlTextPart::getPartCount() const } -void htmlTextPart::generateIn(ref /* message */, ref parent) const +void htmlTextPart::generateIn(shared_ptr /* message */, shared_ptr parent) const { // Plain text if (!m_plainText->isEmpty()) { // -- Create a new part - ref part = vmime::create (); + shared_ptr part = make_shared (); parent->getBody()->appendPart(part); // -- Set contents @@ -79,7 +79,7 @@ void htmlTextPart::generateIn(ref /* message */, ref paren // HTML text // -- Create a new part - ref htmlPart = vmime::create (); + shared_ptr htmlPart = make_shared (); // -- Set contents htmlPart->getBody()->setContents(m_text, @@ -90,7 +90,7 @@ void htmlTextPart::generateIn(ref /* message */, ref paren if (!m_objects.empty()) { // Create a "multipart/related" body part - ref relPart = vmime::create (); + shared_ptr relPart = make_shared (); parent->getBody()->appendPart(relPart); relPart->getHeader()->ContentType()-> @@ -100,10 +100,10 @@ void htmlTextPart::generateIn(ref /* message */, ref paren relPart->getBody()->appendPart(htmlPart); // Also add objects into this part - for (std::vector >::const_iterator it = m_objects.begin() ; + for (std::vector >::const_iterator it = m_objects.begin() ; it != m_objects.end() ; ++it) { - ref objPart = vmime::create (); + shared_ptr objPart = make_shared (); relPart->getBody()->appendPart(objPart); string id = (*it)->getId(); @@ -129,11 +129,11 @@ void htmlTextPart::generateIn(ref /* message */, ref paren void htmlTextPart::findEmbeddedParts(const bodyPart& part, - std::vector >& cidParts, std::vector >& locParts) + std::vector >& cidParts, std::vector >& locParts) { for (size_t i = 0 ; i < part.getBody()->getPartCount() ; ++i) { - ref p = part.getBody()->getPartAt(i); + shared_ptr p = part.getBody()->getPartAt(i); // For a part to be an embedded object, it must have a // Content-Id field or a Content-Location field. @@ -174,25 +174,25 @@ void htmlTextPart::addEmbeddedObject(const bodyPart& part, const string& id, try { - const ref ctf = part.getHeader()->ContentType(); - type = *ctf->getValue().dynamicCast (); + const shared_ptr ctf = part.getHeader()->ContentType(); + type = *ctf->getValue (); } catch (exceptions::no_such_field) { // No "Content-type" field: assume "application/octet-stream". } - m_objects.push_back(vmime::create - (part.getBody()->getContents()->clone().dynamicCast (), + m_objects.push_back(make_shared + (vmime::clone(part.getBody()->getContents()), part.getBody()->getEncoding(), id, type, refType)); } -void htmlTextPart::parse(ref message, ref parent, ref textPart) +void htmlTextPart::parse(shared_ptr message, shared_ptr parent, shared_ptr textPart) { // Search for possible embedded objects in the _whole_ message. - std::vector > cidParts; - std::vector > locParts; + std::vector > cidParts; + std::vector > locParts; findEmbeddedParts(*message, cidParts, locParts); @@ -208,8 +208,8 @@ void htmlTextPart::parse(ref message, ref pare try { - const ref ctf = - textPart->getHeader()->findField(fields::CONTENT_TYPE).dynamicCast (); + const shared_ptr ctf = + textPart->getHeader()->findField (fields::CONTENT_TYPE); m_charset = ctf->getCharset(); } @@ -224,12 +224,12 @@ void htmlTextPart::parse(ref message, ref pare // Extract embedded objects. The algorithm is quite simple: for each previously // found inline part, we check if its CID/Location is contained in the HTML text. - for (std::vector >::const_iterator p = cidParts.begin() ; p != cidParts.end() ; ++p) + for (std::vector >::const_iterator p = cidParts.begin() ; p != cidParts.end() ; ++p) { - const ref midField = + const shared_ptr midField = (*p)->getHeader()->findField(fields::CONTENT_ID); - const messageId mid = *midField->getValue().dynamicCast (); + const messageId mid = *midField->getValue (); if (data.find("CID:" + mid.getId()) != string::npos || data.find("cid:" + mid.getId()) != string::npos) @@ -240,12 +240,12 @@ void htmlTextPart::parse(ref message, ref pare } } - for (std::vector >::const_iterator p = locParts.begin() ; p != locParts.end() ; ++p) + for (std::vector >::const_iterator p = locParts.begin() ; p != locParts.end() ; ++p) { - const ref locField = + const shared_ptr locField = (*p)->getHeader()->findField(fields::CONTENT_LOCATION); - const text loc = *locField->getValue().dynamicCast (); + const text loc = *locField->getValue (); const string locStr = loc.getWholeBuffer(); if (data.find(locStr) != string::npos) @@ -259,7 +259,7 @@ void htmlTextPart::parse(ref message, ref pare // Extract plain text, if any. if (!findPlainTextPart(*message, *parent, *textPart)) { - m_plainText = vmime::create (); + m_plainText = make_shared (); } } @@ -269,22 +269,22 @@ bool htmlTextPart::findPlainTextPart(const bodyPart& part, const bodyPart& paren // We search for the nearest "multipart/alternative" part. try { - const ref ctf = + const shared_ptr ctf = part.getHeader()->findField(fields::CONTENT_TYPE); - const mediaType type = *ctf->getValue().dynamicCast (); + const mediaType type = *ctf->getValue (); if (type.getType() == mediaTypes::MULTIPART && type.getSubType() == mediaTypes::MULTIPART_ALTERNATIVE) { - ref foundPart = NULL; + shared_ptr foundPart; for (size_t i = 0 ; i < part.getBody()->getPartCount() ; ++i) { - const ref p = part.getBody()->getPartAt(i); + const shared_ptr p = part.getBody()->getPartAt(i); - if (p == &parent || // if "text/html" is in "multipart/related" - p == &textPart) // if not... + if (p.get() == &parent || // if "text/html" is in "multipart/related" + p.get() == &textPart) // if not... { foundPart = p; } @@ -297,14 +297,14 @@ bool htmlTextPart::findPlainTextPart(const bodyPart& part, const bodyPart& paren // Now, search for the alternative plain text part for (size_t i = 0 ; !found && i < part.getBody()->getPartCount() ; ++i) { - const ref p = part.getBody()->getPartAt(i); + const shared_ptr p = part.getBody()->getPartAt(i); try { - const ref ctf = + const shared_ptr ctf = p->getHeader()->findField(fields::CONTENT_TYPE); - const mediaType type = *ctf->getValue().dynamicCast (); + const mediaType type = *ctf->getValue (); if (type.getType() == mediaTypes::TEXT && type.getSubType() == mediaTypes::TEXT_PLAIN) @@ -354,25 +354,25 @@ void htmlTextPart::setCharset(const charset& ch) } -ref htmlTextPart::getPlainText() const +shared_ptr htmlTextPart::getPlainText() const { return m_plainText; } -void htmlTextPart::setPlainText(ref plainText) +void htmlTextPart::setPlainText(shared_ptr plainText) { m_plainText = plainText->clone(); } -const ref htmlTextPart::getText() const +const shared_ptr htmlTextPart::getText() const { return m_text; } -void htmlTextPart::setText(ref text) +void htmlTextPart::setText(shared_ptr text) { m_text = text->clone(); } @@ -384,15 +384,15 @@ size_t htmlTextPart::getObjectCount() const } -ref htmlTextPart::getObjectAt(const size_t pos) const +shared_ptr htmlTextPart::getObjectAt(const size_t pos) const { return m_objects[pos]; } -ref htmlTextPart::findObject(const string& id) const +shared_ptr htmlTextPart::findObject(const string& id) const { - for (std::vector >::const_iterator o = m_objects.begin() ; + for (std::vector >::const_iterator o = m_objects.begin() ; o != m_objects.end() ; ++o) { if ((*o)->matchesId(id)) @@ -405,7 +405,7 @@ ref htmlTextPart::findObject(const string& bool htmlTextPart::hasObject(const string& id) const { - for (std::vector >::const_iterator o = m_objects.begin() ; + for (std::vector >::const_iterator o = m_objects.begin() ; o != m_objects.end() ; ++o) { if ((*o)->matchesId(id)) @@ -416,12 +416,12 @@ bool htmlTextPart::hasObject(const string& id) const } -ref htmlTextPart::addObject - (ref data, const vmime::encoding& enc, const mediaType& type) +shared_ptr htmlTextPart::addObject + (shared_ptr data, const vmime::encoding& enc, const mediaType& type) { const messageId mid(messageId::generateId()); - ref obj = vmime::create + shared_ptr obj = make_shared (data, enc, mid.getId(), type, embeddedObject::REFERENCED_BY_ID); m_objects.push_back(obj); @@ -430,17 +430,17 @@ ref htmlTextPart::addObject } -ref htmlTextPart::addObject - (ref data, const mediaType& type) +shared_ptr htmlTextPart::addObject + (shared_ptr data, const mediaType& type) { return addObject(data, encoding::decide(data), type); } -ref htmlTextPart::addObject +shared_ptr htmlTextPart::addObject (const string& data, const mediaType& type) { - ref cts = vmime::create (data); + shared_ptr cts = make_shared (data); return addObject(cts, encoding::decide(cts), type); } @@ -451,15 +451,15 @@ ref htmlTextPart::addObject // htmlTextPart::embeddedObject::embeddedObject - (ref data, const encoding& enc, + (shared_ptr data, const encoding& enc, const string& id, const mediaType& type, const ReferenceType refType) - : m_data(data->clone().dynamicCast ()), + : m_data(vmime::clone(data)), m_encoding(enc), m_id(id), m_type(type), m_refType(refType) { } -ref htmlTextPart::embeddedObject::getData() const +shared_ptr htmlTextPart::embeddedObject::getData() const { return m_data; } diff --git a/src/mailbox.cpp b/src/mailbox.cpp index 1c199a76..a38aada0 100644 --- a/src/mailbox.cpp +++ b/src/mailbox.cpp @@ -452,9 +452,9 @@ mailbox& mailbox::operator=(const mailbox& other) } -ref mailbox::clone() const +shared_ptr mailbox::clone() const { - return vmime::create (*this); + return make_shared (*this); } @@ -501,9 +501,9 @@ void mailbox::setEmail(const emailAddress& email) } -const std::vector > mailbox::getChildComponents() +const std::vector > mailbox::getChildComponents() { - return std::vector >(); + return std::vector >(); } diff --git a/src/mailboxField.cpp b/src/mailboxField.cpp index 4eb9d734..7d138f3e 100644 --- a/src/mailboxField.cpp +++ b/src/mailboxField.cpp @@ -47,12 +47,12 @@ void mailboxField::parse (const parsingContext& ctx, const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition) { - ref mbox = vmime::create (); + shared_ptr mbox = make_shared (); // Here, we cannot simply call "m_mailbox.parse()" because it // may have more than one address specified (even if this field // should contain only one). We are never too much careful... - ref
parsedAddress = address::parseNext(ctx, buffer, position, end, newPosition, NULL); + shared_ptr
parsedAddress = address::parseNext(ctx, buffer, position, end, newPosition, NULL); if (parsedAddress) { @@ -60,7 +60,7 @@ void mailboxField::parse { // If it is a group of mailboxes, take the first // mailbox of the group - ref group = parsedAddress.staticCast (); + shared_ptr group = dynamicCast (parsedAddress); if (!group->isEmpty()) mbox = group->getMailboxAt(0); @@ -68,7 +68,7 @@ void mailboxField::parse else { // Parse only if it is a mailbox - mbox = parsedAddress.staticCast (); + mbox = dynamicCast (parsedAddress); } } diff --git a/src/mailboxGroup.cpp b/src/mailboxGroup.cpp index 9da16653..559d8778 100644 --- a/src/mailboxGroup.cpp +++ b/src/mailboxGroup.cpp @@ -82,24 +82,24 @@ void mailboxGroup::parseImpl while (pos < end && !isLastAddressOfGroup) { - ref
parsedAddress = address::parseNext(ctx, buffer, pos, end, &pos, &isLastAddressOfGroup); + shared_ptr
parsedAddress = address::parseNext(ctx, buffer, pos, end, &pos, &isLastAddressOfGroup); if (parsedAddress) { if (parsedAddress->isGroup()) { - ref group = parsedAddress.staticCast (); + shared_ptr group = dynamicCast (parsedAddress); // Sub-groups are not allowed in mailbox groups: so, we add all // the contents of the sub-group into this group... for (size_t i = 0 ; i < group->getMailboxCount() ; ++i) { - m_list.push_back(group->getMailboxAt(i)->clone().staticCast ()); + m_list.push_back(vmime::clone(group->getMailboxAt(i))); } } else { - m_list.push_back(parsedAddress.staticCast ()); + m_list.push_back(dynamicCast (parsedAddress)); } } } @@ -168,7 +168,7 @@ void mailboxGroup::generateImpl os << ":"; ++pos; - for (std::vector >::const_iterator it = m_list.begin() ; + for (std::vector >::const_iterator it = m_list.begin() ; it != m_list.end() ; ++it) { if (it != m_list.begin()) @@ -201,17 +201,17 @@ void mailboxGroup::copyFrom(const component& other) removeAllMailboxes(); - for (std::vector >::const_iterator it = source.m_list.begin() ; + for (std::vector >::const_iterator it = source.m_list.begin() ; it != source.m_list.end() ; ++it) { - m_list.push_back((*it)->clone().staticCast ()); + m_list.push_back(vmime::clone(*it)); } } -ref mailboxGroup::clone() const +shared_ptr mailboxGroup::clone() const { - return vmime::create (*this); + return make_shared (*this); } @@ -246,15 +246,15 @@ bool mailboxGroup::isEmpty() const } -void mailboxGroup::appendMailbox(ref mbox) +void mailboxGroup::appendMailbox(shared_ptr mbox) { m_list.push_back(mbox); } -void mailboxGroup::insertMailboxBefore(ref beforeMailbox, ref mbox) +void mailboxGroup::insertMailboxBefore(shared_ptr beforeMailbox, shared_ptr mbox) { - const std::vector >::iterator it = std::find + const std::vector >::iterator it = std::find (m_list.begin(), m_list.end(), beforeMailbox); if (it == m_list.end()) @@ -264,15 +264,15 @@ void mailboxGroup::insertMailboxBefore(ref beforeMailbox, ref mbox) +void mailboxGroup::insertMailboxBefore(const size_t pos, shared_ptr mbox) { m_list.insert(m_list.begin() + pos, mbox); } -void mailboxGroup::insertMailboxAfter(ref afterMailbox, ref mbox) +void mailboxGroup::insertMailboxAfter(shared_ptr afterMailbox, shared_ptr mbox) { - const std::vector >::iterator it = std::find + const std::vector >::iterator it = std::find (m_list.begin(), m_list.end(), afterMailbox); if (it == m_list.end()) @@ -282,15 +282,15 @@ void mailboxGroup::insertMailboxAfter(ref afterMailbox, ref } -void mailboxGroup::insertMailboxAfter(const size_t pos, ref mbox) +void mailboxGroup::insertMailboxAfter(const size_t pos, shared_ptr mbox) { m_list.insert(m_list.begin() + pos + 1, mbox); } -void mailboxGroup::removeMailbox(ref mbox) +void mailboxGroup::removeMailbox(shared_ptr mbox) { - const std::vector >::iterator it = std::find + const std::vector >::iterator it = std::find (m_list.begin(), m_list.end(), mbox); if (it == m_list.end()) @@ -302,7 +302,7 @@ void mailboxGroup::removeMailbox(ref mbox) void mailboxGroup::removeMailbox(const size_t pos) { - const std::vector >::iterator it = m_list.begin() + pos; + const std::vector >::iterator it = m_list.begin() + pos; m_list.erase(it); } @@ -320,25 +320,25 @@ size_t mailboxGroup::getMailboxCount() const } -ref mailboxGroup::getMailboxAt(const size_t pos) +shared_ptr mailboxGroup::getMailboxAt(const size_t pos) { return (m_list[pos]); } -const ref mailboxGroup::getMailboxAt(const size_t pos) const +const shared_ptr mailboxGroup::getMailboxAt(const size_t pos) const { return (m_list[pos]); } -const std::vector > mailboxGroup::getMailboxList() const +const std::vector > mailboxGroup::getMailboxList() const { - std::vector > list; + std::vector > list; list.reserve(m_list.size()); - for (std::vector >::const_iterator it = m_list.begin() ; + for (std::vector >::const_iterator it = m_list.begin() ; it != m_list.end() ; ++it) { list.push_back(*it); @@ -348,15 +348,15 @@ const std::vector > mailboxGroup::getMailboxList() const } -const std::vector > mailboxGroup::getMailboxList() +const std::vector > mailboxGroup::getMailboxList() { return (m_list); } -const std::vector > mailboxGroup::getChildComponents() +const std::vector > mailboxGroup::getChildComponents() { - std::vector > list; + std::vector > list; copy_vector(m_list, list); diff --git a/src/mailboxList.cpp b/src/mailboxList.cpp index f0f40ca8..0a76c52a 100644 --- a/src/mailboxList.cpp +++ b/src/mailboxList.cpp @@ -41,13 +41,13 @@ mailboxList::mailboxList(const mailboxList& mboxList) } -void mailboxList::appendMailbox(ref mbox) +void mailboxList::appendMailbox(shared_ptr mbox) { m_list.appendAddress(mbox); } -void mailboxList::insertMailboxBefore(ref beforeMailbox, ref mbox) +void mailboxList::insertMailboxBefore(shared_ptr beforeMailbox, shared_ptr mbox) { try { @@ -60,13 +60,13 @@ void mailboxList::insertMailboxBefore(ref beforeMailbox, ref } -void mailboxList::insertMailboxBefore(const size_t pos, ref mbox) +void mailboxList::insertMailboxBefore(const size_t pos, shared_ptr mbox) { m_list.insertAddressBefore(pos, mbox); } -void mailboxList::insertMailboxAfter(ref afterMailbox, ref mbox) +void mailboxList::insertMailboxAfter(shared_ptr afterMailbox, shared_ptr mbox) { try { @@ -79,13 +79,13 @@ void mailboxList::insertMailboxAfter(ref afterMailbox, ref m } -void mailboxList::insertMailboxAfter(const size_t pos, ref mbox) +void mailboxList::insertMailboxAfter(const size_t pos, shared_ptr mbox) { m_list.insertAddressAfter(pos, mbox); } -void mailboxList::removeMailbox(ref mbox) +void mailboxList::removeMailbox(shared_ptr mbox) { try { @@ -122,27 +122,27 @@ bool mailboxList::isEmpty() const } -ref mailboxList::getMailboxAt(const size_t pos) +shared_ptr mailboxList::getMailboxAt(const size_t pos) { - return m_list.getAddressAt(pos).staticCast (); + return dynamicCast (m_list.getAddressAt(pos)); } -const ref mailboxList::getMailboxAt(const size_t pos) const +const shared_ptr mailboxList::getMailboxAt(const size_t pos) const { - return m_list.getAddressAt(pos).staticCast (); + return dynamicCast (m_list.getAddressAt(pos)); } -const std::vector > mailboxList::getMailboxList() const +const std::vector > mailboxList::getMailboxList() const { - const std::vector > addrList = m_list.getAddressList(); - std::vector > res; + const std::vector > addrList = m_list.getAddressList(); + std::vector > res; - for (std::vector >::const_iterator it = addrList.begin() ; + for (std::vector >::const_iterator it = addrList.begin() ; it != addrList.end() ; ++it) { - const ref mbox = (*it).dynamicCast (); + const shared_ptr mbox = dynamicCast (*it); if (mbox != NULL) res.push_back(mbox); @@ -152,15 +152,15 @@ const std::vector > mailboxList::getMailboxList() const } -const std::vector > mailboxList::getMailboxList() +const std::vector > mailboxList::getMailboxList() { - const std::vector > addrList = m_list.getAddressList(); - std::vector > res; + const std::vector > addrList = m_list.getAddressList(); + std::vector > res; - for (std::vector >::const_iterator it = addrList.begin() ; + for (std::vector >::const_iterator it = addrList.begin() ; it != addrList.end() ; ++it) { - const ref mbox = (*it).dynamicCast (); + const shared_ptr mbox = dynamicCast (*it); if (mbox != NULL) res.push_back(mbox); @@ -170,9 +170,9 @@ const std::vector > mailboxList::getMailboxList() } -ref mailboxList::clone() const +shared_ptr mailboxList::clone() const { - return vmime::create (*this); + return make_shared (*this); } @@ -191,7 +191,7 @@ mailboxList& mailboxList::operator=(const mailboxList& other) } -const std::vector > mailboxList::getChildComponents() +const std::vector > mailboxList::getChildComponents() { return (m_list.getChildComponents()); } @@ -207,13 +207,13 @@ void mailboxList::parseImpl while (pos < end) { - ref
parsedAddress = address::parseNext(ctx, buffer, pos, end, &pos, NULL); + shared_ptr
parsedAddress = address::parseNext(ctx, buffer, pos, end, &pos, NULL); if (parsedAddress != NULL) { if (parsedAddress->isGroup()) { - ref group = parsedAddress.staticCast (); + shared_ptr group = dynamicCast (parsedAddress); for (size_t i = 0 ; i < group->getMailboxCount() ; ++i) { @@ -241,9 +241,9 @@ void mailboxList::generateImpl(const generationContext& ctx, utility::outputStre } -ref mailboxList::toAddressList() const +shared_ptr mailboxList::toAddressList() const { - return m_list.clone().dynamicCast (); + return vmime::clone(m_list); } diff --git a/src/mdn/MDNHelper.cpp b/src/mdn/MDNHelper.cpp index a0d48599..1205aef2 100644 --- a/src/mdn/MDNHelper.cpp +++ b/src/mdn/MDNHelper.cpp @@ -38,33 +38,33 @@ namespace vmime { namespace mdn { -void MDNHelper::attachMDNRequest(ref msg, const mailboxList& mailboxes) +void MDNHelper::attachMDNRequest(shared_ptr msg, const mailboxList& mailboxes) { - ref
hdr = msg->getHeader(); + shared_ptr
hdr = msg->getHeader(); hdr->DispositionNotificationTo()->setValue(mailboxes); } -void MDNHelper::attachMDNRequest(ref msg, const mailbox& mbox) +void MDNHelper::attachMDNRequest(shared_ptr msg, const mailbox& mbox) { mailboxList mboxList; - mboxList.appendMailbox(mbox.clone().dynamicCast ()); + mboxList.appendMailbox(vmime::clone(mbox)); attachMDNRequest(msg, mboxList); } -const std::vector MDNHelper::getPossibleMDNs(const ref msg) +const std::vector MDNHelper::getPossibleMDNs(const shared_ptr msg) { std::vector result; - const ref hdr = msg->getHeader(); + const shared_ptr hdr = msg->getHeader(); if (hdr->hasField(fields::DISPOSITION_NOTIFICATION_TO)) { - const mailboxList& dnto = *hdr->DispositionNotificationTo()->getValue() - .dynamicCast (); + const mailboxList& dnto = + *hdr->DispositionNotificationTo()->getValue (); for (size_t i = 0 ; i < dnto.getMailboxCount() ; ++i) result.push_back(sendableMDNInfos(msg, *dnto.getMailboxAt(i))); @@ -74,9 +74,9 @@ const std::vector MDNHelper::getPossibleMDNs(const ref msg) +bool MDNHelper::isMDN(const shared_ptr msg) { - const ref hdr = msg->getHeader(); + const shared_ptr hdr = msg->getHeader(); // A MDN message implies the following: // - a Content-Type field is present and its value is "multipart/report" @@ -84,10 +84,9 @@ bool MDNHelper::isMDN(const ref msg) // and its value is "disposition-notification" if (hdr->hasField(fields::CONTENT_TYPE)) { - const contentTypeField& ctf = *(hdr->ContentType() - .dynamicCast ()); + const contentTypeField& ctf = *dynamicCast (hdr->ContentType()); - const mediaType type = *ctf.getValue().dynamicCast (); + const mediaType type = *ctf.getValue (); if (type.getType() == vmime::mediaTypes::MULTIPART && type.getSubType() == vmime::mediaTypes::MULTIPART_REPORT) @@ -104,7 +103,7 @@ bool MDNHelper::isMDN(const ref msg) } -receivedMDNInfos MDNHelper::getReceivedMDN(const ref msg) +receivedMDNInfos MDNHelper::getReceivedMDN(const shared_ptr msg) { if (!isMDN(msg)) throw exceptions::invalid_argument(); @@ -113,9 +112,9 @@ receivedMDNInfos MDNHelper::getReceivedMDN(const ref msg) } -bool MDNHelper::needConfirmation(const ref msg) +bool MDNHelper::needConfirmation(const shared_ptr msg) { - ref hdr = msg->getHeader(); + shared_ptr hdr = msg->getHeader(); // No "Return-Path" field if (!hdr->hasField(fields::RETURN_PATH)) @@ -124,8 +123,7 @@ bool MDNHelper::needConfirmation(const ref msg) // More than one address in Disposition-Notification-To if (hdr->hasField(fields::DISPOSITION_NOTIFICATION_TO)) { - const mailboxList& dnto = *hdr->DispositionNotificationTo()->getValue() - .dynamicCast (); + const mailboxList& dnto = *hdr->DispositionNotificationTo()->getValue (); if (dnto.getMailboxCount() > 1) return true; @@ -134,7 +132,7 @@ bool MDNHelper::needConfirmation(const ref msg) // Return-Path != Disposition-Notification-To const mailbox& mbox = *dnto.getMailboxAt(0); - const path& rp = *hdr->ReturnPath()->getValue().dynamicCast (); + const path& rp = *hdr->ReturnPath()->getValue (); if (mbox.getEmail() != rp.getLocalPart() + "@" + rp.getDomain()) return true; @@ -145,7 +143,7 @@ bool MDNHelper::needConfirmation(const ref msg) } -ref MDNHelper::buildMDN(const sendableMDNInfos& mdnInfos, +shared_ptr MDNHelper::buildMDN(const sendableMDNInfos& mdnInfos, const string& text, const charset& ch, const mailbox& expeditor, @@ -155,19 +153,19 @@ ref MDNHelper::buildMDN(const sendableMDNInfos& mdnInfos, const std::map & fields) { // Create a new message - ref msg = vmime::create (); + shared_ptr msg = make_shared (); // Fill-in header fields - ref
hdr = msg->getHeader(); + shared_ptr
hdr = msg->getHeader(); hdr->ContentType()->setValue(mediaType(vmime::mediaTypes::MULTIPART, vmime::mediaTypes::MULTIPART_REPORT)); - hdr->ContentType().dynamicCast ()->setReportType("disposition-notification"); + dynamicCast (hdr->ContentType())->setReportType("disposition-notification"); hdr->Disposition()->setValue(dispo); addressList to; - to.appendAddress(vmime::create (mdnInfos.getRecipient())); + to.appendAddress(make_shared (mdnInfos.getRecipient())); hdr->To()->setValue(to); hdr->From()->setValue(expeditor); @@ -186,36 +184,36 @@ ref MDNHelper::buildMDN(const sendableMDNInfos& mdnInfos, } -ref MDNHelper::createFirstMDNPart(const sendableMDNInfos& /* mdnInfos */, +shared_ptr MDNHelper::createFirstMDNPart(const sendableMDNInfos& /* mdnInfos */, const string& text, const charset& ch) { - ref part = vmime::create (); + shared_ptr part = make_shared (); // Header - ref
hdr = part->getHeader(); + shared_ptr
hdr = part->getHeader(); hdr->ContentType()->setValue(mediaType(vmime::mediaTypes::TEXT, vmime::mediaTypes::TEXT_PLAIN)); - hdr->ContentType().dynamicCast ()->setCharset(ch); + dynamicCast (hdr->ContentType())->setCharset(ch); // Body - part->getBody()->setContents(vmime::create (text)); + part->getBody()->setContents(make_shared (text)); return (part); } -ref MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos, +shared_ptr MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos, const disposition& dispo, const string& reportingUA, const std::vector & reportingUAProducts, const std::map & additionalFields) { - ref part = vmime::create (); + shared_ptr part = make_shared (); // Header - ref
hdr = part->getHeader(); + shared_ptr
hdr = part->getHeader(); hdr->ContentDisposition()->setValue(vmime::contentDispositionTypes::INLINE); hdr->ContentType()->setValue(mediaType(vmime::mediaTypes::MESSAGE, @@ -257,7 +255,7 @@ ref MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos, ruaText += reportingUAProducts[i]; } - ref rua = headerFieldFactory::getInstance()-> + shared_ptr rua = headerFieldFactory::getInstance()-> create(vmime::fields::REPORTING_UA); rua->setValue(ruaText); @@ -266,7 +264,7 @@ ref MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos, } // -- Final-Recipient - ref fr = headerFieldFactory::getInstance()-> + shared_ptr fr = headerFieldFactory::getInstance()-> create(vmime::fields::FINAL_RECIPIENT); fr->setValue("rfc822; " + mdnInfos.getRecipient().getEmail().generate()); @@ -291,7 +289,7 @@ ref MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos, it = additionalFields.find(vmime::fields::ERROR); if (it != additionalFields.end()) { - ref error = headerFieldFactory::getInstance()-> + shared_ptr error = headerFieldFactory::getInstance()-> create(vmime::fields::ERROR); error->setValue(it->second); fields.appendField(error); @@ -300,7 +298,7 @@ ref MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos, it = additionalFields.find(vmime::fields::WARNING); if (it != additionalFields.end()) { - ref warn = headerFieldFactory::getInstance()-> + shared_ptr warn = headerFieldFactory::getInstance()-> create(vmime::fields::WARNING); warn->setValue(it->second); fields.appendField(warn); @@ -309,7 +307,7 @@ ref MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos, it = additionalFields.find(vmime::fields::FAILURE); if (it != additionalFields.end()) { - ref fail = headerFieldFactory::getInstance()-> + shared_ptr fail = headerFieldFactory::getInstance()-> create(vmime::fields::FAILURE); fail->setValue(it->second); fields.appendField(fail); @@ -322,18 +320,18 @@ ref MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos, fields.generate(vos); - part->getBody()->setContents(vmime::create (oss.str())); + part->getBody()->setContents(make_shared (oss.str())); return (part); } -ref MDNHelper::createThirdMDNPart(const sendableMDNInfos& mdnInfos) +shared_ptr MDNHelper::createThirdMDNPart(const sendableMDNInfos& mdnInfos) { - ref part = vmime::create (); + shared_ptr part = make_shared (); // Header - ref
hdr = part->getHeader(); + shared_ptr
hdr = part->getHeader(); hdr->ContentDisposition()->setValue(vmime::contentDispositionTypes::INLINE); hdr->ContentType()->setValue(mediaType(vmime::mediaTypes::TEXT, @@ -345,7 +343,7 @@ ref MDNHelper::createThirdMDNPart(const sendableMDNInfos& mdnInfos) mdnInfos.getMessage()->getHeader()->generate(vos); - part->getBody()->setContents(vmime::create (oss.str())); + part->getBody()->setContents(make_shared (oss.str())); return (part); } diff --git a/src/mdn/receivedMDNInfos.cpp b/src/mdn/receivedMDNInfos.cpp index 876ba3d9..1c523be7 100644 --- a/src/mdn/receivedMDNInfos.cpp +++ b/src/mdn/receivedMDNInfos.cpp @@ -30,7 +30,7 @@ namespace vmime { namespace mdn { -receivedMDNInfos::receivedMDNInfos(const ref msg) +receivedMDNInfos::receivedMDNInfos(const shared_ptr msg) : m_msg(msg) { extract(); @@ -51,7 +51,7 @@ receivedMDNInfos& receivedMDNInfos::operator=(const receivedMDNInfos& other) } -const ref receivedMDNInfos::getMessage() const +const shared_ptr receivedMDNInfos::getMessage() const { return (m_msg); } @@ -86,17 +86,16 @@ void receivedMDNInfos::copyFrom(const receivedMDNInfos& other) void receivedMDNInfos::extract() { - const ref bdy = m_msg->getBody(); + const shared_ptr bdy = m_msg->getBody(); for (size_t i = 0 ; i < bdy->getPartCount() ; ++i) { - const ref part = bdy->getPartAt(i); + const shared_ptr part = bdy->getPartAt(i); if (!part->getHeader()->hasField(fields::CONTENT_TYPE)) continue; - const mediaType& type = *part->getHeader()->ContentType()-> - getValue().dynamicCast (); + const mediaType& type = *part->getHeader()->ContentType()->getValue (); // Extract from second part (message/disposition-notification) if (type.getType() == vmime::mediaTypes::MESSAGE && @@ -111,15 +110,15 @@ void receivedMDNInfos::extract() header fields; fields.parse(oss.str()); - try { m_omid = *fields.OriginalMessageId()->getValue().dynamicCast (); } + try { m_omid = *fields.OriginalMessageId()->getValue (); } catch (exceptions::no_such_field&) { /* Ignore */ } - try { m_disp = *fields.Disposition()->getValue().dynamicCast (); } + try { m_disp = *fields.Disposition()->getValue (); } catch (exceptions::no_such_field&) { /* Ignore */ } try { - text t = *fields.findField("Received-content-MIC")->getValue().dynamicCast (); + text t = *fields.findField("Received-content-MIC")->getValue (); m_contentMIC = t.generate(); } catch (exceptions::no_such_field&) { /* Ignore */ } diff --git a/src/mdn/sendableMDNInfos.cpp b/src/mdn/sendableMDNInfos.cpp index 44c0515c..c145c3b6 100644 --- a/src/mdn/sendableMDNInfos.cpp +++ b/src/mdn/sendableMDNInfos.cpp @@ -28,7 +28,7 @@ namespace vmime { namespace mdn { -sendableMDNInfos::sendableMDNInfos(const ref msg, const mailbox& mbox) +sendableMDNInfos::sendableMDNInfos(const shared_ptr msg, const mailbox& mbox) : m_msg(msg), m_mailbox(mbox) { } @@ -48,7 +48,7 @@ sendableMDNInfos& sendableMDNInfos::operator=(const sendableMDNInfos& other) } -const ref sendableMDNInfos::getMessage() const +const shared_ptr sendableMDNInfos::getMessage() const { return (m_msg); } diff --git a/src/mediaType.cpp b/src/mediaType.cpp index 123c8cee..2f9ca6b1 100644 --- a/src/mediaType.cpp +++ b/src/mediaType.cpp @@ -126,9 +126,9 @@ mediaType& mediaType::operator=(const string& type) } -ref mediaType::clone() const +shared_ptr mediaType::clone() const { - return vmime::create (m_type, m_subType); + return make_shared (m_type, m_subType); } @@ -178,9 +178,9 @@ void mediaType::setFromString(const string& type) } -const std::vector > mediaType::getChildComponents() +const std::vector > mediaType::getChildComponents() { - return std::vector >(); + return std::vector >(); } diff --git a/src/messageBuilder.cpp b/src/messageBuilder.cpp index ecd0f5d7..64880483 100644 --- a/src/messageBuilder.cpp +++ b/src/messageBuilder.cpp @@ -43,10 +43,10 @@ messageBuilder::~messageBuilder() } -ref messageBuilder::construct() const +shared_ptr messageBuilder::construct() const { // Create a new message - ref msg = vmime::create (); + shared_ptr msg = make_shared (); // Generate the header fields msg->getHeader()->Subject()->setValue(m_subject); @@ -101,7 +101,7 @@ ref messageBuilder::construct() const (mediaType(mediaTypes::MULTIPART, mediaTypes::MULTIPART_MIXED)); // Create a sub-part "multipart/alternative" for text parts - ref subPart = vmime::create (); + shared_ptr subPart = make_shared (); msg->getBody()->appendPart(subPart); subPart->getHeader()->ContentType()->setValue @@ -133,7 +133,7 @@ ref messageBuilder::construct() const // Generate the attachments if (!m_attach.empty()) { - for (std::vector >::const_iterator a = m_attach.begin() ; + for (std::vector >::const_iterator a = m_attach.begin() ; a != m_attach.end() ; ++a) { (*a)->generateIn(msg); @@ -147,12 +147,12 @@ ref messageBuilder::construct() const const bodyPart& part = *msg->getBody()->getPartAt(0); // Make a full copy of the body, otherwise the copyFrom() will delete the body we're copying - ref bodyCopy = part.getBody()->clone().dynamicCast (); + shared_ptr bodyCopy = vmime::clone(part.getBody()); // First, copy (and replace) the header fields - const std::vector > fields = part.getHeader()->getFieldList(); + const std::vector > fields = part.getHeader()->getFieldList(); - for (std::vector >::const_iterator it = fields.begin() ; + for (std::vector >::const_iterator it = fields.begin() ; it != fields.end() ; ++it) { *(msg->getHeader()->getField((*it)->getName())) = **it; @@ -167,13 +167,13 @@ ref messageBuilder::construct() const } -void messageBuilder::attach(ref attach) +void messageBuilder::attach(shared_ptr attach) { appendAttachment(attach); } -void messageBuilder::appendAttachment(ref attach) +void messageBuilder::appendAttachment(shared_ptr attach) { m_attach.push_back(attach); } @@ -181,7 +181,7 @@ void messageBuilder::appendAttachment(ref attach) void messageBuilder::constructTextPart(const mediaType& type) { - ref part = NULL; + shared_ptr part; try { @@ -196,7 +196,7 @@ void messageBuilder::constructTextPart(const mediaType& type) } -ref messageBuilder::getTextPart() +shared_ptr messageBuilder::getTextPart() { return (m_textPart); } @@ -286,13 +286,13 @@ void messageBuilder::removeAttachment(const size_t pos) } -const ref messageBuilder::getAttachmentAt(const size_t pos) const +const shared_ptr messageBuilder::getAttachmentAt(const size_t pos) const { return (m_attach[pos]); } -ref messageBuilder::getAttachmentAt(const size_t pos) +shared_ptr messageBuilder::getAttachmentAt(const size_t pos) { return (m_attach[pos]); } @@ -304,13 +304,13 @@ size_t messageBuilder::getAttachmentCount() const } -const std::vector > messageBuilder::getAttachmentList() const +const std::vector > messageBuilder::getAttachmentList() const { - std::vector > res; + std::vector > res; res.reserve(m_attach.size()); - for (std::vector >::const_iterator it = m_attach.begin() ; + for (std::vector >::const_iterator it = m_attach.begin() ; it != m_attach.end() ; ++it) { res.push_back(*it); @@ -320,7 +320,7 @@ const std::vector > messageBuilder::getAttachmentList() } -const std::vector > messageBuilder::getAttachmentList() +const std::vector > messageBuilder::getAttachmentList() { return (m_attach); } diff --git a/src/messageId.cpp b/src/messageId.cpp index 6b558e1b..d981f061 100644 --- a/src/messageId.cpp +++ b/src/messageId.cpp @@ -146,7 +146,7 @@ void messageId::parseImpl } -ref messageId::parseNext +shared_ptr messageId::parseNext (const parsingContext& ctx, const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition) { @@ -162,7 +162,7 @@ ref messageId::parseNext while (pos < end && !parserHelpers::isSpace(buffer[pos])) ++pos; - ref mid = vmime::create (); + shared_ptr mid = make_shared (); mid->parse(ctx, buffer, begin, pos, NULL); if (newPosition != NULL) @@ -174,7 +174,7 @@ ref messageId::parseNext if (newPosition != NULL) *newPosition = end; - return (NULL); + return null; } @@ -245,9 +245,9 @@ bool messageId::operator!=(const messageId& mid) const } -ref messageId::clone() const +shared_ptr messageId::clone() const { - return vmime::create (*this); + return make_shared (*this); } @@ -291,9 +291,9 @@ void messageId::setRight(const string& right) } -const std::vector > messageId::getChildComponents() +const std::vector > messageId::getChildComponents() { - return std::vector >(); + return std::vector >(); } diff --git a/src/messageIdSequence.cpp b/src/messageIdSequence.cpp index 99c96319..bfd0c30f 100644 --- a/src/messageIdSequence.cpp +++ b/src/messageIdSequence.cpp @@ -50,9 +50,9 @@ messageIdSequence::messageIdSequence(const messageIdSequence& midSeq) } -ref messageIdSequence::clone() const +shared_ptr messageIdSequence::clone() const { - return vmime::create (*this); + return make_shared (*this); } @@ -63,7 +63,7 @@ void messageIdSequence::copyFrom(const component& other) removeAllMessageIds(); for (unsigned int i = 0 ; i < midSeq.m_list.size() ; ++i) - m_list.push_back(midSeq.m_list[i]->clone().dynamicCast ()); + m_list.push_back(vmime::clone(midSeq.m_list[i])); } @@ -74,9 +74,9 @@ messageIdSequence& messageIdSequence::operator=(const messageIdSequence& other) } -const std::vector > messageIdSequence::getChildComponents() +const std::vector > messageIdSequence::getChildComponents() { - std::vector > res; + std::vector > res; copy_vector(m_list, res); @@ -94,7 +94,7 @@ void messageIdSequence::parseImpl while (pos < end) { - ref parsedMid = messageId::parseNext(ctx, buffer, pos, end, &pos); + shared_ptr parsedMid = messageId::parseNext(ctx, buffer, pos, end, &pos); if (parsedMid != NULL) m_list.push_back(parsedMid); @@ -118,7 +118,7 @@ void messageIdSequence::generateImpl generationContext tmpCtx(ctx); tmpCtx.setMaxLineLength(ctx.getMaxLineLength() - 2); - for (std::vector >::const_iterator it = m_list.begin() ; ; ) + for (std::vector >::const_iterator it = m_list.begin() ; ; ) { (*it)->generate(ctx, os, pos, &pos); @@ -135,15 +135,15 @@ void messageIdSequence::generateImpl } -void messageIdSequence::appendMessageId(ref mid) +void messageIdSequence::appendMessageId(shared_ptr mid) { m_list.push_back(mid); } -void messageIdSequence::insertMessageIdBefore(ref beforeMid, ref mid) +void messageIdSequence::insertMessageIdBefore(shared_ptr beforeMid, shared_ptr mid) { - const std::vector >::iterator it = std::find + const std::vector >::iterator it = std::find (m_list.begin(), m_list.end(), beforeMid); if (it == m_list.end()) @@ -153,15 +153,15 @@ void messageIdSequence::insertMessageIdBefore(ref beforeMid, ref mid) +void messageIdSequence::insertMessageIdBefore(const size_t pos, shared_ptr mid) { m_list.insert(m_list.begin() + pos, mid); } -void messageIdSequence::insertMessageIdAfter(ref afterMid, ref mid) +void messageIdSequence::insertMessageIdAfter(shared_ptr afterMid, shared_ptr mid) { - const std::vector >::iterator it = std::find + const std::vector >::iterator it = std::find (m_list.begin(), m_list.end(), afterMid); if (it == m_list.end()) @@ -171,15 +171,15 @@ void messageIdSequence::insertMessageIdAfter(ref afterMid, ref mid) +void messageIdSequence::insertMessageIdAfter(const size_t pos, shared_ptr mid) { m_list.insert(m_list.begin() + pos + 1, mid); } -void messageIdSequence::removeMessageId(ref mid) +void messageIdSequence::removeMessageId(shared_ptr mid) { - const std::vector >::iterator it = std::find + const std::vector >::iterator it = std::find (m_list.begin(), m_list.end(), mid); if (it == m_list.end()) @@ -191,7 +191,7 @@ void messageIdSequence::removeMessageId(ref mid) void messageIdSequence::removeMessageId(const size_t pos) { - const std::vector >::iterator it = m_list.begin() + pos; + const std::vector >::iterator it = m_list.begin() + pos; m_list.erase(it); } @@ -215,25 +215,25 @@ bool messageIdSequence::isEmpty() const } -const ref messageIdSequence::getMessageIdAt(const size_t pos) +const shared_ptr messageIdSequence::getMessageIdAt(const size_t pos) { return (m_list[pos]); } -const ref messageIdSequence::getMessageIdAt(const size_t pos) const +const shared_ptr messageIdSequence::getMessageIdAt(const size_t pos) const { return (m_list[pos]); } -const std::vector > messageIdSequence::getMessageIdList() const +const std::vector > messageIdSequence::getMessageIdList() const { - std::vector > list; + std::vector > list; list.reserve(m_list.size()); - for (std::vector >::const_iterator it = m_list.begin() ; + for (std::vector >::const_iterator it = m_list.begin() ; it != m_list.end() ; ++it) { list.push_back(*it); @@ -243,7 +243,7 @@ const std::vector > messageIdSequence::getMessageIdList() } -const std::vector > messageIdSequence::getMessageIdList() +const std::vector > messageIdSequence::getMessageIdList() { return (m_list); } diff --git a/src/messageParser.cpp b/src/messageParser.cpp index 1377072c..41be3803 100644 --- a/src/messageParser.cpp +++ b/src/messageParser.cpp @@ -39,14 +39,14 @@ namespace vmime messageParser::messageParser(const string& buffer) { - ref msg = vmime::create (); + shared_ptr msg = make_shared (); msg->parse(buffer); parse(msg); } -messageParser::messageParser(ref msg) +messageParser::messageParser(shared_ptr msg) { parse(msg); } @@ -57,13 +57,13 @@ messageParser::~messageParser() } -void messageParser::parse(ref msg) +void messageParser::parse(shared_ptr msg) { // Header fields (if field is present, copy its value, else do nothing) #ifndef VMIME_BUILDING_DOC #define TRY_FIELD(var, type, name) \ - try { var = *msg->getHeader()->findField(name)->getValue().dynamicCast (); } \ + try { var = *msg->getHeader()->findField(name)->getValue (); } \ catch (exceptions::no_such_field) { } TRY_FIELD(m_from, mailbox, fields::FROM); @@ -82,14 +82,14 @@ void messageParser::parse(ref msg) try { const headerField& recv = *msg->getHeader()->findField(fields::RECEIVED); - m_date = recv.getValue().dynamicCast ()->getDate(); + m_date = recv.getValue ()->getDate(); } catch (vmime::exceptions::no_such_field&) { try { const headerField& date = *msg->getHeader()->findField(fields::DATE); - m_date = *date.getValue().dynamicCast (); + m_date = *date.getValue (); } catch (vmime::exceptions::no_such_field&) { @@ -105,13 +105,13 @@ void messageParser::parse(ref msg) } -void messageParser::findAttachments(ref msg) +void messageParser::findAttachments(shared_ptr msg) { m_attach = attachmentHelper::findAttachmentsInMessage(msg); } -void messageParser::findTextParts(ref msg, ref part) +void messageParser::findTextParts(shared_ptr msg, shared_ptr part) { // Handle the case in which the message is not multipart: if the body part is // "text/*", take this part. @@ -122,11 +122,11 @@ void messageParser::findTextParts(ref msg, ref try { - const contentTypeField& ctf = dynamic_cast - (*msg->getHeader()->findField(fields::CONTENT_TYPE)); + const contentTypeField& ctf = + *msg->getHeader()->findField (fields::CONTENT_TYPE); const mediaType ctfType = - *ctf.getValue().dynamicCast (); + *ctf.getValue (); if (ctfType.getType() == mediaTypes::TEXT) { @@ -142,7 +142,7 @@ void messageParser::findTextParts(ref msg, ref if (accept) { - ref txtPart = textPartFactory::getInstance()->create(type); + shared_ptr txtPart = textPartFactory::getInstance()->create(type); txtPart->parse(msg, msg, msg); m_textParts.push_back(txtPart); @@ -156,35 +156,35 @@ void messageParser::findTextParts(ref msg, ref } -bool messageParser::findSubTextParts(ref msg, ref part) +bool messageParser::findSubTextParts(shared_ptr msg, shared_ptr part) { // In general, all the text parts are contained in parallel in the same // parent part (or message). // So, wherever the text parts are, all we have to do is to find the first // MIME part which is a text part. - std::vector > textParts; + std::vector > textParts; for (size_t i = 0 ; i < part->getBody()->getPartCount() ; ++i) { - const ref p = part->getBody()->getPartAt(i); + const shared_ptr p = part->getBody()->getPartAt(i); try { - const contentTypeField& ctf = dynamic_cast - (*(p->getHeader()->findField(fields::CONTENT_TYPE))); + const contentTypeField& ctf = + *p->getHeader()->findField (fields::CONTENT_TYPE); - const mediaType type = *ctf.getValue().dynamicCast (); + const mediaType type = *ctf.getValue (); contentDisposition disp; // default should be inline if (type.getType() == mediaTypes::TEXT) { try { - ref cdf = p->getHeader()-> - findField(fields::CONTENT_DISPOSITION).dynamicCast (); + shared_ptr cdf = p->getHeader()-> + findField (fields::CONTENT_DISPOSITION); - disp = *cdf->getValue().dynamicCast (); + disp = *cdf->getValue (); } catch (exceptions::no_such_field&) { @@ -204,17 +204,17 @@ bool messageParser::findSubTextParts(ref msg, ref >::const_iterator p = textParts.begin() ; + for (std::vector >::const_iterator p = textParts.begin() ; p != textParts.end() ; ++p) { - const contentTypeField& ctf = dynamic_cast - (*((*p)->getHeader()->findField(fields::CONTENT_TYPE))); + const contentTypeField& ctf = + *(*p)->getHeader()->findField (fields::CONTENT_TYPE); - const mediaType type = *ctf.getValue().dynamicCast (); + const mediaType type = *ctf.getValue (); try { - ref txtPart = textPartFactory::getInstance()->create(type); + shared_ptr txtPart = textPartFactory::getInstance()->create(type); txtPart->parse(msg, part, *p); m_textParts.push_back(txtPart); @@ -273,7 +273,7 @@ const datetime& messageParser::getDate() const } -const std::vector > messageParser::getAttachmentList() const +const std::vector > messageParser::getAttachmentList() const { return m_attach; } @@ -285,19 +285,19 @@ size_t messageParser::getAttachmentCount() const } -const ref messageParser::getAttachmentAt(const size_t pos) const +const shared_ptr messageParser::getAttachmentAt(const size_t pos) const { return (m_attach[pos]); } -const std::vector > messageParser::getTextPartList() const +const std::vector > messageParser::getTextPartList() const { - std::vector > res; + std::vector > res; res.reserve(m_textParts.size()); - for (std::vector >::const_iterator it = m_textParts.begin() ; + for (std::vector >::const_iterator it = m_textParts.begin() ; it != m_textParts.end() ; ++it) { res.push_back(*it); @@ -313,7 +313,7 @@ size_t messageParser::getTextPartCount() const } -const ref messageParser::getTextPartAt(const size_t pos) const +const shared_ptr messageParser::getTextPartAt(const size_t pos) const { return (m_textParts[pos]); } diff --git a/src/misc/importanceHelper.cpp b/src/misc/importanceHelper.cpp index 2cc7ce6a..8066cc5f 100644 --- a/src/misc/importanceHelper.cpp +++ b/src/misc/importanceHelper.cpp @@ -31,17 +31,17 @@ namespace vmime { namespace misc { -void importanceHelper::resetImportance(ref msg) +void importanceHelper::resetImportance(shared_ptr msg) { resetImportanceHeader(msg->getHeader()); } -void importanceHelper::resetImportanceHeader(ref
hdr) +void importanceHelper::resetImportanceHeader(shared_ptr
hdr) { try { - ref fld = hdr->findField("X-Priority"); + shared_ptr fld = hdr->findField("X-Priority"); hdr->removeField(fld); } catch (exceptions::no_such_field) @@ -51,7 +51,7 @@ void importanceHelper::resetImportanceHeader(ref
hdr) try { - ref fld = hdr->findField("Importance"); + shared_ptr fld = hdr->findField("Importance"); hdr->removeField(fld); } catch (exceptions::no_such_field) @@ -61,19 +61,19 @@ void importanceHelper::resetImportanceHeader(ref
hdr) } -importanceHelper::Importance importanceHelper::getImportance(ref msg) +importanceHelper::Importance importanceHelper::getImportance(shared_ptr msg) { return getImportanceHeader(msg->getHeader()); } -importanceHelper::Importance importanceHelper::getImportanceHeader(ref hdr) +importanceHelper::Importance importanceHelper::getImportanceHeader(shared_ptr hdr) { // Try "X-Priority" field try { - const ref fld = hdr->findField("X-Priority"); - const string value = fld->getValue().dynamicCast ()->getWholeBuffer(); + const shared_ptr fld = hdr->findField("X-Priority"); + const string value = fld->getValue ()->getWholeBuffer(); int n = IMPORTANCE_NORMAL; @@ -98,9 +98,9 @@ importanceHelper::Importance importanceHelper::getImportanceHeader(ref fld = hdr->findField("Importance"); + const shared_ptr fld = hdr->findField("Importance"); const string value = utility::stringUtils::toLower(utility::stringUtils::trim - (fld->getValue().dynamicCast ()->getWholeBuffer())); + (fld->getValue ()->getWholeBuffer())); if (value == "low") return (IMPORTANCE_LOWEST); @@ -121,16 +121,16 @@ importanceHelper::Importance importanceHelper::getImportanceHeader(ref msg, const Importance i) +void importanceHelper::setImportance(shared_ptr msg, const Importance i) { setImportanceHeader(msg->getHeader(), i); } -void importanceHelper::setImportanceHeader(ref
hdr, const Importance i) +void importanceHelper::setImportanceHeader(shared_ptr
hdr, const Importance i) { // "X-Priority:" Field - ref fld = hdr->getField("X-Priority"); + shared_ptr fld = hdr->getField("X-Priority"); switch (i) { diff --git a/src/net/events.cpp b/src/net/events.cpp index 8cc23706..a19e1738 100644 --- a/src/net/events.cpp +++ b/src/net/events.cpp @@ -60,7 +60,7 @@ const char* messageCountEvent::EVENT_CLASS = "messageCountEvent"; messageCountEvent::messageCountEvent - (ref folder, const Types type, const std::vector & nums) + (shared_ptr folder, const Types type, const std::vector & nums) : m_folder(folder), m_type(type) { m_nums.resize(nums.size()); @@ -68,7 +68,7 @@ messageCountEvent::messageCountEvent } -ref messageCountEvent::getFolder() const { return (m_folder); } +shared_ptr messageCountEvent::getFolder() const { return (m_folder); } messageCountEvent::Types messageCountEvent::getType() const { return (m_type); } const std::vector & messageCountEvent::getNumbers() const { return (m_nums); } @@ -76,9 +76,9 @@ const std::vector & messageCountEvent::getNumbers() const { return (m_nums) void messageCountEvent::dispatch(messageCountListener* listener) { if (m_type == TYPE_ADDED) - listener->messagesAdded(thisRef().dynamicCast ()); + listener->messagesAdded(dynamicCast (shared_from_this())); else - listener->messagesRemoved(thisRef().dynamicCast ()); + listener->messagesRemoved(dynamicCast (shared_from_this())); } @@ -96,7 +96,7 @@ const char* messageChangedEvent::EVENT_CLASS = "messageChangedEvent"; messageChangedEvent::messageChangedEvent - (ref folder, const Types type, const std::vector & nums) + (shared_ptr folder, const Types type, const std::vector & nums) : m_folder(folder), m_type(type) { m_nums.resize(nums.size()); @@ -104,14 +104,14 @@ messageChangedEvent::messageChangedEvent } -ref messageChangedEvent::getFolder() const { return (m_folder); } +shared_ptr messageChangedEvent::getFolder() const { return (m_folder); } messageChangedEvent::Types messageChangedEvent::getType() const { return (m_type); } const std::vector & messageChangedEvent::getNumbers() const { return (m_nums); } void messageChangedEvent::dispatch(messageChangedListener* listener) { - listener->messageChanged(thisRef().dynamicCast ()); + listener->messageChanged(dynamicCast (shared_from_this())); } @@ -129,14 +129,14 @@ const char* folderEvent::EVENT_CLASS = "folderEvent"; folderEvent::folderEvent - (ref folder, const Types type, + (shared_ptr folder, const Types type, const utility::path& oldPath, const utility::path& newPath) : m_folder(folder), m_type(type), m_oldPath(oldPath), m_newPath(newPath) { } -ref folderEvent::getFolder() const { return (m_folder); } +shared_ptr folderEvent::getFolder() const { return (m_folder); } folderEvent::Types folderEvent::getType() const { return (m_type); } @@ -144,9 +144,9 @@ void folderEvent::dispatch(folderListener* listener) { switch (m_type) { - case TYPE_CREATED: listener->folderCreated(thisRef().dynamicCast ()); break; - case TYPE_RENAMED: listener->folderRenamed(thisRef().dynamicCast ()); break; - case TYPE_DELETED: listener->folderDeleted(thisRef().dynamicCast ()); break; + case TYPE_CREATED: listener->folderCreated(dynamicCast (shared_from_this())); break; + case TYPE_RENAMED: listener->folderRenamed(dynamicCast (shared_from_this())); break; + case TYPE_DELETED: listener->folderDeleted(dynamicCast (shared_from_this())); break; } } diff --git a/src/net/folder.cpp b/src/net/folder.cpp index 1cc618d4..1d6f3140 100644 --- a/src/net/folder.cpp +++ b/src/net/folder.cpp @@ -48,7 +48,7 @@ void folder::removeMessageChangedListener(events::messageChangedListener* l) } -void folder::notifyMessageChanged(ref event) +void folder::notifyMessageChanged(shared_ptr event) { for (std::list ::iterator it = m_messageChangedListeners.begin() ; it != m_messageChangedListeners.end() ; ++it) @@ -70,7 +70,7 @@ void folder::removeMessageCountListener(events::messageCountListener* l) } -void folder::notifyMessageCount(ref event) +void folder::notifyMessageCount(shared_ptr event) { for (std::list ::iterator it = m_messageCountListeners.begin() ; it != m_messageCountListeners.end() ; ++it) @@ -92,7 +92,7 @@ void folder::removeFolderListener(events::folderListener* l) } -void folder::notifyFolder(ref event) +void folder::notifyFolder(shared_ptr event) { for (std::list ::iterator it = m_folderListeners.begin() ; it != m_folderListeners.end() ; ++it) @@ -102,19 +102,19 @@ void folder::notifyFolder(ref event) } -void folder::notifyEvent(ref event) +void folder::notifyEvent(shared_ptr event) { if (event->getClass() == events::messageCountEvent::EVENT_CLASS) { - notifyMessageCount(event.dynamicCast ()); + notifyMessageCount(dynamicCast (event)); } else if (event->getClass() == events::messageChangedEvent::EVENT_CLASS) { - notifyMessageChanged(event.dynamicCast ()); + notifyMessageChanged(dynamicCast (event)); } else if (event->getClass() == events::folderEvent::EVENT_CLASS) { - notifyFolder(event.dynamicCast ()); + notifyFolder(dynamicCast (event)); } } diff --git a/src/net/imap/IMAPConnection.cpp b/src/net/imap/IMAPConnection.cpp index 53f8ba9f..0dba1ecc 100644 --- a/src/net/imap/IMAPConnection.cpp +++ b/src/net/imap/IMAPConnection.cpp @@ -53,11 +53,11 @@ // Helpers for service properties #define GET_PROPERTY(type, prop) \ - (m_store.acquire()->getInfos().getPropertyValue (getSession(), \ - dynamic_cast (m_store.acquire()->getInfos()).getProperties().prop)) + (m_store.lock()->getInfos().getPropertyValue (getSession(), \ + dynamic_cast (m_store.lock()->getInfos()).getProperties().prop)) #define HAS_PROPERTY(prop) \ - (m_store.acquire()->getInfos().hasProperty(getSession(), \ - dynamic_cast (m_store.acquire()->getInfos()).getProperties().prop)) + (m_store.lock()->getInfos().hasProperty(getSession(), \ + dynamic_cast (m_store.lock()->getInfos()).getProperties().prop)) namespace vmime { @@ -65,9 +65,9 @@ namespace net { namespace imap { -IMAPConnection::IMAPConnection(ref store, ref auth) - : m_store(store), m_auth(auth), m_socket(NULL), m_parser(NULL), m_tag(NULL), - m_hierarchySeparator('\0'), m_state(STATE_NONE), m_timeoutHandler(NULL), +IMAPConnection::IMAPConnection(shared_ptr store, shared_ptr auth) + : m_store(store), m_auth(auth), m_socket(null), m_parser(null), m_tag(null), + m_hierarchySeparator('\0'), m_state(STATE_NONE), m_timeoutHandler(null), m_secured(false), m_firstTag(true), m_capabilitiesFetched(false), m_noModSeq(false) { } @@ -100,7 +100,7 @@ void IMAPConnection::connect() const string address = GET_PROPERTY(string, PROPERTY_SERVER_ADDRESS); const port_t port = GET_PROPERTY(port_t, PROPERTY_SERVER_PORT); - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); // Create the time-out handler if (store->getTimeoutHandlerFactory()) @@ -112,29 +112,29 @@ void IMAPConnection::connect() #if VMIME_HAVE_TLS_SUPPORT if (store->isIMAPS()) // dedicated port/IMAPS { - ref tlsSession = tls::TLSSession::create + shared_ptr tlsSession = tls::TLSSession::create (store->getCertificateVerifier(), store->getSession()->getTLSProperties()); - ref tlsSocket = + shared_ptr tlsSocket = tlsSession->getSocket(m_socket); m_socket = tlsSocket; m_secured = true; - m_cntInfos = vmime::create (address, port, tlsSession, tlsSocket); + m_cntInfos = make_shared (address, port, tlsSession, tlsSocket); } else #endif // VMIME_HAVE_TLS_SUPPORT { - m_cntInfos = vmime::create (address, port); + m_cntInfos = make_shared (address, port); } m_socket->connect(address, port); - m_tag = vmime::create (); - m_parser = vmime::create (m_tag, m_socket, m_timeoutHandler); + m_tag = make_shared (); + m_parser = make_shared (m_tag, m_socket, m_timeoutHandler); setState(STATE_NON_AUTHENTICATED); @@ -145,7 +145,7 @@ void IMAPConnection::connect() // eg: C: // --- S: * OK mydomain.org IMAP4rev1 v12.256 server ready - utility::auto_ptr greet(m_parser->readGreeting()); + std::auto_ptr greet(m_parser->readGreeting()); bool needAuth = false; if (greet->resp_cond_bye()) @@ -223,7 +223,7 @@ void IMAPConnection::connect() void IMAPConnection::authenticate() { - getAuthenticator()->setService(m_store.acquire()); + getAuthenticator()->setService(m_store.lock()); #if VMIME_HAVE_SASL_SUPPORT // First, try SASL authentication @@ -262,7 +262,7 @@ void IMAPConnection::authenticate() send(true, "LOGIN " + IMAPUtils::quoteString(username) + " " + IMAPUtils::quoteString(password), true); - utility::auto_ptr resp(m_parser->readResponse()); + std::auto_ptr resp(m_parser->readResponse()); if (resp->isBad()) { @@ -277,7 +277,7 @@ void IMAPConnection::authenticate() } // Server capabilities may change when logged in - if (!processCapabilityResponseData(resp)) + if (!processCapabilityResponseData(resp.get())) invalidateCapabilities(); } @@ -286,7 +286,7 @@ void IMAPConnection::authenticate() void IMAPConnection::authenticateSASL() { - if (!getAuthenticator().dynamicCast ()) + if (!dynamicCast (getAuthenticator())) throw exceptions::authentication_error("No SASL authenticator available."); const std::vector capa = getCapabilities(); @@ -310,10 +310,10 @@ void IMAPConnection::authenticateSASL() if (saslMechs.empty()) throw exceptions::authentication_error("No SASL mechanism available."); - std::vector > mechList; + std::vector > mechList; - ref saslContext = - vmime::create (); + shared_ptr saslContext = + make_shared (); for (unsigned int i = 0 ; i < saslMechs.size() ; ++i) { @@ -332,14 +332,14 @@ void IMAPConnection::authenticateSASL() throw exceptions::authentication_error("No SASL mechanism available."); // Try to suggest a mechanism among all those supported - ref suggestedMech = + shared_ptr suggestedMech = saslContext->suggestMechanism(mechList); if (!suggestedMech) throw exceptions::authentication_error("Unable to suggest SASL mechanism."); // Allow application to choose which mechanisms to use - mechList = getAuthenticator().dynamicCast ()-> + mechList = dynamicCast (getAuthenticator())-> getAcceptableMechanisms(mechList, suggestedMech); if (mechList.empty()) @@ -348,9 +348,9 @@ void IMAPConnection::authenticateSASL() // Try each mechanism in the list in turn for (unsigned int i = 0 ; i < mechList.size() ; ++i) { - ref mech = mechList[i]; + shared_ptr mech = mechList[i]; - ref saslSession = + shared_ptr saslSession = saslContext->createSession("imap", getAuthenticator(), mech); saslSession->init(); @@ -359,7 +359,7 @@ void IMAPConnection::authenticateSASL() for (bool cont = true ; cont ; ) { - utility::auto_ptr resp(m_parser->readResponse()); + std::auto_ptr resp(m_parser->readResponse()); if (resp->response_done() && resp->response_done()->response_tagged() && @@ -466,7 +466,7 @@ void IMAPConnection::startTLS() { send(true, "STARTTLS", true); - utility::auto_ptr resp(m_parser->readResponse()); + std::auto_ptr resp(m_parser->readResponse()); if (resp->isBad() || resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) @@ -475,11 +475,11 @@ void IMAPConnection::startTLS() ("STARTTLS", resp->getErrorLog(), "bad response"); } - ref tlsSession = tls::TLSSession::create - (m_store.acquire()->getCertificateVerifier(), - m_store.acquire()->getSession()->getTLSProperties()); + shared_ptr tlsSession = tls::TLSSession::create + (m_store.lock()->getCertificateVerifier(), + m_store.lock()->getSession()->getTLSProperties()); - ref tlsSocket = + shared_ptr tlsSocket = tlsSession->getSocket(m_socket); tlsSocket->handshake(m_timeoutHandler); @@ -488,7 +488,7 @@ void IMAPConnection::startTLS() m_parser->setSocket(m_socket); m_secured = true; - m_cntInfos = vmime::create + m_cntInfos = make_shared (m_cntInfos->getHost(), m_cntInfos->getPort(), tlsSession, tlsSocket); // " Once TLS has been started, the client MUST discard cached @@ -551,12 +551,12 @@ void IMAPConnection::fetchCapabilities() { send(true, "CAPABILITY", true); - utility::auto_ptr resp(m_parser->readResponse()); + std::auto_ptr resp(m_parser->readResponse()); if (resp->response_done()->response_tagged()-> resp_cond_state()->status() == IMAPParser::resp_cond_state::OK) { - processCapabilityResponseData(resp); + processCapabilityResponseData(resp.get()); } } @@ -604,7 +604,7 @@ void IMAPConnection::processCapabilityResponseData(const IMAPParser::capability_ } -ref IMAPConnection::getAuthenticator() +shared_ptr IMAPConnection::getAuthenticator() { return m_auth; } @@ -623,7 +623,7 @@ bool IMAPConnection::isSecuredConnection() const } -ref IMAPConnection::getConnectionInfos() const +shared_ptr IMAPConnection::getConnectionInfos() const { return m_cntInfos; } @@ -645,15 +645,15 @@ void IMAPConnection::internalDisconnect() send(true, "LOGOUT", true); m_socket->disconnect(); - m_socket = NULL; + m_socket = null; } - m_timeoutHandler = NULL; + m_timeoutHandler = null; m_state = STATE_LOGOUT; m_secured = false; - m_cntInfos = NULL; + m_cntInfos = null; } @@ -661,7 +661,7 @@ void IMAPConnection::initHierarchySeparator() { send(true, "LIST \"\" \"\"", true); - vmime::utility::auto_ptr resp(m_parser->readResponse()); + std::auto_ptr resp(m_parser->readResponse()); if (resp->isBad() || resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) @@ -769,25 +769,25 @@ char IMAPConnection::hierarchySeparator() const } -ref IMAPConnection::getStore() const +shared_ptr IMAPConnection::getStore() const { - return m_store.acquire(); + return m_store.lock(); } -ref IMAPConnection::getStore() +shared_ptr IMAPConnection::getStore() { - return m_store.acquire(); + return m_store.lock(); } -ref IMAPConnection::getSession() +shared_ptr IMAPConnection::getSession() { - return m_store.acquire()->getSession(); + return m_store.lock()->getSession(); } -ref IMAPConnection::getSocket() const +shared_ptr IMAPConnection::getSocket() const { return m_socket; } diff --git a/src/net/imap/IMAPFolder.cpp b/src/net/imap/IMAPFolder.cpp index 3a3615e6..06d331df 100644 --- a/src/net/imap/IMAPFolder.cpp +++ b/src/net/imap/IMAPFolder.cpp @@ -39,7 +39,6 @@ #include "vmime/message.hpp" #include "vmime/exception.hpp" -#include "vmime/utility/smartPtr.hpp" #include "vmime/utility/outputStreamAdapter.hpp" @@ -52,20 +51,20 @@ namespace net { namespace imap { -IMAPFolder::IMAPFolder(const folder::path& path, ref store, const int type, const int flags) +IMAPFolder::IMAPFolder(const folder::path& path, shared_ptr store, const int type, const int flags) : m_store(store), m_connection(store->connection()), m_path(path), m_name(path.isEmpty() ? folder::path::component("") : path.getLastComponent()), m_mode(-1), m_open(false), m_type(type), m_flags(flags) { store->registerFolder(this); - m_status = vmime::create (); + m_status = make_shared (); } IMAPFolder::~IMAPFolder() { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (store) { @@ -76,7 +75,7 @@ IMAPFolder::~IMAPFolder() } else if (m_open) { - m_connection = NULL; + m_connection = null; onClose(); } } @@ -145,7 +144,7 @@ const folder::path IMAPFolder::getFullPath() const void IMAPFolder::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"); @@ -159,8 +158,8 @@ void IMAPFolder::open(const int mode, bool failIfModeIsNotAvailable) } // Open a connection for this folder - ref connection = - vmime::create (store, store->getAuthenticator()); + shared_ptr connection = + make_shared (store, store->getAuthenticator()); try { @@ -193,7 +192,7 @@ void IMAPFolder::open(const int mode, bool failIfModeIsNotAvailable) connection->send(true, oss.str(), true); // Read the response - utility::auto_ptr resp(connection->readResponse()); + std::auto_ptr resp(connection->readResponse()); if (resp->isBad() || resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) @@ -259,7 +258,7 @@ void IMAPFolder::open(const int mode, bool failIfModeIsNotAvailable) } } - processStatusUpdate(resp); + processStatusUpdate(resp.get()); // Check for access mode (read-only or read-write) const IMAPParser::resp_text_code* respTextCode = resp->response_done()-> @@ -292,7 +291,7 @@ void IMAPFolder::open(const int mode, bool failIfModeIsNotAvailable) void IMAPFolder::close(const bool expunge) { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); @@ -300,7 +299,7 @@ void IMAPFolder::close(const bool expunge) if (!isOpen()) throw exceptions::illegal_state("Folder not open"); - ref oldConnection = m_connection; + shared_ptr oldConnection = m_connection; // Emit the "CLOSE" command to expunge messages marked // as deleted (this is fastest than "EXPUNGE") @@ -316,12 +315,12 @@ void IMAPFolder::close(const bool expunge) oldConnection->disconnect(); // Now use default store connection - m_connection = m_store.acquire()->connection(); + m_connection = m_store.lock()->connection(); m_open = false; m_mode = -1; - m_status = vmime::create (); + m_status = make_shared (); onClose(); } @@ -341,7 +340,7 @@ void IMAPFolder::onClose() void IMAPFolder::create(const int type) { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); @@ -371,7 +370,7 @@ void IMAPFolder::create(const int type) m_connection->send(true, oss.str(), true); - utility::auto_ptr resp(m_connection->readResponse()); + std::auto_ptr resp(m_connection->readResponse()); if (resp->isBad() || resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) @@ -381,9 +380,9 @@ void IMAPFolder::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); @@ -392,7 +391,7 @@ void IMAPFolder::create(const int type) void IMAPFolder::destroy() { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); @@ -409,7 +408,7 @@ void IMAPFolder::destroy() m_connection->send(true, oss.str(), true); - utility::auto_ptr resp(m_connection->readResponse()); + std::auto_ptr resp(m_connection->readResponse()); if (resp->isBad() || resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) @@ -419,9 +418,9 @@ void IMAPFolder::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); @@ -430,7 +429,7 @@ void IMAPFolder::destroy() bool IMAPFolder::exists() { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!isOpen() && !store) throw exceptions::illegal_state("Store disconnected"); @@ -470,7 +469,7 @@ int IMAPFolder::testExistAndGetType() m_connection->send(true, oss.str(), true); - utility::auto_ptr resp(m_connection->readResponse()); + std::auto_ptr resp(m_connection->readResponse()); if (resp->isBad() || resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) @@ -517,7 +516,7 @@ bool IMAPFolder::isOpen() const } -ref IMAPFolder::getMessage(const int num) +shared_ptr IMAPFolder::getMessage(const int num) { if (!isOpen()) throw exceptions::illegal_state("Folder not open"); @@ -525,28 +524,28 @@ ref IMAPFolder::getMessage(const int num) if (num < 1 || num > m_status->getMessageCount()) throw exceptions::message_not_found(); - return vmime::create (thisRef().dynamicCast (), num); + return make_shared (dynamicCast (shared_from_this()), num); } -std::vector > IMAPFolder::getMessages(const messageSet& msgs) +std::vector > IMAPFolder::getMessages(const messageSet& msgs) { if (!isOpen()) throw exceptions::illegal_state("Folder not open"); if (msgs.isEmpty()) - return std::vector >(); + return std::vector >(); - std::vector > messages; + std::vector > messages; if (msgs.isNumberSet()) { const std::vector numbers = IMAPUtils::messageSetToNumberList(msgs); - ref thisFolder = thisRef().dynamicCast (); + shared_ptr thisFolder = dynamicCast (shared_from_this()); for (std::vector ::const_iterator it = numbers.begin() ; it != numbers.end() ; ++it) - messages.push_back(vmime::create (thisFolder, *it)); + messages.push_back(make_shared (thisFolder, *it)); } else if (msgs.isUIDSet()) { @@ -566,7 +565,7 @@ std::vector > IMAPFolder::getMessages(const messageSet& msgs) m_connection->send(true, cmd.str(), true); // Get the response - utility::auto_ptr resp(m_connection->readResponse()); + std::auto_ptr resp(m_connection->readResponse()); if (resp->isBad() || resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) @@ -613,8 +612,8 @@ std::vector > IMAPFolder::getMessages(const messageSet& msgs) if (!msgUID.empty()) { - ref thisFolder = thisRef().dynamicCast (); - messages.push_back(vmime::create (thisFolder, msgNum, msgUID)); + shared_ptr thisFolder = dynamicCast (shared_from_this()); + messages.push_back(make_shared (thisFolder, msgNum, msgUID)); } } } @@ -650,20 +649,20 @@ vmime_uint64 IMAPFolder::getHighestModSequence() const } -ref IMAPFolder::getFolder(const folder::path::component& name) +shared_ptr IMAPFolder::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 > IMAPFolder::getFolders(const bool recursive) +std::vector > IMAPFolder::getFolders(const bool recursive) { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!isOpen() && !store) throw exceptions::illegal_state("Store disconnected"); @@ -699,7 +698,7 @@ std::vector > IMAPFolder::getFolders(const bool recursive) m_connection->send(true, oss.str(), true); - utility::auto_ptr resp(m_connection->readResponse()); + std::auto_ptr resp(m_connection->readResponse()); if (resp->isBad() || resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) @@ -711,7 +710,7 @@ std::vector > IMAPFolder::getFolders(const bool recursive) resp->continue_req_or_response_data(); - std::vector > v; + std::vector > v; for (std::vector ::const_iterator it = respDataList.begin() ; it != respDataList.end() ; ++it) @@ -741,7 +740,7 @@ std::vector > IMAPFolder::getFolders(const bool recursive) const class IMAPParser::mailbox_flag_list* mailbox_flag_list = mailboxData->mailbox_list()->mailbox_flag_list(); - v.push_back(vmime::create (path, store, + v.push_back(make_shared (path, store, IMAPUtils::folderTypeFromFlags(mailbox_flag_list), IMAPUtils::folderFlagsFromFlags(mailbox_flag_list))); } @@ -751,10 +750,10 @@ std::vector > IMAPFolder::getFolders(const bool recursive) } -void IMAPFolder::fetchMessages(std::vector >& msg, const fetchAttributes& options, +void IMAPFolder::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"); @@ -765,12 +764,12 @@ void IMAPFolder::fetchMessages(std::vector >& msg, const fetchAtt std::vector list; list.reserve(msg.size()); - std::map > numberToMsg; + std::map > numberToMsg; - for (std::vector >::iterator it = msg.begin() ; it != msg.end() ; ++it) + for (std::vector >::iterator it = msg.begin() ; it != msg.end() ; ++it) { list.push_back((*it)->getNumber()); - numberToMsg[(*it)->getNumber()] = (*it).dynamicCast (); + numberToMsg[(*it)->getNumber()] = dynamicCast (*it); } // Send the request @@ -780,7 +779,7 @@ void IMAPFolder::fetchMessages(std::vector >& msg, const fetchAtt m_connection->send(true, command, true); // Get the response - utility::auto_ptr resp(m_connection->readResponse()); + std::auto_ptr resp(m_connection->readResponse()); if (resp->isBad() || resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) @@ -819,7 +818,7 @@ void IMAPFolder::fetchMessages(std::vector >& msg, const fetchAtt // Process fetch response for this message const int num = static_cast (messageData->number()); - std::map >::iterator msg = numberToMsg.find(num); + std::map >::iterator msg = numberToMsg.find(num); if (msg != numberToMsg.end()) { @@ -841,13 +840,13 @@ void IMAPFolder::fetchMessages(std::vector >& msg, const fetchAtt if (progress) progress->stop(total); - processStatusUpdate(resp); + processStatusUpdate(resp.get()); } -void IMAPFolder::fetchMessage(ref msg, const fetchAttributes& options) +void IMAPFolder::fetchMessage(shared_ptr msg, const fetchAttributes& options) { - std::vector > msgs; + std::vector > msgs; msgs.push_back(msg); fetchMessages(msgs, options, /* progress */ NULL); @@ -863,24 +862,24 @@ int IMAPFolder::getFetchCapabilities() const } -ref IMAPFolder::getParent() +shared_ptr IMAPFolder::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 IMAPFolder::getStore() const +shared_ptr IMAPFolder::getStore() const { - return m_store.acquire(); + return m_store.lock(); } -ref IMAPFolder::getStore() +shared_ptr IMAPFolder::getStore() { - return m_store.acquire(); + return m_store.lock(); } @@ -902,13 +901,13 @@ void IMAPFolder::unregisterMessage(IMAPMessage* msg) void IMAPFolder::onStoreDisconnected() { - m_store = NULL; + m_store.reset(); } void IMAPFolder::deleteMessages(const messageSet& msgs) { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (msgs.isEmpty()) throw exceptions::invalid_argument(); @@ -935,7 +934,7 @@ void IMAPFolder::deleteMessages(const messageSet& msgs) m_connection->send(true, command.str(), true); // Get the response - utility::auto_ptr resp(m_connection->readResponse()); + std::auto_ptr resp(m_connection->readResponse()); if (resp->isBad() || resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) @@ -944,7 +943,7 @@ void IMAPFolder::deleteMessages(const messageSet& msgs) resp->getErrorLog(), "bad response"); } - processStatusUpdate(resp); + processStatusUpdate(resp.get()); } @@ -977,7 +976,7 @@ void IMAPFolder::setMessageFlags(const messageSet& msgs, const int flags, const m_connection->send(true, command.str(), true); // Get the response - utility::auto_ptr resp(m_connection->readResponse()); + std::auto_ptr resp(m_connection->readResponse()); if (resp->isBad() || resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) @@ -986,12 +985,12 @@ void IMAPFolder::setMessageFlags(const messageSet& msgs, const int flags, const resp->getErrorLog(), "bad response"); } - processStatusUpdate(resp); + processStatusUpdate(resp.get()); } } -void IMAPFolder::addMessage(ref msg, const int flags, +void IMAPFolder::addMessage(shared_ptr msg, const int flags, vmime::datetime* date, utility::progressListener* progress) { std::ostringstream oss; @@ -1009,7 +1008,7 @@ void IMAPFolder::addMessage(ref msg, const int flags, void IMAPFolder::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"); @@ -1045,7 +1044,7 @@ void IMAPFolder::addMessage(utility::inputStream& is, const int size, const int m_connection->send(true, command.str(), true); // Get the response - utility::auto_ptr resp(m_connection->readResponse()); + std::auto_ptr resp(m_connection->readResponse()); bool ok = false; const std::vector & respList @@ -1097,7 +1096,7 @@ void IMAPFolder::addMessage(utility::inputStream& is, const int size, const int progress->stop(total); // Get the response - utility::auto_ptr finalResp(m_connection->readResponse()); + std::auto_ptr finalResp(m_connection->readResponse()); if (finalResp->isBad() || finalResp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) @@ -1106,13 +1105,13 @@ void IMAPFolder::addMessage(utility::inputStream& is, const int size, const int resp->getErrorLog(), "bad response"); } - processStatusUpdate(resp); + processStatusUpdate(resp.get()); } void IMAPFolder::expunge() { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); @@ -1125,7 +1124,7 @@ void IMAPFolder::expunge() m_connection->send(true, "EXPUNGE", true); // Get the response - utility::auto_ptr resp(m_connection->readResponse()); + std::auto_ptr resp(m_connection->readResponse()); if (resp->isBad() || resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) @@ -1134,13 +1133,13 @@ void IMAPFolder::expunge() resp->getErrorLog(), "bad response"); } - processStatusUpdate(resp); + processStatusUpdate(resp.get()); } void IMAPFolder::rename(const folder::path& newPath) { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); @@ -1165,7 +1164,7 @@ void IMAPFolder::rename(const folder::path& newPath) m_connection->send(true, command.str(), true); // Get the response - utility::auto_ptr resp(m_connection->readResponse()); + std::auto_ptr resp(m_connection->readResponse()); if (resp->isBad() || resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) @@ -1180,9 +1179,9 @@ void IMAPFolder::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); @@ -1197,22 +1196,22 @@ void IMAPFolder::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); } } - processStatusUpdate(resp); + processStatusUpdate(resp.get()); } void IMAPFolder::copyMessages(const folder::path& dest, const messageSet& set) { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); @@ -1231,7 +1230,7 @@ void IMAPFolder::copyMessages(const folder::path& dest, const messageSet& set) m_connection->send(true, command.str(), true); // Get the response - utility::auto_ptr resp(m_connection->readResponse()); + std::auto_ptr resp(m_connection->readResponse()); if (resp->isBad() || resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) @@ -1240,7 +1239,7 @@ void IMAPFolder::copyMessages(const folder::path& dest, const messageSet& set) resp->getErrorLog(), "bad response"); } - processStatusUpdate(resp); + processStatusUpdate(resp.get()); } @@ -1249,16 +1248,16 @@ void IMAPFolder::status(int& count, int& unseen) count = 0; unseen = 0; - ref status = getStatus(); + shared_ptr status = getStatus(); count = status->getMessageCount(); unseen = status->getUnseenCount(); } -ref IMAPFolder::getStatus() +shared_ptr IMAPFolder::getStatus() { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); @@ -1283,7 +1282,7 @@ ref IMAPFolder::getStatus() m_connection->send(true, command.str(), true); // Get the response - utility::auto_ptr resp(m_connection->readResponse()); + std::auto_ptr resp(m_connection->readResponse()); if (resp->isBad() || resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) @@ -1305,7 +1304,7 @@ ref IMAPFolder::getStatus() if (responseData->mailbox_data() && responseData->mailbox_data()->type() == IMAPParser::mailbox_data::STATUS) { - ref status = vmime::create (); + shared_ptr status = make_shared (); status->updateFromResponse(responseData->mailbox_data()); m_status->updateFromResponse(responseData->mailbox_data()); @@ -1322,14 +1321,14 @@ ref IMAPFolder::getStatus() void IMAPFolder::noop() { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); m_connection->send(true, "NOOP", true); - utility::auto_ptr resp(m_connection->readResponse()); + std::auto_ptr resp(m_connection->readResponse()); if (resp->isBad() || resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) @@ -1337,7 +1336,7 @@ void IMAPFolder::noop() throw exceptions::command_error("NOOP", resp->getErrorLog()); } - processStatusUpdate(resp); + processStatusUpdate(resp.get()); } @@ -1354,7 +1353,7 @@ std::vector IMAPFolder::getMessageNumbersStartingOnUID(const message::uid& m_connection->send(true, command.str(), true); // Get the response - utility::auto_ptr resp(m_connection->readResponse()); + std::auto_ptr resp(m_connection->readResponse()); if (resp->isBad() || resp->response_done()->response_tagged()->resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) @@ -1393,7 +1392,7 @@ std::vector IMAPFolder::getMessageNumbersStartingOnUID(const message::uid& } } - processStatusUpdate(resp); + processStatusUpdate(resp.get()); return v; } @@ -1401,9 +1400,9 @@ std::vector IMAPFolder::getMessageNumbersStartingOnUID(const message::uid& void IMAPFolder::processStatusUpdate(const IMAPParser::response* resp) { - std::vector > events; + std::vector > events; - ref oldStatus = m_status->clone().dynamicCast (); + shared_ptr oldStatus = vmime::clone(m_status); int expungedMessageCount = 0; // Process tagged response @@ -1450,8 +1449,8 @@ void IMAPFolder::processStatusUpdate(const IMAPParser::response* resp) (*mit)->processFetchResponse(/* options */ 0, msgData); } - events.push_back(vmime::create - (thisRef().dynamicCast (), + events.push_back(make_shared + (dynamicCast (shared_from_this()), events::messageChangedEvent::TYPE_FLAGS, std::vector (1, msgNumber))); } @@ -1467,8 +1466,8 @@ void IMAPFolder::processStatusUpdate(const IMAPParser::response* resp) (*jt)->renumber((*jt)->getNumber() - 1); } - events.push_back(vmime::create - (thisRef().dynamicCast (), + events.push_back(make_shared + (dynamicCast (shared_from_this()), events::messageCountEvent::TYPE_REMOVED, std::vector (1, msgNumber))); @@ -1488,14 +1487,14 @@ void IMAPFolder::processStatusUpdate(const IMAPParser::response* resp) newMessageNumbers.push_back(msgNumber); } - events.push_back(vmime::create - (thisRef().dynamicCast (), + events.push_back(make_shared + (dynamicCast (shared_from_this()), events::messageCountEvent::TYPE_ADDED, newMessageNumbers)); } // Dispatch notifications - for (std::vector >::iterator evit = + for (std::vector >::iterator evit = events.begin() ; evit != events.end() ; ++evit) { notifyEvent(*evit); diff --git a/src/net/imap/IMAPFolderStatus.cpp b/src/net/imap/IMAPFolderStatus.cpp index c231cb38..25c88b02 100644 --- a/src/net/imap/IMAPFolderStatus.cpp +++ b/src/net/imap/IMAPFolderStatus.cpp @@ -94,9 +94,9 @@ vmime_uint64 IMAPFolderStatus::getHighestModSeq() const } -ref IMAPFolderStatus::clone() const +shared_ptr IMAPFolderStatus::clone() const { - return vmime::create (*this); + return make_shared (*this); } diff --git a/src/net/imap/IMAPMessage.cpp b/src/net/imap/IMAPMessage.cpp index d512e752..ae51bfe8 100644 --- a/src/net/imap/IMAPMessage.cpp +++ b/src/net/imap/IMAPMessage.cpp @@ -97,17 +97,17 @@ private: // -IMAPMessage::IMAPMessage(ref folder, const int num) +IMAPMessage::IMAPMessage(shared_ptr folder, const int num) : m_folder(folder), m_num(num), m_size(-1), m_flags(FLAG_UNDEFINED), - m_expunged(false), m_modseq(0), m_structure(NULL) + m_expunged(false), m_modseq(0), m_structure(null) { folder->registerMessage(this); } -IMAPMessage::IMAPMessage(ref folder, const int num, const uid& uid) +IMAPMessage::IMAPMessage(shared_ptr folder, const int num, const uid& uid) : m_folder(folder), m_num(num), m_size(-1), m_flags(FLAG_UNDEFINED), - m_expunged(false), m_uid(uid), m_modseq(0), m_structure(NULL) + m_expunged(false), m_uid(uid), m_modseq(0), m_structure(null) { folder->registerMessage(this); } @@ -115,7 +115,7 @@ IMAPMessage::IMAPMessage(ref folder, const int num, const uid& uid) IMAPMessage::~IMAPMessage() { - ref folder = m_folder.acquire(); + shared_ptr folder = m_folder.lock(); if (folder) folder->unregisterMessage(this); @@ -124,7 +124,7 @@ IMAPMessage::~IMAPMessage() void IMAPMessage::onFolderClosed() { - m_folder = NULL; + m_folder.reset(); } @@ -170,7 +170,7 @@ int IMAPMessage::getFlags() const } -ref IMAPMessage::getStructure() const +shared_ptr IMAPMessage::getStructure() const { if (m_structure == NULL) throw exceptions::unfetched_object(); @@ -179,7 +179,7 @@ ref IMAPMessage::getStructure() const } -ref IMAPMessage::getStructure() +shared_ptr IMAPMessage::getStructure() { if (m_structure == NULL) throw exceptions::unfetched_object(); @@ -188,7 +188,7 @@ ref IMAPMessage::getStructure() } -ref IMAPMessage::getHeader() const +shared_ptr IMAPMessage::getHeader() const { if (m_header == NULL) throw exceptions::unfetched_object(); @@ -200,20 +200,20 @@ ref IMAPMessage::getHeader() const void IMAPMessage::extract(utility::outputStream& os, utility::progressListener* progress, const int start, const int length, const bool peek) const { - ref folder = m_folder.acquire(); + shared_ptr folder = m_folder.lock(); if (!folder) throw exceptions::folder_not_found(); - extractImpl(NULL, os, progress, start, length, EXTRACT_HEADER | EXTRACT_BODY | (peek ? EXTRACT_PEEK : 0)); + extractImpl(null, os, progress, start, length, EXTRACT_HEADER | EXTRACT_BODY | (peek ? EXTRACT_PEEK : 0)); } void IMAPMessage::extractPart - (ref p, utility::outputStream& os, utility::progressListener* progress, + (shared_ptr p, utility::outputStream& os, utility::progressListener* progress, const int start, const int length, const bool peek) const { - ref folder = m_folder.acquire(); + shared_ptr folder = m_folder.lock(); if (!folder) throw exceptions::folder_not_found(); @@ -222,9 +222,9 @@ void IMAPMessage::extractPart } -void IMAPMessage::fetchPartHeader(ref p) +void IMAPMessage::fetchPartHeader(shared_ptr p) { - ref folder = m_folder.acquire(); + shared_ptr folder = m_folder.lock(); if (!folder) throw exceptions::folder_not_found(); @@ -234,15 +234,15 @@ void IMAPMessage::fetchPartHeader(ref p) extractImpl(p, ossAdapter, NULL, 0, -1, EXTRACT_HEADER | EXTRACT_PEEK); - p.dynamicCast ()->getOrCreateHeader().parse(oss.str()); + dynamicCast (p)->getOrCreateHeader().parse(oss.str()); } -void IMAPMessage::fetchPartHeaderForStructure(ref str) +void IMAPMessage::fetchPartHeaderForStructure(shared_ptr str) { for (size_t i = 0, n = str->getPartCount() ; i < n ; ++i) { - ref part = str->getPartAt(i); + shared_ptr part = str->getPartAt(i); // Fetch header of current part fetchPartHeader(part); @@ -253,11 +253,11 @@ void IMAPMessage::fetchPartHeaderForStructure(ref str) } -void IMAPMessage::extractImpl(ref p, utility::outputStream& os, +void IMAPMessage::extractImpl(shared_ptr p, utility::outputStream& os, utility::progressListener* progress, const int start, const int length, const int extractFlags) const { - ref folder = m_folder.acquire(); + shared_ptr folder = m_folder.lock(); IMAPMessage_literalHandler literalHandler(os, progress); @@ -267,7 +267,7 @@ void IMAPMessage::extractImpl(ref p, utility::outputStream& if (p != NULL) { - ref currentPart = p.dynamicCast (); + shared_ptr currentPart = dynamicCast (p); std::vector numbers; numbers.push_back(currentPart->getNumber()); @@ -344,11 +344,11 @@ void IMAPMessage::extractImpl(ref p, utility::outputStream& command << "<" << start << "." << length << ">"; // Send the request - folder.constCast ()->m_connection->send(true, command.str(), true); + constCast (folder)->m_connection->send(true, command.str(), true); // Get the response - utility::auto_ptr resp - (folder.constCast ()->m_connection->readResponse(&literalHandler)); + std::auto_ptr resp + (constCast (folder)->m_connection->readResponse(&literalHandler)); if (resp->isBad() || resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) @@ -368,7 +368,7 @@ void IMAPMessage::extractImpl(ref p, utility::outputStream& int IMAPMessage::processFetchResponse (const fetchAttributes& options, const IMAPParser::message_data* msgData) { - ref folder = m_folder.acquire(); + shared_ptr folder = m_folder.lock(); // Get message attributes const std::vector atts = msgData->msg_att()->items(); @@ -406,7 +406,7 @@ int IMAPMessage::processFetchResponse if (!options.has(fetchAttributes::FULL_HEADER)) { const IMAPParser::envelope* env = (*it)->envelope(); - ref hdr = getOrCreateHeader(); + shared_ptr hdr = getOrCreateHeader(); // Date hdr->Date()->setValue(env->env_date()->value()); @@ -463,7 +463,7 @@ int IMAPMessage::processFetchResponse } case IMAPParser::msg_att_item::BODY_STRUCTURE: { - m_structure = vmime::create ((*it)->body()); + m_structure = make_shared ((*it)->body()); break; } case IMAPParser::msg_att_item::RFC822_HEADER: @@ -488,12 +488,12 @@ int IMAPMessage::processFetchResponse tempHeader.parse((*it)->nstring()->value()); vmime::header& hdr = *getOrCreateHeader(); - std::vector > fields = tempHeader.getFieldList(); + std::vector > fields = tempHeader.getFieldList(); - for (std::vector >::const_iterator jt = fields.begin() ; + for (std::vector >::const_iterator jt = fields.begin() ; jt != fields.end() ; ++jt) { - hdr.appendField((*jt)->clone().dynamicCast ()); + hdr.appendField(vmime::clone(*jt)); } } } @@ -515,18 +515,18 @@ int IMAPMessage::processFetchResponse } -ref
IMAPMessage::getOrCreateHeader() +shared_ptr
IMAPMessage::getOrCreateHeader() { if (m_header != NULL) return (m_header); else - return (m_header = vmime::create
()); + return (m_header = make_shared
()); } void IMAPMessage::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(); @@ -539,20 +539,20 @@ void IMAPMessage::setFlags(const int flags, const int mode) void IMAPMessage::constructParsedMessage - (ref parentPart, ref str, int level) + (shared_ptr parentPart, shared_ptr str, int level) { if (level == 0) { - ref part = str->getPartAt(0); + shared_ptr part = str->getPartAt(0); // Copy header - ref hdr = part->getHeader(); + shared_ptr hdr = part->getHeader(); parentPart->getHeader()->copyFrom(*hdr); // Initialize body parentPart->getBody()->setContents - (vmime::create - (thisRef().dynamicCast (), + (make_shared + (dynamicCast (shared_from_this()), part, parentPart->getBody()->getEncoding())); constructParsedMessage(parentPart, part->getStructure(), 1); @@ -561,18 +561,18 @@ void IMAPMessage::constructParsedMessage { for (size_t i = 0, n = str->getPartCount() ; i < n ; ++i) { - ref part = str->getPartAt(i); + shared_ptr part = str->getPartAt(i); - ref childPart = vmime::create (); + shared_ptr childPart = make_shared (); // Copy header - ref hdr = part->getHeader(); + shared_ptr hdr = part->getHeader(); childPart->getHeader()->copyFrom(*hdr); // Initialize body childPart->getBody()->setContents - (vmime::create - (thisRef().dynamicCast (), + (make_shared + (dynamicCast (shared_from_this()), part, childPart->getBody()->getEncoding())); // Add child part @@ -585,10 +585,10 @@ void IMAPMessage::constructParsedMessage } -ref IMAPMessage::getParsedMessage() +shared_ptr IMAPMessage::getParsedMessage() { // Fetch structure - ref structure = NULL; + shared_ptr structure; try { @@ -596,10 +596,10 @@ ref IMAPMessage::getParsedMessage() } catch (exceptions::unfetched_object&) { - std::vector > msgs; - msgs.push_back(thisRef().dynamicCast ()); + std::vector > msgs; + msgs.push_back(dynamicCast (shared_from_this())); - m_folder.acquire()->fetchMessages + m_folder.lock()->fetchMessages (msgs, fetchAttributes(fetchAttributes::STRUCTURE), /* progress */ NULL); structure = getStructure(); @@ -609,7 +609,7 @@ ref IMAPMessage::getParsedMessage() fetchPartHeaderForStructure(structure); // Construct message from structure - ref msg = vmime::create (); + shared_ptr msg = make_shared (); constructParsedMessage(msg, structure); diff --git a/src/net/imap/IMAPMessagePart.cpp b/src/net/imap/IMAPMessagePart.cpp index 48e063e8..153470cf 100644 --- a/src/net/imap/IMAPMessagePart.cpp +++ b/src/net/imap/IMAPMessagePart.cpp @@ -36,16 +36,16 @@ namespace net { namespace imap { -IMAPMessagePart::IMAPMessagePart(ref parent, const int number, const IMAPParser::body_type_mpart* mpart) - : m_parent(parent), m_header(NULL), m_number(number), m_size(0) +IMAPMessagePart::IMAPMessagePart(shared_ptr parent, const int number, const IMAPParser::body_type_mpart* mpart) + : m_parent(parent), m_header(null), m_number(number), m_size(0) { m_mediaType = vmime::mediaType ("multipart", mpart->media_subtype()->value()); } -IMAPMessagePart::IMAPMessagePart(ref parent, const int number, const IMAPParser::body_type_1part* part) - : m_parent(parent), m_header(NULL), m_number(number), m_size(0) +IMAPMessagePart::IMAPMessagePart(shared_ptr parent, const int number, const IMAPParser::body_type_1part* part) + : m_parent(parent), m_header(null), m_number(number), m_size(0) { if (part->body_type_text()) { @@ -70,11 +70,11 @@ IMAPMessagePart::IMAPMessagePart(ref parent, const int number, m_size = part->body_type_basic()->body_fields()->body_fld_octets()->value(); } - m_structure = NULL; + m_structure = null; } -ref IMAPMessagePart::getStructure() const +shared_ptr IMAPMessagePart::getStructure() const { if (m_structure != NULL) return m_structure; @@ -83,7 +83,7 @@ ref IMAPMessagePart::getStructure() const } -ref IMAPMessagePart::getStructure() +shared_ptr IMAPMessagePart::getStructure() { if (m_structure != NULL) return m_structure; @@ -92,9 +92,9 @@ ref IMAPMessagePart::getStructure() } -ref IMAPMessagePart::getParent() const +shared_ptr IMAPMessagePart::getParent() const { - return m_parent.acquire(); + return m_parent.lock(); } @@ -116,7 +116,7 @@ int IMAPMessagePart::getNumber() const } -ref IMAPMessagePart::getHeader() const +shared_ptr IMAPMessagePart::getHeader() const { if (m_header == NULL) throw exceptions::unfetched_object(); @@ -126,19 +126,19 @@ ref IMAPMessagePart::getHeader() const // static -ref IMAPMessagePart::create - (ref parent, const int number, const IMAPParser::body* body) +shared_ptr IMAPMessagePart::create + (shared_ptr parent, const int number, const IMAPParser::body* body) { if (body->body_type_mpart()) { - ref part = vmime::create (parent, number, body->body_type_mpart()); - part->m_structure = vmime::create (part, body->body_type_mpart()->list()); + shared_ptr part = make_shared (parent, number, body->body_type_mpart()); + part->m_structure = make_shared (part, body->body_type_mpart()->list()); return part; } else { - return vmime::create (parent, number, body->body_type_1part()); + return make_shared (parent, number, body->body_type_1part()); } } @@ -148,7 +148,7 @@ header& IMAPMessagePart::getOrCreateHeader() if (m_header != NULL) return *m_header; else - return *(m_header = vmime::create
()); + return *(m_header = make_shared
()); } diff --git a/src/net/imap/IMAPMessagePartContentHandler.cpp b/src/net/imap/IMAPMessagePartContentHandler.cpp index 10c7a040..7112e3d2 100644 --- a/src/net/imap/IMAPMessagePartContentHandler.cpp +++ b/src/net/imap/IMAPMessagePartContentHandler.cpp @@ -43,17 +43,17 @@ namespace imap { IMAPMessagePartContentHandler::IMAPMessagePartContentHandler - (ref msg, ref part, const vmime::encoding& encoding) + (shared_ptr msg, shared_ptr part, const vmime::encoding& encoding) : m_message(msg), m_part(part), m_encoding(encoding) { } -ref IMAPMessagePartContentHandler::clone() const +shared_ptr IMAPMessagePartContentHandler::clone() const { - return create - (m_message.acquire().constCast (), - m_part.acquire().constCast (), + return make_shared + (constCast (m_message.lock()), + constCast (m_part.lock()), m_encoding); } @@ -61,8 +61,8 @@ ref IMAPMessagePartContentHandler::clone() const void IMAPMessagePartContentHandler::generate (utility::outputStream& os, const vmime::encoding& enc, const string::size_type maxLineLength) const { - ref msg = m_message.acquire().constCast (); - ref part = m_part.acquire().constCast (); + shared_ptr msg = constCast (m_message.lock()); + shared_ptr part = constCast (m_part.lock()); // Data is already encoded if (isEncoded()) @@ -85,14 +85,14 @@ void IMAPMessagePartContentHandler::generate std::ostringstream oss2; utility::outputStreamAdapter tmp2(oss2); - ref theDecoder = m_encoding.getEncoder(); + shared_ptr theDecoder = m_encoding.getEncoder(); theDecoder->decode(in, tmp2); // Reencode to output stream string str = oss2.str(); utility::inputStreamStringAdapter tempIn(str); - ref theEncoder = enc.getEncoder(); + shared_ptr theEncoder = enc.getEncoder(); theEncoder->getProperties()["maxlinelength"] = maxLineLength; theEncoder->getProperties()["text"] = (m_contentType.getType() == mediaTypes::TEXT); @@ -114,7 +114,7 @@ void IMAPMessagePartContentHandler::generate msg->extractPart(part, tmp, NULL); // Encode temporary buffer to output stream - ref theEncoder = enc.getEncoder(); + shared_ptr theEncoder = enc.getEncoder(); theEncoder->getProperties()["maxlinelength"] = maxLineLength; theEncoder->getProperties()["text"] = (m_contentType.getType() == mediaTypes::TEXT); @@ -128,8 +128,8 @@ void IMAPMessagePartContentHandler::generate void IMAPMessagePartContentHandler::extract (utility::outputStream& os, utility::progressListener* progress) const { - ref msg = m_message.acquire().constCast (); - ref part = m_part.acquire().constCast (); + shared_ptr msg = constCast (m_message.lock()); + shared_ptr part = constCast (m_part.lock()); // No decoding to perform if (!isEncoded()) @@ -149,7 +149,7 @@ void IMAPMessagePartContentHandler::extract utility::inputStreamStringAdapter is(oss.str()); utility::progressListenerSizeAdapter plsa(progress, getLength()); - ref theDecoder = m_encoding.getEncoder(); + shared_ptr theDecoder = m_encoding.getEncoder(); theDecoder->decode(is, os, &plsa); } } @@ -158,8 +158,8 @@ void IMAPMessagePartContentHandler::extract void IMAPMessagePartContentHandler::extractRaw (utility::outputStream& os, utility::progressListener* progress) const { - ref msg = m_message.acquire().constCast (); - ref part = m_part.acquire().constCast (); + shared_ptr msg = constCast (m_message.lock()); + shared_ptr part = constCast (m_part.lock()); msg->extractPart(part, os, progress); } @@ -167,7 +167,7 @@ void IMAPMessagePartContentHandler::extractRaw string::size_type IMAPMessagePartContentHandler::getLength() const { - return m_part.acquire()->getSize(); + return m_part.lock()->getSize(); } diff --git a/src/net/imap/IMAPMessageStructure.cpp b/src/net/imap/IMAPMessageStructure.cpp index 60f26c68..8dc333e9 100644 --- a/src/net/imap/IMAPMessageStructure.cpp +++ b/src/net/imap/IMAPMessageStructure.cpp @@ -43,11 +43,11 @@ IMAPMessageStructure::IMAPMessageStructure() IMAPMessageStructure::IMAPMessageStructure(const IMAPParser::body* body) { - m_parts.push_back(IMAPMessagePart::create(NULL, 0, body)); + m_parts.push_back(IMAPMessagePart::create(null, 0, body)); } -IMAPMessageStructure::IMAPMessageStructure(ref parent, const std::vector & list) +IMAPMessageStructure::IMAPMessageStructure(shared_ptr parent, const std::vector & list) { int number = 0; @@ -59,13 +59,13 @@ IMAPMessageStructure::IMAPMessageStructure(ref parent, const s } -ref IMAPMessageStructure::getPartAt(const size_t x) const +shared_ptr IMAPMessageStructure::getPartAt(const size_t x) const { return m_parts[x]; } -ref IMAPMessageStructure::getPartAt(const size_t x) +shared_ptr IMAPMessageStructure::getPartAt(const size_t x) { return m_parts[x]; } @@ -78,9 +78,9 @@ size_t IMAPMessageStructure::getPartCount() const // static -ref IMAPMessageStructure::emptyStructure() +shared_ptr IMAPMessageStructure::emptyStructure() { - static ref emptyStructure = vmime::create (); + static shared_ptr emptyStructure = make_shared (); return emptyStructure; } diff --git a/src/net/imap/IMAPSStore.cpp b/src/net/imap/IMAPSStore.cpp index b467d13a..c9e64f5b 100644 --- a/src/net/imap/IMAPSStore.cpp +++ b/src/net/imap/IMAPSStore.cpp @@ -35,7 +35,7 @@ namespace net { namespace imap { -IMAPSStore::IMAPSStore(ref sess, ref auth) +IMAPSStore::IMAPSStore(shared_ptr sess, shared_ptr auth) : IMAPStore(sess, auth, true) { } diff --git a/src/net/imap/IMAPStore.cpp b/src/net/imap/IMAPStore.cpp index eca58ea7..a1a8c9ca 100644 --- a/src/net/imap/IMAPStore.cpp +++ b/src/net/imap/IMAPStore.cpp @@ -43,8 +43,8 @@ namespace net { namespace imap { -IMAPStore::IMAPStore(ref sess, ref auth, const bool secured) - : store(sess, getInfosInstance(), auth), m_connection(NULL), m_isIMAPS(secured) +IMAPStore::IMAPStore(shared_ptr sess, shared_ptr auth, const bool secured) + : store(sess, getInfosInstance(), auth), m_connection(null), m_isIMAPS(secured) { } @@ -69,32 +69,35 @@ const string IMAPStore::getProtocolName() const } -ref IMAPStore::getRootFolder() +shared_ptr IMAPStore::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 IMAPStore::getDefaultFolder() +shared_ptr IMAPStore::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 IMAPStore::getFolder(const folder::path& path) +shared_ptr IMAPStore::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())); } @@ -109,8 +112,8 @@ void IMAPStore::connect() if (isConnected()) throw exceptions::already_connected(); - m_connection = vmime::create - (thisRef().dynamicCast (), getAuthenticator()); + m_connection = make_shared + (dynamicCast (shared_from_this()), getAuthenticator()); try { @@ -118,7 +121,7 @@ void IMAPStore::connect() } catch (std::exception&) { - m_connection = NULL; + m_connection = null; throw; } } @@ -145,16 +148,16 @@ bool IMAPStore::isSecuredConnection() const } -ref IMAPStore::getConnectionInfos() const +shared_ptr IMAPStore::getConnectionInfos() const { if (m_connection == NULL) - return NULL; + return null; return m_connection->getConnectionInfos(); } -ref IMAPStore::getConnection() +shared_ptr IMAPStore::getConnection() { return m_connection; } @@ -176,7 +179,7 @@ void IMAPStore::disconnect() m_connection->disconnect(); - m_connection = NULL; + m_connection = null; } @@ -187,7 +190,7 @@ void IMAPStore::noop() m_connection->send(true, "NOOP", true); - utility::auto_ptr resp(m_connection->readResponse()); + std::auto_ptr resp(m_connection->readResponse()); if (resp->isBad() || resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) @@ -205,7 +208,7 @@ void IMAPStore::noop() } -ref IMAPStore::connection() +shared_ptr IMAPStore::connection() { return (m_connection); } diff --git a/src/net/imap/IMAPUtils.cpp b/src/net/imap/IMAPUtils.cpp index caaf6575..bf310414 100644 --- a/src/net/imap/IMAPUtils.cpp +++ b/src/net/imap/IMAPUtils.cpp @@ -544,7 +544,7 @@ const string IMAPUtils::dateTime(const vmime::datetime& date) // static const string IMAPUtils::buildFetchRequest - (ref cnt, const messageSet& msgs, const fetchAttributes& options) + (shared_ptr cnt, const messageSet& msgs, const fetchAttributes& options) { // Example: // C: A654 FETCH 2:4 (FLAGS BODY[HEADER.FIELDS (DATE FROM)]) @@ -649,7 +649,7 @@ void IMAPUtils::convertAddressList string email = addr.addr_mailbox()->value() + "@" + addr.addr_host()->value(); - dest.appendMailbox(vmime::create (name, email)); + dest.appendMailbox(make_shared (name, email)); } } 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()) { diff --git a/src/net/message.cpp b/src/net/message.cpp index 09fe6321..6765e73c 100644 --- a/src/net/message.cpp +++ b/src/net/message.cpp @@ -36,13 +36,13 @@ namespace vmime { namespace net { -ref messagePart::getPartAt(const size_t pos) const +shared_ptr messagePart::getPartAt(const size_t pos) const { return getStructure()->getPartAt(pos); } -ref messagePart::getPartAt(const size_t pos) +shared_ptr messagePart::getPartAt(const size_t pos) { return getStructure()->getPartAt(pos); } diff --git a/src/net/messageSet.cpp b/src/net/messageSet.cpp index 04f1debb..71a8a788 100644 --- a/src/net/messageSet.cpp +++ b/src/net/messageSet.cpp @@ -314,8 +314,8 @@ messageSet messageSet::byUID(const std::vector & uids) else { set.m_ranges.push_back(new UIDMessageRange - (static_cast (&(std::ostringstream() << rangeStart))->str(), - static_cast (&(std::ostringstream() << previous))->str())); + (utility::stringUtils::toString(rangeStart), + utility::stringUtils::toString(previous))); previous = current; rangeStart = current; @@ -324,8 +324,8 @@ messageSet messageSet::byUID(const std::vector & uids) } set.m_ranges.push_back(new UIDMessageRange - (static_cast (&(std::ostringstream() << rangeStart))->str(), - static_cast (&(std::ostringstream() << previous))->str())); + (utility::stringUtils::toString(rangeStart), + utility::stringUtils::toString(previous))); return set; } diff --git a/src/net/pop3/POP3Command.cpp b/src/net/pop3/POP3Command.cpp index 6c178891..6fe301ce 100644 --- a/src/net/pop3/POP3Command.cpp +++ b/src/net/pop3/POP3Command.cpp @@ -49,21 +49,21 @@ POP3Command::POP3Command(const string& text) // static -ref POP3Command::CAPA() +shared_ptr POP3Command::CAPA() { return createCommand("CAPA"); } // static -ref POP3Command::NOOP() +shared_ptr POP3Command::NOOP() { return createCommand("NOOP"); } // static -ref POP3Command::AUTH(const string& mechName) +shared_ptr POP3Command::AUTH(const string& mechName) { std::ostringstream cmd; cmd.imbue(std::locale::classic()); @@ -74,14 +74,14 @@ ref POP3Command::AUTH(const string& mechName) // static -ref POP3Command::STLS() +shared_ptr POP3Command::STLS() { return createCommand("STLS"); } // static -ref POP3Command::APOP(const string& username, const string& digest) +shared_ptr POP3Command::APOP(const string& username, const string& digest) { std::ostringstream cmd; cmd.imbue(std::locale::classic()); @@ -92,7 +92,7 @@ ref POP3Command::APOP(const string& username, const string& digest // static -ref POP3Command::USER(const string& username) +shared_ptr POP3Command::USER(const string& username) { std::ostringstream cmd; cmd.imbue(std::locale::classic()); @@ -103,7 +103,7 @@ ref POP3Command::USER(const string& username) // static -ref POP3Command::PASS(const string& password) +shared_ptr POP3Command::PASS(const string& password) { std::ostringstream cmd; cmd.imbue(std::locale::classic()); @@ -114,21 +114,21 @@ ref POP3Command::PASS(const string& password) // static -ref POP3Command::STAT() +shared_ptr POP3Command::STAT() { return createCommand("STAT"); } // static -ref POP3Command::LIST() +shared_ptr POP3Command::LIST() { return createCommand("LIST"); } // static -ref POP3Command::LIST(const unsigned long msg) +shared_ptr POP3Command::LIST(const unsigned long msg) { std::ostringstream cmd; cmd.imbue(std::locale::classic()); @@ -139,14 +139,14 @@ ref POP3Command::LIST(const unsigned long msg) // static -ref POP3Command::UIDL() +shared_ptr POP3Command::UIDL() { return createCommand("UIDL"); } // static -ref POP3Command::UIDL(const unsigned long msg) +shared_ptr POP3Command::UIDL(const unsigned long msg) { std::ostringstream cmd; cmd.imbue(std::locale::classic()); @@ -157,7 +157,7 @@ ref POP3Command::UIDL(const unsigned long msg) // static -ref POP3Command::DELE(const unsigned long msg) +shared_ptr POP3Command::DELE(const unsigned long msg) { std::ostringstream cmd; cmd.imbue(std::locale::classic()); @@ -168,7 +168,7 @@ ref POP3Command::DELE(const unsigned long msg) // static -ref POP3Command::RETR(const unsigned long msg) +shared_ptr POP3Command::RETR(const unsigned long msg) { std::ostringstream cmd; cmd.imbue(std::locale::classic()); @@ -179,7 +179,7 @@ ref POP3Command::RETR(const unsigned long msg) // static -ref POP3Command::TOP(const unsigned long msg, const unsigned long lines) +shared_ptr POP3Command::TOP(const unsigned long msg, const unsigned long lines) { std::ostringstream cmd; cmd.imbue(std::locale::classic()); @@ -190,23 +190,23 @@ ref POP3Command::TOP(const unsigned long msg, const unsigned long // static -ref POP3Command::RSET() +shared_ptr POP3Command::RSET() { return createCommand("RSET"); } // static -ref POP3Command::QUIT() +shared_ptr POP3Command::QUIT() { return createCommand("QUIT"); } // static -ref POP3Command::createCommand(const string& text) +shared_ptr POP3Command::createCommand(const string& text) { - return vmime::create (text); + return shared_ptr (new POP3Command(text)); } @@ -216,7 +216,7 @@ const string POP3Command::getText() const } -void POP3Command::send(ref conn) +void POP3Command::send(shared_ptr conn) { conn->getSocket()->send(m_text + "\r\n"); } diff --git a/src/net/pop3/POP3Connection.cpp b/src/net/pop3/POP3Connection.cpp index dd0024e9..547ef5ef 100644 --- a/src/net/pop3/POP3Connection.cpp +++ b/src/net/pop3/POP3Connection.cpp @@ -50,11 +50,11 @@ // Helpers for service properties #define GET_PROPERTY(type, prop) \ - (m_store.acquire()->getInfos().getPropertyValue (getSession(), \ - dynamic_cast (m_store.acquire()->getInfos()).getProperties().prop)) + (m_store.lock()->getInfos().getPropertyValue (getSession(), \ + dynamic_cast (m_store.lock()->getInfos()).getProperties().prop)) #define HAS_PROPERTY(prop) \ - (m_store.acquire()->getInfos().hasProperty(getSession(), \ - dynamic_cast (m_store.acquire()->getInfos()).getProperties().prop)) + (m_store.lock()->getInfos().hasProperty(getSession(), \ + dynamic_cast (m_store.lock()->getInfos()).getProperties().prop)) namespace vmime { @@ -63,8 +63,8 @@ namespace pop3 { -POP3Connection::POP3Connection(ref store, ref auth) - : m_store(store), m_auth(auth), m_socket(NULL), m_timeoutHandler(NULL), +POP3Connection::POP3Connection(shared_ptr store, shared_ptr auth) + : m_store(store), m_auth(auth), m_socket(null), m_timeoutHandler(null), m_authenticated(false), m_secured(false), m_capabilitiesFetched(false) { } @@ -94,7 +94,7 @@ void POP3Connection::connect() const string address = GET_PROPERTY(string, PROPERTY_SERVER_ADDRESS); const port_t port = GET_PROPERTY(port_t, PROPERTY_SERVER_PORT); - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); // Create the time-out handler if (store->getTimeoutHandlerFactory()) @@ -106,22 +106,22 @@ void POP3Connection::connect() #if VMIME_HAVE_TLS_SUPPORT if (store->isPOP3S()) // dedicated port/POP3S { - ref tlsSession = tls::TLSSession::create + shared_ptr tlsSession = tls::TLSSession::create (store->getCertificateVerifier(), store->getSession()->getTLSProperties()); - ref tlsSocket = + shared_ptr tlsSocket = tlsSession->getSocket(m_socket); m_socket = tlsSocket; m_secured = true; - m_cntInfos = vmime::create (address, port, tlsSession, tlsSocket); + m_cntInfos = make_shared (address, port, tlsSession, tlsSocket); } else #endif // VMIME_HAVE_TLS_SUPPORT { - m_cntInfos = vmime::create (address, port); + m_cntInfos = make_shared (address, port); } m_socket->connect(address, port); @@ -131,8 +131,8 @@ void POP3Connection::connect() // eg: C: // --- S: +OK MailSite POP3 Server 5.3.4.0 Ready <36938848.1056800841.634@somewhere.com> - ref response = POP3Response::readResponse - (thisRef().dynamicCast ()); + shared_ptr response = POP3Response::readResponse + (dynamicCast (shared_from_this())); if (!response->isSuccess()) { @@ -195,8 +195,8 @@ void POP3Connection::internalDisconnect() { try { - POP3Command::QUIT()->send(thisRef().dynamicCast ()); - POP3Response::readResponse(thisRef().dynamicCast ()); + POP3Command::QUIT()->send(dynamicCast (shared_from_this())); + POP3Response::readResponse(dynamicCast (shared_from_this())); } catch (exception&) { @@ -206,21 +206,21 @@ void POP3Connection::internalDisconnect() m_socket->disconnect(); } - m_socket = NULL; + m_socket = null; } - m_timeoutHandler = NULL; + m_timeoutHandler = null; m_authenticated = false; m_secured = false; - m_cntInfos = NULL; + m_cntInfos = null; } void POP3Connection::authenticate(const messageId& randomMID) { - getAuthenticator()->setService(m_store.acquire()); + getAuthenticator()->setService(m_store.lock()); #if VMIME_HAVE_SASL_SUPPORT // First, try SASL authentication @@ -262,8 +262,8 @@ void POP3Connection::authenticate(const messageId& randomMID) const string username = getAuthenticator()->getUsername(); const string password = getAuthenticator()->getPassword(); - ref conn = thisRef().dynamicCast (); - ref response; + shared_ptr conn = dynamicCast (shared_from_this()); + shared_ptr response; if (GET_PROPERTY(bool, PROPERTY_OPTIONS_APOP)) { @@ -271,7 +271,7 @@ void POP3Connection::authenticate(const messageId& randomMID) randomMID.getRight().length() != 0) { // is the result of MD5 applied to "password" - ref md5 = + shared_ptr md5 = security::digest::messageDigestFactory::getInstance()->create("md5"); md5->update(randomMID.generate() + password); @@ -361,7 +361,7 @@ void POP3Connection::authenticate(const messageId& randomMID) void POP3Connection::authenticateSASL() { - if (!getAuthenticator().dynamicCast ()) + if (!dynamicCast (getAuthenticator())) throw exceptions::authentication_error("No SASL authenticator available."); std::vector capa = getCapabilities(); @@ -401,10 +401,10 @@ void POP3Connection::authenticateSASL() if (saslMechs.empty()) throw exceptions::authentication_error("No SASL mechanism available."); - std::vector > mechList; + std::vector > mechList; - ref saslContext = - vmime::create (); + shared_ptr saslContext = + make_shared (); for (unsigned int i = 0 ; i < saslMechs.size() ; ++i) { @@ -423,14 +423,14 @@ void POP3Connection::authenticateSASL() throw exceptions::authentication_error("No SASL mechanism available."); // Try to suggest a mechanism among all those supported - ref suggestedMech = + shared_ptr suggestedMech = saslContext->suggestMechanism(mechList); if (!suggestedMech) throw exceptions::authentication_error("Unable to suggest SASL mechanism."); // Allow application to choose which mechanisms to use - mechList = getAuthenticator().dynamicCast ()-> + mechList = dynamicCast (getAuthenticator())-> getAcceptableMechanisms(mechList, suggestedMech); if (mechList.empty()) @@ -439,19 +439,19 @@ void POP3Connection::authenticateSASL() // Try each mechanism in the list in turn for (unsigned int i = 0 ; i < mechList.size() ; ++i) { - ref mech = mechList[i]; + shared_ptr mech = mechList[i]; - ref saslSession = + shared_ptr saslSession = saslContext->createSession("pop3", getAuthenticator(), mech); saslSession->init(); - POP3Command::AUTH(mech->getName())->send(thisRef().dynamicCast ()); + POP3Command::AUTH(mech->getName())->send(dynamicCast (shared_from_this())); for (bool cont = true ; cont ; ) { - ref response = - POP3Response::readResponse(thisRef().dynamicCast ()); + shared_ptr response = + POP3Response::readResponse(dynamicCast (shared_from_this())); switch (response->getCode()) { @@ -537,19 +537,19 @@ void POP3Connection::startTLS() { try { - POP3Command::STLS()->send(thisRef().dynamicCast ()); + POP3Command::STLS()->send(dynamicCast (shared_from_this())); - ref response = - POP3Response::readResponse(thisRef().dynamicCast ()); + shared_ptr response = + POP3Response::readResponse(dynamicCast (shared_from_this())); if (!response->isSuccess()) throw exceptions::command_error("STLS", response->getFirstLine()); - ref tlsSession = tls::TLSSession::create - (m_store.acquire()->getCertificateVerifier(), - m_store.acquire()->getSession()->getTLSProperties()); + shared_ptr tlsSession = tls::TLSSession::create + (m_store.lock()->getCertificateVerifier(), + m_store.lock()->getSession()->getTLSProperties()); - ref tlsSocket = + shared_ptr tlsSocket = tlsSession->getSocket(m_socket); tlsSocket->handshake(m_timeoutHandler); @@ -557,7 +557,7 @@ void POP3Connection::startTLS() m_socket = tlsSocket; m_secured = true; - m_cntInfos = vmime::create + m_cntInfos = make_shared (m_cntInfos->getHost(), m_cntInfos->getPort(), tlsSession, tlsSocket); // " Once TLS has been started, the client MUST discard cached @@ -601,10 +601,10 @@ void POP3Connection::invalidateCapabilities() void POP3Connection::fetchCapabilities() { - POP3Command::CAPA()->send(thisRef().dynamicCast ()); + POP3Command::CAPA()->send(dynamicCast (shared_from_this())); - ref response = - POP3Response::readMultilineResponse(thisRef().dynamicCast ()); + shared_ptr response = + POP3Response::readMultilineResponse(dynamicCast (shared_from_this())); std::vector res; @@ -631,37 +631,37 @@ bool POP3Connection::isSecuredConnection() const } -ref POP3Connection::getConnectionInfos() const +shared_ptr POP3Connection::getConnectionInfos() const { return m_cntInfos; } -ref POP3Connection::getStore() +shared_ptr POP3Connection::getStore() { - return m_store.acquire(); + return m_store.lock(); } -ref POP3Connection::getSession() +shared_ptr POP3Connection::getSession() { - return m_store.acquire()->getSession(); + return m_store.lock()->getSession(); } -ref POP3Connection::getSocket() +shared_ptr POP3Connection::getSocket() { return m_socket; } -ref POP3Connection::getTimeoutHandler() +shared_ptr POP3Connection::getTimeoutHandler() { return m_timeoutHandler; } -ref POP3Connection::getAuthenticator() +shared_ptr POP3Connection::getAuthenticator() { return m_auth; } diff --git a/src/net/pop3/POP3Folder.cpp b/src/net/pop3/POP3Folder.cpp index ffff121e..66ace31c 100644 --- a/src/net/pop3/POP3Folder.cpp +++ b/src/net/pop3/POP3Folder.cpp @@ -45,7 +45,7 @@ namespace net { namespace pop3 { -POP3Folder::POP3Folder(const folder::path& path, ref store) +POP3Folder::POP3Folder(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) @@ -56,7 +56,7 @@ POP3Folder::POP3Folder(const folder::path& path, ref store) POP3Folder::~POP3Folder() { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (store) { @@ -115,7 +115,7 @@ const folder::path POP3Folder::getFullPath() const void POP3Folder::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"); @@ -134,7 +134,7 @@ void POP3Folder::open(const int mode, bool failIfModeIsNotAvailable) { POP3Command::STAT()->send(store->getConnection()); - ref response = POP3Response::readResponse(store->getConnection()); + shared_ptr response = POP3Response::readResponse(store->getConnection()); if (!response->isSuccess()) throw exceptions::command_error("STAT", response->getFirstLine()); @@ -156,7 +156,7 @@ void POP3Folder::open(const int mode, bool failIfModeIsNotAvailable) void POP3Folder::close(const bool expunge) { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); @@ -200,7 +200,7 @@ void POP3Folder::destroy() bool POP3Folder::exists() { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); @@ -215,9 +215,9 @@ bool POP3Folder::isOpen() const } -ref POP3Folder::getMessage(const int num) +shared_ptr POP3Folder::getMessage(const int num) { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); @@ -226,13 +226,13 @@ ref POP3Folder::getMessage(const int num) else 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 > POP3Folder::getMessages(const messageSet& msgs) +std::vector > POP3Folder::getMessages(const messageSet& msgs) { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); @@ -243,15 +243,15 @@ std::vector > POP3Folder::getMessages(const messageSet& msgs) { const std::vector numbers = POP3Utils::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; @@ -265,7 +265,7 @@ std::vector > POP3Folder::getMessages(const messageSet& msgs) int POP3Folder::getMessageCount() { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); @@ -276,42 +276,42 @@ int POP3Folder::getMessageCount() } -ref POP3Folder::getFolder(const folder::path::component& name) +shared_ptr POP3Folder::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 > POP3Folder::getFolders(const bool /* recursive */) +std::vector > POP3Folder::getFolders(const bool /* recursive */) { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); if (m_path.isEmpty()) { - std::vector > v; - v.push_back(vmime::create (folder::path::component("INBOX"), store)); + std::vector > v; + v.push_back(make_shared (folder::path::component("INBOX"), store)); return (v); } else { - std::vector > v; + std::vector > v; return (v); } } -void POP3Folder::fetchMessages(std::vector >& msg, const fetchAttributes& options, +void POP3Folder::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"); @@ -324,11 +324,11 @@ void POP3Folder::fetchMessages(std::vector >& msg, const fetchAtt if (progress) progress->start(total); - for (std::vector >::iterator it = msg.begin() ; + for (std::vector >::iterator it = msg.begin() ; it != msg.end() ; ++it) { - (*it).dynamicCast ()->fetch - (thisRef().dynamicCast (), options); + dynamicCast (*it)->fetch + (dynamicCast (shared_from_this()), options); if (progress) progress->progress(++current, total); @@ -340,7 +340,7 @@ void POP3Folder::fetchMessages(std::vector >& msg, const fetchAtt POP3Command::LIST()->send(store->getConnection()); // Get the response - ref response = + shared_ptr response = POP3Response::readMultilineResponse(store->getConnection()); if (response->isSuccess()) @@ -353,10 +353,10 @@ void POP3Folder::fetchMessages(std::vector >& msg, const fetchAtt std::map result; POP3Utils::parseMultiListOrUidlResponse(response, result); - for (std::vector >::iterator it = msg.begin() ; + for (std::vector >::iterator it = msg.begin() ; it != msg.end() ; ++it) { - ref m = (*it).dynamicCast (); + shared_ptr m = dynamicCast (*it); std::map ::const_iterator x = result.find(m->m_num); @@ -380,7 +380,7 @@ void POP3Folder::fetchMessages(std::vector >& msg, const fetchAtt POP3Command::UIDL()->send(store->getConnection()); // Get the response - ref response = + shared_ptr response = POP3Response::readMultilineResponse(store->getConnection()); if (response->isSuccess()) @@ -393,10 +393,10 @@ void POP3Folder::fetchMessages(std::vector >& msg, const fetchAtt std::map result; POP3Utils::parseMultiListOrUidlResponse(response, result); - for (std::vector >::iterator it = msg.begin() ; + for (std::vector >::iterator it = msg.begin() ; it != msg.end() ; ++it) { - ref m = (*it).dynamicCast (); + shared_ptr m = dynamicCast (*it); std::map ::const_iterator x = result.find(m->m_num); @@ -411,17 +411,17 @@ void POP3Folder::fetchMessages(std::vector >& msg, const fetchAtt } -void POP3Folder::fetchMessage(ref msg, const fetchAttributes& options) +void POP3Folder::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); if (options.has(fetchAttributes::SIZE)) { @@ -429,7 +429,7 @@ void POP3Folder::fetchMessage(ref msg, const fetchAttributes& options) POP3Command::LIST(msg->getNumber())->send(store->getConnection()); // Get the response - ref response = + shared_ptr response = POP3Response::readResponse(store->getConnection()); if (response->isSuccess()) @@ -451,7 +451,7 @@ void POP3Folder::fetchMessage(ref msg, const fetchAttributes& options) std::istringstream iss(string(it, responseText.end())); iss >> size; - msg.dynamicCast ()->m_size = size; + dynamicCast (msg)->m_size = size; } } } @@ -462,7 +462,7 @@ void POP3Folder::fetchMessage(ref msg, const fetchAttributes& options) POP3Command::UIDL(msg->getNumber())->send(store->getConnection()); // Get the response - ref response = + shared_ptr response = POP3Response::readResponse(store->getConnection()); if (response->isSuccess()) @@ -479,7 +479,7 @@ void POP3Folder::fetchMessage(ref msg, const fetchAttributes& options) if (it != responseText.end()) { - msg.dynamicCast ()->m_uid = + dynamicCast (msg)->m_uid = string(it, responseText.end()); } } @@ -495,24 +495,24 @@ int POP3Folder::getFetchCapabilities() const } -ref POP3Folder::getParent() +shared_ptr POP3Folder::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 POP3Folder::getStore() const +shared_ptr POP3Folder::getStore() const { - return m_store.acquire(); + return m_store.lock(); } -ref POP3Folder::getStore() +shared_ptr POP3Folder::getStore() { - return m_store.acquire(); + return m_store.lock(); } @@ -530,13 +530,13 @@ void POP3Folder::unregisterMessage(POP3Message* msg) void POP3Folder::onStoreDisconnected() { - m_store = NULL; + m_store.reset(); } void POP3Folder::deleteMessages(const messageSet& msgs) { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); const std::vector nums = POP3Utils::messageSetToNumberList(msgs); @@ -553,7 +553,7 @@ void POP3Folder::deleteMessages(const messageSet& msgs) { POP3Command::DELE(*it)->send(store->getConnection()); - ref response = + shared_ptr response = POP3Response::readResponse(store->getConnection()); if (!response->isSuccess()) @@ -579,9 +579,9 @@ void POP3Folder::deleteMessages(const messageSet& msgs) } // Notify message flags changed - ref event = - vmime::create - (thisRef().dynamicCast (), + shared_ptr event = + make_shared + (dynamicCast (shared_from_this()), events::messageChangedEvent::TYPE_FLAGS, list); notifyMessageChanged(event); @@ -601,7 +601,7 @@ void POP3Folder::rename(const folder::path& /* newPath */) } -void POP3Folder::addMessage(ref /* msg */, const int /* flags */, +void POP3Folder::addMessage(shared_ptr /* msg */, const int /* flags */, vmime::datetime* /* date */, utility::progressListener* /* progress */) { throw exceptions::operation_not_supported(); @@ -626,23 +626,23 @@ void POP3Folder::status(int& count, int& unseen) count = 0; unseen = 0; - ref status = getStatus(); + shared_ptr status = getStatus(); count = status->getMessageCount(); unseen = status->getUnseenCount(); } -ref POP3Folder::getStatus() +shared_ptr POP3Folder::getStatus() { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); POP3Command::STAT()->send(store->getConnection()); - ref response = + shared_ptr response = POP3Response::readResponse(store->getConnection()); if (!response->isSuccess()) @@ -654,7 +654,7 @@ ref POP3Folder::getStatus() std::istringstream iss(response->getText()); iss >> count; - ref status = vmime::create (); + shared_ptr status = make_shared (); status->setMessageCount(count); status->setUnseenCount(count); @@ -675,9 +675,9 @@ ref POP3Folder::getStatus() nums[j] = i; // Notify message count changed - ref event = - vmime::create - (thisRef().dynamicCast (), + shared_ptr event = + make_shared + (dynamicCast (shared_from_this()), events::messageCountEvent::TYPE_ADDED, nums); notifyMessageCount(event); @@ -690,9 +690,9 @@ ref POP3Folder::getStatus() { (*it)->m_messageCount = count; - 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); diff --git a/src/net/pop3/POP3FolderStatus.cpp b/src/net/pop3/POP3FolderStatus.cpp index 64c8d9d1..944379ac 100644 --- a/src/net/pop3/POP3FolderStatus.cpp +++ b/src/net/pop3/POP3FolderStatus.cpp @@ -74,9 +74,9 @@ void POP3FolderStatus::setUnseenCount(const unsigned int unseen) } -ref POP3FolderStatus::clone() const +shared_ptr POP3FolderStatus::clone() const { - return vmime::create (*this); + return make_shared (*this); } diff --git a/src/net/pop3/POP3Message.cpp b/src/net/pop3/POP3Message.cpp index bad25cb9..5f0fb725 100644 --- a/src/net/pop3/POP3Message.cpp +++ b/src/net/pop3/POP3Message.cpp @@ -44,7 +44,7 @@ namespace net { namespace pop3 { -POP3Message::POP3Message(ref folder, const int num) +POP3Message::POP3Message(shared_ptr folder, const int num) : m_folder(folder), m_num(num), m_size(-1), m_deleted(false) { folder->registerMessage(this); @@ -53,7 +53,7 @@ POP3Message::POP3Message(ref folder, const int num) POP3Message::~POP3Message() { - ref folder = m_folder.acquire(); + shared_ptr folder = m_folder.lock(); if (folder) folder->unregisterMessage(this); @@ -62,7 +62,7 @@ POP3Message::~POP3Message() void POP3Message::onFolderClosed() { - m_folder = NULL; + m_folder.reset(); } @@ -104,19 +104,19 @@ int POP3Message::getFlags() const } -ref POP3Message::getStructure() const +shared_ptr POP3Message::getStructure() const { throw exceptions::operation_not_supported(); } -ref POP3Message::getStructure() +shared_ptr POP3Message::getStructure() { throw exceptions::operation_not_supported(); } -ref POP3Message::getHeader() const +shared_ptr POP3Message::getHeader() const { if (m_header == NULL) throw exceptions::unfetched_object(); @@ -129,7 +129,7 @@ void POP3Message::extract(utility::outputStream& os, utility::progressListener* progress, const int start, const int length, const bool /* peek */) const { - ref folder = m_folder.acquire(); + shared_ptr folder = m_folder.lock(); if (!folder) throw exceptions::illegal_state("Folder closed"); @@ -140,7 +140,7 @@ void POP3Message::extract(utility::outputStream& os, throw exceptions::partial_fetch_not_supported(); // Emit the "RETR" command - ref store = folder.constCast ()->m_store.acquire(); + shared_ptr store = constCast (folder)->m_store.lock(); POP3Command::RETR(m_num)->send(store->getConnection()); @@ -157,7 +157,7 @@ void POP3Message::extract(utility::outputStream& os, void POP3Message::extractPart - (ref /* p */, utility::outputStream& /* os */, + (shared_ptr /* p */, utility::outputStream& /* os */, utility::progressListener* /* progress */, const int /* start */, const int /* length */, const bool /* peek */) const @@ -166,15 +166,15 @@ void POP3Message::extractPart } -void POP3Message::fetchPartHeader(ref /* p */) +void POP3Message::fetchPartHeader(shared_ptr /* p */) { throw exceptions::operation_not_supported(); } -void POP3Message::fetch(ref msgFolder, const fetchAttributes& options) +void POP3Message::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(); @@ -196,7 +196,7 @@ void POP3Message::fetch(ref msgFolder, const fetchAttributes& optio // fields in particular. // Emit the "TOP" command - ref store = folder->m_store.acquire(); + shared_ptr store = folder->m_store.lock(); POP3Command::TOP(m_num, 0)->send(store->getConnection()); @@ -208,7 +208,7 @@ void POP3Message::fetch(ref msgFolder, const fetchAttributes& optio POP3Response::readLargeResponse(store->getConnection(), bufferStream, /* progress */ NULL, /* predictedSize */ 0); - m_header = vmime::create
(); + m_header = make_shared
(); m_header->parse(buffer); } catch (exceptions::command_error& e) @@ -224,14 +224,14 @@ void POP3Message::setFlags(const int /* flags */, const int /* mode */) } -ref POP3Message::getParsedMessage() +shared_ptr POP3Message::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/pop3/POP3Response.cpp b/src/net/pop3/POP3Response.cpp index 975cd642..e24634c6 100644 --- a/src/net/pop3/POP3Response.cpp +++ b/src/net/pop3/POP3Response.cpp @@ -46,17 +46,17 @@ namespace net { namespace pop3 { -POP3Response::POP3Response(ref sok, ref toh) +POP3Response::POP3Response(shared_ptr sok, shared_ptr toh) : m_socket(sok), m_timeoutHandler(toh) { } // static -ref POP3Response::readResponse(ref conn) +shared_ptr POP3Response::readResponse(shared_ptr conn) { - ref resp = vmime::create - (conn->getSocket(), conn->getTimeoutHandler()); + shared_ptr resp = shared_ptr + (new POP3Response(conn->getSocket(), conn->getTimeoutHandler())); string buffer; resp->readResponseImpl(buffer, /* multiLine */ false); @@ -70,10 +70,10 @@ ref POP3Response::readResponse(ref conn) // static -ref POP3Response::readMultilineResponse(ref conn) +shared_ptr POP3Response::readMultilineResponse(shared_ptr conn) { - ref resp = vmime::create - (conn->getSocket(), conn->getTimeoutHandler()); + shared_ptr resp = shared_ptr + (new POP3Response(conn->getSocket(), conn->getTimeoutHandler())); string buffer; resp->readResponseImpl(buffer, /* multiLine */ true); @@ -96,12 +96,12 @@ ref POP3Response::readMultilineResponse(ref conn // static -ref POP3Response::readLargeResponse - (ref conn, utility::outputStream& os, +shared_ptr POP3Response::readLargeResponse + (shared_ptr conn, utility::outputStream& os, utility::progressListener* progress, const long predictedSize) { - ref resp = vmime::create - (conn->getSocket(), conn->getTimeoutHandler()); + shared_ptr resp = shared_ptr + (new POP3Response(conn->getSocket(), conn->getTimeoutHandler())); string firstLine; resp->readResponseImpl(firstLine, os, progress, predictedSize); diff --git a/src/net/pop3/POP3SStore.cpp b/src/net/pop3/POP3SStore.cpp index f7d17b38..f1c3da74 100644 --- a/src/net/pop3/POP3SStore.cpp +++ b/src/net/pop3/POP3SStore.cpp @@ -35,7 +35,7 @@ namespace net { namespace pop3 { -POP3SStore::POP3SStore(ref sess, ref auth) +POP3SStore::POP3SStore(shared_ptr sess, shared_ptr auth) : POP3Store(sess, auth, true) { } diff --git a/src/net/pop3/POP3Store.cpp b/src/net/pop3/POP3Store.cpp index 6ff404e2..e6e95b1b 100644 --- a/src/net/pop3/POP3Store.cpp +++ b/src/net/pop3/POP3Store.cpp @@ -42,7 +42,7 @@ namespace net { namespace pop3 { -POP3Store::POP3Store(ref sess, ref auth, const bool secured) +POP3Store::POP3Store(shared_ptr sess, shared_ptr auth, const bool secured) : store(sess, getInfosInstance(), auth), m_isPOP3S(secured) { } @@ -68,33 +68,34 @@ const string POP3Store::getProtocolName() const } -ref POP3Store::getDefaultFolder() +shared_ptr POP3Store::getDefaultFolder() { if (!isConnected()) throw exceptions::illegal_state("Not connected"); - return vmime::create (folder::path(folder::path::component("INBOX")), - thisRef().dynamicCast ()); + return make_shared + (folder::path(folder::path::component("INBOX")), + dynamicCast (shared_from_this())); } -ref POP3Store::getRootFolder() +shared_ptr POP3Store::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 POP3Store::getFolder(const folder::path& path) +shared_ptr POP3Store::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())); } @@ -109,8 +110,8 @@ void POP3Store::connect() if (isConnected()) throw exceptions::already_connected(); - m_connection = vmime::create - (thisRef().dynamicCast (), getAuthenticator()); + m_connection = make_shared + (dynamicCast (shared_from_this()), getAuthenticator()); try { @@ -118,7 +119,7 @@ void POP3Store::connect() } catch (std::exception&) { - m_connection = NULL; + m_connection = null; throw; } } @@ -145,16 +146,16 @@ bool POP3Store::isSecuredConnection() const } -ref POP3Store::getConnectionInfos() const +shared_ptr POP3Store::getConnectionInfos() const { if (m_connection == NULL) - return NULL; + return null; return m_connection->getConnectionInfos(); } -ref POP3Store::getConnection() +shared_ptr POP3Store::getConnection() { return m_connection; } @@ -175,7 +176,7 @@ void POP3Store::disconnect() m_connection->disconnect(); - m_connection = NULL; + m_connection = null; } @@ -186,7 +187,7 @@ void POP3Store::noop() POP3Command::NOOP()->send(m_connection); - ref response = POP3Response::readResponse(m_connection); + shared_ptr response = POP3Response::readResponse(m_connection); if (!response->isSuccess()) throw exceptions::command_error("NOOP", response->getFirstLine()); diff --git a/src/net/pop3/POP3Utils.cpp b/src/net/pop3/POP3Utils.cpp index e2722104..7ba65fff 100644 --- a/src/net/pop3/POP3Utils.cpp +++ b/src/net/pop3/POP3Utils.cpp @@ -39,7 +39,7 @@ namespace pop3 { // static -void POP3Utils::parseMultiListOrUidlResponse(ref response, std::map & result) +void POP3Utils::parseMultiListOrUidlResponse(shared_ptr response, std::map & result) { std::map ids; diff --git a/src/net/sendmail/sendmailTransport.cpp b/src/net/sendmail/sendmailTransport.cpp index 82501575..68c96e51 100644 --- a/src/net/sendmail/sendmailTransport.cpp +++ b/src/net/sendmail/sendmailTransport.cpp @@ -36,7 +36,6 @@ #include "vmime/utility/filteredStream.hpp" #include "vmime/utility/childProcess.hpp" -#include "vmime/utility/smartPtr.hpp" #include "vmime/utility/streamUtils.hpp" @@ -59,7 +58,7 @@ namespace net { namespace sendmail { -sendmailTransport::sendmailTransport(ref sess, ref auth) +sendmailTransport::sendmailTransport(shared_ptr sess, shared_ptr auth) : transport(sess, getInfosInstance(), auth), m_connected(false) { } @@ -109,9 +108,9 @@ bool sendmailTransport::isSecuredConnection() const } -ref sendmailTransport::getConnectionInfos() const +shared_ptr sendmailTransport::getConnectionInfos() const { - return vmime::create ("localhost", static_cast (0)); + return make_shared ("localhost", static_cast (0)); } @@ -182,7 +181,7 @@ void sendmailTransport::internalSend const utility::file::path path = vmime::platform::getHandler()-> getFileSystemFactory()->stringToPath(m_sendmailPath); - ref proc = + shared_ptr proc = vmime::platform::getHandler()-> getChildProcessFactory()->create(path); diff --git a/src/net/service.cpp b/src/net/service.cpp index 9ff0c394..c52ba592 100644 --- a/src/net/service.cpp +++ b/src/net/service.cpp @@ -46,23 +46,23 @@ namespace vmime { namespace net { -service::service(ref sess, const serviceInfos& /* infos */, - ref auth) +service::service(shared_ptr sess, const serviceInfos& /* infos */, + shared_ptr auth) : m_session(sess), m_auth(auth) { if (!auth) { #if VMIME_HAVE_SASL_SUPPORT - m_auth = vmime::create + m_auth = make_shared (); #else - m_auth = vmime::create + m_auth = make_shared (); #endif // VMIME_HAVE_SASL_SUPPORT } #if VMIME_HAVE_TLS_SUPPORT - m_certVerifier = vmime::create (); + m_certVerifier = make_shared (); #endif // VMIME_HAVE_TLS_SUPPORT m_socketFactory = platform::getHandler()->getSocketFactory(); @@ -74,31 +74,31 @@ service::~service() } -ref service::getSession() const +shared_ptr service::getSession() const { return (m_session); } -ref service::getSession() +shared_ptr service::getSession() { return (m_session); } -ref service::getAuthenticator() const +shared_ptr service::getAuthenticator() const { return (m_auth); } -ref service::getAuthenticator() +shared_ptr service::getAuthenticator() { return (m_auth); } -void service::setAuthenticator(ref auth) +void service::setAuthenticator(shared_ptr auth) { m_auth = auth; } @@ -106,13 +106,13 @@ void service::setAuthenticator(ref auth) #if VMIME_HAVE_TLS_SUPPORT -void service::setCertificateVerifier(ref cv) +void service::setCertificateVerifier(shared_ptr cv) { m_certVerifier = cv; } -ref service::getCertificateVerifier() +shared_ptr service::getCertificateVerifier() { return m_certVerifier; } @@ -120,25 +120,25 @@ ref service::getCertificateVerifier() #endif // VMIME_HAVE_TLS_SUPPORT -void service::setSocketFactory(ref sf) +void service::setSocketFactory(shared_ptr sf) { m_socketFactory = sf; } -ref service::getSocketFactory() +shared_ptr service::getSocketFactory() { return m_socketFactory; } -void service::setTimeoutHandlerFactory(ref thf) +void service::setTimeoutHandlerFactory(shared_ptr thf) { m_toHandlerFactory = thf; } -ref service::getTimeoutHandlerFactory() +shared_ptr service::getTimeoutHandlerFactory() { return m_toHandlerFactory; } diff --git a/src/net/serviceFactory.cpp b/src/net/serviceFactory.cpp index c44cbadc..a16098ce 100644 --- a/src/net/serviceFactory.cpp +++ b/src/net/serviceFactory.cpp @@ -49,26 +49,26 @@ serviceFactory::~serviceFactory() } -serviceFactory* serviceFactory::getInstance() +shared_ptr serviceFactory::getInstance() { static serviceFactory instance; - return (&instance); + return shared_ptr (&instance, noop_shared_ptr_deleter ()); } -ref serviceFactory::create - (ref sess, const string& protocol, - ref auth) +shared_ptr serviceFactory::create + (shared_ptr sess, const string& protocol, + shared_ptr auth) { return (getServiceByProtocol(protocol)->create(sess, auth)); } -ref serviceFactory::create - (ref sess, const utility::url& u, - ref auth) +shared_ptr serviceFactory::create + (shared_ptr sess, const utility::url& u, + shared_ptr auth) { - ref serv = create(sess, u.getProtocol(), auth); + shared_ptr serv = create(sess, u.getProtocol(), auth); sess->getProperties()[serv->getInfos().getPropertyPrefix() + "server.address"] = u.getHost(); @@ -90,11 +90,11 @@ ref serviceFactory::create } -ref serviceFactory::getServiceByProtocol(const string& protocol) const +shared_ptr serviceFactory::getServiceByProtocol(const string& protocol) const { const string name(utility::stringUtils::toLower(protocol)); - for (std::vector >::const_iterator it = m_services.begin() ; + for (std::vector >::const_iterator it = m_services.begin() ; it != m_services.end() ; ++it) { if ((*it)->getName() == name) @@ -111,17 +111,17 @@ size_t serviceFactory::getServiceCount() const } -ref serviceFactory::getServiceAt(const size_t pos) const +shared_ptr serviceFactory::getServiceAt(const size_t pos) const { return (m_services[pos]); } -const std::vector > serviceFactory::getServiceList() const +const std::vector > serviceFactory::getServiceList() const { - std::vector > res; + std::vector > res; - for (std::vector >::const_iterator it = m_services.begin() ; + for (std::vector >::const_iterator it = m_services.begin() ; it != m_services.end() ; ++it) { res.push_back(*it); @@ -131,7 +131,7 @@ const std::vector > serviceFactor } -void serviceFactory::registerService(ref reg) +void serviceFactory::registerService(shared_ptr reg) { m_services.push_back(reg); } diff --git a/src/net/serviceInfos.cpp b/src/net/serviceInfos.cpp index 751bae3f..8de0529e 100644 --- a/src/net/serviceInfos.cpp +++ b/src/net/serviceInfos.cpp @@ -85,7 +85,7 @@ serviceInfos::~serviceInfos() } -bool serviceInfos::hasProperty(ref s, const property& p) const +bool serviceInfos::hasProperty(shared_ptr s, const property& p) const { return s->getProperties().hasProperty(getPropertyPrefix() + p.getName()); } diff --git a/src/net/serviceRegistration.inl b/src/net/serviceRegistration.inl index 084aed9e..2366fe01 100644 --- a/src/net/serviceRegistration.inl +++ b/src/net/serviceRegistration.inl @@ -41,11 +41,11 @@ public: { } - ref create - (ref sess, - ref auth) const + shared_ptr create + (shared_ptr sess, + shared_ptr auth) const { - return vmime::create (sess, auth); + return make_shared (sess, auth); } const serviceInfos& getInfos() const @@ -80,7 +80,7 @@ public: serviceRegisterer(const string& protocol, const service::Type type) { serviceFactory::getInstance()->registerService - (vmime::create >(protocol, type)); + (make_shared >(protocol, type)); } }; diff --git a/src/net/session.cpp b/src/net/session.cpp index a444d000..fcc5dd12 100644 --- a/src/net/session.cpp +++ b/src/net/session.cpp @@ -39,19 +39,20 @@ namespace net { session::session() - : m_tlsProps(vmime::create ()) + : m_tlsProps(make_shared ()) { } session::session(const session& sess) - : object(), m_props(sess.m_props), m_tlsProps(vmime::create (*sess.m_tlsProps)) + : object(), m_props(sess.m_props), + m_tlsProps(make_shared (*sess.m_tlsProps)) { } session::session(const propertySet& props) - : m_props(props), m_tlsProps(vmime::create ()) + : m_props(props), m_tlsProps(make_shared ()) { } @@ -61,67 +62,67 @@ session::~session() } -ref session::getTransport(ref auth) +shared_ptr session::getTransport(shared_ptr auth) { return (getTransport(m_props["transport.protocol"], auth)); } -ref session::getTransport - (const string& protocol, ref auth) +shared_ptr session::getTransport + (const string& protocol, shared_ptr auth) { - ref sess = thisRef().dynamicCast (); - ref sv = serviceFactory::getInstance()->create(sess, protocol, auth); + shared_ptr sess(dynamicCast (shared_from_this())); + shared_ptr sv = serviceFactory::getInstance()->create(sess, protocol, auth); if (sv->getType() != service::TYPE_TRANSPORT) throw exceptions::no_service_available(); - return sv.staticCast (); + return dynamicCast (sv); } -ref session::getTransport - (const utility::url& url, ref auth) +shared_ptr session::getTransport + (const utility::url& url, shared_ptr auth) { - ref sess = thisRef().dynamicCast (); - ref sv = serviceFactory::getInstance()->create(sess, url, auth); + shared_ptr sess(dynamicCast (shared_from_this())); + shared_ptr sv = serviceFactory::getInstance()->create(sess, url, auth); if (sv->getType() != service::TYPE_TRANSPORT) throw exceptions::no_service_available(); - return sv.staticCast (); + return dynamicCast (sv); } -ref session::getStore(ref auth) +shared_ptr session::getStore(shared_ptr auth) { return (getStore(m_props["store.protocol"], auth)); } -ref session::getStore - (const string& protocol, ref auth) +shared_ptr session::getStore + (const string& protocol, shared_ptr auth) { - ref sess = thisRef().dynamicCast (); - ref sv = serviceFactory::getInstance()->create(sess, protocol, auth); + shared_ptr sess(dynamicCast (shared_from_this())); + shared_ptr sv = serviceFactory::getInstance()->create(sess, protocol, auth); if (sv->getType() != service::TYPE_STORE) throw exceptions::no_service_available(); - return sv.staticCast (); + return dynamicCast (sv); } -ref session::getStore - (const utility::url& url, ref auth) +shared_ptr session::getStore + (const utility::url& url, shared_ptr auth) { - ref sess = thisRef().dynamicCast (); - ref sv = serviceFactory::getInstance()->create(sess, url, auth); + shared_ptr sess(dynamicCast (shared_from_this())); + shared_ptr sv = serviceFactory::getInstance()->create(sess, url, auth); if (sv->getType() != service::TYPE_STORE) throw exceptions::no_service_available(); - return sv.staticCast (); + return dynamicCast (sv); } @@ -137,13 +138,13 @@ propertySet& session::getProperties() } -void session::setTLSProperties(ref tlsProps) +void session::setTLSProperties(shared_ptr tlsProps) { - m_tlsProps = vmime::create (*tlsProps); + m_tlsProps = make_shared (*tlsProps); } -ref session::getTLSProperties() const +shared_ptr session::getTLSProperties() const { return m_tlsProps; } diff --git a/src/net/smtp/SMTPChunkingOutputStreamAdapter.cpp b/src/net/smtp/SMTPChunkingOutputStreamAdapter.cpp index 932bd56f..0584f7e6 100644 --- a/src/net/smtp/SMTPChunkingOutputStreamAdapter.cpp +++ b/src/net/smtp/SMTPChunkingOutputStreamAdapter.cpp @@ -40,7 +40,7 @@ namespace net { namespace smtp { -SMTPChunkingOutputStreamAdapter::SMTPChunkingOutputStreamAdapter(ref conn) +SMTPChunkingOutputStreamAdapter::SMTPChunkingOutputStreamAdapter(shared_ptr conn) : m_connection(conn), m_bufferSize(0), m_chunkCount(0) { } @@ -64,7 +64,7 @@ void SMTPChunkingOutputStreamAdapter::sendChunk // If PIPELINING is not supported, read one response for this BDAT command if (!m_connection->hasExtension("PIPELINING")) { - ref resp = m_connection->readResponse(); + shared_ptr resp = m_connection->readResponse(); if (resp->getCode() != 250) { @@ -77,7 +77,7 @@ void SMTPChunkingOutputStreamAdapter::sendChunk else if (last) { bool invalidReply = false; - ref resp; + shared_ptr resp; for (unsigned int i = 0 ; i < m_chunkCount ; ++i) { diff --git a/src/net/smtp/SMTPCommand.cpp b/src/net/smtp/SMTPCommand.cpp index e40797f2..6b3d1d79 100644 --- a/src/net/smtp/SMTPCommand.cpp +++ b/src/net/smtp/SMTPCommand.cpp @@ -47,7 +47,7 @@ SMTPCommand::SMTPCommand(const string& text) // static -ref SMTPCommand::EHLO(const string& hostname) +shared_ptr SMTPCommand::EHLO(const string& hostname) { std::ostringstream cmd; cmd.imbue(std::locale::classic()); @@ -58,7 +58,7 @@ ref SMTPCommand::EHLO(const string& hostname) // static -ref SMTPCommand::HELO(const string& hostname) +shared_ptr SMTPCommand::HELO(const string& hostname) { std::ostringstream cmd; cmd.imbue(std::locale::classic()); @@ -69,7 +69,7 @@ ref SMTPCommand::HELO(const string& hostname) // static -ref SMTPCommand::AUTH(const string& mechName) +shared_ptr SMTPCommand::AUTH(const string& mechName) { std::ostringstream cmd; cmd.imbue(std::locale::classic()); @@ -80,21 +80,21 @@ ref SMTPCommand::AUTH(const string& mechName) // static -ref SMTPCommand::STARTTLS() +shared_ptr SMTPCommand::STARTTLS() { return createCommand("STARTTLS"); } // static -ref SMTPCommand::MAIL(const mailbox& mbox, const bool utf8) +shared_ptr SMTPCommand::MAIL(const mailbox& mbox, const bool utf8) { return MAIL(mbox, utf8, 0); } // static -ref SMTPCommand::MAIL(const mailbox& mbox, const bool utf8, const unsigned long size) +shared_ptr SMTPCommand::MAIL(const mailbox& mbox, const bool utf8, const unsigned long size) { std::ostringstream cmd; cmd.imbue(std::locale::classic()); @@ -123,7 +123,7 @@ ref SMTPCommand::MAIL(const mailbox& mbox, const bool utf8, const // static -ref SMTPCommand::RCPT(const mailbox& mbox, const bool utf8) +shared_ptr SMTPCommand::RCPT(const mailbox& mbox, const bool utf8) { std::ostringstream cmd; cmd.imbue(std::locale::classic()); @@ -146,21 +146,21 @@ ref SMTPCommand::RCPT(const mailbox& mbox, const bool utf8) // static -ref SMTPCommand::RSET() +shared_ptr SMTPCommand::RSET() { return createCommand("RSET"); } // static -ref SMTPCommand::DATA() +shared_ptr SMTPCommand::DATA() { return createCommand("DATA"); } // static -ref SMTPCommand::BDAT(const unsigned long chunkSize, const bool last) +shared_ptr SMTPCommand::BDAT(const unsigned long chunkSize, const bool last) { std::ostringstream cmd; cmd.imbue(std::locale::classic()); @@ -174,23 +174,23 @@ ref SMTPCommand::BDAT(const unsigned long chunkSize, const bool la // static -ref SMTPCommand::NOOP() +shared_ptr SMTPCommand::NOOP() { return createCommand("NOOP"); } // static -ref SMTPCommand::QUIT() +shared_ptr SMTPCommand::QUIT() { return createCommand("QUIT"); } // static -ref SMTPCommand::createCommand(const string& text) +shared_ptr SMTPCommand::createCommand(const string& text) { - return vmime::create (text); + return shared_ptr (new SMTPCommand(text)); } @@ -200,7 +200,7 @@ const string SMTPCommand::getText() const } -void SMTPCommand::writeToSocket(ref sok) +void SMTPCommand::writeToSocket(shared_ptr sok) { sok->send(m_text + "\r\n"); } diff --git a/src/net/smtp/SMTPCommandSet.cpp b/src/net/smtp/SMTPCommandSet.cpp index a967c3a6..3e03427c 100644 --- a/src/net/smtp/SMTPCommandSet.cpp +++ b/src/net/smtp/SMTPCommandSet.cpp @@ -49,13 +49,13 @@ SMTPCommandSet::SMTPCommandSet(const bool pipeline) // static -ref SMTPCommandSet::create(const bool pipeline) +shared_ptr SMTPCommandSet::create(const bool pipeline) { - return vmime::create (pipeline); + return shared_ptr (new SMTPCommandSet(pipeline)); } -void SMTPCommandSet::addCommand(ref cmd) +void SMTPCommandSet::addCommand(shared_ptr cmd) { if (m_started) { @@ -67,17 +67,17 @@ void SMTPCommandSet::addCommand(ref cmd) } -void SMTPCommandSet::writeToSocket(ref sok) +void SMTPCommandSet::writeToSocket(shared_ptr sok) { if (m_pipeline) { if (!m_started) { // Send all commands at once - for (std::list >::const_iterator it = m_commands.begin() ; + for (std::list >::const_iterator it = m_commands.begin() ; it != m_commands.end() ; ++it) { - ref cmd = *it; + shared_ptr cmd = *it; cmd->writeToSocket(sok); } } @@ -85,7 +85,7 @@ void SMTPCommandSet::writeToSocket(ref sok) if (!m_commands.empty()) { // Advance the pointer to last command sent - ref cmd = m_commands.front(); + shared_ptr cmd = m_commands.front(); m_commands.pop_front(); m_lastCommandSent = cmd; @@ -96,7 +96,7 @@ void SMTPCommandSet::writeToSocket(ref sok) if (!m_commands.empty()) { // Send only one command - ref cmd = m_commands.front(); + shared_ptr cmd = m_commands.front(); m_commands.pop_front(); cmd->writeToSocket(sok); @@ -114,7 +114,7 @@ const string SMTPCommandSet::getText() const std::ostringstream cmd; cmd.imbue(std::locale::classic()); - for (std::list >::const_iterator it = m_commands.begin() ; + for (std::list >::const_iterator it = m_commands.begin() ; it != m_commands.end() ; ++it) { cmd << (*it)->getText() << "\r\n"; @@ -130,7 +130,7 @@ bool SMTPCommandSet::isFinished() const } -ref SMTPCommandSet::getLastCommandSent() const +shared_ptr SMTPCommandSet::getLastCommandSent() const { return m_lastCommandSent; } diff --git a/src/net/smtp/SMTPConnection.cpp b/src/net/smtp/SMTPConnection.cpp index e831ccfc..9fcacbc1 100644 --- a/src/net/smtp/SMTPConnection.cpp +++ b/src/net/smtp/SMTPConnection.cpp @@ -51,11 +51,11 @@ // Helpers for service properties #define GET_PROPERTY(type, prop) \ - (m_transport.acquire()->getInfos().getPropertyValue (getSession(), \ - dynamic_cast (m_transport.acquire()->getInfos()).getProperties().prop)) + (m_transport.lock()->getInfos().getPropertyValue (getSession(), \ + dynamic_cast (m_transport.lock()->getInfos()).getProperties().prop)) #define HAS_PROPERTY(prop) \ - (m_transport.acquire()->getInfos().hasProperty(getSession(), \ - dynamic_cast (m_transport.acquire()->getInfos()).getProperties().prop)) + (m_transport.lock()->getInfos().hasProperty(getSession(), \ + dynamic_cast (m_transport.lock()->getInfos()).getProperties().prop)) namespace vmime { @@ -64,8 +64,8 @@ namespace smtp { -SMTPConnection::SMTPConnection(ref transport, ref auth) - : m_transport(transport), m_auth(auth), m_socket(NULL), m_timeoutHandler(NULL), +SMTPConnection::SMTPConnection(shared_ptr transport, shared_ptr auth) + : m_transport(transport), m_auth(auth), m_socket(null), m_timeoutHandler(null), m_authenticated(false), m_secured(false), m_extendedSMTP(false) { } @@ -95,7 +95,7 @@ void SMTPConnection::connect() const string address = GET_PROPERTY(string, PROPERTY_SERVER_ADDRESS); const port_t port = GET_PROPERTY(port_t, PROPERTY_SERVER_PORT); - ref transport = m_transport.acquire(); + shared_ptr transport = m_transport.lock(); // Create the time-out handler if (transport->getTimeoutHandlerFactory()) @@ -107,22 +107,22 @@ void SMTPConnection::connect() #if VMIME_HAVE_TLS_SUPPORT if (transport->isSMTPS()) // dedicated port/SMTPS { - ref tlsSession = tls::TLSSession::create + shared_ptr tlsSession = tls::TLSSession::create (transport->getCertificateVerifier(), transport->getSession()->getTLSProperties()); - ref tlsSocket = + shared_ptr tlsSocket = tlsSession->getSocket(m_socket); m_socket = tlsSocket; m_secured = true; - m_cntInfos = vmime::create (address, port, tlsSession, tlsSocket); + m_cntInfos = make_shared (address, port, tlsSession, tlsSocket); } else #endif // VMIME_HAVE_TLS_SUPPORT { - m_cntInfos = vmime::create (address, port); + m_cntInfos = make_shared (address, port); } m_socket->connect(address, port); @@ -132,7 +132,7 @@ void SMTPConnection::connect() // eg: C: // --- S: 220 smtp.domain.com Service ready - ref resp; + shared_ptr resp; if ((resp = readResponse())->getCode() != 220) { @@ -199,7 +199,7 @@ void SMTPConnection::helo() sendRequest(SMTPCommand::EHLO(platform::getHandler()->getHostName())); - ref resp; + shared_ptr resp; if ((resp = readResponse())->getCode() != 250) { @@ -281,7 +281,7 @@ void SMTPConnection::authenticate() throw exceptions::command_error("AUTH", "ESMTP not supported."); } - getAuthenticator()->setService(m_transport.acquire()); + getAuthenticator()->setService(m_transport.lock()); #if VMIME_HAVE_SASL_SUPPORT // First, try SASL authentication @@ -325,7 +325,7 @@ void SMTPConnection::authenticate() void SMTPConnection::authenticateSASL() { - if (!getAuthenticator().dynamicCast ()) + if (!dynamicCast (getAuthenticator())) throw exceptions::authentication_error("No SASL authenticator available."); // Obtain SASL mechanisms supported by server from ESMTP extensions @@ -335,10 +335,10 @@ void SMTPConnection::authenticateSASL() if (saslMechs.empty()) throw exceptions::authentication_error("No SASL mechanism available."); - std::vector > mechList; + std::vector > mechList; - ref saslContext = - vmime::create (); + shared_ptr saslContext = + make_shared (); for (unsigned int i = 0 ; i < saslMechs.size() ; ++i) { @@ -357,14 +357,14 @@ void SMTPConnection::authenticateSASL() throw exceptions::authentication_error("No SASL mechanism available."); // Try to suggest a mechanism among all those supported - ref suggestedMech = + shared_ptr suggestedMech = saslContext->suggestMechanism(mechList); if (!suggestedMech) throw exceptions::authentication_error("Unable to suggest SASL mechanism."); // Allow application to choose which mechanisms to use - mechList = getAuthenticator().dynamicCast ()-> + mechList = dynamicCast (getAuthenticator())-> getAcceptableMechanisms(mechList, suggestedMech); if (mechList.empty()) @@ -373,9 +373,9 @@ void SMTPConnection::authenticateSASL() // Try each mechanism in the list in turn for (unsigned int i = 0 ; i < mechList.size() ; ++i) { - ref mech = mechList[i]; + shared_ptr mech = mechList[i]; - ref saslSession = + shared_ptr saslSession = saslContext->createSession("smtp", getAuthenticator(), mech); saslSession->init(); @@ -384,7 +384,7 @@ void SMTPConnection::authenticateSASL() for (bool cont = true ; cont ; ) { - ref response = readResponse(); + shared_ptr response = readResponse(); switch (response->getCode()) { @@ -472,7 +472,7 @@ void SMTPConnection::startTLS() { sendRequest(SMTPCommand::STARTTLS()); - ref resp = readResponse(); + shared_ptr resp = readResponse(); if (resp->getCode() != 220) { @@ -480,11 +480,11 @@ void SMTPConnection::startTLS() resp->getCode(), resp->getEnhancedCode()); } - ref tlsSession = tls::TLSSession::create + shared_ptr tlsSession = tls::TLSSession::create (getTransport()->getCertificateVerifier(), getTransport()->getSession()->getTLSProperties()); - ref tlsSocket = + shared_ptr tlsSocket = tlsSession->getSocket(m_socket); tlsSocket->handshake(m_timeoutHandler); @@ -492,7 +492,7 @@ void SMTPConnection::startTLS() m_socket = tlsSocket; m_secured = true; - m_cntInfos = vmime::create + m_cntInfos = make_shared (m_cntInfos->getHost(), m_cntInfos->getPort(), tlsSession, tlsSocket); } catch (exceptions::command_error&) @@ -533,27 +533,27 @@ void SMTPConnection::internalDisconnect() } m_socket->disconnect(); - m_socket = NULL; + m_socket = null; - m_timeoutHandler = NULL; + m_timeoutHandler = null; m_authenticated = false; m_extendedSMTP = false; m_secured = false; - m_cntInfos = NULL; + m_cntInfos = null; } -void SMTPConnection::sendRequest(ref cmd) +void SMTPConnection::sendRequest(shared_ptr cmd) { cmd->writeToSocket(m_socket); } -ref SMTPConnection::readResponse() +shared_ptr SMTPConnection::readResponse() { - ref resp = SMTPResponse::readResponse + shared_ptr resp = SMTPResponse::readResponse (m_socket, m_timeoutHandler, m_responseState); m_responseState = resp->getCurrentState(); @@ -574,37 +574,37 @@ bool SMTPConnection::isSecuredConnection() const } -ref SMTPConnection::getConnectionInfos() const +shared_ptr SMTPConnection::getConnectionInfos() const { return m_cntInfos; } -ref SMTPConnection::getTransport() +shared_ptr SMTPConnection::getTransport() { - return m_transport.acquire(); + return m_transport.lock(); } -ref SMTPConnection::getSession() +shared_ptr SMTPConnection::getSession() { - return m_transport.acquire()->getSession(); + return m_transport.lock()->getSession(); } -ref SMTPConnection::getSocket() +shared_ptr SMTPConnection::getSocket() { return m_socket; } -ref SMTPConnection::getTimeoutHandler() +shared_ptr SMTPConnection::getTimeoutHandler() { return m_timeoutHandler; } -ref SMTPConnection::getAuthenticator() +shared_ptr SMTPConnection::getAuthenticator() { return m_auth; } diff --git a/src/net/smtp/SMTPResponse.cpp b/src/net/smtp/SMTPResponse.cpp index 9367dcd4..baefc38d 100644 --- a/src/net/smtp/SMTPResponse.cpp +++ b/src/net/smtp/SMTPResponse.cpp @@ -43,7 +43,7 @@ namespace net { namespace smtp { -SMTPResponse::SMTPResponse(ref sok, ref toh, const state& st) +SMTPResponse::SMTPResponse(shared_ptr sok, shared_ptr toh, const state& st) : m_socket(sok), m_timeoutHandler(toh), m_responseBuffer(st.responseBuffer), m_responseContinues(false) { @@ -94,10 +94,10 @@ const string SMTPResponse::getText() const // static -ref SMTPResponse::readResponse - (ref sok, ref toh, const state& st) +shared_ptr SMTPResponse::readResponse + (shared_ptr sok, shared_ptr toh, const state& st) { - ref resp = vmime::create (sok, toh, st); + shared_ptr resp = shared_ptr (new SMTPResponse(sok, toh, st)); resp->readResponse(); diff --git a/src/net/smtp/SMTPSTransport.cpp b/src/net/smtp/SMTPSTransport.cpp index 2e594ce7..ab64d49d 100644 --- a/src/net/smtp/SMTPSTransport.cpp +++ b/src/net/smtp/SMTPSTransport.cpp @@ -35,7 +35,7 @@ namespace net { namespace smtp { -SMTPSTransport::SMTPSTransport(ref sess, ref auth) +SMTPSTransport::SMTPSTransport(shared_ptr sess, shared_ptr auth) : SMTPTransport(sess, auth, true) { } diff --git a/src/net/smtp/SMTPTransport.cpp b/src/net/smtp/SMTPTransport.cpp index 91487ed4..4f409a03 100644 --- a/src/net/smtp/SMTPTransport.cpp +++ b/src/net/smtp/SMTPTransport.cpp @@ -51,7 +51,7 @@ namespace net { namespace smtp { -SMTPTransport::SMTPTransport(ref sess, ref auth, const bool secured) +SMTPTransport::SMTPTransport(shared_ptr sess, shared_ptr auth, const bool secured) : transport(sess, getInfosInstance(), auth), m_isSMTPS(secured), m_needReset(false) { } @@ -88,8 +88,8 @@ void SMTPTransport::connect() if (isConnected()) throw exceptions::already_connected(); - m_connection = vmime::create - (thisRef().dynamicCast (), getAuthenticator()); + m_connection = make_shared + (dynamicCast (shared_from_this()), getAuthenticator()); try { @@ -97,7 +97,7 @@ void SMTPTransport::connect() } catch (std::exception&) { - m_connection = NULL; + m_connection = null; throw; } } @@ -118,16 +118,16 @@ bool SMTPTransport::isSecuredConnection() const } -ref SMTPTransport::getConnectionInfos() const +shared_ptr SMTPTransport::getConnectionInfos() const { if (m_connection == NULL) - return NULL; + return null; return m_connection->getConnectionInfos(); } -ref SMTPTransport::getConnection() +shared_ptr SMTPTransport::getConnection() { return m_connection; } @@ -139,7 +139,7 @@ void SMTPTransport::disconnect() throw exceptions::not_connected(); m_connection->disconnect(); - m_connection = NULL; + m_connection = null; } @@ -150,7 +150,7 @@ void SMTPTransport::noop() m_connection->sendRequest(SMTPCommand::NOOP()); - ref resp = m_connection->readResponse(); + shared_ptr resp = m_connection->readResponse(); if (resp->getCode() != 250) { @@ -177,8 +177,8 @@ void SMTPTransport::sendEnvelope getInfos().getPropertyValue (getSession(), dynamic_cast (getInfos()).getProperties().PROPERTY_OPTIONS_PIPELINING); - ref resp; - ref commands = SMTPCommandSet::create(hasPipelining); + shared_ptr resp; + shared_ptr commands = SMTPCommandSet::create(hasPipelining); // Emit a "RSET" command if we previously sent a message on this connection if (needReset) @@ -336,7 +336,7 @@ void SMTPTransport::send // Send end-of-data delimiter m_connection->getSocket()->sendRaw("\r\n.\r\n", 5); - ref resp; + shared_ptr resp; if ((resp = m_connection->readResponse())->getCode() != 250) { @@ -349,7 +349,7 @@ void SMTPTransport::send void SMTPTransport::send - (ref msg, const mailbox& expeditor, const mailboxList& recipients, + (shared_ptr msg, const mailbox& expeditor, const mailboxList& recipients, utility::progressListener* progress, const mailbox& sender) { if (!isConnected()) diff --git a/src/net/tls/TLSSecuredConnectionInfos.cpp b/src/net/tls/TLSSecuredConnectionInfos.cpp index 5060aede..4856e9af 100644 --- a/src/net/tls/TLSSecuredConnectionInfos.cpp +++ b/src/net/tls/TLSSecuredConnectionInfos.cpp @@ -38,7 +38,7 @@ namespace tls { TLSSecuredConnectionInfos::TLSSecuredConnectionInfos (const string& host, const port_t port, - ref tlsSession, ref tlsSocket) + shared_ptr tlsSession, shared_ptr tlsSocket) : m_host(host), m_port(port), m_tlsSession(tlsSession), m_tlsSocket(tlsSocket) { @@ -57,7 +57,7 @@ port_t TLSSecuredConnectionInfos::getPort() const } -ref TLSSecuredConnectionInfos::getPeerCertificates() const +shared_ptr TLSSecuredConnectionInfos::getPeerCertificates() const { return m_tlsSocket->getPeerCertificates(); } diff --git a/src/net/tls/gnutls/TLSProperties_GnuTLS.cpp b/src/net/tls/gnutls/TLSProperties_GnuTLS.cpp index 2a161dee..36ab7d7a 100644 --- a/src/net/tls/gnutls/TLSProperties_GnuTLS.cpp +++ b/src/net/tls/gnutls/TLSProperties_GnuTLS.cpp @@ -42,7 +42,7 @@ namespace tls { TLSProperties::TLSProperties() - : m_data(vmime::create ()) + : m_data(make_shared ()) { setCipherSuite(CIPHERSUITE_DEFAULT); } @@ -50,9 +50,9 @@ TLSProperties::TLSProperties() TLSProperties::TLSProperties(const TLSProperties& props) : object(), - m_data(vmime::create ()) + m_data(make_shared ()) { - *m_data.dynamicCast () = *props.m_data.dynamicCast (); + *dynamicCast (m_data) = *dynamicCast (props.m_data); } @@ -86,13 +86,13 @@ void TLSProperties::setCipherSuite(const GenericCipherSuite cipherSuite) void TLSProperties::setCipherSuite(const string& cipherSuite) { - m_data.dynamicCast ()->cipherSuite = cipherSuite; + dynamicCast (m_data)->cipherSuite = cipherSuite; } const string TLSProperties::getCipherSuite() const { - return m_data.dynamicCast ()->cipherSuite; + return dynamicCast (m_data)->cipherSuite; } diff --git a/src/net/tls/gnutls/TLSSession_GnuTLS.cpp b/src/net/tls/gnutls/TLSSession_GnuTLS.cpp index 52fedc78..1c520ed1 100644 --- a/src/net/tls/gnutls/TLSSession_GnuTLS.cpp +++ b/src/net/tls/gnutls/TLSSession_GnuTLS.cpp @@ -134,13 +134,13 @@ static TLSGlobal g_gnutlsGlobal; // static -ref TLSSession::create(ref cv, ref props) +shared_ptr TLSSession::create(shared_ptr cv, shared_ptr props) { - return vmime::create (cv, props); + return make_shared (cv, props); } -TLSSession_GnuTLS::TLSSession_GnuTLS(ref cv, ref props) +TLSSession_GnuTLS::TLSSession_GnuTLS(shared_ptr cv, shared_ptr props) : m_certVerifier(cv), m_props(props) { int res; @@ -267,13 +267,13 @@ TLSSession_GnuTLS::~TLSSession_GnuTLS() } -ref TLSSession_GnuTLS::getSocket(ref sok) +shared_ptr TLSSession_GnuTLS::getSocket(shared_ptr sok) { - return TLSSocket::wrap(thisRef().dynamicCast (), sok); + return TLSSocket::wrap(dynamicCast (shared_from_this()), sok); } -ref TLSSession_GnuTLS::getCertificateVerifier() +shared_ptr TLSSession_GnuTLS::getCertificateVerifier() { return m_certVerifier; } diff --git a/src/net/tls/gnutls/TLSSocket_GnuTLS.cpp b/src/net/tls/gnutls/TLSSocket_GnuTLS.cpp index 0a24b720..bb21cb9d 100644 --- a/src/net/tls/gnutls/TLSSocket_GnuTLS.cpp +++ b/src/net/tls/gnutls/TLSSocket_GnuTLS.cpp @@ -44,14 +44,14 @@ namespace tls { // static -ref TLSSocket::wrap(ref session, ref sok) +shared_ptr TLSSocket::wrap(shared_ptr session, shared_ptr sok) { - return vmime::create - (session.dynamicCast (), sok); + return make_shared + (dynamicCast (session), sok); } -TLSSocket_GnuTLS::TLSSocket_GnuTLS(ref session, ref sok) +TLSSocket_GnuTLS::TLSSocket_GnuTLS(shared_ptr session, shared_ptr sok) : m_session(session), m_wrapped(sok), m_connected(false), m_handshaking(false), m_ex(NULL), m_status(0) { @@ -85,7 +85,7 @@ void TLSSocket_GnuTLS::connect(const string& address, const port_t port) { m_wrapped->connect(address, port); - handshake(NULL); + handshake(null); m_connected = true; } @@ -219,7 +219,7 @@ unsigned int TLSSocket_GnuTLS::getStatus() const } -void TLSSocket_GnuTLS::handshake(ref toHandler) +void TLSSocket_GnuTLS::handshake(shared_ptr toHandler) { if (toHandler) toHandler->resetTimeOut(); @@ -260,16 +260,16 @@ void TLSSocket_GnuTLS::handshake(ref toHandler) catch (...) { m_handshaking = false; - m_toHandler = NULL; + m_toHandler = null; throw; } m_handshaking = false; - m_toHandler = NULL; + m_toHandler = null; // Verify server's certificate(s) - ref certs = getPeerCertificates(); + shared_ptr certs = getPeerCertificates(); if (certs == NULL) throw exceptions::tls_exception("No peer certificate."); @@ -364,14 +364,14 @@ ssize_t TLSSocket_GnuTLS::gnutlsPullFunc } -ref TLSSocket_GnuTLS::getPeerCertificates() const +shared_ptr TLSSocket_GnuTLS::getPeerCertificates() const { unsigned int certCount = 0; const gnutls_datum* rawData = gnutls_certificate_get_peers (*m_session->m_gnutlsSession, &certCount); if (rawData == NULL) - return NULL; + return null; // Try X.509 gnutls_x509_crt* x509Certs = new gnutls_x509_crt[certCount]; @@ -387,12 +387,12 @@ ref TLSSocket_GnuTLS::getPeerCertificates() c { // XXX more fine-grained error reporting? delete [] x509Certs; - return NULL; + return null; } } { - std::vector > certs; + std::vector > certs; bool error = false; for (unsigned int i = 0 ; i < certCount ; ++i) @@ -407,7 +407,7 @@ ref TLSSocket_GnuTLS::getPeerCertificates() c gnutls_x509_crt_export(x509Certs[i], GNUTLS_X509_FMT_DER, &data[0], &dataSize); - ref cert = + shared_ptr cert = security::cert::X509Certificate::import(&data[0], dataSize); if (cert != NULL) @@ -421,14 +421,14 @@ ref TLSSocket_GnuTLS::getPeerCertificates() c delete [] x509Certs; if (error) - return NULL; + return null; - return vmime::create (certs); + return make_shared (certs); } delete [] x509Certs; - return NULL; + return null; } @@ -457,7 +457,7 @@ private: void TLSSocket_GnuTLS::internalThrow() { - static std::vector > exToDelete; + static std::vector > exToDelete; if (m_ex) { @@ -467,7 +467,7 @@ void TLSSocket_GnuTLS::internalThrow() m_ex = NULL; // To avoid memory leaks - exToDelete.push_back(vmime::create (ex)); + exToDelete.push_back(make_shared (ex)); throw *ex; } diff --git a/src/net/tls/openssl/OpenSSLInitializer.cpp b/src/net/tls/openssl/OpenSSLInitializer.cpp index 8238b864..1bbb9ee5 100644 --- a/src/net/tls/openssl/OpenSSLInitializer.cpp +++ b/src/net/tls/openssl/OpenSSLInitializer.cpp @@ -49,7 +49,7 @@ namespace net { namespace tls { -ref * OpenSSLInitializer::sm_mutexes; +shared_ptr * OpenSSLInitializer::sm_mutexes; OpenSSLInitializer::autoInitializer::autoInitializer() @@ -93,7 +93,7 @@ void OpenSSLInitializer::initialize() RAND_seed(seed, SEEDSIZE); int numMutexes = CRYPTO_num_locks(); - sm_mutexes = new ref [numMutexes]; + sm_mutexes = new shared_ptr [numMutexes]; for (int i = 0 ; i < numMutexes ; ++i) sm_mutexes[i] = vmime::platform::getHandler()->createCriticalSection(); diff --git a/src/net/tls/openssl/TLSProperties_OpenSSL.cpp b/src/net/tls/openssl/TLSProperties_OpenSSL.cpp index 34e31cf1..932477df 100644 --- a/src/net/tls/openssl/TLSProperties_OpenSSL.cpp +++ b/src/net/tls/openssl/TLSProperties_OpenSSL.cpp @@ -40,7 +40,7 @@ namespace tls { TLSProperties::TLSProperties() - : m_data(vmime::create ()) + : m_data(make_shared ()) { setCipherSuite(CIPHERSUITE_DEFAULT); } @@ -48,9 +48,9 @@ TLSProperties::TLSProperties() TLSProperties::TLSProperties(const TLSProperties& props) : object(), - m_data(vmime::create ()) + m_data(make_shared ()) { - *m_data.dynamicCast () = *props.m_data.dynamicCast (); + *dynamicCast (m_data) = *dynamicCast (props.m_data); } @@ -84,13 +84,13 @@ void TLSProperties::setCipherSuite(const GenericCipherSuite cipherSuite) void TLSProperties::setCipherSuite(const string& cipherSuite) { - m_data.dynamicCast ()->cipherSuite = cipherSuite; + dynamicCast (m_data)->cipherSuite = cipherSuite; } const string TLSProperties::getCipherSuite() const { - return m_data.dynamicCast ()->cipherSuite; + return dynamicCast (m_data)->cipherSuite; } diff --git a/src/net/tls/openssl/TLSSession_OpenSSL.cpp b/src/net/tls/openssl/TLSSession_OpenSSL.cpp index 953e4ebc..cf600a63 100644 --- a/src/net/tls/openssl/TLSSession_OpenSSL.cpp +++ b/src/net/tls/openssl/TLSSession_OpenSSL.cpp @@ -46,13 +46,13 @@ static OpenSSLInitializer::autoInitializer openSSLInitializer; // static -ref TLSSession::create(ref cv, ref props) +shared_ptr TLSSession::create(shared_ptr cv, shared_ptr props) { - return vmime::create (cv, props); + return make_shared (cv, props); } -TLSSession_OpenSSL::TLSSession_OpenSSL(ref cv, ref props) +TLSSession_OpenSSL::TLSSession_OpenSSL(shared_ptr cv, shared_ptr props) : m_sslctx(0), m_certVerifier(cv), m_props(props) { m_sslctx = SSL_CTX_new(SSLv23_client_method()); @@ -76,13 +76,13 @@ TLSSession_OpenSSL::~TLSSession_OpenSSL() } -ref TLSSession_OpenSSL::getSocket(ref sok) +shared_ptr TLSSession_OpenSSL::getSocket(shared_ptr sok) { - return TLSSocket::wrap(thisRef().dynamicCast (), sok); + return TLSSocket::wrap(dynamicCast (shared_from_this()), sok); } -ref TLSSession_OpenSSL::getCertificateVerifier() +shared_ptr TLSSession_OpenSSL::getCertificateVerifier() { return m_certVerifier; } diff --git a/src/net/tls/openssl/TLSSocket_OpenSSL.cpp b/src/net/tls/openssl/TLSSocket_OpenSSL.cpp index 7fda1f15..9aec43e5 100644 --- a/src/net/tls/openssl/TLSSocket_OpenSSL.cpp +++ b/src/net/tls/openssl/TLSSocket_OpenSSL.cpp @@ -65,14 +65,14 @@ BIO_METHOD TLSSocket_OpenSSL::sm_customBIOMethod = // static -ref TLSSocket::wrap(ref session, ref sok) +shared_ptr TLSSocket::wrap(shared_ptr session, shared_ptr sok) { - return vmime::create - (session.dynamicCast (), sok); + return make_shared + (dynamicCast (session), sok); } -TLSSocket_OpenSSL::TLSSocket_OpenSSL(ref session, ref sok) +TLSSocket_OpenSSL::TLSSocket_OpenSSL(shared_ptr session, shared_ptr sok) : m_session(session), m_wrapped(sok), m_connected(false), m_ssl(0), m_ex(NULL) { } @@ -128,7 +128,7 @@ void TLSSocket_OpenSSL::connect(const string& address, const port_t port) createSSLHandle(); - handshake(NULL); + handshake(null); m_connected = true; } @@ -224,7 +224,7 @@ TLSSocket_OpenSSL::size_type TLSSocket_OpenSSL::sendRawNonBlocking(const char* b } -void TLSSocket_OpenSSL::handshake(ref toHandler) +void TLSSocket_OpenSSL::handshake(shared_ptr toHandler) { if (toHandler) toHandler->resetTimeOut(); @@ -245,14 +245,14 @@ void TLSSocket_OpenSSL::handshake(ref toHandler) { SSL_free(m_ssl); m_ssl = 0; - m_toHandler = NULL; + m_toHandler = null; throw; } - m_toHandler = NULL; + m_toHandler = null; // Verify server's certificate(s) - ref certs = getPeerCertificates(); + shared_ptr certs = getPeerCertificates(); if (certs == NULL) throw exceptions::tls_exception("No peer certificate."); @@ -263,24 +263,24 @@ void TLSSocket_OpenSSL::handshake(ref toHandler) } -ref TLSSocket_OpenSSL::getPeerCertificates() const +shared_ptr TLSSocket_OpenSSL::getPeerCertificates() const { STACK_OF(X509)* chain = SSL_get_peer_cert_chain(m_ssl); if (chain == NULL) - return NULL; + return null; int certCount = sk_X509_num(chain); if (certCount == 0) - return NULL; + return null; bool error = false; - std::vector > certs; + std::vector > certs; for (int i = 0; i < certCount && !error; i++) { - ref cert = + shared_ptr cert = vmime::security::cert::X509Certificate_OpenSSL::importInternal(sk_X509_value(chain, i)); if (cert) @@ -290,9 +290,9 @@ ref TLSSocket_OpenSSL::getPeerCertificates() } if (error) - return NULL; + return null; - return vmime::create (certs); + return make_shared (certs); } diff --git a/src/net/transport.cpp b/src/net/transport.cpp index 88ea6773..eae4a024 100644 --- a/src/net/transport.cpp +++ b/src/net/transport.cpp @@ -43,33 +43,33 @@ namespace vmime { namespace net { -transport::transport(ref sess, const serviceInfos& infos, ref auth) +transport::transport(shared_ptr sess, const serviceInfos& infos, shared_ptr auth) : service(sess, infos, auth) { } -ref transport::processHeaderField(ref field) +shared_ptr transport::processHeaderField(shared_ptr field) { if (utility::stringUtils::isStringEqualNoCase(field->getName(), fields::BCC)) { // Remove Bcc headers from the message, as required by the RFC. // Some SMTP server automatically strip this header (Postfix, qmail), // and others have an option for this (Exim). - return NULL; + return null; } else if (utility::stringUtils::isStringEqualNoCase(field->getName(), fields::RETURN_PATH)) { // RFC-2821: Return-Path header is added by the final transport system // that delivers the message to its recipient. Then, it should not be // transmitted to MSA. - return NULL; + return null; } else if (utility::stringUtils::isStringEqualNoCase(field->getName(), fields::ORIGINAL_RECIPIENT)) { // RFC-2298: Delivering MTA may add the Original-Recipient header and // discard existing one; so, no need to send it. - return NULL; + return null; } // Leave the header field as is @@ -77,7 +77,7 @@ ref transport::processHeaderField(ref field) } -void transport::processHeader(ref
header) +void transport::processHeader(shared_ptr
header) { if (header->getFieldCount() == 0) return; @@ -85,8 +85,8 @@ void transport::processHeader(ref
header) // Remove/replace fields for (size_t idx = header->getFieldCount() ; idx != 0 ; --idx) { - ref field = header->getFieldAt(idx - 1); - ref newField = processHeaderField(field); + shared_ptr field = header->getFieldAt(idx - 1); + shared_ptr newField = processHeaderField(field); if (newField == NULL) header->removeField(field); @@ -114,7 +114,7 @@ static void extractMailboxes { for (size_t i = 0 ; i < list.getAddressCount() ; ++i) { - ref mbox = list.getAddressAt(i)->clone().dynamicCast (); + shared_ptr mbox = dynamicCast (list.getAddressAt(i)->clone()); if (mbox != NULL) recipients.appendMailbox(mbox); @@ -122,15 +122,15 @@ static void extractMailboxes } -void transport::send(ref msg, utility::progressListener* progress) +void transport::send(shared_ptr msg, utility::progressListener* progress) { // Extract expeditor mailbox expeditor; try { - const mailbox& mbox = *msg->getHeader()->findField(fields::FROM)-> - getValue().dynamicCast (); + const mailbox& mbox = + *msg->getHeader()->findField(fields::FROM)->getValue (); expeditor = mbox; } @@ -144,8 +144,8 @@ void transport::send(ref msg, utility::progressListener* progre try { - const mailbox& mbox = *msg->getHeader()->findField(fields::SENDER)-> - getValue().dynamicCast (); + const mailbox& mbox = + *msg->getHeader()->findField(fields::SENDER)->getValue (); sender = mbox; } @@ -159,8 +159,8 @@ void transport::send(ref msg, utility::progressListener* progre try { - const addressList& to = *msg->getHeader()->findField(fields::TO)-> - getValue().dynamicCast (); + const addressList& to = + *msg->getHeader()->findField(fields::TO)->getValue (); extractMailboxes(recipients, to); } @@ -168,8 +168,8 @@ void transport::send(ref msg, utility::progressListener* progre try { - const addressList& cc = *msg->getHeader()->findField(fields::CC)-> - getValue().dynamicCast (); + const addressList& cc = + *msg->getHeader()->findField(fields::CC)->getValue (); extractMailboxes(recipients, cc); } @@ -177,8 +177,8 @@ void transport::send(ref msg, utility::progressListener* progre try { - const addressList& bcc = *msg->getHeader()->findField(fields::BCC)-> - getValue().dynamicCast (); + const addressList& bcc = + *msg->getHeader()->findField(fields::BCC)->getValue (); extractMailboxes(recipients, bcc); } @@ -187,7 +187,7 @@ void transport::send(ref msg, utility::progressListener* progre // Process message header by removing fields that should be removed // before transmitting the message to MSA, and adding missing fields // which are required/recommended by the RFCs. - ref
hdr = msg->getHeader()->clone().dynamicCast
(); + shared_ptr
hdr = vmime::clone(msg->getHeader()); processHeader(hdr); // To avoid cloning message body (too much overhead), use processed @@ -195,8 +195,8 @@ void transport::send(ref msg, utility::progressListener* progre // Revert it back to original header after. struct XChangeMsgHeader { - XChangeMsgHeader(vmime::ref _msg, - vmime::ref _hdr) + XChangeMsgHeader(shared_ptr _msg, + shared_ptr _hdr) : msg(_msg), hdr(msg->getHeader()) { // Set new header @@ -211,8 +211,8 @@ void transport::send(ref msg, utility::progressListener* progre private: - vmime::ref msg; - vmime::ref hdr; + shared_ptr msg; + shared_ptr hdr; } headerExchanger(msg, hdr); send(msg, expeditor, recipients, progress, sender); @@ -220,7 +220,7 @@ void transport::send(ref msg, utility::progressListener* progre void transport::send - (ref msg, const mailbox& expeditor, const mailboxList& recipients, + (shared_ptr msg, const mailbox& expeditor, const mailboxList& recipients, utility::progressListener* progress, const mailbox& sender) { // Generate the message, "stream" it and delegate the sending diff --git a/src/object.cpp b/src/object.cpp index 1b50c53c..d07c3c19 100644 --- a/src/object.cpp +++ b/src/object.cpp @@ -25,79 +25,29 @@ #include "vmime/object.hpp" -#ifndef VMIME_BUILDING_DOC - - namespace vmime { object::object() - : m_refMgr(utility::refManager::create(this)) { } object::object(const object&) - : m_refMgr(utility::refManager::create(this)) { } object& object::operator=(const object&) { - // Do _NOT_ copy 'm_refMgr' return *this; } object::~object() { - delete m_refMgr; - m_refMgr = 0; -} - - -ref object::thisRef() -{ - m_refMgr->addStrong(); - return ref ::fromPtr(this); -} - - -ref object::thisRef() const -{ - m_refMgr->addStrong(); - return ref ::fromPtr(this); -} - - -weak_ref object::thisWeakRef() -{ - return weak_ref (thisRef()); -} - - -weak_ref object::thisWeakRef() const -{ - return weak_ref (thisRef()); -} - - -void object::setRefManager(utility::refManager* mgr) -{ - m_refMgr = mgr; -} - - -utility::refManager* object::getRefManager() const -{ - return m_refMgr; } } // vmime - - -#endif // VMIME_BUILDING_DOC - diff --git a/src/parameter.cpp b/src/parameter.cpp index 901139e3..d7fcd7d3 100644 --- a/src/parameter.cpp +++ b/src/parameter.cpp @@ -36,19 +36,19 @@ namespace vmime parameter::parameter(const string& name) - : m_name(name), m_value(vmime::create ()) + : m_name(name), m_value(make_shared ()) { } parameter::parameter(const string& name, const word& value) - : m_name(name), m_value(vmime::create (value)) + : m_name(name), m_value(make_shared (value)) { } parameter::parameter(const string& name, const string& value) - : m_name(name), m_value(vmime::create (value)) + : m_name(name), m_value(make_shared (value)) { } @@ -59,9 +59,9 @@ parameter::parameter(const parameter&) } -ref parameter::clone() const +shared_ptr parameter::clone() const { - ref p = vmime::create (m_name); + shared_ptr p = make_shared (m_name); p->copyFrom(*this); return (p); @@ -589,9 +589,9 @@ void parameter::generateImpl } -const std::vector > parameter::getChildComponents() +const std::vector > parameter::getChildComponents() { - std::vector > list; + std::vector > list; list.push_back(m_value); diff --git a/src/parameterizedHeaderField.cpp b/src/parameterizedHeaderField.cpp index c4e0b368..b329d1c1 100644 --- a/src/parameterizedHeaderField.cpp +++ b/src/parameterizedHeaderField.cpp @@ -321,7 +321,7 @@ void parameterizedHeaderField::parseImpl const paramInfo& info = (*it).second; // Append this parameter to the list - ref param = vmime::create ((*it).first); + shared_ptr param = make_shared ((*it).first); param->parse(ctx, info.value); param->setParsedBounds(info.start, info.end); @@ -345,7 +345,7 @@ void parameterizedHeaderField::generateImpl headerField::generateImpl(ctx, os, pos, &pos); // Parameters - for (std::vector >::const_iterator + for (std::vector >::const_iterator it = m_params.begin() ; it != m_params.end() ; ++it) { os << "; "; @@ -367,10 +367,10 @@ void parameterizedHeaderField::copyFrom(const component& other) removeAllParameters(); - for (std::vector >::const_iterator i = source.m_params.begin() ; + for (std::vector >::const_iterator i = source.m_params.begin() ; i != source.m_params.end() ; ++i) { - appendParameter((*i)->clone().dynamicCast ()); + appendParameter(vmime::clone(*i)); } } @@ -386,8 +386,8 @@ bool parameterizedHeaderField::hasParameter(const string& paramName) const { const string name = utility::stringUtils::toLower(paramName); - std::vector >::const_iterator pos = m_params.begin(); - const std::vector >::const_iterator end = m_params.end(); + std::vector >::const_iterator pos = m_params.begin(); + const std::vector >::const_iterator end = m_params.end(); for ( ; pos != end && utility::stringUtils::toLower((*pos)->getName()) != name ; ++pos) {} @@ -395,13 +395,13 @@ bool parameterizedHeaderField::hasParameter(const string& paramName) const } -ref parameterizedHeaderField::findParameter(const string& paramName) const +shared_ptr parameterizedHeaderField::findParameter(const string& paramName) const { const string name = utility::stringUtils::toLower(paramName); // Find the first parameter that matches the specified name - std::vector >::const_iterator pos = m_params.begin(); - const std::vector >::const_iterator end = m_params.end(); + std::vector >::const_iterator pos = m_params.begin(); + const std::vector >::const_iterator end = m_params.end(); for ( ; pos != end && utility::stringUtils::toLower((*pos)->getName()) != name ; ++pos) {} @@ -418,20 +418,20 @@ ref parameterizedHeaderField::findParameter(const string& paramName) } -ref parameterizedHeaderField::getParameter(const string& paramName) +shared_ptr parameterizedHeaderField::getParameter(const string& paramName) { const string name = utility::stringUtils::toLower(paramName); // Find the first parameter that matches the specified name - std::vector >::const_iterator pos = m_params.begin(); - const std::vector >::const_iterator end = m_params.end(); + std::vector >::const_iterator pos = m_params.begin(); + const std::vector >::const_iterator end = m_params.end(); for ( ; pos != end && utility::stringUtils::toLower((*pos)->getName()) != name ; ++pos) {} // If no parameter with this name can be found, create a new one if (pos == end) { - ref param = vmime::create (paramName); + shared_ptr param = make_shared (paramName); appendParameter(param); @@ -446,15 +446,15 @@ ref parameterizedHeaderField::getParameter(const string& paramName) } -void parameterizedHeaderField::appendParameter(ref param) +void parameterizedHeaderField::appendParameter(shared_ptr param) { m_params.push_back(param); } -void parameterizedHeaderField::insertParameterBefore(ref beforeParam, ref param) +void parameterizedHeaderField::insertParameterBefore(shared_ptr beforeParam, shared_ptr param) { - const std::vector >::iterator it = std::find + const std::vector >::iterator it = std::find (m_params.begin(), m_params.end(), beforeParam); if (it == m_params.end()) @@ -464,15 +464,15 @@ void parameterizedHeaderField::insertParameterBefore(ref beforeParam } -void parameterizedHeaderField::insertParameterBefore(const size_t pos, ref param) +void parameterizedHeaderField::insertParameterBefore(const size_t pos, shared_ptr param) { m_params.insert(m_params.begin() + pos, param); } -void parameterizedHeaderField::insertParameterAfter(ref afterParam, ref param) +void parameterizedHeaderField::insertParameterAfter(shared_ptr afterParam, shared_ptr param) { - const std::vector >::iterator it = std::find + const std::vector >::iterator it = std::find (m_params.begin(), m_params.end(), afterParam); if (it == m_params.end()) @@ -482,15 +482,15 @@ void parameterizedHeaderField::insertParameterAfter(ref afterParam, } -void parameterizedHeaderField::insertParameterAfter(const size_t pos, ref param) +void parameterizedHeaderField::insertParameterAfter(const size_t pos, shared_ptr param) { m_params.insert(m_params.begin() + pos + 1, param); } -void parameterizedHeaderField::removeParameter(ref param) +void parameterizedHeaderField::removeParameter(shared_ptr param) { - const std::vector >::iterator it = std::find + const std::vector >::iterator it = std::find (m_params.begin(), m_params.end(), param); if (it == m_params.end()) @@ -502,7 +502,7 @@ void parameterizedHeaderField::removeParameter(ref param) void parameterizedHeaderField::removeParameter(const size_t pos) { - const std::vector >::iterator it = m_params.begin() + pos; + const std::vector >::iterator it = m_params.begin() + pos; m_params.erase(it); } @@ -526,25 +526,25 @@ bool parameterizedHeaderField::isEmpty() const } -const ref parameterizedHeaderField::getParameterAt(const size_t pos) +const shared_ptr parameterizedHeaderField::getParameterAt(const size_t pos) { return (m_params[pos]); } -const ref parameterizedHeaderField::getParameterAt(const size_t pos) const +const shared_ptr parameterizedHeaderField::getParameterAt(const size_t pos) const { return (m_params[pos]); } -const std::vector > parameterizedHeaderField::getParameterList() const +const std::vector > parameterizedHeaderField::getParameterList() const { - std::vector > list; + std::vector > list; list.reserve(m_params.size()); - for (std::vector >::const_iterator it = m_params.begin() ; + for (std::vector >::const_iterator it = m_params.begin() ; it != m_params.end() ; ++it) { list.push_back(*it); @@ -554,17 +554,17 @@ const std::vector > parameterizedHeaderField::getParamete } -const std::vector > parameterizedHeaderField::getParameterList() +const std::vector > parameterizedHeaderField::getParameterList() { return (m_params); } -const std::vector > parameterizedHeaderField::getChildComponents() +const std::vector > parameterizedHeaderField::getChildComponents() { - std::vector > list = headerField::getChildComponents(); + std::vector > list = headerField::getChildComponents(); - for (std::vector >::iterator it = m_params.begin() ; + for (std::vector >::iterator it = m_params.begin() ; it != m_params.end() ; ++it) { list.push_back(*it); diff --git a/src/parsedMessageAttachment.cpp b/src/parsedMessageAttachment.cpp index bf58a713..242bfde0 100644 --- a/src/parsedMessageAttachment.cpp +++ b/src/parsedMessageAttachment.cpp @@ -33,7 +33,7 @@ namespace vmime { -parsedMessageAttachment::parsedMessageAttachment(ref msg) +parsedMessageAttachment::parsedMessageAttachment(shared_ptr msg) : m_msg(msg) { } @@ -57,7 +57,7 @@ const word parsedMessageAttachment::getName() const } -const ref parsedMessageAttachment::getData() const +const shared_ptr parsedMessageAttachment::getData() const { if (m_data == NULL) { @@ -66,7 +66,7 @@ const ref parsedMessageAttachment::getData() const m_msg->generate(os); - m_data = vmime::create (oss.str()); + m_data = make_shared (oss.str()); } return m_data; @@ -79,28 +79,28 @@ const encoding parsedMessageAttachment::getEncoding() const } -ref parsedMessageAttachment::getPart() const +shared_ptr parsedMessageAttachment::getPart() const { - return NULL; + return null; } -ref parsedMessageAttachment::getHeader() const +shared_ptr parsedMessageAttachment::getHeader() const { - return NULL; + return null; } -ref parsedMessageAttachment::getMessage() const +shared_ptr parsedMessageAttachment::getMessage() const { return m_msg; } -void parsedMessageAttachment::generateIn(ref parent) const +void parsedMessageAttachment::generateIn(shared_ptr parent) const { // Create and append a new part for this attachment - ref part = vmime::create (); + shared_ptr part = make_shared (); parent->getBody()->appendPart(part); // Set header fields diff --git a/src/path.cpp b/src/path.cpp index 3e6e7a84..8722c9a7 100644 --- a/src/path.cpp +++ b/src/path.cpp @@ -93,9 +93,9 @@ void path::copyFrom(const component& other) } -ref path::clone() const +shared_ptr path::clone() const { - return vmime::create (*this); + return make_shared (*this); } @@ -106,9 +106,9 @@ path& path::operator=(const path& other) } -const std::vector > path::getChildComponents() +const std::vector > path::getChildComponents() { - return std::vector >(); + return std::vector >(); } diff --git a/src/plainTextPart.cpp b/src/plainTextPart.cpp index c26e146e..e1959af1 100644 --- a/src/plainTextPart.cpp +++ b/src/plainTextPart.cpp @@ -35,7 +35,7 @@ namespace vmime plainTextPart::plainTextPart() - : m_text(vmime::create ()) + : m_text(make_shared ()) { } @@ -57,10 +57,10 @@ size_t plainTextPart::getPartCount() const } -void plainTextPart::generateIn(ref /* message */, ref parent) const +void plainTextPart::generateIn(shared_ptr /* message */, shared_ptr parent) const { // Create a new part - ref part = vmime::create (); + shared_ptr part = make_shared (); parent->getBody()->appendPart(part); // Set contents @@ -70,15 +70,15 @@ void plainTextPart::generateIn(ref /* message */, ref pare } -void plainTextPart::parse(ref /* message */, - ref /* parent */, ref textPart) +void plainTextPart::parse(shared_ptr /* message */, + shared_ptr /* parent */, shared_ptr textPart) { - m_text = textPart->getBody()->getContents()->clone().dynamicCast (); + m_text = vmime::clone(textPart->getBody()->getContents()); try { - const contentTypeField& ctf = dynamic_cast - (*textPart->getHeader()->findField(fields::CONTENT_TYPE)); + const contentTypeField& ctf = + *textPart->getHeader()->findField (fields::CONTENT_TYPE); m_charset = ctf.getCharset(); } @@ -105,15 +105,15 @@ void plainTextPart::setCharset(const charset& ch) } -const ref plainTextPart::getText() const +const shared_ptr plainTextPart::getText() const { return (m_text); } -void plainTextPart::setText(ref text) +void plainTextPart::setText(shared_ptr text) { - m_text = text->clone().dynamicCast (); + m_text = vmime::clone(text); } diff --git a/src/platform.cpp b/src/platform.cpp index 37c7b027..631d5bcf 100644 --- a/src/platform.cpp +++ b/src/platform.cpp @@ -32,7 +32,7 @@ namespace vmime { -ref platform::sm_handler = NULL; +shared_ptr platform::sm_handler; platform::handler::~handler() @@ -41,29 +41,29 @@ platform::handler::~handler() // static -ref platform::getDefaultHandler() +shared_ptr platform::getDefaultHandler() { #if VMIME_PLATFORM_IS_WINDOWS - return vmime::create (); + return make_shared (); #elif VMIME_PLATFORM_IS_POSIX - return vmime::create (); + return make_shared (); #else - return NULL; + return null; #endif } // static -ref platform::getHandler() +shared_ptr platform::getHandler() { // If a custom platform handler is installed, return it if (sm_handler) return sm_handler; // Else, use the default handler for this platform - ref defaultHandler = getDefaultHandler(); + shared_ptr defaultHandler = getDefaultHandler(); if (defaultHandler) { diff --git a/src/platforms/posix/posixChildProcess.cpp b/src/platforms/posix/posixChildProcess.cpp index 09119996..c4761624 100644 --- a/src/platforms/posix/posixChildProcess.cpp +++ b/src/platforms/posix/posixChildProcess.cpp @@ -32,8 +32,6 @@ #include "vmime/exception.hpp" -#include "vmime/utility/smartPtr.hpp" - #include #include #include @@ -49,9 +47,9 @@ namespace posix { // posixChildProcessFactory -ref posixChildProcessFactory::create(const utility::file::path& path) const +shared_ptr posixChildProcessFactory::create(const utility::file::path& path) const { - return vmime::create (path); + return make_shared (path); } @@ -215,7 +213,7 @@ private: posixChildProcess::posixChildProcess(const utility::file::path& path) : m_processPath(path), m_started(false), - m_stdIn(NULL), m_stdOut(NULL), m_pid(0), m_argArray(NULL) + m_stdIn(null), m_stdOut(null), m_pid(0), m_argArray(NULL) { m_pipe[0] = 0; m_pipe[1] = 0; @@ -319,7 +317,7 @@ void posixChildProcess::start(const std::vector args, const int flags) if (flags & FLAG_REDIRECT_STDIN) { - m_stdIn = vmime::create (m_pipe[1]); + m_stdIn = make_shared (m_pipe[1]); } else { @@ -329,7 +327,7 @@ void posixChildProcess::start(const std::vector args, const int flags) if (flags & FLAG_REDIRECT_STDOUT) { - m_stdOut = vmime::create (m_pipe[0]); + m_stdOut = make_shared (m_pipe[0]); } else { @@ -342,13 +340,13 @@ void posixChildProcess::start(const std::vector args, const int flags) } -ref posixChildProcess::getStdIn() +shared_ptr posixChildProcess::getStdIn() { return (m_stdIn); } -ref posixChildProcess::getStdOut() +shared_ptr posixChildProcess::getStdOut() { return (m_stdOut); } @@ -377,8 +375,7 @@ void posixChildProcess::waitForFinish() { if (WEXITSTATUS(wstat) == 255) { - vmime::utility::auto_ptr pfsf - = new posixFileSystemFactory(); + std::auto_ptr pfsf(new posixFileSystemFactory()); throw exceptions::system_error("Could not execute '" + pfsf->pathToString(m_processPath) + "'"); diff --git a/src/platforms/posix/posixFile.cpp b/src/platforms/posix/posixFile.cpp index 744f01ff..1e4dd070 100644 --- a/src/platforms/posix/posixFile.cpp +++ b/src/platforms/posix/posixFile.cpp @@ -79,9 +79,9 @@ bool posixFileIterator::hasMoreElements() const } -ref posixFileIterator::nextElement() +shared_ptr posixFileIterator::nextElement() { - ref file = vmime::create + shared_ptr file = make_shared (m_path / vmime::utility::file::path::component(m_dirEntry->d_name)); getNextElement(); @@ -258,14 +258,14 @@ posixFileWriter::posixFileWriter(const vmime::utility::file::path& path, const v } -ref posixFileWriter::getOutputStream() +shared_ptr posixFileWriter::getOutputStream() { int fd = 0; if ((fd = ::open(m_nativePath.c_str(), O_WRONLY, 0660)) == -1) posixFileSystemFactory::reportError(m_path, errno); - return vmime::create (m_path, fd); + return make_shared (m_path, fd); } @@ -280,14 +280,14 @@ posixFileReader::posixFileReader(const vmime::utility::file::path& path, const v } -ref posixFileReader::getInputStream() +shared_ptr posixFileReader::getInputStream() { int fd = 0; if ((fd = ::open(m_nativePath.c_str(), O_RDONLY, 0640)) == -1) posixFileSystemFactory::reportError(m_path, errno); - return vmime::create (m_path, fd); + return make_shared (m_path, fd); } @@ -417,12 +417,12 @@ bool posixFile::exists() const } -ref posixFile::getParent() const +shared_ptr posixFile::getParent() const { if (m_path.isEmpty()) - return NULL; + return null; else - return vmime::create (m_path.getParent()); + return make_shared (m_path.getParent()); } @@ -465,24 +465,24 @@ void posixFile::remove() } -ref posixFile::getFileWriter() +shared_ptr posixFile::getFileWriter() { - return vmime::create (m_path, m_nativePath); + return make_shared (m_path, m_nativePath); } -ref posixFile::getFileReader() +shared_ptr posixFile::getFileReader() { - return vmime::create (m_path, m_nativePath); + return make_shared (m_path, m_nativePath); } -ref posixFile::getFiles() const +shared_ptr posixFile::getFiles() const { if (!isDirectory()) throw vmime::exceptions::not_a_directory(m_path); - return vmime::create (m_path, m_nativePath); + return make_shared (m_path, m_nativePath); } @@ -508,9 +508,9 @@ void posixFile::createDirectoryImpl(const vmime::utility::file::path& fullPath, // posixFileSystemFactory // -ref posixFileSystemFactory::create(const vmime::utility::file::path& path) const +shared_ptr posixFileSystemFactory::create(const vmime::utility::file::path& path) const { - return vmime::create (path); + return make_shared (path); } diff --git a/src/platforms/posix/posixHandler.cpp b/src/platforms/posix/posixHandler.cpp index 73005d7e..b5d08ce6 100644 --- a/src/platforms/posix/posixHandler.cpp +++ b/src/platforms/posix/posixHandler.cpp @@ -109,11 +109,11 @@ namespace posix { posixHandler::posixHandler() { #if VMIME_HAVE_MESSAGING_FEATURES - m_socketFactory = vmime::create (); + m_socketFactory = make_shared (); #endif #if VMIME_HAVE_FILESYSTEM_FEATURES - m_fileSysFactory = vmime::create (); - m_childProcFactory = vmime::create (); + m_fileSysFactory = make_shared (); + m_childProcFactory = make_shared (); #endif } @@ -249,7 +249,7 @@ unsigned int posixHandler::getThreadId() const #if VMIME_HAVE_MESSAGING_FEATURES -ref posixHandler::getSocketFactory() +shared_ptr posixHandler::getSocketFactory() { return m_socketFactory; } @@ -259,13 +259,13 @@ ref posixHandler::getSocketFactory() #if VMIME_HAVE_FILESYSTEM_FEATURES -ref posixHandler::getFileSystemFactory() +shared_ptr posixHandler::getFileSystemFactory() { return m_fileSysFactory; } -ref posixHandler::getChildProcessFactory() +shared_ptr posixHandler::getChildProcessFactory() { return m_childProcFactory; } @@ -308,9 +308,9 @@ void posixHandler::generateRandomBytes(unsigned char* buffer, const unsigned int } -ref posixHandler::createCriticalSection() +shared_ptr posixHandler::createCriticalSection() { - return vmime::create (); + return make_shared (); } diff --git a/src/platforms/posix/posixSocket.cpp b/src/platforms/posix/posixSocket.cpp index bee9f89e..e0bcf03a 100644 --- a/src/platforms/posix/posixSocket.cpp +++ b/src/platforms/posix/posixSocket.cpp @@ -59,7 +59,7 @@ namespace posix { // posixSocket // -posixSocket::posixSocket(ref th) +posixSocket::posixSocket(shared_ptr th) : m_timeoutHandler(th), m_desc(-1), m_status(0) { } @@ -631,16 +631,16 @@ unsigned int posixSocket::getStatus() const // posixSocketFactory // -ref posixSocketFactory::create() +shared_ptr posixSocketFactory::create() { - ref th = NULL; - return vmime::create (th); + shared_ptr th; + return make_shared (th); } -ref posixSocketFactory::create(ref th) +shared_ptr posixSocketFactory::create(shared_ptr th) { - return vmime::create (th); + return make_shared (th); } diff --git a/src/platforms/windows/windowsFile.cpp b/src/platforms/windows/windowsFile.cpp index fd8a9651..8d2a19da 100644 --- a/src/platforms/windows/windowsFile.cpp +++ b/src/platforms/windows/windowsFile.cpp @@ -41,9 +41,9 @@ namespace platforms { namespace windows { -ref windowsFileSystemFactory::create(const vmime::utility::file::path& path) const +shared_ptr windowsFileSystemFactory::create(const vmime::utility::file::path& path) const { - return vmime::create (path); + return make_shared (path); } @@ -307,12 +307,12 @@ bool windowsFile::exists() const return false; } -ref windowsFile::getParent() const +shared_ptr windowsFile::getParent() const { if (m_path.isEmpty()) return NULL; else - return vmime::create (m_path.getParent()); + return make_shared (m_path.getParent()); } void windowsFile::rename(const path& newName) @@ -333,19 +333,19 @@ void windowsFile::remove() windowsFileSystemFactory::reportError(m_path, GetLastError()); } -ref windowsFile::getFileWriter() +shared_ptr windowsFile::getFileWriter() { - return vmime::create (m_path, m_nativePath); + return make_shared (m_path, m_nativePath); } -ref windowsFile::getFileReader() +shared_ptr windowsFile::getFileReader() { - return vmime::create (m_path, m_nativePath); + return make_shared (m_path, m_nativePath); } -ref windowsFile::getFiles() const +shared_ptr windowsFile::getFiles() const { - return vmime::create (m_path, m_nativePath); + return make_shared (m_path, m_nativePath); } void windowsFile::createDirectoryImpl(const vmime::utility::file::path& fullPath, const vmime::utility::file::path& path, const bool recursive) @@ -380,9 +380,9 @@ bool windowsFileIterator::hasMoreElements() const return m_moreElements; } -ref windowsFileIterator::nextElement() +shared_ptr windowsFileIterator::nextElement() { - ref pFile = vmime::create + shared_ptr pFile = make_shared (m_path / vmime::utility::file::path::component(m_findData.cFileName)); findNext(); @@ -430,7 +430,7 @@ windowsFileReader::windowsFileReader(const vmime::utility::file::path& path, con { } -ref windowsFileReader::getInputStream() +shared_ptr windowsFileReader::getInputStream() { HANDLE hFile = CreateFile( m_nativePath.c_str(), @@ -442,7 +442,7 @@ ref windowsFileReader::getInputStream() NULL); if (hFile == INVALID_HANDLE_VALUE) windowsFileSystemFactory::reportError(m_path, GetLastError()); - return vmime::create (m_path, hFile); + return make_shared (m_path, hFile); } windowsFileReaderInputStream::windowsFileReaderInputStream(const vmime::utility::file::path& path, HANDLE hFile) @@ -505,7 +505,7 @@ windowsFileWriter::windowsFileWriter(const vmime::utility::file::path& path, con { } -ref windowsFileWriter::getOutputStream() +shared_ptr windowsFileWriter::getOutputStream() { HANDLE hFile = CreateFile( m_nativePath.c_str(), @@ -517,7 +517,7 @@ ref windowsFileWriter::getOutputStream() NULL); if (hFile == INVALID_HANDLE_VALUE) windowsFileSystemFactory::reportError(m_path, GetLastError()); - return vmime::create (m_path, hFile); + return make_shared (m_path, hFile); } windowsFileWriterOutputStream::windowsFileWriterOutputStream(const vmime::utility::file::path& path, HANDLE hFile) diff --git a/src/platforms/windows/windowsHandler.cpp b/src/platforms/windows/windowsHandler.cpp index d4027801..5b9c37ce 100644 --- a/src/platforms/windows/windowsHandler.cpp +++ b/src/platforms/windows/windowsHandler.cpp @@ -57,10 +57,10 @@ windowsHandler::windowsHandler() WSAStartup(MAKEWORD(1, 1), &wsaData); #if VMIME_HAVE_MESSAGING_FEATURES - m_socketFactory = vmime::create (); + m_socketFactory = make_shared (); #endif #if VMIME_HAVE_FILESYSTEM_FEATURES - m_fileSysFactory = vmime::create (); + m_fileSysFactory = make_shared (); #endif } @@ -274,7 +274,7 @@ unsigned int windowsHandler::getThreadId() const #if VMIME_HAVE_MESSAGING_FEATURES -ref windowsHandler::getSocketFactory() +shared_ptr windowsHandler::getSocketFactory() { return m_socketFactory; } @@ -284,13 +284,13 @@ ref windowsHandler::getSocketFactory() #if VMIME_HAVE_FILESYSTEM_FEATURES -ref windowsHandler::getFileSystemFactory() +shared_ptr windowsHandler::getFileSystemFactory() { return m_fileSysFactory; } -ref windowsHandler::getChildProcessFactory() +shared_ptr windowsHandler::getChildProcessFactory() { // TODO: Not implemented return (NULL); @@ -314,9 +314,9 @@ void windowsHandler::generateRandomBytes(unsigned char* buffer, const unsigned i } -ref windowsHandler::createCriticalSection() +shared_ptr windowsHandler::createCriticalSection() { - return vmime::create (); + return make_shared (); } diff --git a/src/platforms/windows/windowsSocket.cpp b/src/platforms/windows/windowsSocket.cpp index dc932965..502d1067 100644 --- a/src/platforms/windows/windowsSocket.cpp +++ b/src/platforms/windows/windowsSocket.cpp @@ -45,7 +45,7 @@ namespace windows { // windowsSocket // -windowsSocket::windowsSocket(ref th) +windowsSocket::windowsSocket(shared_ptr th) : m_timeoutHandler(th), m_desc(INVALID_SOCKET), m_status(0) { WSAData wsaData; @@ -438,15 +438,15 @@ void windowsSocket::waitForData(const WaitOpType t, bool& timedOut) // posixSocketFactory // -ref windowsSocketFactory::create() +shared_ptr windowsSocketFactory::create() { - ref th = NULL; - return vmime::create (th); + shared_ptr th = NULL; + return make_shared (th); } -ref windowsSocketFactory::create(ref th) +shared_ptr windowsSocketFactory::create(shared_ptr th) { - return vmime::create (th); + return make_shared (th); } } // posix diff --git a/src/propertySet.cpp b/src/propertySet.cpp index 284f3eaa..151c3e12 100644 --- a/src/propertySet.cpp +++ b/src/propertySet.cpp @@ -43,8 +43,8 @@ propertySet::propertySet(const string& props) propertySet::propertySet(const propertySet& set) : object() { - for (std::list >::const_iterator it = set.m_props.begin() ; it != set.m_props.end() ; ++it) - m_props.push_back(vmime::create (**it)); + for (std::list >::const_iterator it = set.m_props.begin() ; it != set.m_props.end() ; ++it) + m_props.push_back(make_shared (**it)); } @@ -58,8 +58,8 @@ propertySet& propertySet::operator=(const propertySet& set) { removeAllProperties(); - for (std::list >::const_iterator it = set.m_props.begin() ; it != set.m_props.end() ; ++it) - m_props.push_back(vmime::create (**it)); + for (std::list >::const_iterator it = set.m_props.begin() ; it != set.m_props.end() ; ++it) + m_props.push_back(make_shared (**it)); return (*this); } @@ -79,7 +79,7 @@ void propertySet::removeAllProperties() void propertySet::removeProperty(const string& name) { - std::list >::iterator it = std::find_if + std::list >::iterator it = std::find_if (m_props.begin(), m_props.end(), propFinder(name)); if (it != m_props.end()) @@ -174,24 +174,24 @@ void propertySet::parse(const string& props) } } - m_props.push_back(vmime::create (option, value)); + m_props.push_back(make_shared (option, value)); } } } -ref propertySet::find(const string& name) const +shared_ptr propertySet::find(const string& name) const { - std::list >::const_iterator it = std::find_if + std::list >::const_iterator it = std::find_if (m_props.begin(), m_props.end(), propFinder(name)); - return (it != m_props.end() ? *it : NULL); + return (it != m_props.end() ? *it : null); } -ref propertySet::findOrCreate(const string& name) +shared_ptr propertySet::findOrCreate(const string& name) { - std::list >::const_iterator it = std::find_if + std::list >::const_iterator it = std::find_if (m_props.begin(), m_props.end(), propFinder(name)); if (it != m_props.end()) @@ -200,7 +200,7 @@ ref propertySet::findOrCreate(const string& name) } else { - ref prop = vmime::create (name, ""); + shared_ptr prop = make_shared (name, ""); m_props.push_back(prop); return (prop); } @@ -225,9 +225,9 @@ bool propertySet::hasProperty(const string& name) const } -const std::vector > propertySet::getPropertyList() const +const std::vector > propertySet::getPropertyList() const { - std::vector > res; + std::vector > res; for (list_type::const_iterator it = m_props.begin() ; it != m_props.end() ; ++it) res.push_back(*it); @@ -236,9 +236,9 @@ const std::vector > propertySet::getPropertyL } -const std::vector > propertySet::getPropertyList() +const std::vector > propertySet::getPropertyList() { - std::vector > res; + std::vector > res; for (list_type::const_iterator it = m_props.begin() ; it != m_props.end() ; ++it) res.push_back(*it); diff --git a/src/relay.cpp b/src/relay.cpp index 90957dbe..327118c5 100644 --- a/src/relay.cpp +++ b/src/relay.cpp @@ -254,9 +254,9 @@ relay& relay::operator=(const relay& other) } -ref relay::clone() const +shared_ptr relay::clone() const { - return vmime::create (*this); + return make_shared (*this); } @@ -344,10 +344,10 @@ std::vector & relay::getWithList() } -const std::vector > relay::getChildComponents() +const std::vector > relay::getChildComponents() { // TODO: should fields inherit from 'component'? (using typeAdapter) - return std::vector >(); + return std::vector >(); } diff --git a/src/security/cert/certificateChain.cpp b/src/security/cert/certificateChain.cpp index ab12453e..3cb4e360 100644 --- a/src/security/cert/certificateChain.cpp +++ b/src/security/cert/certificateChain.cpp @@ -29,7 +29,7 @@ namespace security { namespace cert { -certificateChain::certificateChain(const std::vector >& certs) +certificateChain::certificateChain(const std::vector >& certs) : m_certs(certs) { } @@ -41,7 +41,7 @@ unsigned int certificateChain::getCount() const } -ref certificateChain::getAt(const unsigned int index) +shared_ptr certificateChain::getAt(const unsigned int index) { return m_certs[index]; } diff --git a/src/security/cert/defaultCertificateVerifier.cpp b/src/security/cert/defaultCertificateVerifier.cpp index bb185f36..1a95b353 100644 --- a/src/security/cert/defaultCertificateVerifier.cpp +++ b/src/security/cert/defaultCertificateVerifier.cpp @@ -55,7 +55,7 @@ defaultCertificateVerifier::defaultCertificateVerifier(const defaultCertificateV void defaultCertificateVerifier::verify - (ref chain, const string& hostname) + (shared_ptr chain, const string& hostname) { if (chain->getCount() == 0) return; @@ -70,7 +70,7 @@ void defaultCertificateVerifier::verify void defaultCertificateVerifier::verifyX509 - (ref chain, const string& hostname) + (shared_ptr chain, const string& hostname) { // For every certificate in the chain, verify that the certificate // has been issued by the next certificate in the chain @@ -78,11 +78,11 @@ void defaultCertificateVerifier::verifyX509 { for (unsigned int i = 0 ; i < chain->getCount() - 1 ; ++i) { - ref cert = - chain->getAt(i).dynamicCast (); + shared_ptr cert = + dynamicCast (chain->getAt(i)); - ref next = - chain->getAt(i + 1).dynamicCast (); + shared_ptr next = + dynamicCast (chain->getAt(i + 1)); if (!cert->checkIssuer(next)) { @@ -98,8 +98,8 @@ void defaultCertificateVerifier::verifyX509 for (unsigned int i = 0 ; i < chain->getCount() ; ++i) { - ref cert = - chain->getAt(i).dynamicCast (); + shared_ptr cert = + dynamicCast (chain->getAt(i)); const datetime begin = cert->getActivationDate(); const datetime end = cert->getExpirationDate(); @@ -115,14 +115,14 @@ void defaultCertificateVerifier::verifyX509 // -- First, verify that the the last certificate in the chain was // -- issued by a third-party that we trust - ref lastCert = - chain->getAt(chain->getCount() - 1).dynamicCast (); + shared_ptr lastCert = + dynamicCast (chain->getAt(chain->getCount() - 1)); bool trusted = false; for (unsigned int i = 0 ; !trusted && i < m_x509RootCAs.size() ; ++i) { - ref rootCa = m_x509RootCAs[i]; + shared_ptr rootCa = m_x509RootCAs[i]; if (lastCert->verify(rootCa)) trusted = true; @@ -131,12 +131,12 @@ void defaultCertificateVerifier::verifyX509 // -- Next, if the issuer certificate cannot be verified against // -- root CAs, compare the subject's certificate against the // -- trusted certificates - ref firstCert = - chain->getAt(0).dynamicCast (); + shared_ptr firstCert = + dynamicCast (chain->getAt(0)); for (unsigned int i = 0 ; !trusted && i < m_x509TrustedCerts.size() ; ++i) { - ref cert = m_x509TrustedCerts[i]; + shared_ptr cert = m_x509TrustedCerts[i]; if (firstCert->equals(cert)) trusted = true; @@ -158,14 +158,14 @@ void defaultCertificateVerifier::verifyX509 void defaultCertificateVerifier::setX509RootCAs - (const std::vector >& caCerts) + (const std::vector >& caCerts) { m_x509RootCAs = caCerts; } void defaultCertificateVerifier::setX509TrustedCerts - (const std::vector >& trustedCerts) + (const std::vector >& trustedCerts) { m_x509TrustedCerts = trustedCerts; } diff --git a/src/security/cert/gnutls/X509Certificate_GnuTLS.cpp b/src/security/cert/gnutls/X509Certificate_GnuTLS.cpp index 96137844..327ddefa 100644 --- a/src/security/cert/gnutls/X509Certificate_GnuTLS.cpp +++ b/src/security/cert/gnutls/X509Certificate_GnuTLS.cpp @@ -89,7 +89,7 @@ void* X509Certificate_GnuTLS::getInternalData() // static -ref X509Certificate::import(utility::inputStream& is) +shared_ptr X509Certificate::import(utility::inputStream& is) { byteArray bytes; utility::stream::value_type chunk[4096]; @@ -105,7 +105,7 @@ ref X509Certificate::import(utility::inputStream& is) // static -ref X509Certificate::import +shared_ptr X509Certificate::import (const byte_t* data, const size_t length) { gnutls_datum buffer; @@ -113,18 +113,18 @@ ref X509Certificate::import buffer.size = static_cast (length); // Try DER format - ref derCert = vmime::create (); + shared_ptr derCert = make_shared (); if (gnutls_x509_crt_import(derCert->m_data->cert, &buffer, GNUTLS_X509_FMT_DER) >= 0) return derCert; // Try PEM format - ref pemCert = vmime::create (); + shared_ptr pemCert = make_shared (); if (gnutls_x509_crt_import(pemCert->m_data->cert, &buffer, GNUTLS_X509_FMT_PEM) >= 0) return pemCert; - return NULL; + return null; } @@ -161,20 +161,20 @@ const byteArray X509Certificate_GnuTLS::getSerialNumber() const } -bool X509Certificate_GnuTLS::checkIssuer(ref issuer_) const +bool X509Certificate_GnuTLS::checkIssuer(shared_ptr issuer_) const { - ref issuer = - issuer_.dynamicCast (); + shared_ptr issuer = + dynamicCast (issuer_); return (gnutls_x509_crt_check_issuer (m_data->cert, issuer->m_data->cert) >= 1); } -bool X509Certificate_GnuTLS::verify(ref caCert_) const +bool X509Certificate_GnuTLS::verify(shared_ptr caCert_) const { - ref caCert = - caCert_.dynamicCast (); + shared_ptr caCert = + dynamicCast (caCert_); unsigned int verify = 0; @@ -267,10 +267,10 @@ int X509Certificate_GnuTLS::getVersion() const } -bool X509Certificate_GnuTLS::equals(ref other) const +bool X509Certificate_GnuTLS::equals(shared_ptr other) const { - ref otherX509 = - other.dynamicCast (); + shared_ptr otherX509 = + dynamicCast (other); if (!otherX509) return false; diff --git a/src/security/cert/openssl/X509Certificate_OpenSSL.cpp b/src/security/cert/openssl/X509Certificate_OpenSSL.cpp index 8c18583b..8c7174a0 100644 --- a/src/security/cert/openssl/X509Certificate_OpenSSL.cpp +++ b/src/security/cert/openssl/X509Certificate_OpenSSL.cpp @@ -158,17 +158,17 @@ void* X509Certificate_OpenSSL::getInternalData() // static -ref X509Certificate_OpenSSL::importInternal(X509* cert) +shared_ptr X509Certificate_OpenSSL::importInternal(X509* cert) { if (cert) - return vmime::create (reinterpret_cast (cert)); + return make_shared (reinterpret_cast (cert)); - return NULL; + return null; } // static -ref X509Certificate::import(utility::inputStream& is) +shared_ptr X509Certificate::import(utility::inputStream& is) { byteArray bytes; utility::stream::value_type chunk[4096]; @@ -184,17 +184,17 @@ ref X509Certificate::import(utility::inputStream& is) // static -ref X509Certificate::import +shared_ptr X509Certificate::import (const byte_t* data, const size_t length) { - ref cert = vmime::create (); + shared_ptr cert = make_shared (); BIO* membio = BIO_new_mem_buf(const_cast (data), length); if (!PEM_read_bio_X509(membio, &(cert->m_data->cert), 0, 0)) { BIO_vfree(membio); - return NULL; + return null; } BIO_vfree(membio); @@ -270,10 +270,10 @@ const byteArray X509Certificate_OpenSSL::getSerialNumber() const } -bool X509Certificate_OpenSSL::checkIssuer(ref cert_) const +bool X509Certificate_OpenSSL::checkIssuer(shared_ptr cert_) const { - ref cert = - cert_.dynamicCast (); + shared_ptr cert = + dynamicCast (cert_); // Get issuer for this cert BIO *out; @@ -297,10 +297,10 @@ bool X509Certificate_OpenSSL::checkIssuer(ref cert_) con } -bool X509Certificate_OpenSSL::verify(ref caCert_) const +bool X509Certificate_OpenSSL::verify(shared_ptr caCert_) const { - ref caCert = - caCert_.dynamicCast (); + shared_ptr caCert = + dynamicCast (caCert_); bool verified = false; @@ -550,10 +550,10 @@ int X509Certificate_OpenSSL::getVersion() const } -bool X509Certificate_OpenSSL::equals(ref other) const +bool X509Certificate_OpenSSL::equals(shared_ptr other) const { - ref otherX509 = - other.dynamicCast (); + shared_ptr otherX509 = + dynamicCast (other); if (!otherX509) return false; diff --git a/src/security/defaultAuthenticator.cpp b/src/security/defaultAuthenticator.cpp index a2ff37f9..790196d2 100644 --- a/src/security/defaultAuthenticator.cpp +++ b/src/security/defaultAuthenticator.cpp @@ -50,7 +50,7 @@ defaultAuthenticator::~defaultAuthenticator() const string defaultAuthenticator::getUsername() const { - ref service = m_service.acquire(); + shared_ptr service = m_service.lock(); const string prefix = service->getInfos().getPropertyPrefix(); const propertySet& props = service->getSession()->getProperties(); @@ -64,7 +64,7 @@ const string defaultAuthenticator::getUsername() const const string defaultAuthenticator::getPassword() const { - ref service = m_service.acquire(); + shared_ptr service = m_service.lock(); const string prefix = service->getInfos().getPropertyPrefix(); const propertySet& props = service->getSession()->getProperties(); @@ -95,13 +95,13 @@ const string defaultAuthenticator::getServiceName() const } -void defaultAuthenticator::setService(ref serv) +void defaultAuthenticator::setService(shared_ptr serv) { m_service = serv; } -weak_ref defaultAuthenticator::getService() const +weak_ptr defaultAuthenticator::getService() const { return m_service; } diff --git a/src/security/digest/messageDigestFactory.cpp b/src/security/digest/messageDigestFactory.cpp index 6d424155..2831c5a1 100644 --- a/src/security/digest/messageDigestFactory.cpp +++ b/src/security/digest/messageDigestFactory.cpp @@ -52,7 +52,7 @@ messageDigestFactory* messageDigestFactory::getInstance() } -ref messageDigestFactory::create(const string& name) +shared_ptr messageDigestFactory::create(const string& name) { const MapType::const_iterator it = m_algos.find (utility::stringUtils::toLower(name)); diff --git a/src/security/sasl/SASLContext.cpp b/src/security/sasl/SASLContext.cpp index 7b24f1e3..c4d60bd9 100644 --- a/src/security/sasl/SASLContext.cpp +++ b/src/security/sasl/SASLContext.cpp @@ -62,27 +62,27 @@ SASLContext::~SASLContext() } -ref SASLContext::createSession +shared_ptr SASLContext::createSession (const string& serviceName, - ref auth, ref mech) + shared_ptr auth, shared_ptr mech) { - return vmime::create - (serviceName, thisRef().dynamicCast (), auth, mech); + return make_shared + (serviceName, dynamicCast (shared_from_this()), auth, mech); } -ref SASLContext::createMechanism(const string& name) +shared_ptr SASLContext::createMechanism(const string& name) { return SASLMechanismFactory::getInstance()->create - (thisRef().dynamicCast (), name); + (dynamicCast (shared_from_this()), name); } -ref SASLContext::suggestMechanism - (const std::vector >& mechs) +shared_ptr SASLContext::suggestMechanism + (const std::vector >& mechs) { if (mechs.empty()) - return 0; + return null; std::ostringstream oss; @@ -102,7 +102,7 @@ ref SASLContext::suggestMechanism } } - return 0; + return null; } @@ -113,7 +113,7 @@ void SASLContext::decodeB64(const string& input, byte_t** output, long* outputLe utility::inputStreamStringAdapter is(input); utility::outputStreamStringAdapter os(res); - ref dec = + shared_ptr dec = utility::encoder::encoderFactory::getInstance()->create("base64"); dec->decode(is, os); @@ -134,7 +134,7 @@ const string SASLContext::encodeB64(const byte_t* input, const long inputLen) utility::inputStreamByteBufferAdapter is(input, inputLen); utility::outputStreamStringAdapter os(res); - ref enc = + shared_ptr enc = utility::encoder::encoderFactory::getInstance()->create("base64"); enc->encode(is, os); diff --git a/src/security/sasl/SASLMechanismFactory.cpp b/src/security/sasl/SASLMechanismFactory.cpp index 0f2dd3af..255a13f1 100644 --- a/src/security/sasl/SASLMechanismFactory.cpp +++ b/src/security/sasl/SASLMechanismFactory.cpp @@ -68,15 +68,15 @@ SASLMechanismFactory* SASLMechanismFactory::getInstance() } -ref SASLMechanismFactory::create - (ref ctx, const string& name_) +shared_ptr SASLMechanismFactory::create + (shared_ptr ctx, const string& name_) { const string name(utility::stringUtils::toUpper(name_)); // Check for built-in mechanisms if (isMechanismSupported(name)) { - return vmime::create (ctx, name); + return make_shared (ctx, name); } // Check for registered mechanisms else @@ -88,7 +88,7 @@ ref SASLMechanismFactory::create } throw exceptions::no_such_mechanism(name); - return 0; + return null; } diff --git a/src/security/sasl/SASLSession.cpp b/src/security/sasl/SASLSession.cpp index c34bdd7f..1bdd0889 100644 --- a/src/security/sasl/SASLSession.cpp +++ b/src/security/sasl/SASLSession.cpp @@ -43,8 +43,8 @@ namespace security { namespace sasl { -SASLSession::SASLSession(const string& serviceName, ref ctx, - ref auth, ref mech) +SASLSession::SASLSession(const string& serviceName, shared_ptr ctx, + shared_ptr auth, shared_ptr mech) : m_serviceName(serviceName), m_context(ctx), m_auth(auth), m_mech(mech), m_gsaslContext(0), m_gsaslSession(0) { @@ -61,38 +61,38 @@ SASLSession::SASLSession(const string& serviceName, ref ctx, SASLSession::~SASLSession() { gsasl_finish(m_gsaslSession); - m_gsaslSession = 0; + m_gsaslSession = NULL; gsasl_done(m_gsaslContext); - m_gsaslContext = 0; + m_gsaslContext = NULL; } void SASLSession::init() { - ref saslAuth = m_auth.dynamicCast (); + shared_ptr saslAuth = dynamicCast (m_auth); if (saslAuth) { saslAuth->setSASLMechanism(m_mech); - saslAuth->setSASLSession(thisRef().dynamicCast ()); + saslAuth->setSASLSession(dynamicCast (shared_from_this())); } } -ref SASLSession::getAuthenticator() +shared_ptr SASLSession::getAuthenticator() { return m_auth; } -ref SASLSession::getMechanism() +shared_ptr SASLSession::getMechanism() { return m_mech; } -ref SASLSession::getContext() +shared_ptr SASLSession::getContext() { return m_context; } @@ -102,14 +102,14 @@ bool SASLSession::evaluateChallenge (const byte_t* challenge, const long challengeLen, byte_t** response, long* responseLen) { - return m_mech->step(thisRef().dynamicCast (), + return m_mech->step(dynamicCast (shared_from_this()), challenge, challengeLen, response, responseLen); } -ref SASLSession::getSecuredSocket(ref sok) +shared_ptr SASLSession::getSecuredSocket(shared_ptr sok) { - return vmime::create (thisRef().dynamicCast (), sok); + return make_shared (dynamicCast (shared_from_this()), sok); } @@ -126,7 +126,7 @@ int SASLSession::gsaslCallback SASLSession* sess = reinterpret_cast (gsasl_callback_hook_get(ctx)); if (!sess) return GSASL_AUTHENTICATION_ERROR; - ref auth = sess->getAuthenticator(); + shared_ptr auth = sess->getAuthenticator(); try { diff --git a/src/security/sasl/SASLSocket.cpp b/src/security/sasl/SASLSocket.cpp index b6b1d272..37e297dc 100644 --- a/src/security/sasl/SASLSocket.cpp +++ b/src/security/sasl/SASLSocket.cpp @@ -43,7 +43,7 @@ namespace sasl { -SASLSocket::SASLSocket(ref sess, ref wrapped) +SASLSocket::SASLSocket(shared_ptr sess, shared_ptr wrapped) : m_session(sess), m_wrapped(wrapped), m_pendingBuffer(0), m_pendingPos(0), m_pendingLen(0) { diff --git a/src/security/sasl/builtinSASLMechanism.cpp b/src/security/sasl/builtinSASLMechanism.cpp index 86b429bf..e7bd723e 100644 --- a/src/security/sasl/builtinSASLMechanism.cpp +++ b/src/security/sasl/builtinSASLMechanism.cpp @@ -45,7 +45,7 @@ namespace security { namespace sasl { -builtinSASLMechanism::builtinSASLMechanism(ref ctx, const string& name) +builtinSASLMechanism::builtinSASLMechanism(shared_ptr ctx, const string& name) : m_context(ctx), m_name(name), m_complete(false) { } @@ -63,7 +63,7 @@ const string builtinSASLMechanism::getName() const bool builtinSASLMechanism::step - (ref sess, const byte_t* challenge, const long challengeLen, + (shared_ptr sess, const byte_t* challenge, const long challengeLen, byte_t** response, long* responseLen) { char* output = 0; @@ -121,7 +121,7 @@ bool builtinSASLMechanism::isComplete() const void builtinSASLMechanism::encode - (ref sess, const byte_t* input, const long inputLen, + (shared_ptr sess, const byte_t* input, const long inputLen, byte_t** output, long* outputLen) { char* coutput = 0; @@ -154,7 +154,7 @@ void builtinSASLMechanism::encode void builtinSASLMechanism::decode - (ref sess, const byte_t* input, const long inputLen, + (shared_ptr sess, const byte_t* input, const long inputLen, byte_t** output, long* outputLen) { char* coutput = 0; diff --git a/src/security/sasl/defaultSASLAuthenticator.cpp b/src/security/sasl/defaultSASLAuthenticator.cpp index bb72e56f..7fe9b3eb 100644 --- a/src/security/sasl/defaultSASLAuthenticator.cpp +++ b/src/security/sasl/defaultSASLAuthenticator.cpp @@ -51,14 +51,14 @@ defaultSASLAuthenticator::~defaultSASLAuthenticator() } -const std::vector > +const std::vector > defaultSASLAuthenticator::getAcceptableMechanisms - (const std::vector >& available, - ref suggested) const + (const std::vector >& available, + shared_ptr suggested) const { if (suggested) { - std::vector > res; + std::vector > res; res.push_back(suggested); @@ -103,42 +103,42 @@ const string defaultSASLAuthenticator::getAnonymousToken() const const string defaultSASLAuthenticator::getServiceName() const { - return m_saslSession.acquire()->getServiceName(); + return m_saslSession.lock()->getServiceName(); } -void defaultSASLAuthenticator::setService(ref serv) +void defaultSASLAuthenticator::setService(shared_ptr serv) { m_service = serv; m_default.setService(serv); } -weak_ref defaultSASLAuthenticator::getService() const +weak_ptr defaultSASLAuthenticator::getService() const { return m_service; } -void defaultSASLAuthenticator::setSASLSession(ref sess) +void defaultSASLAuthenticator::setSASLSession(shared_ptr sess) { m_saslSession = sess; } -ref defaultSASLAuthenticator::getSASLSession() const +shared_ptr defaultSASLAuthenticator::getSASLSession() const { - return m_saslSession.acquire().constCast (); + return constCast (m_saslSession.lock()); } -void defaultSASLAuthenticator::setSASLMechanism(ref mech) +void defaultSASLAuthenticator::setSASLMechanism(shared_ptr mech) { m_saslMech = mech; } -ref defaultSASLAuthenticator::getSASLMechanism() const +shared_ptr defaultSASLAuthenticator::getSASLMechanism() const { return m_saslMech; } diff --git a/src/streamContentHandler.cpp b/src/streamContentHandler.cpp index d6444833..b84fdae5 100644 --- a/src/streamContentHandler.cpp +++ b/src/streamContentHandler.cpp @@ -34,12 +34,12 @@ namespace vmime streamContentHandler::streamContentHandler() - : m_encoding(NO_ENCODING), m_stream(null) + : m_encoding(NO_ENCODING), m_stream(null), m_length(0) { } -streamContentHandler::streamContentHandler(ref is, +streamContentHandler::streamContentHandler(shared_ptr is, const utility::stream::size_type length, const vmime::encoding& enc) { setData(is, length, enc); @@ -58,9 +58,9 @@ streamContentHandler::streamContentHandler(const streamContentHandler& cts) } -ref streamContentHandler::clone() const +shared_ptr streamContentHandler::clone() const { - return vmime::create (*this); + return make_shared (*this); } @@ -76,7 +76,7 @@ streamContentHandler& streamContentHandler::operator=(const streamContentHandler } -void streamContentHandler::setData(ref is, +void streamContentHandler::setData(shared_ptr is, const utility::stream::size_type length, const vmime::encoding& enc) { m_encoding = enc; @@ -100,8 +100,8 @@ void streamContentHandler::generate(utility::outputStream& os, const vmime::enco // buffer, and then re-encode to output stream... if (m_encoding != enc) { - ref theDecoder = m_encoding.getEncoder(); - ref theEncoder = enc.getEncoder(); + shared_ptr theDecoder = m_encoding.getEncoder(); + shared_ptr theEncoder = enc.getEncoder(); theEncoder->getProperties()["maxlinelength"] = maxLineLength; theEncoder->getProperties()["text"] = (m_contentType.getType() == mediaTypes::TEXT); @@ -129,7 +129,7 @@ void streamContentHandler::generate(utility::outputStream& os, const vmime::enco // Need to encode data before else { - ref theEncoder = enc.getEncoder(); + shared_ptr theEncoder = enc.getEncoder(); theEncoder->getProperties()["maxlinelength"] = maxLineLength; theEncoder->getProperties()["text"] = (m_contentType.getType() == mediaTypes::TEXT); @@ -159,7 +159,7 @@ void streamContentHandler::extract(utility::outputStream& os, // Need to decode data else { - ref theDecoder = m_encoding.getEncoder(); + shared_ptr theDecoder = m_encoding.getEncoder(); m_stream->reset(); // may not work... @@ -211,7 +211,7 @@ const vmime::encoding& streamContentHandler::getEncoding() const bool streamContentHandler::isBuffered() const { - if (m_stream.dynamicCast () != NULL) + if (dynamicCast (m_stream) != NULL) return true; // FIXME: some streams can be resetted diff --git a/src/stringContentHandler.cpp b/src/stringContentHandler.cpp index e4762dce..0fb032dd 100644 --- a/src/stringContentHandler.cpp +++ b/src/stringContentHandler.cpp @@ -68,9 +68,9 @@ stringContentHandler::~stringContentHandler() } -ref stringContentHandler::clone() const +shared_ptr stringContentHandler::clone() const { - return vmime::create (*this); + return make_shared (*this); } @@ -125,8 +125,8 @@ void stringContentHandler::generate(utility::outputStream& os, // buffer, and then re-encode to output stream... if (m_encoding != enc) { - ref theDecoder = m_encoding.getEncoder(); - ref theEncoder = enc.getEncoder(); + shared_ptr theDecoder = m_encoding.getEncoder(); + shared_ptr theEncoder = enc.getEncoder(); theEncoder->getProperties()["maxlinelength"] = maxLineLength; theEncoder->getProperties()["text"] = (m_contentType.getType() == mediaTypes::TEXT); @@ -152,7 +152,7 @@ void stringContentHandler::generate(utility::outputStream& os, // Need to encode data before else { - ref theEncoder = enc.getEncoder(); + shared_ptr theEncoder = enc.getEncoder(); theEncoder->getProperties()["maxlinelength"] = maxLineLength; theEncoder->getProperties()["text"] = (m_contentType.getType() == mediaTypes::TEXT); @@ -174,7 +174,7 @@ void stringContentHandler::extract(utility::outputStream& os, // Need to decode data else { - ref theDecoder = m_encoding.getEncoder(); + shared_ptr theDecoder = m_encoding.getEncoder(); utility::inputStreamStringProxyAdapter in(m_string); utility::progressListenerSizeAdapter plsa(progress, getLength()); diff --git a/src/text.cpp b/src/text.cpp index 05353b08..987510c1 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -57,7 +57,7 @@ text::text(const string& t) text::text(const word& w) { - appendWord(vmime::create (w)); + appendWord(make_shared (w)); } @@ -75,7 +75,7 @@ void text::parseImpl string::size_type newPos; - const std::vector > words = word::parseMultiple(ctx, buffer, position, end, &newPos); + const std::vector > words = word::parseMultiple(ctx, buffer, position, end, &newPos); copy_vector(words, m_words); @@ -100,8 +100,8 @@ void text::copyFrom(const component& other) removeAllWords(); - for (std::vector >::const_iterator i = t.m_words.begin() ; i != t.m_words.end() ; ++i) - m_words.push_back(vmime::create (**i)); + for (std::vector >::const_iterator i = t.m_words.begin() ; i != t.m_words.end() ; ++i) + m_words.push_back(make_shared (**i)); } @@ -125,8 +125,8 @@ bool text::operator==(const text& t) const { bool equal = true; - std::vector >::const_iterator i = m_words.begin(); - std::vector >::const_iterator j = t.m_words.begin(); + std::vector >::const_iterator i = m_words.begin(); + std::vector >::const_iterator j = t.m_words.begin(); for ( ; equal && i != m_words.end() ; ++i, ++j) equal = (**i == **j); @@ -148,26 +148,26 @@ const string text::getConvertedText(const charset& dest, const charsetConverterO { string out; - for (std::vector >::const_iterator i = m_words.begin() ; i != m_words.end() ; ++i) + for (std::vector >::const_iterator i = m_words.begin() ; i != m_words.end() ; ++i) out += (*i)->getConvertedText(dest, opts); return (out); } -void text::appendWord(ref w) +void text::appendWord(shared_ptr w) { m_words.push_back(w); } -void text::insertWordBefore(const size_t pos, ref w) +void text::insertWordBefore(const size_t pos, shared_ptr w) { m_words.insert(m_words.begin() + pos, w); } -void text::insertWordAfter(const size_t pos, ref w) +void text::insertWordAfter(const size_t pos, shared_ptr w) { m_words.insert(m_words.begin() + pos + 1, w); } @@ -175,7 +175,7 @@ void text::insertWordAfter(const size_t pos, ref w) void text::removeWord(const size_t pos) { - const std::vector >::iterator it = m_words.begin() + pos; + const std::vector >::iterator it = m_words.begin() + pos; m_words.erase(it); } @@ -199,25 +199,25 @@ bool text::isEmpty() const } -const ref text::getWordAt(const size_t pos) +const shared_ptr text::getWordAt(const size_t pos) { return (m_words[pos]); } -const ref text::getWordAt(const size_t pos) const +const shared_ptr text::getWordAt(const size_t pos) const { return (m_words[pos]); } -const std::vector > text::getWordList() const +const std::vector > text::getWordList() const { - std::vector > list; + std::vector > list; list.reserve(m_words.size()); - for (std::vector >::const_iterator it = m_words.begin() ; + for (std::vector >::const_iterator it = m_words.begin() ; it != m_words.end() ; ++it) { list.push_back(*it); @@ -227,21 +227,21 @@ const std::vector > text::getWordList() const } -const std::vector > text::getWordList() +const std::vector > text::getWordList() { return (m_words); } -ref text::clone() const +shared_ptr text::clone() const { - return vmime::create (*this); + return make_shared (*this); } -ref text::newFromString(const string& in, const charset& ch) +shared_ptr text::newFromString(const string& in, const charset& ch) { - ref t = vmime::create (); + shared_ptr t = make_shared (); t->createFromString(in, ch); @@ -272,7 +272,7 @@ void text::createFromString(const string& in, const charset& ch) // If there are "too much" non-ASCII chars, encode everything if (alwaysEncode || asciiPercent < 60) // less than 60% ASCII chars { - appendWord(vmime::create (in, ch)); + appendWord(make_shared (in, ch)); } // Else, only encode words which need it else @@ -296,18 +296,18 @@ void text::createFromString(const string& in, const charset& ch) { // No need to create a new encoded word, just append // the current word to the previous one. - ref w = getWordAt(getWordCount() - 1); + shared_ptr w = getWordAt(getWordCount() - 1); w->getBuffer() += " " + chunk; } else { if (count) { - ref w = getWordAt(getWordCount() - 1); + shared_ptr w = getWordAt(getWordCount() - 1); w->getBuffer() += ' '; } - appendWord(vmime::create (chunk, ch)); + appendWord(make_shared (chunk, ch)); prevIs8bit = true; ++count; @@ -317,12 +317,12 @@ void text::createFromString(const string& in, const charset& ch) { if (count && !prevIs8bit) { - ref w = getWordAt(getWordCount() - 1); + shared_ptr w = getWordAt(getWordCount() - 1); w->getBuffer() += " " + chunk; } else { - appendWord(vmime::create + appendWord(make_shared (chunk, charset(charsets::US_ASCII))); prevIs8bit = false; @@ -368,9 +368,9 @@ void text::encodeAndFold } -ref text::decodeAndUnfold(const string& in) +shared_ptr text::decodeAndUnfold(const string& in) { - ref t = vmime::create (); + shared_ptr t = make_shared (); decodeAndUnfold(parsingContext::getDefaultContext(), in, t.get()); @@ -378,9 +378,9 @@ ref text::decodeAndUnfold(const string& in) } -ref text::decodeAndUnfold(const parsingContext& ctx, const string& in) +shared_ptr text::decodeAndUnfold(const parsingContext& ctx, const string& in) { - ref t = vmime::create (); + shared_ptr t = make_shared (); decodeAndUnfold(ctx, in, t.get()); @@ -400,7 +400,7 @@ text* text::decodeAndUnfold(const parsingContext& ctx, const string& in, text* g out->removeAllWords(); - const std::vector > words = word::parseMultiple(ctx, in, 0, in.length(), NULL); + const std::vector > words = word::parseMultiple(ctx, in, 0, in.length(), NULL); copy_vector(words, out->m_words); @@ -408,9 +408,9 @@ text* text::decodeAndUnfold(const parsingContext& ctx, const string& in, text* g } -const std::vector > text::getChildComponents() +const std::vector > text::getChildComponents() { - std::vector > list; + std::vector > list; copy_vector(m_words, list); @@ -422,7 +422,7 @@ const string text::getWholeBuffer() const { string res; - for (std::vector >::const_iterator it = m_words.begin() ; + for (std::vector >::const_iterator it = m_words.begin() ; it != m_words.end() ; ++it) { res += (*it)->getBuffer(); diff --git a/src/textPartFactory.cpp b/src/textPartFactory.cpp index baad6292..85fea6e4 100644 --- a/src/textPartFactory.cpp +++ b/src/textPartFactory.cpp @@ -53,7 +53,7 @@ textPartFactory* textPartFactory::getInstance() } -ref textPartFactory::create(const mediaType& type) +shared_ptr textPartFactory::create(const mediaType& type) { for (MapType::const_iterator it = m_map.begin() ; it != m_map.end() ; ++it) diff --git a/src/utility/encoder/encoderFactory.cpp b/src/utility/encoder/encoderFactory.cpp index 02800b4c..098a810a 100644 --- a/src/utility/encoder/encoderFactory.cpp +++ b/src/utility/encoder/encoderFactory.cpp @@ -61,24 +61,24 @@ encoderFactory::~encoderFactory() } -encoderFactory* encoderFactory::getInstance() +shared_ptr encoderFactory::getInstance() { static encoderFactory instance; - return (&instance); + return shared_ptr (&instance, noop_shared_ptr_deleter ()); } -ref encoderFactory::create(const string& name) +shared_ptr encoderFactory::create(const string& name) { return (getEncoderByName(name)->create()); } -const ref encoderFactory::getEncoderByName(const string& name) const +const shared_ptr encoderFactory::getEncoderByName(const string& name) const { const string lcName(utility::stringUtils::toLower(name)); - for (std::vector >::const_iterator it = m_encoders.begin() ; + for (std::vector >::const_iterator it = m_encoders.begin() ; it != m_encoders.end() ; ++it) { if ((*it)->getName() == lcName) @@ -95,17 +95,17 @@ size_t encoderFactory::getEncoderCount() const } -const ref encoderFactory::getEncoderAt(const size_t pos) const +const shared_ptr encoderFactory::getEncoderAt(const size_t pos) const { return (m_encoders[pos]); } -const std::vector > encoderFactory::getEncoderList() const +const std::vector > encoderFactory::getEncoderList() const { - std::vector > res; + std::vector > res; - for (std::vector >::const_iterator it = m_encoders.begin() ; + for (std::vector >::const_iterator it = m_encoders.begin() ; it != m_encoders.end() ; ++it) { res.push_back(*it); diff --git a/src/utility/parserInputStreamAdapter.cpp b/src/utility/parserInputStreamAdapter.cpp index 0d6248cf..fd10a586 100644 --- a/src/utility/parserInputStreamAdapter.cpp +++ b/src/utility/parserInputStreamAdapter.cpp @@ -28,7 +28,7 @@ namespace vmime { namespace utility { -parserInputStreamAdapter::parserInputStreamAdapter(ref stream) +parserInputStreamAdapter::parserInputStreamAdapter(shared_ptr stream) : m_stream(stream) { } @@ -53,7 +53,7 @@ stream::size_type parserInputStreamAdapter::read } -ref parserInputStreamAdapter::getUnderlyingStream() +shared_ptr parserInputStreamAdapter::getUnderlyingStream() { return m_stream; } diff --git a/src/utility/seekableInputStreamRegionAdapter.cpp b/src/utility/seekableInputStreamRegionAdapter.cpp index ec7c20cf..753d81a5 100644 --- a/src/utility/seekableInputStreamRegionAdapter.cpp +++ b/src/utility/seekableInputStreamRegionAdapter.cpp @@ -29,7 +29,7 @@ namespace utility { seekableInputStreamRegionAdapter::seekableInputStreamRegionAdapter - (ref stream, const size_type begin, const size_type length) + (shared_ptr stream, const size_type begin, const size_type length) : m_stream(stream), m_begin(begin), m_length(length), m_position(0) { } diff --git a/src/utility/smartPtr.cpp b/src/utility/smartPtr.cpp deleted file mode 100644 index 78cf9032..00000000 --- a/src/utility/smartPtr.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// -// VMime library (http://www.vmime.org) -// Copyright (C) 2002-2013 Vincent Richard -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License as -// published by the Free Software Foundation; either version 3 of -// the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -// -// Linking this library statically or dynamically with other modules is making -// a combined work based on this library. Thus, the terms and conditions of -// the GNU General Public License cover the whole combination. -// - -#include "vmime/object.hpp" -#include "vmime/utility/smartPtr.hpp" - - -namespace vmime { -namespace utility { - - -void refManager::deleteObjectImpl(object* obj) -{ - obj->setRefManager(0); - delete obj; -} - - -} // utility -} // vmime - diff --git a/src/utility/smartPtrInt.cpp b/src/utility/smartPtrInt.cpp deleted file mode 100644 index 2bb9d70d..00000000 --- a/src/utility/smartPtrInt.cpp +++ /dev/null @@ -1,295 +0,0 @@ -// -// VMime library (http://www.vmime.org) -// Copyright (C) 2002-2013 Vincent Richard -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License as -// published by the Free Software Foundation; either version 3 of -// the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -// -// Linking this library statically or dynamically with other modules is making -// a combined work based on this library. Thus, the terms and conditions of -// the GNU General Public License cover the whole combination. -// - -#include "vmime/utility/smartPtrInt.hpp" -#include "vmime/object.hpp" - - -namespace vmime { -namespace utility { - - -// static -refManager* refManager::create(object* obj) -{ - return new refManagerImpl(obj); -} - - -// -// refManager -// - -refManagerImpl::refManagerImpl(object* obj) - : m_object(obj), m_strongCount(1), m_weakCount(1) -{ -} - - -refManagerImpl::~refManagerImpl() -{ -} - - -bool refManagerImpl::addStrong() -{ - if (m_strongCount <= 0) - return false; - - m_strongCount.increment(); - m_weakCount.increment(); - - return true; -} - - -void refManagerImpl::releaseStrong() -{ - if (m_strongCount.decrement() <= 0) - deleteObject(); - - releaseWeak(); -} - - -void refManagerImpl::addWeak() -{ - m_weakCount.increment(); -} - - -void refManagerImpl::releaseWeak() -{ - if (m_weakCount.decrement() <= 0) - deleteManager(); -} - - -object* refManagerImpl::getObject() -{ - return m_object; -} - - -void refManagerImpl::deleteManager() -{ - delete this; -} - - -void refManagerImpl::deleteObject() -{ - try - { - deleteObjectImpl(m_object); - } - catch (...) - { - // Exception in destructor - } - - m_object = 0; -} - - -long refManagerImpl::getStrongRefCount() const -{ - return m_strongCount; -} - - -long refManagerImpl::getWeakRefCount() const -{ - return m_weakCount; -} - - - -// -// refCounter -// - -#ifdef _WIN32 - - -refCounter::refCounter(const long initialValue) - : m_value(initialValue) -{ -} - - -refCounter::~refCounter() -{ -} - - -long refCounter::increment() -{ - return InterlockedIncrement(&m_value); -} - - -long refCounter::decrement() -{ - return InterlockedDecrement(&m_value); -} - - -refCounter::operator long() const -{ - return m_value; -} - - -#elif defined(__GNUC__) && (defined(__GLIBCPP__) || defined(__GLIBCXX__)) - - -refCounter::refCounter(const long initialValue) - : m_value(static_cast (initialValue)) -{ -} - - -refCounter::~refCounter() -{ -} - - -long refCounter::increment() -{ -#if __GNUC_MINOR__ < 4 && __GNUC__ < 4 - return __exchange_and_add(&m_value, 1) + 1; -#else - return __gnu_cxx::__exchange_and_add(&m_value, 1) + 1; -#endif -} - - -long refCounter::decrement() -{ -#if __GNUC_MINOR__ < 4 && __GNUC__ < 4 - return __exchange_and_add(&m_value, -1) - 1; -#else - return __gnu_cxx::__exchange_and_add(&m_value, -1) - 1; -#endif -} - - -refCounter::operator long() const -{ -#if __GNUC_MINOR__ < 4 && __GNUC__ < 4 - return static_cast (__exchange_and_add(&m_value, 0)); -#else - return static_cast (__gnu_cxx::__exchange_and_add(&m_value, 0)); -#endif -} - - -#elif defined(VMIME_HAVE_PTHREAD) - - -refCounter::refCounter(const long initialValue) - : m_value(initialValue) -{ - pthread_mutexattr_t attr; - pthread_mutexattr_init(&attr); - pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL); - pthread_mutex_init(&m_mutex, &attr); - pthread_mutexattr_destroy(&attr); -} - - -refCounter::~refCounter() -{ - pthread_mutex_destroy(&m_mutex); -} - - -long refCounter::increment() -{ - long value; - - pthread_mutex_lock(&m_mutex); - value = ++m_value; - pthread_mutex_unlock(&m_mutex); - - return value; -} - - -long refCounter::decrement() -{ - long value; - - pthread_mutex_lock(&m_mutex); - value = --m_value; - pthread_mutex_unlock(&m_mutex); - - return value; -} - - -refCounter::operator long() const -{ - return m_value; -} - - -#else // not thread-safe implementation - - -refCounter::refCounter(const long initialValue) - : m_value(initialValue) -{ -} - - -refCounter::~refCounter() -{ -} - - -long refCounter::increment() -{ - return ++m_value; -} - - -long refCounter::decrement() -{ - return --m_value; -} - - -refCounter::operator long() const -{ - return m_value; -} - - -#endif - - -} // utility -} // vmime - diff --git a/src/word.cpp b/src/word.cpp index 8e254865..fc791b53 100644 --- a/src/word.cpp +++ b/src/word.cpp @@ -25,7 +25,6 @@ #include "vmime/text.hpp" #include "vmime/utility/stringUtils.hpp" -#include "vmime/utility/smartPtr.hpp" #include "vmime/parserHelpers.hpp" #include "vmime/utility/outputStreamStringAdapter.hpp" @@ -66,7 +65,7 @@ word::word(const string& buffer, const charset& charset) } -ref word::parseNext +shared_ptr word::parseNext (const parsingContext& ctx, const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition, bool prevIsEncoded, bool* isEncoded, bool isFirst) @@ -128,7 +127,7 @@ ref word::parseNext if (prevIsEncoded && !isFirst) unencoded = whiteSpaces + unencoded; - ref w = vmime::create (unencoded, defaultCharset); + shared_ptr w = make_shared (unencoded, defaultCharset); w->setParsedBounds(position, pos); if (newPosition) @@ -185,7 +184,7 @@ ref word::parseNext pos += 2; // ?= - ref w = vmime::create (); + shared_ptr w = make_shared (); w->parse(buffer, wordStart, pos, NULL); if (newPosition) @@ -211,7 +210,7 @@ ref word::parseNext // Treat unencoded text at the end of the buffer if (!unencoded.empty()) { - ref w = vmime::create (unencoded, defaultCharset); + shared_ptr w = make_shared (unencoded, defaultCharset); w->setParsedBounds(position, end); if (newPosition) @@ -227,12 +226,12 @@ ref word::parseNext } -const std::vector > word::parseMultiple +const std::vector > word::parseMultiple (const parsingContext& ctx, const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition) { - std::vector > res; - ref w; + std::vector > res; + shared_ptr w; string::size_type pos = position; @@ -743,9 +742,9 @@ const string word::getConvertedText(const charset& dest, const charsetConverterO } -ref word::clone() const +shared_ptr word::clone() const { - return vmime::create (m_buffer, m_charset); + return make_shared (m_buffer, m_charset); } @@ -785,9 +784,9 @@ void word::setBuffer(const string& buffer) } -const std::vector > word::getChildComponents() +const std::vector > word::getChildComponents() { - return std::vector >(); + return std::vector >(); } diff --git a/src/wordEncoder.cpp b/src/wordEncoder.cpp index 332f9bf2..b3e98fd2 100644 --- a/src/wordEncoder.cpp +++ b/src/wordEncoder.cpp @@ -68,11 +68,11 @@ wordEncoder::wordEncoder(const string& buffer, const charset& charset, const Enc if (m_encoding == ENCODING_B64) { - m_encoder = vmime::create (); + m_encoder = make_shared (); } else // ENCODING_QP { - m_encoder = vmime::create (); + m_encoder = make_shared (); m_encoder->getProperties()["rfc2047"] = true; } } @@ -168,7 +168,7 @@ const string wordEncoder::getNextChunk(const string::size_type maxLength) // Fully RFC-compliant encoding else { - ref conv = charsetConverter::create(charsets::UTF_8, m_charset); + shared_ptr conv = charsetConverter::create(charsets::UTF_8, m_charset); string::size_type inputCount = 0; string::size_type outputCount = 0; diff --git a/tests/misc/importanceHelperTest.cpp b/tests/misc/importanceHelperTest.cpp index f4696efb..9a4b86f7 100644 --- a/tests/misc/importanceHelperTest.cpp +++ b/tests/misc/importanceHelperTest.cpp @@ -49,7 +49,7 @@ VMIME_TEST_SUITE_BEGIN(importanceHelperTest) void testResetImportance() { - vmime::ref hdr = vmime::create (); + vmime::shared_ptr hdr = vmime::make_shared (); hdr->getField("Importance")->setValue("xxx"); hdr->getField("X-Priority")->setValue("yyy"); @@ -69,7 +69,7 @@ VMIME_TEST_SUITE_BEGIN(importanceHelperTest) void testSetImportanceImpl(const vmime::misc::importanceHelper::Importance i, const std::string& ImportanceValue, const std::string& XPriorityValue) { - vmime::ref hdr = vmime::create (); + vmime::shared_ptr hdr = vmime::make_shared (); vmime::misc::importanceHelper::setImportanceHeader(hdr, i); @@ -117,12 +117,12 @@ VMIME_TEST_SUITE_BEGIN(importanceHelperTest) const vmime::misc::importanceHelper::Importance i2, const std::string& ImportanceValue, const std::string& XPriorityValue) { - vmime::ref hdr1 = vmime::create (); + vmime::shared_ptr hdr1 = vmime::make_shared (); hdr1->getField("Importance")->setValue(ImportanceValue); VASSERT_EQ("1", i1, vmime::misc::importanceHelper::getImportanceHeader(hdr1)); - vmime::ref hdr2 = vmime::create (); + vmime::shared_ptr hdr2 = vmime::make_shared (); hdr2->getField("X-Priority")->setValue(XPriorityValue); VASSERT_EQ("2", i2, vmime::misc::importanceHelper::getImportanceHeader(hdr2)); diff --git a/tests/net/imap/IMAPParserTest.cpp b/tests/net/imap/IMAPParserTest.cpp index 93f6e6fd..30e8f574 100644 --- a/tests/net/imap/IMAPParserTest.cpp +++ b/tests/net/imap/IMAPParserTest.cpp @@ -37,18 +37,19 @@ VMIME_TEST_SUITE_BEGIN(IMAPParserTest) // For Apple iCloud IMAP server void testExtraSpaceInCapaResponse() { - vmime::ref socket = vmime::create (); - vmime::ref toh = vmime::create (); + vmime::shared_ptr socket = vmime::make_shared (); + vmime::shared_ptr toh = vmime::make_shared (); - vmime::ref tag = - vmime::create (); + vmime::shared_ptr tag = + vmime::make_shared (); socket->localSend( "* CAPABILITY IMAP4rev1 AUTH=ATOKEN AUTH=PLAIN \r\n" // extra space at end "a001 OK Capability completed.\r\n"); - vmime::ref parser = - vmime::create (tag, socket.dynamicCast (), toh); + vmime::shared_ptr parser = + vmime::make_shared + (tag, vmime::dynamicCast (socket), toh); parser->setStrict(false); VASSERT_NO_THROW("non-strict mode", parser->readResponse(/* literalHandler */ NULL)); diff --git a/tests/net/imap/IMAPTagTest.cpp b/tests/net/imap/IMAPTagTest.cpp index 26ed87c5..db04537a 100644 --- a/tests/net/imap/IMAPTagTest.cpp +++ b/tests/net/imap/IMAPTagTest.cpp @@ -38,16 +38,16 @@ VMIME_TEST_SUITE_BEGIN(imapTagTest) void testConstruct() { - vmime::ref tag = - vmime::create (); + vmime::shared_ptr tag = + vmime::make_shared (); VASSERT_EQ("init", "a001", static_cast (*tag)); } void testIncrement() { - vmime::ref tag = - vmime::create (); + vmime::shared_ptr tag = + vmime::make_shared (); (*tag)++; VASSERT_EQ("init", "a002", static_cast (*tag)); @@ -61,8 +61,8 @@ VMIME_TEST_SUITE_BEGIN(imapTagTest) void testReset() { - vmime::ref tag = - vmime::create (); + vmime::shared_ptr tag = + vmime::make_shared (); for (int i = tag->number() ; i < tag->maximumNumber() ; ++i) (*tag)++; @@ -76,8 +76,8 @@ VMIME_TEST_SUITE_BEGIN(imapTagTest) void testNumber() { - vmime::ref tag = - vmime::create (); + vmime::shared_ptr tag = + vmime::make_shared (); for (int i = 0 ; i < 41 ; ++i) (*tag)++; diff --git a/tests/net/maildir/maildirStoreTest.cpp b/tests/net/maildir/maildirStoreTest.cpp index 358e095f..34e8249c 100644 --- a/tests/net/maildir/maildirStoreTest.cpp +++ b/tests/net/maildir/maildirStoreTest.cpp @@ -187,7 +187,7 @@ public: { createMaildir(TEST_MAILDIR_KMAIL, TEST_MAILDIRFILES_KMAIL); - vmime::ref store = + vmime::shared_ptr store = vmime::dynamicCast (createAndConnectStore()); VASSERT_EQ("*", "kmail", store->getFormat()->getName()); @@ -199,7 +199,7 @@ public: { createMaildir(TEST_MAILDIR_COURIER, TEST_MAILDIRFILES_COURIER); - vmime::ref store = + vmime::shared_ptr store = vmime::dynamicCast (createAndConnectStore()); VASSERT_EQ("*", "courier", store->getFormat()->getName()); @@ -223,11 +223,11 @@ public: createMaildir(dirs, files); // Connect to store - vmime::ref store = createAndConnectStore(); - vmime::ref rootFolder = store->getRootFolder(); + vmime::shared_ptr store = createAndConnectStore(); + vmime::shared_ptr rootFolder = store->getRootFolder(); // Get root folders, not recursive - const std::vector > + const std::vector > rootFolders = rootFolder->getFolders(false); VASSERT_EQ("1", 2, rootFolders.size()); @@ -253,11 +253,11 @@ public: createMaildir(dirs, files); // Connect to store - vmime::ref store = createAndConnectStore(); - vmime::ref rootFolder = store->getRootFolder(); + vmime::shared_ptr store = createAndConnectStore(); + vmime::shared_ptr rootFolder = store->getRootFolder(); // Get all folders, recursive - const std::vector > + const std::vector > allFolders = rootFolder->getFolders(true); VASSERT_EQ("1", 5, allFolders.size()); @@ -285,10 +285,10 @@ public: { createMaildir(dirs, files); - vmime::ref store = createAndConnectStore(); - vmime::ref rootFolder = store->getRootFolder(); + vmime::shared_ptr store = createAndConnectStore(); + vmime::shared_ptr rootFolder = store->getRootFolder(); - vmime::ref folder = store->getFolder + vmime::shared_ptr folder = store->getFolder (fpath() / "Folder" / "SubFolder" / "SubSubFolder2"); int count, unseen; @@ -298,7 +298,7 @@ public: folder->open(vmime::net::folder::MODE_READ_ONLY); - vmime::ref msg = folder->getMessage(1); + vmime::shared_ptr msg = folder->getMessage(1); folder->fetchMessage(msg, vmime::net::fetchAttributes::SIZE); @@ -346,17 +346,17 @@ public: { createMaildir(dirs, files); - vmime::ref store = createAndConnectStore(); - vmime::ref rootFolder = store->getRootFolder(); + vmime::shared_ptr store = createAndConnectStore(); + vmime::shared_ptr rootFolder = store->getRootFolder(); // Rename "Folder/SubFolder" to "Folder/foo" - vmime::ref folder = store->getFolder + vmime::shared_ptr folder = store->getFolder (fpath() / "Folder" / "SubFolder"); folder->rename(fpath() / "Folder" / "foo"); // Ensure folder and its subfolders have been renamed - const std::vector > + const std::vector > allFolders = rootFolder->getFolders(true); VASSERT_EQ("1", 5, allFolders.size()); @@ -387,17 +387,17 @@ public: { createMaildir(dirs, files); - vmime::ref store = createAndConnectStore(); - vmime::ref rootFolder = store->getRootFolder(); + vmime::shared_ptr store = createAndConnectStore(); + vmime::shared_ptr rootFolder = store->getRootFolder(); // Destroy "Folder/SubFolder" (total: 3 folders) - vmime::ref folder = store->getFolder + vmime::shared_ptr folder = store->getFolder (fpath() / "Folder" / "SubFolder"); folder->destroy(); // Ensure folder and its subfolders have been deleted and other folders still exist - const std::vector > + const std::vector > allFolders = rootFolder->getFolders(true); VASSERT_EQ("1", 2, allFolders.size()); @@ -425,8 +425,8 @@ public: { createMaildir(dirs, files); - vmime::ref store = createAndConnectStore(); - vmime::ref rootFolder = store->getRootFolder(); + vmime::shared_ptr store = createAndConnectStore(); + vmime::shared_ptr rootFolder = store->getRootFolder(); VASSERT("1", store->getFolder(fpath() / "Folder" / "SubFolder")->exists()); VASSERT("2", !store->getFolder(fpath() / "Folder" / "SubSubFolder1")->exists()); @@ -451,8 +451,8 @@ public: { createMaildir(dirs, files); - vmime::ref store = createAndConnectStore(); - vmime::ref rootFolder = store->getRootFolder(); + vmime::shared_ptr store = createAndConnectStore(); + vmime::shared_ptr rootFolder = store->getRootFolder(); VASSERT("Before", !store->getFolder(fpath() / "Folder" / "NewFolder")->exists()); @@ -469,12 +469,12 @@ private: vmime::utility::file::path m_tempPath; - vmime::ref createAndConnectStore() + vmime::shared_ptr createAndConnectStore() { - vmime::ref session = - vmime::create (); + vmime::shared_ptr session = + vmime::make_shared (); - vmime::ref store = + vmime::shared_ptr store = session->getStore(getStoreURL()); store->connect(); @@ -482,8 +482,8 @@ private: return store; } - const vmime::ref findFolder - (const std::vector >& folders, + const vmime::shared_ptr findFolder + (const std::vector >& folders, const vmime::net::folder::path& path) { for (unsigned int i = 0, n = folders.size() ; i < n ; ++i) @@ -492,12 +492,12 @@ private: return folders[i]; } - return NULL; + return vmime::null; } const vmime::utility::url getStoreURL() { - vmime::ref fsf = + vmime::shared_ptr fsf = vmime::platform::getHandler()->getFileSystemFactory(); vmime::utility::url url(std::string("maildir://localhost") @@ -508,15 +508,15 @@ private: void createMaildir(const vmime::string* const dirs, const vmime::string* const files) { - vmime::ref fsf = + vmime::shared_ptr fsf = vmime::platform::getHandler()->getFileSystemFactory(); - vmime::ref rootDir = fsf->create(m_tempPath); + vmime::shared_ptr rootDir = fsf->create(m_tempPath); rootDir->createDirectory(false); for (vmime::string const* dir = dirs ; *dir != "*" ; ++dir) { - vmime::ref fdir = fsf->create(m_tempPath / fsf->stringToPath(*dir)); + vmime::shared_ptr fdir = fsf->create(m_tempPath / fsf->stringToPath(*dir)); fdir->createDirectory(false); } @@ -524,39 +524,39 @@ private: { const vmime::string& contents = *(file + 1); - vmime::ref ffile = fsf->create(m_tempPath / fsf->stringToPath(*file)); + vmime::shared_ptr ffile = fsf->create(m_tempPath / fsf->stringToPath(*file)); ffile->createFile(); - vmime::ref fileWriter = ffile->getFileWriter(); - vmime::ref os = fileWriter->getOutputStream(); + vmime::shared_ptr fileWriter = ffile->getFileWriter(); + vmime::shared_ptr os = fileWriter->getOutputStream(); os->write(contents.data(), contents.length()); os->flush(); - fileWriter = NULL; + fileWriter = vmime::null; } } void destroyMaildir() { - vmime::ref fsf = + vmime::shared_ptr fsf = vmime::platform::getHandler()->getFileSystemFactory(); recursiveDelete(fsf->create(m_tempPath)); } - void recursiveDelete(vmime::ref dir) + void recursiveDelete(vmime::shared_ptr dir) { if (!dir->exists() || !dir->isDirectory()) return; - vmime::ref files = dir->getFiles(); + vmime::shared_ptr files = dir->getFiles(); // First, delete files and subdirectories in this directory while (files->hasMoreElements()) { - vmime::ref file = files->nextElement(); + vmime::shared_ptr file = files->nextElement(); if (file->isDirectory()) { diff --git a/tests/net/pop3/POP3CommandTest.cpp b/tests/net/pop3/POP3CommandTest.cpp index 14c92be4..4733c96b 100644 --- a/tests/net/pop3/POP3CommandTest.cpp +++ b/tests/net/pop3/POP3CommandTest.cpp @@ -59,7 +59,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testCreateCommand() { - vmime::ref cmd = POP3Command::createCommand("MY_COMMAND"); + vmime::shared_ptr cmd = POP3Command::createCommand("MY_COMMAND"); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "MY_COMMAND", cmd->getText()); @@ -67,7 +67,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testCreateCommandParams() { - vmime::ref cmd = POP3Command::createCommand("MY_COMMAND param1 param2"); + vmime::shared_ptr cmd = POP3Command::createCommand("MY_COMMAND param1 param2"); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "MY_COMMAND param1 param2", cmd->getText()); @@ -75,7 +75,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testCAPA() { - vmime::ref cmd = POP3Command::CAPA(); + vmime::shared_ptr cmd = POP3Command::CAPA(); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "CAPA", cmd->getText()); @@ -83,7 +83,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testNOOP() { - vmime::ref cmd = POP3Command::NOOP(); + vmime::shared_ptr cmd = POP3Command::NOOP(); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "NOOP", cmd->getText()); @@ -91,7 +91,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testAUTH() { - vmime::ref cmd = POP3Command::AUTH("saslmechanism"); + vmime::shared_ptr cmd = POP3Command::AUTH("saslmechanism"); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "AUTH saslmechanism", cmd->getText()); @@ -99,7 +99,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testSTLS() { - vmime::ref cmd = POP3Command::STLS(); + vmime::shared_ptr cmd = POP3Command::STLS(); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "STLS", cmd->getText()); @@ -107,7 +107,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testAPOP() { - vmime::ref cmd = POP3Command::APOP("user", "digest"); + vmime::shared_ptr cmd = POP3Command::APOP("user", "digest"); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "APOP user digest", cmd->getText()); @@ -115,7 +115,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testUSER() { - vmime::ref cmd = POP3Command::USER("user"); + vmime::shared_ptr cmd = POP3Command::USER("user"); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "USER user", cmd->getText()); @@ -123,7 +123,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testPASS() { - vmime::ref cmd = POP3Command::PASS("pass"); + vmime::shared_ptr cmd = POP3Command::PASS("pass"); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "PASS pass", cmd->getText()); @@ -131,7 +131,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testSTAT() { - vmime::ref cmd = POP3Command::STAT(); + vmime::shared_ptr cmd = POP3Command::STAT(); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "STAT", cmd->getText()); @@ -139,7 +139,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testLIST() { - vmime::ref cmd = POP3Command::LIST(); + vmime::shared_ptr cmd = POP3Command::LIST(); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "LIST", cmd->getText()); @@ -147,7 +147,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testLISTMessage() { - vmime::ref cmd = POP3Command::LIST(42); + vmime::shared_ptr cmd = POP3Command::LIST(42); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "LIST 42", cmd->getText()); @@ -155,7 +155,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testUIDL() { - vmime::ref cmd = POP3Command::UIDL(); + vmime::shared_ptr cmd = POP3Command::UIDL(); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "UIDL", cmd->getText()); @@ -163,7 +163,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testUIDLMessage() { - vmime::ref cmd = POP3Command::UIDL(42); + vmime::shared_ptr cmd = POP3Command::UIDL(42); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "UIDL 42", cmd->getText()); @@ -171,7 +171,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testDELE() { - vmime::ref cmd = POP3Command::DELE(42); + vmime::shared_ptr cmd = POP3Command::DELE(42); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "DELE 42", cmd->getText()); @@ -179,7 +179,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testRETR() { - vmime::ref cmd = POP3Command::RETR(42); + vmime::shared_ptr cmd = POP3Command::RETR(42); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "RETR 42", cmd->getText()); @@ -187,7 +187,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testTOP() { - vmime::ref cmd = POP3Command::TOP(42, 567); + vmime::shared_ptr cmd = POP3Command::TOP(42, 567); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "TOP 42 567", cmd->getText()); @@ -195,7 +195,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testRSET() { - vmime::ref cmd = POP3Command::RSET(); + vmime::shared_ptr cmd = POP3Command::RSET(); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "RSET", cmd->getText()); @@ -203,7 +203,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testQUIT() { - vmime::ref cmd = POP3Command::QUIT(); + vmime::shared_ptr cmd = POP3Command::QUIT(); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "QUIT", cmd->getText()); @@ -211,11 +211,12 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest) void testWriteToSocket() { - vmime::ref cmd = POP3Command::createCommand("MY_COMMAND param1 param2"); + vmime::shared_ptr cmd = POP3Command::createCommand("MY_COMMAND param1 param2"); - vmime::ref sok = vmime::create (); - vmime::ref conn = vmime::create - (sok.dynamicCast (), vmime::null); + vmime::shared_ptr sok = vmime::make_shared (); + vmime::shared_ptr conn = vmime::make_shared + (vmime::dynamicCast (sok), + vmime::shared_ptr ()); cmd->send(conn); diff --git a/tests/net/pop3/POP3ResponseTest.cpp b/tests/net/pop3/POP3ResponseTest.cpp index f1fbcd54..2d3b3d32 100644 --- a/tests/net/pop3/POP3ResponseTest.cpp +++ b/tests/net/pop3/POP3ResponseTest.cpp @@ -47,15 +47,15 @@ VMIME_TEST_SUITE_BEGIN(POP3ResponseTest) void testSingleLineResponseOK() { - vmime::ref socket = vmime::create (); - vmime::ref toh = vmime::create (); + vmime::shared_ptr socket = vmime::make_shared (); + vmime::shared_ptr toh = vmime::make_shared (); - vmime::ref conn = vmime::create - (socket.dynamicCast (), toh); + vmime::shared_ptr conn = vmime::make_shared + (vmime::dynamicCast (socket), toh); socket->localSend("+OK Response Text\r\n"); - vmime::ref resp = + vmime::shared_ptr resp = POP3Response::readResponse(conn); VASSERT_EQ("Code", POP3Response::CODE_OK, resp->getCode()); @@ -67,15 +67,15 @@ VMIME_TEST_SUITE_BEGIN(POP3ResponseTest) void testSingleLineResponseERR() { - vmime::ref socket = vmime::create (); - vmime::ref toh = vmime::create (); + vmime::shared_ptr socket = vmime::make_shared (); + vmime::shared_ptr toh = vmime::make_shared (); - vmime::ref conn = vmime::create - (socket.dynamicCast (), toh); + vmime::shared_ptr conn = vmime::make_shared + (vmime::dynamicCast (socket), toh); socket->localSend("-ERR Response Text\r\n"); - vmime::ref resp = + vmime::shared_ptr resp = POP3Response::readResponse(conn); VASSERT_EQ("Code", POP3Response::CODE_ERR, resp->getCode()); @@ -87,15 +87,15 @@ VMIME_TEST_SUITE_BEGIN(POP3ResponseTest) void testSingleLineResponseReady() { - vmime::ref socket = vmime::create (); - vmime::ref toh = vmime::create (); + vmime::shared_ptr socket = vmime::make_shared (); + vmime::shared_ptr toh = vmime::make_shared (); - vmime::ref conn = vmime::create - (socket.dynamicCast (), toh); + vmime::shared_ptr conn = vmime::make_shared + (vmime::dynamicCast (socket), toh); socket->localSend("+ challenge_string\r\n"); - vmime::ref resp = + vmime::shared_ptr resp = POP3Response::readResponse(conn); VASSERT_EQ("Code", POP3Response::CODE_READY, resp->getCode()); @@ -107,15 +107,15 @@ VMIME_TEST_SUITE_BEGIN(POP3ResponseTest) void testSingleLineResponseInvalid() { - vmime::ref socket = vmime::create (); - vmime::ref toh = vmime::create (); + vmime::shared_ptr socket = vmime::make_shared (); + vmime::shared_ptr toh = vmime::make_shared (); - vmime::ref conn = vmime::create - (socket.dynamicCast (), toh); + vmime::shared_ptr conn = vmime::make_shared + (vmime::dynamicCast (socket), toh); socket->localSend("Invalid Response Text\r\n"); - vmime::ref resp = + vmime::shared_ptr resp = POP3Response::readResponse(conn); VASSERT_EQ("Code", POP3Response::CODE_ERR, resp->getCode()); @@ -127,15 +127,15 @@ VMIME_TEST_SUITE_BEGIN(POP3ResponseTest) void testSingleLineResponseLF() { - vmime::ref socket = vmime::create (); - vmime::ref toh = vmime::create (); + vmime::shared_ptr socket = vmime::make_shared (); + vmime::shared_ptr toh = vmime::make_shared (); - vmime::ref conn = vmime::create - (socket.dynamicCast (), toh); + vmime::shared_ptr conn = vmime::make_shared + (vmime::dynamicCast (socket), toh); socket->localSend("+OK Response terminated by LF\n"); - vmime::ref resp = + vmime::shared_ptr resp = POP3Response::readResponse(conn); VASSERT_EQ("Code", POP3Response::CODE_OK, resp->getCode()); @@ -147,18 +147,18 @@ VMIME_TEST_SUITE_BEGIN(POP3ResponseTest) void testMultiLineResponse() { - vmime::ref socket = vmime::create (); - vmime::ref toh = vmime::create (); + vmime::shared_ptr socket = vmime::make_shared (); + vmime::shared_ptr toh = vmime::make_shared (); - vmime::ref conn = vmime::create - (socket.dynamicCast (), toh); + vmime::shared_ptr conn = vmime::make_shared + (vmime::dynamicCast (socket), toh); socket->localSend("+OK Response Text\r\n"); socket->localSend("Line 1\r\n"); socket->localSend("Line 2\r\n"); socket->localSend(".\r\n"); - vmime::ref resp = + vmime::shared_ptr resp = POP3Response::readMultilineResponse(conn); VASSERT_EQ("Code", POP3Response::CODE_OK, resp->getCode()); @@ -172,18 +172,18 @@ VMIME_TEST_SUITE_BEGIN(POP3ResponseTest) void testMultiLineResponseLF() { - vmime::ref socket = vmime::create (); - vmime::ref toh = vmime::create (); + vmime::shared_ptr socket = vmime::make_shared (); + vmime::shared_ptr toh = vmime::make_shared (); - vmime::ref conn = vmime::create - (socket.dynamicCast (), toh); + vmime::shared_ptr conn = vmime::make_shared + (vmime::dynamicCast (socket), toh); socket->localSend("+OK Response Text\n"); socket->localSend("Line 1\n"); socket->localSend("Line 2\n"); socket->localSend(".\n"); - vmime::ref resp = + vmime::shared_ptr resp = POP3Response::readMultilineResponse(conn); VASSERT_EQ("Code", POP3Response::CODE_OK, resp->getCode()); @@ -202,11 +202,11 @@ VMIME_TEST_SUITE_BEGIN(POP3ResponseTest) for (unsigned int i = 0 ; i < 5000 ; ++i) data << "VMIME.VMIME\nVMIME\r\nVMIME_VMIME"; - vmime::ref socket = vmime::create (); - vmime::ref toh = vmime::create (); + vmime::shared_ptr socket = vmime::make_shared (); + vmime::shared_ptr toh = vmime::make_shared (); - vmime::ref conn = vmime::create - (socket.dynamicCast (), toh); + vmime::shared_ptr conn = vmime::make_shared + (vmime::dynamicCast (socket), toh); socket->localSend("+OK Large Response Follows\n"); socket->localSend(data.str()); @@ -215,7 +215,7 @@ VMIME_TEST_SUITE_BEGIN(POP3ResponseTest) vmime::string receivedData; vmime::utility::outputStreamStringAdapter receivedDataStream(receivedData); - vmime::ref resp = + vmime::shared_ptr resp = POP3Response::readLargeResponse(conn, receivedDataStream, NULL, 0); VASSERT_EQ("Code", POP3Response::CODE_OK, resp->getCode()); diff --git a/tests/net/pop3/POP3StoreTest.cpp b/tests/net/pop3/POP3StoreTest.cpp index d938f472..5517f770 100644 --- a/tests/net/pop3/POP3StoreTest.cpp +++ b/tests/net/pop3/POP3StoreTest.cpp @@ -39,29 +39,29 @@ VMIME_TEST_SUITE_BEGIN(POP3StoreTest) void testCreateFromURL() { - vmime::ref sess - = vmime::create (); + vmime::shared_ptr sess + = vmime::make_shared (); // POP3 vmime::utility::url url("pop3://pop3.vmime.org"); - vmime::ref store = sess->getStore(url); + vmime::shared_ptr store = sess->getStore(url); VASSERT_TRUE("pop3", typeid(*store) == typeid(vmime::net::pop3::POP3Store)); // POP3S vmime::utility::url url2("pop3s://pop3s.vmime.org"); - vmime::ref store2 = sess->getStore(url2); + vmime::shared_ptr store2 = sess->getStore(url2); VASSERT_TRUE("pop3s", typeid(*store2) == typeid(vmime::net::pop3::POP3SStore)); } void testConnectToInvalidServer() { - vmime::ref sess - = vmime::create (); + vmime::shared_ptr sess + = vmime::make_shared (); vmime::utility::url url("pop3://invalid-pop3-server"); - vmime::ref store = sess->getStore(url); + vmime::shared_ptr store = sess->getStore(url); VASSERT_THROW("connect", store->connect(), vmime::exceptions::connection_error); } diff --git a/tests/net/pop3/POP3TestUtils.hpp b/tests/net/pop3/POP3TestUtils.hpp index 26b6601a..1c6e8935 100644 --- a/tests/net/pop3/POP3TestUtils.hpp +++ b/tests/net/pop3/POP3TestUtils.hpp @@ -29,25 +29,26 @@ class POP3ConnectionTest : public vmime::net::pop3::POP3Connection { public: - POP3ConnectionTest(vmime::ref socket, - vmime::ref timeoutHandler) - : POP3Connection(NULL, NULL), + POP3ConnectionTest(vmime::shared_ptr socket, + vmime::shared_ptr timeoutHandler) + : POP3Connection(vmime::shared_ptr (), + vmime::shared_ptr ()), m_socket(socket), m_timeoutHandler(timeoutHandler) { } - vmime::ref getSocket() + vmime::shared_ptr getSocket() { return m_socket; } - vmime::ref getTimeoutHandler() + vmime::shared_ptr getTimeoutHandler() { return m_timeoutHandler; } private: - vmime::ref m_socket; - vmime::ref m_timeoutHandler; + vmime::shared_ptr m_socket; + vmime::shared_ptr m_timeoutHandler; }; diff --git a/tests/net/pop3/POP3UtilsTest.cpp b/tests/net/pop3/POP3UtilsTest.cpp index 9d443ddb..55a99806 100644 --- a/tests/net/pop3/POP3UtilsTest.cpp +++ b/tests/net/pop3/POP3UtilsTest.cpp @@ -41,11 +41,11 @@ VMIME_TEST_SUITE_BEGIN(POP3UtilsTest) void testParseMultiListOrUidlResponse() { - vmime::ref socket = vmime::create (); - vmime::ref toh = vmime::create (); + vmime::shared_ptr socket = vmime::make_shared (); + vmime::shared_ptr toh = vmime::make_shared (); - vmime::ref conn = vmime::create - (socket.dynamicCast (), toh); + vmime::shared_ptr conn = vmime::make_shared + (vmime::dynamicCast (socket), toh); socket->localSend("+OK Response Text\r\n"); socket->localSend("1 abcdef\r\n"); @@ -55,7 +55,7 @@ VMIME_TEST_SUITE_BEGIN(POP3UtilsTest) socket->localSend("8 yz \r\n"); socket->localSend(".\r\n"); - vmime::ref resp = + vmime::shared_ptr resp = POP3Response::readMultilineResponse(conn); std::map result; diff --git a/tests/net/smtp/SMTPCommandSetTest.cpp b/tests/net/smtp/SMTPCommandSetTest.cpp index 0cf4b03b..af250078 100644 --- a/tests/net/smtp/SMTPCommandSetTest.cpp +++ b/tests/net/smtp/SMTPCommandSetTest.cpp @@ -46,7 +46,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandSetTest) void testCreate() { - vmime::ref cset = SMTPCommandSet::create(/* pipelining */ false); + vmime::shared_ptr cset = SMTPCommandSet::create(/* pipelining */ false); VASSERT_NOT_NULL("Not null", cset); VASSERT_FALSE("Finished", cset->isFinished()); @@ -54,7 +54,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandSetTest) void testCreatePipeline() { - vmime::ref cset = SMTPCommandSet::create(/* pipelining */ true); + vmime::shared_ptr cset = SMTPCommandSet::create(/* pipelining */ true); VASSERT_NOT_NULL("Not null", cset); VASSERT_FALSE("Finished", cset->isFinished()); @@ -62,14 +62,14 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandSetTest) void testAddCommand() { - vmime::ref cset = SMTPCommandSet::create(/* pipelining */ false); + vmime::shared_ptr cset = SMTPCommandSet::create(/* pipelining */ false); VASSERT_NO_THROW("No throw 1", cset->addCommand(SMTPCommand::createCommand("MY_COMMAND1"))); VASSERT_EQ("Text", "MY_COMMAND1\r\n", cset->getText()); VASSERT_NO_THROW("No throw 2", cset->addCommand(SMTPCommand::createCommand("MY_COMMAND2"))); VASSERT_EQ("Text", "MY_COMMAND1\r\nMY_COMMAND2\r\n", cset->getText()); - vmime::ref sok = vmime::create (); + vmime::shared_ptr sok = vmime::make_shared (); cset->writeToSocket(sok); VASSERT_FALSE("Finished", cset->isFinished()); @@ -83,14 +83,14 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandSetTest) void testAddCommandPipeline() { - vmime::ref cset = SMTPCommandSet::create(/* pipelining */ true); + vmime::shared_ptr cset = SMTPCommandSet::create(/* pipelining */ true); VASSERT_NO_THROW("No throw 1", cset->addCommand(SMTPCommand::createCommand("MY_COMMAND1"))); VASSERT_EQ("Text", "MY_COMMAND1\r\n", cset->getText()); VASSERT_NO_THROW("No throw 2", cset->addCommand(SMTPCommand::createCommand("MY_COMMAND2"))); VASSERT_EQ("Text", "MY_COMMAND1\r\nMY_COMMAND2\r\n", cset->getText()); - vmime::ref sok = vmime::create (); + vmime::shared_ptr sok = vmime::make_shared (); vmime::string response; cset->writeToSocket(sok); @@ -105,12 +105,12 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandSetTest) void testWriteToSocket() { - vmime::ref cset = SMTPCommandSet::create(/* pipelining */ false); + vmime::shared_ptr cset = SMTPCommandSet::create(/* pipelining */ false); cset->addCommand(SMTPCommand::createCommand("MY_COMMAND1")); cset->addCommand(SMTPCommand::createCommand("MY_COMMAND2")); - vmime::ref sok = vmime::create (); + vmime::shared_ptr sok = vmime::make_shared (); vmime::string response; cset->writeToSocket(sok); @@ -126,12 +126,12 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandSetTest) void testWriteToSocketPipeline() { - vmime::ref cset = SMTPCommandSet::create(/* pipelining */ true); + vmime::shared_ptr cset = SMTPCommandSet::create(/* pipelining */ true); cset->addCommand(SMTPCommand::createCommand("MY_COMMAND1")); cset->addCommand(SMTPCommand::createCommand("MY_COMMAND2")); - vmime::ref sok = vmime::create (); + vmime::shared_ptr sok = vmime::make_shared (); vmime::string response; cset->writeToSocket(sok); @@ -142,12 +142,12 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandSetTest) void testGetLastCommandSent() { - vmime::ref cset = SMTPCommandSet::create(/* pipelining */ false); + vmime::shared_ptr cset = SMTPCommandSet::create(/* pipelining */ false); cset->addCommand(SMTPCommand::createCommand("MY_COMMAND1")); cset->addCommand(SMTPCommand::createCommand("MY_COMMAND2")); - vmime::ref sok = vmime::create (); + vmime::shared_ptr sok = vmime::make_shared (); cset->writeToSocket(sok); VASSERT_EQ("Cmd 1", "MY_COMMAND1", cset->getLastCommandSent()->getText()); @@ -158,12 +158,12 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandSetTest) void testGetLastCommandSentPipeline() { - vmime::ref cset = SMTPCommandSet::create(/* pipelining */ true); + vmime::shared_ptr cset = SMTPCommandSet::create(/* pipelining */ true); cset->addCommand(SMTPCommand::createCommand("MY_COMMAND1")); cset->addCommand(SMTPCommand::createCommand("MY_COMMAND2")); - vmime::ref sok = vmime::create (); + vmime::shared_ptr sok = vmime::make_shared (); cset->writeToSocket(sok); VASSERT_EQ("Cmd 1", "MY_COMMAND1", cset->getLastCommandSent()->getText()); diff --git a/tests/net/smtp/SMTPCommandTest.cpp b/tests/net/smtp/SMTPCommandTest.cpp index 9a2c90fc..6d466865 100644 --- a/tests/net/smtp/SMTPCommandTest.cpp +++ b/tests/net/smtp/SMTPCommandTest.cpp @@ -57,7 +57,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testCreateCommand() { - vmime::ref cmd = SMTPCommand::createCommand("MY_COMMAND"); + vmime::shared_ptr cmd = SMTPCommand::createCommand("MY_COMMAND"); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "MY_COMMAND", cmd->getText()); @@ -65,7 +65,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testCreateCommandParams() { - vmime::ref cmd = SMTPCommand::createCommand("MY_COMMAND param1 param2"); + vmime::shared_ptr cmd = SMTPCommand::createCommand("MY_COMMAND param1 param2"); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "MY_COMMAND param1 param2", cmd->getText()); @@ -73,7 +73,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testHELO() { - vmime::ref cmd = SMTPCommand::HELO("hostname"); + vmime::shared_ptr cmd = SMTPCommand::HELO("hostname"); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "HELO hostname", cmd->getText()); @@ -81,7 +81,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testEHLO() { - vmime::ref cmd = SMTPCommand::EHLO("hostname"); + vmime::shared_ptr cmd = SMTPCommand::EHLO("hostname"); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "EHLO hostname", cmd->getText()); @@ -89,7 +89,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testAUTH() { - vmime::ref cmd = SMTPCommand::AUTH("saslmechanism"); + vmime::shared_ptr cmd = SMTPCommand::AUTH("saslmechanism"); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "AUTH saslmechanism", cmd->getText()); @@ -97,7 +97,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testSTARTTLS() { - vmime::ref cmd = SMTPCommand::STARTTLS(); + vmime::shared_ptr cmd = SMTPCommand::STARTTLS(); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "STARTTLS", cmd->getText()); @@ -105,7 +105,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testMAIL() { - vmime::ref cmd = SMTPCommand::MAIL(vmime::mailbox("me@vmime.org"), false); + vmime::shared_ptr cmd = SMTPCommand::MAIL(vmime::mailbox("me@vmime.org"), false); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "MAIL FROM:", cmd->getText()); @@ -113,7 +113,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testMAIL_Encoded() { - vmime::ref cmd = SMTPCommand::MAIL + vmime::shared_ptr cmd = SMTPCommand::MAIL (vmime::mailbox(vmime::emailAddress("mailtest", "例ãˆ.テスト")), false); VASSERT_NOT_NULL("Not null", cmd); @@ -122,7 +122,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testMAIL_UTF8() { - vmime::ref cmd = SMTPCommand::MAIL + vmime::shared_ptr cmd = SMTPCommand::MAIL (vmime::mailbox(vmime::emailAddress("mailtest", "例ãˆ.テスト")), true); VASSERT_NOT_NULL("Not null", cmd); @@ -131,7 +131,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testMAIL_SIZE() { - vmime::ref cmd = SMTPCommand::MAIL + vmime::shared_ptr cmd = SMTPCommand::MAIL (vmime::mailbox("me@vmime.org"), false, 123456789); VASSERT_NOT_NULL("Not null", cmd); @@ -140,7 +140,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testMAIL_SIZE_UTF8() { - vmime::ref cmd = SMTPCommand::MAIL + vmime::shared_ptr cmd = SMTPCommand::MAIL (vmime::mailbox(vmime::emailAddress("mailtest", "例ãˆ.テスト")), true, 123456789); VASSERT_NOT_NULL("Not null", cmd); @@ -149,7 +149,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testRCPT() { - vmime::ref cmd = SMTPCommand::RCPT(vmime::mailbox("someone@vmime.org"), false); + vmime::shared_ptr cmd = SMTPCommand::RCPT(vmime::mailbox("someone@vmime.org"), false); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "RCPT TO:", cmd->getText()); @@ -157,7 +157,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testRCPT_Encoded() { - vmime::ref cmd = SMTPCommand::RCPT + vmime::shared_ptr cmd = SMTPCommand::RCPT (vmime::mailbox(vmime::emailAddress("mailtest", "例ãˆ.テスト")), false); VASSERT_NOT_NULL("Not null", cmd); @@ -166,7 +166,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testRCPT_UTF8() { - vmime::ref cmd = SMTPCommand::RCPT + vmime::shared_ptr cmd = SMTPCommand::RCPT (vmime::mailbox(vmime::emailAddress("mailtest", "例ãˆ.テスト")), true); VASSERT_NOT_NULL("Not null", cmd); @@ -175,7 +175,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testRSET() { - vmime::ref cmd = SMTPCommand::RSET(); + vmime::shared_ptr cmd = SMTPCommand::RSET(); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "RSET", cmd->getText()); @@ -183,7 +183,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testDATA() { - vmime::ref cmd = SMTPCommand::DATA(); + vmime::shared_ptr cmd = SMTPCommand::DATA(); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "DATA", cmd->getText()); @@ -191,12 +191,12 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testBDAT() { - vmime::ref cmd1 = SMTPCommand::BDAT(12345, false); + vmime::shared_ptr cmd1 = SMTPCommand::BDAT(12345, false); VASSERT_NOT_NULL("Not null", cmd1); VASSERT_EQ("Text", "BDAT 12345", cmd1->getText()); - vmime::ref cmd2 = SMTPCommand::BDAT(67890, true); + vmime::shared_ptr cmd2 = SMTPCommand::BDAT(67890, true); VASSERT_NOT_NULL("Not null", cmd2); VASSERT_EQ("Text", "BDAT 67890 LAST", cmd2->getText()); @@ -204,7 +204,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testNOOP() { - vmime::ref cmd = SMTPCommand::NOOP(); + vmime::shared_ptr cmd = SMTPCommand::NOOP(); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "NOOP", cmd->getText()); @@ -212,7 +212,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testQUIT() { - vmime::ref cmd = SMTPCommand::QUIT(); + vmime::shared_ptr cmd = SMTPCommand::QUIT(); VASSERT_NOT_NULL("Not null", cmd); VASSERT_EQ("Text", "QUIT", cmd->getText()); @@ -220,9 +220,9 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest) void testWriteToSocket() { - vmime::ref cmd = SMTPCommand::createCommand("MY_COMMAND param1 param2"); + vmime::shared_ptr cmd = SMTPCommand::createCommand("MY_COMMAND param1 param2"); - vmime::ref sok = vmime::create (); + vmime::shared_ptr sok = vmime::make_shared (); cmd->writeToSocket(sok); vmime::string response; diff --git a/tests/net/smtp/SMTPResponseTest.cpp b/tests/net/smtp/SMTPResponseTest.cpp index 5e75b6a7..352f46c2 100644 --- a/tests/net/smtp/SMTPResponseTest.cpp +++ b/tests/net/smtp/SMTPResponseTest.cpp @@ -43,15 +43,15 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest) void testSingleLineResponse() { - vmime::ref socket = vmime::create (); - vmime::ref toh = - vmime::create (); + vmime::shared_ptr socket = vmime::make_shared (); + vmime::shared_ptr toh = + vmime::make_shared (); socket->localSend("123 Response Text\r\n"); vmime::net::smtp::SMTPResponse::state responseState; - vmime::ref resp = + vmime::shared_ptr resp = vmime::net::smtp::SMTPResponse::readResponse(socket, toh, responseState); VASSERT_EQ("Code", 123, resp->getCode()); @@ -61,15 +61,15 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest) void testSingleLineResponseLF() { - vmime::ref socket = vmime::create (); - vmime::ref toh = - vmime::create (); + vmime::shared_ptr socket = vmime::make_shared (); + vmime::shared_ptr toh = + vmime::make_shared (); socket->localSend("123 Response Text\n"); vmime::net::smtp::SMTPResponse::state responseState; - vmime::ref resp = + vmime::shared_ptr resp = vmime::net::smtp::SMTPResponse::readResponse(socket, toh, responseState); VASSERT_EQ("Code", 123, resp->getCode()); @@ -79,9 +79,9 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest) void testMultiLineResponse() { - vmime::ref socket = vmime::create (); - vmime::ref toh = - vmime::create (); + vmime::shared_ptr socket = vmime::make_shared (); + vmime::shared_ptr toh = + vmime::make_shared (); socket->localSend ( @@ -91,7 +91,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest) vmime::net::smtp::SMTPResponse::state responseState; - vmime::ref resp = + vmime::shared_ptr resp = vmime::net::smtp::SMTPResponse::readResponse(socket, toh, responseState); VASSERT_EQ("Code", 123, resp->getCode()); @@ -107,9 +107,9 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest) void testMultiLineResponseDifferentCode() { - vmime::ref socket = vmime::create (); - vmime::ref toh = - vmime::create (); + vmime::shared_ptr socket = vmime::make_shared (); + vmime::shared_ptr toh = + vmime::make_shared (); socket->localSend ( @@ -119,7 +119,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest) vmime::net::smtp::SMTPResponse::state responseState; - vmime::ref resp = + vmime::shared_ptr resp = vmime::net::smtp::SMTPResponse::readResponse(socket, toh, responseState); VASSERT_EQ("Code", 0, resp->getCode()); @@ -135,9 +135,9 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest) void testIncompleteMultiLineResponse() { - vmime::ref socket = vmime::create (); - vmime::ref toh = - vmime::create (1); + vmime::shared_ptr socket = vmime::make_shared (); + vmime::shared_ptr toh = + vmime::make_shared (1); socket->localSend ( @@ -155,9 +155,9 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest) void testNoResponseText() { - vmime::ref socket = vmime::create (); - vmime::ref toh = - vmime::create (1); + vmime::shared_ptr socket = vmime::make_shared (); + vmime::shared_ptr toh = + vmime::make_shared (1); socket->localSend ( @@ -166,7 +166,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest) vmime::net::smtp::SMTPResponse::state responseState; - vmime::ref resp = + vmime::shared_ptr resp = vmime::net::smtp::SMTPResponse::readResponse(socket, toh, responseState); VASSERT_EQ("Code", 250, resp->getCode()); @@ -176,15 +176,15 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest) void testEnhancedStatusCode() { - vmime::ref socket = vmime::create (); - vmime::ref toh = - vmime::create (); + vmime::shared_ptr socket = vmime::make_shared (); + vmime::shared_ptr toh = + vmime::make_shared (); socket->localSend("250 2.1.5 OK fu13sm4720601wic.7 - gsmtp\r\n"); vmime::net::smtp::SMTPResponse::state responseState; - vmime::ref resp = + vmime::shared_ptr resp = vmime::net::smtp::SMTPResponse::readResponse(socket, toh, responseState); VASSERT_EQ("Code", 250, resp->getCode()); @@ -197,15 +197,15 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest) void testNoEnhancedStatusCode() { - vmime::ref socket = vmime::create (); - vmime::ref toh = - vmime::create (); + vmime::shared_ptr socket = vmime::make_shared (); + vmime::shared_ptr toh = + vmime::make_shared (); socket->localSend("354 Go ahead fu13sm4720601wic.7 - gsmtp\r\n"); vmime::net::smtp::SMTPResponse::state responseState; - vmime::ref resp = + vmime::shared_ptr resp = vmime::net::smtp::SMTPResponse::readResponse(socket, toh, responseState); VASSERT_EQ("Code", 354, resp->getCode()); @@ -218,15 +218,15 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest) void testInvalidEnhancedStatusCode() { - vmime::ref socket = vmime::create (); - vmime::ref toh = - vmime::create (); + vmime::shared_ptr socket = vmime::make_shared (); + vmime::shared_ptr toh = + vmime::make_shared (); socket->localSend("250 4.2 xxx\r\n"); vmime::net::smtp::SMTPResponse::state responseState; - vmime::ref resp = + vmime::shared_ptr resp = vmime::net::smtp::SMTPResponse::readResponse(socket, toh, responseState); VASSERT_EQ("Code", 250, resp->getCode()); diff --git a/tests/net/smtp/SMTPTransportTest.cpp b/tests/net/smtp/SMTPTransportTest.cpp index 13c18309..5997588e 100644 --- a/tests/net/smtp/SMTPTransportTest.cpp +++ b/tests/net/smtp/SMTPTransportTest.cpp @@ -44,25 +44,25 @@ VMIME_TEST_SUITE_BEGIN(SMTPTransportTest) void testConnectToInvalidServer() { - vmime::ref sess - = vmime::create (); + vmime::shared_ptr sess + = vmime::make_shared (); vmime::utility::url url("smtp://invalid-smtp-server"); - vmime::ref store = sess->getTransport(url); + vmime::shared_ptr store = sess->getTransport(url); VASSERT_THROW("connect", store->connect(), vmime::exceptions::connection_error); } void testGreetingError() { - vmime::ref session = - vmime::create (); + vmime::shared_ptr session = + vmime::make_shared (); - vmime::ref tr = session->getTransport + vmime::shared_ptr tr = session->getTransport (vmime::utility::url("smtp://localhost")); - tr->setSocketFactory(vmime::create >()); - tr->setTimeoutHandlerFactory(vmime::create ()); + tr->setSocketFactory(vmime::make_shared >()); + tr->setTimeoutHandlerFactory(vmime::make_shared ()); VASSERT_THROW("Connection", tr->connect(), vmime::exceptions::connection_greeting_error); @@ -70,23 +70,23 @@ VMIME_TEST_SUITE_BEGIN(SMTPTransportTest) void testMAILandRCPT() { - vmime::ref session = - vmime::create (); + vmime::shared_ptr session = + vmime::make_shared (); - vmime::ref tr = session->getTransport + vmime::shared_ptr tr = session->getTransport (vmime::utility::url("smtp://localhost")); - tr->setSocketFactory(vmime::create >()); - tr->setTimeoutHandlerFactory(vmime::create ()); + tr->setSocketFactory(vmime::make_shared >()); + tr->setTimeoutHandlerFactory(vmime::make_shared ()); VASSERT_NO_THROW("Connection", tr->connect()); vmime::mailbox exp("expeditor@test.vmime.org"); vmime::mailboxList recips; - recips.appendMailbox(vmime::create ("recipient1@test.vmime.org")); - recips.appendMailbox(vmime::create ("recipient2@test.vmime.org")); - recips.appendMailbox(vmime::create ("recipient3@test.vmime.org")); + recips.appendMailbox(vmime::make_shared ("recipient1@test.vmime.org")); + recips.appendMailbox(vmime::make_shared ("recipient2@test.vmime.org")); + recips.appendMailbox(vmime::make_shared ("recipient3@test.vmime.org")); vmime::string data("Message data"); vmime::utility::inputStreamStringAdapter is(data); @@ -96,52 +96,52 @@ VMIME_TEST_SUITE_BEGIN(SMTPTransportTest) void testChunking() { - vmime::ref session = - vmime::create (); + vmime::shared_ptr session = + vmime::make_shared (); - vmime::ref tr = session->getTransport + vmime::shared_ptr tr = session->getTransport (vmime::utility::url("smtp://localhost")); - tr->setSocketFactory(vmime::create >()); - tr->setTimeoutHandlerFactory(vmime::create ()); + tr->setSocketFactory(vmime::make_shared >()); + tr->setTimeoutHandlerFactory(vmime::make_shared ()); tr->connect(); VASSERT("Test server should report it supports the CHUNKING extension!", - tr.dynamicCast ()->getConnection()->hasExtension("CHUNKING")); + vmime::dynamicCast (tr)->getConnection()->hasExtension("CHUNKING")); vmime::mailbox exp("expeditor@test.vmime.org"); vmime::mailboxList recips; - recips.appendMailbox(vmime::create ("recipient@test.vmime.org")); + recips.appendMailbox(vmime::make_shared ("recipient@test.vmime.org")); - vmime::ref msg = vmime::create (); + vmime::shared_ptr msg = vmime::make_shared (); tr->send(msg, exp, recips); } void testSize_Chunking() { - vmime::ref session = - vmime::create (); + vmime::shared_ptr session = + vmime::make_shared (); - vmime::ref tr = session->getTransport + vmime::shared_ptr tr = session->getTransport (vmime::utility::url("smtp://localhost")); - tr->setSocketFactory(vmime::create > >()); - tr->setTimeoutHandlerFactory(vmime::create ()); + tr->setSocketFactory(vmime::make_shared > >()); + tr->setTimeoutHandlerFactory(vmime::make_shared ()); tr->connect(); VASSERT("Test server should report it supports the SIZE extension!", - tr.dynamicCast ()->getConnection()->hasExtension("SIZE")); + vmime::dynamicCast (tr)->getConnection()->hasExtension("SIZE")); vmime::mailbox exp("expeditor@test.vmime.org"); vmime::mailboxList recips; - recips.appendMailbox(vmime::create ("recipient@test.vmime.org")); + recips.appendMailbox(vmime::make_shared ("recipient@test.vmime.org")); - vmime::ref msg = vmime::create (); + vmime::shared_ptr msg = vmime::make_shared (); VASSERT_THROW("Connection", tr->send(msg, exp, recips), vmime::net::smtp::SMTPMessageSizeExceedsMaxLimitsException); @@ -149,26 +149,26 @@ VMIME_TEST_SUITE_BEGIN(SMTPTransportTest) void testSize_NoChunking() { - vmime::ref session = - vmime::create (); + vmime::shared_ptr session = + vmime::make_shared (); - vmime::ref tr = session->getTransport + vmime::shared_ptr tr = session->getTransport (vmime::utility::url("smtp://localhost")); - tr->setSocketFactory(vmime::create > >()); - tr->setTimeoutHandlerFactory(vmime::create ()); + tr->setSocketFactory(vmime::make_shared > >()); + tr->setTimeoutHandlerFactory(vmime::make_shared ()); tr->connect(); VASSERT("Test server should report it supports the SIZE extension!", - tr.dynamicCast ()->getConnection()->hasExtension("SIZE")); + vmime::dynamicCast (tr)->getConnection()->hasExtension("SIZE")); vmime::mailbox exp("expeditor@test.vmime.org"); vmime::mailboxList recips; - recips.appendMailbox(vmime::create ("recipient@test.vmime.org")); + recips.appendMailbox(vmime::make_shared ("recipient@test.vmime.org")); - vmime::ref msg = vmime::create (); + vmime::shared_ptr msg = vmime::make_shared (); VASSERT_THROW("Connection", tr->send(msg, exp, recips), vmime::net::smtp::SMTPMessageSizeExceedsMaxLimitsException); diff --git a/tests/net/smtp/SMTPTransportTestUtils.hpp b/tests/net/smtp/SMTPTransportTestUtils.hpp index b74f9783..dd7afeb5 100644 --- a/tests/net/smtp/SMTPTransportTestUtils.hpp +++ b/tests/net/smtp/SMTPTransportTestUtils.hpp @@ -410,7 +410,7 @@ public: vmime::utility::stream::size_type getChunkBufferSize() const { - static vmime::net::smtp::SMTPChunkingOutputStreamAdapter chunkStream(NULL); + static vmime::net::smtp::SMTPChunkingOutputStreamAdapter chunkStream(vmime::null); return chunkStream.getBlockSize(); } @@ -456,13 +456,11 @@ public: bigMessageSMTPTestSocket() { m_state = STATE_NOT_CONNECTED; - m_bdatChunkCount = 0; m_ehloSent = m_mailSent = m_rcptSent = m_quitSent = false; } ~bigMessageSMTPTestSocket() { - VASSERT_EQ("BDAT chunk count", 3, m_bdatChunkCount); VASSERT("Client must send the QUIT command", m_quitSent); } @@ -476,22 +474,6 @@ public: void onDataReceived() { - if (m_state == STATE_DATA) - { - if (m_bdatChunkReceived != m_bdatChunkSize) - { - const size_type remaining = m_bdatChunkSize - m_bdatChunkReceived; - const size_type received = localReceiveRaw(NULL, remaining); - - m_bdatChunkReceived += received; - } - - if (m_bdatChunkReceived == m_bdatChunkSize) - { - m_state = STATE_COMMAND; - } - } - processCommand(); } @@ -584,8 +566,6 @@ private: }; int m_state; - int m_bdatChunkCount; - int m_bdatChunkSize, m_bdatChunkReceived; bool m_ehloSent, m_mailSent, m_rcptSent, m_quitSent; }; diff --git a/tests/parser/attachmentHelperTest.cpp b/tests/parser/attachmentHelperTest.cpp index 0ddf2448..4d4a2623 100644 --- a/tests/parser/attachmentHelperTest.cpp +++ b/tests/parser/attachmentHelperTest.cpp @@ -39,9 +39,9 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest) VMIME_TEST_LIST_END - static const vmime::string getStructure(vmime::ref part) + static const vmime::string getStructure(vmime::shared_ptr part) { - vmime::ref bdy = part->getBody(); + vmime::shared_ptr bdy = part->getBody(); vmime::string res = part->getBody()->getContentType().generate(); @@ -52,7 +52,7 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest) for (size_t i = 0 ; i < bdy->getPartCount() ; ++i) { - vmime::ref subPart = bdy->getPartAt(i); + vmime::shared_ptr subPart = bdy->getPartAt(i); if (i != 0) res += ","; @@ -63,9 +63,9 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest) return res + "]"; } - static const vmime::string extractBodyContents(vmime::ref part) + static const vmime::string extractBodyContents(vmime::shared_ptr part) { - vmime::ref cth = part->getBody()->getContents(); + vmime::shared_ptr cth = part->getBody()->getContents(); vmime::string data; vmime::utility::outputStreamStringAdapter os(data); @@ -83,11 +83,11 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest) "The text\r\n" ""; - vmime::ref msg = vmime::create (); + vmime::shared_ptr msg = vmime::make_shared (); msg->parse(data); - vmime::ref att = vmime::create - (vmime::create ("test"), + vmime::shared_ptr att = vmime::make_shared + (vmime::make_shared ("test"), vmime::mediaType("image/jpeg")); vmime::attachmentHelper::addAttachment(msg, att); @@ -112,11 +112,11 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest) "--foo--\r\n" ""; - vmime::ref msg = vmime::create (); + vmime::shared_ptr msg = vmime::make_shared (); msg->parse(data); - vmime::ref att = vmime::create - (vmime::create ("test"), + vmime::shared_ptr att = vmime::make_shared + (vmime::make_shared ("test"), vmime::mediaType("image/jpeg")); vmime::attachmentHelper::addAttachment(msg, att); @@ -136,11 +136,11 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest) "\r\n" "TWVzc2FnZSBib2R5"; - vmime::ref msg = vmime::create (); + vmime::shared_ptr msg = vmime::make_shared (); msg->parse(data); - vmime::ref att = vmime::create - (vmime::create ("test"), + vmime::shared_ptr att = vmime::make_shared + (vmime::make_shared ("test"), vmime::mediaType("image/jpeg")); vmime::attachmentHelper::addAttachment(msg, att); @@ -155,7 +155,7 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest) { vmime::string data = "Content-Disposition: attachment\r\n\r\nFoo\r\n"; - vmime::ref p = vmime::create (); + vmime::shared_ptr p = vmime::make_shared (); p->parse(data); VASSERT_EQ("1", true, vmime::attachmentHelper::isBodyPartAnAttachment(p)); @@ -167,7 +167,7 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest) { vmime::string data = "Content-Type: multipart/*\r\n\r\nFoo\r\n"; - vmime::ref p = vmime::create (); + vmime::shared_ptr p = vmime::make_shared (); p->parse(data); VASSERT_EQ("1", false, vmime::attachmentHelper::isBodyPartAnAttachment(p)); @@ -184,7 +184,7 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest) { vmime::string data = "Content-Type: application/octet-stream\r\n\r\nFoo\r\n"; - vmime::ref p = vmime::create (); + vmime::shared_ptr p = vmime::make_shared (); p->parse(data); VASSERT_EQ("1", true, vmime::attachmentHelper::isBodyPartAnAttachment(p)); @@ -199,7 +199,7 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest) "Content-Id: bar\r\n" "\r\nFoo\r\n"; - vmime::ref p = vmime::create (); + vmime::shared_ptr p = vmime::make_shared (); p->parse(data); VASSERT_EQ("1", false, vmime::attachmentHelper::isBodyPartAnAttachment(p)); @@ -215,10 +215,10 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest) "\r\n" "Foo bar baz"; - vmime::ref part = vmime::create (); + vmime::shared_ptr part = vmime::make_shared (); part->parse(data); - vmime::ref att = + vmime::shared_ptr att = vmime::attachmentHelper::getBodyPartAttachment(part); VASSERT_EQ("1", "image/jpeg", att->getType().generate()); @@ -233,7 +233,7 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest) VASSERT_EQ("5", "Foo bar baz", attData); //VASSERT_EQ("6", part, att->getPart()); - VASSERT_EQ("6", part->generate(), att->getPart().dynamicCast ()->generate()); + VASSERT_EQ("6", part->generate(), vmime::dynamicCast (att->getPart())->generate()); //VASSERT_EQ("7", part->getHeader(), att->getHeader()); VASSERT_EQ("7", part->getHeader()->generate(), att->getHeader()->generate()); } @@ -246,7 +246,7 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest) "\r\n" "Message body"; - vmime::ref msg = vmime::create (); + vmime::shared_ptr msg = vmime::make_shared (); msg->parse(data); const vmime::string attData = @@ -256,7 +256,7 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest) "\r\n" "QXR0YWNoZWQgbWVzc2FnZSBib2R5"; - vmime::ref amsg = vmime::create (); + vmime::shared_ptr amsg = vmime::make_shared (); amsg->parse(attData); vmime::attachmentHelper::addAttachment(msg, amsg); @@ -265,20 +265,20 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest) VASSERT_EQ("2", "Message body", extractBodyContents(msg->getBody()->getPartAt(0))); // Ensure message has been encoded properly - vmime::ref attPart = msg->getBody()->getPartAt(1); - vmime::ref attCth = attPart->getBody()->getContents(); + vmime::shared_ptr attPart = msg->getBody()->getPartAt(1); + vmime::shared_ptr attCth = attPart->getBody()->getContents(); vmime::string attDataOut; vmime::utility::outputStreamStringAdapter attDataOutOs(attDataOut); attCth->extract(attDataOutOs); - vmime::ref amsgOut = vmime::create (); + vmime::shared_ptr amsgOut = vmime::make_shared (); amsgOut->parse(attDataOut); - vmime::ref hdr = amsgOut->getHeader(); + vmime::shared_ptr hdr = amsgOut->getHeader(); - VASSERT_EQ("3", "Attached message", hdr->Subject()->getValue().dynamicCast ()->generate()); + VASSERT_EQ("3", "Attached message", hdr->Subject()->getValue ()->generate()); VASSERT_EQ("4", "Attached message body", extractBodyContents(amsgOut)); } @@ -300,25 +300,25 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest) "FooBar\r\n" "--foo--\r\n"; - vmime::ref msg = vmime::create (); + vmime::shared_ptr msg = vmime::make_shared (); msg->parse(data); VASSERT_EQ("0", 2, msg->getBody()->getPartCount()); - vmime::ref att = vmime::attachmentHelper:: + vmime::shared_ptr att = vmime::attachmentHelper:: getBodyPartAttachment(msg->getBody()->getPartAt(0)); VASSERT("1", att != NULL); - vmime::ref msgAtt = - att.dynamicCast (); + vmime::shared_ptr msgAtt = + vmime::dynamicCast (att); VASSERT("2", msgAtt != NULL); - vmime::ref amsg = msgAtt->getMessage(); - vmime::ref hdr = amsg->getHeader(); + vmime::shared_ptr amsg = msgAtt->getMessage(); + vmime::shared_ptr hdr = amsg->getHeader(); - VASSERT_EQ("3", "Attached message", hdr->Subject()->getValue().dynamicCast ()->generate()); + VASSERT_EQ("3", "Attached message", hdr->Subject()->getValue ()->generate()); VASSERT_EQ("4", "Attached message body", extractBodyContents(amsg)); } diff --git a/tests/parser/bodyPartTest.cpp b/tests/parser/bodyPartTest.cpp index 453982e0..f6f82f75 100644 --- a/tests/parser/bodyPartTest.cpp +++ b/tests/parser/bodyPartTest.cpp @@ -49,7 +49,7 @@ VMIME_TEST_SUITE_BEGIN(bodyPartTest) buffer.begin() + c.getParsedOffset() + c.getParsedLength()); } - static const vmime::string extractContents(const vmime::ref cts) + static const vmime::string extractContents(const vmime::shared_ptr cts) { std::ostringstream oss; vmime::utility::outputStreamAdapter os(oss); @@ -105,7 +105,7 @@ VMIME_TEST_SUITE_BEGIN(bodyPartTest) { vmime::bodyPart p1; p1.getHeader()->getField("Foo")->setValue(vmime::string("bar")); - p1.getBody()->setContents(vmime::create ("Baz")); + p1.getBody()->setContents(vmime::make_shared ("Baz")); VASSERT_EQ("1", "Foo: bar\r\n\r\nBaz", p1.generate()); } @@ -162,7 +162,7 @@ VMIME_TEST_SUITE_BEGIN(bodyPartTest) "--=_+ZWjySayKqSf2CyrfnNpaAcO6-G1HpoXdHZ4YyswAWqEY39Q--\r\n" "Epilog text"; - vmime::ref msg = vmime::create(); + vmime::shared_ptr msg = vmime::make_shared(); std::string istr(testmail); @@ -223,26 +223,26 @@ VMIME_TEST_SUITE_BEGIN(bodyPartTest) /** Ensure '7bit' encoding is used when body is 7-bit only. */ void testGenerate7bit() { - vmime::ref p1 = vmime::create (); - p1->setText(vmime::create ("Part1 is US-ASCII only.")); + vmime::shared_ptr p1 = vmime::make_shared (); + p1->setText(vmime::make_shared ("Part1 is US-ASCII only.")); - vmime::ref msg = vmime::create (); + vmime::shared_ptr msg = vmime::make_shared (); p1->generateIn(msg, msg); - vmime::ref header1 = msg->getBody()->getPartAt(0)->getHeader(); + vmime::shared_ptr header1 = msg->getBody()->getPartAt(0)->getHeader(); VASSERT_EQ("1", "7bit", header1->ContentTransferEncoding()->getValue()->generate()); } void testTextUsageForQPEncoding() { - vmime::ref part = vmime::create (); - part->setText(vmime::create ("Part1-line1\r\nPart1-line2\r\n\x89")); + vmime::shared_ptr part = vmime::make_shared (); + part->setText(vmime::make_shared ("Part1-line1\r\nPart1-line2\r\n\x89")); - vmime::ref msg = vmime::create (); + vmime::shared_ptr msg = vmime::make_shared (); part->generateIn(msg, msg); - vmime::ref body = msg->getBody()->getPartAt(0)->getBody(); - vmime::ref header = msg->getBody()->getPartAt(0)->getHeader(); + vmime::shared_ptr body = msg->getBody()->getPartAt(0)->getBody(); + vmime::shared_ptr header = msg->getBody()->getPartAt(0)->getHeader(); std::ostringstream oss; vmime::utility::outputStreamAdapter os(oss); @@ -339,30 +339,30 @@ VMIME_TEST_SUITE_BEGIN(bodyPartTest) oss << "\r\n" << "--MY-BOUNDARY--\r\n"; - vmime::ref is = - vmime::create (oss.str()); + vmime::shared_ptr is = + vmime::make_shared (oss.str()); - vmime::ref msg = vmime::create (); + vmime::shared_ptr msg = vmime::make_shared (); msg->parse(is, oss.str().length()); - vmime::ref body1 = msg->getBody()->getPartAt(0)->getBody(); - vmime::ref body1Cts = body1->getContents(); + vmime::shared_ptr body1 = msg->getBody()->getPartAt(0)->getBody(); + vmime::shared_ptr body1Cts = body1->getContents(); - vmime::ref body2 = msg->getBody()->getPartAt(1)->getBody(); - vmime::ref body2Cts = body2->getContents(); + vmime::shared_ptr body2 = msg->getBody()->getPartAt(1)->getBody(); + vmime::shared_ptr body2Cts = body2->getContents(); vmime::string body1CtsExtracted; vmime::utility::outputStreamStringAdapter body1CtsExtractStream(body1CtsExtracted); body1Cts->extract(body1CtsExtractStream); VASSERT_EQ("1.1", BODY1_LENGTH, body1Cts->getLength()); - VASSERT("1.2", body1Cts.dynamicCast () != NULL); + VASSERT("1.2", vmime::dynamicCast (body1Cts) != NULL); VASSERT_EQ("1.3", BODY1_LENGTH, body1CtsExtracted.length()); VASSERT_EQ("1.4", BODY1_BEGIN, body1CtsExtracted.substr(0, BODY1_BEGIN.length())); VASSERT_EQ("1.5", BODY1_END, body1CtsExtracted.substr(BODY1_LENGTH - BODY1_END.length(), BODY1_END.length())); VASSERT_EQ("2.1", BODY2_LINE.length() * BODY2_REPEAT, body2Cts->getLength()); - VASSERT("2.2", body2Cts.dynamicCast () != NULL); + VASSERT("2.2", vmime::dynamicCast (body2Cts) != NULL); } VMIME_TEST_SUITE_END diff --git a/tests/parser/bodyTest.cpp b/tests/parser/bodyTest.cpp index bb4d966b..92a4575e 100644 --- a/tests/parser/bodyTest.cpp +++ b/tests/parser/bodyTest.cpp @@ -40,7 +40,7 @@ VMIME_TEST_SUITE_BEGIN(bodyTest) // Quoted-Printable encoding vmime::bodyPart p; - p.getBody()->setContents(vmime::create + p.getBody()->setContents(vmime::make_shared ("Foo éé\r\né bar\r\nbaz"), vmime::mediaType("text", "plain"), vmime::charset("utf-8"), vmime::encoding("quoted-printable")); @@ -54,7 +54,7 @@ VMIME_TEST_SUITE_BEGIN(bodyTest) void testGenerate_NonText() { vmime::bodyPart p; - p.getBody()->setContents(vmime::create + p.getBody()->setContents(vmime::make_shared ("Binary\xfa\xfb\r\ndata\r\n\r\n\xfc"), vmime::mediaType("application", "octet-stream"), vmime::charset("utf-8"), vmime::encoding("quoted-printable")); diff --git a/tests/parser/charsetFilteredOutputStreamTest.cpp b/tests/parser/charsetFilteredOutputStreamTest.cpp index 32c4c5f3..4c91a71c 100644 --- a/tests/parser/charsetFilteredOutputStreamTest.cpp +++ b/tests/parser/charsetFilteredOutputStreamTest.cpp @@ -42,12 +42,12 @@ VMIME_TEST_SUITE_BEGIN(charsetFilteredOutputStreamTest) void testInputBufferUnderflow() { - vmime::ref cc = + vmime::shared_ptr cc = vmime::charsetConverter::create("utf-8", "iso-8859-1"); vmime::string output; vmime::utility::outputStreamStringAdapter os(output); - vmime::ref cfos = cc->getFilteredOutputStream(os); + vmime::shared_ptr cfos = cc->getFilteredOutputStream(os); VASSERT_NOT_NULL("filteredOutputStream availability", cfos); @@ -73,12 +73,12 @@ VMIME_TEST_SUITE_BEGIN(charsetFilteredOutputStreamTest) vmime::string actualOut; vmime::utility::outputStreamStringAdapter osa(actualOut); - vmime::ref conv = + vmime::shared_ptr conv = vmime::charsetConverter::create (vmime::charset("utf-8"), vmime::charset("iso-8859-1")); - vmime::ref os = + vmime::shared_ptr os = conv->getFilteredOutputStream(osa); VASSERT_NOT_NULL("filteredOutputStream availability", os); @@ -114,10 +114,10 @@ VMIME_TEST_SUITE_BEGIN(charsetFilteredOutputStreamTest) vmime::string actualOut; vmime::utility::outputStreamStringAdapter osa(actualOut); - vmime::ref conv = + vmime::shared_ptr conv = vmime::charsetConverter::create(entry.fromCharset, entry.toCharset); - vmime::ref os = + vmime::shared_ptr os = conv->getFilteredOutputStream(osa); VASSERT_NOT_NULL("filteredOutputStream availability", os); @@ -151,10 +151,10 @@ VMIME_TEST_SUITE_BEGIN(charsetFilteredOutputStreamTest) vmime::string actualOut; vmime::utility::outputStreamStringAdapter osa(actualOut); - vmime::ref conv = + vmime::shared_ptr conv = vmime::charsetConverter::create(entry.fromCharset, entry.toCharset); - vmime::ref os = + vmime::shared_ptr os = conv->getFilteredOutputStream(osa); VASSERT_NOT_NULL("filteredOutputStream availability", os); @@ -191,10 +191,10 @@ VMIME_TEST_SUITE_BEGIN(charsetFilteredOutputStreamTest) vmime::string actualOut; vmime::utility::outputStreamStringAdapter osa(actualOut); - vmime::ref conv = + vmime::shared_ptr conv = vmime::charsetConverter::create(entry.fromCharset, entry.toCharset); - vmime::ref os = + vmime::shared_ptr os = conv->getFilteredOutputStream(osa); VASSERT_NOT_NULL("filteredOutputStream availability", os); diff --git a/tests/parser/fileContentHandlerTest.cpp b/tests/parser/fileContentHandlerTest.cpp index b7373959..9d1459db 100644 --- a/tests/parser/fileContentHandlerTest.cpp +++ b/tests/parser/fileContentHandlerTest.cpp @@ -38,7 +38,7 @@ VMIME_TEST_SUITE_BEGIN(fileContentHandlerTest) VMIME_TEST_LIST_END - vmime::ref testFile; + vmime::shared_ptr testFile; vmime::string testDataEncoded, testDataDecoded; @@ -50,7 +50,7 @@ VMIME_TEST_SUITE_BEGIN(fileContentHandlerTest) std::ostringstream testFilePath; testFilePath << "/tmp/vmime_test_" << (rand() % 999999999); - vmime::ref fsf = + vmime::shared_ptr fsf = vmime::platform::getHandler()->getFileSystemFactory(); testFile = fsf->create(fsf->stringToPath(testFilePath.str())); @@ -61,7 +61,7 @@ VMIME_TEST_SUITE_BEGIN(fileContentHandlerTest) void tearDown() { testFile->remove(); - testFile = NULL; + testFile = vmime::null; } diff --git a/tests/parser/headerFieldTest.cpp b/tests/parser/headerFieldTest.cpp index b551c781..5281a3a2 100644 --- a/tests/parser/headerFieldTest.cpp +++ b/tests/parser/headerFieldTest.cpp @@ -35,16 +35,17 @@ VMIME_TEST_SUITE_BEGIN(headerFieldTest) void testBadValueType() { - vmime::headerFieldFactory *hfactory = vmime::headerFieldFactory::getInstance(); + vmime::shared_ptr hfactory = + vmime::headerFieldFactory::getInstance(); // "To" header field accepts values of type "addressList" - vmime::ref to = hfactory->create(vmime::fields::TO); + vmime::shared_ptr to = hfactory->create(vmime::fields::TO); VASSERT_THROW("to", to->setValue(vmime::mailbox("email@vmime.org")), vmime::exceptions::bad_field_value_type); // Unregistered header field accepts any value type - vmime::ref custom = hfactory->create("X-MyCustomHeader"); + vmime::shared_ptr custom = hfactory->create("X-MyCustomHeader"); VASSERT_NO_THROW("custom/1", custom->setValue(vmime::mailbox("email@vmime.org"))); VASSERT_NO_THROW("custom/2", @@ -57,11 +58,11 @@ VMIME_TEST_SUITE_BEGIN(headerFieldTest) const vmime::string buffer = "Field: \r\n\tfield data"; - vmime::ref hfield = + vmime::shared_ptr hfield = vmime::headerField::parseNext(ctx, buffer, 0, buffer.size()); - vmime::ref hvalue = - hfield->getValue().dynamicCast (); + vmime::shared_ptr hvalue = + hfield->getValue (); VASSERT_EQ("Field name", "Field", hfield->getName()); VASSERT_EQ("Field value", "field data", hvalue->getWholeBuffer()); @@ -73,11 +74,11 @@ VMIME_TEST_SUITE_BEGIN(headerFieldTest) const vmime::string buffer = "Field: \r\n\tfield data "; - vmime::ref hfield = + vmime::shared_ptr hfield = vmime::headerField::parseNext(ctx, buffer, 0, buffer.size()); - vmime::ref hvalue = - hfield->getValue().dynamicCast (); + vmime::shared_ptr hvalue = + hfield->getValue (); VASSERT_EQ("Field name", "Field", hfield->getName()); VASSERT_EQ("Field value", toHex("field data"), toHex(hvalue->getWholeBuffer())); diff --git a/tests/parser/headerTest.cpp b/tests/parser/headerTest.cpp index 91eb03df..959fc631 100644 --- a/tests/parser/headerTest.cpp +++ b/tests/parser/headerTest.cpp @@ -100,10 +100,10 @@ VMIME_TEST_SUITE_BEGIN(headerTest) vmime::header hdr; hdr.parse(""); - vmime::ref hf = vmime::headerFieldFactory::getInstance()->create("A", "a"); + vmime::shared_ptr hf = vmime::headerFieldFactory::getInstance()->create("A", "a"); hdr.appendField(hf); - std::vector > res = hdr.getFieldList(); + std::vector > res = hdr.getFieldList(); VASSERT_EQ("Count", static_cast (1), res.size()); VASSERT_EQ("First value", "A: a", headerTest::getFieldValue(*res[0])); @@ -114,10 +114,10 @@ VMIME_TEST_SUITE_BEGIN(headerTest) vmime::header hdr; hdr.parse("A: a\r\n"); - vmime::ref hf = vmime::headerFieldFactory::getInstance()->create("B", "b"); + vmime::shared_ptr hf = vmime::headerFieldFactory::getInstance()->create("B", "b"); hdr.appendField(hf); - std::vector > res = hdr.getFieldList(); + std::vector > res = hdr.getFieldList(); VASSERT_EQ("Count", static_cast (2), res.size()); VASSERT_EQ("First value", "A: a", headerTest::getFieldValue(*res[0])); @@ -130,10 +130,10 @@ VMIME_TEST_SUITE_BEGIN(headerTest) vmime::header hdr; hdr.parse("A: a\r\nC: c\r\n"); - vmime::ref hf = vmime::headerFieldFactory::getInstance()->create("B", "b"); + vmime::shared_ptr hf = vmime::headerFieldFactory::getInstance()->create("B", "b"); hdr.insertFieldBefore(hdr.getField("C"), hf); - std::vector > res = hdr.getFieldList(); + std::vector > res = hdr.getFieldList(); VASSERT_EQ("Count", static_cast (3), res.size()); VASSERT_EQ("First value", "A: a", headerTest::getFieldValue(*res[0])); @@ -146,10 +146,10 @@ VMIME_TEST_SUITE_BEGIN(headerTest) vmime::header hdr; hdr.parse("A: a\r\nC: c\r\n"); - vmime::ref hf = vmime::headerFieldFactory::getInstance()->create("B", "b"); + vmime::shared_ptr hf = vmime::headerFieldFactory::getInstance()->create("B", "b"); hdr.insertFieldBefore(1, hf); - std::vector > res = hdr.getFieldList(); + std::vector > res = hdr.getFieldList(); VASSERT_EQ("Count", static_cast (3), res.size()); VASSERT_EQ("First value", "A: a", headerTest::getFieldValue(*res[0])); @@ -163,10 +163,10 @@ VMIME_TEST_SUITE_BEGIN(headerTest) vmime::header hdr; hdr.parse("A: a\r\nC: c\r\n"); - vmime::ref hf = vmime::headerFieldFactory::getInstance()->create("B", "b"); + vmime::shared_ptr hf = vmime::headerFieldFactory::getInstance()->create("B", "b"); hdr.insertFieldAfter(hdr.getField("A"), hf); - std::vector > res = hdr.getFieldList(); + std::vector > res = hdr.getFieldList(); VASSERT_EQ("Count", static_cast (3), res.size()); VASSERT_EQ("First value", "A: a", headerTest::getFieldValue(*res[0])); @@ -179,10 +179,10 @@ VMIME_TEST_SUITE_BEGIN(headerTest) vmime::header hdr; hdr.parse("A: a\r\nC: c\r\n"); - vmime::ref hf = vmime::headerFieldFactory::getInstance()->create("B", "b"); + vmime::shared_ptr hf = vmime::headerFieldFactory::getInstance()->create("B", "b"); hdr.insertFieldAfter(0, hf); - std::vector > res = hdr.getFieldList(); + std::vector > res = hdr.getFieldList(); VASSERT_EQ("Count", static_cast (3), res.size()); VASSERT_EQ("First value", "A: a", headerTest::getFieldValue(*res[0])); @@ -196,10 +196,10 @@ VMIME_TEST_SUITE_BEGIN(headerTest) vmime::header hdr; hdr.parse("A: a\r\nB: b\r\nC: c\r\n"); - vmime::ref hf = vmime::headerFieldFactory::getInstance()->create("Z", "z"); + vmime::shared_ptr hf = vmime::headerFieldFactory::getInstance()->create("Z", "z"); hdr.replaceField(hdr.getField("B"), hf); - std::vector > res = hdr.getFieldList(); + std::vector > res = hdr.getFieldList(); VASSERT_EQ("Count", static_cast (3), res.size()); VASSERT_EQ("First value", "A: a", headerTest::getFieldValue(*res[0])); @@ -217,13 +217,13 @@ VMIME_TEST_SUITE_BEGIN(headerTest) hdr1.removeField(hdr1.getField("B")); hdr2.removeField(1); - std::vector > res1 = hdr1.getFieldList(); + std::vector > res1 = hdr1.getFieldList(); VASSERT_EQ("Count", static_cast (2), res1.size()); VASSERT_EQ("First value", "A: a", headerTest::getFieldValue(*res1[0])); VASSERT_EQ("Second value", "C: c", headerTest::getFieldValue(*res1[1])); - std::vector > res2 = hdr2.getFieldList(); + std::vector > res2 = hdr2.getFieldList(); VASSERT_EQ("Count", static_cast (2), res2.size()); VASSERT_EQ("First value", "A: a", headerTest::getFieldValue(*res2[0])); @@ -239,10 +239,10 @@ VMIME_TEST_SUITE_BEGIN(headerTest) hdr1.removeField(hdr1.getField("A")); hdr2.removeField(0); - std::vector > res1 = hdr1.getFieldList(); + std::vector > res1 = hdr1.getFieldList(); VASSERT_EQ("Count", static_cast (0), res1.size()); - std::vector > res2 = hdr2.getFieldList(); + std::vector > res2 = hdr2.getFieldList(); VASSERT_EQ("Count", static_cast (0), res2.size()); } @@ -256,10 +256,10 @@ VMIME_TEST_SUITE_BEGIN(headerTest) hdr1.removeAllFields(); hdr2.removeAllFields(); - std::vector > res1 = hdr1.getFieldList(); + std::vector > res1 = hdr1.getFieldList(); VASSERT_EQ("Count", static_cast (0), res1.size()); - std::vector > res2 = hdr2.getFieldList(); + std::vector > res2 = hdr2.getFieldList(); VASSERT_EQ("Count", static_cast (0), res2.size()); } @@ -295,7 +295,7 @@ VMIME_TEST_SUITE_BEGIN(headerTest) vmime::header hdr; hdr.parse("B: b\r\nA: a\r\nC: c\r\n"); - vmime::ref res = hdr.getFieldAt(2); + vmime::shared_ptr res = hdr.getFieldAt(2); VASSERT_EQ("Value", "C: c", getFieldValue(*res)); } @@ -306,7 +306,7 @@ VMIME_TEST_SUITE_BEGIN(headerTest) vmime::header hdr; hdr.parse("A: a\r\nB: b1\r\nC: c\r\nB: b2\r\n"); - std::vector > res = hdr.getFieldList(); + std::vector > res = hdr.getFieldList(); VASSERT_EQ("Count", static_cast (4), res.size()); VASSERT_EQ("First value", "A: a", headerTest::getFieldValue(*res[0])); @@ -320,7 +320,7 @@ VMIME_TEST_SUITE_BEGIN(headerTest) vmime::header hdr; hdr.parse("\r\n"); - std::vector > res = hdr.getFieldList(); + std::vector > res = hdr.getFieldList(); VASSERT_EQ("Count", static_cast (0), res.size()); } @@ -331,7 +331,7 @@ VMIME_TEST_SUITE_BEGIN(headerTest) vmime::header hdr; hdr.parse("A: a\r\nB: b\r\nC: c\r\nB: d\r\n"); - vmime::ref res = hdr.findField("B"); + vmime::shared_ptr res = hdr.findField("B"); VASSERT_EQ("Value", "B: b", getFieldValue(*res)); } @@ -342,7 +342,7 @@ VMIME_TEST_SUITE_BEGIN(headerTest) vmime::header hdr; hdr.parse("A: a1\nC: c1\n"); - std::vector > res = hdr.findAllFields("B"); + std::vector > res = hdr.findAllFields("B"); VASSERT_EQ("Count", static_cast (0), res.size()); } @@ -352,7 +352,7 @@ VMIME_TEST_SUITE_BEGIN(headerTest) vmime::header hdr; hdr.parse("A: a1\nB: b1\nB: b2\nC: c1\n"); - std::vector > res = hdr.findAllFields("B"); + std::vector > res = hdr.findAllFields("B"); VASSERT_EQ("Count", static_cast (2), res.size()); VASSERT_EQ("First value", "B: b1", headerTest::getFieldValue(*res[0])); @@ -364,7 +364,7 @@ VMIME_TEST_SUITE_BEGIN(headerTest) vmime::header hdr; hdr.parse("A: a1\nB: b1\nB: b2\nC: c1\nC: c3\nC: c2\n"); - std::vector > res = hdr.findAllFields("C"); + std::vector > res = hdr.findAllFields("C"); VASSERT_EQ("Count", static_cast (3), res.size()); VASSERT_EQ("First value", "C: c1", headerTest::getFieldValue(*res[0])); diff --git a/tests/parser/htmlTextPartTest.cpp b/tests/parser/htmlTextPartTest.cpp index 0eb7bbaf..278a87c1 100644 --- a/tests/parser/htmlTextPartTest.cpp +++ b/tests/parser/htmlTextPartTest.cpp @@ -35,7 +35,7 @@ VMIME_TEST_SUITE_BEGIN(htmlTextPartTest) static const vmime::string extractContent - (vmime::ref cth) + (vmime::shared_ptr cth) { std::ostringstream oss; vmime::utility::outputStreamAdapter osa(oss); @@ -74,7 +74,7 @@ VMIME_TEST_SUITE_BEGIN(htmlTextPartTest) "--LEVEL1--\r\n" ""; - vmime::ref msg = vmime::create (); + vmime::shared_ptr msg = vmime::make_shared (); msg->parse(msgString); // Sanity checks @@ -129,7 +129,7 @@ VMIME_TEST_SUITE_BEGIN(htmlTextPartTest) "--LEVEL1--\r\n" ""; - vmime::ref msg = vmime::create (); + vmime::shared_ptr msg = vmime::make_shared (); msg->parse(msgString); // Sanity checks @@ -153,7 +153,7 @@ VMIME_TEST_SUITE_BEGIN(htmlTextPartTest) VASSERT_EQ("has-obj2-pre", true, htmlPart.hasObject("cid:image2@test")); // Check data in objects - vmime::ref obj; + vmime::shared_ptr obj; obj = htmlPart.findObject("image1@test"); @@ -201,7 +201,7 @@ VMIME_TEST_SUITE_BEGIN(htmlTextPartTest) "--LEVEL1--\r\n" ""; - vmime::ref msg = vmime::create (); + vmime::shared_ptr msg = vmime::make_shared (); msg->parse(msgString); // Sanity checks @@ -221,7 +221,7 @@ VMIME_TEST_SUITE_BEGIN(htmlTextPartTest) VASSERT_EQ("has-obj-cid", false, htmlPart.hasObject("image1@test")); // Check data - vmime::ref obj; + vmime::shared_ptr obj; obj = htmlPart.findObject("http://www.vmime.org/test/image1.png"); diff --git a/tests/parser/mailboxGroupTest.cpp b/tests/parser/mailboxGroupTest.cpp index 49d22658..6c1319da 100644 --- a/tests/parser/mailboxGroupTest.cpp +++ b/tests/parser/mailboxGroupTest.cpp @@ -57,8 +57,8 @@ VMIME_TEST_SUITE_BEGIN(mailboxGroupTest) VASSERT_EQ("count", 1, addrs.getAddressCount()); VASSERT_TRUE("is group", addrs.getAddressAt(0)->isGroup()); - vmime::ref mgrp = - addrs.getAddressAt(0).dynamicCast (); + vmime::shared_ptr mgrp = + vmime::dynamicCast (addrs.getAddressAt(0)); VASSERT_EQ("name", "group", mgrp->getName().getWholeBuffer()); VASSERT_EQ("count", 2, mgrp->getMailboxCount()); diff --git a/tests/parser/mailboxTest.cpp b/tests/parser/mailboxTest.cpp index e6e4a608..6bf6670c 100644 --- a/tests/parser/mailboxTest.cpp +++ b/tests/parser/mailboxTest.cpp @@ -119,7 +119,8 @@ VMIME_TEST_SUITE_BEGIN(mailboxTest) VASSERT_EQ("count", 1, addrList.getAddressCount()); VASSERT_EQ("!group", false, addrList.getAddressAt(0)->isGroup()); - vmime::ref mbox = addrList.getAddressAt(0).dynamicCast (); + vmime::shared_ptr mbox = + vmime::dynamicCast (addrList.getAddressAt(0)); VASSERT_EQ("name", "Full Name", mbox->getName()); VASSERT_EQ("email", "", mbox->getEmail()); @@ -132,8 +133,10 @@ VMIME_TEST_SUITE_BEGIN(mailboxTest) VASSERT_EQ("count", 2, addrList.getAddressCount()); - vmime::ref mbox1 = addrList.getAddressAt(0).dynamicCast (); - vmime::ref mbox2 = addrList.getAddressAt(1).dynamicCast (); + vmime::shared_ptr mbox1 = + vmime::dynamicCast (addrList.getAddressAt(0)); + vmime::shared_ptr mbox2 = + vmime::dynamicCast (addrList.getAddressAt(1)); VASSERT_EQ("name1", vmime::text(), mbox1->getName()); VASSERT_EQ("email1", "aaa@vmime.org", mbox1->getEmail()); diff --git a/tests/parser/messageIdSequenceTest.cpp b/tests/parser/messageIdSequenceTest.cpp index ed6d0be3..bc5c7617 100644 --- a/tests/parser/messageIdSequenceTest.cpp +++ b/tests/parser/messageIdSequenceTest.cpp @@ -64,13 +64,13 @@ VMIME_TEST_SUITE_BEGIN(messageIdSequenceTest) void testGenerate() { vmime::messageIdSequence s1; - s1.appendMessageId(vmime::create ("a", "b")); + s1.appendMessageId(vmime::make_shared ("a", "b")); VASSERT_EQ("1", "", s1.generate()); vmime::messageIdSequence s2; - s2.appendMessageId(vmime::create ("a", "b")); - s2.appendMessageId(vmime::create ("c", "d")); + s2.appendMessageId(vmime::make_shared ("a", "b")); + s2.appendMessageId(vmime::make_shared ("c", "d")); VASSERT_EQ("2", " ", s2.generate()); } diff --git a/tests/parser/messageTest.cpp b/tests/parser/messageTest.cpp index 56605e39..a7a16813 100644 --- a/tests/parser/messageTest.cpp +++ b/tests/parser/messageTest.cpp @@ -35,12 +35,12 @@ VMIME_TEST_SUITE_BEGIN(messageTest) { vmime::generationContext ctx; - vmime::ref msg = vmime::create (); + vmime::shared_ptr msg = vmime::make_shared (); msg->getHeader()->getField("Foo")->setValue(vmime::string("bar")); vmime::htmlTextPart textPart; - textPart.setPlainText(vmime::create ("Foo bar bazé foo foo foo")); - textPart.setText(vmime::create ("Foo bar bazé foo foo foo")); + textPart.setPlainText(vmime::make_shared ("Foo bar bazé foo foo foo")); + textPart.setText(vmime::make_shared ("Foo bar bazé foo foo foo")); textPart.generateIn(msg, msg); // Estimated/computed generated size must be greater than the actual generated size diff --git a/tests/parser/parameterTest.cpp b/tests/parser/parameterTest.cpp index 3ebd6e35..3b0edebf 100644 --- a/tests/parser/parameterTest.cpp +++ b/tests/parser/parameterTest.cpp @@ -197,19 +197,19 @@ VMIME_TEST_SUITE_BEGIN(parameterTest) { // Simple parameter/value parameterizedHeaderField p1; - p1.appendParameter(vmime::create ("param1", "value1")); + p1.appendParameter(vmime::make_shared ("param1", "value1")); VASSERT_EQ("1", "F: X; param1=value1", p1.generate()); // Value that needs quoting (1/2) parameterizedHeaderField p2a; - p2a.appendParameter(vmime::create ("param1", "value1a;value1b")); + p2a.appendParameter(vmime::make_shared ("param1", "value1a;value1b")); VASSERT_EQ("2a", "F: X; param1=\"value1a;value1b\"", p2a.generate()); // Value that needs quoting (2/2) parameterizedHeaderField p2b; - p2b.appendParameter(vmime::create ("param1", "va\\lue\"1")); + p2b.appendParameter(vmime::make_shared ("param1", "va\\lue\"1")); VASSERT_EQ("2b", "F: X; param1=\"va\\\\lue\\\"1\"", p2b.generate()); } @@ -218,7 +218,7 @@ VMIME_TEST_SUITE_BEGIN(parameterTest) { // Extended parameter with charset specifier parameterizedHeaderField p1; - p1.appendParameter(vmime::create ("param1", + p1.appendParameter(vmime::make_shared ("param1", vmime::word("value 1\xe9", vmime::charset("charset")))); #if VMIME_ALWAYS_GENERATE_7BIT_PARAMETER @@ -229,7 +229,7 @@ VMIME_TEST_SUITE_BEGIN(parameterTest) // Value that spans on multiple lines parameterizedHeaderField p2; - p2.appendParameter(vmime::create ("param1", + p2.appendParameter(vmime::make_shared ("param1", vmime::word("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", vmime::charset("charset")))); @@ -256,7 +256,7 @@ VMIME_TEST_SUITE_BEGIN(parameterTest) // Non-ASCII parameter value parameterizedHeaderField p3; - p3.appendParameter(vmime::create ("param1", + p3.appendParameter(vmime::make_shared ("param1", vmime::word("δσσσσσσσσσσσσσσσσσσσσδσδα δσαδσδσαδσαδασδασ δσαδασδσα δσαδασδσα δασδασδασ δασαχφδδσα 2008.doc", vmime::charset("utf-8")))); @@ -325,28 +325,28 @@ VMIME_TEST_SUITE_BEGIN(parameterTest) // Encode "tspecials" void testEncodeTSpecials() { - VASSERT_EQ(" 1", "p=\"val(ue\"", vmime::create ("p", "val(ue")->generate()); - VASSERT_EQ(" 2", "p=\"val)ue\"", vmime::create ("p", "val)ue")->generate()); - VASSERT_EQ(" 3", "p=\"val("p", "valgenerate()); - VASSERT_EQ(" 4", "p=\"val>ue\"", vmime::create ("p", "val>ue")->generate()); - VASSERT_EQ(" 5", "p=\"val@ue\"", vmime::create ("p", "val@ue")->generate()); - VASSERT_EQ(" 6", "p=\"val,ue\"", vmime::create ("p", "val,ue")->generate()); - VASSERT_EQ(" 7", "p=\"val;ue\"", vmime::create ("p", "val;ue")->generate()); - VASSERT_EQ(" 8", "p=\"val:ue\"", vmime::create ("p", "val:ue")->generate()); - VASSERT_EQ(" 9", "p=\"val/ue\"", vmime::create ("p", "val/ue")->generate()); - VASSERT_EQ("10", "p=\"val[ue\"", vmime::create ("p", "val[ue")->generate()); - VASSERT_EQ("11", "p=\"val]ue\"", vmime::create ("p", "val]ue")->generate()); - VASSERT_EQ("12", "p=\"val?ue\"", vmime::create ("p", "val?ue")->generate()); - VASSERT_EQ("13", "p=\"val=ue\"", vmime::create ("p", "val=ue")->generate()); - VASSERT_EQ("14", "p=\"val ue\"", vmime::create ("p", "val ue")->generate()); - VASSERT_EQ("15", "p=\"val\tue\"", vmime::create ("p", "val\tue")->generate()); + VASSERT_EQ(" 1", "p=\"val(ue\"", vmime::make_shared ("p", "val(ue")->generate()); + VASSERT_EQ(" 2", "p=\"val)ue\"", vmime::make_shared ("p", "val)ue")->generate()); + VASSERT_EQ(" 3", "p=\"val("p", "valgenerate()); + VASSERT_EQ(" 4", "p=\"val>ue\"", vmime::make_shared ("p", "val>ue")->generate()); + VASSERT_EQ(" 5", "p=\"val@ue\"", vmime::make_shared ("p", "val@ue")->generate()); + VASSERT_EQ(" 6", "p=\"val,ue\"", vmime::make_shared ("p", "val,ue")->generate()); + VASSERT_EQ(" 7", "p=\"val;ue\"", vmime::make_shared ("p", "val;ue")->generate()); + VASSERT_EQ(" 8", "p=\"val:ue\"", vmime::make_shared ("p", "val:ue")->generate()); + VASSERT_EQ(" 9", "p=\"val/ue\"", vmime::make_shared ("p", "val/ue")->generate()); + VASSERT_EQ("10", "p=\"val[ue\"", vmime::make_shared ("p", "val[ue")->generate()); + VASSERT_EQ("11", "p=\"val]ue\"", vmime::make_shared ("p", "val]ue")->generate()); + VASSERT_EQ("12", "p=\"val?ue\"", vmime::make_shared ("p", "val?ue")->generate()); + VASSERT_EQ("13", "p=\"val=ue\"", vmime::make_shared ("p", "val=ue")->generate()); + VASSERT_EQ("14", "p=\"val ue\"", vmime::make_shared ("p", "val ue")->generate()); + VASSERT_EQ("15", "p=\"val\tue\"", vmime::make_shared ("p", "val\tue")->generate()); } // http://sourceforge.net/projects/vmime/forums/forum/237356/topic/3812278 void testEncodeTSpecialsInRFC2231() { VASSERT_EQ("1", "filename*=UTF-8''my_file_name_%C3%B6%C3%A4%C3%BC_%281%29.txt", - vmime::create ("filename", "my_file_name_\xc3\xb6\xc3\xa4\xc3\xbc_(1).txt")->generate()); + vmime::make_shared ("filename", "my_file_name_\xc3\xb6\xc3\xa4\xc3\xbc_(1).txt")->generate()); } void testWhitespaceBreaksTheValue() diff --git a/tests/parser/streamContentHandlerTest.cpp b/tests/parser/streamContentHandlerTest.cpp index 75b3d4d4..55680c93 100644 --- a/tests/parser/streamContentHandlerTest.cpp +++ b/tests/parser/streamContentHandlerTest.cpp @@ -51,8 +51,8 @@ VMIME_TEST_SUITE_BEGIN(streamContentHandlerTest) void testGetLength() { vmime::string data("Test Data"); - vmime::ref stream = - vmime::create (data); + vmime::shared_ptr stream = + vmime::make_shared (data); vmime::streamContentHandler cth(stream, data.length()); @@ -63,8 +63,8 @@ VMIME_TEST_SUITE_BEGIN(streamContentHandlerTest) void testIsEncoded() { vmime::string data("Test Data"); - vmime::ref stream = - vmime::create (data); + vmime::shared_ptr stream = + vmime::make_shared (data); vmime::streamContentHandler cth(stream, data.length()); @@ -73,8 +73,8 @@ VMIME_TEST_SUITE_BEGIN(streamContentHandlerTest) vmime::string data2("Zm9vEjRWYmFy="); - vmime::ref stream2 = - vmime::create (data2); + vmime::shared_ptr stream2 = + vmime::make_shared (data2); vmime::streamContentHandler cth2(stream2, data2.length(), vmime::encoding("base64")); @@ -85,8 +85,8 @@ VMIME_TEST_SUITE_BEGIN(streamContentHandlerTest) void testGetLength_Encoded() { vmime::string data("foo=12=34=56bar"); - vmime::ref stream = - vmime::create (data); + vmime::shared_ptr stream = + vmime::make_shared (data); vmime::streamContentHandler cth(stream, data.length(), vmime::encoding("quoted-printable")); @@ -97,8 +97,8 @@ VMIME_TEST_SUITE_BEGIN(streamContentHandlerTest) void testExtract() { vmime::string data("Test Data"); - vmime::ref stream = - vmime::create (data); + vmime::shared_ptr stream = + vmime::make_shared (data); vmime::streamContentHandler cth(stream, data.length()); @@ -114,8 +114,8 @@ VMIME_TEST_SUITE_BEGIN(streamContentHandlerTest) { vmime::string data ("QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODk="); - vmime::ref stream = - vmime::create (data); + vmime::shared_ptr stream = + vmime::make_shared (data); vmime::streamContentHandler cth(stream, data.length(), vmime::encoding("base64")); @@ -133,8 +133,8 @@ VMIME_TEST_SUITE_BEGIN(streamContentHandlerTest) { vmime::string data ("QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODk="); - vmime::ref stream = - vmime::create (data); + vmime::shared_ptr stream = + vmime::make_shared (data); vmime::streamContentHandler cth(stream, data.length(), vmime::encoding("base64")); @@ -151,8 +151,8 @@ VMIME_TEST_SUITE_BEGIN(streamContentHandlerTest) void testGenerate() { vmime::string data("foo\x12\x34\x56 bar"); - vmime::ref stream = - vmime::create (data); + vmime::shared_ptr stream = + vmime::make_shared (data); vmime::streamContentHandler cth(stream, data.length()); @@ -168,8 +168,8 @@ VMIME_TEST_SUITE_BEGIN(streamContentHandlerTest) void testGenerate_Encoded() { vmime::string data("foo=12=34=56bar"); - vmime::ref stream = - vmime::create (data); + vmime::shared_ptr stream = + vmime::make_shared (data); vmime::streamContentHandler cth(stream, data.length(), vmime::encoding("quoted-printable")); diff --git a/tests/parser/textTest.cpp b/tests/parser/textTest.cpp index f4f30b1b..274687a5 100644 --- a/tests/parser/textTest.cpp +++ b/tests/parser/textTest.cpp @@ -104,7 +104,7 @@ VMIME_TEST_SUITE_BEGIN(textTest) VASSERT_EQ("4.3", w1.getCharset(), t4.getWordAt(0)->getCharset()); vmime::word w2("Other", vmime::charset(vmime::charsets::US_ASCII)); - t4.appendWord(vmime::create (w2)); + t4.appendWord(vmime::make_shared (w2)); vmime::text t5(t4); @@ -296,8 +296,8 @@ VMIME_TEST_SUITE_BEGIN(textTest) // White-space between two encoded words vmime::text txt; - txt.appendWord(vmime::create ("\xc3\x89t\xc3\xa9", "utf-8")); - txt.appendWord(vmime::create ("Fran\xc3\xa7ois", "utf-8")); + txt.appendWord(vmime::make_shared ("\xc3\x89t\xc3\xa9", "utf-8")); + txt.appendWord(vmime::make_shared ("Fran\xc3\xa7ois", "utf-8")); const vmime::string decoded = "\xc3\x89t\xc3\xa9""Fran\xc3\xa7ois"; const vmime::string encoded = "=?utf-8?B?w4l0w6k=?= =?utf-8?Q?Fran=C3=A7ois?="; @@ -319,11 +319,11 @@ VMIME_TEST_SUITE_BEGIN(textTest) { // White-space between two encoded words (#2) vmime::text txt; - txt.appendWord(vmime::create ("Facture ", "utf-8")); - txt.appendWord(vmime::create ("\xc3\xa0", "utf-8")); - txt.appendWord(vmime::create (" envoyer ", "utf-8")); - txt.appendWord(vmime::create ("\xc3\xa0", "utf-8")); - txt.appendWord(vmime::create (" Martine", "utf-8")); + txt.appendWord(vmime::make_shared ("Facture ", "utf-8")); + txt.appendWord(vmime::make_shared ("\xc3\xa0", "utf-8")); + txt.appendWord(vmime::make_shared (" envoyer ", "utf-8")); + txt.appendWord(vmime::make_shared ("\xc3\xa0", "utf-8")); + txt.appendWord(vmime::make_shared (" Martine", "utf-8")); const vmime::string decoded = "Facture ""\xc3\xa0"" envoyer ""\xc3\xa0"" Martine"; const vmime::string encoded = "Facture =?utf-8?B?w6A=?= envoyer =?utf-8?B?w6A=?= Martine"; @@ -422,8 +422,8 @@ VMIME_TEST_SUITE_BEGIN(textTest) VASSERT_EQ("generate1", "=?us-ascii?Q?Achim_?= =?utf-8?Q?Br=C3=A4ndt?= ", mbox.generate()); vmime::text txt; - txt.appendWord(vmime::create ("Achim ", "us-ascii")); - txt.appendWord(vmime::create ("Br\xc3\xa4ndt", "utf-8")); + txt.appendWord(vmime::make_shared ("Achim ", "us-ascii")); + txt.appendWord(vmime::make_shared ("Br\xc3\xa4ndt", "utf-8")); mbox = vmime::mailbox(txt, "me@vmime.org"); VASSERT_EQ("generate2", "=?us-ascii?Q?Achim_?= =?utf-8?Q?Br=C3=A4ndt?= ", mbox.generate()); diff --git a/tests/security/digest/md5Test.cpp b/tests/security/digest/md5Test.cpp index ec4e62b2..c7f0b521 100644 --- a/tests/security/digest/md5Test.cpp +++ b/tests/security/digest/md5Test.cpp @@ -27,7 +27,7 @@ #define INIT_DIGEST(var, algo) \ - vmime::ref var = \ + vmime::shared_ptr var = \ vmime::security::digest::messageDigestFactory::getInstance()->create(algo) diff --git a/tests/security/digest/sha1Test.cpp b/tests/security/digest/sha1Test.cpp index 2accf8c7..c6ce1e65 100644 --- a/tests/security/digest/sha1Test.cpp +++ b/tests/security/digest/sha1Test.cpp @@ -27,7 +27,7 @@ #define INIT_DIGEST(var, algo) \ - vmime::ref var = \ + vmime::shared_ptr var = \ vmime::security::digest::messageDigestFactory::getInstance()->create(algo) diff --git a/tests/testUtils.cpp b/tests/testUtils.cpp index 93cb9e38..c22649e6 100644 --- a/tests/testUtils.cpp +++ b/tests/testUtils.cpp @@ -243,9 +243,9 @@ bool testTimeoutHandler::handleTimeOut() // testTimeoutHandlerFactory : public vmime::net::timeoutHandlerFactory -vmime::ref testTimeoutHandlerFactory::create() +vmime::shared_ptr testTimeoutHandlerFactory::create() { - return vmime::create (); + return vmime::make_shared (); } diff --git a/tests/testUtils.hpp b/tests/testUtils.hpp index 01910cbc..fdcca575 100644 --- a/tests/testUtils.hpp +++ b/tests/testUtils.hpp @@ -315,14 +315,14 @@ class testSocketFactory : public vmime::net::socketFactory { public: - vmime::ref create() + vmime::shared_ptr create() { - return vmime::create (); + return vmime::make_shared (); } - vmime::ref create(vmime::ref /* th */) + vmime::shared_ptr create(vmime::shared_ptr /* th */) { - return vmime::create (); + return vmime::make_shared (); } }; @@ -366,7 +366,7 @@ class testTimeoutHandlerFactory : public vmime::net::timeoutHandlerFactory { public: - vmime::ref create(); + vmime::shared_ptr create(); }; diff --git a/tests/utility/encoder/encoderTestUtils.hpp b/tests/utility/encoder/encoderTestUtils.hpp index 0eb93871..d74c4709 100644 --- a/tests/utility/encoder/encoderTestUtils.hpp +++ b/tests/utility/encoder/encoderTestUtils.hpp @@ -23,10 +23,10 @@ // Helper function to obtain an encoder given its name -static vmime::ref getEncoder(const vmime::string& name, +static vmime::shared_ptr getEncoder(const vmime::string& name, int maxLineLength = 0, const vmime::propertySet props = vmime::propertySet()) { - vmime::ref enc = + vmime::shared_ptr enc = vmime::utility::encoder::encoderFactory::getInstance()->create(name); enc->getProperties() = props; @@ -42,7 +42,7 @@ static vmime::ref getEncoder(const vmime::str static const vmime::string encode(const vmime::string& name, const vmime::string& in, int maxLineLength = 0, const vmime::propertySet props = vmime::propertySet()) { - vmime::ref enc = getEncoder(name, maxLineLength, props); + vmime::shared_ptr enc = getEncoder(name, maxLineLength, props); vmime::utility::inputStreamStringAdapter vin(in); @@ -58,7 +58,7 @@ static const vmime::string encode(const vmime::string& name, const vmime::string // Decoding helper function static const vmime::string decode(const vmime::string& name, const vmime::string& in, int maxLineLength = 0) { - vmime::ref enc = getEncoder(name, maxLineLength); + vmime::shared_ptr enc = getEncoder(name, maxLineLength); vmime::utility::inputStreamStringAdapter vin(in); diff --git a/tests/utility/outputStreamSocketAdapterTest.cpp b/tests/utility/outputStreamSocketAdapterTest.cpp index 920c7f47..417eff8b 100644 --- a/tests/utility/outputStreamSocketAdapterTest.cpp +++ b/tests/utility/outputStreamSocketAdapterTest.cpp @@ -37,7 +37,7 @@ VMIME_TEST_SUITE_BEGIN(outputStreamSocketAdapterTest) void testWrite() { - vmime::ref socket = vmime::create (); + vmime::shared_ptr socket = vmime::make_shared (); vmime::utility::outputStreamSocketAdapter stream(*socket); stream << "some data"; @@ -55,7 +55,7 @@ VMIME_TEST_SUITE_BEGIN(outputStreamSocketAdapterTest) "\xc5\x9a\xc3\xb8\xc9\xb1\xc9\x9b\x20\xc9\x93\xc9\xa8\xc9\xb2\xc9" "\x91\xc5\x95\xc9\xa3\x20\xc9\x96\xc9\x90\xca\x88\xc9\x92"; - vmime::ref socket = vmime::create (); + vmime::shared_ptr socket = vmime::make_shared (); vmime::utility::outputStreamSocketAdapter stream(*socket); stream.write(binaryData, sizeof(binaryData)); @@ -69,7 +69,7 @@ VMIME_TEST_SUITE_BEGIN(outputStreamSocketAdapterTest) void testWriteCRLF() { - vmime::ref socket = vmime::create (); + vmime::shared_ptr socket = vmime::make_shared (); vmime::utility::outputStreamSocketAdapter stream(*socket); stream << "some data"; diff --git a/tests/utility/seekableInputStreamRegionAdapterTest.cpp b/tests/utility/seekableInputStreamRegionAdapterTest.cpp index 3ed024e8..1c33c056 100644 --- a/tests/utility/seekableInputStreamRegionAdapterTest.cpp +++ b/tests/utility/seekableInputStreamRegionAdapterTest.cpp @@ -42,16 +42,16 @@ VMIME_TEST_SUITE_BEGIN(seekableInputStreamRegionAdapterTest) VMIME_TEST_LIST_END - vmime::ref createStream - (vmime::ref * underlyingStream = NULL) + vmime::shared_ptr createStream + (vmime::shared_ptr * underlyingStream = NULL) { vmime::string buffer("THIS IS A TEST BUFFER"); - vmime::ref strStream = - vmime::create (buffer); + vmime::shared_ptr strStream = + vmime::make_shared (buffer); - vmime::ref rgnStream = - vmime::create (strStream, 10, 11); + vmime::shared_ptr rgnStream = + vmime::make_shared (strStream, 10, 11); if (underlyingStream) *underlyingStream = strStream; @@ -61,7 +61,7 @@ VMIME_TEST_SUITE_BEGIN(seekableInputStreamRegionAdapterTest) void testInitialPosition() { - vmime::ref stream = createStream(); + vmime::shared_ptr stream = createStream(); VASSERT_EQ("Pos", 0, stream->getPosition()); VASSERT_FALSE("EOF", stream->eof()); @@ -69,7 +69,7 @@ VMIME_TEST_SUITE_BEGIN(seekableInputStreamRegionAdapterTest) void testSeekAndGetPosition() { - vmime::ref stream = createStream(); + vmime::shared_ptr stream = createStream(); stream->seek(5); @@ -84,11 +84,12 @@ VMIME_TEST_SUITE_BEGIN(seekableInputStreamRegionAdapterTest) void testRead() { - vmime::ref stream = createStream(); + vmime::shared_ptr stream = createStream(); stream->seek(5); stream::value_type buffer[100]; + std::fill(vmime::begin(buffer), vmime::end(buffer), 0); stream::size_type read = stream->read(buffer, 6); VASSERT_EQ("Pos", 11, stream->getPosition()); @@ -99,7 +100,7 @@ VMIME_TEST_SUITE_BEGIN(seekableInputStreamRegionAdapterTest) void testSkip() { - vmime::ref stream = createStream(); + vmime::shared_ptr stream = createStream(); stream->skip(5); @@ -107,6 +108,7 @@ VMIME_TEST_SUITE_BEGIN(seekableInputStreamRegionAdapterTest) VASSERT_FALSE("EOF 1", stream->eof()); stream::value_type buffer[100]; + std::fill(vmime::begin(buffer), vmime::end(buffer), 0); stream::size_type read = stream->read(buffer, 3); VASSERT_EQ("Pos 2", 8, stream->getPosition()); @@ -122,7 +124,7 @@ VMIME_TEST_SUITE_BEGIN(seekableInputStreamRegionAdapterTest) void testReset() { - vmime::ref stream = createStream(); + vmime::shared_ptr stream = createStream(); stream->skip(100); stream->reset(); @@ -136,15 +138,17 @@ VMIME_TEST_SUITE_BEGIN(seekableInputStreamRegionAdapterTest) // seekableInputStreamRegionAdapter should keep track of its own position // in the underlying stream, and not be affected by possible seek/read // operations on it... - vmime::ref ustream; - vmime::ref stream = createStream(&ustream); + vmime::shared_ptr ustream; + vmime::shared_ptr stream = createStream(&ustream); stream->seek(5); stream::value_type buffer1[100]; + std::fill(vmime::begin(buffer1), vmime::end(buffer1), 0); stream::size_type read = ustream->read(buffer1, 7); stream::value_type buffer2[100]; + std::fill(vmime::begin(buffer2), vmime::end(buffer2), 0); stream::size_type read2 = stream->read(buffer2, 6); VASSERT_EQ("Buffer 1", "THIS IS", vmime::string(buffer1, 0, 7)); diff --git a/tests/utility/smartPtrTest.cpp b/tests/utility/smartPtrTest.cpp deleted file mode 100644 index 584adf3b..00000000 --- a/tests/utility/smartPtrTest.cpp +++ /dev/null @@ -1,241 +0,0 @@ -// -// VMime library (http://www.vmime.org) -// Copyright (C) 2002-2013 Vincent Richard -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License as -// published by the Free Software Foundation; either version 3 of -// the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -// -// Linking this library statically or dynamically with other modules is making -// a combined work based on this library. Thus, the terms and conditions of -// the GNU General Public License cover the whole combination. -// - -#include "tests/testUtils.hpp" - -#include "vmime/utility/smartPtr.hpp" - - -VMIME_TEST_SUITE_BEGIN(smartPtrTest) - - VMIME_TEST_LIST_BEGIN - VMIME_TEST(testNull) - VMIME_TEST(testRefCounting) - VMIME_TEST(testWeakRef) - VMIME_TEST(testCast) - VMIME_TEST(testContainer) - VMIME_TEST(testCompare) - VMIME_TEST_LIST_END - - - struct A : public vmime::object - { - int strongCount() const { return getRefManager()->getStrongRefCount(); } - int weakCount() const { return getRefManager()->getWeakRefCount(); } - }; - - struct B : public virtual A { }; - struct C : public virtual A { }; - struct D : public B, public C { }; - - class R : public A - { - public: - - R(bool* aliveFlag) : m_aliveFlag(aliveFlag) { *m_aliveFlag = true; } - ~R() { *m_aliveFlag = false; } - - private: - - bool* m_aliveFlag; - }; - - - void testNull() - { - vmime::ref r1; - - VASSERT("1", r1 == NULL); - VASSERT("2", r1 == 0); - VASSERT("3", NULL == r1); - VASSERT("4", 0 == r1); - VASSERT("5", !r1); - VASSERT("6", r1 == vmime::null); - VASSERT("7", vmime::null == r1); - VASSERT_EQ("8", static_cast (0), r1.get()); - } - - void testRefCounting() - { - bool o1_alive; - vmime::ref r1 = vmime::create (&o1_alive); - - VASSERT("1", r1.get() != 0); - VASSERT("2", o1_alive); - VASSERT_EQ("3", 1, r1->strongCount()); - VASSERT_EQ("4", 1, r1->weakCount()); - - vmime::ref r2 = r1; - - VASSERT("5", o1_alive); - VASSERT_EQ("6", 2, r1->strongCount()); - VASSERT_EQ("7", 2, r1->weakCount()); - - bool o2_alive; - vmime::ref r3 = vmime::create (&o2_alive); - - r2 = r3; - - VASSERT("8", o1_alive); - VASSERT("9", o2_alive); - VASSERT_EQ("10", 1, r1->strongCount()); - VASSERT_EQ("11", 2, r2->strongCount()); - VASSERT_EQ("12", 2, r3->strongCount()); - - { - vmime::ref r4; - - r4 = r1; - - VASSERT("13", o1_alive); - VASSERT("14", o2_alive); - VASSERT_EQ("15", 2, r4->strongCount()); - VASSERT_EQ("16", 2, r1->strongCount()); - - r1 = NULL; - - VASSERT("17", o1_alive); - VASSERT("18", o2_alive); - VASSERT_EQ("19", 1, r4->strongCount()); - - // Here, object1 will be deleted - } - - VASSERT("20", !o1_alive); - VASSERT("21", o2_alive); - - { - vmime::weak_ref w1 = r3; - - VASSERT_EQ("22", 3, r3->weakCount()); - } - - VASSERT("23", o2_alive); - VASSERT_EQ("24", 2, r3->strongCount()); - VASSERT_EQ("25", 2, r3->weakCount()); - } - - void testWeakRef() - { - vmime::ref r1 = vmime::create (); - vmime::weak_ref w1 = r1; - - VASSERT("1", r1.get() != 0); - VASSERT("2", r1.get() == w1.acquire().get()); - - { - vmime::ref r2 = r1; - - VASSERT("3", r1.get() == r2.get()); - VASSERT("4", r1.get() == w1.acquire().get()); - } - - VASSERT("5", r1.get() != 0); - VASSERT("6", r1.get() == w1.acquire().get()); - - r1 = 0; - - VASSERT("7", w1.acquire().get() == 0); - } - - void testCast() - { - // Explicit upcast - vmime::ref r1 = vmime::create (); - vmime::ref r2 = r1.dynamicCast (); - - VASSERT("1", r2.get() == dynamic_cast (r1.get())); - VASSERT("2", 0 == r1.dynamicCast ().get()); - - // Implicit downcast - vmime::ref r3 = vmime::create (); - vmime::ref r4 = r3; - - VASSERT("3", r4.get() == dynamic_cast (r3.get())); - } - - void testContainer() - { - bool o1_alive; - vmime::ref r1 = vmime::create (&o1_alive); - - bool o2_alive; - vmime::ref r2 = vmime::create (&o2_alive); - - std::vector > v1; - v1.push_back(r1); - v1.push_back(r2); - - VASSERT("1", o1_alive); - VASSERT_EQ("2", 2, r1->strongCount()); - VASSERT("3", o2_alive); - VASSERT_EQ("4", 2, r2->strongCount()); - - { - std::vector > v2 = v1; - - VASSERT("5", o1_alive); - VASSERT_EQ("6", 3, r1->strongCount()); - VASSERT("7", o2_alive); - VASSERT_EQ("8", 3, r2->strongCount()); - - v2[1] = NULL; - - VASSERT("9", o1_alive); - VASSERT_EQ("10", 3, r1->strongCount()); - VASSERT("11", o2_alive); - VASSERT_EQ("12", 2, r2->strongCount()); - } - - VASSERT("13", o1_alive); - VASSERT_EQ("14", 2, r1->strongCount()); - VASSERT("15", o2_alive); - VASSERT_EQ("16", 2, r2->strongCount()); - } - - void testCompare() - { - vmime::ref r1 = vmime::create (); - vmime::ref r2 = vmime::create (); - vmime::ref r3 = vmime::create (); - vmime::ref r4 = r1; - - VASSERT("1", r1 != r2); - VASSERT("2", r1.get() == r1); - VASSERT("3", r1 == r1.get()); - VASSERT("4", r2 != r1.get()); - VASSERT("5", r1.get() != r2); - VASSERT("6", r1 == r4); - VASSERT("7", r1.get() == r4); - - std::vector > v; - v.push_back(r1); - v.push_back(r2); - - VASSERT("8", std::find(v.begin(), v.end(), r1) == v.begin()); - VASSERT("9", std::find(v.begin(), v.end(), r2) == v.begin() + 1); - VASSERT("10", std::find(v.begin(), v.end(), r3) == v.end()); - } - -VMIME_TEST_SUITE_END - diff --git a/vmime/address.hpp b/vmime/address.hpp index 3c0c0b2a..110e1e6b 100644 --- a/vmime/address.hpp +++ b/vmime/address.hpp @@ -61,7 +61,7 @@ public: */ virtual bool isGroup() const = 0; - virtual ref clone() const = 0; + virtual shared_ptr clone() const = 0; /** Parse an address from an input buffer. * @@ -74,7 +74,7 @@ public: * of a group (end delimiter was found), or false otherwise (may be set to NULL) * @return a new address object, or null if no more address is available in the input buffer */ - static ref
parseNext + static shared_ptr
parseNext (const parsingContext& ctx, const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition, bool *isLastAddressOfGroup); diff --git a/vmime/addressList.hpp b/vmime/addressList.hpp index 9fd5ab08..2958000b 100644 --- a/vmime/addressList.hpp +++ b/vmime/addressList.hpp @@ -51,19 +51,19 @@ public: ~addressList(); - ref clone() const; + shared_ptr clone() const; void copyFrom(const component& other); addressList& operator=(const addressList& other); addressList& operator=(const mailboxList& other); - const std::vector > getChildComponents(); + const std::vector > getChildComponents(); /** Add a address at the end of the list. * * @param addr address to append */ - void appendAddress(ref
addr); + void appendAddress(shared_ptr
addr); /** Insert a new address before the specified address. * @@ -71,7 +71,7 @@ public: * @param addr address to insert * @throw exceptions::no_such_address if the address is not in the list */ - void insertAddressBefore(ref
beforeAddress, ref
addr); + void insertAddressBefore(shared_ptr
beforeAddress, shared_ptr
addr); /** Insert a new address before the specified position. * @@ -79,7 +79,7 @@ public: * the beginning of the list) * @param addr address to insert */ - void insertAddressBefore(const size_t pos, ref
addr); + void insertAddressBefore(const size_t pos, shared_ptr
addr); /** Insert a new address after the specified address. * @@ -87,21 +87,21 @@ public: * @param addr address to insert * @throw exceptions::no_such_address if the address is not in the list */ - void insertAddressAfter(ref
afterAddress, ref
addr); + void insertAddressAfter(shared_ptr
afterAddress, shared_ptr
addr); /** Insert a new address after the specified position. * * @param pos position of the address before the new address * @param addr address to insert */ - void insertAddressAfter(const size_t pos, ref
addr); + void insertAddressAfter(const size_t pos, shared_ptr
addr); /** Remove the specified address from the list. * * @param addr address to remove * @throw exceptions::no_such_address if the address is not in the list */ - void removeAddress(ref
addr); + void removeAddress(shared_ptr
addr); /** Remove the address at the specified position. * @@ -130,26 +130,26 @@ public: * @param pos position * @return address at position 'pos' */ - ref
getAddressAt(const size_t pos); + shared_ptr
getAddressAt(const size_t pos); /** Return the address at the specified position. * * @param pos position * @return address at position 'pos' */ - const ref getAddressAt(const size_t pos) const; + const shared_ptr getAddressAt(const size_t pos) const; /** Return the address list. * * @return list of addresses */ - const std::vector > getAddressList() const; + const std::vector > getAddressList() const; /** Return the address list. * * @return list of addresses */ - const std::vector > getAddressList(); + const std::vector > getAddressList(); /** Return a list of mailboxes. * If some addresses are actually groups, mailboxes are recursively @@ -157,11 +157,11 @@ public: * * @return list of mailboxes */ - ref toMailboxList() const; + shared_ptr toMailboxList() const; private: - std::vector > m_list; + std::vector > m_list; protected: diff --git a/vmime/attachment.hpp b/vmime/attachment.hpp index e131fcd0..9730bc6c 100644 --- a/vmime/attachment.hpp +++ b/vmime/attachment.hpp @@ -79,7 +79,7 @@ public: * * @return attachment data */ - virtual const ref getData() const = 0; + virtual const shared_ptr getData() const = 0; /** Return the encoding used for this attachment. * @@ -93,14 +93,14 @@ public: * @return attachment part or NULL if the attachment is not * attached to a part */ - virtual ref getPart() const = 0; + virtual shared_ptr getPart() const = 0; /** Return the header of the attachment part. * * @return attachment part header or NULL if the attachment * is not attached to a part */ - virtual ref getHeader() const = 0; + virtual shared_ptr getHeader() const = 0; protected: @@ -108,7 +108,7 @@ protected: * * @param parent body part in which to generate the attachment */ - virtual void generateIn(ref parent) const = 0; + virtual void generateIn(shared_ptr parent) const = 0; }; diff --git a/vmime/attachmentHelper.hpp b/vmime/attachmentHelper.hpp index 0dd052cb..e03a4f7d 100644 --- a/vmime/attachmentHelper.hpp +++ b/vmime/attachmentHelper.hpp @@ -59,7 +59,7 @@ public: * @param options search options (see FindOptions) * @return true if the part is an attachment, false otherwise */ - static bool isBodyPartAnAttachment(ref part, const unsigned int options = 0); + static bool isBodyPartAnAttachment(shared_ptr part, const unsigned int options = 0); /** Return attachment information in the specified body part. * If the specified body part does not contain attachment @@ -69,8 +69,8 @@ public: * @param options search options (see FindOptions) * @return attachment found in the part, or NULL */ - static ref - getBodyPartAttachment(ref part, const unsigned int options = 0); + static shared_ptr + getBodyPartAttachment(shared_ptr part, const unsigned int options = 0); /** Find all attachments contained in the specified part * and all its children parts. @@ -80,8 +80,8 @@ public: * @param options search options (see FindOptions) * @return a list of attachments found */ - static const std::vector > - findAttachmentsInBodyPart(ref part, const unsigned int options = 0); + static const std::vector > + findAttachmentsInBodyPart(shared_ptr part, const unsigned int options = 0); /** Find all attachments contained in the specified message. * This is simply a recursive call to getBodyPartAttachment(). @@ -90,27 +90,27 @@ public: * @param options search options (see FindOptions) * @return a list of attachments found */ - static const std::vector > - findAttachmentsInMessage(ref msg, const unsigned int options = 0); + static const std::vector > + findAttachmentsInMessage(shared_ptr msg, const unsigned int options = 0); /** Add an attachment to the specified message. * * @param msg message into which to add the attachment * @param att attachment to add */ - static void addAttachment(ref msg, ref att); + static void addAttachment(shared_ptr msg, shared_ptr att); /** Add a message attachment to the specified message. * * @param msg message into which to add the attachment * @param amsg message to attach */ - static void addAttachment(ref msg, ref amsg); + static void addAttachment(shared_ptr msg, shared_ptr amsg); protected: - static ref findBodyPart - (ref part, const mediaType& type); + static shared_ptr findBodyPart + (shared_ptr part, const mediaType& type); }; diff --git a/vmime/base.hpp b/vmime/base.hpp index 2437514b..36938cb7 100644 --- a/vmime/base.hpp +++ b/vmime/base.hpp @@ -35,7 +35,6 @@ #include "vmime/config.hpp" #include "vmime/types.hpp" #include "vmime/constants.hpp" -#include "vmime/utility/smartPtr.hpp" namespace vmime @@ -51,6 +50,19 @@ namespace vmime extern VMIME_EXPORT const text NULL_TEXT; extern VMIME_EXPORT const word NULL_WORD; +#ifndef VMIME_BUILDING_DOC + + // Null pointer + struct nullPtrType + { + template + operator shared_ptr () { return shared_ptr (); } + }; + + extern nullPtrType VMIME_EXPORT null; + +#endif // VMIME_BUILDING_DOC + // // Library name and version @@ -66,13 +78,25 @@ namespace vmime // template - inline T const* begin(T const (&array)[N]) + inline T const* cbegin(T const (&array)[N]) { return (array); } template - inline T const* end(T const (&array)[N]) + inline T const* cend(T const (&array)[N]) + { + return (array + N); + } + + template + inline T* begin(T (&array)[N]) + { + return (array); + } + + template + inline T* end(T (&array)[N]) { return (array + N); } @@ -158,100 +182,49 @@ namespace vmime namespace utility { } -#ifndef VMIME_BUILDING_DOC - /** Work-around for friend template functions. - * - * Make this class a friend if you want to be able to use - * vmime::create() with private/protected constructors. - */ - class VMIME_EXPORT creator - { - public: - - template - static ref create() { return ref ::fromPtr(new T); } - - template - static ref create(const P0& p0) { return ref ::fromPtr(new T(p0)); } - - template - static ref create(const P0& p0, const P1& p1) { return ref ::fromPtr(new T(p0, p1)); } - - template - static ref create(const P0& p0, const P1& p1, const P2& p2) { return ref ::fromPtr(new T(p0, p1, p2)); } - - template - static ref create(const P0& p0, const P1& p1, const P2& p2, const P3& p3) { return ref ::fromPtr(new T(p0, p1, p2, p3)); } - - template - static ref create(const P0& p0, const P1& p1, const P2& p2, const P3& p3, const P4& p4) { return ref ::fromPtr(new T(p0, p1, p2, p3, p4)); } - }; -#endif // VMIME_BUILDING_DOC - - /** Create a new object and return a reference to it. - * @return reference to the new object + /** Clone helper (using a shared_ptr). + * This is an alias for dynamic_pointer_cast (obj->clone()). */ template - static ref create() { return creator::create (); } - - /** Create a new object and return a reference to it. - * @return reference to the new object - */ - template - static ref create(const P0& p0) { return creator::create (p0); } - - /** Create a new object and return a reference to it. - * @return reference to the new object - */ - template - static ref create(const P0& p0, const P1& p1) { return creator::create (p0, p1); } - - /** Create a new object and return a reference to it. - * @return reference to the new object - */ - template - static ref create(const P0& p0, const P1& p1, const P2& p2) { return creator::create (p0, p1, p2); } - - /** Create a new object and return a reference to it. - * @return reference to the new object - */ - template - static ref create(const P0& p0, const P1& p1, const P2& p2, const P3& p3) { return creator::create (p0, p1, p2, p3); } - - /** Create a new object and return a reference to it. - * @return reference to the new object - */ - template - static ref create(const P0& p0, const P1& p1, const P2& p2, const P3& p3, const P4& p4) { return creator::create (p0, p1, p2, p3, p4); } - - - /** Clone helper. - * Use "vmime::clone(obj)" instead of "obj->clone().cast ()". - */ - template - ref clone(ref x) + shared_ptr clone(shared_ptr obj) { - return x->clone().template dynamicCast (); + return dynamic_pointer_cast (obj->clone()); } - /** Clone helper. - * Use "vmime::clone(obj)" instead of "obj.clone().cast ()". + /** Clone helper (using a const shared_ptr). + * This is an alias for dynamic_pointer_cast (obj->clone()). */ template - ref clone(const T& x) + shared_ptr clone(shared_ptr obj) { - return x.clone().template dynamicCast (); + return dynamic_pointer_cast (obj->clone()); } + /** Clone helper (using a const reference). + * This is an alias for dynamic_pointer_cast (obj.clone()). + */ + template + shared_ptr clone(const T& obj) + { + return dynamic_pointer_cast (obj.clone()); + } /** Downcast helper. * Usage: vmime::dynamicCast (obj), where 'obj' is of * type Type, and DerivedType is derived from Type. */ template - ref dynamicCast(ref y) + shared_ptr dynamicCast(shared_ptr obj) { - return y.template dynamicCast (); + return dynamic_pointer_cast (obj); + } + + /** Const cast helper. + */ + template + shared_ptr constCast(const shared_ptr & obj) + { + return const_pointer_cast (obj); } /** Inherit from this class to indicate the subclass is not copyable, diff --git a/vmime/body.hpp b/vmime/body.hpp index 3f2ea483..465a7a81 100644 --- a/vmime/body.hpp +++ b/vmime/body.hpp @@ -60,7 +60,7 @@ public: * * @param part part to append */ - void appendPart(ref part); + void appendPart(shared_ptr part); /** Insert a new part before the specified part. * @@ -68,7 +68,7 @@ public: * @param part part to insert * @throw exceptions::no_such_part if the part is not in the list */ - void insertPartBefore(ref beforePart, ref part); + void insertPartBefore(shared_ptr beforePart, shared_ptr part); /** Insert a new part before the specified position. * @@ -76,7 +76,7 @@ public: * the beginning of the list) * @param part part to insert */ - void insertPartBefore(const size_t pos, ref part); + void insertPartBefore(const size_t pos, shared_ptr part); /** Insert a new part after the specified part. * @@ -84,21 +84,21 @@ public: * @param part part to insert * @throw exceptions::no_such_part if the part is not in the list */ - void insertPartAfter(ref afterPart, ref part); + void insertPartAfter(shared_ptr afterPart, shared_ptr part); /** Insert a new part after the specified position. * * @param pos position of the part before the new part * @param part part to insert */ - void insertPartAfter(const size_t pos, ref part); + void insertPartAfter(const size_t pos, shared_ptr part); /** Remove the specified part from the list. * * @param part part to remove * @throw exceptions::no_such_part if the part is not in the list */ - void removePart(ref part); + void removePart(shared_ptr part); /** Remove the part at the specified position. * @@ -127,26 +127,26 @@ public: * @param pos position * @return part at position 'pos' */ - ref getPartAt(const size_t pos); + shared_ptr getPartAt(const size_t pos); /** Return the part at the specified position. * * @param pos position * @return part at position 'pos' */ - const ref getPartAt(const size_t pos) const; + const shared_ptr getPartAt(const size_t pos) const; /** Return the part list. * * @return list of parts */ - const std::vector > getPartList() const; + const std::vector > getPartList() const; /** Return the part list. * * @return list of parts */ - const std::vector > getPartList(); + const std::vector > getPartList(); /** Return the prolog text. * @@ -176,20 +176,20 @@ public: * * @return read-only body contents */ - const ref getContents() const; + const shared_ptr getContents() const; /** Set the body contents. * * @param contents new body contents */ - void setContents(ref contents); + void setContents(shared_ptr contents); /** Set the body contents and type. * * @param contents new body contents * @param type type of contents */ - void setContents(ref contents, const mediaType& type); + void setContents(shared_ptr contents, const mediaType& type); /** Set the body contents, type and charset. * @@ -197,7 +197,7 @@ public: * @param type type of contents * @param chset charset of contents */ - void setContents(ref contents, const mediaType& type, const charset& chset); + void setContents(shared_ptr contents, const mediaType& type, const charset& chset); /** Set the body contents, type, charset and encoding. * @@ -206,7 +206,7 @@ public: * @param chset charset of contents * @param enc contents encoding */ - void setContents(ref contents, const mediaType& type, + void setContents(shared_ptr contents, const mediaType& type, const charset& chset, const encoding& enc); /** Set the MIME type and charset of contents. @@ -274,11 +274,11 @@ public: */ static bool isValidBoundary(const string& boundary); - ref clone() const; + shared_ptr clone() const; void copyFrom(const component& other); body& operator=(const body& other); - const std::vector > getChildComponents(); + const std::vector > getChildComponents(); utility::stream::size_type getGeneratedSize(const generationContext& ctx); @@ -287,22 +287,21 @@ private: text getActualPrologText(const generationContext& ctx) const; text getActualEpilogText(const generationContext& ctx) const; - void setParentPart(ref parent); + void setParentPart(bodyPart* parent); string m_prologText; string m_epilogText; - ref m_contents; + shared_ptr m_contents; - weak_ref m_part; - weak_ref
m_header; + bodyPart* m_part; - std::vector > m_parts; + std::vector > m_parts; bool isRootPart() const; - void initNewPart(ref part); + void initNewPart(shared_ptr part); protected: @@ -319,14 +318,14 @@ protected: * @return the position of the boundary string, or stream::npos if not found */ utility::stream::size_type findNextBoundaryPosition - (ref parser, const string& boundary, + (shared_ptr parser, const string& boundary, const utility::stream::size_type position, const utility::stream::size_type end, utility::stream::size_type* boundaryStart, utility::stream::size_type* boundaryEnd); // Component parsing & assembling void parseImpl (const parsingContext& ctx, - ref parser, + shared_ptr parser, const utility::stream::size_type position, const utility::stream::size_type end, utility::stream::size_type* newPosition = NULL); diff --git a/vmime/bodyPart.hpp b/vmime/bodyPart.hpp index 62365b8b..fd0deb73 100644 --- a/vmime/bodyPart.hpp +++ b/vmime/bodyPart.hpp @@ -46,78 +46,97 @@ class VMIME_EXPORT bodyPart : public component public: bodyPart(); - bodyPart(weak_ref parentPart); /** Return the header section of this part. * * @return header section */ - const ref getHeader() const; + const shared_ptr getHeader() const; /** Return the header section of this part. * * @return header section */ - ref
getHeader(); + shared_ptr
getHeader(); /** Replaces the header section of this part. * * @param header the new header of this part */ - void setHeader(ref
header); + void setHeader(shared_ptr
header); /** Return the body section of this part. * * @return body section */ - const ref getBody() const; + const shared_ptr getBody() const; /** Return the body section of this part. * * @return body section */ - ref getBody(); + shared_ptr getBody(); /** Replaces the body section of this part. * * @param body new body section */ - void setBody(ref body); + void setBody(shared_ptr body); /** Return the parent part of this part. * * @return parent part or NULL if not known */ - ref getParentPart(); + bodyPart* getParentPart(); /** Return the parent part of this part (const version). * * @return parent part or NULL if not known */ - ref getParentPart() const; + const bodyPart* getParentPart() const; - ref clone() const; + shared_ptr clone() const; void copyFrom(const component& other); bodyPart& operator=(const bodyPart& other); - const std::vector > getChildComponents(); + const std::vector > getChildComponents(); utility::stream::size_type getGeneratedSize(const generationContext& ctx); private: - ref
m_header; - ref m_body; + shared_ptr
m_header; + mutable shared_ptr m_body; - weak_ref m_parent; + // We can't use a weak_ptr<> here as the parent part may + // have been allocated on the stack + bodyPart* m_parent; protected: + /** Creates and returns a new part and set this part as its + * parent. The newly created sub-part should then be added + * to this part by calling getBody()->appendPart(). Called + * by the body class. + * + * @return child part + */ + shared_ptr createChildPart(); + + /** Detach the specified part from its current parent part (if + * any) and attach it to this part by setting this part as its + * new parent. The sub-part should then be added to this part + * by calling getBody()->appendPart(). Called by body class. + * + * @param part child part to attach + */ + void importChildPart(shared_ptr part); + // Component parsing & assembling void parseImpl (const parsingContext& ctx, - ref parser, + shared_ptr parser, const utility::stream::size_type position, const utility::stream::size_type end, utility::stream::size_type* newPosition = NULL); diff --git a/vmime/bodyPartAttachment.hpp b/vmime/bodyPartAttachment.hpp index b885d020..e1a4a89a 100644 --- a/vmime/bodyPartAttachment.hpp +++ b/vmime/bodyPartAttachment.hpp @@ -42,33 +42,29 @@ namespace vmime */ class VMIME_EXPORT bodyPartAttachment : public attachment { - friend class creator; - -protected: - - bodyPartAttachment(ref part); - public: + bodyPartAttachment(shared_ptr part); + const mediaType getType() const; const word getName() const; const text getDescription() const; const encoding getEncoding() const; - const ref getData() const; + const shared_ptr getData() const; - ref getPart() const; - ref getHeader() const; + shared_ptr getPart() const; + shared_ptr getHeader() const; private: - void generateIn(ref parent) const; + void generateIn(shared_ptr parent) const; - ref getContentDisposition() const; - ref getContentType() const; + shared_ptr getContentDisposition() const; + shared_ptr getContentType() const; - ref m_part; + shared_ptr m_part; }; diff --git a/vmime/charset.hpp b/vmime/charset.hpp index c77a2e01..9c1325c6 100644 --- a/vmime/charset.hpp +++ b/vmime/charset.hpp @@ -63,7 +63,7 @@ public: bool operator==(const charset& value) const; bool operator!=(const charset& value) const; - const std::vector > getChildComponents(); + const std::vector > getChildComponents(); /** Gets the recommended encoding for this charset. * Note: there may be no recommended encoding. @@ -117,7 +117,7 @@ public: const charset& source, const charset& dest, const charsetConverterOptions& opts = charsetConverterOptions()); - ref clone() const; + shared_ptr clone() const; void copyFrom(const component& other); private: diff --git a/vmime/charsetConverter.hpp b/vmime/charsetConverter.hpp index 9a4f8b37..07f38d8f 100644 --- a/vmime/charsetConverter.hpp +++ b/vmime/charsetConverter.hpp @@ -69,7 +69,7 @@ public: * @param dest output charset * @param opts conversion options */ - static ref create + static shared_ptr create (const charset& source, const charset& dest, const charsetConverterOptions& opts = charsetConverterOptions()); @@ -103,11 +103,11 @@ public: * @param os stream into which filtered data will be written * @return a filtered output stream, or NULL if not supported */ - virtual ref getFilteredOutputStream(utility::outputStream& os) = 0; + virtual shared_ptr getFilteredOutputStream(utility::outputStream& os) = 0; private: - static ref createGenericConverter + static shared_ptr createGenericConverter (const charset& source, const charset& dest, const charsetConverterOptions& opts); }; diff --git a/vmime/charsetConverter_iconv.hpp b/vmime/charsetConverter_iconv.hpp index a590b320..0309d848 100644 --- a/vmime/charsetConverter_iconv.hpp +++ b/vmime/charsetConverter_iconv.hpp @@ -59,7 +59,7 @@ public: void convert(const string& in, string& out); void convert(utility::inputStream& in, utility::outputStream& out); - ref getFilteredOutputStream(utility::outputStream& os); + shared_ptr getFilteredOutputStream(utility::outputStream& os); private: diff --git a/vmime/charsetConverter_icu.hpp b/vmime/charsetConverter_icu.hpp index c693775e..91cf0b86 100644 --- a/vmime/charsetConverter_icu.hpp +++ b/vmime/charsetConverter_icu.hpp @@ -62,7 +62,7 @@ public: void convert(const string& in, string& out); void convert(utility::inputStream& in, utility::outputStream& out); - ref getFilteredOutputStream(utility::outputStream& os); + shared_ptr getFilteredOutputStream(utility::outputStream& os); private: diff --git a/vmime/charsetConverter_idna.hpp b/vmime/charsetConverter_idna.hpp index d3b8b25f..874d6bf1 100644 --- a/vmime/charsetConverter_idna.hpp +++ b/vmime/charsetConverter_idna.hpp @@ -53,7 +53,7 @@ public: void convert(const string& in, string& out); void convert(utility::inputStream& in, utility::outputStream& out); - ref getFilteredOutputStream(utility::outputStream& os); + shared_ptr getFilteredOutputStream(utility::outputStream& os); private: diff --git a/vmime/component.hpp b/vmime/component.hpp index f96572b7..0c3716cb 100644 --- a/vmime/component.hpp +++ b/vmime/component.hpp @@ -70,7 +70,7 @@ public: * @param inputStream stream from which to read data * @param length data length, in bytes (0 = unknown/not specified) */ - void parse(ref inputStream, const utility::stream::size_type length); + void parse(shared_ptr inputStream, const utility::stream::size_type length); /** Parse RFC-822/MIME data for this component, using the default * parsing context. @@ -112,7 +112,7 @@ public: * @param newPosition will receive the new position in the input stream */ void parse - (ref inputStream, + (shared_ptr inputStream, const utility::stream::size_type position, const utility::stream::size_type end, utility::stream::size_type* newPosition = NULL); @@ -129,7 +129,7 @@ public: */ void parse (const parsingContext& ctx, - ref inputStream, + shared_ptr inputStream, const utility::stream::size_type position, const utility::stream::size_type end, utility::stream::size_type* newPosition = NULL); @@ -174,7 +174,7 @@ public: * * @return a copy of this component */ - virtual ref clone() const = 0; + virtual shared_ptr clone() const = 0; /** Replace data in this component by data in other component. * Both components must be of the same type. @@ -205,7 +205,7 @@ public: * * @return list of child components */ - virtual const std::vector > getChildComponents() = 0; + virtual const std::vector > getChildComponents() = 0; /** Get the number of bytes that will be used by this component when * it is generated. This may be a heuristically-derived estimate, @@ -224,7 +224,7 @@ protected: // AT LEAST ONE of these parseImpl() functions MUST be implemented in derived class virtual void parseImpl (const parsingContext& ctx, - ref parser, + shared_ptr parser, const utility::stream::size_type position, const utility::stream::size_type end, utility::stream::size_type* newPosition = NULL); diff --git a/vmime/contentDisposition.hpp b/vmime/contentDisposition.hpp index 9407885d..0f417111 100644 --- a/vmime/contentDisposition.hpp +++ b/vmime/contentDisposition.hpp @@ -59,11 +59,11 @@ public: */ void setName(const string& name); - ref clone() const; + shared_ptr clone() const; void copyFrom(const component& other); contentDisposition& operator=(const contentDisposition& other); - const std::vector > getChildComponents(); + const std::vector > getChildComponents(); contentDisposition& operator=(const string& name); diff --git a/vmime/contentDispositionField.hpp b/vmime/contentDispositionField.hpp index 58b40dff..0eb32bc4 100644 --- a/vmime/contentDispositionField.hpp +++ b/vmime/contentDispositionField.hpp @@ -38,7 +38,7 @@ namespace vmime class VMIME_EXPORT contentDispositionField : public parameterizedHeaderField { - friend class vmime::creator; // create ref + friend class headerFieldFactory; protected: diff --git a/vmime/contentHandler.hpp b/vmime/contentHandler.hpp index ae20e892..5ae9e02b 100644 --- a/vmime/contentHandler.hpp +++ b/vmime/contentHandler.hpp @@ -29,7 +29,6 @@ #include "vmime/base.hpp" #include "vmime/utility/stringProxy.hpp" -#include "vmime/utility/smartPtr.hpp" #include "vmime/utility/progressListener.hpp" #include "vmime/encoding.hpp" #include "vmime/mediaType.hpp" @@ -53,7 +52,7 @@ public: * * @return copy of this object */ - virtual ref clone() const = 0; + virtual shared_ptr clone() const = 0; /** Output the contents into the specified stream. Data will be * encoded before being written into the stream. This is used internally diff --git a/vmime/contentTypeField.hpp b/vmime/contentTypeField.hpp index b522927a..b81d9a68 100644 --- a/vmime/contentTypeField.hpp +++ b/vmime/contentTypeField.hpp @@ -37,7 +37,7 @@ namespace vmime class VMIME_EXPORT contentTypeField : public parameterizedHeaderField { - friend class vmime::creator; // create ref + friend class headerFieldFactory; protected: diff --git a/vmime/dateTime.hpp b/vmime/dateTime.hpp index 1d25124a..8a596f02 100644 --- a/vmime/dateTime.hpp +++ b/vmime/dateTime.hpp @@ -224,7 +224,7 @@ public: void copyFrom(const component& other); - ref clone() const; + shared_ptr clone() const; // Comparison bool operator==(const datetime& other) const; @@ -237,7 +237,7 @@ public: // Current date and time static const datetime now(); - const std::vector > getChildComponents(); + const std::vector > getChildComponents(); protected: diff --git a/vmime/defaultAttachment.hpp b/vmime/defaultAttachment.hpp index 171b7a84..6eb0c5b6 100644 --- a/vmime/defaultAttachment.hpp +++ b/vmime/defaultAttachment.hpp @@ -45,8 +45,8 @@ protected: public: - defaultAttachment(ref data, const encoding& enc, const mediaType& type, const text& desc = NULL_TEXT, const word& name = NULL_WORD); - defaultAttachment(ref data, const mediaType& type, const text& desc = NULL_TEXT, const word& name = NULL_WORD); + defaultAttachment(shared_ptr data, const encoding& enc, const mediaType& type, const text& desc = NULL_TEXT, const word& name = NULL_WORD); + defaultAttachment(shared_ptr data, const mediaType& type, const text& desc = NULL_TEXT, const word& name = NULL_WORD); defaultAttachment(const defaultAttachment& attach); ~defaultAttachment(); @@ -56,29 +56,29 @@ public: const mediaType getType() const; const text getDescription() const; const word getName() const; - const ref getData() const; + const shared_ptr getData() const; const encoding getEncoding() const; - ref getPart() const; + shared_ptr getPart() const; - ref getHeader() const; + shared_ptr getHeader() const; protected: mediaType m_type; /**< Media type (eg. "application/octet-stream") */ text m_desc; /**< Description (eg. "The image you requested") */ - ref m_data; /**< Attachment data (eg. the file contents) */ + shared_ptr m_data; /**< Attachment data (eg. the file contents) */ encoding m_encoding; /**< Encoding */ word m_name; /**< Name/filename (eg. "sunset.jpg") */ private: // No need to override "generateIn", use "generatePart" instead (see below). - void generateIn(ref parent) const; + void generateIn(shared_ptr parent) const; protected: - virtual void generatePart(ref part) const; + virtual void generatePart(shared_ptr part) const; }; diff --git a/vmime/disposition.hpp b/vmime/disposition.hpp index b75327a1..01de1653 100644 --- a/vmime/disposition.hpp +++ b/vmime/disposition.hpp @@ -46,11 +46,11 @@ public: disposition(const string& actionMode, const string& sendingMode, const string& type, const string& modifier); - ref clone() const; + shared_ptr clone() const; void copyFrom(const component& other); disposition& operator=(const disposition& other); - const std::vector > getChildComponents(); + const std::vector > getChildComponents(); /** Set the disposition action mode. diff --git a/vmime/emailAddress.hpp b/vmime/emailAddress.hpp index a16366c7..e46afdf6 100644 --- a/vmime/emailAddress.hpp +++ b/vmime/emailAddress.hpp @@ -98,10 +98,10 @@ public: // Assignment void copyFrom(const component& other); - ref clone() const; + shared_ptr clone() const; emailAddress& operator=(const emailAddress& other); - const std::vector > getChildComponents(); + const std::vector > getChildComponents(); protected: diff --git a/vmime/emptyContentHandler.hpp b/vmime/emptyContentHandler.hpp index 829e8898..1307f7eb 100644 --- a/vmime/emptyContentHandler.hpp +++ b/vmime/emptyContentHandler.hpp @@ -38,7 +38,7 @@ public: emptyContentHandler(); - ref clone() const; + shared_ptr clone() const; void generate(utility::outputStream& os, const vmime::encoding& enc, const string::size_type maxLineLength = lineLengthLimits::infinite) const; diff --git a/vmime/encoding.hpp b/vmime/encoding.hpp index cdee1d43..ba07a25f 100644 --- a/vmime/encoding.hpp +++ b/vmime/encoding.hpp @@ -93,7 +93,7 @@ public: bool operator==(const encoding& value) const; bool operator!=(const encoding& value) const; - const std::vector > getChildComponents(); + const std::vector > getChildComponents(); /** Decide which encoding to use based on the specified data. * @@ -101,7 +101,7 @@ public: * @param usage context of use of data * @return suitable encoding for specified data */ - static const encoding decide(ref data, const EncodingUsage usage = USAGE_BINARY_DATA); + static const encoding decide(shared_ptr data, const EncodingUsage usage = USAGE_BINARY_DATA); /** Decide which encoding to use based on the specified data and charset. * @@ -110,10 +110,10 @@ public: * @param usage context of use of data * @return suitable encoding for specified data and charset */ - static const encoding decide(ref data, const charset& chset, const EncodingUsage usage = USAGE_BINARY_DATA); + static const encoding decide(shared_ptr data, const charset& chset, const EncodingUsage usage = USAGE_BINARY_DATA); - ref clone() const; + shared_ptr clone() const; void copyFrom(const component& other); /** Use encoderFactory to obtain an encoder/decoder object @@ -123,7 +123,7 @@ public: * is registered for the encoding * @return a new encoder object for the encoding type */ - ref getEncoder() const; + shared_ptr getEncoder() const; private: diff --git a/vmime/fileAttachment.hpp b/vmime/fileAttachment.hpp index d18b8a14..2d9ff575 100644 --- a/vmime/fileAttachment.hpp +++ b/vmime/fileAttachment.hpp @@ -52,9 +52,9 @@ public: fileAttachment(const string& filepath, const mediaType& type, const text& desc); fileAttachment(const string& filepath, const mediaType& type, const text& desc, const encoding& enc); - fileAttachment(ref cts, const word& filename, const mediaType& type); - fileAttachment(ref cts, const word& filename, const mediaType& type, const text& desc); - fileAttachment(ref cts, const word& filename, const mediaType& type, const text& desc, const encoding& enc); + fileAttachment(shared_ptr cts, const word& filename, const mediaType& type); + fileAttachment(shared_ptr cts, const word& filename, const mediaType& type, const text& desc); + fileAttachment(shared_ptr cts, const word& filename, const mediaType& type, const text& desc, const encoding& enc); /** Stores information about a file attachment. */ @@ -181,11 +181,11 @@ public: private: void setData(const string& filepath); - void setData(ref cts); + void setData(shared_ptr cts); fileInfo m_fileInfo; - void generatePart(ref part) const; + void generatePart(shared_ptr part) const; }; diff --git a/vmime/fileContentHandler.hpp b/vmime/fileContentHandler.hpp index 36a6a459..68b4d396 100644 --- a/vmime/fileContentHandler.hpp +++ b/vmime/fileContentHandler.hpp @@ -56,7 +56,7 @@ public: * @return a reference to a new content handler */ fileContentHandler - (ref file, + (shared_ptr file, const vmime::encoding& enc = NO_ENCODING); ~fileContentHandler(); @@ -64,7 +64,7 @@ public: fileContentHandler(const fileContentHandler& cts); fileContentHandler& operator=(const fileContentHandler& cts); - ref clone() const; + shared_ptr clone() const; /** Sets the data managed by this content handler. * @@ -73,7 +73,7 @@ public: * in the file is already encoded with the specified encoding */ void setData - (ref file, + (shared_ptr file, const vmime::encoding& enc = NO_ENCODING); private: @@ -83,7 +83,7 @@ private: vmime::encoding m_encoding; // Actual data - ref m_file; + shared_ptr m_file; }; diff --git a/vmime/generatedMessageAttachment.hpp b/vmime/generatedMessageAttachment.hpp index 4c9c0aba..7137b22b 100644 --- a/vmime/generatedMessageAttachment.hpp +++ b/vmime/generatedMessageAttachment.hpp @@ -42,30 +42,30 @@ class VMIME_EXPORT generatedMessageAttachment : public messageAttachment { public: - generatedMessageAttachment(ref part); + generatedMessageAttachment(shared_ptr part); const mediaType getType() const; const text getDescription() const; const word getName() const; - const ref getData() const; + const shared_ptr getData() const; const encoding getEncoding() const; - ref getPart() const; + shared_ptr getPart() const; - ref getHeader() const; + shared_ptr getHeader() const; - ref getMessage() const; + shared_ptr getMessage() const; protected: - void generateIn(ref parent) const; + void generateIn(shared_ptr parent) const; private: - ref m_bpa; - mutable ref m_msg; + shared_ptr m_bpa; + mutable shared_ptr m_msg; }; diff --git a/vmime/header.hpp b/vmime/header.hpp index 0758e775..b073e8cb 100644 --- a/vmime/header.hpp +++ b/vmime/header.hpp @@ -55,8 +55,8 @@ public: ~header(); #define FIELD_ACCESS(methodName, fieldName) \ - ref methodName() { return getField(fields::fieldName); } \ - ref methodName() const { return findField(fields::fieldName); } + shared_ptr methodName() { return getField(fields::fieldName); } \ + shared_ptr methodName() const { return findField(fields::fieldName); } FIELD_ACCESS(From, FROM) FIELD_ACCESS(Sender, SENDER) @@ -102,14 +102,26 @@ public: * @throw exceptions::no_such_field if no field with this name exists * @return first field with the specified name */ - ref findField(const string& fieldName) const; + shared_ptr findField(const string& fieldName) const; + + /** Find the first field that matches the specified name, + * casted to the specified type. + * If no field is found, an exception is thrown. + * + * @return value object + */ + template + shared_ptr findField(const string& fieldName) const + { + return dynamicCast (findField(fieldName)); + } /** Find all fields that match the specified name. * If no field is found, an empty vector is returned. * * @return list of fields with the specified name */ - std::vector > findAllFields(const string& fieldName); + std::vector > findAllFields(const string& fieldName); /** Find the first field that matches the specified name. * If no field is found, one will be created and inserted into @@ -118,13 +130,27 @@ public: * @return first field with the specified name or a new field * if no field is found */ - ref getField(const string& fieldName); + shared_ptr getField(const string& fieldName); + + /** Find the first field that matches the specified name, + * casted to the specified type. + * If no field is found, one will be created and inserted into + * the header. + * + * @return first field with the specified name or a new field + * if no field is found + */ + template + shared_ptr getField(const string& fieldName) + { + return dynamicCast (getField(fieldName)); + } /** Add a field at the end of the list. * * @param field field to append */ - void appendField(ref field); + void appendField(shared_ptr field); /** Insert a new field before the specified field. * @@ -132,7 +158,7 @@ public: * @param field field to insert * @throw exceptions::no_such_field if the field is not in the list */ - void insertFieldBefore(ref beforeField, ref field); + void insertFieldBefore(shared_ptr beforeField, shared_ptr field); /** Insert a new field before the specified position. * @@ -140,7 +166,7 @@ public: * the beginning of the list) * @param field field to insert */ - void insertFieldBefore(const size_t pos, ref field); + void insertFieldBefore(const size_t pos, shared_ptr field); /** Insert a new field after the specified field. * @@ -148,21 +174,21 @@ public: * @param field field to insert * @throw exceptions::no_such_field if the field is not in the list */ - void insertFieldAfter(ref afterField, ref field); + void insertFieldAfter(shared_ptr afterField, shared_ptr field); /** Insert a new field after the specified position. * * @param pos position of the field before the new field * @param field field to insert */ - void insertFieldAfter(const size_t pos, ref field); + void insertFieldAfter(const size_t pos, shared_ptr field); /** Remove the specified field from the list. * * @param field field to remove * @throw exceptions::no_such_field if the field is not in the list */ - void removeField(ref field); + void removeField(shared_ptr field); /** Remove the field at the specified position. * @@ -176,7 +202,7 @@ public: * @param newField field to replace with * @throw exceptions::no_such_field if the field is not in the list */ - void replaceField(ref field, ref newField); + void replaceField(shared_ptr field, shared_ptr newField); /** Remove all fields from the list. */ @@ -203,38 +229,38 @@ public: * @param pos position * @return field at position 'pos' */ - const ref getFieldAt(const size_t pos); + const shared_ptr getFieldAt(const size_t pos); /** Return the field at the specified position. * * @param pos position * @return field at position 'pos' */ - const ref getFieldAt(const size_t pos) const; + const shared_ptr getFieldAt(const size_t pos) const; /** Return the field list. * * @return list of fields */ - const std::vector > getFieldList() const; + const std::vector > getFieldList() const; /** Return the field list. * * @return list of fields */ - const std::vector > getFieldList(); + const std::vector > getFieldList(); - ref clone() const; + shared_ptr clone() const; void copyFrom(const component& other); header& operator=(const header& other); - const std::vector > getChildComponents(); + const std::vector > getChildComponents(); utility::stream::size_type getGeneratedSize(const generationContext& ctx); private: - std::vector > m_fields; + std::vector > m_fields; class fieldHasName @@ -242,7 +268,7 @@ private: public: fieldHasName(const string& name); - bool operator() (const ref & field); + bool operator() (const shared_ptr & field); private: @@ -254,7 +280,7 @@ private: public: fieldHasNotName(const string& name); - bool operator() (const ref & field); + bool operator() (const shared_ptr & field); private: diff --git a/vmime/headerField.hpp b/vmime/headerField.hpp index 5276c84a..c9972317 100644 --- a/vmime/headerField.hpp +++ b/vmime/headerField.hpp @@ -42,8 +42,6 @@ class VMIME_EXPORT headerField : public component friend class headerFieldFactory; friend class header; - friend class vmime::creator; // create ref - protected: // Protected constructor to prevent the user from creating @@ -55,11 +53,11 @@ public: ~headerField(); - ref clone() const; + shared_ptr clone() const; void copyFrom(const component& other); headerField& operator=(const headerField& other); - const std::vector > getChildComponents(); + const std::vector > getChildComponents(); /** Sets the name of this field. * @@ -84,13 +82,35 @@ public: * * @return read-only value object */ - virtual ref getValue() const; + virtual shared_ptr getValue() const; + + /** Return the read-only value object attached to this field, + * casted to the specified type. + * + * @return value object + */ + template + shared_ptr getValue() const + { + return dynamicCast (m_value); + } /** Return the value object attached to this field. * * @return value object */ - virtual ref getValue(); + virtual shared_ptr getValue(); + + /** Return the value object attached to this field, + * casted to the specified type. + * + * @return value object + */ + template + shared_ptr getValue() + { + return dynamicCast (m_value); + } /** Set the value of this field. * @@ -98,7 +118,7 @@ public: * valid for this header field * @param value new value */ - virtual void setValue(ref value); + virtual void setValue(shared_ptr value); /** Set the value of this field by cloning the specified value. * @@ -106,7 +126,7 @@ public: * valid for this header field * @param value new value */ - virtual void setValueConst(ref value); + virtual void setValueConst(shared_ptr value); /** Set the value of this field (reference version). * The value will be cloned. @@ -134,7 +154,7 @@ public: * @return parsed header field, or NULL if no more header field can be parsed * in the input buffer */ - static ref parseNext + static shared_ptr parseNext (const parsingContext& ctx, const string& buffer, const string::size_type position, @@ -160,7 +180,7 @@ protected: string m_name; - ref m_value; + shared_ptr m_value; }; diff --git a/vmime/headerFieldFactory.hpp b/vmime/headerFieldFactory.hpp index e8a1a84c..960f27b7 100644 --- a/vmime/headerFieldFactory.hpp +++ b/vmime/headerFieldFactory.hpp @@ -43,7 +43,7 @@ protected: headerFieldFactory(); ~headerFieldFactory(); - typedef ref (*AllocFunc)(void); + typedef shared_ptr (*AllocFunc)(void); typedef std::map NameMap; NameMap m_nameMap; @@ -51,7 +51,7 @@ protected: struct ValueInfo { - typedef ref (*ValueAllocFunc)(void); + typedef shared_ptr (*ValueAllocFunc)(void); typedef bool (*ValueTypeCheckFunc)(const object&); ValueAllocFunc allocFunc; @@ -64,7 +64,7 @@ protected: public: - static headerFieldFactory* getInstance(); + static shared_ptr getInstance(); #ifndef VMIME_BUILDING_DOC // TYPE must inherit from BASE_TYPE @@ -79,10 +79,10 @@ public: return typedObj != NULL; } - static ref creator() + static shared_ptr creator() { // Allocate a new object - return vmime::create (); + return shared_ptr (new TYPE()); } }; #endif // VMIME_BUILDING_DOC @@ -126,14 +126,14 @@ public: * the value of the field * @return a new field object */ - ref create(const string& name, const string& body = NULL_STRING); + shared_ptr create(const string& name, const string& body = NULL_STRING); /** Create a new field value for the specified field. * * @param fieldName name of the field for which to create value * @return a new value object for the field */ - ref createValue(const string& fieldName); + shared_ptr createValue(const string& fieldName); /** Returns whether the specified value type is valid for the specified field. * diff --git a/vmime/htmlTextPart.hpp b/vmime/htmlTextPart.hpp index 59ed1add..9596f3f4 100644 --- a/vmime/htmlTextPart.hpp +++ b/vmime/htmlTextPart.hpp @@ -51,11 +51,11 @@ public: const charset& getCharset() const; void setCharset(const charset& ch); - ref getPlainText() const; - void setPlainText(ref plainText); + shared_ptr getPlainText() const; + void setPlainText(shared_ptr plainText); - const ref getText() const; - void setText(ref text); + const shared_ptr getText() const; + void setText(shared_ptr text); /** Embedded object (eg: image for <IMG> tag). */ @@ -79,7 +79,7 @@ public: * @param refType reference type * @return a reference to a new embedded object */ - embeddedObject(ref data, const encoding& enc, + embeddedObject(shared_ptr data, const encoding& enc, const string& id, const mediaType& type, const ReferenceType refType); @@ -87,7 +87,7 @@ public: * * @return stored data */ - ref getData() const; + shared_ptr getData() const; /** Return the encoding used for data in this * embedded object. @@ -136,7 +136,7 @@ public: static const string cleanId(const string& id); - ref m_data; + shared_ptr m_data; encoding m_encoding; string m_id; mediaType m_type; @@ -158,7 +158,7 @@ public: * @param id object identifier * @return embedded object with the specified identifier */ - ref findObject(const string& id) const; + shared_ptr findObject(const string& id) const; /** Return the number of embedded objects. * @@ -171,7 +171,7 @@ public: * @param pos position of the embedded object * @return embedded object at position 'pos' */ - ref getObjectAt(const size_t pos) const; + shared_ptr getObjectAt(const size_t pos) const; /** Embed an object and returns a string which identifies it. * The returned identifier is suitable for use in the 'src' attribute @@ -185,7 +185,7 @@ public: * @return an unique object identifier used to identify the new * object among all other embedded objects */ - ref addObject(const string& data, const mediaType& type); + shared_ptr addObject(const string& data, const mediaType& type); /** Embed an object and returns a string which identifies it. * The returned identifier is suitable for use in the 'src' attribute @@ -196,7 +196,7 @@ public: * @return an unique object identifier used to identify the new * object among all other embedded objects */ - ref addObject(ref data, const mediaType& type); + shared_ptr addObject(shared_ptr data, const mediaType& type); /** Embed an object and returns a string which identifies it. * The returned identifier is suitable for use in the 'src' attribute @@ -208,23 +208,23 @@ public: * @return an unique object identifier used to identify the new * object among all other embedded objects */ - ref addObject(ref data, const encoding& enc, const mediaType& type); + shared_ptr addObject(shared_ptr data, const encoding& enc, const mediaType& type); size_t getPartCount() const; - void generateIn(ref message, ref parent) const; - void parse(ref message, ref parent, ref textPart); + void generateIn(shared_ptr message, shared_ptr parent) const; + void parse(shared_ptr message, shared_ptr parent, shared_ptr textPart); private: - ref m_plainText; - ref m_text; + shared_ptr m_plainText; + shared_ptr m_text; charset m_charset; - std::vector > m_objects; + std::vector > m_objects; - void findEmbeddedParts(const bodyPart& part, std::vector >& cidParts, std::vector >& locParts); + void findEmbeddedParts(const bodyPart& part, std::vector >& cidParts, std::vector >& locParts); void addEmbeddedObject(const bodyPart& part, const string& id, const embeddedObject::ReferenceType refType); bool findPlainTextPart(const bodyPart& part, const bodyPart& parent, const bodyPart& textPart); diff --git a/vmime/mailbox.hpp b/vmime/mailbox.hpp index b6dc9fbe..586f88ee 100644 --- a/vmime/mailbox.hpp +++ b/vmime/mailbox.hpp @@ -79,14 +79,14 @@ public: // Assignment void copyFrom(const component& other); - ref clone() const; + shared_ptr clone() const; mailbox& operator=(const mailbox& other); bool isEmpty() const; void clear(); - const std::vector > getChildComponents(); + const std::vector > getChildComponents(); bool isGroup() const; diff --git a/vmime/mailboxField.hpp b/vmime/mailboxField.hpp index 798e84d7..75cae592 100644 --- a/vmime/mailboxField.hpp +++ b/vmime/mailboxField.hpp @@ -43,7 +43,7 @@ namespace vmime class VMIME_EXPORT mailboxField : public headerField { - friend class vmime::creator; // create ref + friend class headerFieldFactory; protected: diff --git a/vmime/mailboxGroup.hpp b/vmime/mailboxGroup.hpp index 1c0511e1..ac6b9741 100644 --- a/vmime/mailboxGroup.hpp +++ b/vmime/mailboxGroup.hpp @@ -49,10 +49,10 @@ public: void copyFrom(const component& other); - ref clone() const; + shared_ptr clone() const; mailboxGroup& operator=(const component& other); - const std::vector > getChildComponents(); + const std::vector > getChildComponents(); /** Return the name of the group. * @@ -70,7 +70,7 @@ public: * * @param mbox mailbox to append */ - void appendMailbox(ref mbox); + void appendMailbox(shared_ptr mbox); /** Insert a new mailbox before the specified mailbox. * @@ -78,7 +78,7 @@ public: * @param mbox mailbox to insert * @throw exceptions::no_such_mailbox if the mailbox is not in the list */ - void insertMailboxBefore(ref beforeMailbox, ref mbox); + void insertMailboxBefore(shared_ptr beforeMailbox, shared_ptr mbox); /** Insert a new mailbox before the specified position. * @@ -86,7 +86,7 @@ public: * the beginning of the list) * @param mbox mailbox to insert */ - void insertMailboxBefore(const size_t pos, ref mbox); + void insertMailboxBefore(const size_t pos, shared_ptr mbox); /** Insert a new mailbox after the specified mailbox. * @@ -94,21 +94,21 @@ public: * @param mbox mailbox to insert * @throw exceptions::no_such_mailbox if the mailbox is not in the list */ - void insertMailboxAfter(ref afterMailbox, ref mbox); + void insertMailboxAfter(shared_ptr afterMailbox, shared_ptr mbox); /** Insert a new mailbox after the specified position. * * @param pos position of the mailbox before the new mailbox * @param mbox mailbox to insert */ - void insertMailboxAfter(const size_t pos, ref mbox); + void insertMailboxAfter(const size_t pos, shared_ptr mbox); /** Remove the specified mailbox from the list. * * @param mbox mailbox to remove * @throw exceptions::no_such_mailbox if the mailbox is not in the list */ - void removeMailbox(ref mbox); + void removeMailbox(shared_ptr mbox); /** Remove the mailbox at the specified position. * @@ -137,33 +137,33 @@ public: * @param pos position * @return mailbox at position 'pos' */ - ref getMailboxAt(const size_t pos); + shared_ptr getMailboxAt(const size_t pos); /** Return the mailbox at the specified position. * * @param pos position * @return mailbox at position 'pos' */ - const ref getMailboxAt(const size_t pos) const; + const shared_ptr getMailboxAt(const size_t pos) const; /** Return the mailbox list. * * @return list of mailboxes */ - const std::vector > getMailboxList() const; + const std::vector > getMailboxList() const; /** Return the mailbox list. * * @return list of mailboxes */ - const std::vector > getMailboxList(); + const std::vector > getMailboxList(); bool isGroup() const; private: text m_name; - std::vector > m_list; + std::vector > m_list; protected: diff --git a/vmime/mailboxList.hpp b/vmime/mailboxList.hpp index 1b4cbb50..25daefec 100644 --- a/vmime/mailboxList.hpp +++ b/vmime/mailboxList.hpp @@ -47,17 +47,17 @@ public: mailboxList(const mailboxList& mboxList); - ref clone() const; + shared_ptr clone() const; void copyFrom(const component& other); mailboxList& operator=(const mailboxList& other); - const std::vector > getChildComponents(); + const std::vector > getChildComponents(); /** Add a mailbox at the end of the list. * * @param mbox mailbox to append */ - void appendMailbox(ref mbox); + void appendMailbox(shared_ptr mbox); /** Insert a new mailbox before the specified mailbox. * @@ -65,7 +65,7 @@ public: * @param mbox mailbox to insert * @throw exceptions::no_such_mailbox if the mailbox is not in the list */ - void insertMailboxBefore(ref beforeMailbox, ref mbox); + void insertMailboxBefore(shared_ptr beforeMailbox, shared_ptr mbox); /** Insert a new mailbox before the specified position. * @@ -73,7 +73,7 @@ public: * the beginning of the list) * @param mbox mailbox to insert */ - void insertMailboxBefore(const size_t pos, ref mbox); + void insertMailboxBefore(const size_t pos, shared_ptr mbox); /** Insert a new mailbox after the specified mailbox. * @@ -81,21 +81,21 @@ public: * @param mbox mailbox to insert * @throw exceptions::no_such_mailbox if the mailbox is not in the list */ - void insertMailboxAfter(ref afterMailbox, ref mbox); + void insertMailboxAfter(shared_ptr afterMailbox, shared_ptr mbox); /** Insert a new mailbox after the specified position. * * @param pos position of the mailbox before the new mailbox * @param mbox mailbox to insert */ - void insertMailboxAfter(const size_t pos, ref mbox); + void insertMailboxAfter(const size_t pos, shared_ptr mbox); /** Remove the specified mailbox from the list. * * @param mbox mailbox to remove * @throw exceptions::no_such_mailbox if the mailbox is not in the list */ - void removeMailbox(ref mbox); + void removeMailbox(shared_ptr mbox); /** Remove the mailbox at the specified position. * @@ -124,32 +124,32 @@ public: * @param pos position * @return mailbox at position 'pos' */ - ref getMailboxAt(const size_t pos); + shared_ptr getMailboxAt(const size_t pos); /** Return the mailbox at the specified position. * * @param pos position * @return mailbox at position 'pos' */ - const ref getMailboxAt(const size_t pos) const; + const shared_ptr getMailboxAt(const size_t pos) const; /** Return the mailbox list. * * @return list of mailboxes */ - const std::vector > getMailboxList() const; + const std::vector > getMailboxList() const; /** Return the mailbox list. * * @return list of mailboxes */ - const std::vector > getMailboxList(); + const std::vector > getMailboxList(); /** Return a list of addresses. * * @return list of addresses */ - ref toAddressList() const; + shared_ptr toAddressList() const; private: diff --git a/vmime/mdn/MDNHelper.hpp b/vmime/mdn/MDNHelper.hpp index 0e853989..2584978f 100644 --- a/vmime/mdn/MDNHelper.hpp +++ b/vmime/mdn/MDNHelper.hpp @@ -48,14 +48,14 @@ public: * @param msg message in which to add a MDN request * @param mailboxes list of mailboxes to which the MDN will be sent */ - static void attachMDNRequest(ref msg, const mailboxList& mailboxes); + static void attachMDNRequest(shared_ptr msg, const mailboxList& mailboxes); /** Attach a MDN request to the specified message. * * @param msg message in which to add a MDN request * @param mbox mailbox to which the MDN will be sent */ - static void attachMDNRequest(ref msg, const mailbox& mbox); + static void attachMDNRequest(shared_ptr msg, const mailbox& mbox); /** Return a list of possible MDNs that can be generated * for the specified message. @@ -63,14 +63,14 @@ public: * @param msg message for which to send a MDN * @return list of possible MDNs */ - static const std::vector getPossibleMDNs(const ref msg); + static const std::vector getPossibleMDNs(const shared_ptr msg); /** Test whether the specified message is a MDN. * * @param msg message * @return true if the message is a MDN, false otherwise */ - static bool isMDN(const ref msg); + static bool isMDN(const shared_ptr msg); /** If the specified message is a MDN, return information * about it. @@ -79,7 +79,7 @@ public: * @throw exceptions::invalid_argument if the message is not a MDN * @return information about the MDN */ - static receivedMDNInfos getReceivedMDN(const ref msg); + static receivedMDNInfos getReceivedMDN(const shared_ptr msg); /** Check whether we need user confirmation for sending a MDN even * if he/she explicitely allowed automatic send of MDNs. This can @@ -88,7 +88,7 @@ public: * @param msg message for which to send a MDN * @return true if user confirmation should be asked, false otherwise */ - static bool needConfirmation(const ref msg); + static bool needConfirmation(const shared_ptr msg); /** Build a new MDN for the message. The resulting MDN can then be * sent over SMTP transport service. @@ -105,7 +105,7 @@ public: * @param fields additional MDN fields, like "Error", "Warning" or "Failure" (optional) * @return a new message object containing the MDN */ - static ref buildMDN(const sendableMDNInfos& mdnInfos, + static shared_ptr buildMDN(const sendableMDNInfos& mdnInfos, const string& text, const charset& ch, const mailbox& expeditor, @@ -118,17 +118,17 @@ public: private: - static ref createFirstMDNPart(const sendableMDNInfos& mdnInfos, + static shared_ptr createFirstMDNPart(const sendableMDNInfos& mdnInfos, const string& text, const charset& ch); - static ref createSecondMDNPart(const sendableMDNInfos& mdnInfos, + static shared_ptr createSecondMDNPart(const sendableMDNInfos& mdnInfos, const disposition& dispo, const string& reportingUA, const std::vector & reportingUAProducts, const std::map & fields); - static ref createThirdMDNPart(const sendableMDNInfos& mdnInfos); + static shared_ptr createThirdMDNPart(const sendableMDNInfos& mdnInfos); }; diff --git a/vmime/mdn/MDNInfos.hpp b/vmime/mdn/MDNInfos.hpp index d77a0306..030aa23e 100644 --- a/vmime/mdn/MDNInfos.hpp +++ b/vmime/mdn/MDNInfos.hpp @@ -47,7 +47,7 @@ public: * * @return related message */ - virtual const ref getMessage() const = 0; + virtual const shared_ptr getMessage() const = 0; }; diff --git a/vmime/mdn/receivedMDNInfos.hpp b/vmime/mdn/receivedMDNInfos.hpp index c836f23c..c6953a24 100644 --- a/vmime/mdn/receivedMDNInfos.hpp +++ b/vmime/mdn/receivedMDNInfos.hpp @@ -44,13 +44,13 @@ class VMIME_EXPORT receivedMDNInfos : public MDNInfos { public: - receivedMDNInfos(const ref msg); + receivedMDNInfos(const shared_ptr msg); receivedMDNInfos(const receivedMDNInfos& other); receivedMDNInfos& operator=(const receivedMDNInfos& other); - const ref getMessage() const; + const shared_ptr getMessage() const; /** Return the identifier of the message for which this MDN * has been generated. @@ -79,7 +79,7 @@ private: void extract(); - ref m_msg; + shared_ptr m_msg; disposition m_disp; messageId m_omid; diff --git a/vmime/mdn/sendableMDNInfos.hpp b/vmime/mdn/sendableMDNInfos.hpp index f886b5fa..e4f6d20d 100644 --- a/vmime/mdn/sendableMDNInfos.hpp +++ b/vmime/mdn/sendableMDNInfos.hpp @@ -42,12 +42,12 @@ class VMIME_EXPORT sendableMDNInfos : public MDNInfos { public: - sendableMDNInfos(const ref msg, const mailbox& mbox); + sendableMDNInfos(const shared_ptr msg, const mailbox& mbox); sendableMDNInfos(const sendableMDNInfos& other); sendableMDNInfos& operator=(const sendableMDNInfos& other); - const ref getMessage() const; + const shared_ptr getMessage() const; /** Return the recipient of the MDN (the mailbox that will receive * the notification message). @@ -61,7 +61,7 @@ private: void copyFrom(const sendableMDNInfos& other); - ref m_msg; + shared_ptr m_msg; mailbox m_mailbox; }; diff --git a/vmime/mediaType.hpp b/vmime/mediaType.hpp index b396c8bf..c2b214bd 100644 --- a/vmime/mediaType.hpp +++ b/vmime/mediaType.hpp @@ -51,11 +51,11 @@ public: mediaType& operator=(const string& type); - ref clone() const; + shared_ptr clone() const; void copyFrom(const component& other); mediaType& operator=(const mediaType& other); - const std::vector > getChildComponents(); + const std::vector > getChildComponents(); /** Return the media type. * See the constants in vmime::mediaTypes. diff --git a/vmime/messageAttachment.hpp b/vmime/messageAttachment.hpp index b6b360f4..641fd3e1 100644 --- a/vmime/messageAttachment.hpp +++ b/vmime/messageAttachment.hpp @@ -44,7 +44,7 @@ public: * * @return encapsulated message */ - virtual ref getMessage() const = 0; + virtual shared_ptr getMessage() const = 0; }; diff --git a/vmime/messageBuilder.hpp b/vmime/messageBuilder.hpp index f3f9fa0d..af86e826 100644 --- a/vmime/messageBuilder.hpp +++ b/vmime/messageBuilder.hpp @@ -136,13 +136,13 @@ public: * * @param attach new attachment */ - void attach(ref attach); + void attach(shared_ptr attach); /** Attach a new object to the message. * * @param attach new attachment */ - void appendAttachment(ref attach); + void appendAttachment(shared_ptr attach); /** Remove the attachment at the specified position. * @@ -155,14 +155,14 @@ public: * @param pos position of the attachment * @return attachment at the specified position */ - const ref getAttachmentAt(const size_t pos) const; + const shared_ptr getAttachmentAt(const size_t pos) const; /** Return the attachment at the specified position. * * @param pos position of the attachment * @return attachment at the specified position */ - ref getAttachmentAt(const size_t pos); + shared_ptr getAttachmentAt(const size_t pos); /** Return the number of attachments in the message. * @@ -174,13 +174,13 @@ public: * * @return list of attachments */ - const std::vector > getAttachmentList() const; + const std::vector > getAttachmentList() const; /** Return the list of attachments. * * @return list of attachments */ - const std::vector > getAttachmentList(); + const std::vector > getAttachmentList(); /** Change the type of the text part and construct a new part. * @@ -192,14 +192,14 @@ public: * * @return text part of the message */ - ref getTextPart(); + shared_ptr getTextPart(); /** Construct a new message based on the information specified * in this object. * * @return a new message */ - ref construct() const; + shared_ptr construct() const; private: @@ -211,9 +211,9 @@ private: text m_subject; - ref m_textPart; + shared_ptr m_textPart; - std::vector > m_attach; + std::vector > m_attach; }; diff --git a/vmime/messageId.hpp b/vmime/messageId.hpp index 7d6348e3..8c2f85d1 100644 --- a/vmime/messageId.hpp +++ b/vmime/messageId.hpp @@ -93,11 +93,11 @@ public: */ const string getId() const; - ref clone() const; + shared_ptr clone() const; void copyFrom(const component& other); messageId& operator=(const messageId& other); - const std::vector > getChildComponents(); + const std::vector > getChildComponents(); private: @@ -128,7 +128,7 @@ protected: * @param newPosition will receive the new position in the input buffer * @return a new message-id object, or null if no more message-id can be parsed from the input buffer */ - static ref parseNext + static shared_ptr parseNext (const parsingContext& ctx, const string& buffer, const string::size_type position, diff --git a/vmime/messageIdSequence.hpp b/vmime/messageIdSequence.hpp index ec54dbd3..39c415c7 100644 --- a/vmime/messageIdSequence.hpp +++ b/vmime/messageIdSequence.hpp @@ -45,18 +45,18 @@ public: ~messageIdSequence(); - ref clone() const; + shared_ptr clone() const; void copyFrom(const component& other); messageIdSequence& operator=(const messageIdSequence& other); - const std::vector > getChildComponents(); + const std::vector > getChildComponents(); /** Add a message-id at the end of the list. * * @param mid message-id to append */ - void appendMessageId(ref mid); + void appendMessageId(shared_ptr mid); /** Insert a new message-id before the specified message-id. * @@ -64,7 +64,7 @@ public: * @param mid message-id to insert * @throw exceptions::no_such_messageid if the message-id is not in the list */ - void insertMessageIdBefore(ref beforeMid, ref mid); + void insertMessageIdBefore(shared_ptr beforeMid, shared_ptr mid); /** Insert a new message-id before the specified position. * @@ -72,7 +72,7 @@ public: * the beginning of the list) * @param mid message-id to insert */ - void insertMessageIdBefore(const size_t pos, ref mid); + void insertMessageIdBefore(const size_t pos, shared_ptr mid); /** Insert a new message-id after the specified message-id. * @@ -80,21 +80,21 @@ public: * @param mid message-id to insert * @throw exceptions::no_such_message_id if the message-id is not in the list */ - void insertMessageIdAfter(ref afterMid, ref mid); + void insertMessageIdAfter(shared_ptr afterMid, shared_ptr mid); /** Insert a new message-id after the specified position. * * @param pos position of the message-id before the new message-id * @param mid message-id to insert */ - void insertMessageIdAfter(const size_t pos, ref mid); + void insertMessageIdAfter(const size_t pos, shared_ptr mid); /** Remove the specified message-id from the list. * * @param mid message-id to remove * @throw exceptions::no_such_message_id if the message-id is not in the list */ - void removeMessageId(ref mid); + void removeMessageId(shared_ptr mid); /** Remove the message-id at the specified position. * @@ -123,30 +123,30 @@ public: * @param pos position * @return message-id at position 'pos' */ - const ref getMessageIdAt(const size_t pos); + const shared_ptr getMessageIdAt(const size_t pos); /** Return the message-id at the specified position. * * @param pos position * @return message-id at position 'pos' */ - const ref getMessageIdAt(const size_t pos) const; + const shared_ptr getMessageIdAt(const size_t pos) const; /** Return the message-id list. * * @return list of message-ids */ - const std::vector > getMessageIdList() const; + const std::vector > getMessageIdList() const; /** Return the message-id list. * * @return list of message-ids */ - const std::vector > getMessageIdList(); + const std::vector > getMessageIdList(); private: - std::vector > m_list; + std::vector > m_list; protected: diff --git a/vmime/messageParser.hpp b/vmime/messageParser.hpp index d89170ad..c3a48f11 100644 --- a/vmime/messageParser.hpp +++ b/vmime/messageParser.hpp @@ -49,7 +49,7 @@ class VMIME_EXPORT messageParser public: messageParser(const string& buffer); - messageParser(ref msg); + messageParser(shared_ptr msg); ~messageParser(); public: @@ -101,19 +101,19 @@ public: * @param pos position of the attachment * @return attachment at position 'pos' */ - const ref getAttachmentAt(const size_t pos) const; + const shared_ptr getAttachmentAt(const size_t pos) const; /** Return the attachments of the message. * * @return list of attachments in the message */ - const std::vector > getAttachmentList() const; + const std::vector > getAttachmentList() const; /** Return the text parts of the message. * * @return list of text parts in the message */ - const std::vector > getTextPartList() const; + const std::vector > getTextPartList() const; /** Return the number of text parts in the message. * @@ -126,7 +126,7 @@ public: * @param pos position of the text part * @return text part at position 'pos' */ - const ref getTextPartAt(const size_t pos) const; + const shared_ptr getTextPartAt(const size_t pos) const; private: @@ -140,16 +140,16 @@ private: datetime m_date; - std::vector > m_attach; + std::vector > m_attach; - std::vector > m_textParts; + std::vector > m_textParts; - void parse(ref msg); + void parse(shared_ptr msg); - void findAttachments(ref msg); + void findAttachments(shared_ptr msg); - void findTextParts(ref msg, ref part); - bool findSubTextParts(ref msg, ref part); + void findTextParts(shared_ptr msg, shared_ptr part); + bool findSubTextParts(shared_ptr msg, shared_ptr part); }; diff --git a/vmime/misc/importanceHelper.hpp b/vmime/misc/importanceHelper.hpp index c5c48f50..ae8297fc 100644 --- a/vmime/misc/importanceHelper.hpp +++ b/vmime/misc/importanceHelper.hpp @@ -58,13 +58,13 @@ public: * * @param msg message on which to reset importance */ - static void resetImportance(ref msg); + static void resetImportance(shared_ptr msg); /** Reset the importance of a message to the default importance. * * @param hdr message header on which to reset importance */ - static void resetImportanceHeader(ref
hdr); + static void resetImportanceHeader(shared_ptr
hdr); /** Return the importance of the specified message. * @@ -72,7 +72,7 @@ public: * @return importance of the message, or default importance is no * information about importance is given in the message */ - static Importance getImportance(ref msg); + static Importance getImportance(shared_ptr msg); /** Return the importance of a message, given its header. * @@ -80,21 +80,21 @@ public: * @return importance of the message, or default importance is no * information about importance is given in the message */ - static Importance getImportanceHeader(ref hdr); + static Importance getImportanceHeader(shared_ptr hdr); /** Set the importance of the specified message. * * @param msg message on which to set importance * @param i new message importance */ - static void setImportance(ref msg, const Importance i); + static void setImportance(shared_ptr msg, const Importance i); /** Set the importance of a message, given its header. * * @param hdr message header on which to set importance * @param i new message importance */ - static void setImportanceHeader(ref
hdr, const Importance i); + static void setImportanceHeader(shared_ptr
hdr, const Importance i); }; diff --git a/vmime/net/events.hpp b/vmime/net/events.hpp index 1e5fd7f3..a3e952d4 100644 --- a/vmime/net/events.hpp +++ b/vmime/net/events.hpp @@ -75,13 +75,13 @@ public: }; - messageCountEvent(ref folder, const Types type, const std::vector & nums); + messageCountEvent(shared_ptr folder, const Types type, const std::vector & nums); /** Return the folder in which messages have been added/removed. * * @return folder in which message count changed */ - ref getFolder() const; + shared_ptr getFolder() const; /** Return the event type. * @@ -106,7 +106,7 @@ public: private: - ref m_folder; + shared_ptr m_folder; const Types m_type; std::vector m_nums; }; @@ -123,8 +123,8 @@ protected: public: - virtual void messagesAdded(ref event) = 0; - virtual void messagesRemoved(ref event) = 0; + virtual void messagesAdded(shared_ptr event) = 0; + virtual void messagesRemoved(shared_ptr event) = 0; }; @@ -144,13 +144,13 @@ public: }; - messageChangedEvent(ref folder, const Types type, const std::vector & nums); + messageChangedEvent(shared_ptr folder, const Types type, const std::vector & nums); /** Return the folder in which messages have changed. * * @return folder in which message count changed */ - ref getFolder() const; + shared_ptr getFolder() const; /** Return the event type. * @@ -175,7 +175,7 @@ public: private: - ref m_folder; + shared_ptr m_folder; const Types m_type; std::vector m_nums; }; @@ -192,7 +192,7 @@ protected: public: - virtual void messageChanged(ref event) = 0; + virtual void messageChanged(shared_ptr event) = 0; }; @@ -214,13 +214,13 @@ public: }; - folderEvent(ref folder, const Types type, const utility::path& oldPath, const utility::path& newPath); + folderEvent(shared_ptr folder, const Types type, const utility::path& oldPath, const utility::path& newPath); /** Return the folder on which the event occured. * * @return folder on which the event occured */ - ref getFolder() const; + shared_ptr getFolder() const; /** Return the event type. * @@ -239,7 +239,7 @@ public: private: - ref m_folder; + shared_ptr m_folder; const Types m_type; const utility::path m_oldPath; const utility::path m_newPath; @@ -257,9 +257,9 @@ protected: public: - virtual void folderCreated(ref event) = 0; - virtual void folderRenamed(ref event) = 0; - virtual void folderDeleted(ref event) = 0; + virtual void folderCreated(shared_ptr event) = 0; + virtual void folderRenamed(shared_ptr event) = 0; + virtual void folderDeleted(shared_ptr event) = 0; }; diff --git a/vmime/net/folder.hpp b/vmime/net/folder.hpp index 643a323b..deefaf49 100644 --- a/vmime/net/folder.hpp +++ b/vmime/net/folder.hpp @@ -186,7 +186,7 @@ public: * @return a new object referencing the specified message * @throw exceptions::net_exception if an error occurs */ - virtual ref getMessage(const int num) = 0; + virtual shared_ptr getMessage(const int num) = 0; /** Get new references to messages in this folder, given either their * sequence numbers or UIDs. @@ -215,7 +215,7 @@ public: * @return new objects referencing the specified messages * @throw exceptions::net_exception if an error occurs */ - virtual std::vector > getMessages(const messageSet& msgs) = 0; + virtual std::vector > getMessages(const messageSet& msgs) = 0; /** Return the number of messages in this folder. * @@ -229,7 +229,7 @@ public: * @return a new object referencing the specified folder * @throw exceptions::net_exception if an error occurs */ - virtual ref getFolder(const folder::path::component& name) = 0; + virtual shared_ptr getFolder(const folder::path::component& name) = 0; /** Get the list of all sub-folders in this folder. * @@ -238,7 +238,7 @@ public: * @return list of sub-folders * @throw exceptions::net_exception if an error occurs */ - virtual std::vector > getFolders(const bool recursive = false) = 0; + virtual std::vector > getFolders(const bool recursive = false) = 0; /** Rename (move) this folder to another location. * @@ -271,7 +271,7 @@ public: * @param progress progress listener, or NULL if not used * @throw exceptions::net_exception if an error occurs */ - virtual void addMessage(ref msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL) = 0; + virtual void addMessage(shared_ptr msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL) = 0; /** Add a message to this folder. * @@ -307,7 +307,7 @@ public: * @return current folder status * @throw exceptions::net_exception if an error occurs */ - virtual ref getStatus() = 0; + virtual shared_ptr getStatus() = 0; /** Expunge deleted messages. * @@ -319,19 +319,19 @@ public: * * @return parent folder object */ - virtual ref getParent() = 0; + virtual shared_ptr getParent() = 0; /** Return a reference to the store to which this folder belongs. * * @return the store object to which this folder is attached */ - virtual ref getStore() const = 0; + virtual shared_ptr getStore() const = 0; /** Return a reference to the store to which this folder belongs. * * @return the store object to which this folder is attached */ - virtual ref getStore() = 0; + virtual shared_ptr getStore() = 0; /** Fetch objects for the specified messages. * @@ -340,7 +340,7 @@ public: * @param progress progress listener, or NULL if not used * @throw exceptions::net_exception if an error occurs */ - virtual void fetchMessages(std::vector >& msg, const fetchAttributes& attribs, utility::progressListener* progress = NULL) = 0; + virtual void fetchMessages(std::vector >& msg, const fetchAttributes& attribs, utility::progressListener* progress = NULL) = 0; /** Fetch objects for the specified message. * @@ -348,7 +348,7 @@ public: * @param attribs set of attributes to fetch * @throw exceptions::net_exception if an error occurs */ - virtual void fetchMessage(ref msg, const fetchAttributes& attribs) = 0; + virtual void fetchMessage(shared_ptr msg, const fetchAttributes& attribs) = 0; /** Return the list of fetchable objects supported by * the underlying protocol (see folder::fetchAttributes). @@ -377,10 +377,10 @@ public: protected: - void notifyMessageChanged(ref event); - void notifyMessageCount(ref event); - void notifyFolder(ref event); - void notifyEvent(ref event); + void notifyMessageChanged(shared_ptr event); + void notifyMessageCount(shared_ptr event); + void notifyFolder(shared_ptr event); + void notifyEvent(shared_ptr event); private: diff --git a/vmime/net/folderStatus.hpp b/vmime/net/folderStatus.hpp index f4cc62fc..b94db052 100644 --- a/vmime/net/folderStatus.hpp +++ b/vmime/net/folderStatus.hpp @@ -61,7 +61,7 @@ public: * * @return a copy of this object */ - virtual ref clone() const = 0; + virtual shared_ptr clone() const = 0; }; diff --git a/vmime/net/imap/IMAPConnection.hpp b/vmime/net/imap/IMAPConnection.hpp index ff95c611..bc5590ba 100644 --- a/vmime/net/imap/IMAPConnection.hpp +++ b/vmime/net/imap/IMAPConnection.hpp @@ -54,7 +54,7 @@ class VMIME_EXPORT IMAPConnection : public object { public: - IMAPConnection(ref store, ref auth); + IMAPConnection(shared_ptr store, shared_ptr auth); ~IMAPConnection(); @@ -85,22 +85,22 @@ public: IMAPParser::response* readResponse(IMAPParser::literalHandler* lh = NULL); - ref getStore() const; - ref getStore(); + shared_ptr getStore() const; + shared_ptr getStore(); - ref getSession(); + shared_ptr getSession(); void fetchCapabilities(); void invalidateCapabilities(); const std::vector getCapabilities(); bool hasCapability(const string& capa); - ref getAuthenticator(); + shared_ptr getAuthenticator(); bool isSecuredConnection() const; - ref getConnectionInfos() const; + shared_ptr getConnectionInfos() const; - ref getSocket() const; + shared_ptr getSocket() const; bool isMODSEQDisabled() const; void disableMODSEQ(); @@ -120,24 +120,24 @@ private: void processCapabilityResponseData(const IMAPParser::capability_data* capaData); - weak_ref m_store; + weak_ptr m_store; - ref m_auth; + shared_ptr m_auth; - ref m_socket; + shared_ptr m_socket; - ref m_parser; + shared_ptr m_parser; - ref m_tag; + shared_ptr m_tag; char m_hierarchySeparator; ProtocolStates m_state; - ref m_timeoutHandler; + shared_ptr m_timeoutHandler; bool m_secured; - ref m_cntInfos; + shared_ptr m_cntInfos; bool m_firstTag; diff --git a/vmime/net/imap/IMAPFolder.hpp b/vmime/net/imap/IMAPFolder.hpp index 7bb9c0af..5edbfb16 100644 --- a/vmime/net/imap/IMAPFolder.hpp +++ b/vmime/net/imap/IMAPFolder.hpp @@ -61,16 +61,15 @@ private: friend class IMAPStore; friend class IMAPMessage; - friend class vmime::creator; // vmime::create - - IMAPFolder(const folder::path& path, ref store, const int type = TYPE_UNDEFINED, const int flags = FLAG_UNDEFINED); IMAPFolder(const IMAPFolder&); - ~IMAPFolder(); - public: + IMAPFolder(const folder::path& path, shared_ptr store, const int type = TYPE_UNDEFINED, const int flags = FLAG_UNDEFINED); + + ~IMAPFolder(); + int getMode() const; int getType(); @@ -90,15 +89,15 @@ public: bool isOpen() const; - ref getMessage(const int num); - std::vector > getMessages(const messageSet& msgs); + shared_ptr getMessage(const int num); + std::vector > getMessages(const messageSet& msgs); std::vector getMessageNumbersStartingOnUID(const message::uid& uid); int getMessageCount(); - ref getFolder(const folder::path::component& name); - std::vector > getFolders(const bool recursive = false); + shared_ptr getFolder(const folder::path::component& name); + std::vector > getFolders(const bool recursive = false); void rename(const folder::path& newPath); @@ -106,26 +105,26 @@ public: void setMessageFlags(const messageSet& msgs, const int flags, const int mode = message::FLAG_MODE_SET); - void addMessage(ref msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL); + void addMessage(shared_ptr msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL); void addMessage(utility::inputStream& is, const int size, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL); void copyMessages(const folder::path& dest, const messageSet& msgs); void status(int& count, int& unseen); - ref getStatus(); + shared_ptr getStatus(); void noop(); void expunge(); - ref getParent(); + shared_ptr getParent(); - ref getStore() const; - ref getStore(); + shared_ptr getStore() const; + shared_ptr getStore(); - void fetchMessages(std::vector >& msg, const fetchAttributes& options, utility::progressListener* progress = NULL); - void fetchMessage(ref msg, const fetchAttributes& options); + void fetchMessages(std::vector >& msg, const fetchAttributes& options, utility::progressListener* progress = NULL); + void fetchMessage(shared_ptr msg, const fetchAttributes& options); int getFetchCapabilities() const; @@ -177,8 +176,8 @@ private: void processStatusUpdate(const IMAPParser::response* resp); - weak_ref m_store; - ref m_connection; + weak_ptr m_store; + shared_ptr m_connection; folder::path m_path; folder::path::component m_name; @@ -189,7 +188,7 @@ private: int m_type; int m_flags; - ref m_status; + shared_ptr m_status; std::vector m_messages; }; diff --git a/vmime/net/imap/IMAPFolderStatus.hpp b/vmime/net/imap/IMAPFolderStatus.hpp index bcd6415e..03ca5937 100644 --- a/vmime/net/imap/IMAPFolderStatus.hpp +++ b/vmime/net/imap/IMAPFolderStatus.hpp @@ -55,7 +55,7 @@ public: unsigned int getMessageCount() const; unsigned int getUnseenCount() const; - ref clone() const; + shared_ptr clone() const; /** Returns the the number of messages with the Recent flag set. * diff --git a/vmime/net/imap/IMAPMessage.hpp b/vmime/net/imap/IMAPMessage.hpp index b57ae332..272fe17b 100644 --- a/vmime/net/imap/IMAPMessage.hpp +++ b/vmime/net/imap/IMAPMessage.hpp @@ -54,16 +54,16 @@ private: friend class IMAPFolder; friend class IMAPMessagePartContentHandler; - friend class vmime::creator; // vmime::create - IMAPMessage(ref folder, const int num); - IMAPMessage(ref folder, const int num, const uid& uid); IMAPMessage(const IMAPMessage&) : message() { } - ~IMAPMessage(); - public: + IMAPMessage(shared_ptr folder, const int num); + IMAPMessage(shared_ptr folder, const int num, const uid& uid); + + ~IMAPMessage(); + int getNumber() const; const uid getUID() const; @@ -84,20 +84,20 @@ public: bool isExpunged() const; - ref getStructure() const; - ref getStructure(); + shared_ptr getStructure() const; + shared_ptr getStructure(); - ref getHeader() const; + shared_ptr getHeader() const; int getFlags() const; void setFlags(const int flags, const int mode = FLAG_MODE_SET); void extract(utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const; - void extractPart(ref p, utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const; + void extractPart(shared_ptr p, utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const; - void fetchPartHeader(ref p); + void fetchPartHeader(shared_ptr p); - ref getParsedMessage(); + shared_ptr getParsedMessage(); private: @@ -125,7 +125,7 @@ private: * * @param str structure for which to fetch parts headers */ - void fetchPartHeaderForStructure(ref str); + void fetchPartHeaderForStructure(shared_ptr str); /** Recursively contruct parsed message from structure. * Called by getParsedMessage(). @@ -134,7 +134,7 @@ private: * @param str structure for which to construct part * @param level current nesting level (0 is root) */ - void constructParsedMessage(ref parentPart, ref str, int level = 0); + void constructParsedMessage(shared_ptr parentPart, shared_ptr str, int level = 0); enum ExtractFlags @@ -144,16 +144,16 @@ private: EXTRACT_PEEK = 0x10 }; - void extractImpl(ref p, utility::outputStream& os, utility::progressListener* progress, + void extractImpl(shared_ptr p, utility::outputStream& os, utility::progressListener* progress, const int start, const int length, const int extractFlags) const; - ref
getOrCreateHeader(); + shared_ptr
getOrCreateHeader(); void onFolderClosed(); - weak_ref m_folder; + weak_ptr m_folder; int m_num; int m_size; @@ -162,8 +162,8 @@ private: uid m_uid; vmime_uint64 m_modseq; - ref
m_header; - ref m_structure; + shared_ptr
m_header; + shared_ptr m_structure; }; diff --git a/vmime/net/imap/IMAPMessagePart.hpp b/vmime/net/imap/IMAPMessagePart.hpp index 5c38501d..f71d7d43 100644 --- a/vmime/net/imap/IMAPMessagePart.hpp +++ b/vmime/net/imap/IMAPMessagePart.hpp @@ -46,38 +46,34 @@ class IMAPMessageStructure; class VMIME_EXPORT IMAPMessagePart : public messagePart { -private: - - friend class vmime::creator; - - IMAPMessagePart(ref parent, const int number, const IMAPParser::body_type_mpart* mpart); - IMAPMessagePart(ref parent, const int number, const IMAPParser::body_type_1part* part); - public: - ref getStructure() const; - ref getStructure(); + IMAPMessagePart(shared_ptr parent, const int number, const IMAPParser::body_type_mpart* mpart); + IMAPMessagePart(shared_ptr parent, const int number, const IMAPParser::body_type_1part* part); - ref getParent() const; + shared_ptr getStructure() const; + shared_ptr getStructure(); + + shared_ptr getParent() const; const mediaType& getType() const; int getSize() const; int getNumber() const; - ref getHeader() const; + shared_ptr getHeader() const; - static ref create - (ref parent, const int number, const IMAPParser::body* body); + static shared_ptr create + (shared_ptr parent, const int number, const IMAPParser::body* body); header& getOrCreateHeader(); private: - ref m_structure; - weak_ref m_parent; - ref
m_header; + shared_ptr m_structure; + weak_ptr m_parent; + shared_ptr
m_header; int m_number; int m_size; diff --git a/vmime/net/imap/IMAPMessagePartContentHandler.hpp b/vmime/net/imap/IMAPMessagePartContentHandler.hpp index ac273151..80e1f0e5 100644 --- a/vmime/net/imap/IMAPMessagePartContentHandler.hpp +++ b/vmime/net/imap/IMAPMessagePartContentHandler.hpp @@ -44,9 +44,9 @@ class VMIME_EXPORT IMAPMessagePartContentHandler : public contentHandler { public: - IMAPMessagePartContentHandler(ref msg, ref part, const vmime::encoding& encoding); + IMAPMessagePartContentHandler(shared_ptr msg, shared_ptr part, const vmime::encoding& encoding); - ref clone() const; + shared_ptr clone() const; void generate(utility::outputStream& os, const vmime::encoding& enc, const string::size_type maxLineLength = lineLengthLimits::infinite) const; @@ -68,8 +68,8 @@ public: private: - weak_ref m_message; - weak_ref m_part; + weak_ptr m_message; + weak_ptr m_part; vmime::encoding m_encoding; vmime::mediaType m_contentType; diff --git a/vmime/net/imap/IMAPMessageStructure.hpp b/vmime/net/imap/IMAPMessageStructure.hpp index e2a9f169..44b6d6f0 100644 --- a/vmime/net/imap/IMAPMessageStructure.hpp +++ b/vmime/net/imap/IMAPMessageStructure.hpp @@ -50,17 +50,17 @@ public: IMAPMessageStructure(); IMAPMessageStructure(const IMAPParser::body* body); - IMAPMessageStructure(ref parent, const std::vector & list); + IMAPMessageStructure(shared_ptr parent, const std::vector & list); - ref getPartAt(const size_t x) const; - ref getPartAt(const size_t x); + shared_ptr getPartAt(const size_t x) const; + shared_ptr getPartAt(const size_t x); size_t getPartCount() const; - static ref emptyStructure(); + static shared_ptr emptyStructure(); private: - std::vector > m_parts; + std::vector > m_parts; }; diff --git a/vmime/net/imap/IMAPParser.hpp b/vmime/net/imap/IMAPParser.hpp index 63858b89..519cadd8 100644 --- a/vmime/net/imap/IMAPParser.hpp +++ b/vmime/net/imap/IMAPParser.hpp @@ -36,7 +36,6 @@ #include "vmime/charset.hpp" #include "vmime/exception.hpp" -#include "vmime/utility/smartPtr.hpp" #include "vmime/utility/stringUtils.hpp" #include "vmime/utility/progressListener.hpp" @@ -55,6 +54,7 @@ #include #include +#include //#define DEBUG_RESPONSE 1 @@ -142,19 +142,19 @@ class VMIME_EXPORT IMAPParser : public object { public: - IMAPParser(weak_ref tag, weak_ref sok, weak_ref _timeoutHandler) + IMAPParser(weak_ptr tag, weak_ptr sok, weak_ptr _timeoutHandler) : m_tag(tag), m_socket(sok), m_progress(NULL), m_strict(false), m_literalHandler(NULL), m_timeoutHandler(_timeoutHandler) { } - ref getTag() const + shared_ptr getTag() const { - return m_tag.acquire(); + return m_tag.lock(); } - void setSocket(ref sok) + void setSocket(shared_ptr sok) { m_socket = sok; } @@ -871,7 +871,7 @@ public: // quoted ::= <"> *QUOTED_CHAR <"> if (parser.check >(line, &pos, true)) { - utility::auto_ptr text(parser.get (line, &pos)); + std::auto_ptr text(parser.get (line, &pos)); parser.check >(line, &pos); if (parser.m_literalHandler != NULL) @@ -2189,28 +2189,28 @@ public: parser.check >(line, &pos); parser.check (line, &pos, true); - utility::auto_ptr nd(parser.get (line, &pos)); + std::auto_ptr nd(parser.get (line, &pos)); parser.check >(line, &pos); - utility::auto_ptr amo(parser.get (line, &pos)); + std::auto_ptr amo(parser.get (line, &pos)); parser.check >(line, &pos); - utility::auto_ptr ny(parser.get (line, &pos)); + std::auto_ptr ny(parser.get (line, &pos)); parser.check (line, &pos, true); // 2digit ":" 2digit ":" 2digit - utility::auto_ptr nh(parser.get (line, &pos)); + std::auto_ptr nh(parser.get (line, &pos)); parser.check >(line, &pos); - utility::auto_ptr nmi(parser.get (line, &pos)); + std::auto_ptr nmi(parser.get (line, &pos)); parser.check >(line, &pos); - utility::auto_ptr ns(parser.get (line, &pos)); + std::auto_ptr ns(parser.get (line, &pos)); parser.check (line, &pos, true); @@ -2220,7 +2220,7 @@ public: if (!(parser.check >(line, &pos, true))) parser.check >(line, &pos); - utility::auto_ptr nz(parser.get (line, &pos)); + std::auto_ptr nz(parser.get (line, &pos)); parser.check >(line, &pos); @@ -5406,8 +5406,8 @@ public: private: - weak_ref m_tag; - weak_ref m_socket; + weak_ptr m_tag; + weak_ptr m_socket; utility::progressListener* m_progress; @@ -5415,7 +5415,7 @@ private: literalHandler* m_literalHandler; - weak_ref m_timeoutHandler; + weak_ptr m_timeoutHandler; string m_buffer; @@ -5461,8 +5461,8 @@ public: { string receiveBuffer; - ref toh = m_timeoutHandler.acquire(); - ref sok = m_socket.acquire(); + shared_ptr toh = m_timeoutHandler.lock(); + shared_ptr sok = m_socket.lock(); if (toh) toh->resetTimeOut(); @@ -5499,8 +5499,8 @@ public: string::size_type len = 0; string receiveBuffer; - ref toh = m_timeoutHandler.acquire(); - ref sok = m_socket.acquire(); + shared_ptr toh = m_timeoutHandler.lock(); + shared_ptr sok = m_socket.lock(); if (m_progress) m_progress->start(count); diff --git a/vmime/net/imap/IMAPSStore.hpp b/vmime/net/imap/IMAPSStore.hpp index e7f05d3f..9d27bdd0 100644 --- a/vmime/net/imap/IMAPSStore.hpp +++ b/vmime/net/imap/IMAPSStore.hpp @@ -46,7 +46,7 @@ class VMIME_EXPORT IMAPSStore : public IMAPStore { public: - IMAPSStore(ref sess, ref auth); + IMAPSStore(shared_ptr sess, shared_ptr auth); ~IMAPSStore(); const string getProtocolName() const; diff --git a/vmime/net/imap/IMAPStore.hpp b/vmime/net/imap/IMAPStore.hpp index e6b27d8d..f854fadf 100644 --- a/vmime/net/imap/IMAPStore.hpp +++ b/vmime/net/imap/IMAPStore.hpp @@ -60,14 +60,14 @@ class VMIME_EXPORT IMAPStore : public store public: - IMAPStore(ref sess, ref auth, const bool secured = false); + IMAPStore(shared_ptr sess, shared_ptr auth, const bool secured = false); ~IMAPStore(); const string getProtocolName() const; - ref getDefaultFolder(); - ref getRootFolder(); - ref getFolder(const folder::path& path); + shared_ptr getDefaultFolder(); + shared_ptr getRootFolder(); + shared_ptr getFolder(const folder::path& path); bool isValidFolderName(const folder::path::component& name) const; @@ -85,17 +85,17 @@ public: bool isIMAPS() const; bool isSecuredConnection() const; - ref getConnectionInfos() const; - ref getConnection(); + shared_ptr getConnectionInfos() const; + shared_ptr getConnection(); protected: // Connection - ref m_connection; + shared_ptr m_connection; - ref connection(); + shared_ptr connection(); void registerFolder(IMAPFolder* folder); diff --git a/vmime/net/imap/IMAPUtils.hpp b/vmime/net/imap/IMAPUtils.hpp index 76c44494..988b6a2c 100644 --- a/vmime/net/imap/IMAPUtils.hpp +++ b/vmime/net/imap/IMAPUtils.hpp @@ -89,7 +89,7 @@ public: * @return fetch request */ static const string buildFetchRequest - (ref cnt, const messageSet& msgs, const fetchAttributes& options); + (shared_ptr cnt, const messageSet& msgs, const fetchAttributes& options); /** Convert a parser-style address list to a mailbox list. * @@ -115,7 +115,7 @@ public: private: static const string buildFetchRequestImpl - (ref cnt, const string& mode, const string& set, const int options); + (shared_ptr cnt, const string& mode, const string& set, const int options); }; diff --git a/vmime/net/maildir/format/courierMaildirFormat.hpp b/vmime/net/maildir/format/courierMaildirFormat.hpp index 6f47b7f8..b8443426 100644 --- a/vmime/net/maildir/format/courierMaildirFormat.hpp +++ b/vmime/net/maildir/format/courierMaildirFormat.hpp @@ -47,7 +47,7 @@ class VMIME_EXPORT courierMaildirFormat : public maildirFormat { public: - courierMaildirFormat(ref ctx); + courierMaildirFormat(shared_ptr ctx); /* Folder types: diff --git a/vmime/net/maildir/format/kmailMaildirFormat.hpp b/vmime/net/maildir/format/kmailMaildirFormat.hpp index ca73eba7..98ca212e 100644 --- a/vmime/net/maildir/format/kmailMaildirFormat.hpp +++ b/vmime/net/maildir/format/kmailMaildirFormat.hpp @@ -47,7 +47,7 @@ class VMIME_EXPORT kmailMaildirFormat : public maildirFormat { public: - kmailMaildirFormat(ref ctx); + kmailMaildirFormat(shared_ptr ctx); /* Folder types: diff --git a/vmime/net/maildir/maildirFolder.hpp b/vmime/net/maildir/maildirFolder.hpp index 92de4d0d..338c6f96 100644 --- a/vmime/net/maildir/maildirFolder.hpp +++ b/vmime/net/maildir/maildirFolder.hpp @@ -59,15 +59,15 @@ private: friend class maildirStore; friend class maildirMessage; - friend class vmime::creator; // vmime::create - - maildirFolder(const folder::path& path, ref store); maildirFolder(const maildirFolder&) : folder() { } +public: + + maildirFolder(const folder::path& path, shared_ptr store); + ~maildirFolder(); -public: int getMode() const; @@ -88,13 +88,13 @@ public: bool isOpen() const; - ref getMessage(const int num); - std::vector > getMessages(const messageSet& msgs); + shared_ptr getMessage(const int num); + std::vector > getMessages(const messageSet& msgs); int getMessageCount(); - ref getFolder(const folder::path::component& name); - std::vector > getFolders(const bool recursive = false); + shared_ptr getFolder(const folder::path::component& name); + std::vector > getFolders(const bool recursive = false); void rename(const folder::path& newPath); @@ -102,24 +102,24 @@ public: void setMessageFlags(const messageSet& msgs, const int flags, const int mode = message::FLAG_MODE_SET); - void addMessage(ref msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL); + void addMessage(shared_ptr msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL); void addMessage(utility::inputStream& is, const int size, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL); void copyMessages(const folder::path& dest, const messageSet& msgs); void status(int& count, int& unseen); - ref getStatus(); + shared_ptr getStatus(); void expunge(); - ref getParent(); + shared_ptr getParent(); - ref getStore() const; - ref getStore(); + shared_ptr getStore() const; + shared_ptr getStore(); - void fetchMessages(std::vector >& msg, const fetchAttributes& options, utility::progressListener* progress = NULL); - void fetchMessage(ref msg, const fetchAttributes& options); + void fetchMessages(std::vector >& msg, const fetchAttributes& options, utility::progressListener* progress = NULL); + void fetchMessage(shared_ptr msg, const fetchAttributes& options); int getFetchCapabilities() const; @@ -129,7 +129,7 @@ private: void scanFolder(); - void listFolders(std::vector >& list, const bool recursive); + void listFolders(std::vector >& list, const bool recursive); void registerMessage(maildirMessage* msg); void unregisterMessage(maildirMessage* msg); @@ -149,7 +149,7 @@ private: void notifyMessagesCopied(const folder::path& dest); - weak_ref m_store; + weak_ptr m_store; folder::path m_path; folder::path::component m_name; diff --git a/vmime/net/maildir/maildirFolderStatus.hpp b/vmime/net/maildir/maildirFolderStatus.hpp index 28e01f11..155fb20f 100644 --- a/vmime/net/maildir/maildirFolderStatus.hpp +++ b/vmime/net/maildir/maildirFolderStatus.hpp @@ -53,7 +53,7 @@ public: unsigned int getMessageCount() const; unsigned int getUnseenCount() const; - ref clone() const; + shared_ptr clone() const; void setMessageCount(const unsigned int count); diff --git a/vmime/net/maildir/maildirFormat.hpp b/vmime/net/maildir/maildirFormat.hpp index e2afea6d..c0daf288 100644 --- a/vmime/net/maildir/maildirFormat.hpp +++ b/vmime/net/maildir/maildirFormat.hpp @@ -55,13 +55,13 @@ public: { public: - context(ref store); + context(shared_ptr store); - ref getStore() const; + shared_ptr getStore() const; private: - weak_ref m_store; + weak_ptr m_store; }; @@ -146,7 +146,7 @@ public: * @param store of which to detect format * @return a Maildir format implementation for the specified store */ - static ref detect(ref store); + static shared_ptr detect(shared_ptr store); protected: @@ -155,20 +155,20 @@ protected: static const utility::file::path::component NEW_DIR; /**< Unread messages. */ - maildirFormat(ref ctx); + maildirFormat(shared_ptr ctx); /** Returns the current context. * * @return current context */ - ref getContext(); + shared_ptr getContext(); /** Returns the current context (const version). * * @return current context */ - ref getContext() const; + shared_ptr getContext() const; /** Quick checks whether this implementation can read the Maildir * format in the specified directory. @@ -180,7 +180,7 @@ protected: private: - ref m_context; + shared_ptr m_context; }; diff --git a/vmime/net/maildir/maildirMessage.hpp b/vmime/net/maildir/maildirMessage.hpp index 527461ff..6218c812 100644 --- a/vmime/net/maildir/maildirMessage.hpp +++ b/vmime/net/maildir/maildirMessage.hpp @@ -49,16 +49,15 @@ class maildirFolder; class VMIME_EXPORT maildirMessage : public message { friend class maildirFolder; - friend class vmime::creator; // vmime::create -private: - - maildirMessage(ref folder, const int num); maildirMessage(const maildirMessage&) : message() { } +public: + + maildirMessage(shared_ptr folder, const int num); + ~maildirMessage(); -public: int getNumber() const; @@ -68,33 +67,33 @@ public: bool isExpunged() const; - ref getStructure() const; - ref getStructure(); + shared_ptr getStructure() const; + shared_ptr getStructure(); - ref getHeader() const; + shared_ptr getHeader() const; int getFlags() const; void setFlags(const int flags, const int mode = FLAG_MODE_SET); void extract(utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const; - void extractPart(ref p, utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const; + void extractPart(shared_ptr p, utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const; - void fetchPartHeader(ref p); + void fetchPartHeader(shared_ptr p); - ref getParsedMessage(); + shared_ptr getParsedMessage(); private: - void fetch(ref folder, const fetchAttributes& options); + void fetch(shared_ptr folder, const fetchAttributes& options); void onFolderClosed(); - ref
getOrCreateHeader(); + shared_ptr
getOrCreateHeader(); void extractImpl(utility::outputStream& os, utility::progressListener* progress, const int start, const int length, const int partialStart, const int partialLength, const bool peek) const; - weak_ref m_folder; + weak_ptr m_folder; int m_num; int m_size; @@ -102,8 +101,8 @@ private: bool m_expunged; uid m_uid; - ref
m_header; - ref m_structure; + shared_ptr
m_header; + shared_ptr m_structure; }; diff --git a/vmime/net/maildir/maildirMessagePart.hpp b/vmime/net/maildir/maildirMessagePart.hpp index f79804ca..00c931ec 100644 --- a/vmime/net/maildir/maildirMessagePart.hpp +++ b/vmime/net/maildir/maildirMessagePart.hpp @@ -46,20 +46,20 @@ class maildirMessagePart : public messagePart { public: - maildirMessagePart(ref parent, const int number, const bodyPart& part); + maildirMessagePart(shared_ptr parent, const int number, const bodyPart& part); ~maildirMessagePart(); - ref getStructure() const; - ref getStructure(); + shared_ptr getStructure() const; + shared_ptr getStructure(); - weak_ref getParent() const { return (m_parent); } + weak_ptr getParent() const { return (m_parent); } const mediaType& getType() const; int getSize() const; int getNumber() const; - ref getHeader() const; + shared_ptr getHeader() const; header& getOrCreateHeader(); @@ -73,9 +73,9 @@ public: private: - ref m_structure; - weak_ref m_parent; - ref
m_header; + shared_ptr m_structure; + weak_ptr m_parent; + shared_ptr
m_header; int m_number; int m_size; diff --git a/vmime/net/maildir/maildirMessageStructure.hpp b/vmime/net/maildir/maildirMessageStructure.hpp index 6d62be2b..a43fc15c 100644 --- a/vmime/net/maildir/maildirMessageStructure.hpp +++ b/vmime/net/maildir/maildirMessageStructure.hpp @@ -47,22 +47,22 @@ class maildirMessageStructure : public messageStructure public: maildirMessageStructure(); - maildirMessageStructure(ref parent, const bodyPart& part); - maildirMessageStructure(ref parent, const std::vector >& list); + maildirMessageStructure(shared_ptr parent, const bodyPart& part); + maildirMessageStructure(shared_ptr parent, const std::vector >& list); - ref getPartAt(const size_t x) const; - ref getPartAt(const size_t x); + shared_ptr getPartAt(const size_t x) const; + shared_ptr getPartAt(const size_t x); size_t getPartCount() const; - static ref emptyStructure(); + static shared_ptr emptyStructure(); private: - static ref m_emptyStructure; + static shared_ptr m_emptyStructure; - std::vector > m_parts; + std::vector > m_parts; }; diff --git a/vmime/net/maildir/maildirStore.hpp b/vmime/net/maildir/maildirStore.hpp index b6ccd111..efadfdfe 100644 --- a/vmime/net/maildir/maildirStore.hpp +++ b/vmime/net/maildir/maildirStore.hpp @@ -60,14 +60,14 @@ class VMIME_EXPORT maildirStore : public store public: - maildirStore(ref sess, ref auth); + maildirStore(shared_ptr sess, shared_ptr auth); ~maildirStore(); const string getProtocolName() const; - ref getDefaultFolder(); - ref getRootFolder(); - ref getFolder(const folder::path& path); + shared_ptr getDefaultFolder(); + shared_ptr getRootFolder(); + shared_ptr getFolder(const folder::path& path); bool isValidFolderName(const folder::path::component& name) const; @@ -85,10 +85,10 @@ public: int getCapabilities() const; bool isSecuredConnection() const; - ref getConnectionInfos() const; + shared_ptr getConnectionInfos() const; - ref getFormat(); - ref getFormat() const; + shared_ptr getFormat(); + shared_ptr getFormat() const; private: @@ -98,7 +98,7 @@ private: std::list m_folders; - ref m_format; + shared_ptr m_format; bool m_connected; diff --git a/vmime/net/maildir/maildirUtils.hpp b/vmime/net/maildir/maildirUtils.hpp index 072a2648..82deefbb 100644 --- a/vmime/net/maildir/maildirUtils.hpp +++ b/vmime/net/maildir/maildirUtils.hpp @@ -130,7 +130,7 @@ public: * * @param dir directory to delete */ - static void recursiveFSDelete(ref dir); + static void recursiveFSDelete(shared_ptr dir); /** Returns a list of message numbers given a message set. * diff --git a/vmime/net/message.hpp b/vmime/net/message.hpp index 6bf4b492..4e291089 100644 --- a/vmime/net/message.hpp +++ b/vmime/net/message.hpp @@ -65,20 +65,20 @@ public: * * @return structure of the part */ - virtual ref getStructure() const = 0; + virtual shared_ptr getStructure() const = 0; /** Return the structure of this part. * * @return structure of the part */ - virtual ref getStructure() = 0; + virtual shared_ptr getStructure() = 0; /** Return the header section for this part (you must fetch header * before using this function: see message::fetchPartHeader). * * @return header section */ - virtual ref getHeader() const = 0; + virtual shared_ptr getHeader() const = 0; /** Return the media-type of the content in this part. * @@ -105,7 +105,7 @@ public: * @param pos index of the sub-part * @return sub-part at position 'pos' */ - ref getPartAt(const size_t pos) const; + shared_ptr getPartAt(const size_t pos) const; /** Return the sub-part at the specified position (zero is the * first part). @@ -113,7 +113,7 @@ public: * @param pos index of the sub-part * @return sub-part at position 'pos' */ - ref getPartAt(const size_t pos); + shared_ptr getPartAt(const size_t pos); /** Return the number of sub-parts in this part. * @@ -143,7 +143,7 @@ public: * @param pos position * @return part at position 'pos' */ - virtual ref getPartAt(const size_t pos) const = 0; + virtual shared_ptr getPartAt(const size_t pos) const = 0; /** Return the part at the specified position (first * part is at position 0). @@ -151,7 +151,7 @@ public: * @param pos position * @return part at position 'pos' */ - virtual ref getPartAt(const size_t pos) = 0; + virtual shared_ptr getPartAt(const size_t pos) = 0; /** Return the number of parts in this part. * @@ -206,19 +206,19 @@ public: * * @return MIME structure of the message */ - virtual ref getStructure() const = 0; + virtual shared_ptr getStructure() const = 0; /** Return the MIME structure of the message (must fetch before). * * @return MIME structure of the message */ - virtual ref getStructure() = 0; + virtual shared_ptr getStructure() = 0; /** Return a reference to the header fields of the message (must fetch before). * * @return header section of the message */ - virtual ref getHeader() const = 0; + virtual shared_ptr getHeader() const = 0; /** Return the sequence number of this message. This number is * used to reference the message in the folder. @@ -313,7 +313,7 @@ public: * an exception if not supported. */ virtual void extractPart - (ref p, + (shared_ptr p, utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, @@ -324,7 +324,7 @@ public: * * @param p the part for which to fetch the header */ - virtual void fetchPartHeader(ref p) = 0; + virtual void fetchPartHeader(shared_ptr p) = 0; /** Get the RFC-822 message for this abstract message. * Warning: This may require getting some data (ie: structure and headers) from @@ -334,7 +334,7 @@ public: * * @return a RFC-822-parsed message */ - virtual ref getParsedMessage() = 0; + virtual shared_ptr getParsedMessage() = 0; }; diff --git a/vmime/net/pop3/POP3Command.hpp b/vmime/net/pop3/POP3Command.hpp index ef2b3ac4..cc3c4fd5 100644 --- a/vmime/net/pop3/POP3Command.hpp +++ b/vmime/net/pop3/POP3Command.hpp @@ -52,40 +52,38 @@ class POP3Connection; */ class VMIME_EXPORT POP3Command : public object { - friend class vmime::creator; - public: - static ref CAPA(); - static ref NOOP(); - static ref AUTH(const string& mechName); - static ref STLS(); - static ref APOP(const string& username, const string& digest); - static ref USER(const string& username); - static ref PASS(const string& password); - static ref STAT(); - static ref LIST(); - static ref LIST(const unsigned long msg); - static ref UIDL(); - static ref UIDL(const unsigned long msg); - static ref DELE(const unsigned long msg); - static ref RETR(const unsigned long msg); - static ref TOP(const unsigned long msg, const unsigned long lines); - static ref RSET(); - static ref QUIT(); + static shared_ptr CAPA(); + static shared_ptr NOOP(); + static shared_ptr AUTH(const string& mechName); + static shared_ptr STLS(); + static shared_ptr APOP(const string& username, const string& digest); + static shared_ptr USER(const string& username); + static shared_ptr PASS(const string& password); + static shared_ptr STAT(); + static shared_ptr LIST(); + static shared_ptr LIST(const unsigned long msg); + static shared_ptr UIDL(); + static shared_ptr UIDL(const unsigned long msg); + static shared_ptr DELE(const unsigned long msg); + static shared_ptr RETR(const unsigned long msg); + static shared_ptr TOP(const unsigned long msg, const unsigned long lines); + static shared_ptr RSET(); + static shared_ptr QUIT(); /** Creates a new POP3 command with the specified text. * * @param text command text * @return a new POP3Command object */ - static ref createCommand(const string& text); + static shared_ptr createCommand(const string& text); /** Sends this command over the specified connection. * * @param conn connection onto which the command will be sent */ - virtual void send(ref conn); + virtual void send(shared_ptr conn); /** Returns the full text of the command, including command name * and parameters (if any). diff --git a/vmime/net/pop3/POP3Connection.hpp b/vmime/net/pop3/POP3Connection.hpp index 96916bab..3622f745 100644 --- a/vmime/net/pop3/POP3Connection.hpp +++ b/vmime/net/pop3/POP3Connection.hpp @@ -62,11 +62,9 @@ class POP3Store; */ class VMIME_EXPORT POP3Connection : public object { - friend class vmime::creator; - public: - POP3Connection(ref store, ref auth); + POP3Connection(shared_ptr store, shared_ptr auth); virtual ~POP3Connection(); @@ -75,13 +73,13 @@ public: virtual void disconnect(); bool isSecuredConnection() const; - ref getConnectionInfos() const; + shared_ptr getConnectionInfos() const; - virtual ref getStore(); - virtual ref getSocket(); - virtual ref getTimeoutHandler(); - virtual ref getAuthenticator(); - virtual ref getSession(); + virtual shared_ptr getStore(); + virtual shared_ptr getSocket(); + virtual shared_ptr getTimeoutHandler(); + virtual shared_ptr getAuthenticator(); + virtual shared_ptr getSession(); private: @@ -101,16 +99,16 @@ private: void internalDisconnect(); - weak_ref m_store; + weak_ptr m_store; - ref m_auth; - ref m_socket; - ref m_timeoutHandler; + shared_ptr m_auth; + shared_ptr m_socket; + shared_ptr m_timeoutHandler; bool m_authenticated; bool m_secured; - ref m_cntInfos; + shared_ptr m_cntInfos; std::vector m_capabilities; bool m_capabilitiesFetched; diff --git a/vmime/net/pop3/POP3Folder.hpp b/vmime/net/pop3/POP3Folder.hpp index 5dbb8d1d..93a2bf35 100644 --- a/vmime/net/pop3/POP3Folder.hpp +++ b/vmime/net/pop3/POP3Folder.hpp @@ -57,15 +57,15 @@ private: friend class POP3Store; friend class POP3Message; - friend class vmime::creator; // vmime::create - POP3Folder(const folder::path& path, ref store); - POP3Folder(const POP3Folder&) : folder() { } - - ~POP3Folder(); + POP3Folder(const POP3Folder&); public: + POP3Folder(const folder::path& path, shared_ptr store); + + ~POP3Folder(); + int getMode() const; int getType(); @@ -85,13 +85,13 @@ public: bool isOpen() const; - ref getMessage(const int num); - std::vector > getMessages(const messageSet& msgs); + shared_ptr getMessage(const int num); + std::vector > getMessages(const messageSet& msgs); int getMessageCount(); - ref getFolder(const folder::path::component& name); - std::vector > getFolders(const bool recursive = false); + shared_ptr getFolder(const folder::path::component& name); + std::vector > getFolders(const bool recursive = false); void rename(const folder::path& newPath); @@ -99,24 +99,24 @@ public: void setMessageFlags(const messageSet& msgs, const int flags, const int mode = message::FLAG_MODE_SET); - void addMessage(ref msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL); + void addMessage(shared_ptr msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL); void addMessage(utility::inputStream& is, const int size, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL); void copyMessages(const folder::path& dest, const messageSet& msgs); void status(int& count, int& unseen); - ref getStatus(); + shared_ptr getStatus(); void expunge(); - ref getParent(); + shared_ptr getParent(); - ref getStore() const; - ref getStore(); + shared_ptr getStore() const; + shared_ptr getStore(); - void fetchMessages(std::vector >& msg, const fetchAttributes& options, utility::progressListener* progress = NULL); - void fetchMessage(ref msg, const fetchAttributes& options); + void fetchMessages(std::vector >& msg, const fetchAttributes& options, utility::progressListener* progress = NULL); + void fetchMessage(shared_ptr msg, const fetchAttributes& options); int getFetchCapabilities() const; @@ -132,7 +132,7 @@ private: void onClose(); - weak_ref m_store; + weak_ptr m_store; folder::path m_path; folder::path::component m_name; diff --git a/vmime/net/pop3/POP3FolderStatus.hpp b/vmime/net/pop3/POP3FolderStatus.hpp index d074ff47..70ba48b6 100644 --- a/vmime/net/pop3/POP3FolderStatus.hpp +++ b/vmime/net/pop3/POP3FolderStatus.hpp @@ -53,7 +53,7 @@ public: unsigned int getMessageCount() const; unsigned int getUnseenCount() const; - ref clone() const; + shared_ptr clone() const; void setMessageCount(const unsigned int count); diff --git a/vmime/net/pop3/POP3Message.hpp b/vmime/net/pop3/POP3Message.hpp index 573fe808..6cb3c719 100644 --- a/vmime/net/pop3/POP3Message.hpp +++ b/vmime/net/pop3/POP3Message.hpp @@ -51,14 +51,15 @@ class VMIME_EXPORT POP3Message : public message private: friend class POP3Folder; - friend class vmime::creator; // vmime::create - POP3Message(ref folder, const int num); - POP3Message(const POP3Message&) : message() { } + POP3Message(const POP3Message&); + +public: + + POP3Message(shared_ptr folder, const int num); ~POP3Message(); -public: int getNumber() const; @@ -68,35 +69,35 @@ public: bool isExpunged() const; - ref getStructure() const; - ref getStructure(); + shared_ptr getStructure() const; + shared_ptr getStructure(); - ref getHeader() const; + shared_ptr getHeader() const; int getFlags() const; void setFlags(const int flags, const int mode = FLAG_MODE_SET); void extract(utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const; - void extractPart(ref p, utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const; + void extractPart(shared_ptr p, utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const; - void fetchPartHeader(ref p); + void fetchPartHeader(shared_ptr p); - ref getParsedMessage(); + shared_ptr getParsedMessage(); private: - void fetch(ref folder, const fetchAttributes& options); + void fetch(shared_ptr folder, const fetchAttributes& options); void onFolderClosed(); - weak_ref m_folder; + weak_ptr m_folder; int m_num; uid m_uid; int m_size; bool m_deleted; - ref
m_header; + shared_ptr
m_header; }; diff --git a/vmime/net/pop3/POP3Response.hpp b/vmime/net/pop3/POP3Response.hpp index efe72d05..4b69290f 100644 --- a/vmime/net/pop3/POP3Response.hpp +++ b/vmime/net/pop3/POP3Response.hpp @@ -57,8 +57,6 @@ class POP3Connection; */ class VMIME_EXPORT POP3Response : public object { - friend class vmime::creator; - public: /** Possible response codes. */ @@ -78,7 +76,7 @@ public: * @throws exceptions::operation_timed_out if no data * has been received within the granted time */ - static ref readResponse(ref conn); + static shared_ptr readResponse(shared_ptr conn); /** Receive and parse a multiline POP3 response from * the specified connection. @@ -88,7 +86,7 @@ public: * @throws exceptions::operation_timed_out if no data * has been received within the granted time */ - static ref readMultilineResponse(ref conn); + static shared_ptr readMultilineResponse(shared_ptr conn); /** Receive and parse a large POP3 response (eg. message data) * from the specified connection. @@ -101,8 +99,8 @@ public: * @throws exceptions::operation_timed_out if no data * has been received within the granted time */ - static ref readLargeResponse - (ref conn, utility::outputStream& os, + static shared_ptr readLargeResponse + (shared_ptr conn, utility::outputStream& os, utility::progressListener* progress, const long predictedSize); @@ -145,7 +143,7 @@ public: private: - POP3Response(ref sok, ref toh); + POP3Response(shared_ptr sok, shared_ptr toh); void readResponseImpl(string& buffer, const bool multiLine); void readResponseImpl @@ -163,8 +161,8 @@ private: static bool checkOneTerminator(string& buffer, const string& term); - ref m_socket; - ref m_timeoutHandler; + shared_ptr m_socket; + shared_ptr m_timeoutHandler; string m_firstLine; ResponseCode m_code; diff --git a/vmime/net/pop3/POP3SStore.hpp b/vmime/net/pop3/POP3SStore.hpp index 3804d97c..e60b4ef8 100644 --- a/vmime/net/pop3/POP3SStore.hpp +++ b/vmime/net/pop3/POP3SStore.hpp @@ -46,7 +46,7 @@ class VMIME_EXPORT POP3SStore : public POP3Store { public: - POP3SStore(ref sess, ref auth); + POP3SStore(shared_ptr sess, shared_ptr auth); ~POP3SStore(); const string getProtocolName() const; diff --git a/vmime/net/pop3/POP3Store.hpp b/vmime/net/pop3/POP3Store.hpp index 17dfdbb0..b35659a0 100644 --- a/vmime/net/pop3/POP3Store.hpp +++ b/vmime/net/pop3/POP3Store.hpp @@ -59,14 +59,14 @@ class VMIME_EXPORT POP3Store : public store public: - POP3Store(ref sess, ref auth, const bool secured = false); + POP3Store(shared_ptr sess, shared_ptr auth, const bool secured = false); ~POP3Store(); const string getProtocolName() const; - ref getDefaultFolder(); - ref getRootFolder(); - ref getFolder(const folder::path& path); + shared_ptr getDefaultFolder(); + shared_ptr getRootFolder(); + shared_ptr getFolder(const folder::path& path); bool isValidFolderName(const folder::path::component& name) const; @@ -82,14 +82,14 @@ public: int getCapabilities() const; bool isSecuredConnection() const; - ref getConnectionInfos() const; - ref getConnection(); + shared_ptr getConnectionInfos() const; + shared_ptr getConnection(); bool isPOP3S() const; private: - ref m_connection; + shared_ptr m_connection; void registerFolder(POP3Folder* folder); diff --git a/vmime/net/pop3/POP3Utils.hpp b/vmime/net/pop3/POP3Utils.hpp index 9d20431c..c7459efe 100644 --- a/vmime/net/pop3/POP3Utils.hpp +++ b/vmime/net/pop3/POP3Utils.hpp @@ -64,7 +64,7 @@ public: * number to its corresponding data (either UID or size) */ static void parseMultiListOrUidlResponse - (ref response, std::map & result); + (shared_ptr response, std::map & result); /** Returns a list of message numbers given a message set. * diff --git a/vmime/net/sendmail/sendmailTransport.hpp b/vmime/net/sendmail/sendmailTransport.hpp index 3ac4fec2..7967ab87 100644 --- a/vmime/net/sendmail/sendmailTransport.hpp +++ b/vmime/net/sendmail/sendmailTransport.hpp @@ -50,7 +50,7 @@ class VMIME_EXPORT sendmailTransport : public transport { public: - sendmailTransport(ref sess, ref auth); + sendmailTransport(shared_ptr sess, shared_ptr auth); ~sendmailTransport(); const string getProtocolName() const; @@ -73,7 +73,7 @@ public: const mailbox& sender = mailbox()); bool isSecuredConnection() const; - ref getConnectionInfos() const; + shared_ptr getConnectionInfos() const; private: diff --git a/vmime/net/service.hpp b/vmime/net/service.hpp index 57b2c3a0..6969ac20 100644 --- a/vmime/net/service.hpp +++ b/vmime/net/service.hpp @@ -59,7 +59,7 @@ class VMIME_EXPORT service : public object { protected: - service(ref sess, const serviceInfos& infos, ref auth); + service(shared_ptr sess, const serviceInfos& infos, shared_ptr auth); public: @@ -88,13 +88,13 @@ public: * * @return session object */ - ref getSession() const; + shared_ptr getSession() const; /** Return the session object associated with this service instance. * * @return session object */ - ref getSession(); + shared_ptr getSession(); /** Return information about this service. * @@ -126,31 +126,31 @@ public: * * @return authenticator object */ - ref getAuthenticator() const; + shared_ptr getAuthenticator() const; /** Return the authenticator object used with this service instance. * * @return authenticator object */ - ref getAuthenticator(); + shared_ptr getAuthenticator(); /** Set the authenticator object used with this service instance. * * @param auth authenticator object */ - void setAuthenticator(ref auth); + void setAuthenticator(shared_ptr auth); #if VMIME_HAVE_TLS_SUPPORT /** Set the object responsible for verifying certificates when * using secured connections (TLS/SSL). */ - void setCertificateVerifier(ref cv); + void setCertificateVerifier(shared_ptr cv); /** Get the object responsible for verifying certificates when * using secured connections (TLS/SSL). */ - ref getCertificateVerifier(); + shared_ptr getCertificateVerifier(); #endif // VMIME_HAVE_TLS_SUPPORT @@ -159,14 +159,14 @@ public: * * @param sf socket factory */ - void setSocketFactory(ref sf); + void setSocketFactory(shared_ptr sf); /** Return the factory used to create socket objects for this * service. * * @return socket factory */ - ref getSocketFactory(); + shared_ptr getSocketFactory(); /** Set the factory used to create timeoutHandler objects for * this service. By default, no timeout handler is used. Not all @@ -174,14 +174,14 @@ public: * * @param thf timeoutHandler factory */ - void setTimeoutHandlerFactory(ref thf); + void setTimeoutHandlerFactory(shared_ptr thf); /** Return the factory used to create timeoutHandler objects for * this service. * * @return timeoutHandler factory */ - ref getTimeoutHandlerFactory(); + shared_ptr getTimeoutHandlerFactory(); /** Set a property for this service (service prefix is added automatically). * @@ -207,20 +207,20 @@ public: * * @return information about the connection */ - virtual ref getConnectionInfos() const = 0; + virtual shared_ptr getConnectionInfos() const = 0; private: - ref m_session; - ref m_auth; + shared_ptr m_session; + shared_ptr m_auth; #if VMIME_HAVE_TLS_SUPPORT - ref m_certVerifier; + shared_ptr m_certVerifier; #endif // VMIME_HAVE_TLS_SUPPORT - ref m_socketFactory; + shared_ptr m_socketFactory; - ref m_toHandlerFactory; + shared_ptr m_toHandlerFactory; }; diff --git a/vmime/net/serviceFactory.hpp b/vmime/net/serviceFactory.hpp index c2df141b..baf692a8 100644 --- a/vmime/net/serviceFactory.hpp +++ b/vmime/net/serviceFactory.hpp @@ -67,7 +67,7 @@ private: public: - static serviceFactory* getInstance(); + static shared_ptr getInstance(); /** Information about a registered service. */ class registeredService : public object @@ -80,9 +80,9 @@ public: public: - virtual ref create - (ref sess, - ref auth) const = 0; + virtual shared_ptr create + (shared_ptr sess, + shared_ptr auth) const = 0; virtual int getType() const = 0; virtual const string& getName() const = 0; @@ -94,7 +94,7 @@ public: * * @param reg service registration infos */ - void registerService(ref reg); + void registerService(shared_ptr reg); /** Create a new service instance from a protocol name. * @@ -105,10 +105,10 @@ public: * @throw exceptions::no_service_available if no service is registered * for this protocol */ - ref create - (ref sess, + shared_ptr create + (shared_ptr sess, const string& protocol, - ref auth = NULL); + shared_ptr auth = null); /** Create a new service instance from a URL. * @@ -120,10 +120,10 @@ public: * @throw exceptions::no_service_available if no service is registered * for this protocol */ - ref create - (ref sess, + shared_ptr create + (shared_ptr sess, const utility::url& u, - ref auth = NULL); + shared_ptr auth = null); /** Return information about a registered protocol. * @@ -132,7 +132,7 @@ public: * @throw exceptions::no_service_available if no service is registered * for this protocol */ - ref getServiceByProtocol(const string& protocol) const; + shared_ptr getServiceByProtocol(const string& protocol) const; /** Return the number of registered services. * @@ -145,17 +145,17 @@ public: * @param pos position of the registered service to return * @return registered service at the specified position */ - ref getServiceAt(const size_t pos) const; + shared_ptr getServiceAt(const size_t pos) const; /** Return a list of all registered services. * * @return list of registered services */ - const std::vector > getServiceList() const; + const std::vector > getServiceList() const; private: - std::vector > m_services; + std::vector > m_services; }; diff --git a/vmime/net/serviceInfos.hpp b/vmime/net/serviceInfos.hpp index efdc8456..6e3209ca 100644 --- a/vmime/net/serviceInfos.hpp +++ b/vmime/net/serviceInfos.hpp @@ -217,7 +217,7 @@ public: * @return value of the property */ template - const TYPE getPropertyValue(ref s, const property& p) const + const TYPE getPropertyValue(shared_ptr s, const property& p) const { if (p.getFlags() & property::FLAG_REQUIRED) return s->getProperties()[getPropertyPrefix() + p.getName()].template getValue (); @@ -233,7 +233,7 @@ public: * @param p property to test * @return true if the property is set, false otherwise */ - bool hasProperty(ref s, const property& p) const; + bool hasProperty(shared_ptr s, const property& p) const; }; diff --git a/vmime/net/session.hpp b/vmime/net/session.hpp index b92c2ac7..59337879 100644 --- a/vmime/net/session.hpp +++ b/vmime/net/session.hpp @@ -72,8 +72,8 @@ public: * credentials by reading the session properties "auth.username" and "auth.password". * @return a new transport service */ - ref getTransport - (ref auth = NULL); + shared_ptr getTransport + (shared_ptr auth = null); /** Return a transport service instance for the specified protocol. * @@ -83,9 +83,9 @@ public: * credentials by reading the session properties "auth.username" and "auth.password". * @return a new transport service */ - ref getTransport + shared_ptr getTransport (const string& protocol, - ref auth = NULL); + shared_ptr auth = null); /** Return a transport service instance for the specified URL. * @@ -95,9 +95,9 @@ public: * credentials by reading the session properties "auth.username" and "auth.password". * @return a new transport service */ - ref getTransport + shared_ptr getTransport (const utility::url& url, - ref auth = NULL); + shared_ptr auth = null); /** Return a transport service instance for the protocol specified * in the session properties. @@ -109,7 +109,7 @@ public: * credentials by reading the session properties "auth.username" and "auth.password". * @return a new store service */ - ref getStore(ref auth = NULL); + shared_ptr getStore(shared_ptr auth = null); /** Return a store service instance for the specified protocol. * @@ -119,9 +119,9 @@ public: * credentials by reading the session properties "auth.username" and "auth.password". * @return a new store service */ - ref getStore + shared_ptr getStore (const string& protocol, - ref auth = NULL); + shared_ptr auth = null); /** Return a store service instance for the specified URL. * @@ -131,9 +131,9 @@ public: * credentials by reading the session properties "auth.username" and "auth.password". * @return a new store service */ - ref getStore + shared_ptr getStore (const utility::url& url, - ref auth = NULL); + shared_ptr auth = null); /** Properties for the session and for the services. */ @@ -147,19 +147,19 @@ public: * * @param tlsProps SSL/TLS properties */ - void setTLSProperties(ref tlsProps); + void setTLSProperties(shared_ptr tlsProps); /** Get properties for SSL/TLS secured connections in this session. * * @return SSL/TLS properties */ - ref getTLSProperties() const; + shared_ptr getTLSProperties() const; private: propertySet m_props; - ref m_tlsProps; + shared_ptr m_tlsProps; }; diff --git a/vmime/net/smtp/SMTPChunkingOutputStreamAdapter.hpp b/vmime/net/smtp/SMTPChunkingOutputStreamAdapter.hpp index a29fbfb4..6ca6c527 100644 --- a/vmime/net/smtp/SMTPChunkingOutputStreamAdapter.hpp +++ b/vmime/net/smtp/SMTPChunkingOutputStreamAdapter.hpp @@ -46,11 +46,9 @@ class SMTPConnection; */ class VMIME_EXPORT SMTPChunkingOutputStreamAdapter : public utility::outputStream { - friend class vmime::creator; - public: - SMTPChunkingOutputStreamAdapter(ref conn); + SMTPChunkingOutputStreamAdapter(shared_ptr conn); void write(const value_type* const data, const size_type count); void flush(); @@ -65,7 +63,7 @@ private: void sendChunk(const value_type* const data, const size_type count, const bool last); - ref m_connection; + shared_ptr m_connection; value_type m_buffer[262144]; // 256 KB size_type m_bufferSize; diff --git a/vmime/net/smtp/SMTPCommand.hpp b/vmime/net/smtp/SMTPCommand.hpp index c4001f85..4005dcdf 100644 --- a/vmime/net/smtp/SMTPCommand.hpp +++ b/vmime/net/smtp/SMTPCommand.hpp @@ -55,35 +55,33 @@ namespace smtp { */ class VMIME_EXPORT SMTPCommand : public object { - friend class vmime::creator; - public: - static ref HELO(const string& hostname); - static ref EHLO(const string& hostname); - static ref AUTH(const string& mechName); - static ref STARTTLS(); - static ref MAIL(const mailbox& mbox, const bool utf8); - static ref MAIL(const mailbox& mbox, const bool utf8, const unsigned long size); - static ref RCPT(const mailbox& mbox, const bool utf8); - static ref RSET(); - static ref DATA(); - static ref BDAT(const unsigned long chunkSize, const bool last); - static ref NOOP(); - static ref QUIT(); + static shared_ptr HELO(const string& hostname); + static shared_ptr EHLO(const string& hostname); + static shared_ptr AUTH(const string& mechName); + static shared_ptr STARTTLS(); + static shared_ptr MAIL(const mailbox& mbox, const bool utf8); + static shared_ptr MAIL(const mailbox& mbox, const bool utf8, const unsigned long size); + static shared_ptr RCPT(const mailbox& mbox, const bool utf8); + static shared_ptr RSET(); + static shared_ptr DATA(); + static shared_ptr BDAT(const unsigned long chunkSize, const bool last); + static shared_ptr NOOP(); + static shared_ptr QUIT(); /** Creates a new SMTP command with the specified text. * * @param text command text * @return a new SMTPCommand object */ - static ref createCommand(const string& text); + static shared_ptr createCommand(const string& text); /** Sends this command to the specified socket. * * @param sok socket to which the command will be written */ - virtual void writeToSocket(ref sok); + virtual void writeToSocket(shared_ptr sok); /** Returns the full text of the command, including command name * and parameters (if any). diff --git a/vmime/net/smtp/SMTPCommandSet.hpp b/vmime/net/smtp/SMTPCommandSet.hpp index e6c5be94..8e744c2b 100644 --- a/vmime/net/smtp/SMTPCommandSet.hpp +++ b/vmime/net/smtp/SMTPCommandSet.hpp @@ -46,8 +46,6 @@ namespace smtp { */ class VMIME_EXPORT SMTPCommandSet : public SMTPCommand { - friend class vmime::creator; - public: /** Creates a new set of SMTP commands. @@ -55,7 +53,7 @@ public: * @param pipeline set to true if the server supports pipelining * @return a new SMTPCommandSet object */ - static ref create(const bool pipeline); + static shared_ptr create(const bool pipeline); /** Adds a new command to this set. * If one or more comments have already been sent to the server, @@ -63,7 +61,7 @@ public: * * @param cmd command to add */ - void addCommand(ref cmd); + void addCommand(shared_ptr cmd); /** Tests whether all commands have been sent. * @@ -77,10 +75,10 @@ public: * @return a pointer to a SMTPCommand, of NULL if no command * has been sent yet */ - ref getLastCommandSent() const; + shared_ptr getLastCommandSent() const; - void writeToSocket(ref sok); + void writeToSocket(shared_ptr sok); const string getText() const; @@ -92,8 +90,8 @@ private: bool m_pipeline; bool m_started; - std::list > m_commands; - ref m_lastCommandSent; + std::list > m_commands; + shared_ptr m_lastCommandSent; }; diff --git a/vmime/net/smtp/SMTPConnection.hpp b/vmime/net/smtp/SMTPConnection.hpp index 96469ab1..cc59ef34 100644 --- a/vmime/net/smtp/SMTPConnection.hpp +++ b/vmime/net/smtp/SMTPConnection.hpp @@ -62,11 +62,9 @@ class SMTPTransport; */ class VMIME_EXPORT SMTPConnection : public object { - friend class vmime::creator; - public: - SMTPConnection(ref transport, ref auth); + SMTPConnection(shared_ptr transport, shared_ptr auth); virtual ~SMTPConnection(); @@ -75,16 +73,16 @@ public: virtual void disconnect(); bool isSecuredConnection() const; - ref getConnectionInfos() const; + shared_ptr getConnectionInfos() const; - virtual ref getTransport(); - virtual ref getSocket(); - virtual ref getTimeoutHandler(); - virtual ref getAuthenticator(); - virtual ref getSession(); + virtual shared_ptr getTransport(); + virtual shared_ptr getSocket(); + virtual shared_ptr getTimeoutHandler(); + virtual shared_ptr getAuthenticator(); + virtual shared_ptr getSession(); - void sendRequest(ref cmd); - ref readResponse(); + void sendRequest(shared_ptr cmd); + shared_ptr readResponse(); bool hasExtension(const std::string& extName, std::vector * params = NULL) const; @@ -103,18 +101,18 @@ private: #endif // VMIME_HAVE_TLS_SUPPORT - weak_ref m_transport; + weak_ptr m_transport; - ref m_auth; - ref m_socket; - ref m_timeoutHandler; + shared_ptr m_auth; + shared_ptr m_socket; + shared_ptr m_timeoutHandler; SMTPResponse::state m_responseState; bool m_authenticated; bool m_secured; - ref m_cntInfos; + shared_ptr m_cntInfos; bool m_extendedSMTP; std::map > m_extensions; diff --git a/vmime/net/smtp/SMTPResponse.hpp b/vmime/net/smtp/SMTPResponse.hpp index e0a5e1cd..000448ac 100644 --- a/vmime/net/smtp/SMTPResponse.hpp +++ b/vmime/net/smtp/SMTPResponse.hpp @@ -50,8 +50,6 @@ namespace smtp { */ class VMIME_EXPORT SMTPResponse : public object { - friend class vmime::creator; - public: /** Current state of response parser. */ @@ -104,7 +102,7 @@ public: * @throws exceptions::operation_timed_out if no data * has been received within the granted time */ - static ref readResponse(ref sok, ref toh, const state& st); + static shared_ptr readResponse(shared_ptr sok, shared_ptr toh, const state& st); /** Return the SMTP response code. * @@ -152,7 +150,7 @@ public: private: - SMTPResponse(ref sok, ref toh, const state& st); + SMTPResponse(shared_ptr sok, shared_ptr toh, const state& st); SMTPResponse(const SMTPResponse&); void readResponse(); @@ -166,8 +164,8 @@ private: std::vector m_lines; - ref m_socket; - ref m_timeoutHandler; + shared_ptr m_socket; + shared_ptr m_timeoutHandler; string m_responseBuffer; bool m_responseContinues; diff --git a/vmime/net/smtp/SMTPSTransport.hpp b/vmime/net/smtp/SMTPSTransport.hpp index cbc6a168..7782f711 100644 --- a/vmime/net/smtp/SMTPSTransport.hpp +++ b/vmime/net/smtp/SMTPSTransport.hpp @@ -46,7 +46,7 @@ class VMIME_EXPORT SMTPSTransport : public SMTPTransport { public: - SMTPSTransport(ref sess, ref auth); + SMTPSTransport(shared_ptr sess, shared_ptr auth); ~SMTPSTransport(); const string getProtocolName() const; diff --git a/vmime/net/smtp/SMTPTransport.hpp b/vmime/net/smtp/SMTPTransport.hpp index 962f4406..90ad447c 100644 --- a/vmime/net/smtp/SMTPTransport.hpp +++ b/vmime/net/smtp/SMTPTransport.hpp @@ -54,7 +54,7 @@ class VMIME_EXPORT SMTPTransport : public transport { public: - SMTPTransport(ref sess, ref auth, const bool secured = false); + SMTPTransport(shared_ptr sess, shared_ptr auth, const bool secured = false); ~SMTPTransport(); const string getProtocolName() const; @@ -77,15 +77,15 @@ public: const mailbox& sender = mailbox()); void send - (ref msg, + (shared_ptr msg, const mailbox& expeditor, const mailboxList& recipients, utility::progressListener* progress = NULL, const mailbox& sender = mailbox()); bool isSecuredConnection() const; - ref getConnectionInfos() const; - ref getConnection(); + shared_ptr getConnectionInfos() const; + shared_ptr getConnection(); bool isSMTPS() const; @@ -109,7 +109,7 @@ private: const utility::stream::size_type size); - ref m_connection; + shared_ptr m_connection; const bool m_isSMTPS; diff --git a/vmime/net/socket.hpp b/vmime/net/socket.hpp index 5662da23..3dadc72b 100644 --- a/vmime/net/socket.hpp +++ b/vmime/net/socket.hpp @@ -162,14 +162,14 @@ public: * * @return a new socket */ - virtual ref create() = 0; + virtual shared_ptr create() = 0; /** Creates a socket with the specified timeout handler. * * @param th timeout handler * @return a new socket */ - virtual ref create(ref th) = 0; + virtual shared_ptr create(shared_ptr th) = 0; }; diff --git a/vmime/net/store.hpp b/vmime/net/store.hpp index 92a43feb..37dcadbc 100644 --- a/vmime/net/store.hpp +++ b/vmime/net/store.hpp @@ -47,7 +47,7 @@ class VMIME_EXPORT store : public service { protected: - store(ref sess, const serviceInfos& infos, ref auth) + store(shared_ptr sess, const serviceInfos& infos, shared_ptr auth) : service(sess, infos, auth) { } public: @@ -57,21 +57,21 @@ public: * * @return default folder */ - virtual ref getDefaultFolder() = 0; + virtual shared_ptr getDefaultFolder() = 0; /** Return the root folder. This is protocol dependent * and usually is the user's mail drop root folder. * * @return root folder */ - virtual ref getRootFolder() = 0; + virtual shared_ptr getRootFolder() = 0; /** Return the folder specified by the path. * * @param path absolute folder path * @return folder at the specified path */ - virtual ref getFolder(const folder::path& path) = 0; + virtual shared_ptr getFolder(const folder::path& path) = 0; /** Test whether the specified folder name is a syntactically * a valid name. diff --git a/vmime/net/timeoutHandler.hpp b/vmime/net/timeoutHandler.hpp index f49ece0c..24129701 100644 --- a/vmime/net/timeoutHandler.hpp +++ b/vmime/net/timeoutHandler.hpp @@ -76,7 +76,7 @@ public: virtual ~timeoutHandlerFactory() { } - virtual ref create() = 0; + virtual shared_ptr create() = 0; }; diff --git a/vmime/net/tls/TLSProperties.hpp b/vmime/net/tls/TLSProperties.hpp index 23540eeb..0dbc8f05 100644 --- a/vmime/net/tls/TLSProperties.hpp +++ b/vmime/net/tls/TLSProperties.hpp @@ -91,7 +91,7 @@ public: private: - ref m_data; + shared_ptr m_data; }; diff --git a/vmime/net/tls/TLSSecuredConnectionInfos.hpp b/vmime/net/tls/TLSSecuredConnectionInfos.hpp index be0fb41a..e552d6f9 100644 --- a/vmime/net/tls/TLSSecuredConnectionInfos.hpp +++ b/vmime/net/tls/TLSSecuredConnectionInfos.hpp @@ -52,7 +52,7 @@ class VMIME_EXPORT TLSSecuredConnectionInfos : public securedConnectionInfos public: TLSSecuredConnectionInfos(const string& host, const port_t port, - ref tlsSession, ref tlsSocket); + shared_ptr tlsSession, shared_ptr tlsSocket); const string getHost() const; port_t getPort() const; @@ -61,15 +61,15 @@ public: * * @return server certificate chain */ - ref getPeerCertificates() const; + shared_ptr getPeerCertificates() const; private: string m_host; port_t m_port; - ref m_tlsSession; - ref m_tlsSocket; + shared_ptr m_tlsSession; + shared_ptr m_tlsSocket; }; diff --git a/vmime/net/tls/TLSSession.hpp b/vmime/net/tls/TLSSession.hpp index faca9d11..9e061f89 100644 --- a/vmime/net/tls/TLSSession.hpp +++ b/vmime/net/tls/TLSSession.hpp @@ -57,7 +57,7 @@ public: * @param props TLS properties for this session * @return a new TLS session */ - static ref create(ref cv, ref props); + static shared_ptr create(shared_ptr cv, shared_ptr props); /** Create a new socket that adds a TLS security layer around * an existing socket. You should create only one socket @@ -66,12 +66,12 @@ public: * @param sok socket to wrap * @return TLS socket wrapper */ - virtual ref getSocket(ref sok) = 0; + virtual shared_ptr getSocket(shared_ptr sok) = 0; /** Get the object responsible for verifying certificates when * using secured connections (TLS/SSL). */ - virtual ref getCertificateVerifier() = 0; + virtual shared_ptr getCertificateVerifier() = 0; protected: diff --git a/vmime/net/tls/TLSSocket.hpp b/vmime/net/tls/TLSSocket.hpp index 68ed1963..e2668ad4 100644 --- a/vmime/net/tls/TLSSocket.hpp +++ b/vmime/net/tls/TLSSocket.hpp @@ -59,7 +59,7 @@ public: * @param session TLS session * @param sok socket to wrap */ - static ref wrap(ref session, ref sok); + static shared_ptr wrap(shared_ptr session, shared_ptr sok); /** Starts a TLS handshake on this connection. * @@ -67,14 +67,14 @@ public: * during the negociation process, exceptions::operation_timed_out * if a time-out occurs */ - virtual void handshake(ref toHandler = NULL) = 0; + virtual void handshake(shared_ptr toHandler = null) = 0; /** Return the peer's certificate (chain) as sent by the peer. * * @return server certificate chain, or NULL if the handshake * has not been performed yet */ - virtual ref getPeerCertificates() const = 0; + virtual shared_ptr getPeerCertificates() const = 0; }; diff --git a/vmime/net/tls/gnutls/TLSSession_GnuTLS.hpp b/vmime/net/tls/gnutls/TLSSession_GnuTLS.hpp index 45fee070..7f762b58 100644 --- a/vmime/net/tls/gnutls/TLSSession_GnuTLS.hpp +++ b/vmime/net/tls/gnutls/TLSSession_GnuTLS.hpp @@ -52,13 +52,13 @@ class TLSSession_GnuTLS : public TLSSession public: - TLSSession_GnuTLS(ref cv, ref props); + TLSSession_GnuTLS(shared_ptr cv, shared_ptr props); ~TLSSession_GnuTLS(); - ref getSocket(ref sok); + shared_ptr getSocket(shared_ptr sok); - ref getCertificateVerifier(); + shared_ptr getCertificateVerifier(); private: @@ -73,8 +73,8 @@ private: void* m_gnutlsSession; #endif // LIBGNUTLS_VERSION - ref m_certVerifier; - ref m_props; + shared_ptr m_certVerifier; + shared_ptr m_props; }; diff --git a/vmime/net/tls/gnutls/TLSSocket_GnuTLS.hpp b/vmime/net/tls/gnutls/TLSSocket_GnuTLS.hpp index 4cce9832..43848ec9 100644 --- a/vmime/net/tls/gnutls/TLSSocket_GnuTLS.hpp +++ b/vmime/net/tls/gnutls/TLSSocket_GnuTLS.hpp @@ -48,17 +48,15 @@ class TLSSession_GnuTLS; class TLSSocket_GnuTLS : public TLSSocket { - friend class vmime::creator; - public: - TLSSocket_GnuTLS(ref session, ref sok); + TLSSocket_GnuTLS(shared_ptr session, shared_ptr sok); ~TLSSocket_GnuTLS(); - void handshake(ref toHandler = NULL); + void handshake(shared_ptr toHandler = null); - ref getPeerCertificates() const; + shared_ptr getPeerCertificates() const; // Implementation of 'socket' void connect(const string& address, const port_t port); @@ -92,15 +90,15 @@ private: #endif // LIBGNUTLS_VERSION - ref m_session; - ref m_wrapped; + shared_ptr m_session; + shared_ptr m_wrapped; bool m_connected; char m_buffer[65536]; bool m_handshaking; - ref m_toHandler; + shared_ptr m_toHandler; exception* m_ex; diff --git a/vmime/net/tls/openssl/OpenSSLInitializer.hpp b/vmime/net/tls/openssl/OpenSSLInitializer.hpp index 5277d4ff..d7595aa8 100644 --- a/vmime/net/tls/openssl/OpenSSLInitializer.hpp +++ b/vmime/net/tls/openssl/OpenSSLInitializer.hpp @@ -80,7 +80,7 @@ protected: static void uninitialize(); - static ref getMutex(); + static shared_ptr getMutex(); enum { @@ -94,7 +94,7 @@ protected: private: - static ref * sm_mutexes; + static shared_ptr * sm_mutexes; }; diff --git a/vmime/net/tls/openssl/TLSSession_OpenSSL.hpp b/vmime/net/tls/openssl/TLSSession_OpenSSL.hpp index 85f018f1..5a2b60a8 100644 --- a/vmime/net/tls/openssl/TLSSession_OpenSSL.hpp +++ b/vmime/net/tls/openssl/TLSSession_OpenSSL.hpp @@ -55,13 +55,13 @@ class TLSSession_OpenSSL : public TLSSession public: - TLSSession_OpenSSL(const ref cv, ref props); + TLSSession_OpenSSL(const shared_ptr cv, shared_ptr props); ~TLSSession_OpenSSL(); - ref getSocket(ref sok); + shared_ptr getSocket(shared_ptr sok); - ref getCertificateVerifier(); + shared_ptr getCertificateVerifier(); /** Set the private key to use if server requires a client certificate. @@ -90,8 +90,8 @@ private: SSL_CTX* m_sslctx; - ref m_certVerifier; - ref m_props; + shared_ptr m_certVerifier; + shared_ptr m_props; }; diff --git a/vmime/net/tls/openssl/TLSSocket_OpenSSL.hpp b/vmime/net/tls/openssl/TLSSocket_OpenSSL.hpp index 5bf27804..b4ff5872 100644 --- a/vmime/net/tls/openssl/TLSSocket_OpenSSL.hpp +++ b/vmime/net/tls/openssl/TLSSocket_OpenSSL.hpp @@ -52,17 +52,15 @@ class TLSSession_OpenSSL; class TLSSocket_OpenSSL : public TLSSocket { - friend class vmime::creator; - public: - TLSSocket_OpenSSL(ref session, ref sok); + TLSSocket_OpenSSL(shared_ptr session, shared_ptr sok); ~TLSSocket_OpenSSL(); - void handshake(ref toHandler = NULL); + void handshake(shared_ptr toHandler = null); - ref getPeerCertificates() const; + shared_ptr getPeerCertificates() const; // Implementation of 'socket' void connect(const string& address, const port_t port); @@ -101,15 +99,15 @@ private: void handleError(int rc); - ref m_session; + shared_ptr m_session; - ref m_wrapped; + shared_ptr m_wrapped; bool m_connected; char m_buffer[65536]; - ref m_toHandler; + shared_ptr m_toHandler; SSL* m_ssl; diff --git a/vmime/net/transport.hpp b/vmime/net/transport.hpp index 3acb2266..96e37669 100644 --- a/vmime/net/transport.hpp +++ b/vmime/net/transport.hpp @@ -56,7 +56,7 @@ class VMIME_EXPORT transport : public service { protected: - transport(ref sess, const serviceInfos& infos, ref auth); + transport(shared_ptr sess, const serviceInfos& infos, shared_ptr auth); public: @@ -67,7 +67,7 @@ public: * @param msg message to send * @param progress progress listener, or NULL if not used */ - virtual void send(ref msg, utility::progressListener* progress = NULL); + virtual void send(shared_ptr msg, utility::progressListener* progress = NULL); /** Send a message over this transport service. * @@ -97,7 +97,7 @@ public: * @param sender envelope sender (if empty, expeditor will be used) */ virtual void send - (ref msg, + (shared_ptr msg, const mailbox& expeditor, const mailboxList& recipients, utility::progressListener* progress = NULL, @@ -115,7 +115,7 @@ protected: * if the field is to be replaced, or a reference to the same headerField * that was passed if the field should be left as is */ - ref processHeaderField(ref field); + shared_ptr processHeaderField(shared_ptr field); /** Prepares the header before transmitting the message. * Removes headers that should not be present (eg. "Bcc", "Return-Path"), @@ -124,7 +124,7 @@ protected: * * @param header headers to process */ - void processHeader(ref
header); + void processHeader(shared_ptr
header); }; diff --git a/vmime/object.hpp b/vmime/object.hpp index 192ab050..0b12df3c 100644 --- a/vmime/object.hpp +++ b/vmime/object.hpp @@ -28,24 +28,15 @@ #include "vmime/types.hpp" -#include - - namespace vmime { -/** Base object for all objects in the library. This implements - * reference counting and auto-deletion. +/** Base object for all objects in the library. */ -class VMIME_EXPORT object +class VMIME_EXPORT object : public enable_shared_from_this { - template friend class utility::ref; - template friend class utility::weak_ref; - - friend class utility::refManager; - protected: object(); @@ -54,42 +45,6 @@ protected: object& operator=(const object&); virtual ~object(); - -#ifndef VMIME_BUILDING_DOC - - /** Return a reference to this object. - * - * @return reference to self - */ - ref thisRef(); - - /** Return a reference to this object (const version). - * - * @return reference to self - */ - ref thisRef() const; - - /** Return a weak reference to this object. - * - * @return weak reference to self - */ - weak_ref thisWeakRef(); - - /** Return a weak reference to this object (const version). - * - * @return weak reference to self - */ - weak_ref thisWeakRef() const; - - - void setRefManager(utility::refManager* mgr); - utility::refManager* getRefManager() const; - -#endif // VMIME_BUILDING_DOC - -private: - - mutable utility::refManager* m_refMgr; }; diff --git a/vmime/parameter.hpp b/vmime/parameter.hpp index a3d0f0f8..d872b312 100644 --- a/vmime/parameter.hpp +++ b/vmime/parameter.hpp @@ -63,11 +63,11 @@ public: #endif // VMIME_BUILDING_DOC - ref clone() const; + shared_ptr clone() const; void copyFrom(const component& other); parameter& operator=(const parameter& other); - const std::vector > getChildComponents(); + const std::vector > getChildComponents(); /** Return the name of this parameter. * @@ -91,7 +91,7 @@ public: * is equivalent to: * *
-	  *    ref  rawValue = getParameter("creation-date");
+	  *    shared_ptr  rawValue = getParameter("creation-date");
 	  *
 	  *    vmime::dateTime theDate;
 	  *    theDate.parse(rawValue->getBuffer());
@@ -143,7 +143,7 @@ private:
 
 
 	string m_name;
-	ref  m_value;
+	shared_ptr  m_value;
 };
 
 
diff --git a/vmime/parameterizedHeaderField.hpp b/vmime/parameterizedHeaderField.hpp
index 1a80073e..efe9c81e 100644
--- a/vmime/parameterizedHeaderField.hpp
+++ b/vmime/parameterizedHeaderField.hpp
@@ -41,7 +41,7 @@ namespace vmime
 
 class VMIME_EXPORT parameterizedHeaderField : virtual public headerField
 {
-	friend class vmime::creator;  // create ref
+	friend class headerFieldFactory;
 
 protected:
 
@@ -69,7 +69,7 @@ public:
 	  * @throw exceptions::no_such_parameter if no parameter with this name exists
 	  * @return first parameter with the specified name
 	  */
-	ref  findParameter(const string& paramName) const;
+	shared_ptr  findParameter(const string& paramName) const;
 
 	/** Find the first parameter that matches the specified name.
 	  * If no parameter is found, one will be created and inserted into
@@ -78,13 +78,13 @@ public:
 	  * @return first parameter with the specified name or a new field
 	  * if no parameter is found
 	  */
-	ref  getParameter(const string& paramName);
+	shared_ptr  getParameter(const string& paramName);
 
 	/** Add a parameter at the end of the list.
 	  *
 	  * @param param parameter to append
 	  */
-	void appendParameter(ref  param);
+	void appendParameter(shared_ptr  param);
 
 	/** Insert a new parameter before the specified parameter.
 	  *
@@ -92,7 +92,7 @@ public:
 	  * @param param parameter to insert
 	  * @throw exceptions::no_such_parameter if the parameter is not in the list
 	  */
-	void insertParameterBefore(ref  beforeParam, ref  param);
+	void insertParameterBefore(shared_ptr  beforeParam, shared_ptr  param);
 
 	/** Insert a new parameter before the specified position.
 	  *
@@ -100,7 +100,7 @@ public:
 	  * the beginning of the list)
 	  * @param param parameter to insert
 	  */
-	void insertParameterBefore(const size_t pos, ref  param);
+	void insertParameterBefore(const size_t pos, shared_ptr  param);
 
 	/** Insert a new parameter after the specified parameter.
 	  *
@@ -108,21 +108,21 @@ public:
 	  * @param param parameter to insert
 	  * @throw exceptions::no_such_parameter if the parameter is not in the list
 	  */
-	void insertParameterAfter(ref  afterParam, ref  param);
+	void insertParameterAfter(shared_ptr  afterParam, shared_ptr  param);
 
 	/** Insert a new parameter after the specified position.
 	  *
 	  * @param pos position of the parameter before the new parameter
 	  * @param param parameter to insert
 	  */
-	void insertParameterAfter(const size_t pos, ref  param);
+	void insertParameterAfter(const size_t pos, shared_ptr  param);
 
 	/** Remove the specified parameter from the list.
 	  *
 	  * @param param parameter to remove
 	  * @throw exceptions::no_such_parameter if the parameter is not in the list
 	  */
-	void removeParameter(ref  param);
+	void removeParameter(shared_ptr  param);
 
 	/** Remove the parameter at the specified position.
 	  *
@@ -151,32 +151,32 @@ public:
 	  * @param pos position
 	  * @return parameter at position 'pos'
 	  */
-	const ref  getParameterAt(const size_t pos);
+	const shared_ptr  getParameterAt(const size_t pos);
 
 	/** Return the parameter at the specified position.
 	  *
 	  * @param pos position
 	  * @return parameter at position 'pos'
 	  */
-	const ref  getParameterAt(const size_t pos) const;
+	const shared_ptr  getParameterAt(const size_t pos) const;
 
 	/** Return the parameter list.
 	  *
 	  * @return list of parameters
 	  */
-	const std::vector  > getParameterList() const;
+	const std::vector  > getParameterList() const;
 
 	/** Return the parameter list.
 	  *
 	  * @return list of parameters
 	  */
-	const std::vector  > getParameterList();
+	const std::vector  > getParameterList();
 
-	const std::vector  > getChildComponents();
+	const std::vector  > getChildComponents();
 
 private:
 
-	std::vector  > m_params;
+	std::vector  > m_params;
 
 protected:
 
diff --git a/vmime/parsedMessageAttachment.hpp b/vmime/parsedMessageAttachment.hpp
index d37c84a6..6c96f80a 100644
--- a/vmime/parsedMessageAttachment.hpp
+++ b/vmime/parsedMessageAttachment.hpp
@@ -41,30 +41,30 @@ class VMIME_EXPORT parsedMessageAttachment : public messageAttachment
 {
 public:
 
-	parsedMessageAttachment(ref  msg);
+	parsedMessageAttachment(shared_ptr  msg);
 
 	const mediaType getType() const;
 	const text getDescription() const;
 	const word getName() const;
 
-	const ref  getData() const;
+	const shared_ptr  getData() const;
 
 	const encoding getEncoding() const;
 
-	ref  getPart() const;
+	shared_ptr  getPart() const;
 
-	ref  getHeader() const;
+	shared_ptr  getHeader() const;
 
-	ref  getMessage() const;
+	shared_ptr  getMessage() const;
 
 protected:
 
-	void generateIn(ref  parent) const;
+	void generateIn(shared_ptr  parent) const;
 
 private:
 
-	ref  m_msg;
-	mutable ref  m_data;
+	shared_ptr  m_msg;
+	mutable shared_ptr  m_data;
 };
 
 
diff --git a/vmime/path.hpp b/vmime/path.hpp
index cb6e4ed4..87409413 100644
--- a/vmime/path.hpp
+++ b/vmime/path.hpp
@@ -73,10 +73,10 @@ public:
 
 	// Assignment
 	void copyFrom(const component& other);
-	ref  clone() const;
+	shared_ptr  clone() const;
 	path& operator=(const path& other);
 
-	const std::vector  > getChildComponents();
+	const std::vector  > getChildComponents();
 
 protected:
 
diff --git a/vmime/plainTextPart.hpp b/vmime/plainTextPart.hpp
index a68b5306..72a8a71c 100644
--- a/vmime/plainTextPart.hpp
+++ b/vmime/plainTextPart.hpp
@@ -47,17 +47,17 @@ public:
 	const charset& getCharset() const;
 	void setCharset(const charset& ch);
 
-	const ref  getText() const;
-	void setText(ref  text);
+	const shared_ptr  getText() const;
+	void setText(shared_ptr  text);
 
 	size_t getPartCount() const;
 
-	void generateIn(ref  message, ref  parent) const;
-	void parse(ref  message, ref  parent, ref  textPart);
+	void generateIn(shared_ptr  message, shared_ptr  parent) const;
+	void parse(shared_ptr  message, shared_ptr  parent, shared_ptr  textPart);
 
 private:
 
-	ref  m_text;
+	shared_ptr  m_text;
 	charset m_charset;
 };
 
diff --git a/vmime/platform.hpp b/vmime/platform.hpp
index f10e5c9c..c72f160e 100644
--- a/vmime/platform.hpp
+++ b/vmime/platform.hpp
@@ -117,7 +117,7 @@ public:
 		  *
 		  * @return socket factory
 		  */
-		virtual ref  getSocketFactory() = 0;
+		virtual shared_ptr  getSocketFactory() = 0;
 #endif
 
 #if VMIME_HAVE_FILESYSTEM_FEATURES
@@ -125,14 +125,14 @@ public:
 		  *
 		  * @return file-system factory
 		  */
-		virtual ref  getFileSystemFactory() = 0;
+		virtual shared_ptr  getFileSystemFactory() = 0;
 
 		/** Return a pointer to a factory that creates child process objects,
 		  * which are used to spawn processes (run executable files).
 		  *
 		  * @return child process factory
 		  */
-		virtual ref  getChildProcessFactory() = 0;
+		virtual shared_ptr  getChildProcessFactory() = 0;
 #endif
 
 		/** Fills a buffer with cryptographically random bytes.
@@ -144,22 +144,22 @@ public:
 
 		/** Creates and initializes a critical section.
 		  */
-		virtual ref  createCriticalSection() = 0;
+		virtual shared_ptr  createCriticalSection() = 0;
 	};
 
 
 	template 
 	static void setHandler()
 	{
-		sm_handler = vmime::create ();
+		sm_handler = vmime::make_shared ();
 	}
 
-	static ref  getDefaultHandler();
-	static ref  getHandler();
+	static shared_ptr  getDefaultHandler();
+	static shared_ptr  getHandler();
 
 private:
 
-	static ref  sm_handler;
+	static shared_ptr  sm_handler;
 };
 
 
diff --git a/vmime/platforms/posix/posixChildProcess.hpp b/vmime/platforms/posix/posixChildProcess.hpp
index 9e60ef19..5b9fa021 100644
--- a/vmime/platforms/posix/posixChildProcess.hpp
+++ b/vmime/platforms/posix/posixChildProcess.hpp
@@ -51,8 +51,8 @@ public:
 
 	void start(const std::vector  args, const int flags = 0);
 
-	ref  getStdIn();
-	ref  getStdOut();
+	shared_ptr  getStdIn();
+	shared_ptr  getStdOut();
 
 	void waitForFinish();
 
@@ -61,8 +61,8 @@ private:
 	utility::file::path m_processPath;
 	bool m_started;
 
-	ref  m_stdIn;
-	ref  m_stdOut;
+	shared_ptr  m_stdIn;
+	shared_ptr  m_stdOut;
 
 	sigset_t m_oldProcMask;
 	pid_t m_pid;
@@ -77,7 +77,7 @@ class posixChildProcessFactory : public utility::childProcessFactory
 {
 public:
 
-	ref  create(const utility::file::path& path) const;
+	shared_ptr  create(const utility::file::path& path) const;
 };
 
 
diff --git a/vmime/platforms/posix/posixFile.hpp b/vmime/platforms/posix/posixFile.hpp
index c19f1674..a1353841 100644
--- a/vmime/platforms/posix/posixFile.hpp
+++ b/vmime/platforms/posix/posixFile.hpp
@@ -95,7 +95,7 @@ public:
 
 	posixFileWriter(const vmime::utility::file::path& path, const vmime::string& nativePath);
 
-	ref  getOutputStream();
+	shared_ptr  getOutputStream();
 
 private:
 
@@ -111,7 +111,7 @@ public:
 
 	posixFileReader(const vmime::utility::file::path& path, const vmime::string& nativePath);
 
-	ref  getInputStream();
+	shared_ptr  getInputStream();
 
 private:
 
@@ -129,7 +129,7 @@ public:
 	~posixFileIterator();
 
 	bool hasMoreElements() const;
-	ref  nextElement();
+	shared_ptr  nextElement();
 
 private:
 
@@ -165,16 +165,16 @@ public:
 
 	bool exists() const;
 
-	ref  getParent() const;
+	shared_ptr  getParent() const;
 
 	void rename(const path& newName);
 
 	void remove();
 
-	ref  getFileWriter();
-	ref  getFileReader();
+	shared_ptr  getFileWriter();
+	shared_ptr  getFileReader();
 
-	ref  getFiles() const;
+	shared_ptr  getFiles() const;
 
 private:
 
@@ -192,7 +192,7 @@ class posixFileSystemFactory : public vmime::utility::fileSystemFactory
 {
 public:
 
-	ref  create(const vmime::utility::file::path& path) const;
+	shared_ptr  create(const vmime::utility::file::path& path) const;
 
 	const vmime::utility::file::path stringToPath(const vmime::string& str) const;
 	const vmime::string pathToString(const vmime::utility::file::path& path) const;
diff --git a/vmime/platforms/posix/posixHandler.hpp b/vmime/platforms/posix/posixHandler.hpp
index 34453916..0bba372b 100644
--- a/vmime/platforms/posix/posixHandler.hpp
+++ b/vmime/platforms/posix/posixHandler.hpp
@@ -67,30 +67,30 @@ public:
 	unsigned int getThreadId() const;
 
 #if VMIME_HAVE_MESSAGING_FEATURES
-	ref  getSocketFactory();
+	shared_ptr  getSocketFactory();
 #endif
 
 #if VMIME_HAVE_FILESYSTEM_FEATURES
-	ref  getFileSystemFactory();
+	shared_ptr  getFileSystemFactory();
 
-	ref  getChildProcessFactory();
+	shared_ptr  getChildProcessFactory();
 #endif
 
 	void wait() const;
 
 	void generateRandomBytes(unsigned char* buffer, const unsigned int count);
 
-	ref  createCriticalSection();
+	shared_ptr  createCriticalSection();
 
 private:
 
 #if VMIME_HAVE_MESSAGING_FEATURES
-	ref  m_socketFactory;
+	shared_ptr  m_socketFactory;
 #endif
 
 #if VMIME_HAVE_FILESYSTEM_FEATURES
-	ref  m_fileSysFactory;
-	ref  m_childProcFactory;
+	shared_ptr  m_fileSysFactory;
+	shared_ptr  m_childProcFactory;
 #endif
 };
 
diff --git a/vmime/platforms/posix/posixSocket.hpp b/vmime/platforms/posix/posixSocket.hpp
index ebbf551e..10df657e 100644
--- a/vmime/platforms/posix/posixSocket.hpp
+++ b/vmime/platforms/posix/posixSocket.hpp
@@ -43,7 +43,7 @@ class posixSocket : public vmime::net::socket
 {
 public:
 
-	posixSocket(ref  th);
+	posixSocket(shared_ptr  th);
 	~posixSocket();
 
 	void connect(const vmime::string& address, const vmime::port_t port);
@@ -70,7 +70,7 @@ protected:
 
 private:
 
-	ref  m_timeoutHandler;
+	shared_ptr  m_timeoutHandler;
 
 	char m_buffer[65536];
 	int m_desc;
@@ -86,8 +86,8 @@ class posixSocketFactory : public vmime::net::socketFactory
 {
 public:
 
-	ref  create();
-	ref  create(ref  th);
+	shared_ptr  create();
+	shared_ptr  create(shared_ptr  th);
 };
 
 
diff --git a/vmime/platforms/windows/windowsFile.hpp b/vmime/platforms/windows/windowsFile.hpp
index 1dae064c..65049b8f 100644
--- a/vmime/platforms/windows/windowsFile.hpp
+++ b/vmime/platforms/windows/windowsFile.hpp
@@ -46,7 +46,7 @@ class windowsFileSystemFactory : public vmime::utility::fileSystemFactory
 {
 public:
 
-	ref  create(const vmime::utility::file::path& path) const;
+	shared_ptr  create(const vmime::utility::file::path& path) const;
 
 	const vmime::utility::file::path stringToPath(const vmime::string& str) const;
 	const vmime::string pathToString(const vmime::utility::file::path& path) const;
@@ -84,16 +84,16 @@ public:
 
 	bool exists() const;
 
-	ref  getParent() const;
+	shared_ptr  getParent() const;
 
 	void rename(const path& newName);
 	void remove();
 
-	ref  getFileWriter();
+	shared_ptr  getFileWriter();
 
-	ref  getFileReader();
+	shared_ptr  getFileReader();
 
-	ref  getFiles() const;
+	shared_ptr  getFiles() const;
 
 private:
 
@@ -114,7 +114,7 @@ public:
 	~windowsFileIterator();
 
 	bool hasMoreElements() const;
-	vmime::ref  nextElement();
+	shared_ptr  nextElement();
 
 private:
 
@@ -140,7 +140,7 @@ public:
 
 public:
 
-	ref  getInputStream();
+	shared_ptr  getInputStream();
 
 private:
 
@@ -180,7 +180,7 @@ public:
 
 public:
 
-	ref  getOutputStream();
+	shared_ptr  getOutputStream();
 
 private:
 
diff --git a/vmime/platforms/windows/windowsHandler.hpp b/vmime/platforms/windows/windowsHandler.hpp
index d3ac434c..4a3678eb 100644
--- a/vmime/platforms/windows/windowsHandler.hpp
+++ b/vmime/platforms/windows/windowsHandler.hpp
@@ -66,29 +66,29 @@ public:
 	unsigned int getThreadId() const;
 
 #if VMIME_HAVE_MESSAGING_FEATURES
-	ref  getSocketFactory();
+	shared_ptr  getSocketFactory();
 #endif
 
 #if VMIME_HAVE_FILESYSTEM_FEATURES
-	ref  getFileSystemFactory();
+	shared_ptr  getFileSystemFactory();
 
-	ref  getChildProcessFactory();
+	shared_ptr  getChildProcessFactory();
 #endif
 
 	void wait() const;
 
 	void generateRandomBytes(unsigned char* buffer, const unsigned int count);
 
-	ref  createCriticalSection();
+	shared_ptr  createCriticalSection();
 
 private:
 
 #if VMIME_HAVE_MESSAGING_FEATURES
-	ref  m_socketFactory;
+	shared_ptr  m_socketFactory;
 #endif
 
 #if VMIME_HAVE_FILESYSTEM_FEATURES
-	ref  m_fileSysFactory;
+	shared_ptr  m_fileSysFactory;
 #endif
 };
 
diff --git a/vmime/platforms/windows/windowsSocket.hpp b/vmime/platforms/windows/windowsSocket.hpp
index db3e6323..4c4344d8 100644
--- a/vmime/platforms/windows/windowsSocket.hpp
+++ b/vmime/platforms/windows/windowsSocket.hpp
@@ -45,7 +45,7 @@ class windowsSocket : public vmime::net::socket
 public:
 
 	windowsSocket();
-	windowsSocket(ref  th);
+	windowsSocket(shared_ptr  th);
 	~windowsSocket();
 
 public:
@@ -83,7 +83,7 @@ protected:
 
 private:
 
-	ref  m_timeoutHandler;
+	shared_ptr  m_timeoutHandler;
 
 	char m_buffer[65536];
 	SOCKET m_desc;
@@ -99,8 +99,8 @@ class windowsSocketFactory : public vmime::net::socketFactory
 {
 public:
 
-	ref  create();
-	ref  create(ref  th);
+	shared_ptr  create();
+	shared_ptr  create(shared_ptr  th);
 };
 
 
diff --git a/vmime/propertySet.hpp b/vmime/propertySet.hpp
index eefdbcc3..bf1c39bf 100644
--- a/vmime/propertySet.hpp
+++ b/vmime/propertySet.hpp
@@ -276,7 +276,7 @@ public:
 	template 
 	const TYPE getProperty(const string& name) const
 	{
-		const ref  prop = find(name);
+		const shared_ptr  prop = find(name);
 		if (!prop) throw exceptions::no_such_property(name);
 
 		//return (prop->getValue ());  // BUG: with g++ < 3.4
@@ -295,7 +295,7 @@ public:
 	template 
 	const TYPE getProperty(const string& name, const TYPE defaultValue) const
 	{
-		const ref  prop = find(name);
+		const shared_ptr  prop = find(name);
 		//return (prop ? prop->getValue () : defaultValue); // BUG: with g++ < 3.4
 		return (prop ? prop->template getValue () : defaultValue);
 	}
@@ -335,13 +335,13 @@ private:
 	void parse(const string& props);
 
 
-	class propFinder : public std::unary_function , bool>
+	class propFinder : public std::unary_function , bool>
 	{
 	public:
 
 		propFinder(const string& name) : m_name(utility::stringUtils::toLower(name)) { }
 
-		bool operator()(ref  p) const
+		bool operator()(shared_ptr  p) const
 		{
 			return (utility::stringUtils::toLower(p->getName()) == m_name);
 		}
@@ -351,10 +351,10 @@ private:
 		const string m_name;
 	};
 
-	ref  find(const string& name) const;
-	ref  findOrCreate(const string& name);
+	shared_ptr  find(const string& name) const;
+	shared_ptr  findOrCreate(const string& name);
 
-	typedef std::list  > list_type;
+	typedef std::list  > list_type;
 	list_type m_props;
 
 public:
@@ -427,13 +427,13 @@ public:
 	  *
 	  * @return list of properties
 	  */
-	const std::vector  > getPropertyList() const;
+	const std::vector  > getPropertyList() const;
 
 	/** Return the property list.
 	  *
 	  * @return list of properties
 	  */
-	const std::vector  > getPropertyList();
+	const std::vector  > getPropertyList();
 };
 
 
diff --git a/vmime/relay.hpp b/vmime/relay.hpp
index f778a0bc..62ed5bf0 100644
--- a/vmime/relay.hpp
+++ b/vmime/relay.hpp
@@ -47,11 +47,11 @@ public:
 
 public:
 
-	ref  clone() const;
+	shared_ptr  clone() const;
 	void copyFrom(const component& other);
 	relay& operator=(const relay& other);
 
-	const std::vector  > getChildComponents();
+	const std::vector  > getChildComponents();
 
 	const string& getFrom() const;
 	void setFrom(const string& from);
diff --git a/vmime/security/authenticator.hpp b/vmime/security/authenticator.hpp
index 5efdb321..bef07b4a 100644
--- a/vmime/security/authenticator.hpp
+++ b/vmime/security/authenticator.hpp
@@ -114,7 +114,7 @@ public:
 	  *
 	  * @param serv messaging service instance
 	  */
-	virtual void setService(ref  serv) = 0;
+	virtual void setService(shared_ptr  serv) = 0;
 };
 
 
diff --git a/vmime/security/cert/X509Certificate.hpp b/vmime/security/cert/X509Certificate.hpp
index 20ebfe5a..215a86cf 100644
--- a/vmime/security/cert/X509Certificate.hpp
+++ b/vmime/security/cert/X509Certificate.hpp
@@ -74,7 +74,7 @@ public:
 	  * @return a X.509 certificate, or NULL if the given data does not
 	  * represent a valid certificate
 	  */
-	static ref  import(utility::inputStream& is);
+	static shared_ptr  import(utility::inputStream& is);
 
 	/** Imports a DER or PEM encoded X.509 certificate.
 	  *
@@ -83,7 +83,7 @@ public:
 	  * @return a X.509 certificate, or NULL if the given data does not
 	  * represent a valid certificate
 	  */
-	static ref  import(const byte_t* data, const size_t length);
+	static shared_ptr  import(const byte_t* data, const size_t length);
 
 	/** Exports this X.509 certificate to the specified format.
 	  *
@@ -107,14 +107,14 @@ public:
 	  * @return true if this certificate was issued by the given issuer,
 	  * false otherwise
 	  */
-	virtual bool checkIssuer(ref  issuer) const = 0;
+	virtual bool checkIssuer(shared_ptr  issuer) const = 0;
 
 	/** Verifies this certificate against a given trusted one.
 	  *
 	  * @param caCert a certificate that is considered to be trusted one
 	  * @return true if the verification succeeded, false otherwise
 	  */
-	virtual bool verify(ref  caCert) const = 0;
+	virtual bool verify(shared_ptr  caCert) const = 0;
 
 	/** Verify certificate's subject name against the given hostname.
 	  *
diff --git a/vmime/security/cert/certificate.hpp b/vmime/security/cert/certificate.hpp
index e4a57fb4..aef1f1f9 100644
--- a/vmime/security/cert/certificate.hpp
+++ b/vmime/security/cert/certificate.hpp
@@ -64,7 +64,7 @@ public:
 	  * @return true if the two certificates are the same,
 	  * false otherwise
 	  */
-	virtual bool equals(ref  other) const = 0;
+	virtual bool equals(shared_ptr  other) const = 0;
 
 	/** Returns a pointer to internal binary data for this certificate.
 	  * The actual type of data depends on the library used for TLS support.
diff --git a/vmime/security/cert/certificateChain.hpp b/vmime/security/cert/certificateChain.hpp
index 8daa4cb5..0ce6bda3 100644
--- a/vmime/security/cert/certificateChain.hpp
+++ b/vmime/security/cert/certificateChain.hpp
@@ -47,7 +47,7 @@ public:
 	  *
 	  * @param certs chain of certificates
 	  */
-	certificateChain(const std::vector  >& certs);
+	certificateChain(const std::vector  >& certs);
 
 	/** Return the number of certificates in the chain.
 	  *
@@ -62,11 +62,11 @@ public:
 	  * @param index position at which to retrieve certificate
 	  * @return certificate at the specified position
 	  */
-	ref  getAt(const unsigned int index);
+	shared_ptr  getAt(const unsigned int index);
 
 protected:
 
-	std::vector  > m_certs;
+	std::vector  > m_certs;
 };
 
 
diff --git a/vmime/security/cert/certificateVerifier.hpp b/vmime/security/cert/certificateVerifier.hpp
index 349ab46d..c72c84cb 100644
--- a/vmime/security/cert/certificateVerifier.hpp
+++ b/vmime/security/cert/certificateVerifier.hpp
@@ -49,7 +49,7 @@ public:
 	  * or more certificates can not be trusted, or the server identity
 	  * cannot be verified
 	  */
-	virtual void verify(ref  chain, const string& hostname) = 0;
+	virtual void verify(shared_ptr  chain, const string& hostname) = 0;
 };
 
 
diff --git a/vmime/security/cert/defaultCertificateVerifier.hpp b/vmime/security/cert/defaultCertificateVerifier.hpp
index 84e08e64..fddcc4f5 100644
--- a/vmime/security/cert/defaultCertificateVerifier.hpp
+++ b/vmime/security/cert/defaultCertificateVerifier.hpp
@@ -53,17 +53,17 @@ public:
 	  *
 	  * @param trustedCerts list of trusted certificates
 	  */
-	void setX509TrustedCerts(const std::vector  >& trustedCerts);
+	void setX509TrustedCerts(const std::vector  >& trustedCerts);
 
 	/** Sets the X.509 root CAs used for certificate verification.
 	  *
 	  * @param caCerts list of root CAs
 	  */
-	void setX509RootCAs(const std::vector  >& caCerts);
+	void setX509RootCAs(const std::vector  >& caCerts);
 
 
 	// Implementation of 'certificateVerifier'
-	void verify(ref  chain, const string& hostname);
+	void verify(shared_ptr  chain, const string& hostname);
 
 private:
 
@@ -72,11 +72,11 @@ private:
 	  * @param chain list of X.509 certificates
 	  * @param hostname server hostname
 	  */
-	void verifyX509(ref  chain, const string& hostname);
+	void verifyX509(shared_ptr  chain, const string& hostname);
 
 
-	std::vector  > m_x509RootCAs;
-	std::vector  > m_x509TrustedCerts;
+	std::vector  > m_x509RootCAs;
+	std::vector  > m_x509TrustedCerts;
 };
 
 
diff --git a/vmime/security/cert/gnutls/X509Certificate_GnuTLS.hpp b/vmime/security/cert/gnutls/X509Certificate_GnuTLS.hpp
index bd38342d..76ee6d4d 100644
--- a/vmime/security/cert/gnutls/X509Certificate_GnuTLS.hpp
+++ b/vmime/security/cert/gnutls/X509Certificate_GnuTLS.hpp
@@ -41,16 +41,14 @@ namespace cert {
 
 class X509Certificate_GnuTLS : public X509Certificate
 {
-	friend class vmime::creator;
 	friend class X509Certificate;
 
-protected:
-
-	X509Certificate_GnuTLS();
 	X509Certificate_GnuTLS(const X509Certificate&);
 
 public:
 
+	X509Certificate_GnuTLS();
+
 	~X509Certificate_GnuTLS();
 
 
@@ -58,9 +56,9 @@ public:
 
 	const byteArray getSerialNumber() const;
 
-	bool checkIssuer(ref  issuer) const;
+	bool checkIssuer(shared_ptr  issuer) const;
 
-	bool verify(ref  caCert) const;
+	bool verify(shared_ptr  caCert) const;
 
 	bool verifyHostName(const string& hostname) const;
 
@@ -74,7 +72,7 @@ public:
 	const byteArray getEncoded() const;
 	const string getType() const;
 	int getVersion() const;
-	bool equals(ref  other) const;
+	bool equals(shared_ptr  other) const;
 	void* getInternalData();
 
 private:
diff --git a/vmime/security/cert/openssl/X509Certificate_OpenSSL.hpp b/vmime/security/cert/openssl/X509Certificate_OpenSSL.hpp
index 60ecda08..bddb4b6c 100644
--- a/vmime/security/cert/openssl/X509Certificate_OpenSSL.hpp
+++ b/vmime/security/cert/openssl/X509Certificate_OpenSSL.hpp
@@ -43,17 +43,15 @@ namespace cert {
 
 class X509Certificate_OpenSSL : public X509Certificate
 {
-	friend class vmime::creator;
 	friend class X509Certificate;
 
-protected:
-
-	X509Certificate_OpenSSL();
-	X509Certificate_OpenSSL(X509* cert);
 	X509Certificate_OpenSSL(const X509Certificate_OpenSSL&);
 
 public:
 
+	X509Certificate_OpenSSL();
+	X509Certificate_OpenSSL(X509* cert);
+
 	~X509Certificate_OpenSSL();
 
 
@@ -61,9 +59,9 @@ public:
 
 	const byteArray getSerialNumber() const;
 
-	bool checkIssuer(ref  issuer) const;
+	bool checkIssuer(shared_ptr  issuer) const;
 
-	bool verify(ref  caCert) const;
+	bool verify(shared_ptr  caCert) const;
 
 	bool verifyHostName(const string& hostname) const;
 
@@ -73,14 +71,14 @@ public:
 	const byteArray getFingerprint(const DigestAlgorithm algo) const;
 
 
-	static ref  importInternal(X509* cert);
+	static shared_ptr  importInternal(X509* cert);
 
 
 	// Implementation of 'certificate'
 	const byteArray getEncoded() const;
 	const string getType() const;
 	int getVersion() const;
-	bool equals(ref  other) const;
+	bool equals(shared_ptr  other) const;
 	void* getInternalData();
 
 private:
diff --git a/vmime/security/defaultAuthenticator.hpp b/vmime/security/defaultAuthenticator.hpp
index 780dc310..eead3d14 100644
--- a/vmime/security/defaultAuthenticator.hpp
+++ b/vmime/security/defaultAuthenticator.hpp
@@ -54,12 +54,12 @@ public:
 	const string getAnonymousToken() const;
 	const string getServiceName() const;
 
-	void setService(ref  serv);
-	weak_ref  getService() const;
+	void setService(shared_ptr  serv);
+	weak_ptr  getService() const;
 
 private:
 
-	weak_ref  m_service;
+	weak_ptr  m_service;
 };
 
 
diff --git a/vmime/security/digest/messageDigestFactory.hpp b/vmime/security/digest/messageDigestFactory.hpp
index 2a1a4083..15fd8a28 100644
--- a/vmime/security/digest/messageDigestFactory.hpp
+++ b/vmime/security/digest/messageDigestFactory.hpp
@@ -55,7 +55,7 @@ private:
 	{
 	public:
 
-		virtual ref  create() const = 0;
+		virtual shared_ptr  create() const = 0;
 	};
 
 	template 
@@ -63,14 +63,14 @@ private:
 	{
 	public:
 
-		ref  create() const
+		shared_ptr  create() const
 		{
-			return vmime::create ();
+			return vmime::make_shared ();
 		}
 	};
 
 
-	typedef std::map  > MapType;
+	typedef std::map  > MapType;
 	MapType m_algos;
 
 public:
@@ -83,7 +83,7 @@ public:
 	void registerAlgorithm(const string& name)
 	{
 		m_algos.insert(MapType::value_type(utility::stringUtils::toLower(name),
-			vmime::create  >()));
+			vmime::make_shared  >()));
 	}
 
 	/** Create a new algorithm instance from its name.
@@ -93,7 +93,7 @@ public:
 	  * @throw exceptions::no_digest_algorithm_available if no algorithm is
 	  * registered with this name
 	  */
-	ref  create(const string& name);
+	shared_ptr  create(const string& name);
 
 	/** Return a list of supported digest algorithms.
 	  *
diff --git a/vmime/security/sasl/SASLAuthenticator.hpp b/vmime/security/sasl/SASLAuthenticator.hpp
index 56588fc8..9f1881f5 100644
--- a/vmime/security/sasl/SASLAuthenticator.hpp
+++ b/vmime/security/sasl/SASLAuthenticator.hpp
@@ -64,15 +64,15 @@ public:
 	  * @return ordered list of mechanism to use among the available
 	  * mechanisms (from the first to try to the last)
 	  */
-	virtual const std::vector  > getAcceptableMechanisms
-		(const std::vector  >& available,
-	         ref  suggested) const = 0;
+	virtual const std::vector  > getAcceptableMechanisms
+		(const std::vector  >& available,
+	         shared_ptr  suggested) const = 0;
 
 	/** Set the SASL session which is using this authenticator.
 	  *
 	  * @param sess SASL session
 	  */
-	virtual void setSASLSession(ref  sess) = 0;
+	virtual void setSASLSession(shared_ptr  sess) = 0;
 
 	/** Set the SASL mechanism which has been selected for the
 	  * SASL authentication process. This may be called several times
@@ -81,7 +81,7 @@ public:
 	  *
 	  * @param mech SASL mechanism
 	  */
-	virtual void setSASLMechanism(ref  mech) = 0;
+	virtual void setSASLMechanism(shared_ptr  mech) = 0;
 };
 
 
diff --git a/vmime/security/sasl/SASLContext.hpp b/vmime/security/sasl/SASLContext.hpp
index 8f6e177c..7afcddf2 100644
--- a/vmime/security/sasl/SASLContext.hpp
+++ b/vmime/security/sasl/SASLContext.hpp
@@ -64,9 +64,9 @@ public:
 	  * @param mech SASL mechanism
 	  * @return a new SASL session
 	  */
-	ref  createSession
+	shared_ptr  createSession
 		(const string& serviceName,
-		 ref  auth, ref  mech);
+		 shared_ptr  auth, shared_ptr  mech);
 
 	/** Create an instance of an SASL mechanism.
 	  *
@@ -75,7 +75,7 @@ public:
 	  * @throw exceptions::no_such_mechanism if no mechanism is
 	  * registered for the specified name
 	  */
-	ref  createMechanism(const string& name);
+	shared_ptr  createMechanism(const string& name);
 
 	/** Suggests an SASL mechanism among a set of mechanisms
 	  * supported by the server.
@@ -84,8 +84,8 @@ public:
 	  * @return suggested mechanism (usually the safest mechanism
 	  * supported by both the client and the server)
 	  */
-	ref  suggestMechanism
-		(const std::vector  >& mechs);
+	shared_ptr  suggestMechanism
+		(const std::vector  >& mechs);
 
 	/** Helper function for decoding Base64-encoded challenge.
 	  *
diff --git a/vmime/security/sasl/SASLMechanism.hpp b/vmime/security/sasl/SASLMechanism.hpp
index 56566a42..623069d5 100644
--- a/vmime/security/sasl/SASLMechanism.hpp
+++ b/vmime/security/sasl/SASLMechanism.hpp
@@ -71,7 +71,7 @@ public:
 	  * 'responseLen' are undetermined)
 	  */
 	virtual bool step
-		(ref  sess,
+		(shared_ptr  sess,
 		 const byte_t* challenge, const long challengeLen,
 		 byte_t** response, long* responseLen) = 0;
 
@@ -97,7 +97,7 @@ public:
 	  * the encoding of data (in this case, the values in 'output' and
 	  * 'outputLen' are undetermined)
 	  */
-	virtual void encode(ref  sess,
+	virtual void encode(shared_ptr  sess,
 		const byte_t* input, const long inputLen,
 		byte_t** output, long* outputLen) = 0;
 
@@ -114,7 +114,7 @@ public:
 	  * the encoding of data (in this case, the values in 'output' and
 	  * 'outputLen' are undetermined)
 	  */
-	virtual void decode(ref  sess,
+	virtual void decode(shared_ptr  sess,
 		const byte_t* input, const long inputLen,
 		byte_t** output, long* outputLen) = 0;
 };
diff --git a/vmime/security/sasl/SASLMechanismFactory.hpp b/vmime/security/sasl/SASLMechanismFactory.hpp
index 920b78fc..3503f71b 100644
--- a/vmime/security/sasl/SASLMechanismFactory.hpp
+++ b/vmime/security/sasl/SASLMechanismFactory.hpp
@@ -61,8 +61,8 @@ private:
 	{
 	public:
 
-		virtual ref  create
-			(ref  ctx, const string& name) = 0;
+		virtual shared_ptr  create
+			(shared_ptr  ctx, const string& name) = 0;
 	};
 
 	template 
@@ -70,13 +70,13 @@ private:
 	{
 	public:
 
-		ref  create(ref  ctx, const string& name)
+		shared_ptr  create(shared_ptr  ctx, const string& name)
 		{
-			return vmime::create (ctx, name);
+			return vmime::make_shared (ctx, name);
 		}
 	};
 
-	typedef std::map  > MapType;
+	typedef std::map  > MapType;
 	MapType m_mechs;
 
 public:
@@ -92,7 +92,7 @@ public:
 	void registerMechanism(const string& name)
 	{
 		m_mechs.insert(MapType::value_type(name,
-			vmime::create  >()));
+			vmime::make_shared  >()));
 	}
 
 	/** Create a mechanism object given its name.
@@ -103,7 +103,7 @@ public:
 	  * @throw exceptions::no_such_mechanism if no mechanism is
 	  * registered for the specified name
 	  */
-	ref  create(ref  ctx, const string& name);
+	shared_ptr  create(shared_ptr  ctx, const string& name);
 
 	/** Return a list of supported mechanisms. This includes mechanisms
 	  * registered using registerMechanism() as well as the ones that
diff --git a/vmime/security/sasl/SASLSession.hpp b/vmime/security/sasl/SASLSession.hpp
index a196e06d..830d9970 100644
--- a/vmime/security/sasl/SASLSession.hpp
+++ b/vmime/security/sasl/SASLSession.hpp
@@ -64,8 +64,8 @@ public:
 	  * @param auth authenticator to use for this session
 	  * @param mech SASL mechanism
 	  */
-	SASLSession(const string& serviceName, ref  ctx,
-	        ref  auth, ref  mech);
+	SASLSession(const string& serviceName, shared_ptr  ctx,
+	        shared_ptr  auth, shared_ptr  mech);
 
 	/** Initialize this SASL session. This must be called before
 	  * calling any other method on this object (except accessors).
@@ -78,19 +78,19 @@ public:
 	  *
 	  * @return authenticator object
 	  */
-	ref  getAuthenticator();
+	shared_ptr  getAuthenticator();
 
 	/** Return the mechanism used for this session.
 	  *
 	  * @return SASL mechanism
 	  */
-	ref  getMechanism();
+	shared_ptr  getMechanism();
 
 	/** Return the SASL context.
 	  *
 	  * @return SASL context
 	  */
-	ref  getContext();
+	shared_ptr  getContext();
 
 	/** Perform one step of SASL authentication. Accept data from the
 	  * server (challenge), process it and return data to be returned
@@ -118,7 +118,7 @@ public:
 	  * @param sok socket to wrap
 	  * @return secured socket
 	  */
-	ref  getSecuredSocket(ref  sok);
+	shared_ptr  getSecuredSocket(shared_ptr  sok);
 
 	/** Return the name of the service which is using this
 	  * SASL session (eg. "imap"). This value should be returned
@@ -132,9 +132,9 @@ private:
 
 	const string m_serviceName;
 
-	ref  m_context;
-	ref  m_auth;
-	ref  m_mech;
+	shared_ptr  m_context;
+	shared_ptr  m_auth;
+	shared_ptr  m_mech;
 
 #ifdef GSASL_VERSION
 	Gsasl* m_gsaslContext;
diff --git a/vmime/security/sasl/SASLSocket.hpp b/vmime/security/sasl/SASLSocket.hpp
index 3c1cf12c..33487eba 100644
--- a/vmime/security/sasl/SASLSocket.hpp
+++ b/vmime/security/sasl/SASLSocket.hpp
@@ -50,7 +50,7 @@ class VMIME_EXPORT SASLSocket : public net::socket
 {
 public:
 
-	SASLSocket(ref  sess, ref  wrapped);
+	SASLSocket(shared_ptr  sess, shared_ptr  wrapped);
 	~SASLSocket();
 
 	void connect(const string& address, const port_t port);
@@ -74,8 +74,8 @@ public:
 
 private:
 
-	ref  m_session;
-	ref  m_wrapped;
+	shared_ptr  m_session;
+	shared_ptr  m_wrapped;
 
 	byte_t* m_pendingBuffer;
 	size_type m_pendingPos;
diff --git a/vmime/security/sasl/builtinSASLMechanism.hpp b/vmime/security/sasl/builtinSASLMechanism.hpp
index 3507dc45..e7081a27 100644
--- a/vmime/security/sasl/builtinSASLMechanism.hpp
+++ b/vmime/security/sasl/builtinSASLMechanism.hpp
@@ -49,30 +49,30 @@ class VMIME_EXPORT builtinSASLMechanism : public SASLMechanism
 {
 public:
 
-	builtinSASLMechanism(ref  ctx, const string& name);
+	builtinSASLMechanism(shared_ptr  ctx, const string& name);
 	~builtinSASLMechanism();
 
 
 	const string getName() const;
 
-	bool step(ref  sess,
+	bool step(shared_ptr  sess,
 		 const byte_t* challenge, const long challengeLen,
 		 byte_t** response, long* responseLen);
 
 	bool isComplete() const;
 
-	void encode(ref  sess,
+	void encode(shared_ptr  sess,
 		const byte_t* input, const long inputLen,
 		byte_t** output, long* outputLen);
 
-	void decode(ref  sess,
+	void decode(shared_ptr  sess,
 		const byte_t* input, const long inputLen,
 		byte_t** output, long* outputLen);
 
 private:
 
 	/** SASL context */
-	ref  m_context;
+	shared_ptr  m_context;
 
 	/** Mechanism name */
 	const string m_name;
diff --git a/vmime/security/sasl/defaultSASLAuthenticator.hpp b/vmime/security/sasl/defaultSASLAuthenticator.hpp
index 68ae7946..6ea9af80 100644
--- a/vmime/security/sasl/defaultSASLAuthenticator.hpp
+++ b/vmime/security/sasl/defaultSASLAuthenticator.hpp
@@ -50,9 +50,9 @@ public:
 	defaultSASLAuthenticator();
 	~defaultSASLAuthenticator();
 
-	const std::vector  > getAcceptableMechanisms
-		(const std::vector  >& available,
-	         ref  suggested) const;
+	const std::vector  > getAcceptableMechanisms
+		(const std::vector  >& available,
+	         shared_ptr  suggested) const;
 
 	const string getUsername() const;
 	const string getPassword() const;
@@ -60,22 +60,22 @@ public:
 	const string getAnonymousToken() const;
 	const string getServiceName() const;
 
-	void setService(ref  serv);
-	weak_ref  getService() const;
+	void setService(shared_ptr  serv);
+	weak_ptr  getService() const;
 
-	void setSASLSession(ref  sess);
-	ref  getSASLSession() const;
+	void setSASLSession(shared_ptr  sess);
+	shared_ptr  getSASLSession() const;
 
-	void setSASLMechanism(ref  mech);
-	ref  getSASLMechanism() const;
+	void setSASLMechanism(shared_ptr  mech);
+	shared_ptr  getSASLMechanism() const;
 
 private:
 
 	defaultAuthenticator m_default;
 
-	weak_ref  m_service;
-	weak_ref  m_saslSession;
-	ref  m_saslMech;
+	weak_ptr  m_service;
+	weak_ptr  m_saslSession;
+	shared_ptr  m_saslMech;
 };
 
 
diff --git a/vmime/streamContentHandler.hpp b/vmime/streamContentHandler.hpp
index bf2eb449..52f6718a 100644
--- a/vmime/streamContentHandler.hpp
+++ b/vmime/streamContentHandler.hpp
@@ -58,7 +58,7 @@ public:
 	  * @return a reference to a new content handler
 	  */
 	streamContentHandler
-		(ref  is,
+		(shared_ptr  is,
 		 const utility::stream::size_type length,
 		 const vmime::encoding& enc = NO_ENCODING);
 
@@ -67,7 +67,7 @@ public:
 	streamContentHandler(const streamContentHandler& cts);
 	streamContentHandler& operator=(const streamContentHandler& cts);
 
-	ref  clone() const;
+	shared_ptr  clone() const;
 
 	/** Sets the data managed by this content handler.
 	  *
@@ -79,7 +79,7 @@ public:
 	  * from the stream is already encoded with the specified encoding
 	  */
 	void setData
-		(ref  is,
+		(shared_ptr  is,
 		 const utility::stream::size_type length,
 		 const vmime::encoding& enc = NO_ENCODING);
 
@@ -111,7 +111,7 @@ private:
 	vmime::encoding m_encoding;
 
 	// Actual data
-	mutable ref  m_stream;
+	mutable shared_ptr  m_stream;
 	string::size_type m_length;
 };
 
diff --git a/vmime/stringContentHandler.hpp b/vmime/stringContentHandler.hpp
index 4565ceb8..b8fdaa71 100644
--- a/vmime/stringContentHandler.hpp
+++ b/vmime/stringContentHandler.hpp
@@ -46,7 +46,7 @@ public:
 	stringContentHandler(const stringContentHandler& cts);
 	stringContentHandler& operator=(const stringContentHandler& cts);
 
-	ref  clone() const;
+	shared_ptr  clone() const;
 
 	// Set the data contained in the body.
 	//
diff --git a/vmime/text.hpp b/vmime/text.hpp
index be55bf08..98e2459a 100644
--- a/vmime/text.hpp
+++ b/vmime/text.hpp
@@ -53,18 +53,18 @@ public:
 	bool operator==(const text& t) const;
 	bool operator!=(const text& t) const;
 
-	ref  clone() const;
+	shared_ptr  clone() const;
 	void copyFrom(const component& other);
 	text& operator=(const component& other);
 	text& operator=(const text& other);
 
-	const std::vector  > getChildComponents();
+	const std::vector  > getChildComponents();
 
 	/** Add a word at the end of the list.
 	  *
 	  * @param w word to append
 	  */
-	void appendWord(ref  w);
+	void appendWord(shared_ptr  w);
 
 	/** Insert a new word before the specified position.
 	  *
@@ -72,14 +72,14 @@ public:
 	  * the beginning of the list)
 	  * @param w word to insert
 	  */
-	void insertWordBefore(const size_t pos, ref  w);
+	void insertWordBefore(const size_t pos, shared_ptr  w);
 
 	/** Insert a new word after the specified position.
 	  *
 	  * @param pos position of the word before the new word
 	  * @param w word to insert
 	  */
-	void insertWordAfter(const size_t pos, ref  w);
+	void insertWordAfter(const size_t pos, shared_ptr  w);
 
 	/** Remove the word at the specified position.
 	  *
@@ -108,26 +108,26 @@ public:
 	  * @param pos position
 	  * @return word at position 'pos'
 	  */
-	const ref  getWordAt(const size_t pos);
+	const shared_ptr  getWordAt(const size_t pos);
 
 	/** Return the word at the specified position.
 	  *
 	  * @param pos position
 	  * @return word at position 'pos'
 	  */
-	const ref  getWordAt(const size_t pos) const;
+	const shared_ptr  getWordAt(const size_t pos) const;
 
 	/** Return the word list.
 	  *
 	  * @return list of words
 	  */
-	const std::vector  > getWordList() const;
+	const std::vector  > getWordList() const;
 
 	/** Return the word list.
 	  *
 	  * @return list of words
 	  */
-	const std::vector  > getWordList();
+	const std::vector  > getWordList();
 
 
 	/** Return the text converted into the specified charset.
@@ -166,7 +166,7 @@ public:
 	  * @param ch input charset
 	  * @return new text object
 	  */
-	static ref  newFromString(const string& in, const charset& ch);
+	static shared_ptr  newFromString(const string& in, const charset& ch);
 
 	/** This function can be used to make several encoded words from a text.
 	  * All the characters in the text must be in the same specified charset.
@@ -216,7 +216,7 @@ public:
 	  * @param in input string
 	  * @return new text object
 	  */
-	static ref  decodeAndUnfold(const string& in);
+	static shared_ptr  decodeAndUnfold(const string& in);
 
 	/** Decode and unfold text (RFC-2047).
 	  *
@@ -224,7 +224,7 @@ public:
 	  * @param in input string
 	  * @return new text object
 	  */
-	static ref  decodeAndUnfold(const parsingContext& ctx, const string& in);
+	static shared_ptr  decodeAndUnfold(const parsingContext& ctx, const string& in);
 
 	/** Decode and unfold text (RFC-2047), using the default parsing context.
 	  *
@@ -267,7 +267,7 @@ protected:
 
 private:
 
-	std::vector  > m_words;
+	std::vector  > m_words;
 };
 
 
diff --git a/vmime/textPart.hpp b/vmime/textPart.hpp
index 0548de3f..6348f8d7 100644
--- a/vmime/textPart.hpp
+++ b/vmime/textPart.hpp
@@ -73,13 +73,13 @@ public:
 	  *
 	  * @return text of the part
 	  */
-	virtual const ref  getText() const = 0;
+	virtual const shared_ptr  getText() const = 0;
 
 	/** Set the text contained in the part.
 	  *
 	  * @param text text of the part
 	  */
-	virtual void setText(ref  text) = 0;
+	virtual void setText(shared_ptr  text) = 0;
 
 	/** Return the actual body parts this text part is composed of.
 	  * For example, HTML parts are composed of two parts: one "text/html"
@@ -94,7 +94,7 @@ public:
 	  * @param message the message
 	  * @param parent body part into which generate this part
 	  */
-	virtual void generateIn(ref  message, ref  parent) const = 0;
+	virtual void generateIn(shared_ptr  message, shared_ptr  parent) const = 0;
 
 	/** Parse the text part(s) from the specified message.
 	  *
@@ -102,7 +102,7 @@ public:
 	  * @param parent part containing the text part
 	  * @param textPart actual text part
 	  */
-	virtual void parse(ref  message, ref  parent, ref  textPart) = 0;
+	virtual void parse(shared_ptr  message, shared_ptr  parent, shared_ptr  textPart) = 0;
 };
 
 
diff --git a/vmime/textPartFactory.hpp b/vmime/textPartFactory.hpp
index 4112f1ba..f5ce3774 100644
--- a/vmime/textPartFactory.hpp
+++ b/vmime/textPartFactory.hpp
@@ -40,7 +40,7 @@ protected:
 	textPartFactory();
 	~textPartFactory();
 
-	typedef ref  (*AllocFunc)(void);
+	typedef shared_ptr  (*AllocFunc)(void);
 	typedef std::vector  > MapType;
 
 	MapType m_map;
@@ -51,10 +51,10 @@ protected:
 	{
 	public:
 
-		static ref  creator()
+		static shared_ptr  creator()
 		{
 			// Allocate a new object
-			return vmime::create ();
+			return vmime::make_shared ();
 		}
 	};
 #endif // VMIME_BUILDING_DOC
@@ -69,7 +69,7 @@ public:
 		m_map.push_back(MapType::value_type(type, ®isterer::creator));
 	}
 
-	ref  create(const mediaType& type);
+	shared_ptr  create(const mediaType& type);
 };
 
 
diff --git a/vmime/types.hpp b/vmime/types.hpp
index d9f5bec6..1a36ea7a 100644
--- a/vmime/types.hpp
+++ b/vmime/types.hpp
@@ -30,7 +30,51 @@
 #include 
 
 #include "vmime/config.hpp"
-#include "vmime/utility/smartPtr.hpp"
+
+
+#ifndef VMIME_BUILDING_DOC
+
+#if VMIME_SHARED_PTR_USE_CXX
+	// If we are compiling with C++11, use shared_ptr<> from the standard lib
+	#include 
+
+	#define VMIME_SHARED_PTR_NAMESPACE std
+#elif VMIME_SHARED_PTR_USE_BOOST
+	// Else, use boost's shared_ptr<>
+	#include 
+	#include 
+	#include 
+	#include 
+	#include 
+
+	#define VMIME_SHARED_PTR_NAMESPACE boost
+#else
+	#error Either VMIME_SHAREDPTR_USE_CXX or VMIME_SHAREDPTR_USE_BOOST must be set to ON
+#endif
+
+namespace vmime
+{
+	using VMIME_SHARED_PTR_NAMESPACE::shared_ptr;
+	using VMIME_SHARED_PTR_NAMESPACE::weak_ptr;
+	using VMIME_SHARED_PTR_NAMESPACE::make_shared;
+	using VMIME_SHARED_PTR_NAMESPACE::enable_shared_from_this;
+	using VMIME_SHARED_PTR_NAMESPACE::dynamic_pointer_cast;
+	using VMIME_SHARED_PTR_NAMESPACE::const_pointer_cast;
+
+	/** Custom deleter to be used with shared_ptr.
+	  * This is does not actually delete the pointer, and is used
+	  * only for the singleton classes allocated on the stack.
+	  */
+	template 
+	struct noop_shared_ptr_deleter
+	{
+		void operator()(T*) const {}
+	};
+}
+
+#undef VMIME_SHARED_PTR_NAMESPACE
+
+#endif // VMIME_BUILDING_DOC
 
 
 namespace vmime
@@ -48,22 +92,12 @@ namespace vmime
 	typedef unsigned long size_t;
 #endif // !VMIME_HAVE_SIZE_T
 
-	// Some aliases
-	namespace utils = utility;
-
-	using vmime::utility::ref;
-	using vmime::utility::weak_ref;
-	using vmime::utility::null_ref;
-
-	extern const null_ref VMIME_EXPORT null;
-
 	// For compatibility with versions <= 0.7.1 (deprecated)
 	namespace net { }
 	namespace messaging = net;
 }
 
 
-// This is here because 'vmime::ref' need to be declared...
 #include "vmime/object.hpp"
 
 
diff --git a/vmime/utility/childProcess.hpp b/vmime/utility/childProcess.hpp
index 637240c1..ebefcf0a 100644
--- a/vmime/utility/childProcess.hpp
+++ b/vmime/utility/childProcess.hpp
@@ -65,13 +65,13 @@ public:
 	  *
 	  * @return output stream wrapper for child's stdin
 	  */
-	virtual ref  getStdIn() = 0;
+	virtual shared_ptr  getStdIn() = 0;
 
 	/** Return a wrapper to the child process standard output.
 	  *
 	  * @return input stream wrapper for child's stdout
 	  */
-	virtual ref  getStdOut() = 0;
+	virtual shared_ptr  getStdOut() = 0;
 
 	/** Wait for the process to finish.
 	  *
@@ -95,7 +95,7 @@ public:
 	  *
 	  * @param path full path of the process executable file
 	  */
-	virtual ref  create(const utility::file::path& path) const = 0;
+	virtual shared_ptr  create(const utility::file::path& path) const = 0;
 };
 
 
diff --git a/vmime/utility/encoder/encoderFactory.hpp b/vmime/utility/encoder/encoderFactory.hpp
index 9324ba57..763cbd5c 100644
--- a/vmime/utility/encoder/encoderFactory.hpp
+++ b/vmime/utility/encoder/encoderFactory.hpp
@@ -46,10 +46,10 @@ private:
 
 public:
 
-	static encoderFactory* getInstance();
+	static shared_ptr  getInstance();
 
 	/** Information about a registered encoder. */
-	class registeredEncoder : public object
+	class VMIME_EXPORT registeredEncoder : public object
 	{
 	protected:
 
@@ -57,7 +57,7 @@ public:
 
 	public:
 
-		virtual ref  create() const = 0;
+		virtual shared_ptr  create() const = 0;
 
 		virtual const string& getName() const = 0;
 	};
@@ -67,17 +67,13 @@ private:
 	template 
 	class registeredEncoderImpl : public registeredEncoder
 	{
-		friend class vmime::creator;
-
-	protected:
+	public:
 
 		registeredEncoderImpl(const string& name) : m_name(name) { }
 
-	public:
-
-		ref  create() const
+		shared_ptr  create() const
 		{
-			return vmime::create ();
+			return vmime::make_shared ();
 		}
 
 		const string& getName() const
@@ -91,7 +87,7 @@ private:
 	};
 
 
-	std::vector  > m_encoders;
+	std::vector  > m_encoders;
 
 public:
 
@@ -102,7 +98,7 @@ public:
 	template 
 	void registerName(const string& name)
 	{
-		m_encoders.push_back(vmime::create  >(utility::stringUtils::toLower(name)));
+		m_encoders.push_back(vmime::make_shared  >(utility::stringUtils::toLower(name)));
 	}
 
 	/** Create a new encoder instance from an encoding name.
@@ -112,7 +108,7 @@ public:
 	  * @throw exceptions::no_encoder_available if no encoder is registered
 	  * for this encoding
 	  */
-	ref  create(const string& name);
+	shared_ptr  create(const string& name);
 
 	/** Return information about a registered encoder.
 	  *
@@ -121,7 +117,7 @@ public:
 	  * @throw exceptions::no_encoder_available if no encoder is registered
 	  * for this encoding
 	  */
-	const ref  getEncoderByName(const string& name) const;
+	const shared_ptr  getEncoderByName(const string& name) const;
 
 	/** Return the number of registered encoders.
 	  *
@@ -134,13 +130,13 @@ public:
 	  * @param pos position of the registered encoder to return
 	  * @return registered encoder at the specified position
 	  */
-	const ref  getEncoderAt(const size_t pos) const;
+	const shared_ptr  getEncoderAt(const size_t pos) const;
 
 	/** Return a list of all registered encoders.
 	  *
 	  * @return list of registered encoders
 	  */
-	const std::vector  > getEncoderList() const;
+	const std::vector  > getEncoderList() const;
 };
 
 
diff --git a/vmime/utility/file.hpp b/vmime/utility/file.hpp
index df7962e9..c0ba2c5b 100644
--- a/vmime/utility/file.hpp
+++ b/vmime/utility/file.hpp
@@ -61,7 +61,7 @@ public:
 	  *
 	  * @return next file or NULL
 	  */
-	virtual ref  nextElement() = 0;
+	virtual shared_ptr  nextElement() = 0;
 };
 
 
@@ -74,7 +74,7 @@ public:
 
 	virtual ~fileWriter() { }
 
-	virtual ref  getOutputStream() = 0;
+	virtual shared_ptr  getOutputStream() = 0;
 };
 
 
@@ -87,7 +87,7 @@ public:
 
 	virtual ~fileReader() { }
 
-	virtual ref  getInputStream() = 0;
+	virtual shared_ptr  getInputStream() = 0;
 };
 
 
@@ -165,7 +165,7 @@ public:
 	  *
 	  * @return parent directory (or NULL if root)
 	  */
-	virtual ref  getParent() const = 0;
+	virtual shared_ptr  getParent() const = 0;
 
 	/** Rename the file/directory.
 	  *
@@ -185,13 +185,13 @@ public:
 	  *
 	  * @return file writer object
 	  */
-	virtual ref  getFileWriter() = 0;
+	virtual shared_ptr  getFileWriter() = 0;
 
 	/** Return an object capable of reading from this file.
 	  *
 	  * @return file reader object
 	  */
-	virtual ref  getFileReader() = 0;
+	virtual shared_ptr  getFileReader() = 0;
 
 	/** Enumerate files contained in this directory.
 	  *
@@ -199,7 +199,7 @@ public:
 	  * @throw exceptions::not_a_directory if this is not a directory,
 	  * exceptions::filesystem_exception if another error occurs
 	  */
-	virtual ref  getFiles() const = 0;
+	virtual shared_ptr  getFiles() const = 0;
 
 protected:
 
@@ -225,7 +225,7 @@ public:
 	  * @param path full path (absolute) of the file
 	  * @return new file object for the path
 	  */
-	virtual ref  create(const file::path& path) const = 0;
+	virtual shared_ptr  create(const file::path& path) const = 0;
 
 	/** Parse a path contained in a string.
 	  *
diff --git a/vmime/utility/parserInputStreamAdapter.hpp b/vmime/utility/parserInputStreamAdapter.hpp
index 00d38279..16ed6f68 100644
--- a/vmime/utility/parserInputStreamAdapter.hpp
+++ b/vmime/utility/parserInputStreamAdapter.hpp
@@ -43,9 +43,9 @@ public:
 
 	/** @param stream input stream to wrap
 	  */
-	parserInputStreamAdapter(ref  stream);
+	parserInputStreamAdapter(shared_ptr  stream);
 
-	ref  getUnderlyingStream();
+	shared_ptr  getUnderlyingStream();
 
 	bool eof() const;
 	void reset();
@@ -161,7 +161,7 @@ public:
 
 private:
 
-	mutable ref  m_stream;
+	mutable shared_ptr  m_stream;
 };
 
 
diff --git a/vmime/utility/seekableInputStreamRegionAdapter.hpp b/vmime/utility/seekableInputStreamRegionAdapter.hpp
index 8947dfc8..ce73b456 100644
--- a/vmime/utility/seekableInputStreamRegionAdapter.hpp
+++ b/vmime/utility/seekableInputStreamRegionAdapter.hpp
@@ -45,7 +45,7 @@ public:
 	  * @param begin start position in source stream
 	  * @param length region length in source stream
 	  */
-	seekableInputStreamRegionAdapter(ref  stream,
+	seekableInputStreamRegionAdapter(shared_ptr  stream,
 		const size_type begin, const size_type length);
 
 	bool eof() const;
@@ -57,7 +57,7 @@ public:
 
 private:
 
-	ref  m_stream;
+	shared_ptr  m_stream;
 	size_type m_begin;
 	size_type m_length;
 	size_type m_position;
diff --git a/vmime/utility/smartPtr.hpp b/vmime/utility/smartPtr.hpp
deleted file mode 100644
index 791dbc7f..00000000
--- a/vmime/utility/smartPtr.hpp
+++ /dev/null
@@ -1,550 +0,0 @@
-//
-// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard 
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 3 of
-// the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License along
-// with this program; if not, write to the Free Software Foundation, Inc.,
-// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
-// Linking this library statically or dynamically with other modules is making
-// a combined work based on this library.  Thus, the terms and conditions of
-// the GNU General Public License cover the whole combination.
-//
-
-#ifndef VMIME_UTILITY_SMARTPTR_HPP_INCLUDED
-#define VMIME_UTILITY_SMARTPTR_HPP_INCLUDED
-
-
-#include 
-
-#include "vmime/config.hpp"
-
-
-// Forward reference to 'object'
-namespace vmime { class object; }
-
-
-namespace vmime {
-namespace utility {
-
-
-/** Simple auto-delete pointer.
-  */
-
-template 
-class VMIME_EXPORT auto_ptr
-{
-private:
-
-	T* const m_ptr;
-
-public:
-
-	auto_ptr(T* const ptr) : m_ptr(ptr) { }
-	~auto_ptr() { delete (m_ptr); }
-
-	operator T*() { return (m_ptr); }
-
-	T* operator ->() { return (m_ptr); }
-	T& operator *() { return (*m_ptr); }
-};
-
-
-/** Manage the life cycle of an object.
-  */
-
-class VMIME_EXPORT refManager
-{
-protected:
-
-	refManager() {}
-
-public:
-
-	virtual ~refManager() {}
-
-	/** Create a ref manager for the specified object.
-	  *
-	  * @return a new manager
-	  */
-	static refManager* create(object* obj);
-
-	/** Add a strong reference to the managed object.
-	  */
-	virtual bool addStrong() = 0;
-
-	/** Release a strong reference to the managed object.
-	  * If it is the last reference, the object is destroyed.
-	  */
-	virtual void releaseStrong() = 0;
-
-	/** Add a weak reference to the managed object.
-	  */
-	virtual void addWeak() = 0;
-
-	/** Release a weak reference to the managed object.
-	  * If it is the last weak reference, the manager is destroyed.
-	  */
-	virtual void releaseWeak() = 0;
-
-	/** Return a raw pointer to the managed object.
-	  *
-	  * @return pointer to the managed object
-	  */
-	virtual object* getObject() = 0;
-
-	/** Return the number of strong refs to this object.
-	  * For debugging purposes only.
-	  *
-	  * @return strong reference count
-	  */
-	virtual long getStrongRefCount() const = 0;
-
-	/** Return the number of weak refs to this object.
-	  * For debugging purposes only.
-	  *
-	  * @return weak reference count
-	  */
-	virtual long getWeakRefCount() const = 0;
-
-protected:
-
-	void deleteObjectImpl(object* obj);
-};
-
-
-/** Null reference.
-  */
-
-class VMIME_EXPORT null_ref
-{
-};
-
-
-template 
-class weak_ref;
-
-
-/** Shared ownership (strong reference to an object).
-  */
-
-template 
-class VMIME_EXPORT ref
-{
-public:
-
-	template  friend class ref;
-	template  friend class weak_ref;
-
-
-	ref() : m_ptr(0) { }
-	ref(const ref& r) : m_ptr(0) { attach(r); }
-	ref(const null_ref&) : m_ptr(0) { }
-
-	virtual ~ref() throw() { detach(); }
-
-	// Allow creating NULL ref (NULL casts to anything*)
-	ref(class null_pointer*) : m_ptr(0) { }
-
-
-	// Access to wrapped object
-//	operator const T*() const { return m_ptr; }
-	operator const void*() const { return m_ptr; }
-
-	T& operator *() { return *m_ptr; }
-	const T& operator *() const { return *m_ptr; }
-
-	T* operator ->() { return m_ptr; }
-	const T* operator ->() const { return m_ptr; }
-
-	const T* get() const { return m_ptr; }
-	T* get() { return m_ptr; }
-
-
-	// dynamic_cast
-	template 
-	ref  dynamicCast() const
-	{
-		U* p = dynamic_cast (const_cast (m_ptr));
-		if (!p) return ref ();
-
-		if (m_ptr)
-			m_ptr->getRefManager()->addStrong();
-
-		return ref ::fromPtrImpl(p);
-	}
-
-	// static_cast
-	template 
-	ref  staticCast() const
-	{
-		U* p = static_cast (const_cast (m_ptr));
-		if (!p) return ref ();
-
-		if (m_ptr)
-			m_ptr->getRefManager()->addStrong();
-
-		return ref ::fromPtrImpl(p);
-	}
-
-	// const_cast
-	template 
-	ref  constCast() const
-	{
-		U* p = const_cast (m_ptr);
-		if (!p) return ref ();
-
-		if (m_ptr)
-			m_ptr->getRefManager()->addStrong();
-
-		return ref ::fromPtrImpl(p);
-	}
-
-	// Implicit downcast
-	template 
-	operator ref () const
-	{
-		if (m_ptr)
-			m_ptr->getRefManager()->addStrong();
-
-		ref  r;
-		r.m_ptr = m_ptr; // will type check at compile-time (prevent from implicit upcast)
-
-		return r;
-	}
-
-	template 
-	operator ref ()
-	{
-		if (m_ptr)
-			m_ptr->getRefManager()->addStrong();
-
-		ref  r;
-		r.m_ptr = m_ptr; // will type check at compile-time (prevent from implicit upcast)
-
-		return r;
-	}
-
-	template 
-	ref & operator=(const ref & other)
-	{
-		U* ptr = other.m_ptr;   // will type check at compile-time (prevent from implicit upcast)
-
-		if (ptr)
-			ptr->getRefManager()->addStrong();
-
-		detach();
-
-		m_ptr = ptr;
-
-		return *this;
-	}
-
-	// Implicit non-const => const conversion
-	operator ref () const
-	{
-		if (m_ptr)
-			m_ptr->getRefManager()->addStrong();
-
-#if defined(_MSC_VER) // VC++ compiler bug (stack overflow)
-		ref  r;
-		r.m_ptr = m_ptr;
-		return r;
-#else
-		return ref ::fromPtrImpl(m_ptr);
-#endif // defined(_MSC_VER)
-
-	}
-
-	// Copy
-	ref& operator=(const ref& p)
-	{
-		attach(p);
-		return *this;
-	}
-
-	// NULL-pointer comparison
-	bool operator==(const class null_pointer*) const { return m_ptr == 0; }
-	bool operator!=(const class null_pointer*) const { return m_ptr != 0; }
-
-	bool operator==(const null_ref&) const { return m_ptr == 0; }
-	bool operator!=(const null_ref&) const { return m_ptr != 0; }
-
-	/** Create a ref<> from a raw pointer.
-	  *
-	  * WARNING: you should use this function only if you know what
-	  * you are doing. In general, you should create ref objects using
-	  * vmime::create().
-	  *
-	  * When this function returns, the pointer is owned by the ref,
-	  * you should not attempt to delete it manually.
-	  *
-	  * @param ptr raw pointer to encapsulate
-	  * @return a ref which encapsulates the specified raw pointer
-	  */
-	static ref  fromPtr(T* const ptr)
-	{
-		return ref ::fromPtrImpl(ptr);
-	}
-
-	static ref  fromPtrConst(const T* const ptr)
-	{
-		return ref ::fromPtrImpl(ptr);
-	}
-
-	static ref  fromWeak(weak_ref  wr)
-	{
-		refManager* mgr = wr.getManager();
-
-		if (mgr && mgr->addStrong())
-			return ref ::fromPtrImpl(dynamic_cast (mgr->getObject()));
-		else
-			return ref ();
-	}
-
-	static ref  fromWeakConst(weak_ref  wr)
-	{
-		refManager* mgr = wr.getManager();
-
-		if (mgr && mgr->addStrong())
-			return ref ::fromPtrImpl(dynamic_cast (mgr->getObject()));
-		else
-			return ref ();
-	}
-
-protected:
-
-	template 
-	static ref  fromPtrImpl(U* ptr)
-	{
-		ref  r;
-		r.m_ptr = ptr;
-
-		return r;
-	}
-
-	void detach()
-	{
-		if (m_ptr)
-		{
-			if (m_ptr->getRefManager())
-				m_ptr->getRefManager()->releaseStrong();
-
-			m_ptr = 0;
-		}
-	}
-
-	template 
-	void attach(U* const ptr)
-	{
-		if (ptr)
-			ptr->getRefManager()->addStrong();
-
-		detach();
-
-		m_ptr = ptr;
-	}
-
-	template 
-	void attach(const ref & r)
-	{
-		if (r.m_ptr)
-			r.m_ptr->getRefManager()->addStrong();
-
-		detach();
-
-		m_ptr = r.m_ptr;
-	}
-
-private:
-
-	T* m_ptr;
-};
-
-
-
-template 
-bool operator==(const ref & a, const ref & b)
-{
-	return (a.get() == b.get());
-}
-
-template 
-bool operator!=(const ref & a, const ref & b)
-{
-	return (a.get() != b.get());
-}
-
-template 
-bool operator==(const ref & a, T* const p)
-{
-	return (a.get() == p);
-}
-
-template 
-bool operator!=(const ref & a, T* const p)
-{
-	return (a.get() != p);
-}
-
-template 
-bool operator==(T* const p, const ref & a)
-{
-	return (a.get() == p);
-}
-
-template 
-bool operator!=(T* const p, const ref & a)
-{
-	return (a.get() != p);
-}
-
-template 
-bool operator==(const null_ref&, const ref & r)
-{
-	return (r.get() == 0);
-}
-
-template 
-bool operator!=(const null_ref&, const ref & r)
-{
-	return (r.get() != 0);
-}
-
-
-
-/** Weak reference.
-  * Avoid circular references.
-  */
-
-template 
-class VMIME_EXPORT weak_ref
-{
-public:
-
-	template  friend class weak_ref;
-
-
-	weak_ref() : m_mgr(0) { }
-	weak_ref(const ref & r) : m_mgr(0) { attach(r); }
-	weak_ref(const weak_ref& r) : m_mgr(0) { attach(r); }
-	weak_ref(const null_ref&) : m_mgr(0) { }
-	weak_ref(class null_pointer*) : m_mgr(0) { }
-
-	~weak_ref() { detach(); }
-
-	/** Return the manager for the object.
-	  *
-	  * @return pointer to the object which manages the object
-	  * or NULL if the weak reference points to nothing
-	  */
-	refManager* getManager()
-	{
-		return m_mgr;
-	}
-
-	/** Try to acquire a strong reference to the object (const version).
-	  *
-	  * @return strong reference or null reference if the
-	  * object is not available anymore
-	  */
-	ref  acquire() const
-	{
-		return ref ::fromWeakConst(*this);
-	}
-
-	/** Try to acquire a strong reference to the object.
-	  *
-	  * @return strong reference or null reference if the
-	  * object is not available anymore
-	  */
-	ref  acquire()
-	{
-		return ref ::fromWeak(*this);
-	}
-
-	// Implicit non-const => const conversion
-	operator weak_ref () const
-	{
-		if (m_mgr)
-			m_mgr->addWeak();
-
-		weak_ref  r;
-		r.m_mgr = m_mgr;
-
-		return r;
-	}
-
-	template 
-	operator weak_ref () const
-	{
-		if (m_mgr)
-			m_mgr->addWeak();
-
-		weak_ref  r;
-		r.m_mgr = m_mgr;
-
-		return r;
-	}
-
-	// Copy
-	weak_ref& operator=(const weak_ref& p)
-	{
-		attach(p);
-		return *this;
-	}
-
-private:
-
-	void detach()
-	{
-		if (m_mgr)
-		{
-			m_mgr->releaseWeak();
-			m_mgr = 0;
-		}
-	}
-
-	void attach(const ref & r)
-	{
-		if (r.m_ptr)
-			r.m_ptr->getRefManager()->addWeak();
-
-		detach();
-
-		if (r.m_ptr)
-			m_mgr = r.m_ptr->getRefManager();
-		else
-			m_mgr = 0;
-	}
-
-	void attach(const weak_ref& r)
-	{
-		if (r.m_mgr)
-			r.m_mgr->addWeak();
-
-		detach();
-
-		m_mgr = r.m_mgr;
-	}
-
-
-	refManager* m_mgr;
-};
-
-
-} // utility
-} // vmime
-
-
-#endif // VMIME_UTILITY_SMARTPTR_HPP_INCLUDED
diff --git a/vmime/utility/smartPtrInt.hpp b/vmime/utility/smartPtrInt.hpp
deleted file mode 100644
index 36c4ff01..00000000
--- a/vmime/utility/smartPtrInt.hpp
+++ /dev/null
@@ -1,113 +0,0 @@
-//
-// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard 
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 3 of
-// the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License along
-// with this program; if not, write to the Free Software Foundation, Inc.,
-// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
-// Linking this library statically or dynamically with other modules is making
-// a combined work based on this library.  Thus, the terms and conditions of
-// the GNU General Public License cover the whole combination.
-//
-
-#ifndef VMIME_UTILITY_SMARTPTRIMPL_HPP_INCLUDED
-#define VMIME_UTILITY_SMARTPTRIMPL_HPP_INCLUDED
-
-
-#include "vmime/config.hpp"
-#include "vmime/utility/smartPtr.hpp"
-
-#if defined(_WIN32)
-#	include 
-#elif defined(VMIME_HAVE_PTHREAD)
-#	include 
-#endif
-
-
-namespace vmime {
-namespace utility {
-
-
-/** Reference counter for shared pointers.
-  */
-
-class refCounter
-{
-public:
-
-	refCounter(const long initialValue);
-	~refCounter();
-
-	long increment();
-	long decrement();
-
-	operator long() const;
-
-private:
-
-#if defined(_WIN32)
-	long m_value;
-#elif defined(__GNUC__) && (defined(__GLIBCPP__) || defined(__GLIBCXX__))
-	mutable volatile int m_value;
-#elif defined (VMIME_HAVE_PTHREAD)
-	volatile long m_value;
-	pthread_mutex_t m_mutex;
-#else // not thread-safe implementation
-	long m_value;
-#endif
-
-};
-
-
-/** Separate implementation of refManager, to avoid polluting global
-  * namespace with system-specific inclusions/definitions.
-  */
-
-class refManagerImpl : public refManager
-{
-public:
-
-	refManagerImpl(object* obj);
-	~refManagerImpl();
-
-	bool addStrong();
-	void releaseStrong();
-
-	void addWeak();
-	void releaseWeak();
-
-	object* getObject();
-
-	long getStrongRefCount() const;
-	long getWeakRefCount() const;
-
-private:
-
-	void deleteManager();
-	void deleteObject();
-
-
-	object* m_object;
-
-	refCounter m_strongCount;
-	refCounter m_weakCount;
-};
-
-
-} // utility
-} // vmime
-
-
-#endif // VMIME_UTILITY_SMARTPTRIMPL_HPP_INCLUDED
-
diff --git a/vmime/utility/sync/autoLock.hpp b/vmime/utility/sync/autoLock.hpp
index 3f1231b7..c058429d 100644
--- a/vmime/utility/sync/autoLock.hpp
+++ b/vmime/utility/sync/autoLock.hpp
@@ -41,7 +41,7 @@ class VMIME_EXPORT autoLock : public object
 {
 public:
 
-	autoLock(ref  mutex)
+	autoLock(shared_ptr  mutex)
 		: m_mutex(mutex)
 	{
 		m_mutex->lock();
@@ -54,7 +54,7 @@ public:
 
 private:
 
-	ref  m_mutex;
+	shared_ptr  m_mutex;
 };
 
 
diff --git a/vmime/word.hpp b/vmime/word.hpp
index d460ccad..29d2969c 100644
--- a/vmime/word.hpp
+++ b/vmime/word.hpp
@@ -111,7 +111,7 @@ public:
 	  *
 	  * @return a copy of this word
 	  */
-	ref  clone() const;
+	shared_ptr  clone() const;
 
 
 #ifndef VMIME_BUILDING_DOC
@@ -160,11 +160,11 @@ public:
 		 generatorState* state) const;
 #endif
 
-	const std::vector  > getChildComponents();
+	const std::vector  > getChildComponents();
 
 private:
 
-	static ref  parseNext
+	static shared_ptr  parseNext
 		(const parsingContext& ctx,
 		 const string& buffer,
 		 const string::size_type position,
@@ -174,7 +174,7 @@ private:
 		 bool* isEncoded,
 		 bool isFirst);
 
-	static const std::vector  > parseMultiple
+	static const std::vector  > parseMultiple
 		(const parsingContext& ctx,
 		 const string& buffer,
 		 const string::size_type position,
diff --git a/vmime/wordEncoder.hpp b/vmime/wordEncoder.hpp
index b2003ac7..557578fa 100644
--- a/vmime/wordEncoder.hpp
+++ b/vmime/wordEncoder.hpp
@@ -101,7 +101,7 @@ private:
 	charset m_charset;
 	Encoding m_encoding;
 
-	ref  m_encoder;
+	shared_ptr  m_encoder;
 };