1 // Copyright 2009 The Archiveopteryx Developers <info@aox.org>
2 
3 #ifndef EVENTMAP_H
4 #define EVENTMAP_H
5 
6 #include "event.h"
7 #include "list.h"
8 
9 
10 class Mailbox;
11 
12 
13 class EventFilterSpec
14     : public Garbage
15 {
16 public:
17     EventFilterSpec();
18 
19     enum Type { Selected, SelectedDelayed,
20                 Inboxes, Personal, Subscribed, Subtree, Mailboxes };
21     void setType( Type );
22     Type type() const;
23 
24     void setMailboxes( List<Mailbox> * );
25     List<Mailbox> * mailboxes() const;
26 
27     void setNewMessageFetcher( class Fetch * );
28     class Fetch * newMessageFetcher() const;
29 
30     enum Event { NewMessage, MessageChange,
31                  Expunge,
32                  FlagChange, AnnotationChange,
33                  MailboxName,
34                  // Subscription has to be last
35                  Subscription };
36     void setNotificationWanted( Event, bool );
37     bool notificationWanted( Event );
38 
39     bool appliesTo( Mailbox * );
40 
41 private:
42     class EventFilterSpecData * d;
43 };
44 
45 
46 class EventMap
47     : public EventHandler
48 {
49 public:
50     EventMap();
51 
52     EventFilterSpec * applicable( Mailbox *, Mailbox * );
53 
54     void add( EventFilterSpec * );
55 
56     void execute();
57 
58     void refresh( class Transaction *, class User * );
59 
60     List<Mailbox> * mailboxes() const;
61 
62 private:
63     class EventMapData * d;
64 };
65 
66 
67 #endif
68