File: mailfolder.cc

package info (click to toggle)
libbuffy 1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 3,796 kB
  • ctags: 380
  • sloc: sh: 8,946; cpp: 2,636; makefile: 75
file content (68 lines) | stat: -rw-r--r-- 2,027 bytes parent folder | download | duplicates (4)
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
/*
 * Mailbox folder access
 *
 * Copyright (C) 2004--2008  Enrico Zini <enrico@debian.org>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
 */

#include <buffy/mailfolder.h>
#include <buffy/mailfolder/mailbox.h>
#include <buffy/mailfolder/maildir.h>

using namespace std;
using namespace buffy;

//void MailFolder::enumerateFoldersSwig(const char* path, Consumer<MailFolder>& cons)
//{
//	return MailFolder::enumerateFolders(path, cons);
//}

MailFolder MailFolder::accessFolder(const std::string& path)
{
	MailFolder res = mailfolder::Mailbox::accessFolder(path);
	if (!res)
		res = mailfolder::Maildir::accessFolder(path);
	return res;
}


void MailFolder::enumerateFolders(const std::string& path, Consumer<MailFolder>& cons)
{
//	fprintf(stderr, "enumerating mailboxes\n");
	mailfolder::Mailbox::enumerateFolders(path, cons);
//	fprintf(stderr, "enumerating maildirs\n");
	mailfolder::Maildir::enumerateFolders(path, cons);
//	fprintf(stderr, "enumerated\n");
}

class MailFolderCollector : public MailFolderConsumer, public vector<MailFolder>
{
public:
	virtual ~MailFolderCollector() throw () {}
	virtual void consume(MailFolder& mf)
	{
		push_back(mf);
	}
};

vector<MailFolder> MailFolder::enumerateFolders(const std::string& path)
{
	MailFolderCollector res;
	enumerateFolders(path, res);
	return res;
}

// vim:set ts=4 sw=4: