summaryrefslogtreecommitdiff
path: root/src/maildir-select.cc
blob: 78daf9def4714226997a120c499664af943dfe6d (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
/**  --------------------------------------------------------------------
 *  @file maildir-select.cc
 *  @brief Implementation of the Maildir class.
 *  @author Andreas Aardal Hanssen
 *  @date Andreas Aardal Hanssen
 *  -----------------------------------------------------------------  **/
#include "maildir.h"

#include <fcntl.h>
#include <unistd.h>

using namespace ::std;
using namespace Binc;

//------------------------------------------------------------------------
bool Binc::Maildir::selectMailbox(const std::string &name,
                                  const std::string &s_in)
{
  setName(name);

  if (selected) {
    closeMailbox();
    selected = false;
  }

  oldrecent = 0;
  oldexists = 0;

  mailboxchanged = false;

  setPath(s_in);

  switch (scan()) {
  case Success: 
    break;
  case TemporaryError:
    if (scan() == Success)
      break;
  case PermanentError:
    return false;
  }

  selected = true;
  return true;
}