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:
Francis Lachapelle
2011-07-08 17:38:27 +00:00
parent 3f6bca5d1e
commit 3d3a5e37ba
12 changed files with 77 additions and 113 deletions
+1 -5
View File
@@ -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"
+9 -25
View File
@@ -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;
}
+10 -4
View File
@@ -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
+3 -2
View File
@@ -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
+34 -49
View File
@@ -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]];
+1 -1
View File
@@ -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];
}
-3
View File
@@ -590,9 +590,6 @@ static NSString *mailETag = nil;
inContext: (WOContext *) _ctx
{
UIxMailRenderingContext *mctx;
WORequest *request;
request = [_ctx request];
[[_ctx response] setHeader:mailETag forKey:@"etag"];
+1 -1
View File
@@ -80,7 +80,7 @@
uids = {
protectedBy = "<public>";
actionClass = "UIxMailListActions";
actionName = "getSortedUIDs";
actionName = "getUIDs";
};
headers = {
protectedBy = "<public>";