bincimap

Log | Files | Refs | LICENSE

pendingupdates.h (3810B)


      1 /* -*- Mode: c++; -*- */
      2 /*  --------------------------------------------------------------------
      3  *  Filename:
      4  *    src/pendingupdates.h
      5  *  
      6  *  Description:
      7  *    <--->
      8  *
      9  *  Authors:
     10  *    Andreas Aardal Hanssen <andreas-binc curly bincimap spot org>
     11  *
     12  *  Bugs:
     13  *
     14  *  ChangeLog:
     15  *
     16  *  --------------------------------------------------------------------
     17  *  Copyright 2002-2005 Andreas Aardal Hanssen
     18  *
     19  *  This program is free software; you can redistribute it and/or modify
     20  *  it under the terms of the GNU General Public License as published by
     21  *  the Free Software Foundation; either version 2 of the License, or
     22  *  (at your option) any later version.
     23  *
     24  *  This program is distributed in the hope that it will be useful,
     25  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     26  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     27  *  GNU General Public License for more details.
     28  *
     29  *  You should have received a copy of the GNU General Public License
     30  *  along with this program; if not, write to the Free Software
     31  *  Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
     32  *  --------------------------------------------------------------------
     33  */
     34 #ifdef HAVE_CONFIG_H
     35 #include <config.h>
     36 #endif
     37 
     38 #include <map>
     39 #include <vector>
     40 
     41 #ifndef pendingupdates_h_included
     42 #define pendingupdates_h_included
     43 
     44 namespace Binc {
     45   class Mailbox;
     46 
     47   //------------------------------------------------------------------------
     48   class PendingUpdates {
     49   public:
     50     enum {
     51       EXPUNGE = 0x01,
     52       FLAGS   = 0x02,
     53       EXISTS  = 0x04,
     54       RECENT  = 0x08
     55     };
     56 
     57     //----------------------------------------------------------------------
     58     class expunged_const_iterator {
     59     private:
     60       std::vector<unsigned int>::iterator internal;
     61 
     62     public:
     63       unsigned int operator * (void) const;
     64       void operator ++ (void);
     65       bool operator != (expunged_const_iterator) const;
     66       bool operator == (expunged_const_iterator) const;
     67 
     68       //--
     69       expunged_const_iterator(void);
     70       expunged_const_iterator(std::vector<unsigned int>::iterator i);
     71     };
     72 
     73     //--
     74     expunged_const_iterator beginExpunged(void);
     75     expunged_const_iterator endExpunged(void);
     76 
     77     //----------------------------------------------------------------------
     78     class flagupdates_const_iterator {
     79     private:
     80       std::map<unsigned int, unsigned int>::iterator internal;
     81       std::map<unsigned int, unsigned int> *sqnrtouid;
     82 
     83     public:
     84       unsigned int first(void) const;
     85       unsigned int second(void) const;
     86       unsigned int getUID(void) const;
     87 
     88       void operator ++ (void);
     89       bool operator != (flagupdates_const_iterator) const;
     90 
     91       //--
     92       flagupdates_const_iterator(void);
     93       flagupdates_const_iterator(std::map<unsigned int, unsigned int>::iterator i,
     94 				 std::map<unsigned int, unsigned int> *);
     95     };
     96 
     97     //--
     98     flagupdates_const_iterator beginFlagUpdates(void);
     99     flagupdates_const_iterator endFlagUpdates(void);
    100 
    101     //--
    102     void addExpunged(unsigned int uid);
    103     void addFlagUpdates(unsigned int sqnr, unsigned int uid, 
    104 			unsigned int flags);
    105     void setExists(unsigned int n);
    106     void setRecent(unsigned int n);
    107     unsigned int getExists(void) const;
    108     unsigned int getRecent(void) const;
    109     bool newExists(void) const;
    110     bool newRecent(void) const;
    111 
    112     //--
    113     PendingUpdates(void);
    114     ~PendingUpdates(void);
    115 
    116   private:
    117     std::vector<unsigned int> expunges;
    118     std::map<unsigned int, unsigned int> flagupdates;
    119     std::map<unsigned int, unsigned int> sqnrtouid;
    120 
    121     unsigned int exists;
    122     unsigned int recent;
    123     bool newexists;
    124     bool newrecent;
    125   };
    126 
    127   bool pendingUpdates(Mailbox *, int type, bool rescan, bool showAll = false, bool forceScan = false, bool uidfetchflags = false);
    128 }
    129 
    130 #endif