Index: Makefile.concept
===================================================================
RCS file: /cvsroot-dbmail/dbmail/Makefile.concept,v
retrieving revision 1.5
diff -u -r1.5 Makefile.concept
--- Makefile.concept	2002/12/11 14:36:23	1.5
+++ Makefile.concept	2003/01/16 23:13:27
@@ -18,7 +18,7 @@
 MINI_OBJECTS = debug.o $(DBOBJECT) list.o dbmd5.o md5.o $(AUTHOBJECT) mime.o config.o
 POP_OBJECTS = pop3.o list.o debug.o $(DBOBJECT) serverchild.o server.o dbmd5.o md5.o mime.o misc.o memblock.o $(AUTHOBJECT) config.o proctitleutils.o
 IMAP_OBJECTS = imap4.o debug.o $(DBOBJECT) serverchild.o server.o config.o list.o dbmd5.o md5.o imaputil.o \
-imapcommands.o mime.o misc.o memblock.o rfcmsg.o $(MSGBUFOBJECT) $(SEARCHOBJECT) $(AUTHOBJECT) proctitleutils.o
+imapcommands.o mime.o misc.o memblock.o rfcmsg.o $(MSGBUFOBJECT) $(SEARCHOBJECT) $(AUTHOBJECT) quota.o proctitleutils.o
 MAINTENANCE_OBJECTS = debug.o list.o dbmd5.o md5.o $(DBOBJECT) mime.o memblock.o $(AUTHOBJECT) config.o
 CONFIG_OBJECTS = $(DBOBJECT) list.o md5.o debug.o dbmd5.o mime.o memblock.o $(AUTHOBJECT) config.o
 USER_OBJECTS = debug.o list.o dbmd5.o md5.o $(DBOBJECT) mime.o memblock.o $(AUTHOBJECT) config.o
@@ -88,6 +88,7 @@
 imap4.o: imap4.h db.h debug.h imaputil.h imapcommands.h
 imaputil.o: imaputil.h db.h memblock.h debug.h dbmailtypes.h
 imapcommands.o: imapcommands.h imaputil.h imap4.h db.h memblock.h debug.h dbmailtypes.h
+quota.o: quota.h
 maintenance.o: maintenance.h debug.h
 settings.o: settings.h debug.h
 proctitleutils.o: proctitleutils.h
Index: imap4.c
===================================================================
RCS file: /cvsroot-dbmail/dbmail/imap4.c,v
retrieving revision 1.64
diff -u -r1.64 imap4.c
--- imap4.c	2002/12/05 11:55:46	1.64
+++ imap4.c	2003/01/16 23:13:27
@@ -46,6 +46,7 @@
   "select", "examine", "create", "delete", "rename", "subscribe", "unsubscribe", 
   "list", "lsub", "status", "append", 
   "check", "close", "expunge", "search", "fetch", "store", "copy", "uid",
+  "getquotaroot", "getquota",
   "***NOMORE***"
 };
 
@@ -60,6 +61,7 @@
 			  IMAP_COMM_CHECK, IMAP_COMM_CLOSE, IMAP_COMM_EXPUNGE,
 			  IMAP_COMM_SEARCH, IMAP_COMM_FETCH, IMAP_COMM_STORE,
 			  IMAP_COMM_COPY, IMAP_COMM_UID,
+			  IMAP_COMM_GETQUOTAROOT, IMAP_COMM_GETQUOTA,
 			  IMAP_COMM_LAST };
 
 
@@ -71,6 +73,7 @@
   _ic_select, _ic_examine, _ic_create, _ic_delete, _ic_rename, 
   _ic_subscribe, _ic_unsubscribe, _ic_list, _ic_lsub, _ic_status, _ic_append, 
   _ic_check, _ic_close, _ic_expunge, _ic_search, _ic_fetch, _ic_store, _ic_copy, _ic_uid,
+  _ic_getquotaroot, _ic_getquota,
   NULL
 };
 
Index: imap4.h
===================================================================
RCS file: /cvsroot-dbmail/dbmail/imap4.h,v
retrieving revision 1.31
diff -u -r1.31 imap4.h
--- imap4.h	2002/12/03 15:05:56	1.31
+++ imap4.h	2003/01/16 23:13:27
@@ -11,7 +11,7 @@
 #include "clientinfo.h"
 
 #define IMAP_SERVER_VERSION "0.9"
-#define IMAP_CAPABILITY_STRING "IMAP4 IMAP4rev1 AUTH=LOGIN"
+#define IMAP_CAPABILITY_STRING "IMAP4 IMAP4rev1 AUTH=LOGIN QUOTA"
 #define IMAP_TIMEOUT_MSG "* BYE dbmail IMAP4 server signing off due to timeout\r\n"
 
 /* max number of BAD/NO responses */
