Fix OpenChange server code and access to Samba4 databases.
[OpenChange-git-clone.git] / libmapi++ / message.h
blob101063223ffb0c0f6d0dd23358da4d0665108d76
1 /*
2 libmapi C++ Wrapper
3 Message Class
5 Copyright (C) Alan Alvarez 2008.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #ifndef LIBMAPIPP__MESSAGE_H__
23 #define LIBMAPIPP__MESSAGE_H__
25 #include <iostream> //for debugging
26 #include <vector>
28 #include <libmapi++/mapi_exception.h>
29 #include <libmapi++/session.h>
30 #include <libmapi++/clibmapi.h>
32 namespace libmapipp
34 class object;
35 class attachment;
37 /**
38 * \brief This class represents a %message in Exchange.
40 * It is important to note that a %message is not necessarily an email %message.
41 * It could be a contact, journal or anything else that is not a folder.
43 class message : public object {
44 public:
45 typedef boost::shared_ptr<attachment> attachment_shared_ptr;
46 typedef std::vector<attachment_shared_ptr> attachment_container_type;
48 /**
49 * \brief Constructor
51 * \param mapi_session The session to use to retrieve this %message.
52 * \param folder_id The id of the folder this %message belongs to.
53 * \param message_id The %message id.
55 message(session& mapi_session, const mapi_id_t folder_id, const mapi_id_t message_id) throw(mapi_exception)
56 : object(mapi_session, "message"), m_folder_id(folder_id), m_id(message_id)
58 if (OpenMessage(&mapi_session.get_message_store().data(), folder_id, message_id, &m_object, 0) != MAPI_E_SUCCESS)
59 throw mapi_exception(GetLastError(), "message::message : OpenMessage");
62 /**
63 * \brief Fetches all attachments in this %message.
65 * \return A container of attachment shared pointers.
67 attachment_container_type fetch_attachments();
69 /**
70 * \brief Get this %message's ID.
72 mapi_id_t get_id() const { return m_id; }
74 /**
75 * \brief Get this message's parent folder ID.
77 mapi_id_t get_folder_id() const { return m_folder_id; }
79 /**
80 * Destructor
82 virtual ~message() throw()
86 private:
87 mapi_id_t m_folder_id;
88 mapi_id_t m_id;
92 } // namespace libmapipp
94 #include <libmapi++/impl/message.ipp>
96 #endif //!LIBMAPIPP__MESSAGE_H__