summaryrefslogtreecommitdiffstats
path: root/libmail/maildirfolder.H
blob: e7710b0e44570aa32cf9c33167d00a6c6764a5f3 (plain)
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
/*
** Copyright 2002, Double Precision Inc.
**
** See COPYING for distribution information.
*/
#ifndef libmail_maildirfolder_H
#define libmail_maildirfolder_H

#include "maildir.H"

#include <string>
#include <set>
#include <list>

LIBMAIL_START

////////////////////////////////////////////////////////////////////////////
//
// Courier-compatible maildir folder.

class maildir::folder : public mail::folder {

	maildir *maildirAccount;

	std::string path;
	std::string name;

	bool hasMessagesFlag;
	bool hasSubfoldersFlag;

	// Compile subdirectory listings

	class listinfo {
	public:
		listinfo();
		~listinfo();

		std::string path;

		std::set<std::string> list, subdirs;
	};

	static void maildir_list_callback(const char *, void *);

public:
	friend class maildir;

	folder(maildir *maildirArg,
	       std::string pathArg);
	~folder();

	void sameServerAsHelperFunc() const;

	std::string getName() const;
	std::string getPath() const;

	bool hasMessages() const;
	bool hasSubFolders() const;
	bool isParentOf(std::string path) const;

	void hasMessages(bool);
	void hasSubFolders(bool);

	void getParentFolder(callback::folderList &callback1,
			     callback &callback2) const;

	void readFolderInfo( mail::callback::folderInfo &callback1,
			     mail::callback &callback2) const;

	void readSubFolders( mail::callback::folderList &callback1,
			     mail::callback &callback2) const;

private:
	void buildFolderList(std::list<mail::folder *> &folderList,
			     std::set<std::string> *folders,
			     std::set<std::string> *dirs) const;

	bool doCreate(bool isDirectory) const;

public:
	mail::addMessage *addMessage(mail::callback &callback) const;

	void createSubFolder(std::string name, bool isDirectory,
			     mail::callback::folderList &callback1,
			     mail::callback &callback2) const;

	void create(bool isDirectory,
		    mail::callback &callback) const;

	void destroy(mail::callback &callback, bool destroyDir) const;

	void renameFolder(const mail::folder *newParent, std::string newName,
			  mail::callback::folderList &callback1,
			  mail::callback &callback) const;

	mail::folder *clone() const;
	std::string toString() const;

	void open(mail::callback &openCallback,
		  snapshot *restoreSnapshot,
		  mail::callback::folder &folderCallback) const;
};

LIBMAIL_END

#endif