libbuffy  1.0
mailfolder.h
Go to the documentation of this file.
1 #ifndef BUFFY_MAILFOLDER_H
2 #define BUFFY_MAILFOLDER_H
3 
4 /*
5  * Abstract interface to mail folders
6  *
7  * Copyright (C) 2003--2008 Enrico Zini <enrico@debian.org>
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22  */
23 
24 #include <buffy/utils/consumer.h>
25 #include <buffy/utils/smartpointer.h>
26 #include <string>
27 #include <vector>
28 
29 namespace buffy {
30 
31 class MailFolderImpl : public SmartPointerItem
32 {
33 public:
34  virtual ~MailFolderImpl() {}
35 
36  virtual const std::string& name() const throw () = 0;
37  virtual const std::string& path() const throw () = 0;
38  virtual std::string type() const throw () = 0;
39 
40  virtual int getMsgTotal() const throw () = 0;
41  virtual int getMsgUnread() const throw () = 0;
42  virtual int getMsgNew() const throw () = 0;
43  virtual int getMsgFlagged() const throw () = 0;
44 
45  virtual bool changed() = 0;
46 
47  virtual void updateStatistics() = 0;
48 };
49 
50 class MailFolder : public SmartPointer<MailFolderImpl>
51 {
52 public:
53  MailFolder() throw () : SmartPointer<MailFolderImpl>() {}
54  MailFolder(const MailFolder& mf) throw () : SmartPointer<MailFolderImpl>(mf) {}
55  MailFolder(MailFolderImpl* otherimpl) throw () : SmartPointer<MailFolderImpl>(otherimpl) {}
56 
60  bool valid() const throw () { return impl; }
61 
65  const std::string& name() const throw () { return impl->name(); }
66 
70  const std::string& path() const throw () { return impl->path(); }
71 
77  std::string type() const throw () { return impl->type(); }
78 
82  int getMsgTotal() const throw () { return impl->getMsgTotal(); }
83 
87  int getMsgUnread() const throw () { return impl->getMsgUnread(); }
88 
92  int getMsgNew() const throw () { return impl->getMsgNew(); }
93 
97  int getMsgFlagged() const throw () { return impl->getMsgFlagged(); }
98 
106  bool changed() { return impl->changed(); }
107 
112  {
113  impl->updateStatistics();
114  }
115 
122  static MailFolder accessFolder(const std::string& path);
123 
127  static void enumerateFolders(const std::string& path, Consumer<MailFolder>& cons);
128 
132  static std::vector<MailFolder> enumerateFolders(const std::string& path);
133 };
134 
135 typedef Consumer<MailFolder> MailFolderConsumer;
136 typedef Filter<MailFolder> MailFolderFilter;
137 
138 }
139 
140 // vim:set ts=4 sw=4:
141 #endif
virtual int getMsgUnread() const =0
virtual int getMsgFlagged() const =0
virtual ~MailFolderImpl()
Definition: mailfolder.h:34
const std::string & path() const
Return the path to this mail folder.
Definition: mailfolder.h:70
MailFolder(const MailFolder &mf)
Definition: mailfolder.h:54
virtual bool changed()=0
virtual int getMsgTotal() const =0
bool valid() const
Return true if this MailFolder is not a null mail folder.
Definition: mailfolder.h:60
virtual void updateStatistics()=0
Definition: mailfolder.h:50
bool changed()
Return true if the folder has been changed since the last updateStatistics.
Definition: mailfolder.h:106
std::string type() const
Return the name of the type of this mail folder.
Definition: mailfolder.h:77
void updateStatistics()
Rescan the folder to update its statistics.
Definition: mailfolder.h:111
const std::string & name() const
Return the presentation name of this mail folder.
Definition: mailfolder.h:65
virtual const std::string & name() const =0
int getMsgUnread() const
Get the number of unread messages.
Definition: mailfolder.h:87
Consumer< MailFolder > MailFolderConsumer
Definition: mailfolder.h:135
MailFolder(MailFolderImpl *otherimpl)
Definition: mailfolder.h:55
virtual int getMsgNew() const =0
MailFolder()
Definition: mailfolder.h:53
Filter< MailFolder > MailFolderFilter
Definition: mailfolder.h:136
virtual std::string type() const =0
int getMsgTotal() const
Get the total number of messages.
Definition: mailfolder.h:82
Definition: mailfolder.h:31
int getMsgFlagged() const
Get the number of messages flagged 'important'.
Definition: mailfolder.h:97
int getMsgNew() const
Get the number of new messages.
Definition: mailfolder.h:92
virtual const std::string & path() const =0