bincimap

Log | Files | Refs | LICENSE

maildir-close.cc (2405B)


      1 /* -*- Mode: c++; -*- */
      2 /*  --------------------------------------------------------------------
      3  *  Filename:
      4  *    maildir-close.cc
      5  *  
      6  *  Description:
      7  *    Implementation of the Maildir class.
      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 "storage.h"
     39 #include "io.h"
     40 #include "maildir.h"
     41 
     42 #include <fcntl.h>
     43 #include <unistd.h>
     44 
     45 using namespace ::std;
     46 using namespace Binc;
     47 
     48 //------------------------------------------------------------------------
     49 void Binc::Maildir::closeMailbox(void)
     50 {
     51   if (!selected)
     52     return;
     53 
     54   if (mailboxchanged && !readOnly)
     55     writeCache();
     56 
     57   mailboxchanged = false;
     58 
     59   if (uidnextchanged) {
     60     const string uidvalfilename = path + "/bincimap-uidvalidity";
     61     Storage uidvalfile("uidvalfilename", Storage::WriteOnly);
     62     uidvalfile.put("depot", "_uidvalidity", toString(uidvalidity));
     63     uidvalfile.put("depot", "_uidnext", toString(uidnext));
     64     uidvalfile.put("depot", "_version", UIDVALFILEVERSION);
     65     uidvalfile.commit();
     66     uidnextchanged = false;
     67   }
     68 
     69   MaildirMessageCache::getInstance().clear();
     70 
     71   messages.clear();
     72   index.clear();
     73   newMessages.clear();
     74   oldrecent = 0;
     75   oldexists = 0;
     76   firstscan = true;
     77   cacheRead = false;
     78   uidvalidity = 0;
     79   uidnext = 1;
     80   selected = false;
     81   path = "";
     82 
     83   old_cur_st_mtime = 0; 
     84   old_cur_st_ctime = 0;
     85   old_new_st_mtime = 0;
     86   old_new_st_ctime = 0;
     87 }