summaryrefslogtreecommitdiff
path: root/src/include/pendingupdates.h
blob: fcfd548e62a33e8e9260dbab0ab2b326c40acf1f (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
/**
 *  @file pendingupdates.h
 *  @brief  <--->
 *  @author Andreas Aardal Hanssen
 *  @date 2002-2005
 */

#ifndef pendingupdates_h_included
#define pendingupdates_h_included

#include <map>
#include <string>
#include <vector>

namespace Binc {
  class Mailbox;

  class PendingUpdates {
  public:
    enum { EXPUNGE = 0x01, FLAGS = 0x02, EXISTS = 0x04, RECENT = 0x08 };

    class expunged_const_iterator {
    private:
      std::vector<unsigned int>::iterator internal;

    public:
      unsigned int operator*() const;
      void operator++();
      bool operator!=(expunged_const_iterator) const;
      bool operator==(expunged_const_iterator) const;

      expunged_const_iterator();
      expunged_const_iterator(std::vector<unsigned int>::iterator i);
    };

    expunged_const_iterator beginExpunged();
    expunged_const_iterator endExpunged();

    class flagupdates_const_iterator {
    private:
      std::map<unsigned int, unsigned int>::iterator internal;
      std::map<unsigned int, unsigned int> *sqnrtouid;
      std::map<unsigned int, std::vector<std::string>> *sqnrtocflags;

    public:
      unsigned int first() const;
      unsigned int second() const;
      std::vector<std::string> getCustomFlags() const;
      unsigned int getUID() const;

      void operator++();
      bool operator!=(flagupdates_const_iterator) const;

      flagupdates_const_iterator();
      flagupdates_const_iterator(std::map<unsigned int, unsigned int>::iterator i,
                                 std::map<unsigned int, std::vector<std::string>> *,
                                 std::map<unsigned int, unsigned int> *);
    };

    flagupdates_const_iterator beginFlagUpdates();
    flagupdates_const_iterator endFlagUpdates();

    void addExpunged(unsigned int uid);
    void addFlagUpdates(unsigned int sqnr,
                        unsigned int uid,
                        unsigned int flags,
                        const std::vector<std::string> &cflags);
    void setExists(unsigned int n);
    void setRecent(unsigned int n);
    unsigned int getExists() const;
    unsigned int getRecent() const;
    bool newExists() const;
    bool newRecent() const;

    PendingUpdates();
    ~PendingUpdates();

  private:
    std::vector<unsigned int> expunges;
    std::map<unsigned int, unsigned int> flagupdates;
    std::map<unsigned int, unsigned int> sqnrtouid;
    std::map<unsigned int, std::vector<std::string>> sqnrtocflags;

    unsigned int exists;
    unsigned int recent;
    bool newexists;
    bool newrecent;
  };

  bool pendingUpdates(Mailbox *,
                      int type,
                      bool rescan,
                      bool showAll = false,
                      bool forceScan = false,
                      bool uidfetchflags = false);
}

#endif