Monotone-Parent: 36de46e421cb49879d5821734892284e4035c708

Monotone-Revision: 73b3e5e425401db9c7ad2fc28660a6447ad0c4a5

Monotone-Author: flachapelle@inverse.ca
Monotone-Date: 2008-09-17T20:27:46
Monotone-Branch: ca.inverse.sogo
maint-2.0.2
Francis Lachapelle 2008-09-17 20:27:46 +00:00
parent 52bcec0fea
commit 032a99adf2
2 changed files with 18 additions and 5 deletions

View File

@ -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 <wsourdeau@inverse.ca>

View File

@ -23,6 +23,7 @@
#import <Foundation/NSArray.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSEnumerator.h>
#import <Foundation/NSUserDefaults.h>
#import <NGObjWeb/WOContext+SoObjects.h>
#import <NGObjWeb/WORequest.h>
@ -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"