Boost/C++11 shared pointers.
This commit is contained in:
parent
7209863438
commit
f9913fa28a
2
.gitignore
vendored
2
.gitignore
vendored
@ -30,6 +30,8 @@ cmake_install.cmake
|
||||
/COPYING.txt
|
||||
build/
|
||||
Makefile
|
||||
export-shared.hpp
|
||||
export-static.hpp
|
||||
|
||||
# Outsourced build test
|
||||
/_build/
|
||||
|
@ -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 <memory>
|
||||
struct A { int foo; };
|
||||
int main() {
|
||||
std::shared_ptr <A> a = std::make_shared <A>(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
|
||||
|
@ -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 <vmime::messaging::folder*> subFolders = folder->getFolders();
|
||||
|
||||
...do something with result...
|
||||
|
||||
for (std::vector <vmime::messaging::folder*>::iterator
|
||||
it = subFolders.begin() ; it != subFolders.end() ; ++it)
|
||||
{
|
||||
delete *it;
|
||||
}
|
||||
|
||||
Now, you can simply write:
|
||||
|
||||
std::vector <ref <vmime::messaging::folder > > 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 <vmime::mailbox> mbox =
|
||||
vmime::create <vmime::mailbox>("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 <vmime::component> foo = ...
|
||||
vmime::ref <vmime::mailbox> mbox = foo.dynamicCast <vmime::mailbox>()
|
||||
|
||||
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 <vmime::component> foo = ...
|
||||
vmime::ref <vmime::mailbox> mbox = foo.staticCast <vmime::mailbox>()
|
||||
|
||||
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 <const vmime::component> foo_const = ...
|
||||
vmime::ref <vmime::component> 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 <vmime::text> t2 = vmime::newFromString("foo", vmime::charset(...));
|
||||
|
@ -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',
|
||||
|
1
cmake/cmake-cxx11/.gitignore
vendored
Normal file
1
cmake/cmake-cxx11/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
build
|
7
cmake/cmake-cxx11/MERGE-TODO
Normal file
7
cmake/cmake-cxx11/MERGE-TODO
Normal file
@ -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
|
||||
|
142
cmake/cmake-cxx11/Modules/CheckCXX11Features.cmake
Normal file
142
cmake/cmake-cxx11/Modules/CheckCXX11Features.cmake
Normal file
@ -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 <eike@sf-mail.de>
|
||||
# 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)
|
@ -0,0 +1,8 @@
|
||||
int main(void)
|
||||
{
|
||||
if (!__func__)
|
||||
return 1;
|
||||
if (!(*__func__))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
@ -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;
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
int main(void)
|
||||
{
|
||||
// must fail because there is no initializer
|
||||
auto i;
|
||||
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
auto foo(int i) -> int {
|
||||
return i - 1;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
return foo(1);
|
||||
}
|
@ -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;
|
||||
}
|
@ -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;
|
||||
}
|
@ -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;
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
#include <cstdint>
|
||||
|
||||
int main()
|
||||
{
|
||||
bool test =
|
||||
(sizeof(int8_t) == 1) &&
|
||||
(sizeof(int16_t) == 2) &&
|
||||
(sizeof(int32_t) == 4) &&
|
||||
(sizeof(int64_t) == 8);
|
||||
return test ? 0 : 1;
|
||||
}
|
@ -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;
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
#include <vector>
|
||||
|
||||
class seq {
|
||||
public:
|
||||
seq(std::initializer_list<int> list);
|
||||
|
||||
int length() const;
|
||||
private:
|
||||
std::vector<int> m_v;
|
||||
};
|
||||
|
||||
seq::seq(std::initializer_list<int> 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;
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
int main()
|
||||
{
|
||||
int ret = 0;
|
||||
return ([&ret]() -> int { return ret; })();
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
int main(void)
|
||||
{
|
||||
long long l;
|
||||
unsigned long long ul;
|
||||
|
||||
return ((sizeof(l) >= 8) && (sizeof(ul) >= 8)) ? 0 : 1;
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
int main(void)
|
||||
{
|
||||
void *v = nullptr;
|
||||
|
||||
return v ? 1 : 0;
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
int main(void)
|
||||
{
|
||||
int i = nullptr;
|
||||
|
||||
return 1;
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
#include <algorithm>
|
||||
#include <regex>
|
||||
|
||||
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<int>(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;
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
#include <cassert>
|
||||
|
||||
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;
|
||||
}
|
@ -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;
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
struct foo {
|
||||
int baz;
|
||||
double bar;
|
||||
};
|
||||
|
||||
int main(void)
|
||||
{
|
||||
return (sizeof(foo::bar) == 4) ? 0 : 1;
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
int main(void)
|
||||
{
|
||||
static_assert(0 < 1, "your ordering of integers is screwed");
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
int main(void)
|
||||
{
|
||||
static_assert(1 < 0, "your ordering of integers is screwed");
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
int Accumulate()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<typename T, typename... Ts>
|
||||
int Accumulate(T v, Ts... vs)
|
||||
{
|
||||
return v + Accumulate(vs...);
|
||||
}
|
||||
|
||||
template<int... Is>
|
||||
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;
|
||||
}
|
33
cmake/cmake-cxx11/Tests/Module/CXX11Features/CMakeLists.txt
Normal file
33
cmake/cmake-cxx11/Tests/Module/CXX11Features/CMakeLists.txt
Normal file
@ -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)
|
@ -0,0 +1,57 @@
|
||||
#if defined(HAS_CXX0X_CSTDINT_H)
|
||||
#include <cstdint>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
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 <stdio.h>
|
||||
|
||||
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;
|
||||
}
|
@ -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@"
|
||||
|
@ -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 <myObject> obj =
|
||||
vmime::create <myObject>("world");
|
||||
vmime::shared_ptr <myObject> obj =
|
||||
vmime::make_shared <myObject>("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 <myObject> obj = vmime::create <myObject>();
|
||||
vmime::shared_ptr <myObject> obj = vmime::make_shared <myObject>();
|
||||
|
||||
// Implicit downcast
|
||||
vmime::ref <myBase> base = obj;
|
||||
vmime::shared_ptr <myBase> base = obj;
|
||||
|
||||
// Explicit upcast
|
||||
vmime::ref <myObject> obj2 = base.dynamicCast <myObject>();
|
||||
vmime::shared_ptr <myObject> obj2 = vmime::dynamicCast <myObject>(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 <child> c)
|
||||
void createChild(vmime::shared_ptr <child> c)
|
||||
{
|
||||
m_child = c;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
vmime::ref <child> m_child;
|
||||
vmime::shared_ptr <child> m_child;
|
||||
};
|
||||
|
||||
class child : public vmime::object
|
||||
{
|
||||
public:
|
||||
|
||||
child(vmime::ref <parent> p)
|
||||
child(vmime::shared_ptr <parent> p)
|
||||
: m_parent(p)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
vmime::ref <parent> m_parent;
|
||||
vmime::shared_ptr <parent> m_parent;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
vmime::ref <parent> p = vmime::create <parent>();
|
||||
vmime::ref <child> c = vmime::create <child>();
|
||||
vmime::shared_ptr <parent> p = vmime::make_shared <parent>();
|
||||
vmime::shared_ptr <child> c = vmime::make_shared <child>();
|
||||
|
||||
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 <parent> m_parent;
|
||||
vmime::weak_ptr <parent> 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 <vmime::mailbox> mbox1 = vmime::create <vmime::mailbox>
|
||||
vmime::shared_ptr <vmime::mailbox> mbox1 = vmime::make_shared <vmime::mailbox>
|
||||
(/* name */ vmime::text("John Doe"), /* email */ "john.doe@acme.com");
|
||||
vmime::ref <vmime::mailbox> mbox2 = vmime::create <vmime::mailbox>
|
||||
vmime::shared_ptr <vmime::mailbox> mbox2 = vmime::make_shared <vmime::mailbox>
|
||||
(/* no name, email only */ "bill@acme.com");
|
||||
|
||||
vmime::ref <vmime::mailboxGroup> grp = vmime::create <vmime::mailboxGroup>();
|
||||
vmime::shared_ptr <vmime::mailboxGroup> grp = vmime::make_shared <vmime::mailboxGroup>();
|
||||
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 <vmime::parameterizedField> field =
|
||||
header->findField("X-Field-That-Contains-Parameters")
|
||||
.dynamicCast <vmime::parameterizedField>();
|
||||
vmime::shared_ptr <vmime::parameterizedField> field =
|
||||
header->findField <vmime::parameterizedField>("X-Field-That-Contains-Parameters");
|
||||
|
||||
// Use setValue() to convert from a basic type to 'text'
|
||||
vmime::ref <vmime::parameter> prm = field->getParameter("my-date-param");
|
||||
vmime::shared_ptr <vmime::parameter> 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 <vmime::contentTypeField> field =
|
||||
header->getField(vmime::fields::CONTENT_TYPE)
|
||||
.dynamicCast <vmime::contentTypeField>();
|
||||
vmime::shared_ptr <vmime::contentTypeField> field =
|
||||
header->getField <vmime::contentTypeField>(vmime::fields::CONTENT_TYPE);
|
||||
|
||||
// 1. First solution: the "hard" way
|
||||
vmime::ref <vmime::parameter> prm = field->findParameter("charset");
|
||||
vmime::shared_ptr <vmime::parameter> prm = field->findParameter("charset");
|
||||
const charset ch1 = prm->getValueAs <vmime::charset>();
|
||||
|
||||
// 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 <vmime::message> msg;
|
||||
vmime::shared_ptr <vmime::message> msg;
|
||||
|
||||
// Obtains a reference to the body contents
|
||||
vmime::ref <vmime::body> body = msg->getBody();
|
||||
vmime::ref <vmime::contentHandler> cts = body->getContents();
|
||||
vmime::shared_ptr <vmime::body> body = msg->getBody();
|
||||
vmime::shared_ptr <vmime::contentHandler> 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 <vmime::bodyPart> part; // suppose we have a body part
|
||||
vmime::shared_ptr <vmime::bodyPart> part; // suppose we have a body part
|
||||
|
||||
// Create a new content handler from a string
|
||||
vmime::ref <vmime::contentHandler> cth =
|
||||
vmime::create <vmime::stringContentHandler>("Put body contents here");
|
||||
vmime::shared_ptr <vmime::contentHandler> cth =
|
||||
vmime::make_shared <vmime::stringContentHandler>("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 <utility::stream> dataStream =
|
||||
vmime::create <vmime::utility::inputStreamPointerAdapter>(fileStream);
|
||||
vmime::shared_ptr <utility::stream> dataStream =
|
||||
vmime::make_shared <vmime::utility::inputStreamPointerAdapter>(fileStream);
|
||||
|
||||
// NOTE: 'fileStream' will be automatically deleted
|
||||
// when 'dataStream' is deleted
|
||||
|
||||
// Create a new content handler
|
||||
vmime::ref <contentHandler> data =
|
||||
vmime::create <vmime::streamContentHandler>(dataStream, 0);
|
||||
vmime::shared_ptr <contentHandler> data =
|
||||
vmime::make_shared <vmime::streamContentHandler>(dataStream, 0);
|
||||
|
||||
// Now create the attachment
|
||||
ref <vmime::attachment> att = vmime::create <vmime::defaultAttachment>
|
||||
ref <vmime::attachment> att = vmime::make_shared <vmime::defaultAttachment>
|
||||
(
|
||||
/* 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 <vmime::message> msg; // we have a message
|
||||
vmime::shared_ptr <vmime::message> msg; // we have a message
|
||||
|
||||
// Obtain the content handler first
|
||||
vmime::ref <vmime::body> body = msg->getBody();
|
||||
vmime::ref <const vmime::contentHandler> cth = body->getContents();
|
||||
vmime::shared_ptr <vmime::body> body = msg->getBody();
|
||||
vmime::shared_ptr <const vmime::contentHandler> cth = body->getContents();
|
||||
|
||||
// Then, extract and convert the contents
|
||||
vmime::utility::outputStreamAdapter out(std::cout);
|
||||
@ -676,7 +686,7 @@ outText.createFromString(inText, inCharset);
|
||||
// . <utf-8> "téléphone "
|
||||
// . <us-ascii> "mobile"
|
||||
|
||||
vmime::ref <vmime::header> header = myMessage->getHeader();
|
||||
vmime::shared_ptr <vmime::header> 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 <vmime::message> msg; // we have a message
|
||||
vmime::shared_ptr <vmime::message> 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 <vmime::utility::encoder::encoder> enc =
|
||||
vmime::shared_ptr <vmime::utility::encoder::encoder> 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 <vmime::utility::encoder::encoderFactory> 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 <const vmime::utility::encoder::encoderFactory::registeredEncoder>
|
||||
vmime::shared_ptr <const vmime::utility::encoder::encoderFactory::registeredEncoder>
|
||||
enc = ef->getEncoderAt(i);
|
||||
|
||||
std::cout << " * " << enc->getName() << std::endl;
|
||||
|
||||
// Create an instance of the encoder to get its properties
|
||||
vmime::ref <vmime::utility::encoder::encoder> e = enc->create();
|
||||
vmime::shared_ptr <vmime::utility::encoder::encoder> e = enc->create();
|
||||
|
||||
std::vector <vmime::string> props = e->getAvailableProperties();
|
||||
std::vector <vmime::string>::const_iterator it;
|
||||
|
@ -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}
|
||||
|
@ -36,22 +36,22 @@ vmime::utility::outputStreamStringAdapter os(data);
|
||||
vmime::utility::bufferedStreamCopy(is, os);
|
||||
|
||||
// Actually parse the message
|
||||
vmime::ref <vmime::message> msg = vmime::create <vmime::message>();
|
||||
vmime::shared_ptr <vmime::message> msg = vmime::make_shared <vmime::message>();
|
||||
msg->parse(data);
|
||||
|
||||
vmime::ref <vmime::header> hdr = msg->getHeader();
|
||||
vmime::ref <vmime::body> bdy = msg->getBody();
|
||||
vmime::shared_ptr <vmime::header> hdr = msg->getHeader();
|
||||
vmime::shared_ptr <vmime::body> 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 <vmime::text>()->getConvertedText(ch)
|
||||
<< hdr->Subject()->getValue <vmime::text>()->getConvertedText(ch)
|
||||
<< std::endl
|
||||
<< "It was sent by: "
|
||||
<< hdr->From()->getValue().dynamicCast <vmime::mailbox>()->getName().getConvertedText(ch)
|
||||
<< " (email: " << hdr->From()->getValue().dynamicCast<vmime::mailbox>()->getEmail() << ")"
|
||||
<< hdr->From()->getValue <vmime::mailbox>()->getName().getConvertedText(ch)
|
||||
<< " (email: " << hdr->From()->getValue <vmime::mailbox>()->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 <vmime::message> msg = vmime::create <vmime::message>();
|
||||
vmime::shared_ptr <vmime::message> msg = vmime::make_shared <vmime::message>();
|
||||
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 <const vmime::attachment> att = mp.getAttachmentAt(i);
|
||||
vmime::shared_ptr <const vmime::attachment> 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 <const vmime::textPart> tp = mp.getTextPartAt(i);
|
||||
vmime::shared_ptr <const vmime::textPart> tp = mp.getTextPartAt(i);
|
||||
|
||||
// text/html
|
||||
if (tp->getType().getSubType() == vmime::mediaTypes::TEXT_HTML)
|
||||
{
|
||||
vmime::ref <const vmime::htmlTextPart> htp =
|
||||
tp.dynamicCast <const vmime::htmlTextPart>();
|
||||
vmime::shared_ptr <const vmime::htmlTextPart> htp =
|
||||
vmime::dynamicCast <const vmime::htmlTextPart>(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 <const vmime::htmlTextPart::embeddedObject> obj =
|
||||
vmime::shared_ptr <const vmime::htmlTextPart::embeddedObject> 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 <vmime::message> msg = vmime::create <vmime::message>();
|
||||
vmime::shared_ptr <vmime::message> msg = vmime::make_shared <vmime::message>();
|
||||
|
||||
vmime::ref <vmime::header> hdr = msg->getHeader();
|
||||
vmime::ref <vmime::body> bdy = msg->getBody();
|
||||
vmime::shared_ptr <vmime::header> hdr = msg->getHeader();
|
||||
vmime::shared_ptr <vmime::body> bdy = msg->getBody();
|
||||
|
||||
vmime::headerFieldFactory* hfFactory =
|
||||
vmime::shared_ptr <vmime::headerFieldFactory> hfFactory =
|
||||
vmime::headerFieldFactory::getInstance();
|
||||
|
||||
// Append a 'Date:' field
|
||||
vmime::ref <vmime::headerField> dateField =
|
||||
vmime::shared_ptr <vmime::headerField> dateField =
|
||||
hfFactory->create(vmime::fields::DATE);
|
||||
|
||||
dateField->setValue(vmime::datetime::now());
|
||||
hdr->appendField(dateField);
|
||||
|
||||
// Append a 'Subject:' field
|
||||
vmime::ref <vmime::headerField> subjectField =
|
||||
vmime::shared_ptr <vmime::headerField> subjectField =
|
||||
hfFactory->create(vmime::fields::SUBJECT);
|
||||
|
||||
subjectField->setValue(vmime::text("Message subject"));
|
||||
hdr->appendField(subjectField);
|
||||
|
||||
// Append a 'From:' field
|
||||
vmime::ref <vmime::headerField> fromField =
|
||||
vmime::shared_ptr <vmime::headerField> fromField =
|
||||
hfFactory->create(vmime::fields::FROM);
|
||||
|
||||
fromField->setValue
|
||||
(vmime::create <vmime::mailbox>("me@vmime.org"));
|
||||
(vmime::make_shared <vmime::mailbox>("me@vmime.org"));
|
||||
hdr->appendField(fromField);
|
||||
|
||||
// Append a 'To:' field
|
||||
vmime::ref <vmime::headerField> toField =
|
||||
vmime::shared_ptr <vmime::headerField> toField =
|
||||
hfFactory->create(vmime::fields::TO);
|
||||
|
||||
vmime::ref <vmime::mailboxList> recipients =
|
||||
vmime::create <vmime::mailboxList>();
|
||||
vmime::shared_ptr <vmime::mailboxList> recipients =
|
||||
vmime::make_shared <vmime::mailboxList>();
|
||||
|
||||
recipients->appendMailbox
|
||||
(vmime::create <vmime::mailbox>("you@vmime.org"));
|
||||
(vmime::make_shared <vmime::mailbox>("you@vmime.org"));
|
||||
|
||||
toField->setValue(recipients);
|
||||
hdr->appendField(toField);
|
||||
|
||||
// Set the body contents
|
||||
bdy->setContents(vmime::create <vmime::stringContentHandler>
|
||||
bdy->setContents(vmime::make_shared <vmime::stringContentHandler>
|
||||
("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 <vmime::mailbox>("you@vmime.org"));
|
||||
(vmime::make_shared <vmime::mailbox>("you@vmime.org"));
|
||||
|
||||
mb.getTextPart()->setCharset(vmime::charsets::ISO8859_15);
|
||||
mb.getTextPart()->setText(vmime::create <vmime::stringContentHandler>
|
||||
mb.getTextPart()->setText(vmime::make_shared <vmime::stringContentHandler>
|
||||
("This is the text of your message..."));
|
||||
|
||||
// Message construction
|
||||
vmime::ref <vmime::message> msg = mb.construct();
|
||||
vmime::shared_ptr <vmime::message> 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 <vmime::fileAttachment> att =
|
||||
vmime::create <vmime::fileAttachment>
|
||||
vmime::shared_ptr <vmime::fileAttachment> att =
|
||||
vmime::make_shared <vmime::fileAttachment>
|
||||
(
|
||||
/* 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 <vmime::mailbox>("you@vmime.org"));
|
||||
(vmime::make_shared <vmime::mailbox>("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 <vmime::htmlTextPart> textPart =
|
||||
mb.getTextPart().dynamicCast <vmime::htmlTextPart>();
|
||||
vmime::shared_ptr <vmime::htmlTextPart> textPart =
|
||||
vmime::dynamicCast <vmime::htmlTextPart>(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 <vmime::stringContentHandler>
|
||||
textPart->setText(vmime::make_shared <vmime::stringContentHandler>
|
||||
("This is the <b>HTML text</b>, and the image:<br/>"
|
||||
"<img src=\"") + id + vmime::string("\"/>"));
|
||||
|
||||
textPart->setPlainText(vmime::create <vmime::stringContentHandler>
|
||||
textPart->setPlainText(vmime::make_shared <vmime::stringContentHandler>
|
||||
("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 <vmime::utility::file> imageFile =
|
||||
vmime::shared_ptr <vmime::utility::file> imageFile =
|
||||
fs->create(fs->stringToPath("/path/to/image.jpg"));
|
||||
|
||||
vmime::ref <vmime::contentHandler> imageCts =
|
||||
vmime::create <vmime::streamContentHandler>
|
||||
vmime::shared_ptr <vmime::contentHandler> imageCts =
|
||||
vmime::make_shared <vmime::streamContentHandler>
|
||||
(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 <vmime::bodyPart> part; // suppose we have a body part
|
||||
vmime::shared_ptr <vmime::bodyPart> part; // suppose we have a body part
|
||||
|
||||
if (vmime::attachmentHelper::isBodyPartAnAttachment(part))
|
||||
{
|
||||
// The body part contains an attachment, get it
|
||||
vmime::ref <const vmime::attachment> attach =
|
||||
vmime::shared_ptr <const vmime::attachment> 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 <vmime::message> msg; // suppose we have a message
|
||||
vmime::shared_ptr <vmime::message> msg; // suppose we have a message
|
||||
|
||||
const std::vector <ref <const attachment> > 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 <vmime::message> msg; // suppose we have a message
|
||||
vmime::shared_ptr <vmime::message> msg; // suppose we have a message
|
||||
|
||||
// Create an attachment
|
||||
vmime::ref <vmime::fileAttachment> att =
|
||||
vmime::create <vmime::fileAttachment>
|
||||
vmime::shared_ptr <vmime::fileAttachment> att =
|
||||
vmime::make_shared <vmime::fileAttachment>
|
||||
(
|
||||
/* full path to file */ "/home/vincent/paris.jpg",
|
||||
/* content type */ vmime::mediaType("image/jpeg),
|
||||
|
@ -68,7 +68,7 @@ services. Before using a messaging service, you must create and
|
||||
initialize a session object:
|
||||
|
||||
\begin{lstlisting}
|
||||
vmime::ref <net::session> theSession = vmime::create <net::session>();
|
||||
vmime::shared_ptr <net::session> theSession = vmime::make_shared <net::session>();
|
||||
\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 <vmime::net::store> st = sess->getStore(url);
|
||||
vmime::shared_ptr <vmime::net::store> st = sess->getStore(url);
|
||||
\end{lstlisting}
|
||||
|
||||
and for transport services:
|
||||
|
||||
\begin{lstlisting}
|
||||
vmime::utility:url url("smtp://smtp.example.com");
|
||||
vmime::ref <vmime::net::transport> tr = sess->getTransport(url);
|
||||
vmime::shared_ptr <vmime::net::transport> 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 <vmime::net::session> sess; // Suppose we have a session
|
||||
vmime::shared_ptr <vmime::net::session> 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 <vmime::net::session> sess =
|
||||
vmime::create <vmime::net::session>();
|
||||
vmime::shared_ptr <vmime::net::session> sess =
|
||||
vmime::make_shared <vmime::net::session>();
|
||||
|
||||
// Next, initialize a service which will use our authenticator
|
||||
vmime::ref <vmime::net::store> st =
|
||||
vmime::shared_ptr <vmime::net::store> st =
|
||||
sess->getStore(vmime::utility::url("imap://imap.example.com"),
|
||||
/* use our authenticator */ vmime::create <myAuthenticator>());
|
||||
/* use our authenticator */ vmime::make_shared <myAuthenticator>());
|
||||
\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 <vmime::ref <mechanism > getAcceptableMechanisms
|
||||
(const std::vector <vmime::ref <mechanism> >& available,
|
||||
vmime::ref <mechanism> suggested) const
|
||||
const std::vector <vmime::shared_ptr <mechanism> > getAcceptableMechanisms
|
||||
(const std::vector <vmime::shared_ptr <mechanism> >& available,
|
||||
vmime::shared_ptr <mechanism> 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 <mechanism> mech)
|
||||
void setSASLMechanism(vmime::shared_ptr <mechanism> 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 <vmime::net::session> sess =
|
||||
vmime::create <vmime::net::session>();
|
||||
vmime::shared_ptr <vmime::net::session> sess =
|
||||
vmime::make_shared <vmime::net::session>();
|
||||
|
||||
// Create an instance of the transport service
|
||||
vmime::ref <vmime::net::transport> tr = sess->getTransport(url);
|
||||
vmime::shared_ptr <vmime::net::transport> 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 <vmime::mailbox>("you@example.org"));
|
||||
to.appendMailbox(vmime::make_shared <vmime::mailbox>("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 <vmime::net::session> sess =
|
||||
vmime::create <vmime::net::session>();
|
||||
vmime::shared_ptr <vmime::net::session> sess =
|
||||
vmime::make_shared <vmime::net::session>();
|
||||
|
||||
// Create an instance of the transport service
|
||||
vmime::ref <vmime::net::store> store = sess->getStore(url);
|
||||
vmime::shared_ptr <vmime::net::store> 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 <vmime::net::folder> fld = store->getFolder(path);
|
||||
vmime::shared_ptr <vmime::net::folder> 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 <vmime::net::message> msg = allMessages[i];
|
||||
vmime::shared_ptr <vmime::net::message> 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 <const vmime::header> hdr = msg->getHeader();
|
||||
vmime::shared_ptr <const vmime::header> 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 <vmime::net::folder> folder = store->getDefaultFolder();
|
||||
vmime::ref <vmime::net::message> msg = folder->getMessage(1);
|
||||
vmime::shared_ptr <vmime::net::folder> folder = store->getDefaultFolder();
|
||||
vmime::shared_ptr <vmime::net::message> 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 <vmime::net::folder> folder = store->getDefaultFolder();
|
||||
vmime::shared_ptr <vmime::net::folder> folder = store->getDefaultFolder();
|
||||
|
||||
folder->deleteMessages(vmime::net::messageSet::byNumber(/* from */ 2, /* to */ 3));
|
||||
|
||||
@ -785,7 +785,7 @@ public:
|
||||
|
||||
ref <timeoutHandler> create()
|
||||
{
|
||||
return vmime::create <myTimeoutHandler>();
|
||||
return vmime::make_shared <myTimeoutHandler>();
|
||||
}
|
||||
};
|
||||
\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 <myTimeoutHandlerFactory>());
|
||||
theService->setTimeoutHandlerFactory(vmime::make_shared <myTimeoutHandlerFactory>());
|
||||
\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 <vmime::net::store> store =
|
||||
vmime::shared_ptr <vmime::net::store> 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::security::cert::X509Certificate>
|
||||
vmime::shared_ptr <vmime::security::cert::X509Certificate>
|
||||
loadX509CertificateFromFile(const std::string& path)
|
||||
{
|
||||
std::ifstream certFile;
|
||||
@ -925,7 +925,7 @@ vmime::ref <vmime::security::cert::X509Certificate>
|
||||
}
|
||||
|
||||
vmime::utility::inputStreamAdapter is(certFile);
|
||||
vmime::ref <vmime::security::cert::X509Certificate> cert;
|
||||
vmime::shared_ptr <vmime::security::cert::X509Certificate> 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 <vmime::security::cert::defaultCertificateVerifier> vrf =
|
||||
vmime::create <vmime::security::cert::defaultCertificateVerifier>();
|
||||
vmime::shared_ptr <vmime::security::cert::defaultCertificateVerifier> vrf =
|
||||
vmime::make_shared <vmime::security::cert::defaultCertificateVerifier>();
|
||||
|
||||
// Load root CAs (such as Verisign or Thawte)
|
||||
std::vector <vmime::ref <vmime::security::cert::X509Certificate> > rootCAs;
|
||||
std::vector <vmime::shared_ptr <vmime::security::cert::X509Certificate> > 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 <vmime::ref <vmime::security::cert::X509Certificate> > trusted;
|
||||
std::vector <vmime::shared_ptr <vmime::security::cert::X509Certificate> > 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 <certificateChain> certs)
|
||||
void verify(vmime::shared_ptr <certificateChain> certs)
|
||||
{
|
||||
// Obtain the subject's certificate
|
||||
vmime::ref <vmime::security::cert::certificate> cert = chain->getAt(0);
|
||||
vmime::shared_ptr <vmime::security::cert::certificate> 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 <myCertVerifier>());
|
||||
theService->setCertificateVerifier(vmime::make_shared <myCertVerifier>());
|
||||
\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 <vmime::net::session> sess = /* ... */;
|
||||
vmime::shared_ptr <vmime::net::session> sess = /* ... */;
|
||||
|
||||
vmime::ref <vmime::net::tls::TLSProperties> tlsProps =
|
||||
vmime::create <vmime::net::tls::TLSProperties>();
|
||||
vmime::shared_ptr <vmime::net::tls::TLSProperties> tlsProps =
|
||||
vmime::make_shared <vmime::net::tls::TLSProperties>();
|
||||
|
||||
// for OpenSSL
|
||||
tlsProps->setCipherString("HIGH:!ADH:@STRENGTH");
|
||||
|
@ -52,24 +52,24 @@ int main()
|
||||
mb.setExpeditor(vmime::mailbox("me@somewhere.com"));
|
||||
|
||||
vmime::addressList to;
|
||||
to.appendAddress(vmime::create <vmime::mailbox>("you@elsewhere.com"));
|
||||
to.appendAddress(vmime::make_shared <vmime::mailbox>("you@elsewhere.com"));
|
||||
|
||||
mb.setRecipients(to);
|
||||
|
||||
vmime::addressList bcc;
|
||||
bcc.appendAddress(vmime::create <vmime::mailbox>("you-bcc@nowhere.com"));
|
||||
bcc.appendAddress(vmime::make_shared <vmime::mailbox>("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 <vmime::stringContentHandler>(
|
||||
mb.getTextPart()->setText(vmime::make_shared <vmime::stringContentHandler>(
|
||||
"I'm writing this short text to test message construction " \
|
||||
"using the vmime::messageBuilder component."));
|
||||
|
||||
// Construction
|
||||
vmime::ref <vmime::message> msg = mb.construct();
|
||||
vmime::shared_ptr <vmime::message> msg = mb.construct();
|
||||
|
||||
// Raw text generation
|
||||
std::cout << "Generated message:" << std::endl;
|
||||
|
@ -52,24 +52,24 @@ int main()
|
||||
mb.setExpeditor(vmime::mailbox("me@somewhere.com"));
|
||||
|
||||
vmime::addressList to;
|
||||
to.appendAddress(vmime::create <vmime::mailbox>("you@elsewhere.com"));
|
||||
to.appendAddress(vmime::make_shared <vmime::mailbox>("you@elsewhere.com"));
|
||||
|
||||
mb.setRecipients(to);
|
||||
|
||||
vmime::addressList bcc;
|
||||
bcc.appendAddress(vmime::create <vmime::mailbox>("you-bcc@nowhere.com"));
|
||||
bcc.appendAddress(vmime::make_shared <vmime::mailbox>("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 <vmime::stringContentHandler>(
|
||||
mb.getTextPart()->setText(vmime::make_shared <vmime::stringContentHandler>(
|
||||
"I'm writing this short text to test message construction " \
|
||||
"with attachment, using the vmime::messageBuilder component."));
|
||||
|
||||
// Adding an attachment
|
||||
vmime::ref <vmime::fileAttachment> a = vmime::create <vmime::fileAttachment>
|
||||
vmime::shared_ptr <vmime::fileAttachment> a = vmime::make_shared <vmime::fileAttachment>
|
||||
(
|
||||
"./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 <vmime::message> msg = mb.construct();
|
||||
vmime::shared_ptr <vmime::message> msg = mb.construct();
|
||||
|
||||
// Raw text generation
|
||||
vmime::string dataToSend = msg->generate();
|
||||
|
@ -52,12 +52,12 @@ int main()
|
||||
mb.setExpeditor(vmime::mailbox("me@somewhere.com"));
|
||||
|
||||
vmime::addressList to;
|
||||
to.appendAddress(vmime::create <vmime::mailbox>("you@elsewhere.com"));
|
||||
to.appendAddress(vmime::make_shared <vmime::mailbox>("you@elsewhere.com"));
|
||||
|
||||
mb.setRecipients(to);
|
||||
|
||||
vmime::addressList bcc;
|
||||
bcc.appendAddress(vmime::create <vmime::mailbox>("you-bcc@nowhere.com"));
|
||||
bcc.appendAddress(vmime::make_shared <vmime::mailbox>("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>();
|
||||
vmime::htmlTextPart& textPart = *vmime::dynamicCast <vmime::htmlTextPart>(mb.getTextPart());
|
||||
|
||||
// -- embed an image (the returned "CID" (content identifier) is used to reference
|
||||
// -- the image into HTML content).
|
||||
vmime::ref <vmime::utility::fileSystemFactory> fs =
|
||||
vmime::shared_ptr <vmime::utility::fileSystemFactory> fs =
|
||||
vmime::platform::getHandler()->getFileSystemFactory();
|
||||
|
||||
vmime::ref <vmime::utility::file> imageFile =
|
||||
vmime::shared_ptr <vmime::utility::file> imageFile =
|
||||
fs->create(fs->stringToPath("/path/to/image.jpg"));
|
||||
|
||||
vmime::ref <vmime::utility::fileReader> fileReader =
|
||||
vmime::shared_ptr <vmime::utility::fileReader> fileReader =
|
||||
imageFile->getFileReader();
|
||||
|
||||
vmime::ref <vmime::contentHandler> imageCts =
|
||||
vmime::create <vmime::streamContentHandler>
|
||||
vmime::shared_ptr <vmime::contentHandler> imageCts =
|
||||
vmime::make_shared <vmime::streamContentHandler>
|
||||
(fileReader->getInputStream(), imageFile->getLength());
|
||||
|
||||
vmime::ref <const vmime::htmlTextPart::embeddedObject> obj = textPart.addObject
|
||||
vmime::shared_ptr <const vmime::htmlTextPart::embeddedObject> obj = textPart.addObject
|
||||
(imageCts, vmime::mediaType(vmime::mediaTypes::IMAGE, vmime::mediaTypes::IMAGE_JPEG));
|
||||
|
||||
// -- message text
|
||||
textPart.setText(vmime::create <vmime::stringContentHandler>
|
||||
textPart.setText(vmime::make_shared <vmime::stringContentHandler>
|
||||
(vmime::string("This is the <b>HTML text</b>.<br/>"
|
||||
"<img src=\"") + obj->getReferenceId() + vmime::string("\"/>")));
|
||||
textPart.setPlainText(vmime::create <vmime::stringContentHandler>
|
||||
textPart.setPlainText(vmime::make_shared <vmime::stringContentHandler>
|
||||
("This is the plain text (without HTML formatting)."));
|
||||
|
||||
// Construction
|
||||
vmime::ref <vmime::message> msg = mb.construct();
|
||||
vmime::shared_ptr <vmime::message> msg = mb.construct();
|
||||
|
||||
// Raw text generation
|
||||
vmime::string dataToSend = msg->generate();
|
||||
|
@ -31,8 +31,8 @@
|
||||
|
||||
|
||||
// Global session object
|
||||
static vmime::ref <vmime::net::session> g_session
|
||||
= vmime::create <vmime::net::session>();
|
||||
static vmime::shared_ptr <vmime::net::session> g_session
|
||||
= vmime::make_shared <vmime::net::session>();
|
||||
|
||||
|
||||
#if VMIME_HAVE_SASL_SUPPORT
|
||||
@ -40,9 +40,9 @@ static vmime::ref <vmime::net::session> g_session
|
||||
// SASL authentication handler
|
||||
class interactiveAuthenticator : public vmime::security::sasl::defaultSASLAuthenticator
|
||||
{
|
||||
const std::vector <vmime::ref <vmime::security::sasl::SASLMechanism> > getAcceptableMechanisms
|
||||
(const std::vector <vmime::ref <vmime::security::sasl::SASLMechanism> >& available,
|
||||
vmime::ref <vmime::security::sasl::SASLMechanism> suggested) const
|
||||
const std::vector <vmime::shared_ptr <vmime::security::sasl::SASLMechanism> > getAcceptableMechanisms
|
||||
(const std::vector <vmime::shared_ptr <vmime::security::sasl::SASLMechanism> >& available,
|
||||
vmime::shared_ptr <vmime::security::sasl::SASLMechanism> 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 <vmime::security::sasl::SASLMechanism> mech)
|
||||
void setSASLMechanism(vmime::shared_ptr <vmime::security::sasl::SASLMechanism> 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 <vmime::security::cert::certificateChain> chain, const vmime::string& hostname)
|
||||
void verify(vmime::shared_ptr <vmime::security::cert::certificateChain> chain, const vmime::string& hostname)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -158,7 +158,7 @@ public:
|
||||
catch (vmime::exceptions::certificate_verification_exception&)
|
||||
{
|
||||
// Obtain subject's certificate
|
||||
vmime::ref <vmime::security::cert::certificate> cert = chain->getAt(0);
|
||||
vmime::shared_ptr <vmime::security::cert::certificate> 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
|
||||
<vmime::security::cert::X509Certificate>());
|
||||
m_trustedCerts.push_back(vmime::dynamicCast
|
||||
<vmime::security::cert::X509Certificate>(cert));
|
||||
|
||||
setX509TrustedCerts(m_trustedCerts);
|
||||
defaultCertificateVerifier::verify(chain, hostname);
|
||||
@ -191,11 +191,11 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
static std::vector <vmime::ref <vmime::security::cert::X509Certificate> > m_trustedCerts;
|
||||
static std::vector <vmime::shared_ptr <vmime::security::cert::X509Certificate> > m_trustedCerts;
|
||||
};
|
||||
|
||||
|
||||
std::vector <vmime::ref <vmime::security::cert::X509Certificate> >
|
||||
std::vector <vmime::shared_ptr <vmime::security::cert::X509Certificate> >
|
||||
interactiveCertificateVerifier::m_trustedCerts;
|
||||
|
||||
#endif // VMIME_HAVE_TLS_SUPPORT
|
||||
@ -208,7 +208,8 @@ std::vector <vmime::ref <vmime::security::cert::X509Certificate> >
|
||||
*/
|
||||
static const std::string findAvailableProtocols(const vmime::net::service::Type type)
|
||||
{
|
||||
vmime::net::serviceFactory* sf = vmime::net::serviceFactory::getInstance();
|
||||
vmime::shared_ptr <vmime::net::serviceFactory> 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 <const vmime::net::messageStructure> s, const int level = 0)
|
||||
static void printStructure(vmime::shared_ptr <const vmime::net::messageStructure> s, const int level = 0)
|
||||
{
|
||||
for (int i = 0 ; i < s->getPartCount() ; ++i)
|
||||
{
|
||||
vmime::ref <const vmime::net::messagePart> part = s->getPartAt(i);
|
||||
vmime::shared_ptr <const vmime::net::messagePart> part = s->getPartAt(i);
|
||||
|
||||
for (int j = 0 ; j < level * 2 ; ++j)
|
||||
std::cout << " ";
|
||||
@ -311,7 +312,7 @@ static void printStructure(vmime::ref <const vmime::net::messageStructure> s, co
|
||||
}
|
||||
|
||||
|
||||
static const vmime::string getFolderPathString(vmime::ref <vmime::net::folder> f)
|
||||
static const vmime::string getFolderPathString(vmime::shared_ptr <vmime::net::folder> f)
|
||||
{
|
||||
const vmime::string n = f->getName().getBuffer();
|
||||
|
||||
@ -321,7 +322,7 @@ static const vmime::string getFolderPathString(vmime::ref <vmime::net::folder> f
|
||||
}
|
||||
else
|
||||
{
|
||||
vmime::ref <vmime::net::folder> p = f->getParent();
|
||||
vmime::shared_ptr <vmime::net::folder> p = f->getParent();
|
||||
return getFolderPathString(p) + n + "/";
|
||||
}
|
||||
}
|
||||
@ -331,14 +332,14 @@ static const vmime::string getFolderPathString(vmime::ref <vmime::net::folder> f
|
||||
*
|
||||
* @param folder current folder
|
||||
*/
|
||||
static void printFolders(vmime::ref <vmime::net::folder> folder, const int level = 0)
|
||||
static void printFolders(vmime::shared_ptr <vmime::net::folder> folder, const int level = 0)
|
||||
{
|
||||
for (int j = 0 ; j < level * 2 ; ++j)
|
||||
std::cout << " ";
|
||||
|
||||
std::cout << getFolderPathString(folder) << std::endl;
|
||||
|
||||
std::vector <vmime::ref <vmime::net::folder> > subFolders = folder->getFolders(false);
|
||||
std::vector <vmime::shared_ptr <vmime::net::folder> > 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 <vmime::net::transport> tr =
|
||||
g_session->getTransport(url, vmime::create <interactiveAuthenticator>());
|
||||
vmime::shared_ptr <vmime::net::transport> tr =
|
||||
g_session->getTransport(url, vmime::make_shared <interactiveAuthenticator>());
|
||||
|
||||
#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 <interactiveCertificateVerifier>());
|
||||
(vmime::make_shared <interactiveCertificateVerifier>());
|
||||
|
||||
#endif // VMIME_HAVE_TLS_SUPPORT
|
||||
|
||||
@ -435,7 +436,7 @@ static void sendMessage()
|
||||
cont = (toString.size() != 0);
|
||||
|
||||
if (cont)
|
||||
to.appendMailbox(vmime::create <vmime::mailbox>(toString));
|
||||
to.appendMailbox(vmime::make_shared <vmime::mailbox>(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 <vmime::net::store> st;
|
||||
vmime::shared_ptr <vmime::net::store> st;
|
||||
|
||||
if (url.getUsername().empty() || url.getPassword().empty())
|
||||
st = g_session->getStore(url, vmime::create <interactiveAuthenticator>());
|
||||
st = g_session->getStore(url, vmime::make_shared <interactiveAuthenticator>());
|
||||
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 <interactiveCertificateVerifier>());
|
||||
(vmime::make_shared <interactiveCertificateVerifier>());
|
||||
|
||||
#endif // VMIME_HAVE_TLS_SUPPORT
|
||||
|
||||
@ -528,15 +529,15 @@ static void connectStore()
|
||||
st->connect();
|
||||
|
||||
// Display some information about the connection
|
||||
vmime::ref <vmime::net::connectionInfos> ci = st->getConnectionInfos();
|
||||
vmime::shared_ptr <vmime::net::connectionInfos> 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 <vmime::net::folder> f = st->getDefaultFolder();
|
||||
// vmime::ref <vmime::net::folder> f = st->getFolder(vmime::utility::path("a"));
|
||||
vmime::shared_ptr <vmime::net::folder> f = st->getDefaultFolder();
|
||||
// vmime::shared_ptr <vmime::net::folder> 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 <int, vmime::ref <vmime::net::message> > MessageList;
|
||||
typedef std::map <int, vmime::shared_ptr <vmime::net::message> > MessageList;
|
||||
MessageList msgList;
|
||||
|
||||
try
|
||||
@ -567,7 +568,7 @@ static void connectStore()
|
||||
const int choice = printMenu(choices);
|
||||
|
||||
// Request message number
|
||||
vmime::ref <vmime::net::message> msg;
|
||||
vmime::shared_ptr <vmime::net::message> msg;
|
||||
|
||||
if (choice != 6 && choice != 7 && choice != 8)
|
||||
{
|
||||
@ -677,7 +678,7 @@ static void connectStore()
|
||||
// List folders
|
||||
case 7:
|
||||
{
|
||||
vmime::ref <vmime::net::folder>
|
||||
vmime::shared_ptr <vmime::net::folder>
|
||||
root = st->getRootFolder();
|
||||
|
||||
printFolders(root);
|
||||
@ -692,7 +693,7 @@ static void connectStore()
|
||||
std::string path;
|
||||
std::getline(std::cin, path);
|
||||
|
||||
vmime::ref <vmime::net::folder> newFolder = st->getRootFolder();
|
||||
vmime::shared_ptr <vmime::net::folder> 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 <vmime::net::folder> f = st->getFolder(vmime::net::folder::path("c"));
|
||||
vmime::shared_ptr <vmime::net::folder> f = st->getFolder(vmime::net::folder::path("c"));
|
||||
f->rename(vmime::net::folder::path("c2"));
|
||||
|
||||
vmime::ref <vmime::net::folder> g = st->getFolder(vmime::net::folder::path("c2"));
|
||||
vmime::shared_ptr <vmime::net::folder> 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 <vmime::net::folder> g = st->getFolder(vmime::net::folder::path("TEMP"));
|
||||
vmime::shared_ptr <vmime::net::folder> g = st->getFolder(vmime::net::folder::path("TEMP"));
|
||||
|
||||
if (!g->exists())
|
||||
g->create(vmime::net::folder::TYPE_CONTAINS_MESSAGES);
|
||||
|
@ -43,18 +43,19 @@ int main()
|
||||
vmime::platform::setHandler<vmime::platforms::posix::posixHandler>();
|
||||
|
||||
// Enumerate encoders
|
||||
vmime::utility::encoder::encoderFactory* ef = vmime::utility::encoder::encoderFactory::getInstance();
|
||||
vmime::shared_ptr <vmime::utility::encoder::encoderFactory> ef =
|
||||
vmime::utility::encoder::encoderFactory::getInstance();
|
||||
|
||||
std::cout << "Available encoders:" << std::endl;
|
||||
|
||||
for (int i = 0 ; i < ef->getEncoderCount() ; ++i)
|
||||
{
|
||||
vmime::ref <const vmime::utility::encoder::encoderFactory::registeredEncoder>
|
||||
vmime::shared_ptr <const vmime::utility::encoder::encoderFactory::registeredEncoder>
|
||||
enc = ef->getEncoderAt(i);
|
||||
|
||||
std::cout << " * " << enc->getName() << std::endl;
|
||||
|
||||
vmime::ref <vmime::utility::encoder::encoder> e =
|
||||
vmime::shared_ptr <vmime::utility::encoder::encoder> e =
|
||||
vmime::utility::encoder::encoderFactory::getInstance()->create(enc->getName());
|
||||
|
||||
std::vector <vmime::string> 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 <vmime::net::serviceFactory> sf =
|
||||
vmime::net::serviceFactory::getInstance();
|
||||
|
||||
std::cout << "Available messaging services:" << std::endl;
|
||||
|
||||
|
@ -49,18 +49,18 @@ GtkWidget* textArea = NULL;
|
||||
|
||||
GtkTreeStore* treeModel = NULL;
|
||||
|
||||
vmime::ref <vmime::message> currentMessage = NULL;
|
||||
vmime::shared_ptr <vmime::message> currentMessage;
|
||||
|
||||
|
||||
|
||||
void insertRowInModel(GtkTreeStore* model, vmime::ref <vmime::component> comp, GtkTreeIter* parent = NULL)
|
||||
void insertRowInModel(GtkTreeStore* model, vmime::shared_ptr <vmime::component> 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 <vmime::ref <vmime::component> > children = comp->getChildComponents();
|
||||
const std::vector <vmime::shared_ptr <vmime::component> > 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 <vmime::message> msg = vmime::create <vmime::message>();
|
||||
vmime::shared_ptr <vmime::message> msg = vmime::make_shared <vmime::message>();
|
||||
msg->parse(data);
|
||||
|
||||
currentMessage = msg;
|
||||
|
@ -66,7 +66,7 @@ address-list = (address *("," address)) / obs-addr-list
|
||||
|
||||
*/
|
||||
|
||||
ref <address> address::parseNext
|
||||
shared_ptr <address> 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> address::parseNext
|
||||
// Parse extracted address (mailbox or group)
|
||||
if (pos != start)
|
||||
{
|
||||
ref <address> parsedAddress = isGroup
|
||||
? create <mailboxGroup>().dynamicCast <address>()
|
||||
: create <mailbox>().dynamicCast <address>();
|
||||
shared_ptr <address> parsedAddress;
|
||||
|
||||
if (isGroup)
|
||||
parsedAddress = make_shared <mailboxGroup>();
|
||||
else
|
||||
parsedAddress = make_shared <mailbox>();
|
||||
|
||||
parsedAddress->parse(ctx, buffer, start, pos, NULL);
|
||||
parsedAddress->setParsedBounds(start, pos);
|
||||
@ -206,7 +209,7 @@ ref <address> address::parseNext
|
||||
return (parsedAddress);
|
||||
}
|
||||
|
||||
return (NULL);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
@ -60,7 +60,7 @@ void addressList::parseImpl
|
||||
|
||||
while (pos < end)
|
||||
{
|
||||
ref <address> parsedAddress = address::parseNext(ctx, buffer, pos, end, &pos, NULL);
|
||||
shared_ptr <address> 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 <ref <address> >::const_iterator i = m_list.begin() ; ; )
|
||||
for (std::vector <shared_ptr <address> >::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 <ref <address> >::const_iterator it = addrList.m_list.begin() ;
|
||||
for (std::vector <shared_ptr <address> >::const_iterator it = addrList.m_list.begin() ;
|
||||
it != addrList.m_list.end() ; ++it)
|
||||
{
|
||||
m_list.push_back((*it)->clone().dynamicCast <address>());
|
||||
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 <address>());
|
||||
m_list.push_back(dynamicCast <address>(other.getMailboxAt(i)->clone()));
|
||||
|
||||
return (*this);
|
||||
}
|
||||
|
||||
|
||||
ref <component> addressList::clone() const
|
||||
shared_ptr <component> addressList::clone() const
|
||||
{
|
||||
return vmime::create <addressList>(*this);
|
||||
return make_shared <addressList>(*this);
|
||||
}
|
||||
|
||||
|
||||
void addressList::appendAddress(ref <address> addr)
|
||||
void addressList::appendAddress(shared_ptr <address> addr)
|
||||
{
|
||||
m_list.push_back(addr);
|
||||
}
|
||||
|
||||
|
||||
void addressList::insertAddressBefore(ref <address> beforeAddress, ref <address> addr)
|
||||
void addressList::insertAddressBefore(shared_ptr <address> beforeAddress, shared_ptr <address> addr)
|
||||
{
|
||||
const std::vector <ref <address> >::iterator it = std::find
|
||||
const std::vector <shared_ptr <address> >::iterator it = std::find
|
||||
(m_list.begin(), m_list.end(), beforeAddress);
|
||||
|
||||
if (it == m_list.end())
|
||||
@ -157,15 +157,15 @@ void addressList::insertAddressBefore(ref <address> beforeAddress, ref <address>
|
||||
}
|
||||
|
||||
|
||||
void addressList::insertAddressBefore(const size_t pos, ref <address> addr)
|
||||
void addressList::insertAddressBefore(const size_t pos, shared_ptr <address> addr)
|
||||
{
|
||||
m_list.insert(m_list.begin() + pos, addr);
|
||||
}
|
||||
|
||||
|
||||
void addressList::insertAddressAfter(ref <address> afterAddress, ref <address> addr)
|
||||
void addressList::insertAddressAfter(shared_ptr <address> afterAddress, shared_ptr <address> addr)
|
||||
{
|
||||
const std::vector <ref <address> >::iterator it = std::find
|
||||
const std::vector <shared_ptr <address> >::iterator it = std::find
|
||||
(m_list.begin(), m_list.end(), afterAddress);
|
||||
|
||||
if (it == m_list.end())
|
||||
@ -175,15 +175,15 @@ void addressList::insertAddressAfter(ref <address> afterAddress, ref <address> a
|
||||
}
|
||||
|
||||
|
||||
void addressList::insertAddressAfter(const size_t pos, ref <address> addr)
|
||||
void addressList::insertAddressAfter(const size_t pos, shared_ptr <address> addr)
|
||||
{
|
||||
m_list.insert(m_list.begin() + pos + 1, addr);
|
||||
}
|
||||
|
||||
|
||||
void addressList::removeAddress(ref <address> addr)
|
||||
void addressList::removeAddress(shared_ptr <address> addr)
|
||||
{
|
||||
const std::vector <ref <address> >::iterator it = std::find
|
||||
const std::vector <shared_ptr <address> >::iterator it = std::find
|
||||
(m_list.begin(), m_list.end(), addr);
|
||||
|
||||
if (it == m_list.end())
|
||||
@ -195,7 +195,7 @@ void addressList::removeAddress(ref <address> addr)
|
||||
|
||||
void addressList::removeAddress(const size_t pos)
|
||||
{
|
||||
const std::vector <ref <address> >::iterator it = m_list.begin() + pos;
|
||||
const std::vector <shared_ptr <address> >::iterator it = m_list.begin() + pos;
|
||||
|
||||
m_list.erase(it);
|
||||
}
|
||||
@ -219,25 +219,25 @@ bool addressList::isEmpty() const
|
||||
}
|
||||
|
||||
|
||||
ref <address> addressList::getAddressAt(const size_t pos)
|
||||
shared_ptr <address> addressList::getAddressAt(const size_t pos)
|
||||
{
|
||||
return (m_list[pos]);
|
||||
}
|
||||
|
||||
|
||||
const ref <const address> addressList::getAddressAt(const size_t pos) const
|
||||
const shared_ptr <const address> addressList::getAddressAt(const size_t pos) const
|
||||
{
|
||||
return (m_list[pos]);
|
||||
}
|
||||
|
||||
|
||||
const std::vector <ref <const address> > addressList::getAddressList() const
|
||||
const std::vector <shared_ptr <const address> > addressList::getAddressList() const
|
||||
{
|
||||
std::vector <ref <const address> > list;
|
||||
std::vector <shared_ptr <const address> > list;
|
||||
|
||||
list.reserve(m_list.size());
|
||||
|
||||
for (std::vector <ref <address> >::const_iterator it = m_list.begin() ;
|
||||
for (std::vector <shared_ptr <address> >::const_iterator it = m_list.begin() ;
|
||||
it != m_list.end() ; ++it)
|
||||
{
|
||||
list.push_back(*it);
|
||||
@ -247,15 +247,15 @@ const std::vector <ref <const address> > addressList::getAddressList() const
|
||||
}
|
||||
|
||||
|
||||
const std::vector <ref <address> > addressList::getAddressList()
|
||||
const std::vector <shared_ptr <address> > addressList::getAddressList()
|
||||
{
|
||||
return (m_list);
|
||||
}
|
||||
|
||||
|
||||
const std::vector <ref <component> > addressList::getChildComponents()
|
||||
const std::vector <shared_ptr <component> > addressList::getChildComponents()
|
||||
{
|
||||
std::vector <ref <component> > list;
|
||||
std::vector <shared_ptr <component> > list;
|
||||
|
||||
copy_vector(m_list, list);
|
||||
|
||||
@ -263,21 +263,21 @@ const std::vector <ref <component> > addressList::getChildComponents()
|
||||
}
|
||||
|
||||
|
||||
ref <mailboxList> addressList::toMailboxList() const
|
||||
shared_ptr <mailboxList> addressList::toMailboxList() const
|
||||
{
|
||||
ref <mailboxList> res = vmime::create <mailboxList>();
|
||||
shared_ptr <mailboxList> res = make_shared <mailboxList>();
|
||||
|
||||
for (std::vector <ref <address> >::const_iterator it = m_list.begin() ;
|
||||
for (std::vector <shared_ptr <address> >::const_iterator it = m_list.begin() ;
|
||||
it != m_list.end() ; ++it)
|
||||
{
|
||||
ref <const address> addr = *it;
|
||||
shared_ptr <const address> addr = *it;
|
||||
|
||||
if (addr->isGroup())
|
||||
{
|
||||
const std::vector <ref <const mailbox> > mailboxes =
|
||||
addr.dynamicCast <const mailboxGroup>()->getMailboxList();
|
||||
const std::vector <shared_ptr <const mailbox> > mailboxes =
|
||||
dynamicCast <const mailboxGroup>(addr)->getMailboxList();
|
||||
|
||||
for (std::vector <ref <const mailbox> >::const_iterator jt = mailboxes.begin() ;
|
||||
for (std::vector <shared_ptr <const mailbox> >::const_iterator jt = mailboxes.begin() ;
|
||||
jt != mailboxes.end() ; ++jt)
|
||||
{
|
||||
res->appendMailbox(vmime::clone(*jt));
|
||||
@ -285,7 +285,7 @@ ref <mailboxList> addressList::toMailboxList() const
|
||||
}
|
||||
else
|
||||
{
|
||||
res->appendMailbox(addr->clone().dynamicCast <mailbox>());
|
||||
res->appendMailbox(dynamicCast <mailbox>(addr->clone()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,15 +39,14 @@ namespace vmime
|
||||
|
||||
// static
|
||||
bool attachmentHelper::isBodyPartAnAttachment
|
||||
(ref <const bodyPart> part, const unsigned int options)
|
||||
(shared_ptr <const bodyPart> part, const unsigned int options)
|
||||
{
|
||||
try
|
||||
{
|
||||
const contentDispositionField& cdf = dynamic_cast<contentDispositionField&>
|
||||
(*part->getHeader()->findField(fields::CONTENT_DISPOSITION));
|
||||
const contentDispositionField& cdf =
|
||||
*part->getHeader()->findField <contentDispositionField>(fields::CONTENT_DISPOSITION);
|
||||
|
||||
const contentDisposition disp = *cdf.getValue()
|
||||
.dynamicCast <const contentDisposition>();
|
||||
const contentDisposition disp = *cdf.getValue <const contentDisposition>();
|
||||
|
||||
if (disp.getName() != contentDispositionTypes::INLINE)
|
||||
return true;
|
||||
@ -80,10 +79,10 @@ bool attachmentHelper::isBodyPartAnAttachment
|
||||
|
||||
try
|
||||
{
|
||||
const contentTypeField& ctf = dynamic_cast<contentTypeField&>
|
||||
(*part->getHeader()->findField(fields::CONTENT_TYPE));
|
||||
const contentTypeField& ctf =
|
||||
*part->getHeader()->findField <contentTypeField>(fields::CONTENT_TYPE);
|
||||
|
||||
type = *ctf.getValue().dynamicCast <const mediaType>();
|
||||
type = *ctf.getValue <const mediaType>();
|
||||
|
||||
if (ctf.hasParameter("name"))
|
||||
hasContentTypeName = true;
|
||||
@ -125,20 +124,20 @@ bool attachmentHelper::isBodyPartAnAttachment
|
||||
|
||||
|
||||
// static
|
||||
ref <const attachment> attachmentHelper::getBodyPartAttachment
|
||||
(ref <const bodyPart> part, const unsigned int options)
|
||||
shared_ptr <const attachment> attachmentHelper::getBodyPartAttachment
|
||||
(shared_ptr <const bodyPart> part, const unsigned int options)
|
||||
{
|
||||
if (!isBodyPartAnAttachment(part, options))
|
||||
return NULL;
|
||||
return null;
|
||||
|
||||
mediaType type;
|
||||
|
||||
try
|
||||
{
|
||||
const contentTypeField& ctf = dynamic_cast<contentTypeField&>
|
||||
(*part->getHeader()->findField(fields::CONTENT_TYPE));
|
||||
const contentTypeField& ctf =
|
||||
*part->getHeader()->findField <contentTypeField>(fields::CONTENT_TYPE);
|
||||
|
||||
type = *ctf.getValue().dynamicCast <const mediaType>();
|
||||
type = *ctf.getValue <mediaType>();
|
||||
}
|
||||
catch (exceptions::no_such_field&)
|
||||
{
|
||||
@ -150,30 +149,30 @@ ref <const attachment> attachmentHelper::getBodyPartAttachment
|
||||
if (type.getType() == mediaTypes::MESSAGE &&
|
||||
type.getSubType() == mediaTypes::MESSAGE_RFC822)
|
||||
{
|
||||
return vmime::create <generatedMessageAttachment>(part);
|
||||
return make_shared <generatedMessageAttachment>(part);
|
||||
}
|
||||
else
|
||||
{
|
||||
return vmime::create <bodyPartAttachment>(part);
|
||||
return make_shared <bodyPartAttachment>(part);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// static
|
||||
const std::vector <ref <const attachment> >
|
||||
const std::vector <shared_ptr <const attachment> >
|
||||
attachmentHelper::findAttachmentsInMessage
|
||||
(ref <const message> msg, const unsigned int options)
|
||||
(shared_ptr <const message> msg, const unsigned int options)
|
||||
{
|
||||
return findAttachmentsInBodyPart(msg, options);
|
||||
}
|
||||
|
||||
|
||||
// static
|
||||
const std::vector <ref <const attachment> >
|
||||
const std::vector <shared_ptr <const attachment> >
|
||||
attachmentHelper::findAttachmentsInBodyPart
|
||||
(ref <const bodyPart> part, const unsigned int options)
|
||||
(shared_ptr <const bodyPart> part, const unsigned int options)
|
||||
{
|
||||
std::vector <ref <const attachment> > atts;
|
||||
std::vector <shared_ptr <const attachment> > atts;
|
||||
|
||||
// Test this part
|
||||
if (isBodyPartAnAttachment(part, options))
|
||||
@ -183,11 +182,11 @@ const std::vector <ref <const attachment> >
|
||||
// Find in sub-parts
|
||||
else
|
||||
{
|
||||
ref <const body> bdy = part->getBody();
|
||||
shared_ptr <const body> bdy = part->getBody();
|
||||
|
||||
for (size_t i = 0 ; i < bdy->getPartCount() ; ++i)
|
||||
{
|
||||
std::vector <ref <const attachment> > partAtts =
|
||||
std::vector <shared_ptr <const attachment> > partAtts =
|
||||
findAttachmentsInBodyPart(bdy->getPartAt(i), options);
|
||||
|
||||
std::copy(partAtts.begin(), partAtts.end(), std::back_inserter(atts));
|
||||
@ -199,7 +198,7 @@ const std::vector <ref <const attachment> >
|
||||
|
||||
|
||||
// static
|
||||
void attachmentHelper::addAttachment(ref <message> msg, ref <attachment> att)
|
||||
void attachmentHelper::addAttachment(shared_ptr <message> msg, shared_ptr <attachment> 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 <message> msg, ref <attachment> att)
|
||||
vmime::mediaType mpMixed(vmime::mediaTypes::MULTIPART,
|
||||
vmime::mediaTypes::MULTIPART_MIXED);
|
||||
|
||||
ref <bodyPart> part = findBodyPart(msg, mpMixed);
|
||||
shared_ptr <bodyPart> part = findBodyPart(msg, mpMixed);
|
||||
|
||||
if (part == NULL) // create it
|
||||
{
|
||||
@ -216,7 +215,7 @@ void attachmentHelper::addAttachment(ref <message> msg, ref <attachment> att)
|
||||
{
|
||||
// Create a new container part for the parts that were in
|
||||
// the root part of the message
|
||||
ref <bodyPart> container = vmime::create <bodyPart>();
|
||||
shared_ptr <bodyPart> container = make_shared <bodyPart>();
|
||||
|
||||
try
|
||||
{
|
||||
@ -238,7 +237,7 @@ void attachmentHelper::addAttachment(ref <message> msg, ref <attachment> att)
|
||||
}
|
||||
|
||||
// Move parts from the root part to this new part
|
||||
const std::vector <ref <bodyPart> > partList =
|
||||
const std::vector <shared_ptr <bodyPart> > partList =
|
||||
msg->getBody()->getPartList();
|
||||
|
||||
msg->getBody()->removeAllParts();
|
||||
@ -253,7 +252,7 @@ void attachmentHelper::addAttachment(ref <message> msg, ref <attachment> 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 <bodyPart> child = vmime::create <bodyPart>();
|
||||
shared_ptr <bodyPart> child = make_shared <bodyPart>();
|
||||
|
||||
if (msg->getHeader()->hasField(fields::CONTENT_TYPE))
|
||||
{
|
||||
@ -268,7 +267,7 @@ void attachmentHelper::addAttachment(ref <message> msg, ref <attachment> att)
|
||||
}
|
||||
|
||||
child->getBody()->setContents(msg->getBody()->getContents());
|
||||
msg->getBody()->setContents(vmime::create <emptyContentHandler>());
|
||||
msg->getBody()->setContents(make_shared <emptyContentHandler>());
|
||||
|
||||
msg->getBody()->appendPart(child);
|
||||
}
|
||||
@ -288,32 +287,32 @@ void attachmentHelper::addAttachment(ref <message> msg, ref <attachment> att)
|
||||
|
||||
|
||||
// static
|
||||
ref <bodyPart> attachmentHelper::findBodyPart
|
||||
(ref <bodyPart> part, const mediaType& type)
|
||||
shared_ptr <bodyPart> attachmentHelper::findBodyPart
|
||||
(shared_ptr <bodyPart> part, const mediaType& type)
|
||||
{
|
||||
if (part->getBody()->getContentType() == type)
|
||||
return part;
|
||||
|
||||
// Try in sub-parts
|
||||
ref <body> bdy = part->getBody();
|
||||
shared_ptr <body> bdy = part->getBody();
|
||||
|
||||
for (size_t i = 0 ; i < bdy->getPartCount() ; ++i)
|
||||
{
|
||||
ref <bodyPart> found =
|
||||
shared_ptr <bodyPart> found =
|
||||
findBodyPart(bdy->getPartAt(i), type);
|
||||
|
||||
if (found != NULL)
|
||||
return found;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// static
|
||||
void attachmentHelper::addAttachment(ref <message> msg, ref <message> amsg)
|
||||
void attachmentHelper::addAttachment(shared_ptr <message> msg, shared_ptr <message> amsg)
|
||||
{
|
||||
ref <attachment> att = vmime::create <parsedMessageAttachment>(amsg);
|
||||
shared_ptr <attachment> att = make_shared <parsedMessageAttachment>(amsg);
|
||||
addAttachment(msg, att);
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
163
src/body.cpp
163
src/body.cpp
@ -44,7 +44,7 @@ namespace vmime
|
||||
|
||||
|
||||
body::body()
|
||||
: m_contents(create <emptyContentHandler>()), m_part(NULL), m_header(NULL)
|
||||
: m_contents(make_shared <emptyContentHandler>())
|
||||
{
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ body::~body()
|
||||
|
||||
// static
|
||||
utility::stream::size_type body::findNextBoundaryPosition
|
||||
(ref <utility::parserInputStreamAdapter> parser, const string& boundary,
|
||||
(shared_ptr <utility::parserInputStreamAdapter> 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 <utility::parserInputStreamAdapter> parser,
|
||||
shared_ptr <utility::parserInputStreamAdapter> 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 <const contentTypeField> ctf =
|
||||
m_header.acquire()->findField(fields::CONTENT_TYPE).dynamicCast <contentTypeField>();
|
||||
const shared_ptr <const contentTypeField> ctf =
|
||||
m_part->getHeader()->findField <contentTypeField>(fields::CONTENT_TYPE);
|
||||
|
||||
const mediaType type = *ctf->getValue().dynamicCast <const mediaType>();
|
||||
const mediaType type = *ctf->getValue <mediaType>();
|
||||
|
||||
if (type.getType() == mediaTypes::MULTIPART)
|
||||
{
|
||||
@ -302,7 +302,7 @@ void body::parseImpl
|
||||
}
|
||||
else // index > 0
|
||||
{
|
||||
ref <bodyPart> part = vmime::create <bodyPart>();
|
||||
shared_ptr <bodyPart> 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 <emptyContentHandler>();
|
||||
m_contents = make_shared <emptyContentHandler>();
|
||||
|
||||
// Last part was not found: recover from missing boundary
|
||||
if (!lastPart && pos == utility::stream::npos)
|
||||
{
|
||||
ref <bodyPart> part = vmime::create <bodyPart>();
|
||||
shared_ptr <bodyPart> 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 <const headerField> cef =
|
||||
m_header.acquire()->findField(fields::CONTENT_TRANSFER_ENCODING);
|
||||
const shared_ptr <headerField> cef =
|
||||
m_part->getHeader()->findField(fields::CONTENT_TRANSFER_ENCODING);
|
||||
|
||||
enc = *cef->getValue().dynamicCast <const encoding>();
|
||||
enc = *cef->getValue <encoding>();
|
||||
}
|
||||
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 <utility::inputStream> contentStream =
|
||||
vmime::create <utility::seekableInputStreamRegionAdapter>
|
||||
shared_ptr <utility::inputStream> contentStream =
|
||||
make_shared <utility::seekableInputStreamRegionAdapter>
|
||||
(parser->getUnderlyingStream(), position, length);
|
||||
|
||||
m_contents = vmime::create <streamContentHandler>(contentStream, length, enc);
|
||||
m_contents = make_shared <streamContentHandler>(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 <const contentTypeField> ctf =
|
||||
m_header.acquire()->findField(fields::CONTENT_TYPE)
|
||||
.dynamicCast <const contentTypeField>();
|
||||
shared_ptr <contentTypeField> ctf =
|
||||
m_part->getHeader()->findField <contentTypeField>(fields::CONTENT_TYPE);
|
||||
|
||||
boundary = ctf->getBoundary();
|
||||
}
|
||||
@ -494,7 +490,7 @@ void body::generateImpl
|
||||
else
|
||||
{
|
||||
// Generate the contents
|
||||
ref <contentHandler> contents = m_contents->clone();
|
||||
shared_ptr <contentHandler> 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 <utility::encoder::encoder> srcEncoder = m_contents->getEncoding().getEncoder();
|
||||
ref <utility::encoder::encoder> dstEncoder = getEncoding().getEncoder();
|
||||
shared_ptr <utility::encoder::encoder> srcEncoder = m_contents->getEncoding().getEncoder();
|
||||
shared_ptr <utility::encoder::encoder> 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 <contentTypeField> ctf = m_header.acquire()->ContentType().dynamicCast <contentTypeField>();
|
||||
shared_ptr <contentTypeField> ctf =
|
||||
dynamicCast <contentTypeField>(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 <const contentTypeField> ctf =
|
||||
m_header.acquire()->findField(fields::CONTENT_TYPE).dynamicCast <const contentTypeField>();
|
||||
shared_ptr <const contentTypeField> ctf =
|
||||
m_part->getHeader()->findField <contentTypeField>(fields::CONTENT_TYPE);
|
||||
|
||||
return (*ctf->getValue().dynamicCast <const mediaType>());
|
||||
return (*ctf->getValue <mediaType>());
|
||||
}
|
||||
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 <contentTypeField> ctf =
|
||||
m_header.acquire()->findField(fields::CONTENT_TYPE).dynamicCast <contentTypeField>();
|
||||
shared_ptr <contentTypeField> ctf =
|
||||
m_part->getHeader()->findField <contentTypeField>(fields::CONTENT_TYPE);
|
||||
|
||||
ctf->setCharset(chset);
|
||||
}
|
||||
@ -699,8 +696,8 @@ const charset body::getCharset() const
|
||||
{
|
||||
try
|
||||
{
|
||||
const ref <const contentTypeField> ctf =
|
||||
m_header.acquire()->findField(fields::CONTENT_TYPE).dynamicCast <contentTypeField>();
|
||||
const shared_ptr <const contentTypeField> ctf =
|
||||
m_part->getHeader()->findField <contentTypeField>(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 <const headerField> cef =
|
||||
m_header.acquire()->findField(fields::CONTENT_TRANSFER_ENCODING);
|
||||
const shared_ptr <const headerField> cef =
|
||||
m_part->getHeader()->findField(fields::CONTENT_TRANSFER_ENCODING);
|
||||
|
||||
return (*cef->getValue().dynamicCast <const encoding>());
|
||||
return *cef->getValue <encoding>();
|
||||
}
|
||||
catch (exceptions::no_such_field&)
|
||||
{
|
||||
@ -747,30 +744,28 @@ const encoding body::getEncoding() const
|
||||
}
|
||||
|
||||
|
||||
void body::setParentPart(ref <bodyPart> parent)
|
||||
void body::setParentPart(bodyPart* parent)
|
||||
{
|
||||
m_part = parent;
|
||||
m_header = (parent != NULL ? parent->getHeader() : NULL);
|
||||
|
||||
for (std::vector <ref <bodyPart> >::iterator it = m_parts.begin() ;
|
||||
for (std::vector <shared_ptr <bodyPart> >::iterator it = m_parts.begin() ;
|
||||
it != m_parts.end() ; ++it)
|
||||
{
|
||||
ref <bodyPart> childPart = *it;
|
||||
childPart->m_parent = parent;
|
||||
shared_ptr <bodyPart> childPart = *it;
|
||||
parent->importChildPart(childPart);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool body::isRootPart() const
|
||||
{
|
||||
ref <const bodyPart> part = m_part.acquire();
|
||||
return (part == NULL || part->getParentPart() == NULL);
|
||||
return (m_part == NULL || m_part->getParentPart() == NULL);
|
||||
}
|
||||
|
||||
|
||||
ref <component> body::clone() const
|
||||
shared_ptr <component> body::clone() const
|
||||
{
|
||||
ref <body> bdy = vmime::create <body>();
|
||||
shared_ptr <body> bdy = make_shared <body>();
|
||||
|
||||
bdy->copyFrom(*this);
|
||||
|
||||
@ -791,9 +786,9 @@ void body::copyFrom(const component& other)
|
||||
|
||||
for (size_t p = 0 ; p < bdy.getPartCount() ; ++p)
|
||||
{
|
||||
ref <bodyPart> part = bdy.getPartAt(p)->clone().dynamicCast <bodyPart>();
|
||||
shared_ptr <bodyPart> 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 <const contentHandler> body::getContents() const
|
||||
const shared_ptr <const contentHandler> body::getContents() const
|
||||
{
|
||||
return (m_contents);
|
||||
}
|
||||
|
||||
|
||||
void body::setContents(ref <const contentHandler> contents)
|
||||
void body::setContents(shared_ptr <const contentHandler> contents)
|
||||
{
|
||||
m_contents = contents;
|
||||
}
|
||||
|
||||
|
||||
void body::setContents(ref <const contentHandler> contents, const mediaType& type)
|
||||
void body::setContents(shared_ptr <const contentHandler> contents, const mediaType& type)
|
||||
{
|
||||
m_contents = contents;
|
||||
|
||||
@ -851,7 +846,7 @@ void body::setContents(ref <const contentHandler> contents, const mediaType& typ
|
||||
}
|
||||
|
||||
|
||||
void body::setContents(ref <const contentHandler> contents, const mediaType& type, const charset& chset)
|
||||
void body::setContents(shared_ptr <const contentHandler> contents, const mediaType& type, const charset& chset)
|
||||
{
|
||||
m_contents = contents;
|
||||
|
||||
@ -859,7 +854,7 @@ void body::setContents(ref <const contentHandler> contents, const mediaType& typ
|
||||
}
|
||||
|
||||
|
||||
void body::setContents(ref <const contentHandler> contents, const mediaType& type,
|
||||
void body::setContents(shared_ptr <const contentHandler> contents, const mediaType& type,
|
||||
const charset& chset, const encoding& enc)
|
||||
{
|
||||
m_contents = contents;
|
||||
@ -869,19 +864,25 @@ void body::setContents(ref <const contentHandler> contents, const mediaType& typ
|
||||
}
|
||||
|
||||
|
||||
void body::initNewPart(ref <bodyPart> part)
|
||||
void body::initNewPart(shared_ptr <bodyPart> 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 <header> hdr = m_header.acquire();
|
||||
|
||||
if (hdr != NULL)
|
||||
if (m_part != NULL)
|
||||
{
|
||||
m_part->importChildPart(part);
|
||||
|
||||
shared_ptr <header> hdr = m_part->getHeader();
|
||||
|
||||
// Check whether we have a boundary string
|
||||
try
|
||||
{
|
||||
ref <contentTypeField> ctf =
|
||||
hdr->findField(fields::CONTENT_TYPE).dynamicCast <contentTypeField>();
|
||||
shared_ptr <contentTypeField> ctf =
|
||||
hdr->findField <contentTypeField>(fields::CONTENT_TYPE);
|
||||
|
||||
try
|
||||
{
|
||||
@ -896,7 +897,7 @@ void body::initNewPart(ref <bodyPart> part)
|
||||
ctf->setBoundary(generateRandomBoundaryString());
|
||||
}
|
||||
|
||||
if (ctf->getValue().dynamicCast <const mediaType>()->getType() != mediaTypes::MULTIPART)
|
||||
if (ctf->getValue <mediaType>()->getType() != mediaTypes::MULTIPART)
|
||||
{
|
||||
// Warning: multi-part body but the Content-Type is
|
||||
// not specified as "multipart/..."
|
||||
@ -906,8 +907,8 @@ void body::initNewPart(ref <bodyPart> part)
|
||||
{
|
||||
// No "Content-Type" field: create a new one and generate
|
||||
// a random boundary string.
|
||||
ref <contentTypeField> ctf =
|
||||
hdr->getField(fields::CONTENT_TYPE).dynamicCast <contentTypeField>();
|
||||
shared_ptr <contentTypeField> ctf =
|
||||
hdr->getField <contentTypeField>(fields::CONTENT_TYPE);
|
||||
|
||||
ctf->setValue(mediaType(mediaTypes::MULTIPART, mediaTypes::MULTIPART_MIXED));
|
||||
ctf->setBoundary(generateRandomBoundaryString());
|
||||
@ -916,7 +917,7 @@ void body::initNewPart(ref <bodyPart> part)
|
||||
}
|
||||
|
||||
|
||||
void body::appendPart(ref <bodyPart> part)
|
||||
void body::appendPart(shared_ptr <bodyPart> part)
|
||||
{
|
||||
initNewPart(part);
|
||||
|
||||
@ -924,11 +925,11 @@ void body::appendPart(ref <bodyPart> part)
|
||||
}
|
||||
|
||||
|
||||
void body::insertPartBefore(ref <bodyPart> beforePart, ref <bodyPart> part)
|
||||
void body::insertPartBefore(shared_ptr <bodyPart> beforePart, shared_ptr <bodyPart> part)
|
||||
{
|
||||
initNewPart(part);
|
||||
|
||||
const std::vector <ref <bodyPart> >::iterator it = std::find
|
||||
const std::vector <shared_ptr <bodyPart> >::iterator it = std::find
|
||||
(m_parts.begin(), m_parts.end(), beforePart);
|
||||
|
||||
if (it == m_parts.end())
|
||||
@ -938,7 +939,7 @@ void body::insertPartBefore(ref <bodyPart> beforePart, ref <bodyPart> part)
|
||||
}
|
||||
|
||||
|
||||
void body::insertPartBefore(const size_t pos, ref <bodyPart> part)
|
||||
void body::insertPartBefore(const size_t pos, shared_ptr <bodyPart> part)
|
||||
{
|
||||
initNewPart(part);
|
||||
|
||||
@ -946,11 +947,11 @@ void body::insertPartBefore(const size_t pos, ref <bodyPart> part)
|
||||
}
|
||||
|
||||
|
||||
void body::insertPartAfter(ref <bodyPart> afterPart, ref <bodyPart> part)
|
||||
void body::insertPartAfter(shared_ptr <bodyPart> afterPart, shared_ptr <bodyPart> part)
|
||||
{
|
||||
initNewPart(part);
|
||||
|
||||
const std::vector <ref <bodyPart> >::iterator it = std::find
|
||||
const std::vector <shared_ptr <bodyPart> >::iterator it = std::find
|
||||
(m_parts.begin(), m_parts.end(), afterPart);
|
||||
|
||||
if (it == m_parts.end())
|
||||
@ -960,7 +961,7 @@ void body::insertPartAfter(ref <bodyPart> afterPart, ref <bodyPart> part)
|
||||
}
|
||||
|
||||
|
||||
void body::insertPartAfter(const size_t pos, ref <bodyPart> part)
|
||||
void body::insertPartAfter(const size_t pos, shared_ptr <bodyPart> part)
|
||||
{
|
||||
initNewPart(part);
|
||||
|
||||
@ -968,9 +969,9 @@ void body::insertPartAfter(const size_t pos, ref <bodyPart> part)
|
||||
}
|
||||
|
||||
|
||||
void body::removePart(ref <bodyPart> part)
|
||||
void body::removePart(shared_ptr <bodyPart> part)
|
||||
{
|
||||
const std::vector <ref <bodyPart> >::iterator it = std::find
|
||||
const std::vector <shared_ptr <bodyPart> >::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 <bodyPart> body::getPartAt(const size_t pos)
|
||||
shared_ptr <bodyPart> body::getPartAt(const size_t pos)
|
||||
{
|
||||
return (m_parts[pos]);
|
||||
}
|
||||
|
||||
|
||||
const ref <const bodyPart> body::getPartAt(const size_t pos) const
|
||||
const shared_ptr <const bodyPart> body::getPartAt(const size_t pos) const
|
||||
{
|
||||
return (m_parts[pos]);
|
||||
}
|
||||
|
||||
|
||||
const std::vector <ref <const bodyPart> > body::getPartList() const
|
||||
const std::vector <shared_ptr <const bodyPart> > body::getPartList() const
|
||||
{
|
||||
std::vector <ref <const bodyPart> > list;
|
||||
std::vector <shared_ptr <const bodyPart> > list;
|
||||
|
||||
list.reserve(m_parts.size());
|
||||
|
||||
for (std::vector <ref <bodyPart> >::const_iterator it = m_parts.begin() ;
|
||||
for (std::vector <shared_ptr <bodyPart> >::const_iterator it = m_parts.begin() ;
|
||||
it != m_parts.end() ; ++it)
|
||||
{
|
||||
list.push_back(*it);
|
||||
@ -1032,15 +1033,15 @@ const std::vector <ref <const bodyPart> > body::getPartList() const
|
||||
}
|
||||
|
||||
|
||||
const std::vector <ref <bodyPart> > body::getPartList()
|
||||
const std::vector <shared_ptr <bodyPart> > body::getPartList()
|
||||
{
|
||||
return (m_parts);
|
||||
}
|
||||
|
||||
|
||||
const std::vector <ref <component> > body::getChildComponents()
|
||||
const std::vector <shared_ptr <component> > body::getChildComponents()
|
||||
{
|
||||
std::vector <ref <component> > list;
|
||||
std::vector <shared_ptr <component> > list;
|
||||
|
||||
copy_vector(m_parts, list);
|
||||
|
||||
|
@ -29,26 +29,17 @@ namespace vmime
|
||||
|
||||
|
||||
bodyPart::bodyPart()
|
||||
: m_header(vmime::create <header>()),
|
||||
m_body(vmime::create <body>()),
|
||||
m_parent(NULL)
|
||||
: m_header(make_shared <header>()),
|
||||
m_body(make_shared <body>()),
|
||||
m_parent()
|
||||
{
|
||||
m_body->setParentPart(thisRef().dynamicCast <bodyPart>());
|
||||
}
|
||||
|
||||
|
||||
bodyPart::bodyPart(weak_ref <vmime::bodyPart> parentPart)
|
||||
: m_header(vmime::create <header>()),
|
||||
m_body(vmime::create <body>()),
|
||||
m_parent(parentPart)
|
||||
{
|
||||
m_body->setParentPart(thisRef().dynamicCast <bodyPart>());
|
||||
m_body->setParentPart(this);
|
||||
}
|
||||
|
||||
|
||||
void bodyPart::parseImpl
|
||||
(const parsingContext& ctx,
|
||||
ref <utility::parserInputStreamAdapter> parser,
|
||||
shared_ptr <utility::parserInputStreamAdapter> 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 <component> bodyPart::clone() const
|
||||
shared_ptr <component> bodyPart::clone() const
|
||||
{
|
||||
ref <bodyPart> p = vmime::create <bodyPart>();
|
||||
shared_ptr <bodyPart> p = make_shared <bodyPart>();
|
||||
|
||||
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 <const header> bodyPart::getHeader() const
|
||||
const shared_ptr <const header> bodyPart::getHeader() const
|
||||
{
|
||||
return (m_header);
|
||||
}
|
||||
|
||||
|
||||
ref <header> bodyPart::getHeader()
|
||||
shared_ptr <header> bodyPart::getHeader()
|
||||
{
|
||||
return (m_header);
|
||||
}
|
||||
|
||||
|
||||
void bodyPart::setHeader(ref <header> h)
|
||||
void bodyPart::setHeader(shared_ptr <header> h)
|
||||
{
|
||||
m_header = h;
|
||||
}
|
||||
|
||||
|
||||
const ref <const body> bodyPart::getBody() const
|
||||
const shared_ptr <const body> bodyPart::getBody() const
|
||||
{
|
||||
return (m_body);
|
||||
}
|
||||
|
||||
|
||||
ref <body> bodyPart::getBody()
|
||||
shared_ptr <body> bodyPart::getBody()
|
||||
{
|
||||
return (m_body);
|
||||
}
|
||||
|
||||
|
||||
void bodyPart::setBody(ref <body> b)
|
||||
void bodyPart::setBody(shared_ptr <body> b)
|
||||
{
|
||||
ref <bodyPart> oldPart = b->m_part.acquire();
|
||||
bodyPart* oldPart = b->m_part;
|
||||
|
||||
m_body = b;
|
||||
m_body->setParentPart(thisRef().dynamicCast <bodyPart>());
|
||||
m_body->setParentPart(this);
|
||||
|
||||
// A body is associated to one and only one part
|
||||
if (oldPart != NULL)
|
||||
oldPart->setBody(vmime::create <body>());
|
||||
oldPart->setBody(make_shared <body>());
|
||||
}
|
||||
|
||||
|
||||
ref <bodyPart> bodyPart::getParentPart()
|
||||
bodyPart* bodyPart::getParentPart()
|
||||
{
|
||||
return m_parent.acquire();
|
||||
return m_parent;
|
||||
}
|
||||
|
||||
|
||||
ref <const bodyPart> bodyPart::getParentPart() const
|
||||
const bodyPart* bodyPart::getParentPart() const
|
||||
{
|
||||
return m_parent.acquire();
|
||||
return m_parent;
|
||||
}
|
||||
|
||||
|
||||
const std::vector <ref <component> > bodyPart::getChildComponents()
|
||||
shared_ptr <bodyPart> bodyPart::createChildPart()
|
||||
{
|
||||
std::vector <ref <component> > list;
|
||||
shared_ptr <bodyPart> part = make_shared <bodyPart>();
|
||||
part->m_parent = this;
|
||||
|
||||
return part;
|
||||
}
|
||||
|
||||
|
||||
void bodyPart::importChildPart(shared_ptr <bodyPart> part)
|
||||
{
|
||||
part->m_parent = this;
|
||||
}
|
||||
|
||||
|
||||
const std::vector <shared_ptr <component> > bodyPart::getChildComponents()
|
||||
{
|
||||
std::vector <shared_ptr <component> > list;
|
||||
|
||||
list.push_back(m_header);
|
||||
list.push_back(m_body);
|
||||
|
@ -28,7 +28,7 @@ namespace vmime
|
||||
{
|
||||
|
||||
|
||||
bodyPartAttachment::bodyPartAttachment(ref <const bodyPart> part)
|
||||
bodyPartAttachment::bodyPartAttachment(shared_ptr <const bodyPart> part)
|
||||
: m_part(part)
|
||||
{
|
||||
}
|
||||
@ -40,7 +40,7 @@ const mediaType bodyPartAttachment::getType() const
|
||||
|
||||
try
|
||||
{
|
||||
type = *getContentType()->getValue().dynamicCast <const mediaType>();
|
||||
type = *getContentType()->getValue <mediaType>();
|
||||
}
|
||||
catch (exceptions::no_such_field&)
|
||||
{
|
||||
@ -76,7 +76,7 @@ const word bodyPartAttachment::getName() const
|
||||
{
|
||||
try
|
||||
{
|
||||
ref <parameter> prm = getContentType()->findParameter("name");
|
||||
shared_ptr <parameter> prm = getContentType()->findParameter("name");
|
||||
|
||||
if (prm != NULL)
|
||||
name = prm->getValue();
|
||||
@ -101,10 +101,10 @@ const text bodyPartAttachment::getDescription() const
|
||||
|
||||
try
|
||||
{
|
||||
ref <const headerField> cd =
|
||||
shared_ptr <const headerField> cd =
|
||||
getHeader()->findField(fields::CONTENT_DESCRIPTION);
|
||||
|
||||
description = *cd->getValue().dynamicCast <const text>();
|
||||
description = *cd->getValue <text>();
|
||||
}
|
||||
catch (exceptions::no_such_field&)
|
||||
{
|
||||
@ -121,39 +121,37 @@ const encoding bodyPartAttachment::getEncoding() const
|
||||
}
|
||||
|
||||
|
||||
const ref <const contentHandler> bodyPartAttachment::getData() const
|
||||
const shared_ptr <const contentHandler> bodyPartAttachment::getData() const
|
||||
{
|
||||
return m_part->getBody()->getContents();
|
||||
}
|
||||
|
||||
|
||||
ref <const object> bodyPartAttachment::getPart() const
|
||||
shared_ptr <const object> bodyPartAttachment::getPart() const
|
||||
{
|
||||
return m_part;
|
||||
}
|
||||
|
||||
|
||||
ref <const header> bodyPartAttachment::getHeader() const
|
||||
shared_ptr <const header> bodyPartAttachment::getHeader() const
|
||||
{
|
||||
return m_part->getHeader();
|
||||
}
|
||||
|
||||
|
||||
ref <const contentDispositionField> bodyPartAttachment::getContentDisposition() const
|
||||
shared_ptr <const contentDispositionField> bodyPartAttachment::getContentDisposition() const
|
||||
{
|
||||
return getHeader()->findField(fields::CONTENT_DISPOSITION).
|
||||
dynamicCast <const contentDispositionField>();
|
||||
return getHeader()->findField <contentDispositionField>(fields::CONTENT_DISPOSITION);
|
||||
}
|
||||
|
||||
|
||||
ref <const contentTypeField> bodyPartAttachment::getContentType() const
|
||||
shared_ptr <const contentTypeField> bodyPartAttachment::getContentType() const
|
||||
{
|
||||
return getHeader()->findField(fields::CONTENT_TYPE).
|
||||
dynamicCast <const contentTypeField>();
|
||||
return getHeader()->findField <contentTypeField>(fields::CONTENT_TYPE);
|
||||
}
|
||||
|
||||
|
||||
void bodyPartAttachment::generateIn(ref <bodyPart> /* parent */) const
|
||||
void bodyPartAttachment::generateIn(shared_ptr <bodyPart> /* parent */) const
|
||||
{
|
||||
// Not used
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ void charset::convert(utility::inputStream& in, utility::outputStream& out,
|
||||
const charset& source, const charset& dest,
|
||||
const charsetConverterOptions& opts)
|
||||
{
|
||||
ref <charsetConverter> conv = charsetConverter::create(source, dest, opts);
|
||||
shared_ptr <charsetConverter> 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 <charsetConverter> conv = charsetConverter::create(source, dest, opts);
|
||||
shared_ptr <charsetConverter> conv = charsetConverter::create(source, dest, opts);
|
||||
conv->convert(in, out);
|
||||
}
|
||||
|
||||
@ -134,9 +134,9 @@ bool charset::operator!=(const charset& value) const
|
||||
}
|
||||
|
||||
|
||||
ref <component> charset::clone() const
|
||||
shared_ptr <component> charset::clone() const
|
||||
{
|
||||
return vmime::create <charset>(m_name);
|
||||
return make_shared <charset>(m_name);
|
||||
}
|
||||
|
||||
|
||||
@ -152,9 +152,9 @@ void charset::copyFrom(const component& other)
|
||||
}
|
||||
|
||||
|
||||
const std::vector <ref <component> > charset::getChildComponents()
|
||||
const std::vector <shared_ptr <component> > charset::getChildComponents()
|
||||
{
|
||||
return std::vector <ref <component> >();
|
||||
return std::vector <shared_ptr <component> >();
|
||||
}
|
||||
|
||||
|
||||
|
@ -31,12 +31,12 @@ namespace vmime
|
||||
|
||||
|
||||
// static
|
||||
ref <charsetConverter> charsetConverter::create
|
||||
shared_ptr <charsetConverter> charsetConverter::create
|
||||
(const charset& source, const charset& dest,
|
||||
const charsetConverterOptions& opts)
|
||||
{
|
||||
if (source == "idna" || dest == "idna")
|
||||
return vmime::create <charsetConverter_idna>(source, dest, opts);
|
||||
return make_shared <charsetConverter_idna>(source, dest, opts);
|
||||
else
|
||||
return createGenericConverter(source, dest, opts);
|
||||
}
|
||||
|
@ -89,11 +89,11 @@ namespace vmime
|
||||
|
||||
|
||||
// static
|
||||
ref <charsetConverter> charsetConverter::createGenericConverter
|
||||
shared_ptr <charsetConverter> charsetConverter::createGenericConverter
|
||||
(const charset& source, const charset& dest,
|
||||
const charsetConverterOptions& opts)
|
||||
{
|
||||
return vmime::create <charsetConverter_iconv>(source, dest, opts);
|
||||
return make_shared <charsetConverter_iconv>(source, dest, opts);
|
||||
}
|
||||
|
||||
|
||||
@ -222,9 +222,9 @@ void charsetConverter_iconv::convert(const string& in, string& out)
|
||||
}
|
||||
|
||||
|
||||
ref <utility::charsetFilteredOutputStream> charsetConverter_iconv::getFilteredOutputStream(utility::outputStream& os)
|
||||
shared_ptr <utility::charsetFilteredOutputStream> charsetConverter_iconv::getFilteredOutputStream(utility::outputStream& os)
|
||||
{
|
||||
return vmime::create <utility::charsetFilteredOutputStream_iconv>(m_source, m_dest, &os);
|
||||
return make_shared <utility::charsetFilteredOutputStream_iconv>(m_source, m_dest, &os);
|
||||
}
|
||||
|
||||
|
||||
|
@ -53,11 +53,11 @@ namespace vmime
|
||||
|
||||
|
||||
// static
|
||||
ref <charsetConverter> charsetConverter::createGenericConverter
|
||||
shared_ptr <charsetConverter> charsetConverter::createGenericConverter
|
||||
(const charset& source, const charset& dest,
|
||||
const charsetConverterOptions& opts)
|
||||
{
|
||||
return vmime::create <charsetConverter_icu>(source, dest, opts);
|
||||
return make_shared <charsetConverter_icu>(source, dest, opts);
|
||||
}
|
||||
|
||||
|
||||
@ -195,9 +195,9 @@ void charsetConverter_icu::convert(const string& in, string& out)
|
||||
}
|
||||
|
||||
|
||||
ref <utility::charsetFilteredOutputStream> charsetConverter_icu::getFilteredOutputStream(utility::outputStream& os)
|
||||
shared_ptr <utility::charsetFilteredOutputStream> charsetConverter_icu::getFilteredOutputStream(utility::outputStream& os)
|
||||
{
|
||||
return vmime::create <utility::charsetFilteredOutputStream_icu>(m_source, m_dest, &os);
|
||||
return make_shared <utility::charsetFilteredOutputStream_icu>(m_source, m_dest, &os);
|
||||
}
|
||||
|
||||
|
||||
|
@ -159,9 +159,9 @@ void charsetConverter_idna::convert(const string& in, string& out)
|
||||
}
|
||||
|
||||
|
||||
ref <utility::charsetFilteredOutputStream> charsetConverter_idna::getFilteredOutputStream(utility::outputStream& /* os */)
|
||||
shared_ptr <utility::charsetFilteredOutputStream> charsetConverter_idna::getFilteredOutputStream(utility::outputStream& /* os */)
|
||||
{
|
||||
return NULL;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
@ -47,14 +47,14 @@ component::~component()
|
||||
|
||||
|
||||
void component::parse
|
||||
(ref <utility::inputStream> inputStream, const utility::stream::size_type length)
|
||||
(shared_ptr <utility::inputStream> inputStream, const utility::stream::size_type length)
|
||||
{
|
||||
parse(inputStream, 0, length, NULL);
|
||||
}
|
||||
|
||||
|
||||
void component::parse
|
||||
(ref <utility::inputStream> inputStream, const utility::stream::size_type position,
|
||||
(shared_ptr <utility::inputStream> 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 <utility::inputStream> inputStream, const utility::stream::size_type position,
|
||||
shared_ptr <utility::inputStream> inputStream, const utility::stream::size_type position,
|
||||
const utility::stream::size_type end, utility::stream::size_type* newPosition)
|
||||
{
|
||||
m_parsedOffset = m_parsedLength = 0;
|
||||
|
||||
ref <utility::seekableInputStream> seekableStream =
|
||||
inputStream.dynamicCast <utility::seekableInputStream>();
|
||||
shared_ptr <utility::seekableInputStream> seekableStream =
|
||||
dynamicCast <utility::seekableInputStream>(inputStream);
|
||||
|
||||
if (seekableStream == NULL || end == 0)
|
||||
{
|
||||
@ -84,8 +84,8 @@ void component::parse
|
||||
}
|
||||
else
|
||||
{
|
||||
ref <utility::parserInputStreamAdapter> parser =
|
||||
vmime::create <utility::parserInputStreamAdapter>(seekableStream);
|
||||
shared_ptr <utility::parserInputStreamAdapter> parser =
|
||||
make_shared <utility::parserInputStreamAdapter>(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 <ref <component> > children = getChildComponents();
|
||||
std::vector <shared_ptr <component> > 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 <utility::parserInputStreamAdapter> parser,
|
||||
(const parsingContext& ctx, shared_ptr <utility::parserInputStreamAdapter> 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 <utility::seekableInputStream> stream =
|
||||
vmime::create <utility::inputStreamStringAdapter>(buffer);
|
||||
shared_ptr <utility::seekableInputStream> stream =
|
||||
make_shared <utility::inputStreamStringAdapter>(buffer);
|
||||
|
||||
ref <utility::parserInputStreamAdapter> parser =
|
||||
vmime::create <utility::parserInputStreamAdapter>(stream);
|
||||
shared_ptr <utility::parserInputStreamAdapter> parser =
|
||||
make_shared <utility::parserInputStreamAdapter>(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 <ref <component> > children = getChildComponents();
|
||||
std::vector <shared_ptr <component> > children = getChildComponents();
|
||||
utility::stream::size_type totalSize = 0;
|
||||
|
||||
for (std::vector <ref <component> >::iterator it = children.begin() ; it != children.end() ; ++it)
|
||||
for (std::vector <shared_ptr <component> >::iterator it = children.begin() ; it != children.end() ; ++it)
|
||||
totalSize += (*it)->getGeneratedSize(ctx);
|
||||
|
||||
return totalSize;
|
||||
|
@ -91,9 +91,9 @@ bool contentDisposition::operator!=(const contentDisposition& value) const
|
||||
}
|
||||
|
||||
|
||||
ref <component> contentDisposition::clone() const
|
||||
shared_ptr <component> contentDisposition::clone() const
|
||||
{
|
||||
return vmime::create <contentDisposition>(*this);
|
||||
return make_shared <contentDisposition>(*this);
|
||||
}
|
||||
|
||||
|
||||
@ -124,9 +124,9 @@ void contentDisposition::setName(const string& name)
|
||||
}
|
||||
|
||||
|
||||
const std::vector <ref <component> > contentDisposition::getChildComponents()
|
||||
const std::vector <shared_ptr <component> > contentDisposition::getChildComponents()
|
||||
{
|
||||
return std::vector <ref <component> >();
|
||||
return std::vector <shared_ptr <component> >();
|
||||
}
|
||||
|
||||
|
||||
|
@ -776,15 +776,15 @@ const datetime datetime::now()
|
||||
}
|
||||
|
||||
|
||||
ref <component> datetime::clone() const
|
||||
shared_ptr <component> datetime::clone() const
|
||||
{
|
||||
return vmime::create <datetime>(*this);
|
||||
return make_shared <datetime>(*this);
|
||||
}
|
||||
|
||||
|
||||
const std::vector <ref <component> > datetime::getChildComponents()
|
||||
const std::vector <shared_ptr <component> > datetime::getChildComponents()
|
||||
{
|
||||
return std::vector <ref <component> >();
|
||||
return std::vector <shared_ptr <component> >();
|
||||
}
|
||||
|
||||
|
||||
|
@ -37,14 +37,14 @@ defaultAttachment::defaultAttachment()
|
||||
}
|
||||
|
||||
|
||||
defaultAttachment::defaultAttachment(ref <const contentHandler> data,
|
||||
defaultAttachment::defaultAttachment(shared_ptr <const contentHandler> 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 <const contentHandler> data,
|
||||
defaultAttachment::defaultAttachment(shared_ptr <const contentHandler> 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 <const contentHandler> data,
|
||||
|
||||
defaultAttachment::defaultAttachment(const defaultAttachment& attach)
|
||||
: attachment(), m_type(attach.m_type), m_desc(attach.m_desc),
|
||||
m_data(attach.m_data->clone().dynamicCast <contentHandler>()),
|
||||
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 <contentHandler>();
|
||||
m_data = vmime::clone(attach.m_data);
|
||||
m_encoding = attach.m_encoding;
|
||||
|
||||
return (*this);
|
||||
}
|
||||
|
||||
|
||||
void defaultAttachment::generateIn(ref <bodyPart> parent) const
|
||||
void defaultAttachment::generateIn(shared_ptr <bodyPart> parent) const
|
||||
{
|
||||
// Create and append a new part for this attachment
|
||||
ref <bodyPart> part = vmime::create <bodyPart>();
|
||||
shared_ptr <bodyPart> part = make_shared <bodyPart>();
|
||||
parent->getBody()->appendPart(part);
|
||||
|
||||
generatePart(part);
|
||||
}
|
||||
|
||||
|
||||
void defaultAttachment::generatePart(ref <bodyPart> part) const
|
||||
void defaultAttachment::generatePart(shared_ptr <bodyPart> 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 <contentDispositionField>()->setFilename(m_name);
|
||||
dynamicCast <contentDispositionField>(part->getHeader()->ContentDisposition())->setFilename(m_name);
|
||||
|
||||
// Set contents
|
||||
part->getBody()->setContents(m_data);
|
||||
@ -119,7 +119,7 @@ const word defaultAttachment::getName() const
|
||||
}
|
||||
|
||||
|
||||
const ref <const contentHandler> defaultAttachment::getData() const
|
||||
const shared_ptr <const contentHandler> defaultAttachment::getData() const
|
||||
{
|
||||
return m_data;
|
||||
}
|
||||
@ -131,15 +131,15 @@ const encoding defaultAttachment::getEncoding() const
|
||||
}
|
||||
|
||||
|
||||
ref <const object> defaultAttachment::getPart() const
|
||||
shared_ptr <const object> defaultAttachment::getPart() const
|
||||
{
|
||||
return NULL;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
ref <const header> defaultAttachment::getHeader() const
|
||||
shared_ptr <const header> defaultAttachment::getHeader() const
|
||||
{
|
||||
return NULL;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
@ -44,9 +44,9 @@ disposition::disposition(const string& actionMode, const string& sendingMode,
|
||||
}
|
||||
|
||||
|
||||
ref <component> disposition::clone() const
|
||||
shared_ptr <component> disposition::clone() const
|
||||
{
|
||||
ref <disposition> disp = vmime::create <disposition>();
|
||||
shared_ptr <disposition> disp = make_shared <disposition>();
|
||||
|
||||
disp->m_actionMode = m_actionMode;
|
||||
disp->m_sendingMode = m_sendingMode;
|
||||
@ -79,9 +79,9 @@ disposition& disposition::operator=(const disposition& other)
|
||||
}
|
||||
|
||||
|
||||
const std::vector <ref <component> > disposition::getChildComponents()
|
||||
const std::vector <shared_ptr <component> > disposition::getChildComponents()
|
||||
{
|
||||
return std::vector <ref <component> >();
|
||||
return std::vector <shared_ptr <component> >();
|
||||
}
|
||||
|
||||
|
||||
|
@ -469,9 +469,9 @@ emailAddress& emailAddress::operator=(const emailAddress& other)
|
||||
}
|
||||
|
||||
|
||||
ref <component>emailAddress::clone() const
|
||||
shared_ptr <component>emailAddress::clone() const
|
||||
{
|
||||
return vmime::create <emailAddress>(*this);
|
||||
return make_shared <emailAddress>(*this);
|
||||
}
|
||||
|
||||
|
||||
@ -499,9 +499,9 @@ void emailAddress::setDomainName(const word& domainName)
|
||||
}
|
||||
|
||||
|
||||
const std::vector <ref <component> > emailAddress::getChildComponents()
|
||||
const std::vector <shared_ptr <component> > emailAddress::getChildComponents()
|
||||
{
|
||||
return std::vector <ref <component> >();
|
||||
return std::vector <shared_ptr <component> >();
|
||||
}
|
||||
|
||||
|
||||
@ -528,9 +528,9 @@ const string emailAddress::toString() const
|
||||
const text emailAddress::toText() const
|
||||
{
|
||||
text txt;
|
||||
txt.appendWord(vmime::create <vmime::word>(m_localName));
|
||||
txt.appendWord(vmime::create <vmime::word>("@", vmime::charsets::US_ASCII));
|
||||
txt.appendWord(vmime::create <vmime::word>(m_domainName));
|
||||
txt.appendWord(make_shared <vmime::word>(m_localName));
|
||||
txt.appendWord(make_shared <vmime::word>("@", vmime::charsets::US_ASCII));
|
||||
txt.appendWord(make_shared <vmime::word>(m_domainName));
|
||||
|
||||
return txt;
|
||||
}
|
||||
|
@ -33,9 +33,9 @@ emptyContentHandler::emptyContentHandler()
|
||||
}
|
||||
|
||||
|
||||
ref <contentHandler> emptyContentHandler::clone() const
|
||||
shared_ptr <contentHandler> emptyContentHandler::clone() const
|
||||
{
|
||||
return vmime::create <emptyContentHandler>();
|
||||
return make_shared <emptyContentHandler>();
|
||||
}
|
||||
|
||||
|
||||
|
@ -92,9 +92,9 @@ void encoding::generateImpl
|
||||
}
|
||||
|
||||
|
||||
ref <utility::encoder::encoder> encoding::getEncoder() const
|
||||
shared_ptr <utility::encoder::encoder> encoding::getEncoder() const
|
||||
{
|
||||
ref <utility::encoder::encoder> encoder =
|
||||
shared_ptr <utility::encoder::encoder> 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 <const contentHandler> data, const EncodingUsage usage)
|
||||
(shared_ptr <const contentHandler> 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 <const contentHandler> data,
|
||||
const encoding encoding::decide(shared_ptr <const contentHandler> 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 <const contentHandler> data,
|
||||
}
|
||||
|
||||
|
||||
ref <component> encoding::clone() const
|
||||
shared_ptr <component> encoding::clone() const
|
||||
{
|
||||
return vmime::create <encoding>(*this);
|
||||
return make_shared <encoding>(*this);
|
||||
}
|
||||
|
||||
|
||||
@ -291,9 +291,9 @@ void encoding::setUsage(const EncodingUsage usage)
|
||||
}
|
||||
|
||||
|
||||
const std::vector <ref <component> > encoding::getChildComponents()
|
||||
const std::vector <shared_ptr <component> > encoding::getChildComponents()
|
||||
{
|
||||
return std::vector <ref <component> >();
|
||||
return std::vector <shared_ptr <component> >();
|
||||
}
|
||||
|
||||
|
||||
|
@ -79,7 +79,7 @@ fileAttachment::fileAttachment(const string& filepath, const mediaType& type,
|
||||
}
|
||||
|
||||
|
||||
fileAttachment::fileAttachment(ref <contentHandler> cts, const word& filename, const mediaType& type)
|
||||
fileAttachment::fileAttachment(shared_ptr <contentHandler> cts, const word& filename, const mediaType& type)
|
||||
{
|
||||
if (!filename.isEmpty())
|
||||
m_fileInfo.setFilename(filename);
|
||||
@ -92,7 +92,7 @@ fileAttachment::fileAttachment(ref <contentHandler> cts, const word& filename, c
|
||||
}
|
||||
|
||||
|
||||
fileAttachment::fileAttachment(ref <contentHandler> cts, const word& filename,
|
||||
fileAttachment::fileAttachment(shared_ptr <contentHandler> cts, const word& filename,
|
||||
const mediaType& type, const text& desc)
|
||||
{
|
||||
if (!filename.isEmpty())
|
||||
@ -107,7 +107,7 @@ fileAttachment::fileAttachment(ref <contentHandler> cts, const word& filename,
|
||||
}
|
||||
|
||||
|
||||
fileAttachment::fileAttachment(ref <contentHandler> cts, const word& filename,
|
||||
fileAttachment::fileAttachment(shared_ptr <contentHandler> cts, const word& filename,
|
||||
const mediaType& type, const text& desc, const encoding& enc)
|
||||
{
|
||||
if (!filename.isEmpty())
|
||||
@ -123,15 +123,15 @@ fileAttachment::fileAttachment(ref <contentHandler> cts, const word& filename,
|
||||
|
||||
void fileAttachment::setData(const string& filepath)
|
||||
{
|
||||
ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
utility::file::path path = fsf->stringToPath(filepath);
|
||||
|
||||
ref <utility::file> file = fsf->create(path);
|
||||
shared_ptr <utility::file> file = fsf->create(path);
|
||||
|
||||
if (!file->isFile())
|
||||
throw exceptions::open_file_error();
|
||||
|
||||
m_data = vmime::create <streamContentHandler>
|
||||
m_data = make_shared <streamContentHandler>
|
||||
(file->getFileReader()->getInputStream(), file->getLength());
|
||||
|
||||
m_fileInfo.setFilename(path.getLastComponent());
|
||||
@ -139,7 +139,7 @@ void fileAttachment::setData(const string& filepath)
|
||||
}
|
||||
|
||||
|
||||
void fileAttachment::setData(ref <contentHandler> cts)
|
||||
void fileAttachment::setData(shared_ptr <contentHandler> cts)
|
||||
{
|
||||
m_data = cts;
|
||||
|
||||
@ -147,12 +147,12 @@ void fileAttachment::setData(ref <contentHandler> cts)
|
||||
}
|
||||
|
||||
|
||||
void fileAttachment::generatePart(ref <bodyPart> part) const
|
||||
void fileAttachment::generatePart(shared_ptr <bodyPart> part) const
|
||||
{
|
||||
defaultAttachment::generatePart(part);
|
||||
|
||||
ref <contentDispositionField> cdf = part->getHeader()->ContentDisposition().
|
||||
dynamicCast <contentDispositionField>();
|
||||
shared_ptr <contentDispositionField> cdf =
|
||||
dynamicCast <contentDispositionField>(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());
|
||||
|
@ -35,7 +35,7 @@ fileContentHandler::fileContentHandler()
|
||||
|
||||
|
||||
fileContentHandler::fileContentHandler
|
||||
(ref <utility::file> file, const vmime::encoding& enc)
|
||||
(shared_ptr <utility::file> file, const vmime::encoding& enc)
|
||||
{
|
||||
setData(file, enc);
|
||||
}
|
||||
@ -61,14 +61,14 @@ fileContentHandler& fileContentHandler::operator=(const fileContentHandler& cts)
|
||||
}
|
||||
|
||||
|
||||
ref <contentHandler> fileContentHandler::clone() const
|
||||
shared_ptr <contentHandler> fileContentHandler::clone() const
|
||||
{
|
||||
return vmime::create <fileContentHandler>(*this);
|
||||
return make_shared <fileContentHandler>(*this);
|
||||
}
|
||||
|
||||
|
||||
void fileContentHandler::setData
|
||||
(ref <utility::file> file, const vmime::encoding& enc)
|
||||
(shared_ptr <utility::file> file, const vmime::encoding& enc)
|
||||
{
|
||||
m_file = file;
|
||||
m_encoding = enc;
|
||||
|
@ -30,8 +30,8 @@ namespace vmime
|
||||
{
|
||||
|
||||
|
||||
generatedMessageAttachment::generatedMessageAttachment(ref <const bodyPart> part)
|
||||
: m_bpa(vmime::create <bodyPartAttachment>(part))
|
||||
generatedMessageAttachment::generatedMessageAttachment(shared_ptr <const bodyPart> part)
|
||||
: m_bpa(make_shared <bodyPartAttachment>(part))
|
||||
{
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ const word generatedMessageAttachment::getName() const
|
||||
}
|
||||
|
||||
|
||||
const ref <const contentHandler> generatedMessageAttachment::getData() const
|
||||
const shared_ptr <const contentHandler> generatedMessageAttachment::getData() const
|
||||
{
|
||||
return m_bpa->getData();
|
||||
}
|
||||
@ -66,19 +66,19 @@ const encoding generatedMessageAttachment::getEncoding() const
|
||||
}
|
||||
|
||||
|
||||
ref <const object> generatedMessageAttachment::getPart() const
|
||||
shared_ptr <const object> generatedMessageAttachment::getPart() const
|
||||
{
|
||||
return m_bpa->getPart();
|
||||
}
|
||||
|
||||
|
||||
ref <const header> generatedMessageAttachment::getHeader() const
|
||||
shared_ptr <const header> generatedMessageAttachment::getHeader() const
|
||||
{
|
||||
return m_bpa->getHeader();
|
||||
}
|
||||
|
||||
|
||||
ref <message> generatedMessageAttachment::getMessage() const
|
||||
shared_ptr <message> generatedMessageAttachment::getMessage() const
|
||||
{
|
||||
if (m_msg == NULL)
|
||||
{
|
||||
@ -89,7 +89,7 @@ ref <message> generatedMessageAttachment::getMessage() const
|
||||
getData()->extract(os);
|
||||
|
||||
// Parse message
|
||||
m_msg = vmime::create <message>();
|
||||
m_msg = make_shared <message>();
|
||||
m_msg->parse(oss.str());
|
||||
}
|
||||
|
||||
@ -97,7 +97,7 @@ ref <message> generatedMessageAttachment::getMessage() const
|
||||
}
|
||||
|
||||
|
||||
void generatedMessageAttachment::generateIn(ref <bodyPart> /* parent */) const
|
||||
void generatedMessageAttachment::generateIn(shared_ptr <bodyPart> /* parent */) const
|
||||
{
|
||||
// Not used (see 'parsedMessageAttachment')
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ void header::parseImpl
|
||||
|
||||
while (pos < end)
|
||||
{
|
||||
ref <headerField> field = headerField::parseNext(ctx, buffer, pos, end, &pos);
|
||||
shared_ptr <headerField> 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 <ref <headerField> >::const_iterator it = m_fields.begin() ;
|
||||
for (std::vector <shared_ptr <headerField> >::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 <component> header::clone() const
|
||||
shared_ptr <component> header::clone() const
|
||||
{
|
||||
ref <header> hdr = vmime::create <header>();
|
||||
shared_ptr <header> hdr = make_shared <header>();
|
||||
|
||||
hdr->m_fields.reserve(m_fields.size());
|
||||
|
||||
for (std::vector <ref <headerField> >::const_iterator it = m_fields.begin() ;
|
||||
for (std::vector <shared_ptr <headerField> >::const_iterator it = m_fields.begin() ;
|
||||
it != m_fields.end() ; ++it)
|
||||
{
|
||||
hdr->m_fields.push_back((*it)->clone().dynamicCast <headerField>());
|
||||
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 <const header&>(other);
|
||||
|
||||
std::vector <ref <headerField> > fields;
|
||||
std::vector <shared_ptr <headerField> > fields;
|
||||
|
||||
fields.reserve(h.m_fields.size());
|
||||
|
||||
for (std::vector <ref <headerField> >::const_iterator it = h.m_fields.begin() ;
|
||||
for (std::vector <shared_ptr <headerField> >::const_iterator it = h.m_fields.begin() ;
|
||||
it != h.m_fields.end() ; ++it)
|
||||
{
|
||||
fields.push_back((*it)->clone().dynamicCast <headerField>());
|
||||
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 <ref <headerField> >::const_iterator pos =
|
||||
std::vector <shared_ptr <headerField> >::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 <headerField> header::findField(const string& fieldName) const
|
||||
shared_ptr <headerField> header::findField(const string& fieldName) const
|
||||
{
|
||||
// Find the first field that matches the specified name
|
||||
std::vector <ref <headerField> >::const_iterator pos =
|
||||
std::vector <shared_ptr <headerField> >::const_iterator pos =
|
||||
std::find_if(m_fields.begin(), m_fields.end(),
|
||||
fieldHasName(utility::stringUtils::toLower(fieldName)));
|
||||
|
||||
@ -182,10 +182,10 @@ ref <headerField> header::findField(const string& fieldName) const
|
||||
}
|
||||
|
||||
|
||||
std::vector <ref <headerField> > header::findAllFields(const string& fieldName)
|
||||
std::vector <shared_ptr <headerField> > header::findAllFields(const string& fieldName)
|
||||
{
|
||||
std::vector <ref <headerField> > result;
|
||||
std::back_insert_iterator <std::vector <ref <headerField> > > back(result);
|
||||
std::vector <shared_ptr <headerField> > result;
|
||||
std::back_insert_iterator <std::vector <shared_ptr <headerField> > > back(result);
|
||||
|
||||
std::remove_copy_if(m_fields.begin(), m_fields.end(), back,
|
||||
fieldHasNotName(utility::stringUtils::toLower(fieldName)));
|
||||
@ -194,13 +194,13 @@ std::vector <ref <headerField> > header::findAllFields(const string& fieldName)
|
||||
}
|
||||
|
||||
|
||||
ref <headerField> header::getField(const string& fieldName)
|
||||
shared_ptr <headerField> header::getField(const string& fieldName)
|
||||
{
|
||||
const string name = utility::stringUtils::toLower(fieldName);
|
||||
|
||||
// Find the first field that matches the specified name
|
||||
std::vector <ref <headerField> >::const_iterator pos = m_fields.begin();
|
||||
const std::vector <ref <headerField> >::const_iterator end = m_fields.end();
|
||||
std::vector <shared_ptr <headerField> >::const_iterator pos = m_fields.begin();
|
||||
const std::vector <shared_ptr <headerField> >::const_iterator end = m_fields.end();
|
||||
|
||||
while (pos != end && utility::stringUtils::toLower((*pos)->getName()) != name)
|
||||
++pos;
|
||||
@ -208,7 +208,7 @@ ref <headerField> header::getField(const string& fieldName)
|
||||
// If no field with this name can be found, create a new one
|
||||
if (pos == end)
|
||||
{
|
||||
ref <headerField> field = headerFieldFactory::getInstance()->create(fieldName);
|
||||
shared_ptr <headerField> field = headerFieldFactory::getInstance()->create(fieldName);
|
||||
|
||||
appendField(field);
|
||||
|
||||
@ -223,15 +223,15 @@ ref <headerField> header::getField(const string& fieldName)
|
||||
}
|
||||
|
||||
|
||||
void header::appendField(ref <headerField> field)
|
||||
void header::appendField(shared_ptr <headerField> field)
|
||||
{
|
||||
m_fields.push_back(field);
|
||||
}
|
||||
|
||||
|
||||
void header::insertFieldBefore(ref <headerField> beforeField, ref <headerField> field)
|
||||
void header::insertFieldBefore(shared_ptr <headerField> beforeField, shared_ptr <headerField> field)
|
||||
{
|
||||
const std::vector <ref <headerField> >::iterator it = std::find
|
||||
const std::vector <shared_ptr <headerField> >::iterator it = std::find
|
||||
(m_fields.begin(), m_fields.end(), beforeField);
|
||||
|
||||
if (it == m_fields.end())
|
||||
@ -241,15 +241,15 @@ void header::insertFieldBefore(ref <headerField> beforeField, ref <headerField>
|
||||
}
|
||||
|
||||
|
||||
void header::insertFieldBefore(const size_t pos, ref <headerField> field)
|
||||
void header::insertFieldBefore(const size_t pos, shared_ptr <headerField> field)
|
||||
{
|
||||
m_fields.insert(m_fields.begin() + pos, field);
|
||||
}
|
||||
|
||||
|
||||
void header::insertFieldAfter(ref <headerField> afterField, ref <headerField> field)
|
||||
void header::insertFieldAfter(shared_ptr <headerField> afterField, shared_ptr <headerField> field)
|
||||
{
|
||||
const std::vector <ref <headerField> >::iterator it = std::find
|
||||
const std::vector <shared_ptr <headerField> >::iterator it = std::find
|
||||
(m_fields.begin(), m_fields.end(), afterField);
|
||||
|
||||
if (it == m_fields.end())
|
||||
@ -259,15 +259,15 @@ void header::insertFieldAfter(ref <headerField> afterField, ref <headerField> fi
|
||||
}
|
||||
|
||||
|
||||
void header::insertFieldAfter(const size_t pos, ref <headerField> field)
|
||||
void header::insertFieldAfter(const size_t pos, shared_ptr <headerField> field)
|
||||
{
|
||||
m_fields.insert(m_fields.begin() + pos + 1, field);
|
||||
}
|
||||
|
||||
|
||||
void header::removeField(ref <headerField> field)
|
||||
void header::removeField(shared_ptr <headerField> field)
|
||||
{
|
||||
const std::vector <ref <headerField> >::iterator it = std::find
|
||||
const std::vector <shared_ptr <headerField> >::iterator it = std::find
|
||||
(m_fields.begin(), m_fields.end(), field);
|
||||
|
||||
if (it == m_fields.end())
|
||||
@ -279,13 +279,13 @@ void header::removeField(ref <headerField> field)
|
||||
|
||||
void header::removeField(const size_t pos)
|
||||
{
|
||||
const std::vector <ref <headerField> >::iterator it = m_fields.begin() + pos;
|
||||
const std::vector <shared_ptr <headerField> >::iterator it = m_fields.begin() + pos;
|
||||
|
||||
m_fields.erase(it);
|
||||
}
|
||||
|
||||
|
||||
void header::replaceField(ref <headerField> field, ref <headerField> newField)
|
||||
void header::replaceField(shared_ptr <headerField> field, shared_ptr <headerField> newField)
|
||||
{
|
||||
insertFieldBefore(field, newField);
|
||||
removeField(field);
|
||||
@ -300,7 +300,7 @@ void header::removeAllFields()
|
||||
|
||||
void header::removeAllFields(const string& fieldName)
|
||||
{
|
||||
std::vector <ref <headerField> > fields = findAllFields(fieldName);
|
||||
std::vector <shared_ptr <headerField> > 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 <headerField> header::getFieldAt(const size_t pos)
|
||||
const shared_ptr <headerField> header::getFieldAt(const size_t pos)
|
||||
{
|
||||
return (m_fields[pos]);
|
||||
}
|
||||
|
||||
|
||||
const ref <const headerField> header::getFieldAt(const size_t pos) const
|
||||
const shared_ptr <const headerField> header::getFieldAt(const size_t pos) const
|
||||
{
|
||||
return (m_fields[pos]);
|
||||
}
|
||||
|
||||
|
||||
const std::vector <ref <const headerField> > header::getFieldList() const
|
||||
const std::vector <shared_ptr <const headerField> > header::getFieldList() const
|
||||
{
|
||||
std::vector <ref <const headerField> > list;
|
||||
std::vector <shared_ptr <const headerField> > list;
|
||||
|
||||
list.reserve(m_fields.size());
|
||||
|
||||
for (std::vector <ref <headerField> >::const_iterator it = m_fields.begin() ;
|
||||
for (std::vector <shared_ptr <headerField> >::const_iterator it = m_fields.begin() ;
|
||||
it != m_fields.end() ; ++it)
|
||||
{
|
||||
list.push_back(*it);
|
||||
@ -347,15 +347,15 @@ const std::vector <ref <const headerField> > header::getFieldList() const
|
||||
}
|
||||
|
||||
|
||||
const std::vector <ref <headerField> > header::getFieldList()
|
||||
const std::vector <shared_ptr <headerField> > header::getFieldList()
|
||||
{
|
||||
return (m_fields);
|
||||
}
|
||||
|
||||
|
||||
const std::vector <ref <component> > header::getChildComponents()
|
||||
const std::vector <shared_ptr <component> > header::getChildComponents()
|
||||
{
|
||||
std::vector <ref <component> > list;
|
||||
std::vector <shared_ptr <component> > list;
|
||||
|
||||
copy_vector(m_fields, list);
|
||||
|
||||
@ -372,7 +372,7 @@ header::fieldHasName::fieldHasName(const string& name)
|
||||
{
|
||||
}
|
||||
|
||||
bool header::fieldHasName::operator() (const ref <const headerField>& field)
|
||||
bool header::fieldHasName::operator() (const shared_ptr <const headerField>& 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 <const headerField>& field)
|
||||
bool header::fieldHasNotName::operator() (const shared_ptr <const headerField>& field)
|
||||
{
|
||||
return utility::stringUtils::toLower(field->getName()) != m_name;
|
||||
}
|
||||
|
@ -50,9 +50,9 @@ headerField::~headerField()
|
||||
}
|
||||
|
||||
|
||||
ref <component> headerField::clone() const
|
||||
shared_ptr <component> headerField::clone() const
|
||||
{
|
||||
ref <headerField> field = headerFieldFactory::getInstance()->create(m_name);
|
||||
shared_ptr <headerField> field = headerFieldFactory::getInstance()->create(m_name);
|
||||
|
||||
field->copyFrom(*this);
|
||||
|
||||
@ -75,7 +75,7 @@ headerField& headerField::operator=(const headerField& other)
|
||||
}
|
||||
|
||||
|
||||
ref <headerField> headerField::parseNext
|
||||
shared_ptr <headerField> 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> 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> headerField::parseNext
|
||||
}
|
||||
|
||||
// Return a new field
|
||||
ref <headerField> field = headerFieldFactory::getInstance()->create(name);
|
||||
shared_ptr <headerField> field = headerFieldFactory::getInstance()->create(name);
|
||||
|
||||
field->parse(ctx, buffer, contentsStart, contentsEnd, NULL);
|
||||
field->setParsedBounds(nameStart, pos);
|
||||
@ -253,14 +253,14 @@ ref <headerField> 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> headerField::parseNext
|
||||
if (newPosition)
|
||||
*newPosition = pos;
|
||||
|
||||
return (NULL);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ -321,9 +321,9 @@ bool headerField::isCustom() const
|
||||
}
|
||||
|
||||
|
||||
const std::vector <ref <component> > headerField::getChildComponents()
|
||||
const std::vector <shared_ptr <component> > headerField::getChildComponents()
|
||||
{
|
||||
std::vector <ref <component> > list;
|
||||
std::vector <shared_ptr <component> > list;
|
||||
|
||||
if (m_value)
|
||||
list.push_back(m_value);
|
||||
@ -332,19 +332,19 @@ const std::vector <ref <component> > headerField::getChildComponents()
|
||||
}
|
||||
|
||||
|
||||
ref <const headerFieldValue> headerField::getValue() const
|
||||
shared_ptr <const headerFieldValue> headerField::getValue() const
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
|
||||
|
||||
ref <headerFieldValue> headerField::getValue()
|
||||
shared_ptr <headerFieldValue> headerField::getValue()
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
|
||||
|
||||
void headerField::setValue(ref <headerFieldValue> value)
|
||||
void headerField::setValue(shared_ptr <headerFieldValue> value)
|
||||
{
|
||||
if (!headerFieldFactory::getInstance()->isValueTypeValid(*this, *value))
|
||||
throw exceptions::bad_field_value_type(getName());
|
||||
@ -354,12 +354,12 @@ void headerField::setValue(ref <headerFieldValue> value)
|
||||
}
|
||||
|
||||
|
||||
void headerField::setValueConst(ref <const headerFieldValue> value)
|
||||
void headerField::setValueConst(shared_ptr <const headerFieldValue> value)
|
||||
{
|
||||
if (!headerFieldFactory::getInstance()->isValueTypeValid(*this, *value))
|
||||
throw exceptions::bad_field_value_type(getName());
|
||||
|
||||
m_value = value->clone().dynamicCast <headerFieldValue>();
|
||||
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 <headerFieldValue>();
|
||||
m_value = vmime::clone(value);
|
||||
}
|
||||
|
||||
|
||||
|
@ -90,18 +90,18 @@ headerFieldFactory::~headerFieldFactory()
|
||||
}
|
||||
|
||||
|
||||
headerFieldFactory* headerFieldFactory::getInstance()
|
||||
shared_ptr <headerFieldFactory> headerFieldFactory::getInstance()
|
||||
{
|
||||
static headerFieldFactory instance;
|
||||
return (&instance);
|
||||
return shared_ptr <headerFieldFactory>(&instance, noop_shared_ptr_deleter <headerFieldFactory>());
|
||||
}
|
||||
|
||||
|
||||
ref <headerField> headerFieldFactory::create
|
||||
shared_ptr <headerField> headerFieldFactory::create
|
||||
(const string& name, const string& body)
|
||||
{
|
||||
NameMap::const_iterator pos = m_nameMap.find(utility::stringUtils::toLower(name));
|
||||
ref <headerField> field = NULL;
|
||||
shared_ptr <headerField> field;
|
||||
|
||||
if (pos != m_nameMap.end())
|
||||
field = ((*pos).second)();
|
||||
@ -118,12 +118,12 @@ ref <headerField> headerFieldFactory::create
|
||||
}
|
||||
|
||||
|
||||
ref <headerFieldValue> headerFieldFactory::createValue(const string& fieldName)
|
||||
shared_ptr <headerFieldValue> headerFieldFactory::createValue(const string& fieldName)
|
||||
{
|
||||
ValueMap::const_iterator pos = m_valueMap.find
|
||||
(utility::stringUtils::toLower(fieldName));
|
||||
|
||||
ref <headerFieldValue> value = NULL;
|
||||
shared_ptr <headerFieldValue> value;
|
||||
|
||||
if (pos != m_valueMap.end())
|
||||
value = ((*pos).second.allocFunc)();
|
||||
|
@ -39,8 +39,8 @@ namespace vmime
|
||||
|
||||
|
||||
htmlTextPart::htmlTextPart()
|
||||
: m_plainText(vmime::create <emptyContentHandler>()),
|
||||
m_text(vmime::create <emptyContentHandler>())
|
||||
: m_plainText(make_shared <emptyContentHandler>()),
|
||||
m_text(make_shared <emptyContentHandler>())
|
||||
{
|
||||
}
|
||||
|
||||
@ -62,13 +62,13 @@ size_t htmlTextPart::getPartCount() const
|
||||
}
|
||||
|
||||
|
||||
void htmlTextPart::generateIn(ref <bodyPart> /* message */, ref <bodyPart> parent) const
|
||||
void htmlTextPart::generateIn(shared_ptr <bodyPart> /* message */, shared_ptr <bodyPart> parent) const
|
||||
{
|
||||
// Plain text
|
||||
if (!m_plainText->isEmpty())
|
||||
{
|
||||
// -- Create a new part
|
||||
ref <bodyPart> part = vmime::create <bodyPart>();
|
||||
shared_ptr <bodyPart> part = make_shared <bodyPart>();
|
||||
parent->getBody()->appendPart(part);
|
||||
|
||||
// -- Set contents
|
||||
@ -79,7 +79,7 @@ void htmlTextPart::generateIn(ref <bodyPart> /* message */, ref <bodyPart> paren
|
||||
|
||||
// HTML text
|
||||
// -- Create a new part
|
||||
ref <bodyPart> htmlPart = vmime::create <bodyPart>();
|
||||
shared_ptr <bodyPart> htmlPart = make_shared <bodyPart>();
|
||||
|
||||
// -- Set contents
|
||||
htmlPart->getBody()->setContents(m_text,
|
||||
@ -90,7 +90,7 @@ void htmlTextPart::generateIn(ref <bodyPart> /* message */, ref <bodyPart> paren
|
||||
if (!m_objects.empty())
|
||||
{
|
||||
// Create a "multipart/related" body part
|
||||
ref <bodyPart> relPart = vmime::create <bodyPart>();
|
||||
shared_ptr <bodyPart> relPart = make_shared <bodyPart>();
|
||||
parent->getBody()->appendPart(relPart);
|
||||
|
||||
relPart->getHeader()->ContentType()->
|
||||
@ -100,10 +100,10 @@ void htmlTextPart::generateIn(ref <bodyPart> /* message */, ref <bodyPart> paren
|
||||
relPart->getBody()->appendPart(htmlPart);
|
||||
|
||||
// Also add objects into this part
|
||||
for (std::vector <ref <embeddedObject> >::const_iterator it = m_objects.begin() ;
|
||||
for (std::vector <shared_ptr <embeddedObject> >::const_iterator it = m_objects.begin() ;
|
||||
it != m_objects.end() ; ++it)
|
||||
{
|
||||
ref <bodyPart> objPart = vmime::create <bodyPart>();
|
||||
shared_ptr <bodyPart> objPart = make_shared <bodyPart>();
|
||||
relPart->getBody()->appendPart(objPart);
|
||||
|
||||
string id = (*it)->getId();
|
||||
@ -129,11 +129,11 @@ void htmlTextPart::generateIn(ref <bodyPart> /* message */, ref <bodyPart> paren
|
||||
|
||||
|
||||
void htmlTextPart::findEmbeddedParts(const bodyPart& part,
|
||||
std::vector <ref <const bodyPart> >& cidParts, std::vector <ref <const bodyPart> >& locParts)
|
||||
std::vector <shared_ptr <const bodyPart> >& cidParts, std::vector <shared_ptr <const bodyPart> >& locParts)
|
||||
{
|
||||
for (size_t i = 0 ; i < part.getBody()->getPartCount() ; ++i)
|
||||
{
|
||||
ref <const bodyPart> p = part.getBody()->getPartAt(i);
|
||||
shared_ptr <const bodyPart> 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 <const headerField> ctf = part.getHeader()->ContentType();
|
||||
type = *ctf->getValue().dynamicCast <const mediaType>();
|
||||
const shared_ptr <const headerField> ctf = part.getHeader()->ContentType();
|
||||
type = *ctf->getValue <mediaType>();
|
||||
}
|
||||
catch (exceptions::no_such_field)
|
||||
{
|
||||
// No "Content-type" field: assume "application/octet-stream".
|
||||
}
|
||||
|
||||
m_objects.push_back(vmime::create <embeddedObject>
|
||||
(part.getBody()->getContents()->clone().dynamicCast <contentHandler>(),
|
||||
m_objects.push_back(make_shared <embeddedObject>
|
||||
(vmime::clone(part.getBody()->getContents()),
|
||||
part.getBody()->getEncoding(), id, type, refType));
|
||||
}
|
||||
|
||||
|
||||
void htmlTextPart::parse(ref <const bodyPart> message, ref <const bodyPart> parent, ref <const bodyPart> textPart)
|
||||
void htmlTextPart::parse(shared_ptr <const bodyPart> message, shared_ptr <const bodyPart> parent, shared_ptr <const bodyPart> textPart)
|
||||
{
|
||||
// Search for possible embedded objects in the _whole_ message.
|
||||
std::vector <ref <const bodyPart> > cidParts;
|
||||
std::vector <ref <const bodyPart> > locParts;
|
||||
std::vector <shared_ptr <const bodyPart> > cidParts;
|
||||
std::vector <shared_ptr <const bodyPart> > locParts;
|
||||
|
||||
findEmbeddedParts(*message, cidParts, locParts);
|
||||
|
||||
@ -208,8 +208,8 @@ void htmlTextPart::parse(ref <const bodyPart> message, ref <const bodyPart> pare
|
||||
|
||||
try
|
||||
{
|
||||
const ref <const contentTypeField> ctf =
|
||||
textPart->getHeader()->findField(fields::CONTENT_TYPE).dynamicCast <contentTypeField>();
|
||||
const shared_ptr <const contentTypeField> ctf =
|
||||
textPart->getHeader()->findField <contentTypeField>(fields::CONTENT_TYPE);
|
||||
|
||||
m_charset = ctf->getCharset();
|
||||
}
|
||||
@ -224,12 +224,12 @@ void htmlTextPart::parse(ref <const bodyPart> message, ref <const bodyPart> 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 <ref <const bodyPart> >::const_iterator p = cidParts.begin() ; p != cidParts.end() ; ++p)
|
||||
for (std::vector <shared_ptr <const bodyPart> >::const_iterator p = cidParts.begin() ; p != cidParts.end() ; ++p)
|
||||
{
|
||||
const ref <const headerField> midField =
|
||||
const shared_ptr <const headerField> midField =
|
||||
(*p)->getHeader()->findField(fields::CONTENT_ID);
|
||||
|
||||
const messageId mid = *midField->getValue().dynamicCast <const messageId>();
|
||||
const messageId mid = *midField->getValue <messageId>();
|
||||
|
||||
if (data.find("CID:" + mid.getId()) != string::npos ||
|
||||
data.find("cid:" + mid.getId()) != string::npos)
|
||||
@ -240,12 +240,12 @@ void htmlTextPart::parse(ref <const bodyPart> message, ref <const bodyPart> pare
|
||||
}
|
||||
}
|
||||
|
||||
for (std::vector <ref <const bodyPart> >::const_iterator p = locParts.begin() ; p != locParts.end() ; ++p)
|
||||
for (std::vector <shared_ptr <const bodyPart> >::const_iterator p = locParts.begin() ; p != locParts.end() ; ++p)
|
||||
{
|
||||
const ref <const headerField> locField =
|
||||
const shared_ptr <const headerField> locField =
|
||||
(*p)->getHeader()->findField(fields::CONTENT_LOCATION);
|
||||
|
||||
const text loc = *locField->getValue().dynamicCast <const text>();
|
||||
const text loc = *locField->getValue <text>();
|
||||
const string locStr = loc.getWholeBuffer();
|
||||
|
||||
if (data.find(locStr) != string::npos)
|
||||
@ -259,7 +259,7 @@ void htmlTextPart::parse(ref <const bodyPart> message, ref <const bodyPart> pare
|
||||
// Extract plain text, if any.
|
||||
if (!findPlainTextPart(*message, *parent, *textPart))
|
||||
{
|
||||
m_plainText = vmime::create <emptyContentHandler>();
|
||||
m_plainText = make_shared <emptyContentHandler>();
|
||||
}
|
||||
}
|
||||
|
||||
@ -269,22 +269,22 @@ bool htmlTextPart::findPlainTextPart(const bodyPart& part, const bodyPart& paren
|
||||
// We search for the nearest "multipart/alternative" part.
|
||||
try
|
||||
{
|
||||
const ref <const headerField> ctf =
|
||||
const shared_ptr <const headerField> ctf =
|
||||
part.getHeader()->findField(fields::CONTENT_TYPE);
|
||||
|
||||
const mediaType type = *ctf->getValue().dynamicCast <const mediaType>();
|
||||
const mediaType type = *ctf->getValue <mediaType>();
|
||||
|
||||
if (type.getType() == mediaTypes::MULTIPART &&
|
||||
type.getSubType() == mediaTypes::MULTIPART_ALTERNATIVE)
|
||||
{
|
||||
ref <const bodyPart> foundPart = NULL;
|
||||
shared_ptr <const bodyPart> foundPart;
|
||||
|
||||
for (size_t i = 0 ; i < part.getBody()->getPartCount() ; ++i)
|
||||
{
|
||||
const ref <const bodyPart> p = part.getBody()->getPartAt(i);
|
||||
const shared_ptr <const bodyPart> 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 <const bodyPart> p = part.getBody()->getPartAt(i);
|
||||
const shared_ptr <const bodyPart> p = part.getBody()->getPartAt(i);
|
||||
|
||||
try
|
||||
{
|
||||
const ref <const headerField> ctf =
|
||||
const shared_ptr <const headerField> ctf =
|
||||
p->getHeader()->findField(fields::CONTENT_TYPE);
|
||||
|
||||
const mediaType type = *ctf->getValue().dynamicCast <const mediaType>();
|
||||
const mediaType type = *ctf->getValue <mediaType>();
|
||||
|
||||
if (type.getType() == mediaTypes::TEXT &&
|
||||
type.getSubType() == mediaTypes::TEXT_PLAIN)
|
||||
@ -354,25 +354,25 @@ void htmlTextPart::setCharset(const charset& ch)
|
||||
}
|
||||
|
||||
|
||||
ref <const contentHandler> htmlTextPart::getPlainText() const
|
||||
shared_ptr <const contentHandler> htmlTextPart::getPlainText() const
|
||||
{
|
||||
return m_plainText;
|
||||
}
|
||||
|
||||
|
||||
void htmlTextPart::setPlainText(ref <contentHandler> plainText)
|
||||
void htmlTextPart::setPlainText(shared_ptr <contentHandler> plainText)
|
||||
{
|
||||
m_plainText = plainText->clone();
|
||||
}
|
||||
|
||||
|
||||
const ref <const contentHandler> htmlTextPart::getText() const
|
||||
const shared_ptr <const contentHandler> htmlTextPart::getText() const
|
||||
{
|
||||
return m_text;
|
||||
}
|
||||
|
||||
|
||||
void htmlTextPart::setText(ref <contentHandler> text)
|
||||
void htmlTextPart::setText(shared_ptr <contentHandler> text)
|
||||
{
|
||||
m_text = text->clone();
|
||||
}
|
||||
@ -384,15 +384,15 @@ size_t htmlTextPart::getObjectCount() const
|
||||
}
|
||||
|
||||
|
||||
ref <const htmlTextPart::embeddedObject> htmlTextPart::getObjectAt(const size_t pos) const
|
||||
shared_ptr <const htmlTextPart::embeddedObject> htmlTextPart::getObjectAt(const size_t pos) const
|
||||
{
|
||||
return m_objects[pos];
|
||||
}
|
||||
|
||||
|
||||
ref <const htmlTextPart::embeddedObject> htmlTextPart::findObject(const string& id) const
|
||||
shared_ptr <const htmlTextPart::embeddedObject> htmlTextPart::findObject(const string& id) const
|
||||
{
|
||||
for (std::vector <ref <embeddedObject> >::const_iterator o = m_objects.begin() ;
|
||||
for (std::vector <shared_ptr <embeddedObject> >::const_iterator o = m_objects.begin() ;
|
||||
o != m_objects.end() ; ++o)
|
||||
{
|
||||
if ((*o)->matchesId(id))
|
||||
@ -405,7 +405,7 @@ ref <const htmlTextPart::embeddedObject> htmlTextPart::findObject(const string&
|
||||
|
||||
bool htmlTextPart::hasObject(const string& id) const
|
||||
{
|
||||
for (std::vector <ref <embeddedObject> >::const_iterator o = m_objects.begin() ;
|
||||
for (std::vector <shared_ptr <embeddedObject> >::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 <const htmlTextPart::embeddedObject> htmlTextPart::addObject
|
||||
(ref <contentHandler> data, const vmime::encoding& enc, const mediaType& type)
|
||||
shared_ptr <const htmlTextPart::embeddedObject> htmlTextPart::addObject
|
||||
(shared_ptr <contentHandler> data, const vmime::encoding& enc, const mediaType& type)
|
||||
{
|
||||
const messageId mid(messageId::generateId());
|
||||
|
||||
ref <embeddedObject> obj = vmime::create <embeddedObject>
|
||||
shared_ptr <embeddedObject> obj = make_shared <embeddedObject>
|
||||
(data, enc, mid.getId(), type, embeddedObject::REFERENCED_BY_ID);
|
||||
|
||||
m_objects.push_back(obj);
|
||||
@ -430,17 +430,17 @@ ref <const htmlTextPart::embeddedObject> htmlTextPart::addObject
|
||||
}
|
||||
|
||||
|
||||
ref <const htmlTextPart::embeddedObject> htmlTextPart::addObject
|
||||
(ref <contentHandler> data, const mediaType& type)
|
||||
shared_ptr <const htmlTextPart::embeddedObject> htmlTextPart::addObject
|
||||
(shared_ptr <contentHandler> data, const mediaType& type)
|
||||
{
|
||||
return addObject(data, encoding::decide(data), type);
|
||||
}
|
||||
|
||||
|
||||
ref <const htmlTextPart::embeddedObject> htmlTextPart::addObject
|
||||
shared_ptr <const htmlTextPart::embeddedObject> htmlTextPart::addObject
|
||||
(const string& data, const mediaType& type)
|
||||
{
|
||||
ref <stringContentHandler> cts = vmime::create <stringContentHandler>(data);
|
||||
shared_ptr <stringContentHandler> cts = make_shared <stringContentHandler>(data);
|
||||
return addObject(cts, encoding::decide(cts), type);
|
||||
}
|
||||
|
||||
@ -451,15 +451,15 @@ ref <const htmlTextPart::embeddedObject> htmlTextPart::addObject
|
||||
//
|
||||
|
||||
htmlTextPart::embeddedObject::embeddedObject
|
||||
(ref <contentHandler> data, const encoding& enc,
|
||||
(shared_ptr <contentHandler> data, const encoding& enc,
|
||||
const string& id, const mediaType& type, const ReferenceType refType)
|
||||
: m_data(data->clone().dynamicCast <contentHandler>()),
|
||||
: m_data(vmime::clone(data)),
|
||||
m_encoding(enc), m_id(id), m_type(type), m_refType(refType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
ref <const contentHandler> htmlTextPart::embeddedObject::getData() const
|
||||
shared_ptr <const contentHandler> htmlTextPart::embeddedObject::getData() const
|
||||
{
|
||||
return m_data;
|
||||
}
|
||||
|
@ -452,9 +452,9 @@ mailbox& mailbox::operator=(const mailbox& other)
|
||||
}
|
||||
|
||||
|
||||
ref <component>mailbox::clone() const
|
||||
shared_ptr <component>mailbox::clone() const
|
||||
{
|
||||
return vmime::create <mailbox>(*this);
|
||||
return make_shared <mailbox>(*this);
|
||||
}
|
||||
|
||||
|
||||
@ -501,9 +501,9 @@ void mailbox::setEmail(const emailAddress& email)
|
||||
}
|
||||
|
||||
|
||||
const std::vector <ref <component> > mailbox::getChildComponents()
|
||||
const std::vector <shared_ptr <component> > mailbox::getChildComponents()
|
||||
{
|
||||
return std::vector <ref <component> >();
|
||||
return std::vector <shared_ptr <component> >();
|
||||
}
|
||||
|
||||
|
||||
|
@ -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 <mailbox> mbox = vmime::create <mailbox>();
|
||||
shared_ptr <mailbox> mbox = make_shared <mailbox>();
|
||||
|
||||
// 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 <address> parsedAddress = address::parseNext(ctx, buffer, position, end, newPosition, NULL);
|
||||
shared_ptr <address> 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 <mailboxGroup> group = parsedAddress.staticCast <mailboxGroup>();
|
||||
shared_ptr <mailboxGroup> group = dynamicCast <mailboxGroup>(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 <mailbox>();
|
||||
mbox = dynamicCast <mailbox>(parsedAddress);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,24 +82,24 @@ void mailboxGroup::parseImpl
|
||||
|
||||
while (pos < end && !isLastAddressOfGroup)
|
||||
{
|
||||
ref <address> parsedAddress = address::parseNext(ctx, buffer, pos, end, &pos, &isLastAddressOfGroup);
|
||||
shared_ptr <address> parsedAddress = address::parseNext(ctx, buffer, pos, end, &pos, &isLastAddressOfGroup);
|
||||
|
||||
if (parsedAddress)
|
||||
{
|
||||
if (parsedAddress->isGroup())
|
||||
{
|
||||
ref <mailboxGroup> group = parsedAddress.staticCast <mailboxGroup>();
|
||||
shared_ptr <mailboxGroup> group = dynamicCast <mailboxGroup>(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 <mailbox>());
|
||||
m_list.push_back(vmime::clone(group->getMailboxAt(i)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_list.push_back(parsedAddress.staticCast <mailbox>());
|
||||
m_list.push_back(dynamicCast <mailbox>(parsedAddress));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -168,7 +168,7 @@ void mailboxGroup::generateImpl
|
||||
os << ":";
|
||||
++pos;
|
||||
|
||||
for (std::vector <ref <mailbox> >::const_iterator it = m_list.begin() ;
|
||||
for (std::vector <shared_ptr <mailbox> >::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 <ref <mailbox> >::const_iterator it = source.m_list.begin() ;
|
||||
for (std::vector <shared_ptr <mailbox> >::const_iterator it = source.m_list.begin() ;
|
||||
it != source.m_list.end() ; ++it)
|
||||
{
|
||||
m_list.push_back((*it)->clone().staticCast <mailbox>());
|
||||
m_list.push_back(vmime::clone(*it));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ref <component> mailboxGroup::clone() const
|
||||
shared_ptr <component> mailboxGroup::clone() const
|
||||
{
|
||||
return vmime::create <mailboxGroup>(*this);
|
||||
return make_shared <mailboxGroup>(*this);
|
||||
}
|
||||
|
||||
|
||||
@ -246,15 +246,15 @@ bool mailboxGroup::isEmpty() const
|
||||
}
|
||||
|
||||
|
||||
void mailboxGroup::appendMailbox(ref <mailbox> mbox)
|
||||
void mailboxGroup::appendMailbox(shared_ptr <mailbox> mbox)
|
||||
{
|
||||
m_list.push_back(mbox);
|
||||
}
|
||||
|
||||
|
||||
void mailboxGroup::insertMailboxBefore(ref <mailbox> beforeMailbox, ref <mailbox> mbox)
|
||||
void mailboxGroup::insertMailboxBefore(shared_ptr <mailbox> beforeMailbox, shared_ptr <mailbox> mbox)
|
||||
{
|
||||
const std::vector <ref <mailbox> >::iterator it = std::find
|
||||
const std::vector <shared_ptr <mailbox> >::iterator it = std::find
|
||||
(m_list.begin(), m_list.end(), beforeMailbox);
|
||||
|
||||
if (it == m_list.end())
|
||||
@ -264,15 +264,15 @@ void mailboxGroup::insertMailboxBefore(ref <mailbox> beforeMailbox, ref <mailbox
|
||||
}
|
||||
|
||||
|
||||
void mailboxGroup::insertMailboxBefore(const size_t pos, ref <mailbox> mbox)
|
||||
void mailboxGroup::insertMailboxBefore(const size_t pos, shared_ptr <mailbox> mbox)
|
||||
{
|
||||
m_list.insert(m_list.begin() + pos, mbox);
|
||||
}
|
||||
|
||||
|
||||
void mailboxGroup::insertMailboxAfter(ref <mailbox> afterMailbox, ref <mailbox> mbox)
|
||||
void mailboxGroup::insertMailboxAfter(shared_ptr <mailbox> afterMailbox, shared_ptr <mailbox> mbox)
|
||||
{
|
||||
const std::vector <ref <mailbox> >::iterator it = std::find
|
||||
const std::vector <shared_ptr <mailbox> >::iterator it = std::find
|
||||
(m_list.begin(), m_list.end(), afterMailbox);
|
||||
|
||||
if (it == m_list.end())
|
||||
@ -282,15 +282,15 @@ void mailboxGroup::insertMailboxAfter(ref <mailbox> afterMailbox, ref <mailbox>
|
||||
}
|
||||
|
||||
|
||||
void mailboxGroup::insertMailboxAfter(const size_t pos, ref <mailbox> mbox)
|
||||
void mailboxGroup::insertMailboxAfter(const size_t pos, shared_ptr <mailbox> mbox)
|
||||
{
|
||||
m_list.insert(m_list.begin() + pos + 1, mbox);
|
||||
}
|
||||
|
||||
|
||||
void mailboxGroup::removeMailbox(ref <mailbox> mbox)
|
||||
void mailboxGroup::removeMailbox(shared_ptr <mailbox> mbox)
|
||||
{
|
||||
const std::vector <ref <mailbox> >::iterator it = std::find
|
||||
const std::vector <shared_ptr <mailbox> >::iterator it = std::find
|
||||
(m_list.begin(), m_list.end(), mbox);
|
||||
|
||||
if (it == m_list.end())
|
||||
@ -302,7 +302,7 @@ void mailboxGroup::removeMailbox(ref <mailbox> mbox)
|
||||
|
||||
void mailboxGroup::removeMailbox(const size_t pos)
|
||||
{
|
||||
const std::vector <ref <mailbox> >::iterator it = m_list.begin() + pos;
|
||||
const std::vector <shared_ptr <mailbox> >::iterator it = m_list.begin() + pos;
|
||||
|
||||
m_list.erase(it);
|
||||
}
|
||||
@ -320,25 +320,25 @@ size_t mailboxGroup::getMailboxCount() const
|
||||
}
|
||||
|
||||
|
||||
ref <mailbox> mailboxGroup::getMailboxAt(const size_t pos)
|
||||
shared_ptr <mailbox> mailboxGroup::getMailboxAt(const size_t pos)
|
||||
{
|
||||
return (m_list[pos]);
|
||||
}
|
||||
|
||||
|
||||
const ref <const mailbox> mailboxGroup::getMailboxAt(const size_t pos) const
|
||||
const shared_ptr <const mailbox> mailboxGroup::getMailboxAt(const size_t pos) const
|
||||
{
|
||||
return (m_list[pos]);
|
||||
}
|
||||
|
||||
|
||||
const std::vector <ref <const mailbox> > mailboxGroup::getMailboxList() const
|
||||
const std::vector <shared_ptr <const mailbox> > mailboxGroup::getMailboxList() const
|
||||
{
|
||||
std::vector <ref <const mailbox> > list;
|
||||
std::vector <shared_ptr <const mailbox> > list;
|
||||
|
||||
list.reserve(m_list.size());
|
||||
|
||||
for (std::vector <ref <mailbox> >::const_iterator it = m_list.begin() ;
|
||||
for (std::vector <shared_ptr <mailbox> >::const_iterator it = m_list.begin() ;
|
||||
it != m_list.end() ; ++it)
|
||||
{
|
||||
list.push_back(*it);
|
||||
@ -348,15 +348,15 @@ const std::vector <ref <const mailbox> > mailboxGroup::getMailboxList() const
|
||||
}
|
||||
|
||||
|
||||
const std::vector <ref <mailbox> > mailboxGroup::getMailboxList()
|
||||
const std::vector <shared_ptr <mailbox> > mailboxGroup::getMailboxList()
|
||||
{
|
||||
return (m_list);
|
||||
}
|
||||
|
||||
|
||||
const std::vector <ref <component> > mailboxGroup::getChildComponents()
|
||||
const std::vector <shared_ptr <component> > mailboxGroup::getChildComponents()
|
||||
{
|
||||
std::vector <ref <component> > list;
|
||||
std::vector <shared_ptr <component> > list;
|
||||
|
||||
copy_vector(m_list, list);
|
||||
|
||||
|
@ -41,13 +41,13 @@ mailboxList::mailboxList(const mailboxList& mboxList)
|
||||
}
|
||||
|
||||
|
||||
void mailboxList::appendMailbox(ref <mailbox> mbox)
|
||||
void mailboxList::appendMailbox(shared_ptr <mailbox> mbox)
|
||||
{
|
||||
m_list.appendAddress(mbox);
|
||||
}
|
||||
|
||||
|
||||
void mailboxList::insertMailboxBefore(ref <mailbox> beforeMailbox, ref <mailbox> mbox)
|
||||
void mailboxList::insertMailboxBefore(shared_ptr <mailbox> beforeMailbox, shared_ptr <mailbox> mbox)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -60,13 +60,13 @@ void mailboxList::insertMailboxBefore(ref <mailbox> beforeMailbox, ref <mailbox>
|
||||
}
|
||||
|
||||
|
||||
void mailboxList::insertMailboxBefore(const size_t pos, ref <mailbox> mbox)
|
||||
void mailboxList::insertMailboxBefore(const size_t pos, shared_ptr <mailbox> mbox)
|
||||
{
|
||||
m_list.insertAddressBefore(pos, mbox);
|
||||
}
|
||||
|
||||
|
||||
void mailboxList::insertMailboxAfter(ref <mailbox> afterMailbox, ref <mailbox> mbox)
|
||||
void mailboxList::insertMailboxAfter(shared_ptr <mailbox> afterMailbox, shared_ptr <mailbox> mbox)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -79,13 +79,13 @@ void mailboxList::insertMailboxAfter(ref <mailbox> afterMailbox, ref <mailbox> m
|
||||
}
|
||||
|
||||
|
||||
void mailboxList::insertMailboxAfter(const size_t pos, ref <mailbox> mbox)
|
||||
void mailboxList::insertMailboxAfter(const size_t pos, shared_ptr <mailbox> mbox)
|
||||
{
|
||||
m_list.insertAddressAfter(pos, mbox);
|
||||
}
|
||||
|
||||
|
||||
void mailboxList::removeMailbox(ref <mailbox> mbox)
|
||||
void mailboxList::removeMailbox(shared_ptr <mailbox> mbox)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -122,27 +122,27 @@ bool mailboxList::isEmpty() const
|
||||
}
|
||||
|
||||
|
||||
ref <mailbox> mailboxList::getMailboxAt(const size_t pos)
|
||||
shared_ptr <mailbox> mailboxList::getMailboxAt(const size_t pos)
|
||||
{
|
||||
return m_list.getAddressAt(pos).staticCast <mailbox>();
|
||||
return dynamicCast <mailbox>(m_list.getAddressAt(pos));
|
||||
}
|
||||
|
||||
|
||||
const ref <const mailbox> mailboxList::getMailboxAt(const size_t pos) const
|
||||
const shared_ptr <const mailbox> mailboxList::getMailboxAt(const size_t pos) const
|
||||
{
|
||||
return m_list.getAddressAt(pos).staticCast <const mailbox>();
|
||||
return dynamicCast <const mailbox>(m_list.getAddressAt(pos));
|
||||
}
|
||||
|
||||
|
||||
const std::vector <ref <const mailbox> > mailboxList::getMailboxList() const
|
||||
const std::vector <shared_ptr <const mailbox> > mailboxList::getMailboxList() const
|
||||
{
|
||||
const std::vector <ref <const address> > addrList = m_list.getAddressList();
|
||||
std::vector <ref <const mailbox> > res;
|
||||
const std::vector <shared_ptr <const address> > addrList = m_list.getAddressList();
|
||||
std::vector <shared_ptr <const mailbox> > res;
|
||||
|
||||
for (std::vector <ref <const address> >::const_iterator it = addrList.begin() ;
|
||||
for (std::vector <shared_ptr <const address> >::const_iterator it = addrList.begin() ;
|
||||
it != addrList.end() ; ++it)
|
||||
{
|
||||
const ref <const mailbox> mbox = (*it).dynamicCast <const mailbox>();
|
||||
const shared_ptr <const mailbox> mbox = dynamicCast <const mailbox>(*it);
|
||||
|
||||
if (mbox != NULL)
|
||||
res.push_back(mbox);
|
||||
@ -152,15 +152,15 @@ const std::vector <ref <const mailbox> > mailboxList::getMailboxList() const
|
||||
}
|
||||
|
||||
|
||||
const std::vector <ref <mailbox> > mailboxList::getMailboxList()
|
||||
const std::vector <shared_ptr <mailbox> > mailboxList::getMailboxList()
|
||||
{
|
||||
const std::vector <ref <address> > addrList = m_list.getAddressList();
|
||||
std::vector <ref <mailbox> > res;
|
||||
const std::vector <shared_ptr <address> > addrList = m_list.getAddressList();
|
||||
std::vector <shared_ptr <mailbox> > res;
|
||||
|
||||
for (std::vector <ref <address> >::const_iterator it = addrList.begin() ;
|
||||
for (std::vector <shared_ptr <address> >::const_iterator it = addrList.begin() ;
|
||||
it != addrList.end() ; ++it)
|
||||
{
|
||||
const ref <mailbox> mbox = (*it).dynamicCast <mailbox>();
|
||||
const shared_ptr <mailbox> mbox = dynamicCast <mailbox>(*it);
|
||||
|
||||
if (mbox != NULL)
|
||||
res.push_back(mbox);
|
||||
@ -170,9 +170,9 @@ const std::vector <ref <mailbox> > mailboxList::getMailboxList()
|
||||
}
|
||||
|
||||
|
||||
ref <component> mailboxList::clone() const
|
||||
shared_ptr <component> mailboxList::clone() const
|
||||
{
|
||||
return vmime::create <mailboxList>(*this);
|
||||
return make_shared <mailboxList>(*this);
|
||||
}
|
||||
|
||||
|
||||
@ -191,7 +191,7 @@ mailboxList& mailboxList::operator=(const mailboxList& other)
|
||||
}
|
||||
|
||||
|
||||
const std::vector <ref <component> > mailboxList::getChildComponents()
|
||||
const std::vector <shared_ptr <component> > mailboxList::getChildComponents()
|
||||
{
|
||||
return (m_list.getChildComponents());
|
||||
}
|
||||
@ -207,13 +207,13 @@ void mailboxList::parseImpl
|
||||
|
||||
while (pos < end)
|
||||
{
|
||||
ref <address> parsedAddress = address::parseNext(ctx, buffer, pos, end, &pos, NULL);
|
||||
shared_ptr <address> parsedAddress = address::parseNext(ctx, buffer, pos, end, &pos, NULL);
|
||||
|
||||
if (parsedAddress != NULL)
|
||||
{
|
||||
if (parsedAddress->isGroup())
|
||||
{
|
||||
ref <mailboxGroup> group = parsedAddress.staticCast <mailboxGroup>();
|
||||
shared_ptr <mailboxGroup> group = dynamicCast <mailboxGroup>(parsedAddress);
|
||||
|
||||
for (size_t i = 0 ; i < group->getMailboxCount() ; ++i)
|
||||
{
|
||||
@ -241,9 +241,9 @@ void mailboxList::generateImpl(const generationContext& ctx, utility::outputStre
|
||||
}
|
||||
|
||||
|
||||
ref <addressList> mailboxList::toAddressList() const
|
||||
shared_ptr <addressList> mailboxList::toAddressList() const
|
||||
{
|
||||
return m_list.clone().dynamicCast <addressList>();
|
||||
return vmime::clone(m_list);
|
||||
}
|
||||
|
||||
|
||||
|
@ -38,33 +38,33 @@ namespace vmime {
|
||||
namespace mdn {
|
||||
|
||||
|
||||
void MDNHelper::attachMDNRequest(ref <message> msg, const mailboxList& mailboxes)
|
||||
void MDNHelper::attachMDNRequest(shared_ptr <message> msg, const mailboxList& mailboxes)
|
||||
{
|
||||
ref <header> hdr = msg->getHeader();
|
||||
shared_ptr <header> hdr = msg->getHeader();
|
||||
|
||||
hdr->DispositionNotificationTo()->setValue(mailboxes);
|
||||
}
|
||||
|
||||
|
||||
void MDNHelper::attachMDNRequest(ref <message> msg, const mailbox& mbox)
|
||||
void MDNHelper::attachMDNRequest(shared_ptr <message> msg, const mailbox& mbox)
|
||||
{
|
||||
mailboxList mboxList;
|
||||
mboxList.appendMailbox(mbox.clone().dynamicCast <mailbox>());
|
||||
mboxList.appendMailbox(vmime::clone(mbox));
|
||||
|
||||
attachMDNRequest(msg, mboxList);
|
||||
}
|
||||
|
||||
|
||||
const std::vector <sendableMDNInfos> MDNHelper::getPossibleMDNs(const ref <const message> msg)
|
||||
const std::vector <sendableMDNInfos> MDNHelper::getPossibleMDNs(const shared_ptr <const message> msg)
|
||||
{
|
||||
std::vector <sendableMDNInfos> result;
|
||||
|
||||
const ref <const header> hdr = msg->getHeader();
|
||||
const shared_ptr <const header> hdr = msg->getHeader();
|
||||
|
||||
if (hdr->hasField(fields::DISPOSITION_NOTIFICATION_TO))
|
||||
{
|
||||
const mailboxList& dnto = *hdr->DispositionNotificationTo()->getValue()
|
||||
.dynamicCast <const mailboxList>();
|
||||
const mailboxList& dnto =
|
||||
*hdr->DispositionNotificationTo()->getValue <mailboxList>();
|
||||
|
||||
for (size_t i = 0 ; i < dnto.getMailboxCount() ; ++i)
|
||||
result.push_back(sendableMDNInfos(msg, *dnto.getMailboxAt(i)));
|
||||
@ -74,9 +74,9 @@ const std::vector <sendableMDNInfos> MDNHelper::getPossibleMDNs(const ref <const
|
||||
}
|
||||
|
||||
|
||||
bool MDNHelper::isMDN(const ref <const message> msg)
|
||||
bool MDNHelper::isMDN(const shared_ptr <const message> msg)
|
||||
{
|
||||
const ref <const header> hdr = msg->getHeader();
|
||||
const shared_ptr <const header> 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 <const message> msg)
|
||||
// and its value is "disposition-notification"
|
||||
if (hdr->hasField(fields::CONTENT_TYPE))
|
||||
{
|
||||
const contentTypeField& ctf = *(hdr->ContentType()
|
||||
.dynamicCast <const contentTypeField>());
|
||||
const contentTypeField& ctf = *dynamicCast <const contentTypeField>(hdr->ContentType());
|
||||
|
||||
const mediaType type = *ctf.getValue().dynamicCast <const mediaType>();
|
||||
const mediaType type = *ctf.getValue <mediaType>();
|
||||
|
||||
if (type.getType() == vmime::mediaTypes::MULTIPART &&
|
||||
type.getSubType() == vmime::mediaTypes::MULTIPART_REPORT)
|
||||
@ -104,7 +103,7 @@ bool MDNHelper::isMDN(const ref <const message> msg)
|
||||
}
|
||||
|
||||
|
||||
receivedMDNInfos MDNHelper::getReceivedMDN(const ref <const message> msg)
|
||||
receivedMDNInfos MDNHelper::getReceivedMDN(const shared_ptr <const message> msg)
|
||||
{
|
||||
if (!isMDN(msg))
|
||||
throw exceptions::invalid_argument();
|
||||
@ -113,9 +112,9 @@ receivedMDNInfos MDNHelper::getReceivedMDN(const ref <const message> msg)
|
||||
}
|
||||
|
||||
|
||||
bool MDNHelper::needConfirmation(const ref <const message> msg)
|
||||
bool MDNHelper::needConfirmation(const shared_ptr <const message> msg)
|
||||
{
|
||||
ref <const header> hdr = msg->getHeader();
|
||||
shared_ptr <const header> hdr = msg->getHeader();
|
||||
|
||||
// No "Return-Path" field
|
||||
if (!hdr->hasField(fields::RETURN_PATH))
|
||||
@ -124,8 +123,7 @@ bool MDNHelper::needConfirmation(const ref <const message> 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>();
|
||||
const mailboxList& dnto = *hdr->DispositionNotificationTo()->getValue <mailboxList>();
|
||||
|
||||
if (dnto.getMailboxCount() > 1)
|
||||
return true;
|
||||
@ -134,7 +132,7 @@ bool MDNHelper::needConfirmation(const ref <const message> msg)
|
||||
|
||||
// Return-Path != Disposition-Notification-To
|
||||
const mailbox& mbox = *dnto.getMailboxAt(0);
|
||||
const path& rp = *hdr->ReturnPath()->getValue().dynamicCast <const path>();
|
||||
const path& rp = *hdr->ReturnPath()->getValue <path>();
|
||||
|
||||
if (mbox.getEmail() != rp.getLocalPart() + "@" + rp.getDomain())
|
||||
return true;
|
||||
@ -145,7 +143,7 @@ bool MDNHelper::needConfirmation(const ref <const message> msg)
|
||||
}
|
||||
|
||||
|
||||
ref <message> MDNHelper::buildMDN(const sendableMDNInfos& mdnInfos,
|
||||
shared_ptr <message> MDNHelper::buildMDN(const sendableMDNInfos& mdnInfos,
|
||||
const string& text,
|
||||
const charset& ch,
|
||||
const mailbox& expeditor,
|
||||
@ -155,19 +153,19 @@ ref <message> MDNHelper::buildMDN(const sendableMDNInfos& mdnInfos,
|
||||
const std::map <string, string>& fields)
|
||||
{
|
||||
// Create a new message
|
||||
ref <message> msg = vmime::create <message>();
|
||||
shared_ptr <message> msg = make_shared <message>();
|
||||
|
||||
// Fill-in header fields
|
||||
ref <header> hdr = msg->getHeader();
|
||||
shared_ptr <header> hdr = msg->getHeader();
|
||||
|
||||
hdr->ContentType()->setValue(mediaType(vmime::mediaTypes::MULTIPART,
|
||||
vmime::mediaTypes::MULTIPART_REPORT));
|
||||
hdr->ContentType().dynamicCast <contentTypeField>()->setReportType("disposition-notification");
|
||||
dynamicCast <contentTypeField>(hdr->ContentType())->setReportType("disposition-notification");
|
||||
|
||||
hdr->Disposition()->setValue(dispo);
|
||||
|
||||
addressList to;
|
||||
to.appendAddress(vmime::create <mailbox>(mdnInfos.getRecipient()));
|
||||
to.appendAddress(make_shared <mailbox>(mdnInfos.getRecipient()));
|
||||
hdr->To()->setValue(to);
|
||||
|
||||
hdr->From()->setValue(expeditor);
|
||||
@ -186,36 +184,36 @@ ref <message> MDNHelper::buildMDN(const sendableMDNInfos& mdnInfos,
|
||||
}
|
||||
|
||||
|
||||
ref <bodyPart> MDNHelper::createFirstMDNPart(const sendableMDNInfos& /* mdnInfos */,
|
||||
shared_ptr <bodyPart> MDNHelper::createFirstMDNPart(const sendableMDNInfos& /* mdnInfos */,
|
||||
const string& text, const charset& ch)
|
||||
{
|
||||
ref <bodyPart> part = vmime::create <bodyPart>();
|
||||
shared_ptr <bodyPart> part = make_shared <bodyPart>();
|
||||
|
||||
// Header
|
||||
ref <header> hdr = part->getHeader();
|
||||
shared_ptr <header> hdr = part->getHeader();
|
||||
|
||||
hdr->ContentType()->setValue(mediaType(vmime::mediaTypes::TEXT,
|
||||
vmime::mediaTypes::TEXT_PLAIN));
|
||||
|
||||
hdr->ContentType().dynamicCast <contentTypeField>()->setCharset(ch);
|
||||
dynamicCast <contentTypeField>(hdr->ContentType())->setCharset(ch);
|
||||
|
||||
// Body
|
||||
part->getBody()->setContents(vmime::create <stringContentHandler>(text));
|
||||
part->getBody()->setContents(make_shared <stringContentHandler>(text));
|
||||
|
||||
return (part);
|
||||
}
|
||||
|
||||
|
||||
ref <bodyPart> MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos,
|
||||
shared_ptr <bodyPart> MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos,
|
||||
const disposition& dispo,
|
||||
const string& reportingUA,
|
||||
const std::vector <string>& reportingUAProducts,
|
||||
const std::map <string, string>& additionalFields)
|
||||
{
|
||||
ref <bodyPart> part = vmime::create <bodyPart>();
|
||||
shared_ptr <bodyPart> part = make_shared <bodyPart>();
|
||||
|
||||
// Header
|
||||
ref <header> hdr = part->getHeader();
|
||||
shared_ptr <header> hdr = part->getHeader();
|
||||
|
||||
hdr->ContentDisposition()->setValue(vmime::contentDispositionTypes::INLINE);
|
||||
hdr->ContentType()->setValue(mediaType(vmime::mediaTypes::MESSAGE,
|
||||
@ -257,7 +255,7 @@ ref <bodyPart> MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos,
|
||||
ruaText += reportingUAProducts[i];
|
||||
}
|
||||
|
||||
ref <headerField> rua = headerFieldFactory::getInstance()->
|
||||
shared_ptr <headerField> rua = headerFieldFactory::getInstance()->
|
||||
create(vmime::fields::REPORTING_UA);
|
||||
|
||||
rua->setValue(ruaText);
|
||||
@ -266,7 +264,7 @@ ref <bodyPart> MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos,
|
||||
}
|
||||
|
||||
// -- Final-Recipient
|
||||
ref <headerField> fr = headerFieldFactory::getInstance()->
|
||||
shared_ptr <headerField> fr = headerFieldFactory::getInstance()->
|
||||
create(vmime::fields::FINAL_RECIPIENT);
|
||||
|
||||
fr->setValue("rfc822; " + mdnInfos.getRecipient().getEmail().generate());
|
||||
@ -291,7 +289,7 @@ ref <bodyPart> MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos,
|
||||
it = additionalFields.find(vmime::fields::ERROR);
|
||||
if (it != additionalFields.end())
|
||||
{
|
||||
ref <headerField> error = headerFieldFactory::getInstance()->
|
||||
shared_ptr <headerField> error = headerFieldFactory::getInstance()->
|
||||
create(vmime::fields::ERROR);
|
||||
error->setValue(it->second);
|
||||
fields.appendField(error);
|
||||
@ -300,7 +298,7 @@ ref <bodyPart> MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos,
|
||||
it = additionalFields.find(vmime::fields::WARNING);
|
||||
if (it != additionalFields.end())
|
||||
{
|
||||
ref <headerField> warn = headerFieldFactory::getInstance()->
|
||||
shared_ptr <headerField> warn = headerFieldFactory::getInstance()->
|
||||
create(vmime::fields::WARNING);
|
||||
warn->setValue(it->second);
|
||||
fields.appendField(warn);
|
||||
@ -309,7 +307,7 @@ ref <bodyPart> MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos,
|
||||
it = additionalFields.find(vmime::fields::FAILURE);
|
||||
if (it != additionalFields.end())
|
||||
{
|
||||
ref <headerField> fail = headerFieldFactory::getInstance()->
|
||||
shared_ptr <headerField> fail = headerFieldFactory::getInstance()->
|
||||
create(vmime::fields::FAILURE);
|
||||
fail->setValue(it->second);
|
||||
fields.appendField(fail);
|
||||
@ -322,18 +320,18 @@ ref <bodyPart> MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos,
|
||||
|
||||
fields.generate(vos);
|
||||
|
||||
part->getBody()->setContents(vmime::create <stringContentHandler>(oss.str()));
|
||||
part->getBody()->setContents(make_shared <stringContentHandler>(oss.str()));
|
||||
|
||||
return (part);
|
||||
}
|
||||
|
||||
|
||||
ref <bodyPart> MDNHelper::createThirdMDNPart(const sendableMDNInfos& mdnInfos)
|
||||
shared_ptr <bodyPart> MDNHelper::createThirdMDNPart(const sendableMDNInfos& mdnInfos)
|
||||
{
|
||||
ref <bodyPart> part = vmime::create <bodyPart>();
|
||||
shared_ptr <bodyPart> part = make_shared <bodyPart>();
|
||||
|
||||
// Header
|
||||
ref <header> hdr = part->getHeader();
|
||||
shared_ptr <header> hdr = part->getHeader();
|
||||
|
||||
hdr->ContentDisposition()->setValue(vmime::contentDispositionTypes::INLINE);
|
||||
hdr->ContentType()->setValue(mediaType(vmime::mediaTypes::TEXT,
|
||||
@ -345,7 +343,7 @@ ref <bodyPart> MDNHelper::createThirdMDNPart(const sendableMDNInfos& mdnInfos)
|
||||
|
||||
mdnInfos.getMessage()->getHeader()->generate(vos);
|
||||
|
||||
part->getBody()->setContents(vmime::create <stringContentHandler>(oss.str()));
|
||||
part->getBody()->setContents(make_shared <stringContentHandler>(oss.str()));
|
||||
|
||||
return (part);
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ namespace vmime {
|
||||
namespace mdn {
|
||||
|
||||
|
||||
receivedMDNInfos::receivedMDNInfos(const ref <const message> msg)
|
||||
receivedMDNInfos::receivedMDNInfos(const shared_ptr <const message> msg)
|
||||
: m_msg(msg)
|
||||
{
|
||||
extract();
|
||||
@ -51,7 +51,7 @@ receivedMDNInfos& receivedMDNInfos::operator=(const receivedMDNInfos& other)
|
||||
}
|
||||
|
||||
|
||||
const ref <const message> receivedMDNInfos::getMessage() const
|
||||
const shared_ptr <const message> receivedMDNInfos::getMessage() const
|
||||
{
|
||||
return (m_msg);
|
||||
}
|
||||
@ -86,17 +86,16 @@ void receivedMDNInfos::copyFrom(const receivedMDNInfos& other)
|
||||
|
||||
void receivedMDNInfos::extract()
|
||||
{
|
||||
const ref <const body> bdy = m_msg->getBody();
|
||||
const shared_ptr <const body> bdy = m_msg->getBody();
|
||||
|
||||
for (size_t i = 0 ; i < bdy->getPartCount() ; ++i)
|
||||
{
|
||||
const ref <const bodyPart> part = bdy->getPartAt(i);
|
||||
const shared_ptr <const bodyPart> part = bdy->getPartAt(i);
|
||||
|
||||
if (!part->getHeader()->hasField(fields::CONTENT_TYPE))
|
||||
continue;
|
||||
|
||||
const mediaType& type = *part->getHeader()->ContentType()->
|
||||
getValue().dynamicCast <const mediaType>();
|
||||
const mediaType& type = *part->getHeader()->ContentType()->getValue <mediaType>();
|
||||
|
||||
// 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 <const messageId>(); }
|
||||
try { m_omid = *fields.OriginalMessageId()->getValue <messageId>(); }
|
||||
catch (exceptions::no_such_field&) { /* Ignore */ }
|
||||
|
||||
try { m_disp = *fields.Disposition()->getValue().dynamicCast <const disposition>(); }
|
||||
try { m_disp = *fields.Disposition()->getValue <disposition>(); }
|
||||
catch (exceptions::no_such_field&) { /* Ignore */ }
|
||||
|
||||
try
|
||||
{
|
||||
text t = *fields.findField("Received-content-MIC")->getValue().dynamicCast <const text>();
|
||||
text t = *fields.findField("Received-content-MIC")->getValue <text>();
|
||||
m_contentMIC = t.generate();
|
||||
}
|
||||
catch (exceptions::no_such_field&) { /* Ignore */ }
|
||||
|
@ -28,7 +28,7 @@ namespace vmime {
|
||||
namespace mdn {
|
||||
|
||||
|
||||
sendableMDNInfos::sendableMDNInfos(const ref <const message> msg, const mailbox& mbox)
|
||||
sendableMDNInfos::sendableMDNInfos(const shared_ptr <const message> msg, const mailbox& mbox)
|
||||
: m_msg(msg), m_mailbox(mbox)
|
||||
{
|
||||
}
|
||||
@ -48,7 +48,7 @@ sendableMDNInfos& sendableMDNInfos::operator=(const sendableMDNInfos& other)
|
||||
}
|
||||
|
||||
|
||||
const ref <const message> sendableMDNInfos::getMessage() const
|
||||
const shared_ptr <const message> sendableMDNInfos::getMessage() const
|
||||
{
|
||||
return (m_msg);
|
||||
}
|
||||
|
@ -126,9 +126,9 @@ mediaType& mediaType::operator=(const string& type)
|
||||
}
|
||||
|
||||
|
||||
ref <component> mediaType::clone() const
|
||||
shared_ptr <component> mediaType::clone() const
|
||||
{
|
||||
return vmime::create <mediaType>(m_type, m_subType);
|
||||
return make_shared <mediaType>(m_type, m_subType);
|
||||
}
|
||||
|
||||
|
||||
@ -178,9 +178,9 @@ void mediaType::setFromString(const string& type)
|
||||
}
|
||||
|
||||
|
||||
const std::vector <ref <component> > mediaType::getChildComponents()
|
||||
const std::vector <shared_ptr <component> > mediaType::getChildComponents()
|
||||
{
|
||||
return std::vector <ref <component> >();
|
||||
return std::vector <shared_ptr <component> >();
|
||||
}
|
||||
|
||||
|
||||
|
@ -43,10 +43,10 @@ messageBuilder::~messageBuilder()
|
||||
}
|
||||
|
||||
|
||||
ref <message> messageBuilder::construct() const
|
||||
shared_ptr <message> messageBuilder::construct() const
|
||||
{
|
||||
// Create a new message
|
||||
ref <message> msg = vmime::create <message>();
|
||||
shared_ptr <message> msg = make_shared <message>();
|
||||
|
||||
// Generate the header fields
|
||||
msg->getHeader()->Subject()->setValue(m_subject);
|
||||
@ -101,7 +101,7 @@ ref <message> messageBuilder::construct() const
|
||||
(mediaType(mediaTypes::MULTIPART, mediaTypes::MULTIPART_MIXED));
|
||||
|
||||
// Create a sub-part "multipart/alternative" for text parts
|
||||
ref <bodyPart> subPart = vmime::create <bodyPart>();
|
||||
shared_ptr <bodyPart> subPart = make_shared <bodyPart>();
|
||||
msg->getBody()->appendPart(subPart);
|
||||
|
||||
subPart->getHeader()->ContentType()->setValue
|
||||
@ -133,7 +133,7 @@ ref <message> messageBuilder::construct() const
|
||||
// Generate the attachments
|
||||
if (!m_attach.empty())
|
||||
{
|
||||
for (std::vector <ref <attachment> >::const_iterator a = m_attach.begin() ;
|
||||
for (std::vector <shared_ptr <attachment> >::const_iterator a = m_attach.begin() ;
|
||||
a != m_attach.end() ; ++a)
|
||||
{
|
||||
(*a)->generateIn(msg);
|
||||
@ -147,12 +147,12 @@ ref <message> 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 <body> bodyCopy = part.getBody()->clone().dynamicCast <body>();
|
||||
shared_ptr <body> bodyCopy = vmime::clone(part.getBody());
|
||||
|
||||
// First, copy (and replace) the header fields
|
||||
const std::vector <ref <const headerField> > fields = part.getHeader()->getFieldList();
|
||||
const std::vector <shared_ptr <const headerField> > fields = part.getHeader()->getFieldList();
|
||||
|
||||
for (std::vector <ref <const headerField> >::const_iterator it = fields.begin() ;
|
||||
for (std::vector <shared_ptr <const headerField> >::const_iterator it = fields.begin() ;
|
||||
it != fields.end() ; ++it)
|
||||
{
|
||||
*(msg->getHeader()->getField((*it)->getName())) = **it;
|
||||
@ -167,13 +167,13 @@ ref <message> messageBuilder::construct() const
|
||||
}
|
||||
|
||||
|
||||
void messageBuilder::attach(ref <attachment> attach)
|
||||
void messageBuilder::attach(shared_ptr <attachment> attach)
|
||||
{
|
||||
appendAttachment(attach);
|
||||
}
|
||||
|
||||
|
||||
void messageBuilder::appendAttachment(ref <attachment> attach)
|
||||
void messageBuilder::appendAttachment(shared_ptr <attachment> attach)
|
||||
{
|
||||
m_attach.push_back(attach);
|
||||
}
|
||||
@ -181,7 +181,7 @@ void messageBuilder::appendAttachment(ref <attachment> attach)
|
||||
|
||||
void messageBuilder::constructTextPart(const mediaType& type)
|
||||
{
|
||||
ref <textPart> part = NULL;
|
||||
shared_ptr <textPart> part;
|
||||
|
||||
try
|
||||
{
|
||||
@ -196,7 +196,7 @@ void messageBuilder::constructTextPart(const mediaType& type)
|
||||
}
|
||||
|
||||
|
||||
ref <textPart> messageBuilder::getTextPart()
|
||||
shared_ptr <textPart> messageBuilder::getTextPart()
|
||||
{
|
||||
return (m_textPart);
|
||||
}
|
||||
@ -286,13 +286,13 @@ void messageBuilder::removeAttachment(const size_t pos)
|
||||
}
|
||||
|
||||
|
||||
const ref <const attachment> messageBuilder::getAttachmentAt(const size_t pos) const
|
||||
const shared_ptr <const attachment> messageBuilder::getAttachmentAt(const size_t pos) const
|
||||
{
|
||||
return (m_attach[pos]);
|
||||
}
|
||||
|
||||
|
||||
ref <attachment> messageBuilder::getAttachmentAt(const size_t pos)
|
||||
shared_ptr <attachment> messageBuilder::getAttachmentAt(const size_t pos)
|
||||
{
|
||||
return (m_attach[pos]);
|
||||
}
|
||||
@ -304,13 +304,13 @@ size_t messageBuilder::getAttachmentCount() const
|
||||
}
|
||||
|
||||
|
||||
const std::vector <ref <const attachment> > messageBuilder::getAttachmentList() const
|
||||
const std::vector <shared_ptr <const attachment> > messageBuilder::getAttachmentList() const
|
||||
{
|
||||
std::vector <ref <const attachment> > res;
|
||||
std::vector <shared_ptr <const attachment> > res;
|
||||
|
||||
res.reserve(m_attach.size());
|
||||
|
||||
for (std::vector <ref <attachment> >::const_iterator it = m_attach.begin() ;
|
||||
for (std::vector <shared_ptr <attachment> >::const_iterator it = m_attach.begin() ;
|
||||
it != m_attach.end() ; ++it)
|
||||
{
|
||||
res.push_back(*it);
|
||||
@ -320,7 +320,7 @@ const std::vector <ref <const attachment> > messageBuilder::getAttachmentList()
|
||||
}
|
||||
|
||||
|
||||
const std::vector <ref <attachment> > messageBuilder::getAttachmentList()
|
||||
const std::vector <shared_ptr <attachment> > messageBuilder::getAttachmentList()
|
||||
{
|
||||
return (m_attach);
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ void messageId::parseImpl
|
||||
}
|
||||
|
||||
|
||||
ref <messageId> messageId::parseNext
|
||||
shared_ptr <messageId> 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> messageId::parseNext
|
||||
while (pos < end && !parserHelpers::isSpace(buffer[pos]))
|
||||
++pos;
|
||||
|
||||
ref <messageId> mid = vmime::create <messageId>();
|
||||
shared_ptr <messageId> mid = make_shared <messageId>();
|
||||
mid->parse(ctx, buffer, begin, pos, NULL);
|
||||
|
||||
if (newPosition != NULL)
|
||||
@ -174,7 +174,7 @@ ref <messageId> messageId::parseNext
|
||||
if (newPosition != NULL)
|
||||
*newPosition = end;
|
||||
|
||||
return (NULL);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ -245,9 +245,9 @@ bool messageId::operator!=(const messageId& mid) const
|
||||
}
|
||||
|
||||
|
||||
ref <component> messageId::clone() const
|
||||
shared_ptr <component> messageId::clone() const
|
||||
{
|
||||
return vmime::create <messageId>(*this);
|
||||
return make_shared <messageId>(*this);
|
||||
}
|
||||
|
||||
|
||||
@ -291,9 +291,9 @@ void messageId::setRight(const string& right)
|
||||
}
|
||||
|
||||
|
||||
const std::vector <ref <component> > messageId::getChildComponents()
|
||||
const std::vector <shared_ptr <component> > messageId::getChildComponents()
|
||||
{
|
||||
return std::vector <ref <component> >();
|
||||
return std::vector <shared_ptr <component> >();
|
||||
}
|
||||
|
||||
|
||||
|
@ -50,9 +50,9 @@ messageIdSequence::messageIdSequence(const messageIdSequence& midSeq)
|
||||
}
|
||||
|
||||
|
||||
ref <component> messageIdSequence::clone() const
|
||||
shared_ptr <component> messageIdSequence::clone() const
|
||||
{
|
||||
return vmime::create <messageIdSequence>(*this);
|
||||
return make_shared <messageIdSequence>(*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 <messageId>());
|
||||
m_list.push_back(vmime::clone(midSeq.m_list[i]));
|
||||
}
|
||||
|
||||
|
||||
@ -74,9 +74,9 @@ messageIdSequence& messageIdSequence::operator=(const messageIdSequence& other)
|
||||
}
|
||||
|
||||
|
||||
const std::vector <ref <component> > messageIdSequence::getChildComponents()
|
||||
const std::vector <shared_ptr <component> > messageIdSequence::getChildComponents()
|
||||
{
|
||||
std::vector <ref <component> > res;
|
||||
std::vector <shared_ptr <component> > res;
|
||||
|
||||
copy_vector(m_list, res);
|
||||
|
||||
@ -94,7 +94,7 @@ void messageIdSequence::parseImpl
|
||||
|
||||
while (pos < end)
|
||||
{
|
||||
ref <messageId> parsedMid = messageId::parseNext(ctx, buffer, pos, end, &pos);
|
||||
shared_ptr <messageId> 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 <ref <messageId> >::const_iterator it = m_list.begin() ; ; )
|
||||
for (std::vector <shared_ptr <messageId> >::const_iterator it = m_list.begin() ; ; )
|
||||
{
|
||||
(*it)->generate(ctx, os, pos, &pos);
|
||||
|
||||
@ -135,15 +135,15 @@ void messageIdSequence::generateImpl
|
||||
}
|
||||
|
||||
|
||||
void messageIdSequence::appendMessageId(ref <messageId> mid)
|
||||
void messageIdSequence::appendMessageId(shared_ptr <messageId> mid)
|
||||
{
|
||||
m_list.push_back(mid);
|
||||
}
|
||||
|
||||
|
||||
void messageIdSequence::insertMessageIdBefore(ref <messageId> beforeMid, ref <messageId> mid)
|
||||
void messageIdSequence::insertMessageIdBefore(shared_ptr <messageId> beforeMid, shared_ptr <messageId> mid)
|
||||
{
|
||||
const std::vector <ref <messageId> >::iterator it = std::find
|
||||
const std::vector <shared_ptr <messageId> >::iterator it = std::find
|
||||
(m_list.begin(), m_list.end(), beforeMid);
|
||||
|
||||
if (it == m_list.end())
|
||||
@ -153,15 +153,15 @@ void messageIdSequence::insertMessageIdBefore(ref <messageId> beforeMid, ref <me
|
||||
}
|
||||
|
||||
|
||||
void messageIdSequence::insertMessageIdBefore(const size_t pos, ref <messageId> mid)
|
||||
void messageIdSequence::insertMessageIdBefore(const size_t pos, shared_ptr <messageId> mid)
|
||||
{
|
||||
m_list.insert(m_list.begin() + pos, mid);
|
||||
}
|
||||
|
||||
|
||||
void messageIdSequence::insertMessageIdAfter(ref <messageId> afterMid, ref <messageId> mid)
|
||||
void messageIdSequence::insertMessageIdAfter(shared_ptr <messageId> afterMid, shared_ptr <messageId> mid)
|
||||
{
|
||||
const std::vector <ref <messageId> >::iterator it = std::find
|
||||
const std::vector <shared_ptr <messageId> >::iterator it = std::find
|
||||
(m_list.begin(), m_list.end(), afterMid);
|
||||
|
||||
if (it == m_list.end())
|
||||
@ -171,15 +171,15 @@ void messageIdSequence::insertMessageIdAfter(ref <messageId> afterMid, ref <mess
|
||||
}
|
||||
|
||||
|
||||
void messageIdSequence::insertMessageIdAfter(const size_t pos, ref <messageId> mid)
|
||||
void messageIdSequence::insertMessageIdAfter(const size_t pos, shared_ptr <messageId> mid)
|
||||
{
|
||||
m_list.insert(m_list.begin() + pos + 1, mid);
|
||||
}
|
||||
|
||||
|
||||
void messageIdSequence::removeMessageId(ref <messageId> mid)
|
||||
void messageIdSequence::removeMessageId(shared_ptr <messageId> mid)
|
||||
{
|
||||
const std::vector <ref <messageId> >::iterator it = std::find
|
||||
const std::vector <shared_ptr <messageId> >::iterator it = std::find
|
||||
(m_list.begin(), m_list.end(), mid);
|
||||
|
||||
if (it == m_list.end())
|
||||
@ -191,7 +191,7 @@ void messageIdSequence::removeMessageId(ref <messageId> mid)
|
||||
|
||||
void messageIdSequence::removeMessageId(const size_t pos)
|
||||
{
|
||||
const std::vector <ref <messageId> >::iterator it = m_list.begin() + pos;
|
||||
const std::vector <shared_ptr <messageId> >::iterator it = m_list.begin() + pos;
|
||||
|
||||
m_list.erase(it);
|
||||
}
|
||||
@ -215,25 +215,25 @@ bool messageIdSequence::isEmpty() const
|
||||
}
|
||||
|
||||
|
||||
const ref <messageId> messageIdSequence::getMessageIdAt(const size_t pos)
|
||||
const shared_ptr <messageId> messageIdSequence::getMessageIdAt(const size_t pos)
|
||||
{
|
||||
return (m_list[pos]);
|
||||
}
|
||||
|
||||
|
||||
const ref <const messageId> messageIdSequence::getMessageIdAt(const size_t pos) const
|
||||
const shared_ptr <const messageId> messageIdSequence::getMessageIdAt(const size_t pos) const
|
||||
{
|
||||
return (m_list[pos]);
|
||||
}
|
||||
|
||||
|
||||
const std::vector <ref <const messageId> > messageIdSequence::getMessageIdList() const
|
||||
const std::vector <shared_ptr <const messageId> > messageIdSequence::getMessageIdList() const
|
||||
{
|
||||
std::vector <ref <const messageId> > list;
|
||||
std::vector <shared_ptr <const messageId> > list;
|
||||
|
||||
list.reserve(m_list.size());
|
||||
|
||||
for (std::vector <ref <messageId> >::const_iterator it = m_list.begin() ;
|
||||
for (std::vector <shared_ptr <messageId> >::const_iterator it = m_list.begin() ;
|
||||
it != m_list.end() ; ++it)
|
||||
{
|
||||
list.push_back(*it);
|
||||
@ -243,7 +243,7 @@ const std::vector <ref <const messageId> > messageIdSequence::getMessageIdList()
|
||||
}
|
||||
|
||||
|
||||
const std::vector <ref <messageId> > messageIdSequence::getMessageIdList()
|
||||
const std::vector <shared_ptr <messageId> > messageIdSequence::getMessageIdList()
|
||||
{
|
||||
return (m_list);
|
||||
}
|
||||
|
@ -39,14 +39,14 @@ namespace vmime
|
||||
|
||||
messageParser::messageParser(const string& buffer)
|
||||
{
|
||||
ref <message> msg = vmime::create <message>();
|
||||
shared_ptr <message> msg = make_shared <message>();
|
||||
msg->parse(buffer);
|
||||
|
||||
parse(msg);
|
||||
}
|
||||
|
||||
|
||||
messageParser::messageParser(ref <const message> msg)
|
||||
messageParser::messageParser(shared_ptr <const message> msg)
|
||||
{
|
||||
parse(msg);
|
||||
}
|
||||
@ -57,13 +57,13 @@ messageParser::~messageParser()
|
||||
}
|
||||
|
||||
|
||||
void messageParser::parse(ref <const message> msg)
|
||||
void messageParser::parse(shared_ptr <const message> 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 <type>(); } \
|
||||
try { var = *msg->getHeader()->findField(name)->getValue <type>(); } \
|
||||
catch (exceptions::no_such_field) { }
|
||||
|
||||
TRY_FIELD(m_from, mailbox, fields::FROM);
|
||||
@ -82,14 +82,14 @@ void messageParser::parse(ref <const message> msg)
|
||||
try
|
||||
{
|
||||
const headerField& recv = *msg->getHeader()->findField(fields::RECEIVED);
|
||||
m_date = recv.getValue().dynamicCast <const relay>()->getDate();
|
||||
m_date = recv.getValue <relay>()->getDate();
|
||||
}
|
||||
catch (vmime::exceptions::no_such_field&)
|
||||
{
|
||||
try
|
||||
{
|
||||
const headerField& date = *msg->getHeader()->findField(fields::DATE);
|
||||
m_date = *date.getValue().dynamicCast <const datetime>();
|
||||
m_date = *date.getValue <datetime>();
|
||||
}
|
||||
catch (vmime::exceptions::no_such_field&)
|
||||
{
|
||||
@ -105,13 +105,13 @@ void messageParser::parse(ref <const message> msg)
|
||||
}
|
||||
|
||||
|
||||
void messageParser::findAttachments(ref <const message> msg)
|
||||
void messageParser::findAttachments(shared_ptr <const message> msg)
|
||||
{
|
||||
m_attach = attachmentHelper::findAttachmentsInMessage(msg);
|
||||
}
|
||||
|
||||
|
||||
void messageParser::findTextParts(ref <const bodyPart> msg, ref <const bodyPart> part)
|
||||
void messageParser::findTextParts(shared_ptr <const bodyPart> msg, shared_ptr <const bodyPart> 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 <const bodyPart> msg, ref <const bodyPart>
|
||||
|
||||
try
|
||||
{
|
||||
const contentTypeField& ctf = dynamic_cast<contentTypeField&>
|
||||
(*msg->getHeader()->findField(fields::CONTENT_TYPE));
|
||||
const contentTypeField& ctf =
|
||||
*msg->getHeader()->findField <contentTypeField>(fields::CONTENT_TYPE);
|
||||
|
||||
const mediaType ctfType =
|
||||
*ctf.getValue().dynamicCast <const mediaType>();
|
||||
*ctf.getValue <mediaType>();
|
||||
|
||||
if (ctfType.getType() == mediaTypes::TEXT)
|
||||
{
|
||||
@ -142,7 +142,7 @@ void messageParser::findTextParts(ref <const bodyPart> msg, ref <const bodyPart>
|
||||
|
||||
if (accept)
|
||||
{
|
||||
ref <textPart> txtPart = textPartFactory::getInstance()->create(type);
|
||||
shared_ptr <textPart> txtPart = textPartFactory::getInstance()->create(type);
|
||||
txtPart->parse(msg, msg, msg);
|
||||
|
||||
m_textParts.push_back(txtPart);
|
||||
@ -156,35 +156,35 @@ void messageParser::findTextParts(ref <const bodyPart> msg, ref <const bodyPart>
|
||||
}
|
||||
|
||||
|
||||
bool messageParser::findSubTextParts(ref <const bodyPart> msg, ref <const bodyPart> part)
|
||||
bool messageParser::findSubTextParts(shared_ptr <const bodyPart> msg, shared_ptr <const bodyPart> 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 <ref <const bodyPart> > textParts;
|
||||
std::vector <shared_ptr <const bodyPart> > textParts;
|
||||
|
||||
for (size_t i = 0 ; i < part->getBody()->getPartCount() ; ++i)
|
||||
{
|
||||
const ref <const bodyPart> p = part->getBody()->getPartAt(i);
|
||||
const shared_ptr <const bodyPart> p = part->getBody()->getPartAt(i);
|
||||
|
||||
try
|
||||
{
|
||||
const contentTypeField& ctf = dynamic_cast <const contentTypeField&>
|
||||
(*(p->getHeader()->findField(fields::CONTENT_TYPE)));
|
||||
const contentTypeField& ctf =
|
||||
*p->getHeader()->findField <contentTypeField>(fields::CONTENT_TYPE);
|
||||
|
||||
const mediaType type = *ctf.getValue().dynamicCast <const mediaType>();
|
||||
const mediaType type = *ctf.getValue <mediaType>();
|
||||
contentDisposition disp; // default should be inline
|
||||
|
||||
if (type.getType() == mediaTypes::TEXT)
|
||||
{
|
||||
try
|
||||
{
|
||||
ref <const contentDispositionField> cdf = p->getHeader()->
|
||||
findField(fields::CONTENT_DISPOSITION).dynamicCast <const contentDispositionField>();
|
||||
shared_ptr <const contentDispositionField> cdf = p->getHeader()->
|
||||
findField <contentDispositionField>(fields::CONTENT_DISPOSITION);
|
||||
|
||||
disp = *cdf->getValue().dynamicCast <const contentDisposition>();
|
||||
disp = *cdf->getValue <contentDisposition>();
|
||||
}
|
||||
catch (exceptions::no_such_field&)
|
||||
{
|
||||
@ -204,17 +204,17 @@ bool messageParser::findSubTextParts(ref <const bodyPart> msg, ref <const bodyPa
|
||||
if (textParts.size())
|
||||
{
|
||||
// Okay. So we have found at least one text part
|
||||
for (std::vector <ref <const bodyPart> >::const_iterator p = textParts.begin() ;
|
||||
for (std::vector <shared_ptr <const bodyPart> >::const_iterator p = textParts.begin() ;
|
||||
p != textParts.end() ; ++p)
|
||||
{
|
||||
const contentTypeField& ctf = dynamic_cast <const contentTypeField&>
|
||||
(*((*p)->getHeader()->findField(fields::CONTENT_TYPE)));
|
||||
const contentTypeField& ctf =
|
||||
*(*p)->getHeader()->findField <contentTypeField>(fields::CONTENT_TYPE);
|
||||
|
||||
const mediaType type = *ctf.getValue().dynamicCast <const mediaType>();
|
||||
const mediaType type = *ctf.getValue <mediaType>();
|
||||
|
||||
try
|
||||
{
|
||||
ref <textPart> txtPart = textPartFactory::getInstance()->create(type);
|
||||
shared_ptr <textPart> 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 <ref <const attachment> > messageParser::getAttachmentList() const
|
||||
const std::vector <shared_ptr <const attachment> > messageParser::getAttachmentList() const
|
||||
{
|
||||
return m_attach;
|
||||
}
|
||||
@ -285,19 +285,19 @@ size_t messageParser::getAttachmentCount() const
|
||||
}
|
||||
|
||||
|
||||
const ref <const attachment> messageParser::getAttachmentAt(const size_t pos) const
|
||||
const shared_ptr <const attachment> messageParser::getAttachmentAt(const size_t pos) const
|
||||
{
|
||||
return (m_attach[pos]);
|
||||
}
|
||||
|
||||
|
||||
const std::vector <ref <const textPart> > messageParser::getTextPartList() const
|
||||
const std::vector <shared_ptr <const textPart> > messageParser::getTextPartList() const
|
||||
{
|
||||
std::vector <ref <const textPart> > res;
|
||||
std::vector <shared_ptr <const textPart> > res;
|
||||
|
||||
res.reserve(m_textParts.size());
|
||||
|
||||
for (std::vector <ref <textPart> >::const_iterator it = m_textParts.begin() ;
|
||||
for (std::vector <shared_ptr <textPart> >::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 <const textPart> messageParser::getTextPartAt(const size_t pos) const
|
||||
const shared_ptr <const textPart> messageParser::getTextPartAt(const size_t pos) const
|
||||
{
|
||||
return (m_textParts[pos]);
|
||||
}
|
||||
|
@ -31,17 +31,17 @@ namespace vmime {
|
||||
namespace misc {
|
||||
|
||||
|
||||
void importanceHelper::resetImportance(ref <message> msg)
|
||||
void importanceHelper::resetImportance(shared_ptr <message> msg)
|
||||
{
|
||||
resetImportanceHeader(msg->getHeader());
|
||||
}
|
||||
|
||||
|
||||
void importanceHelper::resetImportanceHeader(ref <header> hdr)
|
||||
void importanceHelper::resetImportanceHeader(shared_ptr <header> hdr)
|
||||
{
|
||||
try
|
||||
{
|
||||
ref <headerField> fld = hdr->findField("X-Priority");
|
||||
shared_ptr <headerField> fld = hdr->findField("X-Priority");
|
||||
hdr->removeField(fld);
|
||||
}
|
||||
catch (exceptions::no_such_field)
|
||||
@ -51,7 +51,7 @@ void importanceHelper::resetImportanceHeader(ref <header> hdr)
|
||||
|
||||
try
|
||||
{
|
||||
ref <headerField> fld = hdr->findField("Importance");
|
||||
shared_ptr <headerField> fld = hdr->findField("Importance");
|
||||
hdr->removeField(fld);
|
||||
}
|
||||
catch (exceptions::no_such_field)
|
||||
@ -61,19 +61,19 @@ void importanceHelper::resetImportanceHeader(ref <header> hdr)
|
||||
}
|
||||
|
||||
|
||||
importanceHelper::Importance importanceHelper::getImportance(ref <const message> msg)
|
||||
importanceHelper::Importance importanceHelper::getImportance(shared_ptr <const message> msg)
|
||||
{
|
||||
return getImportanceHeader(msg->getHeader());
|
||||
}
|
||||
|
||||
|
||||
importanceHelper::Importance importanceHelper::getImportanceHeader(ref <const header> hdr)
|
||||
importanceHelper::Importance importanceHelper::getImportanceHeader(shared_ptr <const header> hdr)
|
||||
{
|
||||
// Try "X-Priority" field
|
||||
try
|
||||
{
|
||||
const ref <const headerField> fld = hdr->findField("X-Priority");
|
||||
const string value = fld->getValue().dynamicCast <const text>()->getWholeBuffer();
|
||||
const shared_ptr <const headerField> fld = hdr->findField("X-Priority");
|
||||
const string value = fld->getValue <text>()->getWholeBuffer();
|
||||
|
||||
int n = IMPORTANCE_NORMAL;
|
||||
|
||||
@ -98,9 +98,9 @@ importanceHelper::Importance importanceHelper::getImportanceHeader(ref <const he
|
||||
// Try "Importance" field
|
||||
try
|
||||
{
|
||||
const ref <const headerField> fld = hdr->findField("Importance");
|
||||
const shared_ptr <const headerField> fld = hdr->findField("Importance");
|
||||
const string value = utility::stringUtils::toLower(utility::stringUtils::trim
|
||||
(fld->getValue().dynamicCast <const text>()->getWholeBuffer()));
|
||||
(fld->getValue <text>()->getWholeBuffer()));
|
||||
|
||||
if (value == "low")
|
||||
return (IMPORTANCE_LOWEST);
|
||||
@ -121,16 +121,16 @@ importanceHelper::Importance importanceHelper::getImportanceHeader(ref <const he
|
||||
}
|
||||
|
||||
|
||||
void importanceHelper::setImportance(ref <message> msg, const Importance i)
|
||||
void importanceHelper::setImportance(shared_ptr <message> msg, const Importance i)
|
||||
{
|
||||
setImportanceHeader(msg->getHeader(), i);
|
||||
}
|
||||
|
||||
|
||||
void importanceHelper::setImportanceHeader(ref <header> hdr, const Importance i)
|
||||
void importanceHelper::setImportanceHeader(shared_ptr <header> hdr, const Importance i)
|
||||
{
|
||||
// "X-Priority:" Field
|
||||
ref <headerField> fld = hdr->getField("X-Priority");
|
||||
shared_ptr <headerField> fld = hdr->getField("X-Priority");
|
||||
|
||||
switch (i)
|
||||
{
|
||||
|
@ -60,7 +60,7 @@ const char* messageCountEvent::EVENT_CLASS = "messageCountEvent";
|
||||
|
||||
|
||||
messageCountEvent::messageCountEvent
|
||||
(ref <folder> folder, const Types type, const std::vector <int>& nums)
|
||||
(shared_ptr <folder> folder, const Types type, const std::vector <int>& nums)
|
||||
: m_folder(folder), m_type(type)
|
||||
{
|
||||
m_nums.resize(nums.size());
|
||||
@ -68,7 +68,7 @@ messageCountEvent::messageCountEvent
|
||||
}
|
||||
|
||||
|
||||
ref <folder> messageCountEvent::getFolder() const { return (m_folder); }
|
||||
shared_ptr <folder> messageCountEvent::getFolder() const { return (m_folder); }
|
||||
messageCountEvent::Types messageCountEvent::getType() const { return (m_type); }
|
||||
const std::vector <int>& messageCountEvent::getNumbers() const { return (m_nums); }
|
||||
|
||||
@ -76,9 +76,9 @@ const std::vector <int>& messageCountEvent::getNumbers() const { return (m_nums)
|
||||
void messageCountEvent::dispatch(messageCountListener* listener)
|
||||
{
|
||||
if (m_type == TYPE_ADDED)
|
||||
listener->messagesAdded(thisRef().dynamicCast <messageCountEvent>());
|
||||
listener->messagesAdded(dynamicCast <messageCountEvent>(shared_from_this()));
|
||||
else
|
||||
listener->messagesRemoved(thisRef().dynamicCast <messageCountEvent>());
|
||||
listener->messagesRemoved(dynamicCast <messageCountEvent>(shared_from_this()));
|
||||
}
|
||||
|
||||
|
||||
@ -96,7 +96,7 @@ const char* messageChangedEvent::EVENT_CLASS = "messageChangedEvent";
|
||||
|
||||
|
||||
messageChangedEvent::messageChangedEvent
|
||||
(ref <folder> folder, const Types type, const std::vector <int>& nums)
|
||||
(shared_ptr <folder> folder, const Types type, const std::vector <int>& nums)
|
||||
: m_folder(folder), m_type(type)
|
||||
{
|
||||
m_nums.resize(nums.size());
|
||||
@ -104,14 +104,14 @@ messageChangedEvent::messageChangedEvent
|
||||
}
|
||||
|
||||
|
||||
ref <folder> messageChangedEvent::getFolder() const { return (m_folder); }
|
||||
shared_ptr <folder> messageChangedEvent::getFolder() const { return (m_folder); }
|
||||
messageChangedEvent::Types messageChangedEvent::getType() const { return (m_type); }
|
||||
const std::vector <int>& messageChangedEvent::getNumbers() const { return (m_nums); }
|
||||
|
||||
|
||||
void messageChangedEvent::dispatch(messageChangedListener* listener)
|
||||
{
|
||||
listener->messageChanged(thisRef().dynamicCast <messageChangedEvent>());
|
||||
listener->messageChanged(dynamicCast <messageChangedEvent>(shared_from_this()));
|
||||
}
|
||||
|
||||
|
||||
@ -129,14 +129,14 @@ const char* folderEvent::EVENT_CLASS = "folderEvent";
|
||||
|
||||
|
||||
folderEvent::folderEvent
|
||||
(ref <folder> folder, const Types type,
|
||||
(shared_ptr <folder> 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 <folder> folderEvent::getFolder() const { return (m_folder); }
|
||||
shared_ptr <folder> 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 <folderEvent>()); break;
|
||||
case TYPE_RENAMED: listener->folderRenamed(thisRef().dynamicCast <folderEvent>()); break;
|
||||
case TYPE_DELETED: listener->folderDeleted(thisRef().dynamicCast <folderEvent>()); break;
|
||||
case TYPE_CREATED: listener->folderCreated(dynamicCast <folderEvent>(shared_from_this())); break;
|
||||
case TYPE_RENAMED: listener->folderRenamed(dynamicCast <folderEvent>(shared_from_this())); break;
|
||||
case TYPE_DELETED: listener->folderDeleted(dynamicCast <folderEvent>(shared_from_this())); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ void folder::removeMessageChangedListener(events::messageChangedListener* l)
|
||||
}
|
||||
|
||||
|
||||
void folder::notifyMessageChanged(ref <events::messageChangedEvent> event)
|
||||
void folder::notifyMessageChanged(shared_ptr <events::messageChangedEvent> event)
|
||||
{
|
||||
for (std::list <events::messageChangedListener*>::iterator
|
||||
it = m_messageChangedListeners.begin() ; it != m_messageChangedListeners.end() ; ++it)
|
||||
@ -70,7 +70,7 @@ void folder::removeMessageCountListener(events::messageCountListener* l)
|
||||
}
|
||||
|
||||
|
||||
void folder::notifyMessageCount(ref <events::messageCountEvent> event)
|
||||
void folder::notifyMessageCount(shared_ptr <events::messageCountEvent> event)
|
||||
{
|
||||
for (std::list <events::messageCountListener*>::iterator
|
||||
it = m_messageCountListeners.begin() ; it != m_messageCountListeners.end() ; ++it)
|
||||
@ -92,7 +92,7 @@ void folder::removeFolderListener(events::folderListener* l)
|
||||
}
|
||||
|
||||
|
||||
void folder::notifyFolder(ref <events::folderEvent> event)
|
||||
void folder::notifyFolder(shared_ptr <events::folderEvent> event)
|
||||
{
|
||||
for (std::list <events::folderListener*>::iterator
|
||||
it = m_folderListeners.begin() ; it != m_folderListeners.end() ; ++it)
|
||||
@ -102,19 +102,19 @@ void folder::notifyFolder(ref <events::folderEvent> event)
|
||||
}
|
||||
|
||||
|
||||
void folder::notifyEvent(ref <events::event> event)
|
||||
void folder::notifyEvent(shared_ptr <events::event> event)
|
||||
{
|
||||
if (event->getClass() == events::messageCountEvent::EVENT_CLASS)
|
||||
{
|
||||
notifyMessageCount(event.dynamicCast <events::messageCountEvent>());
|
||||
notifyMessageCount(dynamicCast <events::messageCountEvent>(event));
|
||||
}
|
||||
else if (event->getClass() == events::messageChangedEvent::EVENT_CLASS)
|
||||
{
|
||||
notifyMessageChanged(event.dynamicCast <events::messageChangedEvent>());
|
||||
notifyMessageChanged(dynamicCast <events::messageChangedEvent>(event));
|
||||
}
|
||||
else if (event->getClass() == events::folderEvent::EVENT_CLASS)
|
||||
{
|
||||
notifyFolder(event.dynamicCast <events::folderEvent>());
|
||||
notifyFolder(dynamicCast <events::folderEvent>(event));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,11 +53,11 @@
|
||||
|
||||
// Helpers for service properties
|
||||
#define GET_PROPERTY(type, prop) \
|
||||
(m_store.acquire()->getInfos().getPropertyValue <type>(getSession(), \
|
||||
dynamic_cast <const IMAPServiceInfos&>(m_store.acquire()->getInfos()).getProperties().prop))
|
||||
(m_store.lock()->getInfos().getPropertyValue <type>(getSession(), \
|
||||
dynamic_cast <const IMAPServiceInfos&>(m_store.lock()->getInfos()).getProperties().prop))
|
||||
#define HAS_PROPERTY(prop) \
|
||||
(m_store.acquire()->getInfos().hasProperty(getSession(), \
|
||||
dynamic_cast <const IMAPServiceInfos&>(m_store.acquire()->getInfos()).getProperties().prop))
|
||||
(m_store.lock()->getInfos().hasProperty(getSession(), \
|
||||
dynamic_cast <const IMAPServiceInfos&>(m_store.lock()->getInfos()).getProperties().prop))
|
||||
|
||||
|
||||
namespace vmime {
|
||||
@ -65,9 +65,9 @@ namespace net {
|
||||
namespace imap {
|
||||
|
||||
|
||||
IMAPConnection::IMAPConnection(ref <IMAPStore> store, ref <security::authenticator> 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 <IMAPStore> store, shared_ptr <security::authenticator> 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 <IMAPStore> store = m_store.acquire();
|
||||
shared_ptr <IMAPStore> 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 <tls::TLSSession> tlsSession = tls::TLSSession::create
|
||||
shared_ptr <tls::TLSSession> tlsSession = tls::TLSSession::create
|
||||
(store->getCertificateVerifier(),
|
||||
store->getSession()->getTLSProperties());
|
||||
|
||||
ref <tls::TLSSocket> tlsSocket =
|
||||
shared_ptr <tls::TLSSocket> tlsSocket =
|
||||
tlsSession->getSocket(m_socket);
|
||||
|
||||
m_socket = tlsSocket;
|
||||
|
||||
m_secured = true;
|
||||
m_cntInfos = vmime::create <tls::TLSSecuredConnectionInfos>(address, port, tlsSession, tlsSocket);
|
||||
m_cntInfos = make_shared <tls::TLSSecuredConnectionInfos>(address, port, tlsSession, tlsSocket);
|
||||
}
|
||||
else
|
||||
#endif // VMIME_HAVE_TLS_SUPPORT
|
||||
{
|
||||
m_cntInfos = vmime::create <defaultConnectionInfos>(address, port);
|
||||
m_cntInfos = make_shared <defaultConnectionInfos>(address, port);
|
||||
}
|
||||
|
||||
m_socket->connect(address, port);
|
||||
|
||||
|
||||
m_tag = vmime::create <IMAPTag>();
|
||||
m_parser = vmime::create <IMAPParser>(m_tag, m_socket, m_timeoutHandler);
|
||||
m_tag = make_shared <IMAPTag>();
|
||||
m_parser = make_shared <IMAPParser>(m_tag, m_socket, m_timeoutHandler);
|
||||
|
||||
|
||||
setState(STATE_NON_AUTHENTICATED);
|
||||
@ -145,7 +145,7 @@ void IMAPConnection::connect()
|
||||
// eg: C: <connection to server>
|
||||
// --- S: * OK mydomain.org IMAP4rev1 v12.256 server ready
|
||||
|
||||
utility::auto_ptr <IMAPParser::greeting> greet(m_parser->readGreeting());
|
||||
std::auto_ptr <IMAPParser::greeting> 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 <IMAPParser::response> resp(m_parser->readResponse());
|
||||
std::auto_ptr <IMAPParser::response> 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 <security::sasl::SASLAuthenticator>())
|
||||
if (!dynamicCast <security::sasl::SASLAuthenticator>(getAuthenticator()))
|
||||
throw exceptions::authentication_error("No SASL authenticator available.");
|
||||
|
||||
const std::vector <string> capa = getCapabilities();
|
||||
@ -310,10 +310,10 @@ void IMAPConnection::authenticateSASL()
|
||||
if (saslMechs.empty())
|
||||
throw exceptions::authentication_error("No SASL mechanism available.");
|
||||
|
||||
std::vector <ref <security::sasl::SASLMechanism> > mechList;
|
||||
std::vector <shared_ptr <security::sasl::SASLMechanism> > mechList;
|
||||
|
||||
ref <security::sasl::SASLContext> saslContext =
|
||||
vmime::create <security::sasl::SASLContext>();
|
||||
shared_ptr <security::sasl::SASLContext> saslContext =
|
||||
make_shared <security::sasl::SASLContext>();
|
||||
|
||||
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 <security::sasl::SASLMechanism> suggestedMech =
|
||||
shared_ptr <security::sasl::SASLMechanism> 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 <security::sasl::SASLAuthenticator>()->
|
||||
mechList = dynamicCast <security::sasl::SASLAuthenticator>(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 <security::sasl::SASLMechanism> mech = mechList[i];
|
||||
shared_ptr <security::sasl::SASLMechanism> mech = mechList[i];
|
||||
|
||||
ref <security::sasl::SASLSession> saslSession =
|
||||
shared_ptr <security::sasl::SASLSession> saslSession =
|
||||
saslContext->createSession("imap", getAuthenticator(), mech);
|
||||
|
||||
saslSession->init();
|
||||
@ -359,7 +359,7 @@ void IMAPConnection::authenticateSASL()
|
||||
|
||||
for (bool cont = true ; cont ; )
|
||||
{
|
||||
utility::auto_ptr <IMAPParser::response> resp(m_parser->readResponse());
|
||||
std::auto_ptr <IMAPParser::response> 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 <IMAPParser::response> resp(m_parser->readResponse());
|
||||
std::auto_ptr <IMAPParser::response> 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 <tls::TLSSession> tlsSession = tls::TLSSession::create
|
||||
(m_store.acquire()->getCertificateVerifier(),
|
||||
m_store.acquire()->getSession()->getTLSProperties());
|
||||
shared_ptr <tls::TLSSession> tlsSession = tls::TLSSession::create
|
||||
(m_store.lock()->getCertificateVerifier(),
|
||||
m_store.lock()->getSession()->getTLSProperties());
|
||||
|
||||
ref <tls::TLSSocket> tlsSocket =
|
||||
shared_ptr <tls::TLSSocket> 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 <tls::TLSSecuredConnectionInfos>
|
||||
m_cntInfos = make_shared <tls::TLSSecuredConnectionInfos>
|
||||
(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 <IMAPParser::response> resp(m_parser->readResponse());
|
||||
std::auto_ptr <IMAPParser::response> 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 <security::authenticator> IMAPConnection::getAuthenticator()
|
||||
shared_ptr <security::authenticator> IMAPConnection::getAuthenticator()
|
||||
{
|
||||
return m_auth;
|
||||
}
|
||||
@ -623,7 +623,7 @@ bool IMAPConnection::isSecuredConnection() const
|
||||
}
|
||||
|
||||
|
||||
ref <connectionInfos> IMAPConnection::getConnectionInfos() const
|
||||
shared_ptr <connectionInfos> 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 <IMAPParser::response> resp(m_parser->readResponse());
|
||||
std::auto_ptr <IMAPParser::response> 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 <const IMAPStore> IMAPConnection::getStore() const
|
||||
shared_ptr <const IMAPStore> IMAPConnection::getStore() const
|
||||
{
|
||||
return m_store.acquire();
|
||||
return m_store.lock();
|
||||
}
|
||||
|
||||
|
||||
ref <IMAPStore> IMAPConnection::getStore()
|
||||
shared_ptr <IMAPStore> IMAPConnection::getStore()
|
||||
{
|
||||
return m_store.acquire();
|
||||
return m_store.lock();
|
||||
}
|
||||
|
||||
|
||||
ref <session> IMAPConnection::getSession()
|
||||
shared_ptr <session> IMAPConnection::getSession()
|
||||
{
|
||||
return m_store.acquire()->getSession();
|
||||
return m_store.lock()->getSession();
|
||||
}
|
||||
|
||||
|
||||
ref <const socket> IMAPConnection::getSocket() const
|
||||
shared_ptr <const socket> IMAPConnection::getSocket() const
|
||||
{
|
||||
return m_socket;
|
||||
}
|
||||
|
@ -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 <IMAPStore> store, const int type, const int flags)
|
||||
IMAPFolder::IMAPFolder(const folder::path& path, shared_ptr <IMAPStore> 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 <IMAPFolderStatus>();
|
||||
m_status = make_shared <IMAPFolderStatus>();
|
||||
}
|
||||
|
||||
|
||||
IMAPFolder::~IMAPFolder()
|
||||
{
|
||||
ref <IMAPStore> store = m_store.acquire();
|
||||
shared_ptr <IMAPStore> 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 <IMAPStore> store = m_store.acquire();
|
||||
shared_ptr <IMAPStore> 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 <IMAPConnection> connection =
|
||||
vmime::create <IMAPConnection>(store, store->getAuthenticator());
|
||||
shared_ptr <IMAPConnection> connection =
|
||||
make_shared <IMAPConnection>(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 <IMAPParser::response> resp(connection->readResponse());
|
||||
std::auto_ptr <IMAPParser::response> 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 <IMAPStore> store = m_store.acquire();
|
||||
shared_ptr <IMAPStore> 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 <IMAPConnection> oldConnection = m_connection;
|
||||
shared_ptr <IMAPConnection> 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 <IMAPFolderStatus>();
|
||||
m_status = make_shared <IMAPFolderStatus>();
|
||||
|
||||
onClose();
|
||||
}
|
||||
@ -341,7 +340,7 @@ void IMAPFolder::onClose()
|
||||
|
||||
void IMAPFolder::create(const int type)
|
||||
{
|
||||
ref <IMAPStore> store = m_store.acquire();
|
||||
shared_ptr <IMAPStore> 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 <IMAPParser::response> resp(m_connection->readResponse());
|
||||
std::auto_ptr <IMAPParser::response> 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 <events::folderEvent> event =
|
||||
vmime::create <events::folderEvent>
|
||||
(thisRef().dynamicCast <folder>(),
|
||||
shared_ptr <events::folderEvent> event =
|
||||
make_shared <events::folderEvent>
|
||||
(dynamicCast <folder>(shared_from_this()),
|
||||
events::folderEvent::TYPE_CREATED, m_path, m_path);
|
||||
|
||||
notifyFolder(event);
|
||||
@ -392,7 +391,7 @@ void IMAPFolder::create(const int type)
|
||||
|
||||
void IMAPFolder::destroy()
|
||||
{
|
||||
ref <IMAPStore> store = m_store.acquire();
|
||||
shared_ptr <IMAPStore> 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 <IMAPParser::response> resp(m_connection->readResponse());
|
||||
std::auto_ptr <IMAPParser::response> 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 <events::folderEvent> event =
|
||||
vmime::create <events::folderEvent>
|
||||
(thisRef().dynamicCast <folder>(),
|
||||
shared_ptr <events::folderEvent> event =
|
||||
make_shared <events::folderEvent>
|
||||
(dynamicCast <folder>(shared_from_this()),
|
||||
events::folderEvent::TYPE_DELETED, m_path, m_path);
|
||||
|
||||
notifyFolder(event);
|
||||
@ -430,7 +429,7 @@ void IMAPFolder::destroy()
|
||||
|
||||
bool IMAPFolder::exists()
|
||||
{
|
||||
ref <IMAPStore> store = m_store.acquire();
|
||||
shared_ptr <IMAPStore> 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 <IMAPParser::response> resp(m_connection->readResponse());
|
||||
std::auto_ptr <IMAPParser::response> 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 <message> IMAPFolder::getMessage(const int num)
|
||||
shared_ptr <message> IMAPFolder::getMessage(const int num)
|
||||
{
|
||||
if (!isOpen())
|
||||
throw exceptions::illegal_state("Folder not open");
|
||||
@ -525,28 +524,28 @@ ref <message> IMAPFolder::getMessage(const int num)
|
||||
if (num < 1 || num > m_status->getMessageCount())
|
||||
throw exceptions::message_not_found();
|
||||
|
||||
return vmime::create <IMAPMessage>(thisRef().dynamicCast <IMAPFolder>(), num);
|
||||
return make_shared <IMAPMessage>(dynamicCast <IMAPFolder>(shared_from_this()), num);
|
||||
}
|
||||
|
||||
|
||||
std::vector <ref <message> > IMAPFolder::getMessages(const messageSet& msgs)
|
||||
std::vector <shared_ptr <message> > IMAPFolder::getMessages(const messageSet& msgs)
|
||||
{
|
||||
if (!isOpen())
|
||||
throw exceptions::illegal_state("Folder not open");
|
||||
|
||||
if (msgs.isEmpty())
|
||||
return std::vector <ref <message> >();
|
||||
return std::vector <shared_ptr <message> >();
|
||||
|
||||
std::vector <ref <message> > messages;
|
||||
std::vector <shared_ptr <message> > messages;
|
||||
|
||||
if (msgs.isNumberSet())
|
||||
{
|
||||
const std::vector <int> numbers = IMAPUtils::messageSetToNumberList(msgs);
|
||||
|
||||
ref <IMAPFolder> thisFolder = thisRef().dynamicCast <IMAPFolder>();
|
||||
shared_ptr <IMAPFolder> thisFolder = dynamicCast <IMAPFolder>(shared_from_this());
|
||||
|
||||
for (std::vector <int>::const_iterator it = numbers.begin() ; it != numbers.end() ; ++it)
|
||||
messages.push_back(vmime::create <IMAPMessage>(thisFolder, *it));
|
||||
messages.push_back(make_shared <IMAPMessage>(thisFolder, *it));
|
||||
}
|
||||
else if (msgs.isUIDSet())
|
||||
{
|
||||
@ -566,7 +565,7 @@ std::vector <ref <message> > IMAPFolder::getMessages(const messageSet& msgs)
|
||||
m_connection->send(true, cmd.str(), true);
|
||||
|
||||
// Get the response
|
||||
utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
||||
std::auto_ptr <IMAPParser::response> 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 <ref <message> > IMAPFolder::getMessages(const messageSet& msgs)
|
||||
|
||||
if (!msgUID.empty())
|
||||
{
|
||||
ref <IMAPFolder> thisFolder = thisRef().dynamicCast <IMAPFolder>();
|
||||
messages.push_back(vmime::create <IMAPMessage>(thisFolder, msgNum, msgUID));
|
||||
shared_ptr <IMAPFolder> thisFolder = dynamicCast <IMAPFolder>(shared_from_this());
|
||||
messages.push_back(make_shared <IMAPMessage>(thisFolder, msgNum, msgUID));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -650,20 +649,20 @@ vmime_uint64 IMAPFolder::getHighestModSequence() const
|
||||
}
|
||||
|
||||
|
||||
ref <folder> IMAPFolder::getFolder(const folder::path::component& name)
|
||||
shared_ptr <folder> IMAPFolder::getFolder(const folder::path::component& name)
|
||||
{
|
||||
ref <IMAPStore> store = m_store.acquire();
|
||||
shared_ptr <IMAPStore> store = m_store.lock();
|
||||
|
||||
if (!store)
|
||||
throw exceptions::illegal_state("Store disconnected");
|
||||
|
||||
return vmime::create <IMAPFolder>(m_path / name, store);
|
||||
return make_shared <IMAPFolder>(m_path / name, store);
|
||||
}
|
||||
|
||||
|
||||
std::vector <ref <folder> > IMAPFolder::getFolders(const bool recursive)
|
||||
std::vector <shared_ptr <folder> > IMAPFolder::getFolders(const bool recursive)
|
||||
{
|
||||
ref <IMAPStore> store = m_store.acquire();
|
||||
shared_ptr <IMAPStore> store = m_store.lock();
|
||||
|
||||
if (!isOpen() && !store)
|
||||
throw exceptions::illegal_state("Store disconnected");
|
||||
@ -699,7 +698,7 @@ std::vector <ref <folder> > IMAPFolder::getFolders(const bool recursive)
|
||||
m_connection->send(true, oss.str(), true);
|
||||
|
||||
|
||||
utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
||||
std::auto_ptr <IMAPParser::response> 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 <ref <folder> > IMAPFolder::getFolders(const bool recursive)
|
||||
resp->continue_req_or_response_data();
|
||||
|
||||
|
||||
std::vector <ref <folder> > v;
|
||||
std::vector <shared_ptr <folder> > v;
|
||||
|
||||
for (std::vector <IMAPParser::continue_req_or_response_data*>::const_iterator
|
||||
it = respDataList.begin() ; it != respDataList.end() ; ++it)
|
||||
@ -741,7 +740,7 @@ std::vector <ref <folder> > 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 <IMAPFolder>(path, store,
|
||||
v.push_back(make_shared <IMAPFolder>(path, store,
|
||||
IMAPUtils::folderTypeFromFlags(mailbox_flag_list),
|
||||
IMAPUtils::folderFlagsFromFlags(mailbox_flag_list)));
|
||||
}
|
||||
@ -751,10 +750,10 @@ std::vector <ref <folder> > IMAPFolder::getFolders(const bool recursive)
|
||||
}
|
||||
|
||||
|
||||
void IMAPFolder::fetchMessages(std::vector <ref <message> >& msg, const fetchAttributes& options,
|
||||
void IMAPFolder::fetchMessages(std::vector <shared_ptr <message> >& msg, const fetchAttributes& options,
|
||||
utility::progressListener* progress)
|
||||
{
|
||||
ref <IMAPStore> store = m_store.acquire();
|
||||
shared_ptr <IMAPStore> store = m_store.lock();
|
||||
|
||||
if (!store)
|
||||
throw exceptions::illegal_state("Store disconnected");
|
||||
@ -765,12 +764,12 @@ void IMAPFolder::fetchMessages(std::vector <ref <message> >& msg, const fetchAtt
|
||||
std::vector <int> list;
|
||||
list.reserve(msg.size());
|
||||
|
||||
std::map <int, ref <IMAPMessage> > numberToMsg;
|
||||
std::map <int, shared_ptr <IMAPMessage> > numberToMsg;
|
||||
|
||||
for (std::vector <ref <message> >::iterator it = msg.begin() ; it != msg.end() ; ++it)
|
||||
for (std::vector <shared_ptr <message> >::iterator it = msg.begin() ; it != msg.end() ; ++it)
|
||||
{
|
||||
list.push_back((*it)->getNumber());
|
||||
numberToMsg[(*it)->getNumber()] = (*it).dynamicCast <IMAPMessage>();
|
||||
numberToMsg[(*it)->getNumber()] = dynamicCast <IMAPMessage>(*it);
|
||||
}
|
||||
|
||||
// Send the request
|
||||
@ -780,7 +779,7 @@ void IMAPFolder::fetchMessages(std::vector <ref <message> >& msg, const fetchAtt
|
||||
m_connection->send(true, command, true);
|
||||
|
||||
// Get the response
|
||||
utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
||||
std::auto_ptr <IMAPParser::response> 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 <ref <message> >& msg, const fetchAtt
|
||||
// Process fetch response for this message
|
||||
const int num = static_cast <int>(messageData->number());
|
||||
|
||||
std::map <int, ref <IMAPMessage> >::iterator msg = numberToMsg.find(num);
|
||||
std::map <int, shared_ptr <IMAPMessage> >::iterator msg = numberToMsg.find(num);
|
||||
|
||||
if (msg != numberToMsg.end())
|
||||
{
|
||||
@ -841,13 +840,13 @@ void IMAPFolder::fetchMessages(std::vector <ref <message> >& msg, const fetchAtt
|
||||
if (progress)
|
||||
progress->stop(total);
|
||||
|
||||
processStatusUpdate(resp);
|
||||
processStatusUpdate(resp.get());
|
||||
}
|
||||
|
||||
|
||||
void IMAPFolder::fetchMessage(ref <message> msg, const fetchAttributes& options)
|
||||
void IMAPFolder::fetchMessage(shared_ptr <message> msg, const fetchAttributes& options)
|
||||
{
|
||||
std::vector <ref <message> > msgs;
|
||||
std::vector <shared_ptr <message> > msgs;
|
||||
msgs.push_back(msg);
|
||||
|
||||
fetchMessages(msgs, options, /* progress */ NULL);
|
||||
@ -863,24 +862,24 @@ int IMAPFolder::getFetchCapabilities() const
|
||||
}
|
||||
|
||||
|
||||
ref <folder> IMAPFolder::getParent()
|
||||
shared_ptr <folder> IMAPFolder::getParent()
|
||||
{
|
||||
if (m_path.isEmpty())
|
||||
return NULL;
|
||||
return null;
|
||||
else
|
||||
return vmime::create <IMAPFolder>(m_path.getParent(), m_store.acquire());
|
||||
return make_shared <IMAPFolder>(m_path.getParent(), m_store.lock());
|
||||
}
|
||||
|
||||
|
||||
ref <const store> IMAPFolder::getStore() const
|
||||
shared_ptr <const store> IMAPFolder::getStore() const
|
||||
{
|
||||
return m_store.acquire();
|
||||
return m_store.lock();
|
||||
}
|
||||
|
||||
|
||||
ref <store> IMAPFolder::getStore()
|
||||
shared_ptr <store> 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 <IMAPStore> store = m_store.acquire();
|
||||
shared_ptr <IMAPStore> 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 <IMAPParser::response> resp(m_connection->readResponse());
|
||||
std::auto_ptr <IMAPParser::response> 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 <IMAPParser::response> resp(m_connection->readResponse());
|
||||
std::auto_ptr <IMAPParser::response> 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 <vmime::message> msg, const int flags,
|
||||
void IMAPFolder::addMessage(shared_ptr <vmime::message> msg, const int flags,
|
||||
vmime::datetime* date, utility::progressListener* progress)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
@ -1009,7 +1008,7 @@ void IMAPFolder::addMessage(ref <vmime::message> msg, const int flags,
|
||||
void IMAPFolder::addMessage(utility::inputStream& is, const int size, const int flags,
|
||||
vmime::datetime* date, utility::progressListener* progress)
|
||||
{
|
||||
ref <IMAPStore> store = m_store.acquire();
|
||||
shared_ptr <IMAPStore> 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 <IMAPParser::response> resp(m_connection->readResponse());
|
||||
std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
||||
|
||||
bool ok = false;
|
||||
const std::vector <IMAPParser::continue_req_or_response_data*>& 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 <IMAPParser::response> finalResp(m_connection->readResponse());
|
||||
std::auto_ptr <IMAPParser::response> 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 <IMAPStore> store = m_store.acquire();
|
||||
shared_ptr <IMAPStore> 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 <IMAPParser::response> resp(m_connection->readResponse());
|
||||
std::auto_ptr <IMAPParser::response> 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 <IMAPStore> store = m_store.acquire();
|
||||
shared_ptr <IMAPStore> 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 <IMAPParser::response> resp(m_connection->readResponse());
|
||||
std::auto_ptr <IMAPParser::response> 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 <events::folderEvent> event =
|
||||
vmime::create <events::folderEvent>
|
||||
(thisRef().dynamicCast <folder>(),
|
||||
shared_ptr <events::folderEvent> event =
|
||||
make_shared <events::folderEvent>
|
||||
(dynamicCast <folder>(shared_from_this()),
|
||||
events::folderEvent::TYPE_RENAMED, oldPath, newPath);
|
||||
|
||||
notifyFolder(event);
|
||||
@ -1197,22 +1196,22 @@ void IMAPFolder::rename(const folder::path& newPath)
|
||||
|
||||
(*it)->m_path.renameParent(oldPath, newPath);
|
||||
|
||||
ref <events::folderEvent> event =
|
||||
vmime::create <events::folderEvent>
|
||||
((*it)->thisRef().dynamicCast <folder>(),
|
||||
shared_ptr <events::folderEvent> event =
|
||||
make_shared <events::folderEvent>
|
||||
(dynamicCast <folder>((*it)->shared_from_this()),
|
||||
events::folderEvent::TYPE_RENAMED, oldPath, (*it)->m_path);
|
||||
|
||||
(*it)->notifyFolder(event);
|
||||
}
|
||||
}
|
||||
|
||||
processStatusUpdate(resp);
|
||||
processStatusUpdate(resp.get());
|
||||
}
|
||||
|
||||
|
||||
void IMAPFolder::copyMessages(const folder::path& dest, const messageSet& set)
|
||||
{
|
||||
ref <IMAPStore> store = m_store.acquire();
|
||||
shared_ptr <IMAPStore> 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 <IMAPParser::response> resp(m_connection->readResponse());
|
||||
std::auto_ptr <IMAPParser::response> 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 <folderStatus> status = getStatus();
|
||||
shared_ptr <folderStatus> status = getStatus();
|
||||
|
||||
count = status->getMessageCount();
|
||||
unseen = status->getUnseenCount();
|
||||
}
|
||||
|
||||
|
||||
ref <folderStatus> IMAPFolder::getStatus()
|
||||
shared_ptr <folderStatus> IMAPFolder::getStatus()
|
||||
{
|
||||
ref <IMAPStore> store = m_store.acquire();
|
||||
shared_ptr <IMAPStore> store = m_store.lock();
|
||||
|
||||
if (!store)
|
||||
throw exceptions::illegal_state("Store disconnected");
|
||||
@ -1283,7 +1282,7 @@ ref <folderStatus> IMAPFolder::getStatus()
|
||||
m_connection->send(true, command.str(), true);
|
||||
|
||||
// Get the response
|
||||
utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
||||
std::auto_ptr <IMAPParser::response> 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 <folderStatus> IMAPFolder::getStatus()
|
||||
if (responseData->mailbox_data() &&
|
||||
responseData->mailbox_data()->type() == IMAPParser::mailbox_data::STATUS)
|
||||
{
|
||||
ref <IMAPFolderStatus> status = vmime::create <IMAPFolderStatus>();
|
||||
shared_ptr <IMAPFolderStatus> status = make_shared <IMAPFolderStatus>();
|
||||
status->updateFromResponse(responseData->mailbox_data());
|
||||
|
||||
m_status->updateFromResponse(responseData->mailbox_data());
|
||||
@ -1322,14 +1321,14 @@ ref <folderStatus> IMAPFolder::getStatus()
|
||||
|
||||
void IMAPFolder::noop()
|
||||
{
|
||||
ref <IMAPStore> store = m_store.acquire();
|
||||
shared_ptr <IMAPStore> store = m_store.lock();
|
||||
|
||||
if (!store)
|
||||
throw exceptions::illegal_state("Store disconnected");
|
||||
|
||||
m_connection->send(true, "NOOP", true);
|
||||
|
||||
utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
||||
std::auto_ptr <IMAPParser::response> 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 <int> IMAPFolder::getMessageNumbersStartingOnUID(const message::uid&
|
||||
m_connection->send(true, command.str(), true);
|
||||
|
||||
// Get the response
|
||||
utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
||||
std::auto_ptr <IMAPParser::response> 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 <int> IMAPFolder::getMessageNumbersStartingOnUID(const message::uid&
|
||||
}
|
||||
}
|
||||
|
||||
processStatusUpdate(resp);
|
||||
processStatusUpdate(resp.get());
|
||||
|
||||
return v;
|
||||
}
|
||||
@ -1401,9 +1400,9 @@ std::vector <int> IMAPFolder::getMessageNumbersStartingOnUID(const message::uid&
|
||||
|
||||
void IMAPFolder::processStatusUpdate(const IMAPParser::response* resp)
|
||||
{
|
||||
std::vector <ref <events::event> > events;
|
||||
std::vector <shared_ptr <events::event> > events;
|
||||
|
||||
ref <IMAPFolderStatus> oldStatus = m_status->clone().dynamicCast <IMAPFolderStatus>();
|
||||
shared_ptr <IMAPFolderStatus> 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 <events::messageChangedEvent>
|
||||
(thisRef().dynamicCast <folder>(),
|
||||
events.push_back(make_shared <events::messageChangedEvent>
|
||||
(dynamicCast <folder>(shared_from_this()),
|
||||
events::messageChangedEvent::TYPE_FLAGS,
|
||||
std::vector <int>(1, msgNumber)));
|
||||
}
|
||||
@ -1467,8 +1466,8 @@ void IMAPFolder::processStatusUpdate(const IMAPParser::response* resp)
|
||||
(*jt)->renumber((*jt)->getNumber() - 1);
|
||||
}
|
||||
|
||||
events.push_back(vmime::create <events::messageCountEvent>
|
||||
(thisRef().dynamicCast <folder>(),
|
||||
events.push_back(make_shared <events::messageCountEvent>
|
||||
(dynamicCast <folder>(shared_from_this()),
|
||||
events::messageCountEvent::TYPE_REMOVED,
|
||||
std::vector <int>(1, msgNumber)));
|
||||
|
||||
@ -1488,14 +1487,14 @@ void IMAPFolder::processStatusUpdate(const IMAPParser::response* resp)
|
||||
newMessageNumbers.push_back(msgNumber);
|
||||
}
|
||||
|
||||
events.push_back(vmime::create <events::messageCountEvent>
|
||||
(thisRef().dynamicCast <folder>(),
|
||||
events.push_back(make_shared <events::messageCountEvent>
|
||||
(dynamicCast <folder>(shared_from_this()),
|
||||
events::messageCountEvent::TYPE_ADDED,
|
||||
newMessageNumbers));
|
||||
}
|
||||
|
||||
// Dispatch notifications
|
||||
for (std::vector <ref <events::event> >::iterator evit =
|
||||
for (std::vector <shared_ptr <events::event> >::iterator evit =
|
||||
events.begin() ; evit != events.end() ; ++evit)
|
||||
{
|
||||
notifyEvent(*evit);
|
||||
|
@ -94,9 +94,9 @@ vmime_uint64 IMAPFolderStatus::getHighestModSeq() const
|
||||
}
|
||||
|
||||
|
||||
ref <folderStatus> IMAPFolderStatus::clone() const
|
||||
shared_ptr <folderStatus> IMAPFolderStatus::clone() const
|
||||
{
|
||||
return vmime::create <IMAPFolderStatus>(*this);
|
||||
return make_shared <IMAPFolderStatus>(*this);
|
||||
}
|
||||
|
||||
|
||||
|
@ -97,17 +97,17 @@ private:
|
||||
//
|
||||
|
||||
|
||||
IMAPMessage::IMAPMessage(ref <IMAPFolder> folder, const int num)
|
||||
IMAPMessage::IMAPMessage(shared_ptr <IMAPFolder> 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 <IMAPFolder> folder, const int num, const uid& uid)
|
||||
IMAPMessage::IMAPMessage(shared_ptr <IMAPFolder> 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 <IMAPFolder> folder, const int num, const uid& uid)
|
||||
|
||||
IMAPMessage::~IMAPMessage()
|
||||
{
|
||||
ref <IMAPFolder> folder = m_folder.acquire();
|
||||
shared_ptr <IMAPFolder> 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 <const messageStructure> IMAPMessage::getStructure() const
|
||||
shared_ptr <const messageStructure> IMAPMessage::getStructure() const
|
||||
{
|
||||
if (m_structure == NULL)
|
||||
throw exceptions::unfetched_object();
|
||||
@ -179,7 +179,7 @@ ref <const messageStructure> IMAPMessage::getStructure() const
|
||||
}
|
||||
|
||||
|
||||
ref <messageStructure> IMAPMessage::getStructure()
|
||||
shared_ptr <messageStructure> IMAPMessage::getStructure()
|
||||
{
|
||||
if (m_structure == NULL)
|
||||
throw exceptions::unfetched_object();
|
||||
@ -188,7 +188,7 @@ ref <messageStructure> IMAPMessage::getStructure()
|
||||
}
|
||||
|
||||
|
||||
ref <const header> IMAPMessage::getHeader() const
|
||||
shared_ptr <const header> IMAPMessage::getHeader() const
|
||||
{
|
||||
if (m_header == NULL)
|
||||
throw exceptions::unfetched_object();
|
||||
@ -200,20 +200,20 @@ ref <const header> IMAPMessage::getHeader() const
|
||||
void IMAPMessage::extract(utility::outputStream& os, utility::progressListener* progress,
|
||||
const int start, const int length, const bool peek) const
|
||||
{
|
||||
ref <const IMAPFolder> folder = m_folder.acquire();
|
||||
shared_ptr <const IMAPFolder> 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 <const messagePart> p, utility::outputStream& os, utility::progressListener* progress,
|
||||
(shared_ptr <const messagePart> p, utility::outputStream& os, utility::progressListener* progress,
|
||||
const int start, const int length, const bool peek) const
|
||||
{
|
||||
ref <const IMAPFolder> folder = m_folder.acquire();
|
||||
shared_ptr <const IMAPFolder> folder = m_folder.lock();
|
||||
|
||||
if (!folder)
|
||||
throw exceptions::folder_not_found();
|
||||
@ -222,9 +222,9 @@ void IMAPMessage::extractPart
|
||||
}
|
||||
|
||||
|
||||
void IMAPMessage::fetchPartHeader(ref <messagePart> p)
|
||||
void IMAPMessage::fetchPartHeader(shared_ptr <messagePart> p)
|
||||
{
|
||||
ref <IMAPFolder> folder = m_folder.acquire();
|
||||
shared_ptr <IMAPFolder> folder = m_folder.lock();
|
||||
|
||||
if (!folder)
|
||||
throw exceptions::folder_not_found();
|
||||
@ -234,15 +234,15 @@ void IMAPMessage::fetchPartHeader(ref <messagePart> p)
|
||||
|
||||
extractImpl(p, ossAdapter, NULL, 0, -1, EXTRACT_HEADER | EXTRACT_PEEK);
|
||||
|
||||
p.dynamicCast <IMAPMessagePart>()->getOrCreateHeader().parse(oss.str());
|
||||
dynamicCast <IMAPMessagePart>(p)->getOrCreateHeader().parse(oss.str());
|
||||
}
|
||||
|
||||
|
||||
void IMAPMessage::fetchPartHeaderForStructure(ref <messageStructure> str)
|
||||
void IMAPMessage::fetchPartHeaderForStructure(shared_ptr <messageStructure> str)
|
||||
{
|
||||
for (size_t i = 0, n = str->getPartCount() ; i < n ; ++i)
|
||||
{
|
||||
ref <messagePart> part = str->getPartAt(i);
|
||||
shared_ptr <messagePart> part = str->getPartAt(i);
|
||||
|
||||
// Fetch header of current part
|
||||
fetchPartHeader(part);
|
||||
@ -253,11 +253,11 @@ void IMAPMessage::fetchPartHeaderForStructure(ref <messageStructure> str)
|
||||
}
|
||||
|
||||
|
||||
void IMAPMessage::extractImpl(ref <const messagePart> p, utility::outputStream& os,
|
||||
void IMAPMessage::extractImpl(shared_ptr <const messagePart> p, utility::outputStream& os,
|
||||
utility::progressListener* progress, const int start,
|
||||
const int length, const int extractFlags) const
|
||||
{
|
||||
ref <const IMAPFolder> folder = m_folder.acquire();
|
||||
shared_ptr <const IMAPFolder> folder = m_folder.lock();
|
||||
|
||||
IMAPMessage_literalHandler literalHandler(os, progress);
|
||||
|
||||
@ -267,7 +267,7 @@ void IMAPMessage::extractImpl(ref <const messagePart> p, utility::outputStream&
|
||||
|
||||
if (p != NULL)
|
||||
{
|
||||
ref <const IMAPMessagePart> currentPart = p.dynamicCast <const IMAPMessagePart>();
|
||||
shared_ptr <const IMAPMessagePart> currentPart = dynamicCast <const IMAPMessagePart>(p);
|
||||
std::vector <int> numbers;
|
||||
|
||||
numbers.push_back(currentPart->getNumber());
|
||||
@ -344,11 +344,11 @@ void IMAPMessage::extractImpl(ref <const messagePart> p, utility::outputStream&
|
||||
command << "<" << start << "." << length << ">";
|
||||
|
||||
// Send the request
|
||||
folder.constCast <IMAPFolder>()->m_connection->send(true, command.str(), true);
|
||||
constCast <IMAPFolder>(folder)->m_connection->send(true, command.str(), true);
|
||||
|
||||
// Get the response
|
||||
utility::auto_ptr <IMAPParser::response> resp
|
||||
(folder.constCast <IMAPFolder>()->m_connection->readResponse(&literalHandler));
|
||||
std::auto_ptr <IMAPParser::response> resp
|
||||
(constCast <IMAPFolder>(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 <const messagePart> p, utility::outputStream&
|
||||
int IMAPMessage::processFetchResponse
|
||||
(const fetchAttributes& options, const IMAPParser::message_data* msgData)
|
||||
{
|
||||
ref <IMAPFolder> folder = m_folder.acquire();
|
||||
shared_ptr <IMAPFolder> folder = m_folder.lock();
|
||||
|
||||
// Get message attributes
|
||||
const std::vector <IMAPParser::msg_att_item*> 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 <vmime::header> hdr = getOrCreateHeader();
|
||||
shared_ptr <vmime::header> 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 <IMAPMessageStructure>((*it)->body());
|
||||
m_structure = make_shared <IMAPMessageStructure>((*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 <ref <headerField> > fields = tempHeader.getFieldList();
|
||||
std::vector <shared_ptr <headerField> > fields = tempHeader.getFieldList();
|
||||
|
||||
for (std::vector <ref <headerField> >::const_iterator jt = fields.begin() ;
|
||||
for (std::vector <shared_ptr <headerField> >::const_iterator jt = fields.begin() ;
|
||||
jt != fields.end() ; ++jt)
|
||||
{
|
||||
hdr.appendField((*jt)->clone().dynamicCast <headerField>());
|
||||
hdr.appendField(vmime::clone(*jt));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -515,18 +515,18 @@ int IMAPMessage::processFetchResponse
|
||||
}
|
||||
|
||||
|
||||
ref <header> IMAPMessage::getOrCreateHeader()
|
||||
shared_ptr <header> IMAPMessage::getOrCreateHeader()
|
||||
{
|
||||
if (m_header != NULL)
|
||||
return (m_header);
|
||||
else
|
||||
return (m_header = vmime::create <header>());
|
||||
return (m_header = make_shared <header>());
|
||||
}
|
||||
|
||||
|
||||
void IMAPMessage::setFlags(const int flags, const int mode)
|
||||
{
|
||||
ref <IMAPFolder> folder = m_folder.acquire();
|
||||
shared_ptr <IMAPFolder> 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 <bodyPart> parentPart, ref <messageStructure> str, int level)
|
||||
(shared_ptr <bodyPart> parentPart, shared_ptr <messageStructure> str, int level)
|
||||
{
|
||||
if (level == 0)
|
||||
{
|
||||
ref <messagePart> part = str->getPartAt(0);
|
||||
shared_ptr <messagePart> part = str->getPartAt(0);
|
||||
|
||||
// Copy header
|
||||
ref <const header> hdr = part->getHeader();
|
||||
shared_ptr <const header> hdr = part->getHeader();
|
||||
parentPart->getHeader()->copyFrom(*hdr);
|
||||
|
||||
// Initialize body
|
||||
parentPart->getBody()->setContents
|
||||
(vmime::create <IMAPMessagePartContentHandler>
|
||||
(thisRef().dynamicCast <IMAPMessage>(),
|
||||
(make_shared <IMAPMessagePartContentHandler>
|
||||
(dynamicCast <IMAPMessage>(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 <messagePart> part = str->getPartAt(i);
|
||||
shared_ptr <messagePart> part = str->getPartAt(i);
|
||||
|
||||
ref <bodyPart> childPart = vmime::create <bodyPart>();
|
||||
shared_ptr <bodyPart> childPart = make_shared <bodyPart>();
|
||||
|
||||
// Copy header
|
||||
ref <const header> hdr = part->getHeader();
|
||||
shared_ptr <const header> hdr = part->getHeader();
|
||||
childPart->getHeader()->copyFrom(*hdr);
|
||||
|
||||
// Initialize body
|
||||
childPart->getBody()->setContents
|
||||
(vmime::create <IMAPMessagePartContentHandler>
|
||||
(thisRef().dynamicCast <IMAPMessage>(),
|
||||
(make_shared <IMAPMessagePartContentHandler>
|
||||
(dynamicCast <IMAPMessage>(shared_from_this()),
|
||||
part, childPart->getBody()->getEncoding()));
|
||||
|
||||
// Add child part
|
||||
@ -585,10 +585,10 @@ void IMAPMessage::constructParsedMessage
|
||||
}
|
||||
|
||||
|
||||
ref <vmime::message> IMAPMessage::getParsedMessage()
|
||||
shared_ptr <vmime::message> IMAPMessage::getParsedMessage()
|
||||
{
|
||||
// Fetch structure
|
||||
ref <messageStructure> structure = NULL;
|
||||
shared_ptr <messageStructure> structure;
|
||||
|
||||
try
|
||||
{
|
||||
@ -596,10 +596,10 @@ ref <vmime::message> IMAPMessage::getParsedMessage()
|
||||
}
|
||||
catch (exceptions::unfetched_object&)
|
||||
{
|
||||
std::vector <ref <message> > msgs;
|
||||
msgs.push_back(thisRef().dynamicCast <IMAPMessage>());
|
||||
std::vector <shared_ptr <message> > msgs;
|
||||
msgs.push_back(dynamicCast <IMAPMessage>(shared_from_this()));
|
||||
|
||||
m_folder.acquire()->fetchMessages
|
||||
m_folder.lock()->fetchMessages
|
||||
(msgs, fetchAttributes(fetchAttributes::STRUCTURE), /* progress */ NULL);
|
||||
|
||||
structure = getStructure();
|
||||
@ -609,7 +609,7 @@ ref <vmime::message> IMAPMessage::getParsedMessage()
|
||||
fetchPartHeaderForStructure(structure);
|
||||
|
||||
// Construct message from structure
|
||||
ref <vmime::message> msg = vmime::create <vmime::message>();
|
||||
shared_ptr <vmime::message> msg = make_shared <vmime::message>();
|
||||
|
||||
constructParsedMessage(msg, structure);
|
||||
|
||||
|
@ -36,16 +36,16 @@ namespace net {
|
||||
namespace imap {
|
||||
|
||||
|
||||
IMAPMessagePart::IMAPMessagePart(ref <IMAPMessagePart> 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 <IMAPMessagePart> 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 <IMAPMessagePart> 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 <IMAPMessagePart> 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 <IMAPMessagePart> parent, const int number,
|
||||
m_size = part->body_type_basic()->body_fields()->body_fld_octets()->value();
|
||||
}
|
||||
|
||||
m_structure = NULL;
|
||||
m_structure = null;
|
||||
}
|
||||
|
||||
|
||||
ref <const messageStructure> IMAPMessagePart::getStructure() const
|
||||
shared_ptr <const messageStructure> IMAPMessagePart::getStructure() const
|
||||
{
|
||||
if (m_structure != NULL)
|
||||
return m_structure;
|
||||
@ -83,7 +83,7 @@ ref <const messageStructure> IMAPMessagePart::getStructure() const
|
||||
}
|
||||
|
||||
|
||||
ref <messageStructure> IMAPMessagePart::getStructure()
|
||||
shared_ptr <messageStructure> IMAPMessagePart::getStructure()
|
||||
{
|
||||
if (m_structure != NULL)
|
||||
return m_structure;
|
||||
@ -92,9 +92,9 @@ ref <messageStructure> IMAPMessagePart::getStructure()
|
||||
}
|
||||
|
||||
|
||||
ref <const IMAPMessagePart> IMAPMessagePart::getParent() const
|
||||
shared_ptr <const IMAPMessagePart> IMAPMessagePart::getParent() const
|
||||
{
|
||||
return m_parent.acquire();
|
||||
return m_parent.lock();
|
||||
}
|
||||
|
||||
|
||||
@ -116,7 +116,7 @@ int IMAPMessagePart::getNumber() const
|
||||
}
|
||||
|
||||
|
||||
ref <const header> IMAPMessagePart::getHeader() const
|
||||
shared_ptr <const header> IMAPMessagePart::getHeader() const
|
||||
{
|
||||
if (m_header == NULL)
|
||||
throw exceptions::unfetched_object();
|
||||
@ -126,19 +126,19 @@ ref <const header> IMAPMessagePart::getHeader() const
|
||||
|
||||
|
||||
// static
|
||||
ref <IMAPMessagePart> IMAPMessagePart::create
|
||||
(ref <IMAPMessagePart> parent, const int number, const IMAPParser::body* body)
|
||||
shared_ptr <IMAPMessagePart> IMAPMessagePart::create
|
||||
(shared_ptr <IMAPMessagePart> parent, const int number, const IMAPParser::body* body)
|
||||
{
|
||||
if (body->body_type_mpart())
|
||||
{
|
||||
ref <IMAPMessagePart> part = vmime::create <IMAPMessagePart>(parent, number, body->body_type_mpart());
|
||||
part->m_structure = vmime::create <IMAPMessageStructure>(part, body->body_type_mpart()->list());
|
||||
shared_ptr <IMAPMessagePart> part = make_shared <IMAPMessagePart>(parent, number, body->body_type_mpart());
|
||||
part->m_structure = make_shared <IMAPMessageStructure>(part, body->body_type_mpart()->list());
|
||||
|
||||
return part;
|
||||
}
|
||||
else
|
||||
{
|
||||
return vmime::create <IMAPMessagePart>(parent, number, body->body_type_1part());
|
||||
return make_shared <IMAPMessagePart>(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 <header>());
|
||||
return *(m_header = make_shared <header>());
|
||||
}
|
||||
|
||||
|
||||
|
@ -43,17 +43,17 @@ namespace imap {
|
||||
|
||||
|
||||
IMAPMessagePartContentHandler::IMAPMessagePartContentHandler
|
||||
(ref <IMAPMessage> msg, ref <messagePart> part, const vmime::encoding& encoding)
|
||||
(shared_ptr <IMAPMessage> msg, shared_ptr <messagePart> part, const vmime::encoding& encoding)
|
||||
: m_message(msg), m_part(part), m_encoding(encoding)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
ref <contentHandler> IMAPMessagePartContentHandler::clone() const
|
||||
shared_ptr <contentHandler> IMAPMessagePartContentHandler::clone() const
|
||||
{
|
||||
return create <IMAPMessagePartContentHandler>
|
||||
(m_message.acquire().constCast <IMAPMessage>(),
|
||||
m_part.acquire().constCast <messagePart>(),
|
||||
return make_shared <IMAPMessagePartContentHandler>
|
||||
(constCast <IMAPMessage>(m_message.lock()),
|
||||
constCast <messagePart>(m_part.lock()),
|
||||
m_encoding);
|
||||
}
|
||||
|
||||
@ -61,8 +61,8 @@ ref <contentHandler> IMAPMessagePartContentHandler::clone() const
|
||||
void IMAPMessagePartContentHandler::generate
|
||||
(utility::outputStream& os, const vmime::encoding& enc, const string::size_type maxLineLength) const
|
||||
{
|
||||
ref <IMAPMessage> msg = m_message.acquire().constCast <IMAPMessage>();
|
||||
ref <messagePart> part = m_part.acquire().constCast <messagePart>();
|
||||
shared_ptr <IMAPMessage> msg = constCast <IMAPMessage>(m_message.lock());
|
||||
shared_ptr <messagePart> part = constCast <messagePart>(m_part.lock());
|
||||
|
||||
// Data is already encoded
|
||||
if (isEncoded())
|
||||
@ -85,14 +85,14 @@ void IMAPMessagePartContentHandler::generate
|
||||
std::ostringstream oss2;
|
||||
utility::outputStreamAdapter tmp2(oss2);
|
||||
|
||||
ref <utility::encoder::encoder> theDecoder = m_encoding.getEncoder();
|
||||
shared_ptr <utility::encoder::encoder> theDecoder = m_encoding.getEncoder();
|
||||
theDecoder->decode(in, tmp2);
|
||||
|
||||
// Reencode to output stream
|
||||
string str = oss2.str();
|
||||
utility::inputStreamStringAdapter tempIn(str);
|
||||
|
||||
ref <utility::encoder::encoder> theEncoder = enc.getEncoder();
|
||||
shared_ptr <utility::encoder::encoder> 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 <utility::encoder::encoder> theEncoder = enc.getEncoder();
|
||||
shared_ptr <utility::encoder::encoder> 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 <IMAPMessage> msg = m_message.acquire().constCast <IMAPMessage>();
|
||||
ref <messagePart> part = m_part.acquire().constCast <messagePart>();
|
||||
shared_ptr <IMAPMessage> msg = constCast <IMAPMessage>(m_message.lock());
|
||||
shared_ptr <messagePart> part = constCast <messagePart>(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 <utility::encoder::encoder> theDecoder = m_encoding.getEncoder();
|
||||
shared_ptr <utility::encoder::encoder> 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 <IMAPMessage> msg = m_message.acquire().constCast <IMAPMessage>();
|
||||
ref <messagePart> part = m_part.acquire().constCast <messagePart>();
|
||||
shared_ptr <IMAPMessage> msg = constCast <IMAPMessage>(m_message.lock());
|
||||
shared_ptr <messagePart> part = constCast <messagePart>(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();
|
||||
}
|
||||
|
||||
|
||||
|
@ -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 <IMAPMessagePart> parent, const std::vector <IMAPParser::body*>& list)
|
||||
IMAPMessageStructure::IMAPMessageStructure(shared_ptr <IMAPMessagePart> parent, const std::vector <IMAPParser::body*>& list)
|
||||
{
|
||||
int number = 0;
|
||||
|
||||
@ -59,13 +59,13 @@ IMAPMessageStructure::IMAPMessageStructure(ref <IMAPMessagePart> parent, const s
|
||||
}
|
||||
|
||||
|
||||
ref <const messagePart> IMAPMessageStructure::getPartAt(const size_t x) const
|
||||
shared_ptr <const messagePart> IMAPMessageStructure::getPartAt(const size_t x) const
|
||||
{
|
||||
return m_parts[x];
|
||||
}
|
||||
|
||||
|
||||
ref <messagePart> IMAPMessageStructure::getPartAt(const size_t x)
|
||||
shared_ptr <messagePart> IMAPMessageStructure::getPartAt(const size_t x)
|
||||
{
|
||||
return m_parts[x];
|
||||
}
|
||||
@ -78,9 +78,9 @@ size_t IMAPMessageStructure::getPartCount() const
|
||||
|
||||
|
||||
// static
|
||||
ref <IMAPMessageStructure> IMAPMessageStructure::emptyStructure()
|
||||
shared_ptr <IMAPMessageStructure> IMAPMessageStructure::emptyStructure()
|
||||
{
|
||||
static ref <IMAPMessageStructure> emptyStructure = vmime::create <IMAPMessageStructure>();
|
||||
static shared_ptr <IMAPMessageStructure> emptyStructure = make_shared <IMAPMessageStructure>();
|
||||
return emptyStructure;
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ namespace net {
|
||||
namespace imap {
|
||||
|
||||
|
||||
IMAPSStore::IMAPSStore(ref <session> sess, ref <security::authenticator> auth)
|
||||
IMAPSStore::IMAPSStore(shared_ptr <session> sess, shared_ptr <security::authenticator> auth)
|
||||
: IMAPStore(sess, auth, true)
|
||||
{
|
||||
}
|
||||
|
@ -43,8 +43,8 @@ namespace net {
|
||||
namespace imap {
|
||||
|
||||
|
||||
IMAPStore::IMAPStore(ref <session> sess, ref <security::authenticator> auth, const bool secured)
|
||||
: store(sess, getInfosInstance(), auth), m_connection(NULL), m_isIMAPS(secured)
|
||||
IMAPStore::IMAPStore(shared_ptr <session> sess, shared_ptr <security::authenticator> auth, const bool secured)
|
||||
: store(sess, getInfosInstance(), auth), m_connection(null), m_isIMAPS(secured)
|
||||
{
|
||||
}
|
||||
|
||||
@ -69,32 +69,35 @@ const string IMAPStore::getProtocolName() const
|
||||
}
|
||||
|
||||
|
||||
ref <folder> IMAPStore::getRootFolder()
|
||||
shared_ptr <folder> IMAPStore::getRootFolder()
|
||||
{
|
||||
if (!isConnected())
|
||||
throw exceptions::illegal_state("Not connected");
|
||||
|
||||
return vmime::create <IMAPFolder>(folder::path(),
|
||||
thisRef().dynamicCast <IMAPStore>());
|
||||
return make_shared <IMAPFolder>
|
||||
(folder::path(),
|
||||
dynamicCast <IMAPStore>(shared_from_this()));
|
||||
}
|
||||
|
||||
|
||||
ref <folder> IMAPStore::getDefaultFolder()
|
||||
shared_ptr <folder> IMAPStore::getDefaultFolder()
|
||||
{
|
||||
if (!isConnected())
|
||||
throw exceptions::illegal_state("Not connected");
|
||||
|
||||
return vmime::create <IMAPFolder>(folder::path::component("INBOX"),
|
||||
thisRef().dynamicCast <IMAPStore>());
|
||||
return make_shared <IMAPFolder>
|
||||
(folder::path::component("INBOX"),
|
||||
dynamicCast <IMAPStore>(shared_from_this()));
|
||||
}
|
||||
|
||||
|
||||
ref <folder> IMAPStore::getFolder(const folder::path& path)
|
||||
shared_ptr <folder> IMAPStore::getFolder(const folder::path& path)
|
||||
{
|
||||
if (!isConnected())
|
||||
throw exceptions::illegal_state("Not connected");
|
||||
|
||||
return vmime::create <IMAPFolder>(path, thisRef().dynamicCast <IMAPStore>());
|
||||
return make_shared <IMAPFolder>
|
||||
(path, dynamicCast <IMAPStore>(shared_from_this()));
|
||||
}
|
||||
|
||||
|
||||
@ -109,8 +112,8 @@ void IMAPStore::connect()
|
||||
if (isConnected())
|
||||
throw exceptions::already_connected();
|
||||
|
||||
m_connection = vmime::create <IMAPConnection>
|
||||
(thisRef().dynamicCast <IMAPStore>(), getAuthenticator());
|
||||
m_connection = make_shared <IMAPConnection>
|
||||
(dynamicCast <IMAPStore>(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 <connectionInfos> IMAPStore::getConnectionInfos() const
|
||||
shared_ptr <connectionInfos> IMAPStore::getConnectionInfos() const
|
||||
{
|
||||
if (m_connection == NULL)
|
||||
return NULL;
|
||||
return null;
|
||||
|
||||
return m_connection->getConnectionInfos();
|
||||
}
|
||||
|
||||
|
||||
ref <IMAPConnection> IMAPStore::getConnection()
|
||||
shared_ptr <IMAPConnection> 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 <IMAPParser::response> resp(m_connection->readResponse());
|
||||
std::auto_ptr <IMAPParser::response> 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 <IMAPConnection> IMAPStore::connection()
|
||||
shared_ptr <IMAPConnection> IMAPStore::connection()
|
||||
{
|
||||
return (m_connection);
|
||||
}
|
||||
|
@ -544,7 +544,7 @@ const string IMAPUtils::dateTime(const vmime::datetime& date)
|
||||
|
||||
// static
|
||||
const string IMAPUtils::buildFetchRequest
|
||||
(ref <IMAPConnection> cnt, const messageSet& msgs, const fetchAttributes& options)
|
||||
(shared_ptr <IMAPConnection> 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 <mailbox>(name, email));
|
||||
dest.appendMailbox(make_shared <mailbox>(name, email));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ namespace maildir {
|
||||
namespace format {
|
||||
|
||||
|
||||
courierMaildirFormat::courierMaildirFormat(ref <context> ctx)
|
||||
courierMaildirFormat::courierMaildirFormat(shared_ptr <context> ctx)
|
||||
: maildirFormat(ctx)
|
||||
{
|
||||
}
|
||||
@ -55,19 +55,19 @@ const string courierMaildirFormat::getName() const
|
||||
|
||||
void courierMaildirFormat::createFolder(const folder::path& path)
|
||||
{
|
||||
ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
|
||||
if (!fsf->isValidPath(folderPathToFileSystemPath(path, ROOT_DIRECTORY)))
|
||||
throw exceptions::invalid_folder_name();
|
||||
|
||||
ref <utility::file> rootDir = fsf->create
|
||||
shared_ptr <utility::file> rootDir = fsf->create
|
||||
(folderPathToFileSystemPath(path, ROOT_DIRECTORY));
|
||||
|
||||
ref <utility::file> newDir = fsf->create
|
||||
shared_ptr <utility::file> newDir = fsf->create
|
||||
(folderPathToFileSystemPath(path, NEW_DIRECTORY));
|
||||
ref <utility::file> tmpDir = fsf->create
|
||||
shared_ptr <utility::file> tmpDir = fsf->create
|
||||
(folderPathToFileSystemPath(path, TMP_DIRECTORY));
|
||||
ref <utility::file> curDir = fsf->create
|
||||
shared_ptr <utility::file> curDir = fsf->create
|
||||
(folderPathToFileSystemPath(path, CUR_DIRECTORY));
|
||||
|
||||
rootDir->createDirectory(true);
|
||||
@ -76,7 +76,7 @@ void courierMaildirFormat::createFolder(const folder::path& path)
|
||||
tmpDir->createDirectory(false);
|
||||
curDir->createDirectory(false);
|
||||
|
||||
ref <utility::file> maildirFile = fsf->create
|
||||
shared_ptr <utility::file> maildirFile = fsf->create
|
||||
(folderPathToFileSystemPath(path, ROOT_DIRECTORY)
|
||||
/ utility::file::path::component("maildirfolder"));
|
||||
|
||||
@ -86,7 +86,7 @@ void courierMaildirFormat::createFolder(const folder::path& path)
|
||||
|
||||
void courierMaildirFormat::destroyFolder(const folder::path& path)
|
||||
{
|
||||
ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
|
||||
// Recursively delete directories of subfolders
|
||||
const std::vector <folder::path> folders = listFolders(path, true);
|
||||
@ -125,7 +125,7 @@ void courierMaildirFormat::renameFolder
|
||||
void courierMaildirFormat::renameFolderImpl
|
||||
(const folder::path& oldPath, const folder::path& newPath)
|
||||
{
|
||||
ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
|
||||
const utility::file::path oldFSPath =
|
||||
folderPathToFileSystemPath(oldPath, ROOT_DIRECTORY);
|
||||
@ -133,26 +133,26 @@ void courierMaildirFormat::renameFolderImpl
|
||||
const utility::file::path newFSPath =
|
||||
folderPathToFileSystemPath(newPath, ROOT_DIRECTORY);
|
||||
|
||||
ref <utility::file> rootDir = fsf->create(oldFSPath);
|
||||
shared_ptr <utility::file> rootDir = fsf->create(oldFSPath);
|
||||
rootDir->rename(newFSPath);
|
||||
}
|
||||
|
||||
|
||||
bool courierMaildirFormat::folderExists(const folder::path& path) const
|
||||
{
|
||||
ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
|
||||
ref <utility::file> rootDir = fsf->create
|
||||
shared_ptr <utility::file> rootDir = fsf->create
|
||||
(folderPathToFileSystemPath(path, ROOT_DIRECTORY));
|
||||
|
||||
ref <utility::file> newDir = fsf->create
|
||||
shared_ptr <utility::file> newDir = fsf->create
|
||||
(folderPathToFileSystemPath(path, NEW_DIRECTORY));
|
||||
ref <utility::file> tmpDir = fsf->create
|
||||
shared_ptr <utility::file> tmpDir = fsf->create
|
||||
(folderPathToFileSystemPath(path, TMP_DIRECTORY));
|
||||
ref <utility::file> curDir = fsf->create
|
||||
shared_ptr <utility::file> curDir = fsf->create
|
||||
(folderPathToFileSystemPath(path, CUR_DIRECTORY));
|
||||
|
||||
ref <utility::file> maildirFile = fsf->create
|
||||
shared_ptr <utility::file> maildirFile = fsf->create
|
||||
(folderPathToFileSystemPath(path, ROOT_DIRECTORY)
|
||||
/ utility::file::path::component("maildirfolder"));
|
||||
|
||||
@ -260,9 +260,9 @@ const std::vector <folder::path> courierMaildirFormat::listFolders
|
||||
bool courierMaildirFormat::listDirectories(const folder::path& root,
|
||||
std::vector <string>& dirs, const bool onlyTestForExistence) const
|
||||
{
|
||||
ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
|
||||
ref <utility::file> rootDir = fsf->create
|
||||
shared_ptr <utility::file> rootDir = fsf->create
|
||||
(getContext()->getStore()->getFileSystemPath());
|
||||
|
||||
if (rootDir->exists())
|
||||
@ -278,11 +278,11 @@ bool courierMaildirFormat::listDirectories(const folder::path& root,
|
||||
}
|
||||
|
||||
// Enumerate directories
|
||||
ref <utility::fileIterator> it = rootDir->getFiles();
|
||||
shared_ptr <utility::fileIterator> it = rootDir->getFiles();
|
||||
|
||||
while (it->hasMoreElements())
|
||||
{
|
||||
ref <utility::file> file = it->nextElement();
|
||||
shared_ptr <utility::file> file = it->nextElement();
|
||||
|
||||
if (isSubfolderDirectory(*file))
|
||||
{
|
||||
@ -502,24 +502,24 @@ const folder::path::component courierMaildirFormat::fromModifiedUTF7(const strin
|
||||
|
||||
bool courierMaildirFormat::supports() const
|
||||
{
|
||||
ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
|
||||
ref <utility::file> rootDir = fsf->create
|
||||
shared_ptr <utility::file> rootDir = fsf->create
|
||||
(getContext()->getStore()->getFileSystemPath());
|
||||
|
||||
if (rootDir->exists())
|
||||
{
|
||||
// Try to find a file named "maildirfolder", which indicates
|
||||
// the Maildir is in Courier format
|
||||
ref <utility::fileIterator> it = rootDir->getFiles();
|
||||
shared_ptr <utility::fileIterator> it = rootDir->getFiles();
|
||||
|
||||
while (it->hasMoreElements())
|
||||
{
|
||||
ref <utility::file> file = it->nextElement();
|
||||
shared_ptr <utility::file> file = it->nextElement();
|
||||
|
||||
if (isSubfolderDirectory(*file))
|
||||
{
|
||||
ref <utility::file> folderFile = fsf->create
|
||||
shared_ptr <utility::file> folderFile = fsf->create
|
||||
(file->getFullPath() / utility::file::path::component("maildirfolder"));
|
||||
|
||||
if (folderFile->exists() && folderFile->isFile())
|
||||
|
@ -41,7 +41,7 @@ namespace maildir {
|
||||
namespace format {
|
||||
|
||||
|
||||
kmailMaildirFormat::kmailMaildirFormat(ref <context> ctx)
|
||||
kmailMaildirFormat::kmailMaildirFormat(shared_ptr <context> ctx)
|
||||
: maildirFormat(ctx)
|
||||
{
|
||||
}
|
||||
@ -55,19 +55,19 @@ const string kmailMaildirFormat::getName() const
|
||||
|
||||
void kmailMaildirFormat::createFolder(const folder::path& path)
|
||||
{
|
||||
ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
|
||||
if (!fsf->isValidPath(folderPathToFileSystemPath(path, ROOT_DIRECTORY)))
|
||||
throw exceptions::invalid_folder_name();
|
||||
|
||||
ref <utility::file> rootDir = fsf->create
|
||||
shared_ptr <utility::file> rootDir = fsf->create
|
||||
(folderPathToFileSystemPath(path, ROOT_DIRECTORY));
|
||||
|
||||
ref <utility::file> newDir = fsf->create
|
||||
shared_ptr <utility::file> newDir = fsf->create
|
||||
(folderPathToFileSystemPath(path, NEW_DIRECTORY));
|
||||
ref <utility::file> tmpDir = fsf->create
|
||||
shared_ptr <utility::file> tmpDir = fsf->create
|
||||
(folderPathToFileSystemPath(path, TMP_DIRECTORY));
|
||||
ref <utility::file> curDir = fsf->create
|
||||
shared_ptr <utility::file> curDir = fsf->create
|
||||
(folderPathToFileSystemPath(path, CUR_DIRECTORY));
|
||||
|
||||
rootDir->createDirectory(true);
|
||||
@ -81,7 +81,7 @@ void kmailMaildirFormat::createFolder(const folder::path& path)
|
||||
void kmailMaildirFormat::destroyFolder(const folder::path& path)
|
||||
{
|
||||
// Delete 'folder' and '.folder.directory' directories
|
||||
ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
|
||||
maildirUtils::recursiveFSDelete(fsf->create
|
||||
(folderPathToFileSystemPath(path, ROOT_DIRECTORY))); // root
|
||||
@ -93,16 +93,16 @@ void kmailMaildirFormat::destroyFolder(const folder::path& path)
|
||||
|
||||
bool kmailMaildirFormat::folderExists(const folder::path& path) const
|
||||
{
|
||||
ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
|
||||
ref <utility::file> rootDir = fsf->create
|
||||
shared_ptr <utility::file> rootDir = fsf->create
|
||||
(folderPathToFileSystemPath(path, ROOT_DIRECTORY));
|
||||
|
||||
ref <utility::file> newDir = fsf->create
|
||||
shared_ptr <utility::file> newDir = fsf->create
|
||||
(folderPathToFileSystemPath(path, NEW_DIRECTORY));
|
||||
ref <utility::file> tmpDir = fsf->create
|
||||
shared_ptr <utility::file> tmpDir = fsf->create
|
||||
(folderPathToFileSystemPath(path, TMP_DIRECTORY));
|
||||
ref <utility::file> curDir = fsf->create
|
||||
shared_ptr <utility::file> curDir = fsf->create
|
||||
(folderPathToFileSystemPath(path, CUR_DIRECTORY));
|
||||
|
||||
return rootDir->exists() && rootDir->isDirectory() &&
|
||||
@ -183,18 +183,18 @@ const std::vector <folder::path> kmailMaildirFormat::listFolders
|
||||
void kmailMaildirFormat::listFoldersImpl
|
||||
(std::vector <folder::path>& list, const folder::path& root, const bool recursive) const
|
||||
{
|
||||
ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
|
||||
ref <utility::file> rootDir = fsf->create(folderPathToFileSystemPath(root,
|
||||
shared_ptr <utility::file> rootDir = fsf->create(folderPathToFileSystemPath(root,
|
||||
root.isEmpty() ? ROOT_DIRECTORY : CONTAINER_DIRECTORY));
|
||||
|
||||
if (rootDir->exists())
|
||||
{
|
||||
ref <utility::fileIterator> it = rootDir->getFiles();
|
||||
shared_ptr <utility::fileIterator> it = rootDir->getFiles();
|
||||
|
||||
while (it->hasMoreElements())
|
||||
{
|
||||
ref <utility::file> file = it->nextElement();
|
||||
shared_ptr <utility::file> file = it->nextElement();
|
||||
|
||||
if (isSubfolderDirectory(*file))
|
||||
{
|
||||
@ -232,11 +232,11 @@ bool kmailMaildirFormat::isSubfolderDirectory(const utility::file& file)
|
||||
|
||||
void kmailMaildirFormat::renameFolder(const folder::path& oldPath, const folder::path& newPath)
|
||||
{
|
||||
ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
|
||||
ref <utility::file> rootDir = fsf->create
|
||||
shared_ptr <utility::file> rootDir = fsf->create
|
||||
(folderPathToFileSystemPath(oldPath, ROOT_DIRECTORY));
|
||||
ref <utility::file> contDir = fsf->create
|
||||
shared_ptr <utility::file> contDir = fsf->create
|
||||
(folderPathToFileSystemPath(oldPath, CONTAINER_DIRECTORY));
|
||||
|
||||
try
|
||||
@ -283,16 +283,16 @@ void kmailMaildirFormat::renameFolder(const folder::path& oldPath, const folder:
|
||||
|
||||
bool kmailMaildirFormat::folderHasSubfolders(const folder::path& path) const
|
||||
{
|
||||
ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
|
||||
ref <utility::file> rootDir = fsf->create
|
||||
shared_ptr <utility::file> rootDir = fsf->create
|
||||
(folderPathToFileSystemPath(path, CONTAINER_DIRECTORY));
|
||||
|
||||
ref <utility::fileIterator> it = rootDir->getFiles();
|
||||
shared_ptr <utility::fileIterator> it = rootDir->getFiles();
|
||||
|
||||
while (it->hasMoreElements())
|
||||
{
|
||||
ref <utility::file> file = it->nextElement();
|
||||
shared_ptr <utility::file> file = it->nextElement();
|
||||
|
||||
if (isSubfolderDirectory(*file))
|
||||
return true;
|
||||
|
@ -35,8 +35,6 @@
|
||||
#include "vmime/net/maildir/maildirFormat.hpp"
|
||||
#include "vmime/net/maildir/maildirFolderStatus.hpp"
|
||||
|
||||
#include "vmime/utility/smartPtr.hpp"
|
||||
|
||||
#include "vmime/message.hpp"
|
||||
|
||||
#include "vmime/exception.hpp"
|
||||
@ -51,7 +49,7 @@ namespace net {
|
||||
namespace maildir {
|
||||
|
||||
|
||||
maildirFolder::maildirFolder(const folder::path& path, ref <maildirStore> store)
|
||||
maildirFolder::maildirFolder(const folder::path& path, shared_ptr <maildirStore> store)
|
||||
: m_store(store), m_path(path),
|
||||
m_name(path.isEmpty() ? folder::path::component("") : path.getLastComponent()),
|
||||
m_mode(-1), m_open(false), m_unreadMessageCount(0), m_messageCount(0)
|
||||
@ -62,7 +60,7 @@ maildirFolder::maildirFolder(const folder::path& path, ref <maildirStore> store)
|
||||
|
||||
maildirFolder::~maildirFolder()
|
||||
{
|
||||
ref <maildirStore> store = m_store.acquire();
|
||||
shared_ptr <maildirStore> store = m_store.lock();
|
||||
|
||||
if (store)
|
||||
{
|
||||
@ -80,7 +78,7 @@ maildirFolder::~maildirFolder()
|
||||
|
||||
void maildirFolder::onStoreDisconnected()
|
||||
{
|
||||
m_store = NULL;
|
||||
m_store.reset();
|
||||
}
|
||||
|
||||
|
||||
@ -106,7 +104,7 @@ int maildirFolder::getFlags()
|
||||
{
|
||||
int flags = 0;
|
||||
|
||||
if (m_store.acquire()->getFormat()->folderHasSubfolders(m_path))
|
||||
if (m_store.lock()->getFormat()->folderHasSubfolders(m_path))
|
||||
flags |= FLAG_CHILDREN; // Contains at least one sub-folder
|
||||
|
||||
return (flags);
|
||||
@ -127,7 +125,7 @@ const folder::path maildirFolder::getFullPath() const
|
||||
|
||||
void maildirFolder::open(const int mode, bool /* failIfModeIsNotAvailable */)
|
||||
{
|
||||
ref <maildirStore> store = m_store.acquire();
|
||||
shared_ptr <maildirStore> store = m_store.lock();
|
||||
|
||||
if (!store)
|
||||
throw exceptions::illegal_state("Store disconnected");
|
||||
@ -145,7 +143,7 @@ void maildirFolder::open(const int mode, bool /* failIfModeIsNotAvailable */)
|
||||
|
||||
void maildirFolder::close(const bool expunge)
|
||||
{
|
||||
ref <maildirStore> store = m_store.acquire();
|
||||
shared_ptr <maildirStore> store = m_store.lock();
|
||||
|
||||
if (!store)
|
||||
throw exceptions::illegal_state("Store disconnected");
|
||||
@ -193,7 +191,7 @@ void maildirFolder::unregisterMessage(maildirMessage* msg)
|
||||
|
||||
void maildirFolder::create(const int /* type */)
|
||||
{
|
||||
ref <maildirStore> store = m_store.acquire();
|
||||
shared_ptr <maildirStore> store = m_store.lock();
|
||||
|
||||
if (!store)
|
||||
throw exceptions::illegal_state("Store disconnected");
|
||||
@ -215,9 +213,9 @@ void maildirFolder::create(const int /* type */)
|
||||
}
|
||||
|
||||
// Notify folder created
|
||||
ref <events::folderEvent> event =
|
||||
vmime::create <events::folderEvent>
|
||||
(thisRef().dynamicCast <folder>(),
|
||||
shared_ptr <events::folderEvent> event =
|
||||
make_shared <events::folderEvent>
|
||||
(dynamicCast <folder>(shared_from_this()),
|
||||
events::folderEvent::TYPE_CREATED, m_path, m_path);
|
||||
|
||||
notifyFolder(event);
|
||||
@ -226,7 +224,7 @@ void maildirFolder::create(const int /* type */)
|
||||
|
||||
void maildirFolder::destroy()
|
||||
{
|
||||
ref <maildirStore> store = m_store.acquire();
|
||||
shared_ptr <maildirStore> store = m_store.lock();
|
||||
|
||||
if (!store)
|
||||
throw exceptions::illegal_state("Store disconnected");
|
||||
@ -244,9 +242,9 @@ void maildirFolder::destroy()
|
||||
}
|
||||
|
||||
// Notify folder deleted
|
||||
ref <events::folderEvent> event =
|
||||
vmime::create <events::folderEvent>
|
||||
(thisRef().dynamicCast <folder>(),
|
||||
shared_ptr <events::folderEvent> event =
|
||||
make_shared <events::folderEvent>
|
||||
(dynamicCast <folder>(shared_from_this()),
|
||||
events::folderEvent::TYPE_DELETED, m_path, m_path);
|
||||
|
||||
notifyFolder(event);
|
||||
@ -255,7 +253,7 @@ void maildirFolder::destroy()
|
||||
|
||||
bool maildirFolder::exists()
|
||||
{
|
||||
ref <maildirStore> store = m_store.acquire();
|
||||
shared_ptr <maildirStore> store = m_store.lock();
|
||||
|
||||
return store->getFormat()->folderExists(m_path);
|
||||
}
|
||||
@ -269,42 +267,42 @@ bool maildirFolder::isOpen() const
|
||||
|
||||
void maildirFolder::scanFolder()
|
||||
{
|
||||
ref <maildirStore> store = m_store.acquire();
|
||||
shared_ptr <maildirStore> store = m_store.lock();
|
||||
|
||||
try
|
||||
{
|
||||
m_messageCount = 0;
|
||||
m_unreadMessageCount = 0;
|
||||
|
||||
ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
|
||||
utility::file::path newDirPath = store->getFormat()->folderPathToFileSystemPath
|
||||
(m_path, maildirFormat::NEW_DIRECTORY);
|
||||
ref <utility::file> newDir = fsf->create(newDirPath);
|
||||
shared_ptr <utility::file> newDir = fsf->create(newDirPath);
|
||||
|
||||
utility::file::path curDirPath = store->getFormat()->folderPathToFileSystemPath
|
||||
(m_path, maildirFormat::CUR_DIRECTORY);
|
||||
ref <utility::file> curDir = fsf->create(curDirPath);
|
||||
shared_ptr <utility::file> curDir = fsf->create(curDirPath);
|
||||
|
||||
// New received messages (new/)
|
||||
ref <utility::fileIterator> nit = newDir->getFiles();
|
||||
shared_ptr <utility::fileIterator> nit = newDir->getFiles();
|
||||
std::vector <utility::file::path::component> newMessageFilenames;
|
||||
|
||||
while (nit->hasMoreElements())
|
||||
{
|
||||
ref <utility::file> file = nit->nextElement();
|
||||
shared_ptr <utility::file> file = nit->nextElement();
|
||||
|
||||
if (maildirUtils::isMessageFile(*file))
|
||||
newMessageFilenames.push_back(file->getFullPath().getLastComponent());
|
||||
}
|
||||
|
||||
// Current messages (cur/)
|
||||
ref <utility::fileIterator> cit = curDir->getFiles();
|
||||
shared_ptr <utility::fileIterator> cit = curDir->getFiles();
|
||||
std::vector <utility::file::path::component> curMessageFilenames;
|
||||
|
||||
while (cit->hasMoreElements())
|
||||
{
|
||||
ref <utility::file> file = cit->nextElement();
|
||||
shared_ptr <utility::file> file = cit->nextElement();
|
||||
|
||||
if (maildirUtils::isMessageFile(*file))
|
||||
curMessageFilenames.push_back(file->getFullPath().getLastComponent());
|
||||
@ -354,7 +352,7 @@ void maildirFolder::scanFolder()
|
||||
maildirUtils::buildFilename(maildirUtils::extractId(*it), 0);
|
||||
|
||||
// Move messages from 'new' to 'cur'
|
||||
ref <utility::file> file = fsf->create(newDirPath / *it);
|
||||
shared_ptr <utility::file> file = fsf->create(newDirPath / *it);
|
||||
file->rename(curDirPath / newFilename);
|
||||
|
||||
// Append to message list
|
||||
@ -406,7 +404,7 @@ void maildirFolder::scanFolder()
|
||||
}
|
||||
|
||||
|
||||
ref <message> maildirFolder::getMessage(const int num)
|
||||
shared_ptr <message> maildirFolder::getMessage(const int num)
|
||||
{
|
||||
if (!isOpen())
|
||||
throw exceptions::illegal_state("Folder not open");
|
||||
@ -414,12 +412,12 @@ ref <message> maildirFolder::getMessage(const int num)
|
||||
if (num < 1 || num > m_messageCount)
|
||||
throw exceptions::message_not_found();
|
||||
|
||||
return vmime::create <maildirMessage>
|
||||
(thisRef().dynamicCast <maildirFolder>(), num);
|
||||
return make_shared <maildirMessage>
|
||||
(dynamicCast <maildirFolder>(shared_from_this()), num);
|
||||
}
|
||||
|
||||
|
||||
std::vector <ref <message> > maildirFolder::getMessages(const messageSet& msgs)
|
||||
std::vector <shared_ptr <message> > maildirFolder::getMessages(const messageSet& msgs)
|
||||
{
|
||||
if (!isOpen())
|
||||
throw exceptions::illegal_state("Folder not open");
|
||||
@ -428,15 +426,15 @@ std::vector <ref <message> > maildirFolder::getMessages(const messageSet& msgs)
|
||||
{
|
||||
const std::vector <int> numbers = maildirUtils::messageSetToNumberList(msgs);
|
||||
|
||||
std::vector <ref <message> > messages;
|
||||
ref <maildirFolder> thisFolder = thisRef().dynamicCast <maildirFolder>();
|
||||
std::vector <shared_ptr <message> > messages;
|
||||
shared_ptr <maildirFolder> thisFolder = dynamicCast <maildirFolder>(shared_from_this());
|
||||
|
||||
for (std::vector <int>::const_iterator it = numbers.begin() ; it != numbers.end() ; ++it)
|
||||
{
|
||||
if (*it < 1|| *it > m_messageCount)
|
||||
throw exceptions::message_not_found();
|
||||
|
||||
messages.push_back(vmime::create <maildirMessage>(thisFolder, *it));
|
||||
messages.push_back(make_shared <maildirMessage>(thisFolder, *it));
|
||||
}
|
||||
|
||||
return messages;
|
||||
@ -454,25 +452,25 @@ int maildirFolder::getMessageCount()
|
||||
}
|
||||
|
||||
|
||||
ref <folder> maildirFolder::getFolder(const folder::path::component& name)
|
||||
shared_ptr <folder> maildirFolder::getFolder(const folder::path::component& name)
|
||||
{
|
||||
ref <maildirStore> store = m_store.acquire();
|
||||
shared_ptr <maildirStore> store = m_store.lock();
|
||||
|
||||
if (!store)
|
||||
throw exceptions::illegal_state("Store disconnected");
|
||||
|
||||
return vmime::create <maildirFolder>(m_path / name, store);
|
||||
return make_shared <maildirFolder>(m_path / name, store);
|
||||
}
|
||||
|
||||
|
||||
std::vector <ref <folder> > maildirFolder::getFolders(const bool recursive)
|
||||
std::vector <shared_ptr <folder> > maildirFolder::getFolders(const bool recursive)
|
||||
{
|
||||
ref <maildirStore> store = m_store.acquire();
|
||||
shared_ptr <maildirStore> store = m_store.lock();
|
||||
|
||||
if (!isOpen() && !store)
|
||||
throw exceptions::illegal_state("Store disconnected");
|
||||
|
||||
std::vector <ref <folder> > list;
|
||||
std::vector <shared_ptr <folder> > list;
|
||||
|
||||
listFolders(list, recursive);
|
||||
|
||||
@ -480,9 +478,9 @@ std::vector <ref <folder> > maildirFolder::getFolders(const bool recursive)
|
||||
}
|
||||
|
||||
|
||||
void maildirFolder::listFolders(std::vector <ref <folder> >& list, const bool recursive)
|
||||
void maildirFolder::listFolders(std::vector <shared_ptr <folder> >& list, const bool recursive)
|
||||
{
|
||||
ref <maildirStore> store = m_store.acquire();
|
||||
shared_ptr <maildirStore> store = m_store.lock();
|
||||
|
||||
try
|
||||
{
|
||||
@ -493,8 +491,8 @@ void maildirFolder::listFolders(std::vector <ref <folder> >& list, const bool re
|
||||
|
||||
for (std::vector <folder::path>::size_type i = 0, n = pathList.size() ; i < n ; ++i)
|
||||
{
|
||||
ref <maildirFolder> subFolder =
|
||||
vmime::create <maildirFolder>(pathList[i], store);
|
||||
shared_ptr <maildirFolder> subFolder =
|
||||
make_shared <maildirFolder>(pathList[i], store);
|
||||
|
||||
list.push_back(subFolder);
|
||||
}
|
||||
@ -508,7 +506,7 @@ void maildirFolder::listFolders(std::vector <ref <folder> >& list, const bool re
|
||||
|
||||
void maildirFolder::rename(const folder::path& newPath)
|
||||
{
|
||||
ref <maildirStore> store = m_store.acquire();
|
||||
shared_ptr <maildirStore> store = m_store.lock();
|
||||
|
||||
if (!store)
|
||||
throw exceptions::illegal_state("Store disconnected");
|
||||
@ -533,9 +531,9 @@ void maildirFolder::rename(const folder::path& newPath)
|
||||
m_path = newPath;
|
||||
m_name = newPath.getLastComponent();
|
||||
|
||||
ref <events::folderEvent> event =
|
||||
vmime::create <events::folderEvent>
|
||||
(thisRef().dynamicCast <folder>(),
|
||||
shared_ptr <events::folderEvent> event =
|
||||
make_shared <events::folderEvent>
|
||||
(dynamicCast <folder>(shared_from_this()),
|
||||
events::folderEvent::TYPE_RENAMED, oldPath, newPath);
|
||||
|
||||
notifyFolder(event);
|
||||
@ -549,9 +547,9 @@ void maildirFolder::rename(const folder::path& newPath)
|
||||
(*it)->m_path = newPath;
|
||||
(*it)->m_name = newPath.getLastComponent();
|
||||
|
||||
ref <events::folderEvent> event =
|
||||
vmime::create <events::folderEvent>
|
||||
((*it)->thisRef().dynamicCast <folder>(),
|
||||
shared_ptr <events::folderEvent> event =
|
||||
make_shared <events::folderEvent>
|
||||
(dynamicCast <folder>((*it)->shared_from_this()),
|
||||
events::folderEvent::TYPE_RENAMED, oldPath, newPath);
|
||||
|
||||
(*it)->notifyFolder(event);
|
||||
@ -562,9 +560,9 @@ void maildirFolder::rename(const folder::path& newPath)
|
||||
|
||||
(*it)->m_path.renameParent(oldPath, newPath);
|
||||
|
||||
ref <events::folderEvent> event =
|
||||
vmime::create <events::folderEvent>
|
||||
((*it)->thisRef().dynamicCast <folder>(),
|
||||
shared_ptr <events::folderEvent> event =
|
||||
make_shared <events::folderEvent>
|
||||
(dynamicCast <folder>((*it)->shared_from_this()),
|
||||
events::folderEvent::TYPE_RENAMED, oldPath, (*it)->m_path);
|
||||
|
||||
(*it)->notifyFolder(event);
|
||||
@ -583,7 +581,7 @@ void maildirFolder::deleteMessages(const messageSet& msgs)
|
||||
void maildirFolder::setMessageFlags
|
||||
(const messageSet& msgs, const int flags, const int mode)
|
||||
{
|
||||
ref <maildirStore> store = m_store.acquire();
|
||||
shared_ptr <maildirStore> store = m_store.lock();
|
||||
|
||||
if (!store)
|
||||
throw exceptions::illegal_state("Store disconnected");
|
||||
@ -597,7 +595,7 @@ void maildirFolder::setMessageFlags
|
||||
const std::vector <int> nums = maildirUtils::messageSetToNumberList(msgs);
|
||||
|
||||
// Change message flags
|
||||
ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
|
||||
utility::file::path curDirPath = store->getFormat()->
|
||||
folderPathToFileSystemPath(m_path, maildirFormat::CUR_DIRECTORY);
|
||||
@ -610,7 +608,7 @@ void maildirFolder::setMessageFlags
|
||||
try
|
||||
{
|
||||
const utility::file::path::component path = m_messageInfos[num].path;
|
||||
ref <utility::file> file = fsf->create(curDirPath / path);
|
||||
shared_ptr <utility::file> file = fsf->create(curDirPath / path);
|
||||
|
||||
int newFlags = maildirUtils::extractFlags(path);
|
||||
|
||||
@ -690,9 +688,9 @@ void maildirFolder::setMessageFlags
|
||||
}
|
||||
|
||||
// Notify message flags changed
|
||||
ref <events::messageChangedEvent> event =
|
||||
vmime::create <events::messageChangedEvent>
|
||||
(thisRef().dynamicCast <folder>(),
|
||||
shared_ptr <events::messageChangedEvent> event =
|
||||
make_shared <events::messageChangedEvent>
|
||||
(dynamicCast <folder>(shared_from_this()),
|
||||
events::messageChangedEvent::TYPE_FLAGS, nums);
|
||||
|
||||
notifyMessageChanged(event);
|
||||
@ -706,7 +704,7 @@ void maildirFolder::setMessageFlags
|
||||
}
|
||||
|
||||
|
||||
void maildirFolder::addMessage(ref <vmime::message> msg, const int flags,
|
||||
void maildirFolder::addMessage(shared_ptr <vmime::message> msg, const int flags,
|
||||
vmime::datetime* date, utility::progressListener* progress)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
@ -724,7 +722,7 @@ void maildirFolder::addMessage(ref <vmime::message> msg, const int flags,
|
||||
void maildirFolder::addMessage(utility::inputStream& is, const int size,
|
||||
const int flags, vmime::datetime* /* date */, utility::progressListener* progress)
|
||||
{
|
||||
ref <maildirStore> store = m_store.acquire();
|
||||
shared_ptr <maildirStore> store = m_store.lock();
|
||||
|
||||
if (!store)
|
||||
throw exceptions::illegal_state("Store disconnected");
|
||||
@ -733,7 +731,7 @@ void maildirFolder::addMessage(utility::inputStream& is, const int size,
|
||||
else if (m_mode == MODE_READ_ONLY)
|
||||
throw exceptions::illegal_state("Folder is read-only");
|
||||
|
||||
ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
|
||||
utility::file::path tmpDirPath = store->getFormat()->
|
||||
folderPathToFileSystemPath(m_path,maildirFormat::TMP_DIRECTORY);
|
||||
@ -749,7 +747,7 @@ void maildirFolder::addMessage(utility::inputStream& is, const int size,
|
||||
|
||||
try
|
||||
{
|
||||
ref <utility::file> tmpDir = fsf->create(tmpDirPath);
|
||||
shared_ptr <utility::file> tmpDir = fsf->create(tmpDirPath);
|
||||
tmpDir->createDirectory(true);
|
||||
}
|
||||
catch (exceptions::filesystem_exception&)
|
||||
@ -759,7 +757,7 @@ void maildirFolder::addMessage(utility::inputStream& is, const int size,
|
||||
|
||||
try
|
||||
{
|
||||
ref <utility::file> curDir = fsf->create(dstDirPath);
|
||||
shared_ptr <utility::file> curDir = fsf->create(dstDirPath);
|
||||
curDir->createDirectory(true);
|
||||
}
|
||||
catch (exceptions::filesystem_exception&)
|
||||
@ -785,9 +783,9 @@ void maildirFolder::addMessage(utility::inputStream& is, const int size,
|
||||
std::vector <int> nums;
|
||||
nums.push_back(m_messageCount);
|
||||
|
||||
ref <events::messageCountEvent> event =
|
||||
vmime::create <events::messageCountEvent>
|
||||
(thisRef().dynamicCast <folder>(),
|
||||
shared_ptr <events::messageCountEvent> event =
|
||||
make_shared <events::messageCountEvent>
|
||||
(dynamicCast <folder>(shared_from_this()),
|
||||
events::messageCountEvent::TYPE_ADDED, nums);
|
||||
|
||||
notifyMessageCount(event);
|
||||
@ -804,9 +802,9 @@ void maildirFolder::addMessage(utility::inputStream& is, const int size,
|
||||
(*it)->m_messageInfos.resize(m_messageInfos.size());
|
||||
std::copy(m_messageInfos.begin(), m_messageInfos.end(), (*it)->m_messageInfos.begin());
|
||||
|
||||
ref <events::messageCountEvent> event =
|
||||
vmime::create <events::messageCountEvent>
|
||||
((*it)->thisRef().dynamicCast <folder>(),
|
||||
shared_ptr <events::messageCountEvent> event =
|
||||
make_shared <events::messageCountEvent>
|
||||
(dynamicCast <folder>((*it)->shared_from_this()),
|
||||
events::messageCountEvent::TYPE_ADDED, nums);
|
||||
|
||||
(*it)->notifyMessageCount(event);
|
||||
@ -821,9 +819,9 @@ void maildirFolder::copyMessageImpl(const utility::file::path& tmpDirPath,
|
||||
utility::inputStream& is, const utility::stream::size_type size,
|
||||
utility::progressListener* progress)
|
||||
{
|
||||
ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
|
||||
ref <utility::file> file = fsf->create(tmpDirPath / filename);
|
||||
shared_ptr <utility::file> file = fsf->create(tmpDirPath / filename);
|
||||
|
||||
if (progress)
|
||||
progress->start(size);
|
||||
@ -833,8 +831,8 @@ void maildirFolder::copyMessageImpl(const utility::file::path& tmpDirPath,
|
||||
{
|
||||
file->createFile();
|
||||
|
||||
ref <utility::fileWriter> fw = file->getFileWriter();
|
||||
ref <utility::outputStream> os = fw->getOutputStream();
|
||||
shared_ptr <utility::fileWriter> fw = file->getFileWriter();
|
||||
shared_ptr <utility::outputStream> os = fw->getOutputStream();
|
||||
|
||||
utility::stream::value_type buffer[65536];
|
||||
utility::stream::size_type total = 0;
|
||||
@ -863,7 +861,7 @@ void maildirFolder::copyMessageImpl(const utility::file::path& tmpDirPath,
|
||||
// Delete temporary file
|
||||
try
|
||||
{
|
||||
ref <utility::file> file = fsf->create(tmpDirPath / filename);
|
||||
shared_ptr <utility::file> file = fsf->create(tmpDirPath / filename);
|
||||
file->remove();
|
||||
}
|
||||
catch (exceptions::filesystem_exception&)
|
||||
@ -888,7 +886,7 @@ void maildirFolder::copyMessageImpl(const utility::file::path& tmpDirPath,
|
||||
try
|
||||
{
|
||||
file->remove();
|
||||
ref <utility::file> file = fsf->create(dstDirPath / filename);
|
||||
shared_ptr <utility::file> file = fsf->create(dstDirPath / filename);
|
||||
file->remove();
|
||||
}
|
||||
catch (exceptions::filesystem_exception&)
|
||||
@ -906,14 +904,14 @@ void maildirFolder::copyMessageImpl(const utility::file::path& tmpDirPath,
|
||||
|
||||
void maildirFolder::copyMessages(const folder::path& dest, const messageSet& msgs)
|
||||
{
|
||||
ref <maildirStore> store = m_store.acquire();
|
||||
shared_ptr <maildirStore> store = m_store.lock();
|
||||
|
||||
if (!store)
|
||||
throw exceptions::illegal_state("Store disconnected");
|
||||
else if (!isOpen())
|
||||
throw exceptions::illegal_state("Folder not open");
|
||||
|
||||
ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
|
||||
utility::file::path curDirPath = store->getFormat()->folderPathToFileSystemPath
|
||||
(m_path, maildirFormat::CUR_DIRECTORY);
|
||||
@ -926,7 +924,7 @@ void maildirFolder::copyMessages(const folder::path& dest, const messageSet& msg
|
||||
// Create destination directories
|
||||
try
|
||||
{
|
||||
ref <utility::file> destTmpDir = fsf->create(destTmpDirPath);
|
||||
shared_ptr <utility::file> destTmpDir = fsf->create(destTmpDirPath);
|
||||
destTmpDir->createDirectory(true);
|
||||
}
|
||||
catch (exceptions::filesystem_exception&)
|
||||
@ -936,7 +934,7 @@ void maildirFolder::copyMessages(const folder::path& dest, const messageSet& msg
|
||||
|
||||
try
|
||||
{
|
||||
ref <utility::file> destCurDir = fsf->create(destCurDirPath);
|
||||
shared_ptr <utility::file> destCurDir = fsf->create(destCurDirPath);
|
||||
destCurDir->createDirectory(true);
|
||||
}
|
||||
catch (exceptions::filesystem_exception&)
|
||||
@ -959,9 +957,9 @@ void maildirFolder::copyMessages(const folder::path& dest, const messageSet& msg
|
||||
const utility::file::path::component filename =
|
||||
maildirUtils::buildFilename(maildirUtils::generateId(), flags);
|
||||
|
||||
ref <utility::file> file = fsf->create(curDirPath / msg.path);
|
||||
ref <utility::fileReader> fr = file->getFileReader();
|
||||
ref <utility::inputStream> is = fr->getInputStream();
|
||||
shared_ptr <utility::file> file = fsf->create(curDirPath / msg.path);
|
||||
shared_ptr <utility::fileReader> fr = file->getFileReader();
|
||||
shared_ptr <utility::inputStream> is = fr->getInputStream();
|
||||
|
||||
copyMessageImpl(destTmpDirPath, destCurDirPath,
|
||||
filename, *is, file->getLength(), NULL);
|
||||
@ -979,7 +977,7 @@ void maildirFolder::copyMessages(const folder::path& dest, const messageSet& msg
|
||||
|
||||
void maildirFolder::notifyMessagesCopied(const folder::path& dest)
|
||||
{
|
||||
ref <maildirStore> store = m_store.acquire();
|
||||
shared_ptr <maildirStore> store = m_store.lock();
|
||||
|
||||
for (std::list <maildirFolder*>::iterator it = store->m_folders.begin() ;
|
||||
it != store->m_folders.end() ; ++it)
|
||||
@ -1002,22 +1000,22 @@ void maildirFolder::status(int& count, int& unseen)
|
||||
count = 0;
|
||||
unseen = 0;
|
||||
|
||||
ref <folderStatus> status = getStatus();
|
||||
shared_ptr <folderStatus> status = getStatus();
|
||||
|
||||
count = status->getMessageCount();
|
||||
unseen = status->getUnseenCount();
|
||||
}
|
||||
|
||||
|
||||
ref <folderStatus> maildirFolder::getStatus()
|
||||
shared_ptr <folderStatus> maildirFolder::getStatus()
|
||||
{
|
||||
ref <maildirStore> store = m_store.acquire();
|
||||
shared_ptr <maildirStore> store = m_store.lock();
|
||||
|
||||
const int oldCount = m_messageCount;
|
||||
|
||||
scanFolder();
|
||||
|
||||
ref <maildirFolderStatus> status = vmime::create <maildirFolderStatus>();
|
||||
shared_ptr <maildirFolderStatus> status = make_shared <maildirFolderStatus>();
|
||||
|
||||
status->setMessageCount(m_messageCount);
|
||||
status->setUnseenCount(m_unreadMessageCount);
|
||||
@ -1031,9 +1029,9 @@ ref <folderStatus> maildirFolder::getStatus()
|
||||
for (int i = oldCount + 1, j = 0 ; i <= m_messageCount ; ++i, ++j)
|
||||
nums[j] = i;
|
||||
|
||||
ref <events::messageCountEvent> event =
|
||||
vmime::create <events::messageCountEvent>
|
||||
(thisRef().dynamicCast <folder>(),
|
||||
shared_ptr <events::messageCountEvent> event =
|
||||
make_shared <events::messageCountEvent>
|
||||
(dynamicCast <folder>(shared_from_this()),
|
||||
events::messageCountEvent::TYPE_ADDED, nums);
|
||||
|
||||
notifyMessageCount(event);
|
||||
@ -1050,9 +1048,9 @@ ref <folderStatus> maildirFolder::getStatus()
|
||||
(*it)->m_messageInfos.resize(m_messageInfos.size());
|
||||
std::copy(m_messageInfos.begin(), m_messageInfos.end(), (*it)->m_messageInfos.begin());
|
||||
|
||||
ref <events::messageCountEvent> event =
|
||||
vmime::create <events::messageCountEvent>
|
||||
((*it)->thisRef().dynamicCast <folder>(),
|
||||
shared_ptr <events::messageCountEvent> event =
|
||||
make_shared <events::messageCountEvent>
|
||||
(dynamicCast <folder>((*it)->shared_from_this()),
|
||||
events::messageCountEvent::TYPE_ADDED, nums);
|
||||
|
||||
(*it)->notifyMessageCount(event);
|
||||
@ -1066,7 +1064,7 @@ ref <folderStatus> maildirFolder::getStatus()
|
||||
|
||||
void maildirFolder::expunge()
|
||||
{
|
||||
ref <maildirStore> store = m_store.acquire();
|
||||
shared_ptr <maildirStore> store = m_store.lock();
|
||||
|
||||
if (!store)
|
||||
throw exceptions::illegal_state("Store disconnected");
|
||||
@ -1075,7 +1073,7 @@ void maildirFolder::expunge()
|
||||
else if (m_mode == MODE_READ_ONLY)
|
||||
throw exceptions::illegal_state("Folder is read-only");
|
||||
|
||||
ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
|
||||
utility::file::path curDirPath = store->getFormat()->
|
||||
folderPathToFileSystemPath(m_path, maildirFormat::CUR_DIRECTORY);
|
||||
@ -1106,7 +1104,7 @@ void maildirFolder::expunge()
|
||||
// Delete file from file system
|
||||
try
|
||||
{
|
||||
ref <utility::file> file = fsf->create(curDirPath / infos.path);
|
||||
shared_ptr <utility::file> file = fsf->create(curDirPath / infos.path);
|
||||
file->remove();
|
||||
}
|
||||
catch (exceptions::filesystem_exception& e)
|
||||
@ -1126,9 +1124,9 @@ void maildirFolder::expunge()
|
||||
m_unreadMessageCount -= unreadCount;
|
||||
|
||||
// Notify message expunged
|
||||
ref <events::messageCountEvent> event =
|
||||
vmime::create <events::messageCountEvent>
|
||||
(thisRef().dynamicCast <folder>(),
|
||||
shared_ptr <events::messageCountEvent> event =
|
||||
make_shared <events::messageCountEvent>
|
||||
(dynamicCast <folder>(shared_from_this()),
|
||||
events::messageCountEvent::TYPE_REMOVED, nums);
|
||||
|
||||
notifyMessageCount(event);
|
||||
@ -1145,9 +1143,9 @@ void maildirFolder::expunge()
|
||||
(*it)->m_messageInfos.resize(m_messageInfos.size());
|
||||
std::copy(m_messageInfos.begin(), m_messageInfos.end(), (*it)->m_messageInfos.begin());
|
||||
|
||||
ref <events::messageCountEvent> event =
|
||||
vmime::create <events::messageCountEvent>
|
||||
((*it)->thisRef().dynamicCast <folder>(),
|
||||
shared_ptr <events::messageCountEvent> event =
|
||||
make_shared <events::messageCountEvent>
|
||||
(dynamicCast <folder>((*it)->shared_from_this()),
|
||||
events::messageCountEvent::TYPE_REMOVED, nums);
|
||||
|
||||
(*it)->notifyMessageCount(event);
|
||||
@ -1156,31 +1154,31 @@ void maildirFolder::expunge()
|
||||
}
|
||||
|
||||
|
||||
ref <folder> maildirFolder::getParent()
|
||||
shared_ptr <folder> maildirFolder::getParent()
|
||||
{
|
||||
if (m_path.isEmpty())
|
||||
return NULL;
|
||||
return null;
|
||||
else
|
||||
return vmime::create <maildirFolder>(m_path.getParent(), m_store.acquire());
|
||||
return make_shared <maildirFolder>(m_path.getParent(), m_store.lock());
|
||||
}
|
||||
|
||||
|
||||
ref <const store> maildirFolder::getStore() const
|
||||
shared_ptr <const store> maildirFolder::getStore() const
|
||||
{
|
||||
return m_store.acquire();
|
||||
return m_store.lock();
|
||||
}
|
||||
|
||||
|
||||
ref <store> maildirFolder::getStore()
|
||||
shared_ptr <store> maildirFolder::getStore()
|
||||
{
|
||||
return m_store.acquire();
|
||||
return m_store.lock();
|
||||
}
|
||||
|
||||
|
||||
void maildirFolder::fetchMessages(std::vector <ref <message> >& msg,
|
||||
void maildirFolder::fetchMessages(std::vector <shared_ptr <message> >& msg,
|
||||
const fetchAttributes& options, utility::progressListener* progress)
|
||||
{
|
||||
ref <maildirStore> store = m_store.acquire();
|
||||
shared_ptr <maildirStore> store = m_store.lock();
|
||||
|
||||
if (!store)
|
||||
throw exceptions::illegal_state("Store disconnected");
|
||||
@ -1193,12 +1191,12 @@ void maildirFolder::fetchMessages(std::vector <ref <message> >& msg,
|
||||
if (progress)
|
||||
progress->start(total);
|
||||
|
||||
ref <maildirFolder> thisFolder = thisRef().dynamicCast <maildirFolder>();
|
||||
shared_ptr <maildirFolder> thisFolder = dynamicCast <maildirFolder>(shared_from_this());
|
||||
|
||||
for (std::vector <ref <message> >::iterator it = msg.begin() ;
|
||||
for (std::vector <shared_ptr <message> >::iterator it = msg.begin() ;
|
||||
it != msg.end() ; ++it)
|
||||
{
|
||||
(*it).dynamicCast <maildirMessage>()->fetch(thisFolder, options);
|
||||
dynamicCast <maildirMessage>(*it)->fetch(thisFolder, options);
|
||||
|
||||
if (progress)
|
||||
progress->progress(++current, total);
|
||||
@ -1209,17 +1207,17 @@ void maildirFolder::fetchMessages(std::vector <ref <message> >& msg,
|
||||
}
|
||||
|
||||
|
||||
void maildirFolder::fetchMessage(ref <message> msg, const fetchAttributes& options)
|
||||
void maildirFolder::fetchMessage(shared_ptr <message> msg, const fetchAttributes& options)
|
||||
{
|
||||
ref <maildirStore> store = m_store.acquire();
|
||||
shared_ptr <maildirStore> store = m_store.lock();
|
||||
|
||||
if (!store)
|
||||
throw exceptions::illegal_state("Store disconnected");
|
||||
else if (!isOpen())
|
||||
throw exceptions::illegal_state("Folder not open");
|
||||
|
||||
msg.dynamicCast <maildirMessage>()->fetch
|
||||
(thisRef().dynamicCast <maildirFolder>(), options);
|
||||
dynamicCast <maildirMessage>(msg)->fetch
|
||||
(dynamicCast <maildirFolder>(shared_from_this()), options);
|
||||
}
|
||||
|
||||
|
||||
@ -1234,7 +1232,7 @@ int maildirFolder::getFetchCapabilities() const
|
||||
|
||||
const utility::file::path maildirFolder::getMessageFSPath(const int number) const
|
||||
{
|
||||
utility::file::path curDirPath = m_store.acquire()->getFormat()->
|
||||
utility::file::path curDirPath = m_store.lock()->getFormat()->
|
||||
folderPathToFileSystemPath(m_path, maildirFormat::CUR_DIRECTORY);
|
||||
|
||||
return (curDirPath / m_messageInfos[number - 1].path);
|
||||
|
@ -74,9 +74,9 @@ void maildirFolderStatus::setUnseenCount(const unsigned int unseen)
|
||||
}
|
||||
|
||||
|
||||
ref <folderStatus> maildirFolderStatus::clone() const
|
||||
shared_ptr <folderStatus> maildirFolderStatus::clone() const
|
||||
{
|
||||
return vmime::create <maildirFolderStatus>(*this);
|
||||
return make_shared <maildirFolderStatus>(*this);
|
||||
}
|
||||
|
||||
|
||||
|
@ -50,15 +50,15 @@ const utility::file::path::component maildirFormat::NEW_DIR("new", vmime::charse
|
||||
// maildirFormat::context
|
||||
//
|
||||
|
||||
maildirFormat::context::context(ref <maildirStore> store)
|
||||
maildirFormat::context::context(shared_ptr <maildirStore> store)
|
||||
: m_store(store)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
ref <maildirStore> maildirFormat::context::getStore() const
|
||||
shared_ptr <maildirStore> maildirFormat::context::getStore() const
|
||||
{
|
||||
return m_store.acquire().constCast <maildirStore>();
|
||||
return constCast <maildirStore>(m_store.lock());
|
||||
}
|
||||
|
||||
|
||||
@ -66,37 +66,37 @@ ref <maildirStore> maildirFormat::context::getStore() const
|
||||
// maildirFormat
|
||||
//
|
||||
|
||||
maildirFormat::maildirFormat(ref <context> ctx)
|
||||
maildirFormat::maildirFormat(shared_ptr <context> ctx)
|
||||
: m_context(ctx)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
ref <maildirFormat::context> maildirFormat::getContext()
|
||||
shared_ptr <maildirFormat::context> maildirFormat::getContext()
|
||||
{
|
||||
return m_context;
|
||||
}
|
||||
|
||||
|
||||
ref <const maildirFormat::context> maildirFormat::getContext() const
|
||||
shared_ptr <const maildirFormat::context> maildirFormat::getContext() const
|
||||
{
|
||||
return m_context;
|
||||
}
|
||||
|
||||
|
||||
// static
|
||||
ref <maildirFormat> maildirFormat::detect(ref <maildirStore> store)
|
||||
shared_ptr <maildirFormat> maildirFormat::detect(shared_ptr <maildirStore> store)
|
||||
{
|
||||
ref <context> ctx = create <context>(store);
|
||||
shared_ptr <context> ctx = make_shared <context>(store);
|
||||
|
||||
// Try Courier format
|
||||
ref <maildirFormat> fmt = create <format::courierMaildirFormat>(ctx);
|
||||
shared_ptr <maildirFormat> fmt = make_shared <format::courierMaildirFormat>(ctx);
|
||||
|
||||
if (fmt->supports())
|
||||
return fmt;
|
||||
|
||||
// Default is KMail format
|
||||
return create <format::kmailMaildirFormat>(ctx);
|
||||
return make_shared <format::kmailMaildirFormat>(ctx);
|
||||
}
|
||||
|
||||
|
||||
|
@ -47,9 +47,9 @@ namespace net {
|
||||
namespace maildir {
|
||||
|
||||
|
||||
maildirMessage::maildirMessage(ref <maildirFolder> folder, const int num)
|
||||
maildirMessage::maildirMessage(shared_ptr <maildirFolder> folder, const int num)
|
||||
: m_folder(folder), m_num(num), m_size(-1), m_flags(FLAG_UNDEFINED),
|
||||
m_expunged(false), m_structure(NULL)
|
||||
m_expunged(false), m_structure(null)
|
||||
{
|
||||
folder->registerMessage(this);
|
||||
}
|
||||
@ -57,7 +57,7 @@ maildirMessage::maildirMessage(ref <maildirFolder> folder, const int num)
|
||||
|
||||
maildirMessage::~maildirMessage()
|
||||
{
|
||||
ref <maildirFolder> folder = m_folder.acquire();
|
||||
shared_ptr <maildirFolder> folder = m_folder.lock();
|
||||
|
||||
if (folder)
|
||||
folder->unregisterMessage(this);
|
||||
@ -66,7 +66,7 @@ maildirMessage::~maildirMessage()
|
||||
|
||||
void maildirMessage::onFolderClosed()
|
||||
{
|
||||
m_folder = NULL;
|
||||
m_folder.reset();
|
||||
}
|
||||
|
||||
|
||||
@ -97,7 +97,7 @@ bool maildirMessage::isExpunged() const
|
||||
}
|
||||
|
||||
|
||||
ref <const messageStructure> maildirMessage::getStructure() const
|
||||
shared_ptr <const messageStructure> maildirMessage::getStructure() const
|
||||
{
|
||||
if (m_structure == NULL)
|
||||
throw exceptions::unfetched_object();
|
||||
@ -106,7 +106,7 @@ ref <const messageStructure> maildirMessage::getStructure() const
|
||||
}
|
||||
|
||||
|
||||
ref <messageStructure> maildirMessage::getStructure()
|
||||
shared_ptr <messageStructure> maildirMessage::getStructure()
|
||||
{
|
||||
if (m_structure == NULL)
|
||||
throw exceptions::unfetched_object();
|
||||
@ -115,7 +115,7 @@ ref <messageStructure> maildirMessage::getStructure()
|
||||
}
|
||||
|
||||
|
||||
ref <const header> maildirMessage::getHeader() const
|
||||
shared_ptr <const header> maildirMessage::getHeader() const
|
||||
{
|
||||
if (m_header == NULL)
|
||||
throw exceptions::unfetched_object();
|
||||
@ -135,7 +135,7 @@ int maildirMessage::getFlags() const
|
||||
|
||||
void maildirMessage::setFlags(const int flags, const int mode)
|
||||
{
|
||||
ref <maildirFolder> folder = m_folder.acquire();
|
||||
shared_ptr <maildirFolder> folder = m_folder.lock();
|
||||
|
||||
if (!folder)
|
||||
throw exceptions::folder_not_found();
|
||||
@ -152,11 +152,11 @@ void maildirMessage::extract(utility::outputStream& os,
|
||||
}
|
||||
|
||||
|
||||
void maildirMessage::extractPart(ref <const messagePart> p, utility::outputStream& os,
|
||||
void maildirMessage::extractPart(shared_ptr <const messagePart> p, utility::outputStream& os,
|
||||
utility::progressListener* progress, const int start,
|
||||
const int length, const bool peek) const
|
||||
{
|
||||
ref <const maildirMessagePart> mp = p.dynamicCast <const maildirMessagePart>();
|
||||
shared_ptr <const maildirMessagePart> mp = dynamicCast <const maildirMessagePart>(p);
|
||||
|
||||
extractImpl(os, progress, mp->getBodyParsedOffset(), mp->getBodyParsedLength(),
|
||||
start, length, peek);
|
||||
@ -167,15 +167,15 @@ void maildirMessage::extractImpl(utility::outputStream& os, utility::progressLis
|
||||
const int start, const int length, const int partialStart, const int partialLength,
|
||||
const bool /* peek */) const
|
||||
{
|
||||
ref <const maildirFolder> folder = m_folder.acquire();
|
||||
shared_ptr <const maildirFolder> folder = m_folder.lock();
|
||||
|
||||
ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
|
||||
const utility::file::path path = folder->getMessageFSPath(m_num);
|
||||
ref <utility::file> file = fsf->create(path);
|
||||
shared_ptr <utility::file> file = fsf->create(path);
|
||||
|
||||
ref <utility::fileReader> reader = file->getFileReader();
|
||||
ref <utility::inputStream> is = reader->getInputStream();
|
||||
shared_ptr <utility::fileReader> reader = file->getFileReader();
|
||||
shared_ptr <utility::inputStream> is = reader->getInputStream();
|
||||
|
||||
is->skip(start + partialStart);
|
||||
|
||||
@ -210,19 +210,19 @@ void maildirMessage::extractImpl(utility::outputStream& os, utility::progressLis
|
||||
}
|
||||
|
||||
|
||||
void maildirMessage::fetchPartHeader(ref <messagePart> p)
|
||||
void maildirMessage::fetchPartHeader(shared_ptr <messagePart> p)
|
||||
{
|
||||
ref <maildirFolder> folder = m_folder.acquire();
|
||||
shared_ptr <maildirFolder> folder = m_folder.lock();
|
||||
|
||||
ref <maildirMessagePart> mp = p.dynamicCast <maildirMessagePart>();
|
||||
shared_ptr <maildirMessagePart> mp = dynamicCast <maildirMessagePart>(p);
|
||||
|
||||
ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
|
||||
const utility::file::path path = folder->getMessageFSPath(m_num);
|
||||
ref <utility::file> file = fsf->create(path);
|
||||
shared_ptr <utility::file> file = fsf->create(path);
|
||||
|
||||
ref <utility::fileReader> reader = file->getFileReader();
|
||||
ref <utility::inputStream> is = reader->getInputStream();
|
||||
shared_ptr <utility::fileReader> reader = file->getFileReader();
|
||||
shared_ptr <utility::inputStream> is = reader->getInputStream();
|
||||
|
||||
is->skip(mp->getHeaderParsedOffset());
|
||||
|
||||
@ -246,17 +246,17 @@ void maildirMessage::fetchPartHeader(ref <messagePart> p)
|
||||
}
|
||||
|
||||
|
||||
void maildirMessage::fetch(ref <maildirFolder> msgFolder, const fetchAttributes& options)
|
||||
void maildirMessage::fetch(shared_ptr <maildirFolder> msgFolder, const fetchAttributes& options)
|
||||
{
|
||||
ref <maildirFolder> folder = m_folder.acquire();
|
||||
shared_ptr <maildirFolder> folder = m_folder.lock();
|
||||
|
||||
if (folder != msgFolder)
|
||||
throw exceptions::folder_not_found();
|
||||
|
||||
ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
|
||||
|
||||
const utility::file::path path = folder->getMessageFSPath(m_num);
|
||||
ref <utility::file> file = fsf->create(path);
|
||||
shared_ptr <utility::file> file = fsf->create(path);
|
||||
|
||||
if (options.has(fetchAttributes::FLAGS))
|
||||
m_flags = maildirUtils::extractFlags(path.getLastComponent());
|
||||
@ -273,8 +273,8 @@ void maildirMessage::fetch(ref <maildirFolder> msgFolder, const fetchAttributes&
|
||||
{
|
||||
string contents;
|
||||
|
||||
ref <utility::fileReader> reader = file->getFileReader();
|
||||
ref <utility::inputStream> is = reader->getInputStream();
|
||||
shared_ptr <utility::fileReader> reader = file->getFileReader();
|
||||
shared_ptr <utility::inputStream> is = reader->getInputStream();
|
||||
|
||||
// Need whole message contents for structure
|
||||
if (options.has(fetchAttributes::STRUCTURE))
|
||||
@ -323,7 +323,7 @@ void maildirMessage::fetch(ref <maildirFolder> msgFolder, const fetchAttributes&
|
||||
// Extract structure
|
||||
if (options.has(fetchAttributes::STRUCTURE))
|
||||
{
|
||||
m_structure = vmime::create <maildirMessageStructure>(null, msg);
|
||||
m_structure = make_shared <maildirMessageStructure>(shared_ptr <maildirMessagePart>(), msg);
|
||||
}
|
||||
|
||||
// Extract some header fields or whole header
|
||||
@ -338,23 +338,23 @@ void maildirMessage::fetch(ref <maildirFolder> msgFolder, const fetchAttributes&
|
||||
}
|
||||
|
||||
|
||||
ref <header> maildirMessage::getOrCreateHeader()
|
||||
shared_ptr <header> maildirMessage::getOrCreateHeader()
|
||||
{
|
||||
if (m_header != NULL)
|
||||
return (m_header);
|
||||
else
|
||||
return (m_header = vmime::create <header>());
|
||||
return (m_header = make_shared <header>());
|
||||
}
|
||||
|
||||
|
||||
ref <vmime::message> maildirMessage::getParsedMessage()
|
||||
shared_ptr <vmime::message> maildirMessage::getParsedMessage()
|
||||
{
|
||||
std::ostringstream oss;
|
||||
utility::outputStreamAdapter os(oss);
|
||||
|
||||
extract(os);
|
||||
|
||||
vmime::ref <vmime::message> msg = vmime::create <vmime::message>();
|
||||
shared_ptr <vmime::message> msg = make_shared <vmime::message>();
|
||||
msg->parse(oss.str());
|
||||
|
||||
return msg;
|
||||
|
@ -36,8 +36,8 @@ namespace net {
|
||||
namespace maildir {
|
||||
|
||||
|
||||
maildirMessagePart::maildirMessagePart(ref <maildirMessagePart> parent, const int number, const bodyPart& part)
|
||||
: m_parent(parent), m_header(NULL), m_number(number)
|
||||
maildirMessagePart::maildirMessagePart(shared_ptr <maildirMessagePart> parent, const int number, const bodyPart& part)
|
||||
: m_parent(parent), m_header(null), m_number(number)
|
||||
{
|
||||
m_headerParsedOffset = part.getHeader()->getParsedOffset();
|
||||
m_headerParsedLength = part.getHeader()->getParsedLength();
|
||||
@ -59,17 +59,17 @@ maildirMessagePart::~maildirMessagePart()
|
||||
void maildirMessagePart::initStructure(const bodyPart& part)
|
||||
{
|
||||
if (part.getBody()->getPartList().size() == 0)
|
||||
m_structure = NULL;
|
||||
m_structure = null;
|
||||
else
|
||||
{
|
||||
m_structure = vmime::create <maildirMessageStructure>
|
||||
(thisRef().dynamicCast <maildirMessagePart>(),
|
||||
m_structure = make_shared <maildirMessageStructure>
|
||||
(dynamicCast <maildirMessagePart>(shared_from_this()),
|
||||
part.getBody()->getPartList());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ref <const messageStructure> maildirMessagePart::getStructure() const
|
||||
shared_ptr <const messageStructure> maildirMessagePart::getStructure() const
|
||||
{
|
||||
if (m_structure != NULL)
|
||||
return m_structure;
|
||||
@ -78,7 +78,7 @@ ref <const messageStructure> maildirMessagePart::getStructure() const
|
||||
}
|
||||
|
||||
|
||||
ref <messageStructure> maildirMessagePart::getStructure()
|
||||
shared_ptr <messageStructure> maildirMessagePart::getStructure()
|
||||
{
|
||||
if (m_structure != NULL)
|
||||
return m_structure;
|
||||
@ -105,7 +105,7 @@ int maildirMessagePart::getNumber() const
|
||||
}
|
||||
|
||||
|
||||
ref <const header> maildirMessagePart::getHeader() const
|
||||
shared_ptr <const header> maildirMessagePart::getHeader() const
|
||||
{
|
||||
if (m_header == NULL)
|
||||
throw exceptions::unfetched_object();
|
||||
@ -119,7 +119,7 @@ header& maildirMessagePart::getOrCreateHeader()
|
||||
if (m_header != NULL)
|
||||
return *m_header;
|
||||
else
|
||||
return *(m_header = vmime::create <header>());
|
||||
return *(m_header = make_shared <header>());
|
||||
}
|
||||
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user