operator-check.cc (2770B)
1 /* -*- Mode: c++; -*- */ 2 /* -------------------------------------------------------------------- 3 * Filename: 4 * operator-check.cc 5 * 6 * Description: 7 * Implementation of the CHECK command. 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 #include <string> 35 36 #include "depot.h" 37 #include "io.h" 38 #include "mailbox.h" 39 #include "operators.h" 40 #include "recursivedescent.h" 41 #include "pendingupdates.h" 42 #include "session.h" 43 44 using namespace ::std; 45 using namespace Binc; 46 47 //---------------------------------------------------------------------- 48 CheckOperator::CheckOperator(void) 49 { 50 } 51 52 53 //---------------------------------------------------------------------- 54 CheckOperator::~CheckOperator(void) 55 { 56 } 57 58 //---------------------------------------------------------------------- 59 const string CheckOperator::getName(void) const 60 { 61 return "CHECK"; 62 } 63 64 //---------------------------------------------------------------------- 65 int CheckOperator::getState(void) const 66 { 67 return Session::SELECTED; 68 } 69 70 //------------------------------------------------------------------------ 71 Operator::ProcessResult CheckOperator::process(Depot &depot, 72 Request &command) 73 { 74 Mailbox *mailbox = depot.getSelected(); 75 if (mailbox != 0) 76 pendingUpdates(mailbox, PendingUpdates::FLAGS 77 | PendingUpdates::EXISTS 78 | PendingUpdates::RECENT, true); 79 80 return OK; 81 } 82 83 //---------------------------------------------------------------------- 84 Operator::ParseResult CheckOperator::parse(Request &c_in) const 85 { 86 Session &session = Session::getInstance(); 87 88 if (c_in.getUidMode()) 89 return REJECT; 90 91 Operator::ParseResult res; 92 if ((res = expectCRLF()) != ACCEPT) { 93 session.setLastError("Expected CRLF after CHECK"); 94 return res; 95 } 96 97 c_in.setName("CHECK"); 98 return ACCEPT; 99 } 100