See ChangeLog

Monotone-Parent: d5f9ac8f8c26df4ffbd173e66fb8557ec6e21545
Monotone-Revision: dc272097703f10ee6c465fdca0d4d40682d7ce55

Monotone-Author: flachapelle@inverse.ca
Monotone-Date: 2011-03-17T21:26:51
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Francis Lachapelle
2011-03-17 21:26:51 +00:00
parent adefb89d55
commit 8cebdc7033
7 changed files with 114 additions and 69 deletions
+3 -31
View File
@@ -1,6 +1,6 @@
/* UIxMailAccountActions.m - this file is part of SOGo
*
* Copyright (C) 2007, 2008 Inverse inc.
* Copyright (C) 2007, 2011 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
@@ -137,38 +137,10 @@
folders = [self _jsonFolders: rawFolders];
inboxQuota = nil;
// Retrieve INBOX quota
if ([co supportsQuotas])
{
SOGoMailFolder *inbox;
NGImap4Client *client;
NSString *inboxName;
SOGoDomainDefaults *dd;
id infos;
float quota;
dd = [[context activeUser] domainDefaults];
quota = [dd softQuotaRatio];
inbox = [co inboxFolderInContext: context];
inboxName = [NSString stringWithFormat: @"/%@", [inbox relativeImap4Name]];
client = [[inbox imap4Connection] client];
infos = [[client getQuotaRoot: [inbox relativeImap4Name]] objectForKey: @"quotas"];
inboxQuota = [infos objectForKey: inboxName];
if (quota != 0 && inboxQuota != nil)
{
// A soft quota ration is imposed for all users
quota = quota * [(NSNumber*)[inboxQuota objectForKey: @"maxQuota"] intValue];
inboxQuota = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithFloat: (long)(quota+0.5)], @"maxQuota",
[inboxQuota objectForKey: @"usedSpace"], @"usedSpace",
nil];
}
}
// The parameter order is important here, as if the server doesn't support
// The parameters order is important here, as if the server doesn't support
// quota, inboxQuota will be nil and it'll terminate the list of objects/keys.
data = [NSDictionary dictionaryWithObjectsAndKeys: folders, @"mailboxes",
inboxQuota, @"quotas",
[co getInboxQuota], @"quotas",
nil];
response = [self responseWithStatus: 200
andString: [data jsonRepresentation]];
-1
View File
@@ -38,7 +38,6 @@
- (WOResponse *) emptyTrashAction;
- (WOResponse *) subscribeAction;
- (WOResponse *) unsubscribeAction;
- (WOResponse *) quotasAction;
@end
+29 -29
View File
@@ -1,8 +1,9 @@
/* UIxMailFolderActions.m - this file is part of SOGo
*
* Copyright (C) 2007-2010 Inverse inc.
* Copyright (C) 2007-2011 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
* Francis Lachapelle <flachapelle@inverse.ca>
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -295,9 +296,11 @@
- (WOResponse *) copyMessagesAction
{
SOGoMailFolder *co;
SOGoMailAccount *account;
WOResponse *response;
NSArray *uids;
NSString *value, *destinationFolder;
NSDictionary *data;
co = [self clientObject];
value = [[context request] formValueForKey: @"uid"];
@@ -309,7 +312,13 @@
uids = [value componentsSeparatedByString: @","];
response = [co copyUIDs: uids toFolder: destinationFolder inContext: context];
if (!response)
response = [self responseWith204];
{
// We return the inbox quota
account = [co container];
data = [NSDictionary dictionaryWithObjectsAndKeys: [account getInboxQuota], @"quotas", nil];
response = [self responseWithStatus: 200
andString: [data jsonRepresentation]];
}
}
else
{
@@ -466,6 +475,8 @@
{
NSException *error;
SOGoTrashFolder *co;
SOGoMailAccount *account;
NSDictionary *data;
WOResponse *response;
co = [self clientObject];
@@ -479,20 +490,27 @@
else
{
[co flushMailCaches];
response = [self responseWith204];
// We return the inbox quota
account = [co container];
data = [NSDictionary dictionaryWithObjectsAndKeys: [account getInboxQuota], @"quotas", nil];
response = [self responseWithStatus: 200
andString: [data jsonRepresentation]];
}
return response;
}
- (WOResponse *) emptyTrashAction
- (WOResponse *) emptyTrashAction
{
NSException *error;
SOGoTrashFolder *co;
SOGoMailAccount *account;
NSEnumerator *subfolders;
WOResponse *response;
NGImap4Connection *connection;
NSURL *currentURL;
NSDictionary *data;
co = [self clientObject];
@@ -513,7 +531,13 @@
[response appendContentString: @"Unable to empty the trash folder."];
}
else
response = [self responseWith204];
{
// We return the inbox quota
account = [co container];
data = [NSDictionary dictionaryWithObjectsAndKeys: [account getInboxQuota], @"quotas", nil];
response = [self responseWithStatus: 200
andString: [data jsonRepresentation]];
}
return response;
}
@@ -556,30 +580,6 @@
return [self _subscriptionStubAction];
}
- (WOResponse *) quotasAction
{
SOGoMailFolder *folder;
NSURL *folderURL;
id infos;
WOResponse *response;
NGImap4Client *client;
NSString *responseString;
response = [self responseWithStatus: 200];
[response setHeader: @"text/plain; charset=UTF-8"
forKey: @"content-type"];
folder = [self clientObject];
folderURL = [folder imap4URL];
client = [[folder imap4Connection] client];
infos = [client getQuotaRoot: [folder relativeImap4Name]];
responseString = [[infos objectForKey: @"quotas"] jsonRepresentation];
[response appendContentString: responseString];
return response;
}
- (NSDictionary *) _unseenCount
{
EOQualifier *searchQualifier;