Index: imapcommands.c
===================================================================
RCS file: /cvsroot-dbmail/dbmail/imapcommands.c,v
retrieving revision 1.105
diff -u -r1.105 imapcommands.c
--- imapcommands.c	2002/12/09 09:53:09	1.105
+++ imapcommands.c	2003/01/16 23:13:30
@@ -13,6 +13,7 @@
 #include "memblock.h"
 #include "rfcmsg.h"
 #include "dbmsgbuf.h"
+#include "quota.h"
 #include <string.h>
 #include <ctype.h>
 #include <stdlib.h>
@@ -3322,7 +3323,87 @@
 }
 
 
-
-
+/* Helper function for _ic_getquotaroot() and _ic_getquota().
+ * Send all resource limits in `quota'.
+ */
+void send_quota(quota_t *quota, ClientInfo *ci) {
+    int r;
+    u64_t usage, limit;
+    char *name;
+    
+    for (r=0; r<quota->n_resources; r++) {
+	if (quota->resource[r].limit > 0) {
+	    switch (quota->resource[r].type) {
+	    case RT_STORAGE:
+		name  = "STORAGE";
+		usage = quota->resource[r].usage/1024;
+		limit = quota->resource[r].limit/1024;
+		break;
+	    default: continue;
+	    }
+	    fprintf(ci->tx, "* QUOTA \"%s\" (\"%s\" %llu %llu)\r\n",
+		    quota->root, name, usage, limit);
+	}
+    }
+}
 
+/*
+ * _ic_getquotaroot()
+ *
+ * get quota root and send quota
+ */
+int _ic_getquotaroot(char *tag, char **args, ClientInfo *ci) {
+    imap_userdata_t *ud = (imap_userdata_t*)ci->userData;
+    quota_t *quota;
+    char *root, *errormsg;
+    
+    if (!check_state_and_args("GETQUOTAROOT", tag, args, 1,
+			      IMAPCS_AUTHENTICATED, ci))
+	return 1; /* error, return */
+    
+    root = quota_get_quotaroot(ud->userid, args[0], &errormsg);
+    if (root == NULL) {
+	fprintf(ci->tx, "%s NO %s\r\n", tag, errormsg);
+	return 1;
+    }
+    
+    quota = quota_get_quota(ud->userid, root, &errormsg);
+    if (quota == NULL) {
+	fprintf(ci->tx, "%s NO %s\r\n", tag, errormsg);
+	return 1;
+    }
+    
+    fprintf(ci->tx, "* QUOTAROOT \"%s\" \"%s\"\r\n", args[0], quota->root);
+    send_quota(quota, ci);
+    quota_free(quota);
+    
+    fprintf(ci->tx, "%s OK GETQUOTAROOT completed\r\n", tag);
+    return 0;
+}
 
+/*
+ * _ic_getquot()
+ *
+ * get quota
+ */
+int _ic_getquota(char *tag, char **args, ClientInfo *ci) {
+    imap_userdata_t *ud = (imap_userdata_t*)ci->userData;
+    quota_t *quota;
+    char *errormsg;
+    
+    if (!check_state_and_args("GETQUOTA", tag, args, 1,
+			      IMAPCS_AUTHENTICATED, ci))
+	return 1; /* error, return */
+    
+    quota = quota_get_quota(ud->userid, args[0], &errormsg);
+    if (quota == NULL) {
+	fprintf(ci->tx, "%s NO %s\r\n", tag, errormsg);
+	return 1;
+    }
+    
+    send_quota(quota, ci);
+    quota_free(quota);
+    
+    fprintf(ci->tx, "%s OK GETQUOTA completed\r\n", tag);
+    return 0;
+}
Index: imapcommands.h
===================================================================
RCS file: /cvsroot-dbmail/dbmail/imapcommands.h,v
retrieving revision 1.4
diff -u -r1.4 imapcommands.h
--- imapcommands.h	2002/12/03 15:05:56	1.4
+++ imapcommands.h	2003/01/16 23:13:30
@@ -43,5 +43,8 @@
 int _ic_copy(char *tag, char **args, ClientInfo *ci);
 int _ic_uid(char *tag, char **args, ClientInfo *ci);
 
+/* quota commands */
+int _ic_getquotaroot(char *tag, char **args, ClientInfo *ci);
+int _ic_getquota(char *tag, char **args, ClientInfo *ci);
 
 #endif
