From 032a99adf215400ce1e03467f53af52bce8da2d3 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Wed, 17 Sep 2008 20:27:46 +0000 Subject: [PATCH] Monotone-Parent: 36de46e421cb49879d5821734892284e4035c708 Monotone-Revision: 73b3e5e425401db9c7ad2fc28660a6447ad0c4a5 Monotone-Author: flachapelle@inverse.ca Monotone-Date: 2008-09-17T20:27:46 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 4 +++- UI/MailerUI/UIxMailAccountActions.m | 19 +++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index fecf7e16a..a40fd100e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,7 +2,9 @@ * UI/MailerUI/UIxMailAccountActions.m ([WOResponse -listMailboxesAction]): also returns the inbox quota, wrapped in a - new dictionary with keys "mailboxes" and "quotas". + new dictionary with keys "mailboxes" and "quotas". Uses the new user + default "SOGoSoftQuota" to force a quota and ignore the one + returned by the IMAP server. 2008-09-17 Wolfgang Sourdeau diff --git a/UI/MailerUI/UIxMailAccountActions.m b/UI/MailerUI/UIxMailAccountActions.m index 1752390fc..9ed6cc90c 100644 --- a/UI/MailerUI/UIxMailAccountActions.m +++ b/UI/MailerUI/UIxMailAccountActions.m @@ -23,6 +23,7 @@ #import #import #import +#import #import #import @@ -122,7 +123,7 @@ - (WOResponse *) listMailboxesAction { - id infos; + id infos, inboxQuota; SOGoMailAccount *co; SOGoMailFolder *inbox; NGImap4Client *client; @@ -130,21 +131,31 @@ NSArray *folders; NSDictionary *data; NSString *inboxName; + NSUserDefaults *ud; WOResponse *response; + int quota; + ud = [NSUserDefaults standardUserDefaults]; co = [self clientObject]; rawFolders = [[co allFolderPaths] objectEnumerator]; folders = [self _jsonFolders: rawFolders]; // Retrieve INBOX quota + quota = [ud integerForKey: @"SOGoSoftQuota"]; inbox = [co inboxFolderInContext: context]; inboxName = [NSString stringWithFormat: @"/%@", [inbox relativeImap4Name]]; client = [[inbox imap4Connection] client]; - infos = [client getQuotaRoot: [inbox relativeImap4Name]]; - + infos = [[client getQuotaRoot: [inbox relativeImap4Name]] objectForKey: @"quotas"]; + inboxQuota = [infos objectForKey: inboxName]; + if (quota > 0 && inboxQuota != nil) + // A soft quota is imposed for all users + inboxQuota = [NSDictionary dictionaryWithObjectsAndKeys: + [NSNumber numberWithInt: quota], @"maxQuota", + [inboxQuota objectForKey: @"usedSpace"], @"usedSpace", + nil]; data = [NSDictionary dictionaryWithObjectsAndKeys: folders, @"mailboxes", - [[infos objectForKey: @"quotas"] objectForKey: inboxName], @"quotas", + inboxQuota, @"quotas", nil]; response = [self responseWithStatus: 200]; [response setHeader: @"text/plain; charset=utf-8"