summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Kalowsky <kalowsky@php.net>2001-02-25 04:41:18 +0000
committerDan Kalowsky <kalowsky@php.net>2001-02-25 04:41:18 +0000
commit6b805544040861e45ca47523e9ad9d80c22af5b9 (patch)
tree0bcffa2e4daf3262f83180d2f937a9277737e3d1
parent9a1c4e532858d2031c9c45af0fe70ab9823da4d6 (diff)
downloadphp-git-6b805544040861e45ca47523e9ad9d80c22af5b9.tar.gz
Updating the IMAP client to include quota support via the imap c-client2000 libraries.
# Y2K support is good... Removes the SA_QUOTA and SA_QUOTA_ALL defines # After speaking with Mark Crispin, it is believed these never existed. Cleans up the imap_status() function to remove notion of quotas in a status message. # There is no quota setting in a STATUS message from c-client. Changes the config.m4 to support the client.h include # This should include all the approriate headers for c-client (as defined by # c-client maintainers) such as mail.h, and rfc822.h. Changed the directory search order for the include files as well. # Place the /usr/local/include last, and searched the # /usr/local/include/{c-client|imap} directories first (PHP imap_get_quota) Added (PHP imap_set_quota) Added @- IMAP quota support (imap_set_quota, imap_get_quota) enabled/added via @ c-client2000 PR: Submitted by: Reviewed by: Obtained from:
-rw-r--r--ext/imap/config.m44
-rw-r--r--ext/imap/php_imap.c124
-rw-r--r--ext/imap/php_imap.h18
3 files changed, 107 insertions, 39 deletions
diff --git a/ext/imap/config.m4 b/ext/imap/config.m4
index 2d82ff23e8..ff7a0a7ce1 100644
--- a/ext/imap/config.m4
+++ b/ext/imap/config.m4
@@ -41,9 +41,9 @@ PHP_ARG_WITH(imap,for IMAP support,
if test "$PHP_IMAP" != "no"; then
for i in /usr/local /usr $PHP_IMAP; do
IMAP_INC_CHK()
- el[]IMAP_INC_CHK(/include)
- el[]IMAP_INC_CHK(/include/imap)
el[]IMAP_INC_CHK(/include/c-client)
+ el[]IMAP_INC_CHK(/include/imap)
+ el[]IMAP_INC_CHK(/include)
el[]IMAP_INC_CHK(/imap)
el[]IMAP_INC_CHK(/c-client)
fi
diff --git a/ext/imap/php_imap.c b/ext/imap/php_imap.c
index 550ebc9ab7..67f9471366 100644
--- a/ext/imap/php_imap.c
+++ b/ext/imap/php_imap.c
@@ -101,6 +101,8 @@ function_entry imap_functions[] = {
PHP_FE(imap_createmailbox, NULL)
PHP_FE(imap_renamemailbox, NULL)
PHP_FE(imap_deletemailbox, NULL)
+ PHP_FE(imap_get_quota, NULL)
+ PHP_FE(imap_set_quota, NULL)
PHP_FALIAS(imap_listmailbox, imap_list, NULL)
PHP_FALIAS(imap_getmailboxes, imap_list_full, NULL)
PHP_FALIAS(imap_scanmailbox, imap_listscan, NULL)
@@ -355,6 +357,20 @@ MESSAGELIST *mail_newmessagelist(void)
sizeof(MESSAGELIST));
}
+/* Mail GET_QUOTA callback
+ * Called via the mail_parameter function in c-client:src/c-client/mail.c
+ * Author DRK
+ */
+void mail_getquota(MAILSTREAM *stream, char *qroot,QUOTALIST *qlist)
+{
+ /* this should only be run through once */
+ for (; qlist; qlist = qlist->next)
+ {
+ IMAPG(quota_usage) = qlist->usage;
+ IMAPG(quota_limit) = qlist->limit;
+ }
+}
+
/* Mail garbage collect MESSAGELIST
* Accepts: pointer to MESSAGELIST pointer
* Author: CJH
@@ -532,16 +548,12 @@ PHP_MINIT_FUNCTION(imap)
REGISTER_MAIN_LONG_CONSTANT("SA_UIDVALIDITY",SA_UIDVALIDITY , CONST_PERSISTENT | CONST_CS);
/* UID validity value */
-#ifdef SA_QUOTA
- sa_all |= SA_QUOTA;
- REGISTER_MAIN_LONG_CONSTANT("SA_QUOTA",SA_QUOTA , CONST_PERSISTENT | CONST_CS);
+ sa_all |= GET_QUOTA;
+ REGISTER_MAIN_LONG_CONSTANT("GET_QUOTA",GET_QUOTA , CONST_PERSISTENT | CONST_CS);
/* Disk space taken up by mailbox. */
-#endif
-#ifdef SA_QUOTA_ALL
- sa_all |= SA_QUOTA_ALL;
- REGISTER_MAIN_LONG_CONSTANT("SA_QUOTA_ALL",SA_QUOTA_ALL , CONST_PERSISTENT | CONST_CS);
+ sa_all |= GET_QUOTAROOT;
+ REGISTER_MAIN_LONG_CONSTANT("GET_QUOTAROOT",GET_QUOTAROOT , CONST_PERSISTENT | CONST_CS);
/* Disk space taken up by all mailboxes owned by user. */
-#endif
REGISTER_MAIN_LONG_CONSTANT("SA_ALL", sa_all, CONST_PERSISTENT | CONST_CS);
/* get all status information */
@@ -1000,6 +1012,80 @@ PHP_FUNCTION(imap_num_recent)
/* }}} */
+/* {{{ proto array imap_get_quota(int stream_id, string qroot)
+ Returns the quota set to the mailbox account qroot */
+PHP_FUNCTION(imap_get_quota)
+{
+ zval **streamind, **qroot;
+
+ int ind, ind_type;
+ pils *imap_le_struct;
+
+ if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &streamind, &qroot) == FAILURE) {
+ ZEND_WRONG_PARAM_COUNT();
+ }
+
+ convert_to_long_ex(streamind);
+ convert_to_string_ex(qroot);
+
+ ind = Z_LVAL_PP(streamind);
+ imap_le_struct = (pils *) zend_list_find(ind, &ind_type);
+ if (!imap_le_struct || !IS_STREAM(ind_type)) {
+ php_error(E_WARNING, "Unable to find stream pointer");
+ RETURN_FALSE;
+ }
+
+ /* set the callback for the GET_QUOTA function */
+ mail_parameters(NIL, SET_QUOTA, (void *) mail_getquota);
+
+ if(!imap_getquota(imap_le_struct->imap_stream, Z_STRVAL_PP(qroot))) {
+ php_error(E_WARNING, "c-client imap_getquota failed");
+ RETURN_FALSE;
+ }
+
+ if (array_init(return_value) == FAILURE) {
+ php_error(E_WARNING, "Unable to allocate array memory");
+ RETURN_FALSE;
+ }
+
+ add_assoc_long(return_value, "usage", IMAPG(quota_usage));
+ add_assoc_long(return_value, "limit", IMAPG(quota_limit));
+}
+/* }}} */
+
+
+/* {{{ proto int imap_set_quota(int stream_id, string qroot, int mailbox_size)
+ Will set the quota for qroot mailbox */
+PHP_FUNCTION(imap_set_quota)
+{
+ zval **streamind, **qroot, **mailbox_size;
+ STRINGLIST limits;
+ int ind, ind_type;
+ pils *imap_le_struct;
+
+ if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &streamind, &qroot, &mailbox_size) == FAILURE) {
+ ZEND_WRONG_PARAM_COUNT();
+ }
+
+ convert_to_long_ex(streamind);
+ convert_to_string_ex(qroot);
+ convert_to_long_ex(mailbox_size);
+
+ limits.text.data = "STORAGE";
+ limits.text.size = Z_LVAL_PP(mailbox_size);
+ limits.next = NIL;
+
+ ind = Z_LVAL_PP(streamind);
+ imap_le_struct = (pils *) zend_list_find(ind, &ind_type);
+ if (!imap_le_struct || !IS_STREAM(ind_type)) {
+ php_error(E_WARNING, "Unable to find stream pointer");
+ RETURN_FALSE;
+ }
+ RETURN_LONG(imap_setquota(imap_le_struct->imap_stream, Z_STRVAL_PP(qroot), &limits));
+}
+/* }}} */
+
+
/* {{{ proto int imap_expunge(int stream_id)
Permanently delete all messages marked for deletion */
PHP_FUNCTION(imap_expunge)
@@ -2813,6 +2899,7 @@ PHP_FUNCTION(imap_status)
if (object_init(return_value) == FAILURE) {
RETURN_FALSE;
}
+
if (mail_status(imap_le_struct->imap_stream, Z_STRVAL_PP(mbx), Z_LVAL_PP(flags))) {
add_property_long(return_value, "flags", IMAPG(status_flags));
if (IMAPG(status_flags) & SA_MESSAGES) {
@@ -2830,16 +2917,6 @@ PHP_FUNCTION(imap_status)
if (IMAPG(status_flags) & SA_UIDVALIDITY) {
add_property_long(return_value, "uidvalidity", IMAPG(status_uidvalidity));
}
-#ifdef SA_QUOTA
- if (IMAPG(status_flags) & SA_QUOTA) {
- add_property_long(return_value, "quota", IMAPG(status_quota));
- }
-#endif
-#ifdef SA_QUOTA
- if (IMAPG(status_flags) & SA_QUOTA_ALL) {
- add_property_long(return_value, "quota_all", IMAPG(status_quota_all));
- }
-#endif
} else {
RETURN_FALSE;
}
@@ -4075,17 +4152,6 @@ void mm_status(MAILSTREAM *stream, char *mailbox,MAILSTATUS *status)
if (IMAPG(status_flags) & SA_UIDVALIDITY) {
IMAPG(status_uidvalidity)=status->uidvalidity;
}
-
-#ifdef SA_QUOTA
- if (IMAPG(status_flags) & SA_QUOTA) {
- IMAPG(status_quota)=status->quota;
- }
-#endif
-#ifdef SA_QUOTA_ALL
- if (IMAPG(status_flags) & SA_QUOTA_ALL) {
- IMAPG(status_quota_all)=status->quota_all;
- }
-#endif
}
void mm_log(char *str, long errflg)
diff --git a/ext/imap/php_imap.h b/ext/imap/php_imap.h
index 1d1b9c8cfb..2d91299376 100644
--- a/ext/imap/php_imap.h
+++ b/ext/imap/php_imap.h
@@ -6,8 +6,12 @@
#include "build-defs.h"
#endif
-#include "mail.h"
-#include "rfc822.h"
+/*
+ #include "mail.h"
+ #include "rfc822.h"
+*/
+#include "c-client.h"
+#include "imap4r1.h" /* used for the imap_setquota function */
#include "modules.h"
extern zend_module_entry imap_module_entry;
@@ -100,6 +104,8 @@ PHP_FUNCTION(imap_renamemailbox);
PHP_FUNCTION(imap_deletemailbox);
PHP_FUNCTION(imap_listmailbox);
PHP_FUNCTION(imap_scanmailbox);
+PHP_FUNCTION(imap_get_quota);
+PHP_FUNCTION(imap_set_quota);
PHP_FUNCTION(imap_subscribe);
PHP_FUNCTION(imap_unsubscribe);
PHP_FUNCTION(imap_append);
@@ -156,12 +162,8 @@ ZEND_BEGIN_MODULE_GLOBALS(imap)
unsigned long status_unseen;
unsigned long status_uidnext;
unsigned long status_uidvalidity;
-#ifdef SA_QUOTA
- unsigned long status_quota;
-#endif
-#ifdef SA_QUOTA_ALL
- unsigned long status_quota_all;
-#endif
+ unsigned long quota_usage;
+ unsigned long quota_limit;
ZEND_END_MODULE_GLOBALS(imap)