bincimap

Log | Files | Refs | LICENSE

operator-noop-pending.cc (2621B)


      1 /* -*- Mode: c++; -*- */
      2 /*  --------------------------------------------------------------------
      3  *  Filename:
      4  *    operator-noop-pending.cc
      5  *  
      6  *  Description:
      7  *    Operator for the NOOP command, with pending extension
      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 <string>
     39 #include <iostream>
     40 
     41 #include "mailbox.h"
     42 #include "pendingupdates.h"
     43 #include "io.h"
     44 
     45 #include "recursivedescent.h"
     46 #include "session.h"
     47 #include "depot.h"
     48 #include "operators.h"
     49 
     50 using namespace ::std;
     51 using namespace Binc;
     52 
     53 //----------------------------------------------------------------------
     54 NoopPendingOperator::NoopPendingOperator(void) : NoopOperator()
     55 {
     56 }
     57 
     58 //----------------------------------------------------------------------
     59 NoopPendingOperator::~NoopPendingOperator(void)
     60 {
     61 }
     62 
     63 //----------------------------------------------------------------------
     64 Operator::ProcessResult NoopPendingOperator::process(Depot &depot,
     65 						     Request &command)
     66 {
     67   Mailbox *mailbox = depot.getSelected();
     68   if (mailbox && !pendingUpdates(mailbox, 
     69 		      PendingUpdates::EXPUNGE
     70 		      | PendingUpdates::EXISTS 
     71 		      | PendingUpdates::RECENT 
     72 		      | PendingUpdates::FLAGS, true)) {
     73       Session &session = Session::getInstance();
     74       IO &com = IOFactory::getInstance().get(1);
     75       IO &logger = IOFactory::getInstance().get(2);
     76       logger << "when scanning mailbox: "
     77 	     << session.getLastError() << endl;
     78       com << "* BYE " << session.getLastError() << endl;
     79       com.flushContent();
     80       session.setState(Session::LOGOUT);
     81       return NOTHING;
     82   }
     83 
     84   return OK;
     85 }