mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-03-12 18:31:23 +00:00
See Changelog.
Monotone-Parent: 1e456d9a08ec90bd4e7fad4909eecfaa354aed5a Monotone-Revision: c2868ffdea9d34b226e1f85e0a8de47117a91bb5 Monotone-Author: flachapelle@inverse.ca Monotone-Date: 2011-07-08T17:38:27 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
2011-07-12 Francis Lachapelle <flachapelle@inverse.ca>
|
||||
|
||||
* UI/MailerUI/UIxMailFolderActions.m (-batchDeleteAction): we
|
||||
only return the quota when not using the trash folder.
|
||||
|
||||
* SoObjects/SOGo/SOGoFolder.m (-compare:): handle the case when
|
||||
the display name is not defined.
|
||||
|
||||
|
||||
@@ -261,6 +261,7 @@ static NSString *inboxFolderName = @"INBOX";
|
||||
{
|
||||
// A soft quota ratio is imposed for all users
|
||||
quota = quota * [(NSNumber*)[inboxQuota objectForKey: @"maxQuota"] intValue];
|
||||
NSLog(@"*** quota %@/%@", [inboxQuota objectForKey: @"usedSpace"], [inboxQuota objectForKey: @"maxQuota"]);
|
||||
inboxQuota = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSNumber numberWithLong: (long)(quota+0.5)], @"maxQuota",
|
||||
[inboxQuota objectForKey: @"usedSpace"], @"usedSpace",
|
||||
|
||||
@@ -1167,17 +1167,11 @@ static NSString *defaultUserID = @"anyone";
|
||||
|
||||
- (NSString *) httpURLForAdvisoryToUser: (NSString *) uid
|
||||
{
|
||||
SOGoUser *user;
|
||||
NSString *otherUsersPath, *url;
|
||||
SOGoMailAccount *thisAccount;
|
||||
NSDictionary *mailAccount;
|
||||
|
||||
user = [SOGoUser userWithLogin: uid roles: nil];
|
||||
otherUsersPath = [self otherUsersPathToFolder];
|
||||
if (otherUsersPath)
|
||||
{
|
||||
thisAccount = [self mailAccountFolder];
|
||||
mailAccount = [[user mailAccounts] objectAtIndex: 0];
|
||||
url = [NSString stringWithFormat: @"%@/0%@",
|
||||
[self soURLToBaseContainerForUser: uid],
|
||||
otherUsersPath];
|
||||
|
||||
@@ -187,11 +187,7 @@
|
||||
rawFolders = [[co allFolderPaths] objectEnumerator];
|
||||
folders = [self _jsonFolders: rawFolders];
|
||||
|
||||
// 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",
|
||||
[co getInboxQuota], @"quotas",
|
||||
nil];
|
||||
data = [NSDictionary dictionaryWithObjectsAndKeys: folders, @"mailboxes", nil];
|
||||
response = [self responseWithStatus: 200
|
||||
andString: [data jsonRepresentation]];
|
||||
[response setHeader: @"application/json"
|
||||
|
||||
@@ -94,30 +94,22 @@
|
||||
- (id) markMessageUnflaggedAction
|
||||
{
|
||||
id response;
|
||||
SOGoMailFolder *mailFolder;
|
||||
|
||||
response = [[self clientObject] removeFlags: @"\\Flagged"];
|
||||
if (!response)
|
||||
{
|
||||
mailFolder = [[self clientObject] container];
|
||||
response = [self responseWith204];
|
||||
}
|
||||
|
||||
response = [self responseWith204];
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
- (id) markMessageFlaggedAction
|
||||
{
|
||||
id response;
|
||||
SOGoMailFolder *mailFolder;
|
||||
|
||||
response = [[self clientObject] addFlags: @"\\Flagged"];
|
||||
if (!response)
|
||||
{
|
||||
mailFolder = [[self clientObject] container];
|
||||
response = [self responseWith204];
|
||||
}
|
||||
|
||||
response = [self responseWith204];
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -125,30 +117,22 @@
|
||||
- (id) markMessageUnreadAction
|
||||
{
|
||||
id response;
|
||||
SOGoMailFolder *mailFolder;
|
||||
|
||||
|
||||
response = [[self clientObject] removeFlags: @"seen"];
|
||||
if (!response)
|
||||
{
|
||||
mailFolder = [[self clientObject] container];
|
||||
response = [self responseWith204];
|
||||
}
|
||||
|
||||
response = [self responseWith204];
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
- (id) markMessageReadAction
|
||||
{
|
||||
id response;
|
||||
SOGoMailFolder *mailFolder;
|
||||
|
||||
response = [[self clientObject] addFlags: @"seen"];
|
||||
if (!response)
|
||||
{
|
||||
mailFolder = [[self clientObject] container];
|
||||
response = [self responseWith204];
|
||||
}
|
||||
|
||||
response = [self responseWith204];
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
@@ -247,10 +247,16 @@
|
||||
response = (WOResponse *) [co deleteUIDs: uids useTrashFolder: !withoutTrash inContext: context];
|
||||
if (!response)
|
||||
{
|
||||
account = [co mailAccountFolder];
|
||||
data = [NSDictionary dictionaryWithObjectsAndKeys: [account getInboxQuota], @"quotas", nil];
|
||||
response = [self responseWithStatus: 200
|
||||
andString: [data jsonRepresentation]];
|
||||
if (withoutTrash)
|
||||
{
|
||||
// When not using a trash folder, return the quota
|
||||
account = [co mailAccountFolder];
|
||||
data = [NSDictionary dictionaryWithObjectsAndKeys: [account getInboxQuota], @"quotas", nil];
|
||||
response = [self responseWithStatus: 200
|
||||
andString: [data jsonRepresentation]];
|
||||
}
|
||||
else
|
||||
response = [self responseWith204];
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -49,9 +49,10 @@
|
||||
- (NSArray *) getSortedUIDsInFolder: (SOGoMailFolder *) mailFolder;
|
||||
- (NSArray *) getHeadersForUIDs: (NSArray *) uids
|
||||
inFolder: (SOGoMailFolder *) mailFolder;
|
||||
- (NSDictionary *) getUIDsAndHeadersInFolder: (SOGoMailFolder *) mailFolder;
|
||||
- (NSDictionary *) getUIDsInFolder: (SOGoMailFolder *) folder
|
||||
withHeaders: (BOOL) includeHeaders;
|
||||
|
||||
- (id <WOActionResults>) getSortedUIDsAction;
|
||||
- (id <WOActionResults>) getUIDsAction;
|
||||
- (id <WOActionResults>) getHeadersAction;
|
||||
|
||||
@end
|
||||
|
||||
@@ -623,55 +623,64 @@
|
||||
}
|
||||
*/
|
||||
|
||||
- (NSDictionary *) getUIDsAndHeadersInFolder: (SOGoMailFolder *) mailFolder
|
||||
- (NSDictionary *) getUIDsInFolder: (SOGoMailFolder *) folder
|
||||
withHeaders: (BOOL) includeHeaders
|
||||
{
|
||||
NSMutableDictionary *data;
|
||||
NSArray *uids, *threadedUids, *headers;
|
||||
NSDictionary *data;
|
||||
NSRange r;
|
||||
int count;
|
||||
SOGoMailAccount *account;
|
||||
id quota;
|
||||
|
||||
uids = [self getSortedUIDsInFolder: mailFolder]; // retrieves the form parameters "sort" and "asc"
|
||||
int count;
|
||||
|
||||
// Also retrieve the first headers, up to 'headersPrefetchMaxSize'
|
||||
count = [uids count];
|
||||
if (count > headersPrefetchMaxSize) count = headersPrefetchMaxSize;
|
||||
r = NSMakeRange(0, count);
|
||||
headers = [self getHeadersForUIDs: [[uids flattenedArray] subarrayWithRange: r]
|
||||
inFolder: mailFolder];
|
||||
data = [NSMutableDictionary dictionary];
|
||||
|
||||
// TODO: we might want to flush the caches?
|
||||
//[folder flushMailCaches];
|
||||
[folder expungeLastMarkedFolder];
|
||||
|
||||
// Retrieve messages UIDs using form parameters "sort" and "asc"
|
||||
uids = [self getSortedUIDsInFolder: folder];
|
||||
|
||||
if (includeHeaders)
|
||||
{
|
||||
// Also retrieve the first headers, up to 'headersPrefetchMaxSize'
|
||||
count = [uids count];
|
||||
if (count > headersPrefetchMaxSize) count = headersPrefetchMaxSize;
|
||||
r = NSMakeRange(0, count);
|
||||
headers = [self getHeadersForUIDs: [[uids flattenedArray] subarrayWithRange: r]
|
||||
inFolder: folder];
|
||||
|
||||
[data setObject: headers forKey: @"headers"];
|
||||
}
|
||||
|
||||
if (sortByThread)
|
||||
{
|
||||
// Add threads information
|
||||
threadedUids = [self threadedUIDs: uids];
|
||||
if (threadedUids != nil)
|
||||
uids = threadedUids;
|
||||
else
|
||||
sortByThread = NO;
|
||||
}
|
||||
|
||||
// We also return the inbox quota
|
||||
account = [mailFolder mailAccountFolder];
|
||||
quota = [account getInboxQuota];
|
||||
[data setObject: uids forKey: @"uids"];
|
||||
[data setObject: [NSNumber numberWithBool: sortByThread] forKey: @"threaded"];
|
||||
|
||||
data = [NSDictionary dictionaryWithObjectsAndKeys: uids, @"uids",
|
||||
headers, @"headers",
|
||||
[NSNumber numberWithBool: sortByThread], @"threaded",
|
||||
quota, @"quotas", nil];
|
||||
// We also return the inbox quota
|
||||
account = [folder mailAccountFolder];
|
||||
quota = [account getInboxQuota];
|
||||
[data setObject: quota forKey: @"quotas"];
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/* Module actions */
|
||||
|
||||
- (id <WOActionResults>) getSortedUIDsAction
|
||||
- (id <WOActionResults>) getUIDsAction
|
||||
{
|
||||
NSDictionary *data;
|
||||
NSArray *uids, *threadedUids;
|
||||
NSString *noHeaders;
|
||||
SOGoMailAccount *account;
|
||||
SOGoMailFolder *folder;
|
||||
id quota;
|
||||
WORequest *request;
|
||||
WOResponse *response;
|
||||
|
||||
@@ -681,33 +690,9 @@
|
||||
forKey: @"content-type"];
|
||||
folder = [self clientObject];
|
||||
|
||||
// TODO: we might want to flush the caches?
|
||||
//[folder flushMailCaches];
|
||||
[folder expungeLastMarkedFolder];
|
||||
|
||||
noHeaders = [request formValueForKey: @"no_headers"];
|
||||
if ([noHeaders length])
|
||||
{
|
||||
uids = [self getSortedUIDsInFolder: folder];
|
||||
if (sortByThread)
|
||||
{
|
||||
threadedUids = [self threadedUIDs: uids];
|
||||
if (threadedUids != nil)
|
||||
uids = threadedUids;
|
||||
else
|
||||
sortByThread = NO;
|
||||
}
|
||||
|
||||
// We also return the inbox quota
|
||||
account = [folder mailAccountFolder];
|
||||
quota = [account getInboxQuota];
|
||||
|
||||
data = [NSDictionary dictionaryWithObjectsAndKeys: uids, @"uids",
|
||||
[NSNumber numberWithBool: sortByThread], @"threaded",
|
||||
quota, @"quotas", nil];
|
||||
}
|
||||
else
|
||||
data = [self getUIDsAndHeadersInFolder: folder];
|
||||
data = [self getUIDsInFolder: folder
|
||||
withHeaders: ([noHeaders length] == 0)];
|
||||
|
||||
[response appendContentString: [data jsonRepresentation]];
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@
|
||||
account = [accounts lookupName: @"0" inContext: context acquire: NO];
|
||||
inbox = [account inboxFolderInContext: context];
|
||||
|
||||
data = [actions getUIDsAndHeadersInFolder: inbox];
|
||||
data = [actions getUIDsInFolder: inbox withHeaders: YES];
|
||||
|
||||
return [data jsonRepresentation];
|
||||
}
|
||||
|
||||
@@ -590,9 +590,6 @@ static NSString *mailETag = nil;
|
||||
inContext: (WOContext *) _ctx
|
||||
{
|
||||
UIxMailRenderingContext *mctx;
|
||||
WORequest *request;
|
||||
|
||||
request = [_ctx request];
|
||||
|
||||
[[_ctx response] setHeader:mailETag forKey:@"etag"];
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
uids = {
|
||||
protectedBy = "<public>";
|
||||
actionClass = "UIxMailListActions";
|
||||
actionName = "getSortedUIDs";
|
||||
actionName = "getUIDs";
|
||||
};
|
||||
headers = {
|
||||
protectedBy = "<public>";
|
||||
|
||||
@@ -14,7 +14,6 @@ var Mailer = {
|
||||
cachedMessages: new Array(),
|
||||
foldersStateTimer: false,
|
||||
popups: new Array(),
|
||||
quotas: null,
|
||||
|
||||
dataTable: null,
|
||||
dataSources: new Hash(),
|
||||
@@ -524,11 +523,14 @@ function deleteSelectedMessages(sender) {
|
||||
}
|
||||
|
||||
function deleteSelectedMessagesCallback(http) {
|
||||
if (http.status == 200) {
|
||||
if (isHttpStatus204(http.status) || http.status == 200) {
|
||||
var data = http.callbackData;
|
||||
var rdata = http.responseText.evalJSON(true);
|
||||
if (rdata.quotas && data["mailbox"].startsWith('/0/'))
|
||||
updateQuotas(rdata.quotas);
|
||||
if (http.status == 200) {
|
||||
// The answer contains quota information
|
||||
var rdata = http.responseText.evalJSON(true);
|
||||
if (rdata.quotas && data["mailbox"].startsWith('/0/'))
|
||||
updateQuotas(rdata.quotas);
|
||||
}
|
||||
if (data["refreshUnseenCount"])
|
||||
// TODO : the unseen count should be returned when calling the batchDelete remote action,
|
||||
// in order to avoid this extra AJAX call.
|
||||
@@ -821,7 +823,7 @@ function openMailbox(mailbox, reload) {
|
||||
if (inboxData) {
|
||||
// Use UIDs and headers from the WOX template; this only
|
||||
// happens once and only with the inbox
|
||||
dataSource.init(inboxData['uids'], inboxData['threaded'], inboxData['headers']);
|
||||
dataSource.init(inboxData['uids'], inboxData['threaded'], inboxData['headers'], inboxData['quotas']);
|
||||
inboxData = null; // invalidate this initial lookup
|
||||
}
|
||||
else
|
||||
@@ -2067,14 +2069,12 @@ function updateMailboxTreeInPage() {
|
||||
}
|
||||
}
|
||||
|
||||
updateQuotas();
|
||||
//updateQuotas();
|
||||
}
|
||||
|
||||
function updateQuotas(quotas) {
|
||||
if (quotas)
|
||||
Mailer.quotas = quotas;
|
||||
if (Mailer.quotas && parseInt(Mailer.quotas.maxQuota) > 0) {
|
||||
log ("updating quotas " + Mailer.quotas.usedSpace + "/" + Mailer.quotas.maxQuota);
|
||||
if (quotas && parseInt(quotas.maxQuota) > 0) {
|
||||
log ("updating quotas " + quotas.usedSpace + "/" + quotas.maxQuota);
|
||||
var treeContent = $("folderTreeContent");
|
||||
var tree = $("mailboxTree");
|
||||
var quotaDiv = $("quotaIndicator");
|
||||
@@ -2082,13 +2082,13 @@ function updateQuotas(quotas) {
|
||||
treeContent.removeChild(quotaDiv);
|
||||
}
|
||||
// Build quota indicator, show values in MB
|
||||
var percents = (Math.round(Mailer.quotas.usedSpace * 10000
|
||||
/ Mailer.quotas.maxQuota)
|
||||
var percents = (Math.round(quotas.usedSpace * 10000
|
||||
/ quotas.maxQuota)
|
||||
/ 100);
|
||||
var level = (percents > 85)? "alert" : (percents > 70)? "warn" : "ok";
|
||||
var format = _("quotasFormat");
|
||||
var text = format.formatted(percents,
|
||||
Math.round(Mailer.quotas.maxQuota/10.24)/100);
|
||||
Math.round(quotas.maxQuota/10.24)/100);
|
||||
quotaDiv = new Element('div', { 'id': 'quotaIndicator',
|
||||
'class': 'quota',
|
||||
'info': text });
|
||||
@@ -2215,9 +2215,6 @@ function buildMailboxes(accountIdx, encoded) {
|
||||
var mailboxes = data.mailboxes;
|
||||
var unseen = (data.status? data.status.unseen : 0);
|
||||
|
||||
if (accountIdx == 0 && data.quotas)
|
||||
Mailer.quotas = data.quotas;
|
||||
|
||||
for (var i = 0; i < mailboxes.length; i++) {
|
||||
var currentNode = account;
|
||||
var names = mailboxes[i].path.split("/");
|
||||
|
||||
Reference in New Issue
Block a user