-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaildrop.h
86 lines (70 loc) · 2.15 KB
/
maildrop.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
/*
* File: maildrop.h
* Author: Wouter Van Rossem
*
*/
#ifndef _MAILDROP_H
#define _MAILDROP_H
#include <dvthread/thread.h>
#include <vector>
#include <string>
#include <fstream>
#include <sys/types.h>
#include <dirent.h>
#include "message.h"
/** The Maildrop class represents a maildrop of a user.
* All the messages are stored in a vector.
* The path to the folder of the maildrop is stored
*/
class Maildrop
{
public:
/** Constructor for Maildrop
* @param folderpath String indicating where the folder is located
* @exception std::runtime_error If the folder cannot be opened
*/
Maildrop (std::string folderpath);
/** Destructor for Maildrop
* This will delete all the messages marked as deleted
*/
virtual ~Maildrop ();
/** Add a new message to the maildrop
* @param message The message to add to the maildrop
*/
void add_message (Message* message);
/** Retrieve a message from the maildrop
* @param msg_nr The number of the message
* @return The actual message if found
* @return false if the message is not found
*/
Message* retrieve_message (int msg_nr) const;
/** Delete a message from the maildrop
* This does not actually delete the message but marks it as deleted
* @param msg_nr The number of the message
* @return A bool indicating if the operation has succeeded
*/
bool delete_message (int msg_nr);
/**
* @param deleted Count messages marked as deleted?
* @return the number of messages in the maildrop
*/
int nr_of_messages (bool deleted = false) const;
/** Return the size of the maildrop
* @return The size of the maildrop in octets
*/
unsigned long size () const;
/** Get all the messages from the maildrop (including the ones marked
* as deleted or not).
* @param deleted Return messages marked as deleted
* @return A vector containing the messages
*/
std::vector<Message*> messages (bool deleted = false) const;
private:
/** Private copy constructor */
Maildrop (const Maildrop& orig);
/* Vector containning all the messages in the maildrop */
std::vector<Message*> _messages;
/* String */
std::string _folder_path;
};
#endif /* _MAILDROP_H */