/usr/include/vmime/net/folder.hpp is in libvmime-dev 0.9.1-5build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 | //
// VMime library (http://www.vmime.org)
// Copyright (C) 2002-2009 Vincent Richard <vincent@vincent-richard.net>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 3 of
// the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// Linking this library statically or dynamically with other modules is making
// a combined work based on this library. Thus, the terms and conditions of
// the GNU General Public License cover the whole combination.
//
#ifndef VMIME_NET_FOLDER_HPP_INCLUDED
#define VMIME_NET_FOLDER_HPP_INCLUDED
#include <vector>
#include "vmime/types.hpp"
#include "vmime/dateTime.hpp"
#include "vmime/message.hpp"
#include "vmime/net/message.hpp"
#include "vmime/net/events.hpp"
#include "vmime/utility/path.hpp"
#include "vmime/utility/stream.hpp"
#include "vmime/utility/progressListener.hpp"
namespace vmime {
namespace net {
class store;
/** Abstract representation of a folder in a message store.
*/
class folder : public object
{
protected:
folder(const folder&) : object() { }
folder() { }
public:
virtual ~folder() { }
/** Type used for fully qualified path name of a folder.
*/
typedef vmime::utility::path path;
/** Open mode.
*/
enum Modes
{
MODE_READ_ONLY, /**< Read-only mode (no modification to folder or messages is possible). */
MODE_READ_WRITE /**< Full access mode (read and write). */
};
/** Folder types.
*/
enum Types
{
TYPE_CONTAINS_FOLDERS = (1 << 0), /**< Folder can contain folders. */
TYPE_CONTAINS_MESSAGES = (1 << 1), /**< Folder can contain messages. */
TYPE_UNDEFINED = 9999 /**< Used internally (this should not be returned
by the type() function). */
};
/** Folder flags.
*/
enum Flags
{
FLAG_CHILDREN = (1 << 0), /**< Folder contains subfolders. */
FLAG_NO_OPEN = (1 << 1), /**< Folder cannot be open. */
FLAG_UNDEFINED = 9999 /**< Used internally (this should not be returned
by the type() function). */
};
/** Return the type of this folder.
*
* @return folder type (see folder::Types)
*/
virtual int getType() = 0;
/** Return the flags of this folder.
*
* @return folder flags (see folder::Flags)
*/
virtual int getFlags() = 0;
/** Return the mode in which the folder has been open.
*
* @return folder opening mode (see folder::Modes)
*/
virtual int getMode() const = 0;
/** Return the name of this folder.
*
* @return folder name
*/
virtual const folder::path::component getName() const = 0;
/** Return the fully qualified path name of this folder.
*
* @return absolute path of the folder
*/
virtual const folder::path getFullPath() const = 0;
/** Open this folder.
*
* @param mode open mode (see folder::Modes)
* @param failIfModeIsNotAvailable if set to false and if the requested mode
* is not available, a more restricted mode will be selected automatically.
* If set to true and if the requested mode is not available, the opening
* will fail.
* @throw net_exception if an error occurs
*/
virtual void open(const int mode, bool failIfModeIsNotAvailable = false) = 0;
/** Close this folder.
*
* @param expunge if set to true, deleted messages are expunged
* @throw net_exception if an error occurs
*/
virtual void close(const bool expunge) = 0;
/** Create this folder.
*
* @param type folder type (see folder::Types)
* @throw net_exception if an error occurs
*/
virtual void create(const int type) = 0;
/** Test whether this folder exists.
*
* @return true if the folder exists, false otherwise
*/
virtual bool exists() = 0;
/** Delete this folder.
* The folder should be closed before attempting to delete it.
*
* @throw net_exception if an error occurs
*/
virtual void destroy() = 0;
/** Test whether this folder is open.
*
* @return true if the folder is open, false otherwise
*/
virtual bool isOpen() const = 0;
/** Get a new reference to a message in this folder.
*
* @param num message sequence number
* @return a new object referencing the specified message
* @throw net_exception if an error occurs
*/
virtual ref <message> getMessage(const int num) = 0;
/** Get new references to messages in this folder.
*
* @param from sequence number of the first message to get
* @param to sequence number of the last message to get
* @return new objects referencing the specified messages
* @throw net_exception if an error occurs
*/
virtual std::vector <ref <message> > getMessages(const int from = 1, const int to = -1) = 0;
/** Get new references to messages in this folder.
*
* @param nums sequence numbers of the messages to delete
* @return new objects referencing the specified messages
* @throw net_exception if an error occurs
*/
virtual std::vector <ref <message> > getMessages(const std::vector <int>& nums) = 0;
/** Return the number of messages in this folder.
*
* @return number of messages in the folder
*/
virtual int getMessageCount() = 0;
/** Get a new reference to a sub-folder in this folder.
*
* @param name sub-folder name
* @return a new object referencing the specified folder
* @throw net_exception if an error occurs
*/
virtual ref <folder> getFolder(const folder::path::component& name) = 0;
/** Get the list of all sub-folders in this folder.
*
* @param recursive if set to true, all the descendant are returned.
* If set to false, only the direct children are returned.
* @return list of sub-folders
* @throw net_exception if an error occurs
*/
virtual std::vector <ref <folder> > getFolders(const bool recursive = false) = 0;
/** Rename (move) this folder to another location.
*
* @param newPath new path of the folder
* @throw net_exception if an error occurs
*/
virtual void rename(const folder::path& newPath) = 0;
/** Remove a message in this folder.
*
* @param num sequence number of the message to delete
* @throw net_exception if an error occurs
*/
virtual void deleteMessage(const int num) = 0;
/** Remove one or more messages from this folder.
*
* @param from sequence number of the first message to delete
* @param to sequence number of the last message to delete
* @throw net_exception if an error occurs
*/
virtual void deleteMessages(const int from = 1, const int to = -1) = 0;
/** Remove one or more messages from this folder.
*
* @param nums sequence numbers of the messages to delete
* @throw net_exception if an error occurs
*/
virtual void deleteMessages(const std::vector <int>& nums) = 0;
/** Change the flags for one or more messages in this folder.
*
* @param from sequence number of the first message to modify
* @param to sequence number of the last message to modify
* @param flags set of flags (see message::Flags)
* @param mode indicate how to treat old and new flags (see message::FlagsModes)
* @throw net_exception if an error occurs
*/
virtual void setMessageFlags(const int from, const int to, const int flags, const int mode = message::FLAG_MODE_SET) = 0;
/** Change the flags for one or more messages in this folder.
*
* @param nums sequence numbers of the messages to modify
* @param flags set of flags (see message::Flags)
* @param mode indicate how to treat old and new flags (see message::FlagsModes)
* @throw net_exception if an error occurs
*/
virtual void setMessageFlags(const std::vector <int>& nums, const int flags, const int mode = message::FLAG_MODE_SET) = 0;
/** Add a message to this folder.
*
* @param msg message to add (data: header + body)
* @param flags flags for the new message
* @param date date/time for the new message (if NULL, the current time is used)
* @param progress progress listener, or NULL if not used
* @throw net_exception if an error occurs
*/
virtual void addMessage(ref <vmime::message> msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL) = 0;
/** Add a message to this folder.
*
* @param is message to add (data: header + body)
* @param size size of the message to add (in bytes)
* @param flags flags for the new message
* @param date date/time for the new message (if NULL, the current time is used)
* @param progress progress listener, or NULL if not used
* @throw net_exception if an error occurs
*/
virtual void addMessage(utility::inputStream& is, const int size, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL) = 0;
/** Copy a message from this folder to another folder.
*
* @param dest destination folder path
* @param num sequence number of the message to copy
* @throw net_exception if an error occurs
*/
virtual void copyMessage(const folder::path& dest, const int num) = 0;
/** Copy messages from this folder to another folder.
*
* @param dest destination folder path
* @param from sequence number of the first message to copy
* @param to sequence number of the last message to copy
* @throw net_exception if an error occurs
*/
virtual void copyMessages(const folder::path& dest, const int from = 1, const int to = -1) = 0;
/** Copy messages from this folder to another folder.
*
* @param dest destination folder path
* @param nums sequence numbers of the messages to copy
* @throw net_exception if an error occurs
*/
virtual void copyMessages(const folder::path& dest, const std::vector <int>& nums) = 0;
/** Request folder status without opening it.
*
* @param count will receive the number of messages in the folder
* @param unseen will receive the number of unseen messages in the folder
* @throw net_exception if an error occurs
*/
virtual void status(int& count, int& unseen) = 0;
/** Expunge deleted messages.
*
* @throw net_exception if an error occurs
*/
virtual void expunge() = 0;
/** Return a new folder object referencing the parent folder of this folder.
*
* @return parent folder object
*/
virtual ref <folder> getParent() = 0;
/** Return a reference to the store to which this folder belongs.
*
* @return the store object to which this folder is attached
*/
virtual ref <const store> getStore() const = 0;
/** Return a reference to the store to which this folder belongs.
*
* @return the store object to which this folder is attached
*/
virtual ref <store> getStore() = 0;
/** Fetchable objects.
*/
enum FetchOptions
{
FETCH_ENVELOPE = (1 << 0), /**< Fetch sender, recipients, date, subject. */
FETCH_STRUCTURE = (1 << 1), /**< Fetch structure (body parts). */
FETCH_CONTENT_INFO = (1 << 2), /**< Fetch top-level content type. */
FETCH_FLAGS = (1 << 3), /**< Fetch message flags. */
FETCH_SIZE = (1 << 4), /**< Fetch message size (exact or estimated). */
FETCH_FULL_HEADER = (1 << 5), /**< Fetch full RFC-[2]822 header. */
FETCH_UID = (1 << 6), /**< Fetch unique identifier (protocol specific). */
FETCH_IMPORTANCE = (1 << 7), /**< Fetch header fields suitable for use with misc::importanceHelper. */
FETCH_CUSTOM = (1 << 16) /**< Reserved for future use. */
};
/** Fetch objects for the specified messages.
*
* @param msg list of message sequence numbers
* @param options objects to fetch (combination of folder::FetchOptions flags)
* @param progress progress listener, or NULL if not used
* @throw net_exception if an error occurs
*/
virtual void fetchMessages(std::vector <ref <message> >& msg, const int options, utility::progressListener* progress = NULL) = 0;
/** Fetch objects for the specified message.
*
* @param msg the message
* @param options objects to fetch (combination of folder::FetchOptions flags)
* @throw net_exception if an error occurs
*/
virtual void fetchMessage(ref <message> msg, const int options) = 0;
/** Return the list of fetchable objects supported by
* the underlying protocol (see folder::FetchOptions).
*
* @return list of supported fetchable objects
*/
virtual int getFetchCapabilities() const = 0;
// Event listeners
void addMessageChangedListener(events::messageChangedListener* l);
void removeMessageChangedListener(events::messageChangedListener* l);
void addMessageCountListener(events::messageCountListener* l);
void removeMessageCountListener(events::messageCountListener* l);
void addFolderListener(events::folderListener* l);
void removeFolderListener(events::folderListener* l);
protected:
void notifyMessageChanged(const events::messageChangedEvent& event);
void notifyMessageCount(const events::messageCountEvent& event);
void notifyFolder(const events::folderEvent& event);
private:
std::list <events::messageChangedListener*> m_messageChangedListeners;
std::list <events::messageCountListener*> m_messageCountListeners;
std::list <events::folderListener*> m_folderListeners;
};
} // net
} // vmime
#endif // VMIME_NET_FOLDER_HPP_INCLUDED
|