forked from openchange/openchange
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfolder.h
118 lines (97 loc) · 2.95 KB
/
folder.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
libmapi C++ Wrapper
Folder Class
Copyright (C) Alan Alvarez 2008.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LIBMAPIPP__FOLDER_H__
#define LIBMAPIPP__FOLDER_H__
#include <iostream> //for debugging
#include <memory>
#include <vector>
#include <libmapi++/clibmapi.h>
#include <libmapi++/mapi_exception.h>
#include <libmapi++/object.h>
#include <libmapi++/message.h>
namespace libmapipp
{
/**
* This class represents a %folder or container within Exchange
*/
class folder : public object {
public:
/**
* Pointer to a message
*/
typedef std::shared_ptr<message> message_shared_ptr;
typedef std::vector<message_shared_ptr > message_container_type;
/**
* Pointer to a %folder
*/
typedef std::shared_ptr<folder> folder_shared_ptr;
/**
* Hierarchy folders
*
* This is a vector (list) of child folders for a given %folder
*/
typedef std::vector<folder_shared_ptr> hierarchy_container_type;
/**
* \brief Constructor
*
* \param parent_folder The parent of this %folder.
* \param folder_id This folder's id.
*/
folder(object& parent_folder, const mapi_id_t folder_id) throw(mapi_exception)
: object(parent_folder.get_session(), "folder"), m_id(folder_id)
{
if (OpenFolder(&parent_folder.data(), folder_id, &m_object) != MAPI_E_SUCCESS)
throw mapi_exception(GetLastError(), "folder::folder : OpenFolder");
}
/**
* \brief Obtain %folder id
*
* \return This folder's id.
*/
mapi_id_t get_id() const { return m_id; }
/**
* \brief Delete a message that belongs to this %folder
*
* \param message_id The id of the message to delete.
*/
void delete_message(mapi_id_t message_id) throw (mapi_exception)
{
if (DeleteMessage(&m_object, &message_id, 1) != MAPI_E_SUCCESS)
throw mapi_exception(GetLastError(), "folder::delete_message : DeleteMessage");
}
/**
* \brief Fetch all messages in this %folder
*
* \return A container of message shared pointers.
*/
message_container_type fetch_messages() throw(mapi_exception);
/**
* \brief Fetch all subfolders within this %folder
*
* \return A container of %folder shared pointers.
*/
hierarchy_container_type fetch_hierarchy() throw(mapi_exception);
/**
* Destructor
*/
virtual ~folder() throw()
{
}
private:
mapi_id_t m_id;
};
} // namespace libmapipp
#endif //!LIBMAPIPP__FOLDER_H__