summaryrefslogtreecommitdiff
path: root/src/operator-namespace.cc
diff options
context:
space:
mode:
authorErwin Hoffmann <feh@fehcom.de>2023-09-21 17:36:16 +0200
committerErwin Hoffmann <feh@fehcom.de>2023-09-21 17:36:16 +0200
commit44388ac49531af9e2565f76ef99ff7afb757b3fb (patch)
tree4eeb294db5bc3dbd075d0df5fea13c664cc331e2 /src/operator-namespace.cc
parent889d69a87d51c8df531885cf1ac3d12d64a0cff7 (diff)
all sources
Diffstat (limited to 'src/operator-namespace.cc')
-rw-r--r--src/operator-namespace.cc79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/operator-namespace.cc b/src/operator-namespace.cc
new file mode 100644
index 0000000..8574f91
--- /dev/null
+++ b/src/operator-namespace.cc
@@ -0,0 +1,79 @@
+/** --------------------------------------------------------------------
+ * @file operator-namespace.cc
+ * @brief Operator for the NAMESPACE command.
+ * @author Andreas Aardal Hanssen
+ * @date 2002-2005
+ * ----------------------------------------------------------------- **/
+#include <string>
+#include <iostream>
+
+#include "depot.h"
+#include "iodevice.h"
+#include "iofactory.h"
+#include "operators.h"
+#include "recursivedescent.h"
+#include "session.h"
+
+using namespace ::std;
+using namespace Binc;
+
+//----------------------------------------------------------------------
+NamespaceOperator::NamespaceOperator(void)
+{
+}
+
+//----------------------------------------------------------------------
+NamespaceOperator::~NamespaceOperator(void)
+{
+}
+
+//----------------------------------------------------------------------
+const string NamespaceOperator::getName(void) const
+{
+ return "NAMESPACE";
+}
+
+//----------------------------------------------------------------------
+int NamespaceOperator::getState(void) const
+{
+ return Session::AUTHENTICATED | Session::SELECTED;
+}
+
+//----------------------------------------------------------------------
+Operator::ProcessResult NamespaceOperator::process(Depot &depot,
+ Request &command)
+{
+ bincClient << "* NAMESPACE ";
+
+ bincClient << "(("; // personal namespace
+ bincClient << toImapString(depot.getPersonalNamespace());
+ bincClient << " ";
+ char c = depot.getDelimiter();
+ bincClient << toImapString(string(&c, 1));
+ bincClient << "))";
+
+ bincClient << " NIL"; // others' namespaces
+ bincClient << " NIL"; // shared namespaces
+ bincClient << endl;
+
+ return OK;
+}
+
+//----------------------------------------------------------------------
+Operator::ParseResult NamespaceOperator::parse(Request &c_in) const
+{
+ Session &session = Session::getInstance();
+
+ if (c_in.getUidMode())
+ return REJECT;
+
+ Operator::ParseResult res;
+ if ((res = expectCRLF()) != ACCEPT) {
+ session.setLastError("Expected CRLF after NAMESPACE");
+ return res;
+ }
+
+ c_in.setName("NAMESPACE");
+
+ return ACCEPT;
+}