Bincimap 2.0.16
Easy Imapping
Loading...
Searching...
No Matches
bincimap-updatecache.cc
Go to the documentation of this file.
1
7#include "depot.h"
8#include "mailbox.h"
9#include "maildir.h"
10#include "session.h"
11
12using namespace ::Binc;
13using namespace ::std;
14
15int main(int argc, char *argv[])
16{
17 if (argc < 2) {
18 fprintf(stderr, "usage: %s <directory> ", argv[0]);
19 fprintf(stderr, "Updates the cache file in <directory>.\n");
20 fprintf(stderr, "Use export $DEPOT=\"IMAPdir\" to enable updates for this type.\n");
21 return 1;
22 }
23
24 Session &session = Session::getInstance();
25
26 DepotFactory &depotfactory = DepotFactory::getInstance();
27 depotfactory.assign(new IMAPdirDepot());
28 depotfactory.assign(new MaildirPPDepot());
29
30 string depottype = session.getEnv("DEPOT");
31 if (depottype == "") depottype = "Maildir++";
32
33 Depot *depot;
34 if ((depot = depotfactory.get(depottype)) == 0) {
35 fprintf(stderr, "Found no Depot for \"%s\". Please check " \
36 " your configurations file under the Mailbox section.\n",
37 depottype.c_str());
38 return 1;
39 }
40
41 depot->assign(new Maildir());
42 depot->setDefaultType("Maildir");
43
44 Mailbox *mailbox = depot->get(depot->filenameToMailbox(argv[1]));
45
46 if (!mailbox) {
47 fprintf(stderr, "selecting mailbox failed: %s\n",
48 depot->getLastError().c_str());
49 return 1;
50 }
51
52 if (!mailbox->selectMailbox(argv[1], argv[1])) {
53 fprintf(stderr, "selecting mailbox failed: %s\n",
54 mailbox->getLastError().c_str());
55 return 1;
56 }
57
58 mailbox->closeMailbox();
59
60 return 0;
61}
Declaration of the Mailbox class (Mailbox is logical container)
Declaration of the Maildir class.
Definition: bincimapd.cc:9
int main()
Definition: tryfilio.cc:6