summaryrefslogtreecommitdiff
path: root/src/bincimap-updatecache.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/bincimap-updatecache.cc')
-rw-r--r--src/bincimap-updatecache.cc61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/bincimap-updatecache.cc b/src/bincimap-updatecache.cc
new file mode 100644
index 0000000..4efe723
--- /dev/null
+++ b/src/bincimap-updatecache.cc
@@ -0,0 +1,61 @@
+/** --------------------------------------------------------------------
+ * @file bincimap-updatecache.cc
+ * @brief Implementation of the bincimap-updatecache tool.
+ * @author Andreas Aardal Hanssen
+ * @date 2002-2005
+ * ----------------------------------------------------------------- **/
+#include "depot.h"
+#include "mailbox.h"
+#include "maildir.h"
+#include "session.h"
+
+using namespace ::Binc;
+using namespace ::std;
+
+int main(int argc, char *argv[])
+{
+ if (argc < 2) {
+ fprintf(stderr, "usage: %s <directory> ", argv[0]);
+ fprintf(stderr, "Updates the cache file in <directory>.\n");
+ fprintf(stderr, "Use export $DEPOT=\"IMAPdir\" to enable updates for this type.\n");
+ return 1;
+ }
+
+ Session &session = Session::getInstance();
+
+ DepotFactory &depotfactory = DepotFactory::getInstance();
+ depotfactory.assign(new IMAPdirDepot());
+ depotfactory.assign(new MaildirPPDepot());
+
+ string depottype = session.getEnv("DEPOT");
+ if (depottype == "") depottype = "Maildir++";
+
+ Depot *depot;
+ if ((depot = depotfactory.get(depottype)) == 0) {
+ fprintf(stderr, "Found no Depot for \"%s\". Please check " \
+ " your configurations file under the Mailbox section.\n",
+ depottype.c_str());
+ return 1;
+ }
+
+ depot->assign(new Maildir());
+ depot->setDefaultType("Maildir");
+
+ Mailbox *mailbox = depot->get(depot->filenameToMailbox(argv[1]));
+
+ if (!mailbox) {
+ fprintf(stderr, "selecting mailbox failed: %s\n",
+ depot->getLastError().c_str());
+ return 1;
+ }
+
+ if (!mailbox->selectMailbox(argv[1], argv[1])) {
+ fprintf(stderr, "selecting mailbox failed: %s\n",
+ mailbox->getLastError().c_str());
+ return 1;
+ }
+
+ mailbox->closeMailbox();
+
+ return 0;
+}