summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul J Stevens <paul@nfg.nl>2010-06-27 16:37:55 +0200
committerPaul J Stevens <paul@nfg.nl>2010-06-27 16:39:26 +0200
commitaf691c9077fe81a0a6c90cc6a68ba06293ad22a6 (patch)
treedad94ea19d106ee36ab38d80c7bcc2fdad18a904
parent5bd79e0c0e02fb5c562604d3421f483557a50604 (diff)
backport IMAP-ID capability
-rw-r--r--dbmail.h.in1
-rw-r--r--dbmailtypes.h1
-rw-r--r--imap4.c4
-rw-r--r--imap4.h2
-rw-r--r--imapcommands.c13
-rw-r--r--imapcommands.h1
6 files changed, 19 insertions, 3 deletions
diff --git a/dbmail.h.in b/dbmail.h.in
index cec9f733..0c571262 100644
--- a/dbmail.h.in
+++ b/dbmail.h.in
@@ -69,6 +69,7 @@
#include <sys/wait.h>
#include <sys/ipc.h>
#include <sys/shm.h>
+#include <sys/utsname.h>
#include <time.h>
#include <termios.h>
#include <unistd.h>
diff --git a/dbmailtypes.h b/dbmailtypes.h
index d85d3a0e..2f64fc83 100644
--- a/dbmailtypes.h
+++ b/dbmailtypes.h
@@ -244,6 +244,7 @@ enum IMAP_COMMAND_TYPES {
IMAP_COMM_THREAD,
IMAP_COMM_UNSELECT,
IMAP_COMM_IDLE,
+ IMAP_COMM_ID,
IMAP_COMM_LAST
};
diff --git a/imap4.c b/imap4.c
index 2a6cf1ad..4922fb0a 100644
--- a/imap4.c
+++ b/imap4.c
@@ -39,7 +39,7 @@ const char *IMAP_COMMANDS[] = {
"check", "close", "expunge", "search", "fetch", "store", "copy",
"uid", "sort", "getquotaroot", "getquota",
"setacl", "deleteacl", "getacl", "listrights", "myrights",
- "namespace","thread","unselect","idle",
+ "namespace","thread","unselect","idle","id",
"***NOMORE***"
};
@@ -57,7 +57,7 @@ const IMAP_COMMAND_HANDLER imap_handler_functions[] = {
_ic_getquotaroot, _ic_getquota,
_ic_setacl, _ic_deleteacl, _ic_getacl, _ic_listrights,
_ic_myrights,
- _ic_namespace, _ic_thread, _ic_unselect, _ic_idle,
+ _ic_namespace, _ic_thread, _ic_unselect, _ic_idle, _ic_id,
NULL
};
diff --git a/imap4.h b/imap4.h
index 3b879339..afefc269 100644
--- a/imap4.h
+++ b/imap4.h
@@ -28,7 +28,7 @@
#include "dbmail.h"
#define IMAP_SERVER_VERSION VERSION
-#define IMAP_CAPABILITY_STRING "IMAP4 IMAP4rev1 AUTH=LOGIN ACL NAMESPACE CHILDREN SORT QUOTA THREAD=ORDEREDSUBJECT UNSELECT IDLE"
+#define IMAP_CAPABILITY_STRING "IMAP4 IMAP4rev1 AUTH=LOGIN ACL NAMESPACE CHILDREN SORT QUOTA THREAD=ORDEREDSUBJECT UNSELECT IDLE ID"
#define IMAP_TIMEOUT_MSG "* BYE dbmail IMAP4 server signing off due to timeout\r\n"
/* max number of BAD/NO responses */
diff --git a/imapcommands.c b/imapcommands.c
index e49abfd2..c123b341 100644
--- a/imapcommands.c
+++ b/imapcommands.c
@@ -104,7 +104,20 @@ int _ic_noop(struct ImapSession *self)
return 0;
}
+int _ic_id(struct ImapSession *self)
+{
+ struct utsname buf;
+ imap_userdata_t *ud = (imap_userdata_t *) self->ci->userData;
+ if (!check_state_and_args(self, "ID", 0, 0, -1)) return 1; /* error, return */
+
+ memset(&buf, 0, sizeof(buf));
+ uname(&buf);
+ dbmail_imap_session_printf(self, "* ID (\"name\" \"dbmail\" \"version\" \"%s\""
+ " \"os\" \"%s\" \"os-version\" \"%s\")\r\n", DBMAIL_VERSION, &buf.sysname, &buf.release);
+ dbmail_imap_session_printf(self, "%s OK ID completed\r\n", self->tag);
+ return 0;
+}
/*
* _ic_logout()
*
diff --git a/imapcommands.h b/imapcommands.h
index 298a64a2..06c8dac9 100644
--- a/imapcommands.h
+++ b/imapcommands.h
@@ -33,6 +33,7 @@
/* any-state commands */
int _ic_capability(struct ImapSession *self);
int _ic_noop(struct ImapSession *self);
+int _ic_id(struct ImapSession *self);
int _ic_logout(struct ImapSession *self);
/* non-auth state commands */