aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Petro Korienev <soxjke@gmail.com>2013-08-08 17:40:45 +0300
committerGravatar Petro Korienev <soxjke@gmail.com>2013-08-08 17:40:45 +0300
commitc6c9d10e66ae6a01fabd6c55c4492566372b59e5 (patch)
tree7ef20e5899dadd35f627fd644d4545b2db68926a /src/core
parentd5ed180d3615e668a59d098156189616b596a67a (diff)
added getQuota operation to get free space in mailbox
Diffstat (limited to 'src/core')
-rwxr-xr-x[-rw-r--r--]src/core/imap/MCIMAPSession.cc36
-rwxr-xr-x[-rw-r--r--]src/core/imap/MCIMAPSession.h1
2 files changed, 37 insertions, 0 deletions
diff --git a/src/core/imap/MCIMAPSession.cc b/src/core/imap/MCIMAPSession.cc
index 7ebe4354..f423de1c 100644..100755
--- a/src/core/imap/MCIMAPSession.cc
+++ b/src/core/imap/MCIMAPSession.cc
@@ -2445,6 +2445,7 @@ IndexSet * IMAPSession::search(String * folder, IMAPSearchExpression * expressio
clist * result_list = NULL;
+// int r = mailimap_uid_search(mImap, expression->shouldAvoidCharset() ? NULL : "utf-8", key, &result_list);
int r = mailimap_uid_search(mImap, "utf-8", key, &result_list);
mailimap_search_key_free(key);
MCLog("had error : %i", r);
@@ -2471,6 +2472,41 @@ IndexSet * IMAPSession::search(String * folder, IMAPSearchExpression * expressio
return result;
}
+void IMAPSession::getQuota(uint32_t *usage, uint32_t *limit, ErrorCode * pError)
+{
+ static char * const inboxFolderName = "INBOX";
+ mailimap_quota_complete_data *quota_data;
+ selectIfNeeded(MCSTR("INBOX"), pError);
+
+ if (* pError != ErrorNone)
+ return;
+
+ int r = mailimap_quota_getquotaroot(mImap, inboxFolderName, &quota_data);
+ if (r == MAILIMAP_ERROR_STREAM) {
+ * pError = ErrorConnection;
+ return;
+ }
+ else if (r == MAILIMAP_ERROR_PARSE) {
+ * pError = ErrorParse;
+ return;
+ }
+ else if (hasError(r)) {
+ * pError = ErrorFetch;
+ return;
+ }
+ for(clistiter * cur = clist_begin(quota_data->quota_list); cur != NULL; cur = clist_next(cur)) {
+ mailimap_quota_quota_data *quota = (mailimap_quota_quota_data*)clist_content(cur);
+ for (clistiter *cur2 = clist_begin(quota->quota_list); cur2 != NULL; cur2 = clist_next(cur2)) {
+ mailimap_quota_quota_resource *res = (mailimap_quota_quota_resource*)clist_content(cur2);
+ if (!strcasecmp("STORAGE", res->resource_name)) {
+ *usage = res->usage;
+ *limit = res->limit;
+ }
+ }
+ }
+ mailimap_quota_complete_data_free(quota_data);
+}
+
bool IMAPSession::setupIdle()
{
// main thread
diff --git a/src/core/imap/MCIMAPSession.h b/src/core/imap/MCIMAPSession.h
index 4128b516..97567d65 100644..100755
--- a/src/core/imap/MCIMAPSession.h
+++ b/src/core/imap/MCIMAPSession.h
@@ -126,6 +126,7 @@ namespace mailcore {
virtual IndexSet * search(String * folder, IMAPSearchKind kind, String * searchString, ErrorCode * pError);
virtual IndexSet * search(String * folder, IMAPSearchExpression * expression, ErrorCode * pError);
+ virtual void getQuota(uint32_t *usage, uint32_t *limit, ErrorCode * pError);
virtual bool setupIdle();
virtual void idle(String * folder, uint32_t lastKnownUID, ErrorCode * pError);