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"