Monotone-Parent: 351c343491eb5005eeec456fd7caf97dd6c27489
Monotone-Revision: f445ddae9e72252fda8d9a7adee3c89ef2f81c87 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-05-28T19:05:00 Monotone-Branch: ca.inverse.sogomaint-2.0.2
parent
85d84068ac
commit
52c2283eba
10
ChangeLog
10
ChangeLog
|
@ -1,7 +1,17 @@
|
||||||
2007-05-28 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
2007-05-28 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||||
|
|
||||||
|
* UI/MailerUI/UIxMailFolderActions.m ([UIxMailFolderActions
|
||||||
|
-emptyTrashAction]): new method inspired by a similar one from
|
||||||
|
UIxMailListView, to which we added the ability to remove
|
||||||
|
subfolders.
|
||||||
|
|
||||||
|
* UI/MailerUI/UIxMailListView.m ([-emptyTrashAction]): removed
|
||||||
|
method. Replaced with a similar one in UIxMailFolderActions.
|
||||||
|
|
||||||
* UI/MailerUI/UIxMailFolderActions.m ([UIxMailFolderActions
|
* UI/MailerUI/UIxMailFolderActions.m ([UIxMailFolderActions
|
||||||
-renameFolderAction]): implemented method.
|
-renameFolderAction]): implemented method.
|
||||||
|
([UIxMailFolderActions -deleteFolderAction]): no longer delete the
|
||||||
|
specified folder. Instead, we put it in the trash folder.
|
||||||
|
|
||||||
* UI/MailerUI/UIxMailListView.m ([-createFolderAction]): removed
|
* UI/MailerUI/UIxMailListView.m ([-createFolderAction]): removed
|
||||||
method, replaced with a similar method in the new
|
method, replaced with a similar method in the new
|
||||||
|
|
|
@ -32,8 +32,6 @@
|
||||||
NSString *draftFolderName;
|
NSString *draftFolderName;
|
||||||
NSString *sentFolderName;
|
NSString *sentFolderName;
|
||||||
NSString *trashFolderName;
|
NSString *trashFolderName;
|
||||||
NSString *sharedFolderName;
|
|
||||||
NSString *otherUsersFolderName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (WOResponse *) listMailboxesAction;
|
- (WOResponse *) listMailboxesAction;
|
||||||
|
|
|
@ -87,30 +87,17 @@
|
||||||
|
|
||||||
- (WOResponse *) listMailboxesAction
|
- (WOResponse *) listMailboxesAction
|
||||||
{
|
{
|
||||||
SOGoMailAccount *clientObject;
|
SOGoMailAccount *co;
|
||||||
NSArray *rawFolders, *folders, *mainFolders;
|
NSArray *rawFolders, *folders;
|
||||||
NSMutableArray *newFolders;
|
|
||||||
WOResponse *response;
|
WOResponse *response;
|
||||||
|
|
||||||
clientObject = [self clientObject];
|
co = [self clientObject];
|
||||||
rawFolders = [[clientObject imap4Connection]
|
draftFolderName = [co draftsFolderNameInContext: context];
|
||||||
allFoldersForURL: [clientObject imap4URL]];
|
sentFolderName = [co sentFolderNameInContext: context];
|
||||||
|
trashFolderName = [co trashFolderNameInContext: context];
|
||||||
|
|
||||||
draftFolderName = [clientObject draftsFolderNameInContext: context];
|
rawFolders = [co allFolderPaths];
|
||||||
sentFolderName = [clientObject sentFolderNameInContext: context];
|
folders = [self _jsonFolders: [rawFolders objectEnumerator]];
|
||||||
trashFolderName = [clientObject trashFolderNameInContext: context];
|
|
||||||
sharedFolderName = [clientObject sharedFolderName];
|
|
||||||
otherUsersFolderName = [clientObject otherUsersFolderName];
|
|
||||||
mainFolders = [NSArray arrayWithObjects: @"INBOX", draftFolderName,
|
|
||||||
sentFolderName, trashFolderName, nil];
|
|
||||||
|
|
||||||
newFolders = [NSMutableArray arrayWithArray: rawFolders];
|
|
||||||
[newFolders removeObjectsInArray: mainFolders];
|
|
||||||
[newFolders sortUsingSelector: @selector (caseInsensitiveCompare:)];
|
|
||||||
[newFolders replaceObjectsInRange: NSMakeRange (0, 0)
|
|
||||||
withObjectsFromArray: mainFolders];
|
|
||||||
|
|
||||||
folders = [self _jsonFolders: [newFolders objectEnumerator]];
|
|
||||||
|
|
||||||
response = [context response];
|
response = [context response];
|
||||||
[response appendContentString: [folders jsonRepresentation]];
|
[response appendContentString: [folders jsonRepresentation]];
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
#import <NGImap4/NGImap4Connection.h>
|
#import <NGImap4/NGImap4Connection.h>
|
||||||
|
|
||||||
#import <SoObjects/Mailer/SOGoMailFolder.h>
|
#import <SoObjects/Mailer/SOGoMailFolder.h>
|
||||||
|
#import <SoObjects/Mailer/SOGoTrashFolder.h>
|
||||||
|
#import <SoObjects/Mailer/SOGoMailAccount.h>
|
||||||
|
|
||||||
#import "UIxMailFolderActions.h"
|
#import "UIxMailFolderActions.h"
|
||||||
|
|
||||||
|
@ -73,18 +75,14 @@
|
||||||
renamedTo: (NSString *) folderName
|
renamedTo: (NSString *) folderName
|
||||||
{
|
{
|
||||||
NSString *path;
|
NSString *path;
|
||||||
NSMutableArray *pathArray;
|
|
||||||
NSURL *destURL;
|
NSURL *destURL;
|
||||||
|
|
||||||
path = [srcURL path];
|
path = [[srcURL path] stringByDeletingLastPathComponent];
|
||||||
pathArray = [NSMutableArray arrayWithArray:
|
|
||||||
[path componentsSeparatedByString: @"/"]];
|
|
||||||
[pathArray replaceObjectAtIndex: [pathArray count] - 1
|
|
||||||
withObject: folderName];
|
|
||||||
|
|
||||||
destURL = [[NSURL alloc] initWithScheme: [srcURL scheme]
|
destURL = [[NSURL alloc] initWithScheme: [srcURL scheme]
|
||||||
host: [srcURL host]
|
host: [srcURL host]
|
||||||
path: [pathArray componentsJoinedByString: @"/"]];
|
path: [NSString stringWithFormat: @"%@%@",
|
||||||
|
path, folderName]];
|
||||||
[destURL autorelease];
|
[destURL autorelease];
|
||||||
|
|
||||||
return destURL;
|
return destURL;
|
||||||
|
@ -127,26 +125,89 @@
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSURL *) _trashedURLOfFolder: (NSURL *) srcURL
|
||||||
|
withCO: (SOGoMailFolder *) co
|
||||||
|
{
|
||||||
|
NSURL *destURL;
|
||||||
|
NSString *trashFolderName, *folderName;
|
||||||
|
|
||||||
|
folderName = [[srcURL path] lastPathComponent];
|
||||||
|
trashFolderName
|
||||||
|
= [[co mailAccountFolder] trashFolderNameInContext: context];
|
||||||
|
|
||||||
|
destURL = [[NSURL alloc] initWithScheme: [srcURL scheme]
|
||||||
|
host: [srcURL host]
|
||||||
|
path: [NSString stringWithFormat: @"/%@/%@",
|
||||||
|
trashFolderName, folderName]];
|
||||||
|
[destURL autorelease];
|
||||||
|
|
||||||
|
return destURL;
|
||||||
|
}
|
||||||
|
|
||||||
- (WOResponse *) deleteFolderAction
|
- (WOResponse *) deleteFolderAction
|
||||||
{
|
{
|
||||||
SOGoMailFolder *co;
|
SOGoMailFolder *co;
|
||||||
WOResponse *response;
|
WOResponse *response;
|
||||||
NGImap4Connection *connection;
|
NGImap4Connection *connection;
|
||||||
NSException *error;
|
NSException *error;
|
||||||
|
NSURL *srcURL, *destURL;
|
||||||
|
|
||||||
co = [self clientObject];
|
co = [self clientObject];
|
||||||
response = [context response];
|
response = [context response];
|
||||||
connection = [co imap4Connection];
|
connection = [co imap4Connection];
|
||||||
error = [connection deleteMailboxAtURL: [co imap4URL]];
|
srcURL = [co imap4URL];
|
||||||
|
destURL = [self _trashedURLOfFolder: srcURL
|
||||||
|
withCO: co];
|
||||||
|
connection = [co imap4Connection];
|
||||||
|
error = [connection moveMailboxAtURL: srcURL
|
||||||
|
toURL: destURL];
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
[response setStatus: 403];
|
[response setStatus: 403];
|
||||||
[response appendContentString: @"Unable to delete folder."];
|
[response appendContentString: @"Unable to move folder."];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
[response setStatus: 204];
|
[response setStatus: 204];
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (WOResponse *) emptyTrashAction
|
||||||
|
{
|
||||||
|
NSException *error;
|
||||||
|
SOGoTrashFolder *co;
|
||||||
|
NSEnumerator *subfolders;
|
||||||
|
WOResponse *response;
|
||||||
|
NGImap4Connection *connection;
|
||||||
|
NSURL *currentURL;
|
||||||
|
|
||||||
|
co = [self clientObject];
|
||||||
|
response = [context response];
|
||||||
|
|
||||||
|
error = [co addFlagsToAllMessages: @"deleted"];
|
||||||
|
if (!error)
|
||||||
|
error = [co expunge];
|
||||||
|
if (!error)
|
||||||
|
{
|
||||||
|
[co flushMailCaches];
|
||||||
|
connection = [co imap4Connection];
|
||||||
|
subfolders = [[co subfoldersURL] objectEnumerator];
|
||||||
|
currentURL = [subfolders nextObject];
|
||||||
|
while (currentURL)
|
||||||
|
{
|
||||||
|
[connection deleteMailboxAtURL: currentURL];
|
||||||
|
currentURL = [subfolders nextObject];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (error)
|
||||||
|
{
|
||||||
|
[response setStatus: 403];
|
||||||
|
[response appendContentString: @"Unable to empty the trash folder."];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
[response setStatus: 204];
|
||||||
|
|
||||||
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -539,46 +539,6 @@ static int attachmentFlagSize = 8096;
|
||||||
return [self redirectToLocation:@"view"];
|
return [self redirectToLocation:@"view"];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) emptyTrashAction
|
|
||||||
{
|
|
||||||
// TODO: we might want to flush the caches?
|
|
||||||
NSException *error;
|
|
||||||
id client;
|
|
||||||
|
|
||||||
if ((client = [self clientObject]) == nil) {
|
|
||||||
error = [NSException exceptionWithHTTPStatus:404 /* Not Found */
|
|
||||||
reason:@"did not find mail folder"];
|
|
||||||
return [self redirectToViewWithError:error];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (![client isKindOfClass:NSClassFromString(@"SOGoTrashFolder")]) {
|
|
||||||
/* would be better to move the method to an own class, but well .. */
|
|
||||||
error = [NSException exceptionWithHTTPStatus:400 /* Bad Request */
|
|
||||||
reason:@"method cannot be invoked on "
|
|
||||||
@"the specified object"];
|
|
||||||
return [self redirectToViewWithError:error];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* mark all as deleted */
|
|
||||||
|
|
||||||
[self logWithFormat:@"TODO: must mark all as deleted for empty-trash"];
|
|
||||||
|
|
||||||
error = [[self clientObject] addFlagsToAllMessages:@"deleted"];
|
|
||||||
if (error != nil)
|
|
||||||
// TODO: improve error
|
|
||||||
return [self redirectToViewWithError:error];
|
|
||||||
|
|
||||||
/* expunge */
|
|
||||||
|
|
||||||
if ((error = [[self clientObject] expunge]) != nil)
|
|
||||||
// TODO: improve error
|
|
||||||
return [self redirectToViewWithError:error];
|
|
||||||
|
|
||||||
if ([client respondsToSelector:@selector(flushMailCaches)])
|
|
||||||
[client flushMailCaches];
|
|
||||||
return [self redirectToLocation:@"view"];
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
/* UIxMailListView */
|
/* UIxMailListView */
|
||||||
|
|
|
@ -164,8 +164,8 @@
|
||||||
methods = {
|
methods = {
|
||||||
emptyTrash = {
|
emptyTrash = {
|
||||||
protectedBy = "View";
|
protectedBy = "View";
|
||||||
pageName = "UIxMailListView";
|
actionClass = "UIxMailFolderActions";
|
||||||
actionName = "emptyTrash";
|
actionName = "emptyTrash";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1261,6 +1261,12 @@ function onMenuDeleteFolder(event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onMenuEmptyTrash(event) {
|
||||||
|
var folderID = document.menuTarget.getAttribute("dataname");
|
||||||
|
var urlstr = URLForFolderID(folderID) + "/emptyTrash";
|
||||||
|
triggerAjaxRequest(urlstr, folderOperationCallback);
|
||||||
|
}
|
||||||
|
|
||||||
function folderOperationCallback(http) {
|
function folderOperationCallback(http) {
|
||||||
if (http.readyState == 4
|
if (http.readyState == 4
|
||||||
&& http.status == 204)
|
&& http.status == 204)
|
||||||
|
@ -1282,7 +1288,8 @@ function initializeMenus() {
|
||||||
onMenuSharing);
|
onMenuSharing);
|
||||||
menus["trashIconMenu"] = new Array(null, null, null, "-", null,
|
menus["trashIconMenu"] = new Array(null, null, null, "-", null,
|
||||||
onMenuCreateFolder, null,
|
onMenuCreateFolder, null,
|
||||||
null, "-", null, onMenuSharing);
|
onMenuEmptyTrash, "-", null,
|
||||||
|
onMenuSharing);
|
||||||
menus["mailboxIconMenu"] = new Array(null, null, null, "-", null,
|
menus["mailboxIconMenu"] = new Array(null, null, null, "-", null,
|
||||||
onMenuCreateFolder,
|
onMenuCreateFolder,
|
||||||
onMenuRenameFolder,
|
onMenuRenameFolder,
|
||||||
|
|
Loading…
Reference in New Issue