mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-08-25 16:33:22 +00:00
merge of 'baf4c7f8461dec960162ae0da21047d576421c14'
and 'fefb3f05edb2d5e5ba63661ae145d0369e47b444' Monotone-Parent: baf4c7f8461dec960162ae0da21047d576421c14 Monotone-Parent: fefb3f05edb2d5e5ba63661ae145d0369e47b444 Monotone-Revision: 9ef1fb2c66953b8ada0d55d0eec183621a71ebab Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-09-11T20:58:35 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -108,8 +108,7 @@
|
||||
rawFolders = [co allFolderPaths];
|
||||
folders = [self _jsonFolders: [rawFolders objectEnumerator]];
|
||||
|
||||
response = [context response];
|
||||
[response setStatus: 200];
|
||||
response = [self responseWithStatus: 200];
|
||||
[response setHeader: @"text/plain; charset=utf-8"
|
||||
forKey: @"content-type"];
|
||||
[response appendContentString: [folders jsonRepresentation]];
|
||||
|
||||
@@ -94,10 +94,7 @@
|
||||
|
||||
response = [[self clientObject] trashInContext: context];
|
||||
if (!response)
|
||||
{
|
||||
response = [context response];
|
||||
[response setStatus: 204];
|
||||
}
|
||||
response = [self responseWith204];
|
||||
|
||||
return response;
|
||||
}
|
||||
@@ -113,10 +110,7 @@
|
||||
response = [[self clientObject] moveToFolderNamed: destinationFolder
|
||||
inContext: context];
|
||||
if (!response)
|
||||
{
|
||||
response = [context response];
|
||||
[response setStatus: 204];
|
||||
}
|
||||
response = [self responseWith204];
|
||||
}
|
||||
else
|
||||
response = [NSException exceptionWithHTTPStatus: 500 /* Server Error */
|
||||
@@ -125,6 +119,30 @@
|
||||
return response;
|
||||
}
|
||||
|
||||
/* active message */
|
||||
|
||||
- (id) markMessageUnreadAction
|
||||
{
|
||||
id response;
|
||||
|
||||
response = [[self clientObject] removeFlags: @"seen"];
|
||||
if (!response)
|
||||
response = [self responseWith204];
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
- (id) markMessageReadAction
|
||||
{
|
||||
id response;
|
||||
|
||||
response = [[self clientObject] addFlags: @"seen"];
|
||||
if (!response)
|
||||
response = [self responseWith204];
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/* SOGoDraftObject */
|
||||
- (WOResponse *) editAction
|
||||
{
|
||||
@@ -158,10 +176,7 @@
|
||||
if (error)
|
||||
response = error;
|
||||
else
|
||||
{
|
||||
response = [context response];
|
||||
[response setStatus: 204];
|
||||
}
|
||||
response = [self responseWith204];
|
||||
|
||||
return response;
|
||||
}
|
||||
@@ -171,17 +186,15 @@
|
||||
WOResponse *response;
|
||||
NSString *filename;
|
||||
|
||||
response = [context response];
|
||||
|
||||
filename = [[context request] formValueForKey: @"filename"];
|
||||
if ([filename length] > 0)
|
||||
{
|
||||
response = [self responseWith204];
|
||||
[[self clientObject] deleteAttachmentWithName: filename];
|
||||
[response setStatus: 204];
|
||||
}
|
||||
else
|
||||
{
|
||||
[response setStatus: 500];
|
||||
response = [self responseWithStatus: 500];
|
||||
[response appendContentString: @"How did you end up here?"];
|
||||
}
|
||||
|
||||
|
||||
@@ -404,10 +404,7 @@ static NSArray *infoKeys = nil;
|
||||
{
|
||||
result = [[self clientObject] save];
|
||||
if (!result)
|
||||
{
|
||||
result = [context response];
|
||||
[result setStatus: 204];
|
||||
}
|
||||
result = [self responseWith204];
|
||||
}
|
||||
else
|
||||
result = [self failedToSaveFormResponse];
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
#import <SoObjects/Mailer/SOGoMailAccount.h>
|
||||
#import <SoObjects/SOGo/NSObject+Utilities.h>
|
||||
|
||||
#import <UI/Common/WODirectAction+SOGo.h>
|
||||
|
||||
#import "UIxMailFolderActions.h"
|
||||
|
||||
@implementation UIxMailFolderActions
|
||||
@@ -49,7 +51,6 @@
|
||||
NSString *folderName;
|
||||
|
||||
co = [self clientObject];
|
||||
response = [context response];
|
||||
|
||||
folderName = [[context request] formValueForKey: @"name"];
|
||||
if ([folderName length] > 0)
|
||||
@@ -58,15 +59,15 @@
|
||||
error = [connection createMailbox: folderName atURL: [co imap4URL]];
|
||||
if (error)
|
||||
{
|
||||
[response setStatus: 500];
|
||||
response = [self responseWithStatus: 500];
|
||||
[response appendContentString: @"Unable to create folder."];
|
||||
}
|
||||
else
|
||||
[response setStatus: 204];
|
||||
response = [self responseWith204];
|
||||
}
|
||||
else
|
||||
{
|
||||
[response setStatus: 500];
|
||||
response = [self responseWithStatus: 500];
|
||||
[response appendContentString: @"Missing 'name' parameter."];
|
||||
}
|
||||
|
||||
@@ -100,7 +101,6 @@
|
||||
NSURL *srcURL, *destURL;
|
||||
|
||||
co = [self clientObject];
|
||||
response = [context response];
|
||||
|
||||
folderName = [[context request] formValueForKey: @"name"];
|
||||
if ([folderName length] > 0)
|
||||
@@ -112,15 +112,15 @@
|
||||
toURL: destURL];
|
||||
if (error)
|
||||
{
|
||||
[response setStatus: 500];
|
||||
response = [self responseWithStatus: 500];
|
||||
[response appendContentString: @"Unable to rename folder."];
|
||||
}
|
||||
else
|
||||
[response setStatus: 204];
|
||||
response = [self responseWith204];
|
||||
}
|
||||
else
|
||||
{
|
||||
[response setStatus: 500];
|
||||
response = [self responseWithStatus: 500];
|
||||
[response appendContentString: @"Missing 'name' parameter."];
|
||||
}
|
||||
|
||||
@@ -154,7 +154,6 @@
|
||||
NSURL *srcURL, *destURL;
|
||||
|
||||
co = [self clientObject];
|
||||
response = [context response];
|
||||
connection = [co imap4Connection];
|
||||
srcURL = [co imap4URL];
|
||||
destURL = [self _trashedURLOfFolder: srcURL
|
||||
@@ -164,11 +163,11 @@
|
||||
toURL: destURL];
|
||||
if (error)
|
||||
{
|
||||
[response setStatus: 500];
|
||||
response = [self responseWithStatus: 500];
|
||||
[response appendContentString: @"Unable to move folder."];
|
||||
}
|
||||
else
|
||||
[response setStatus: 204];
|
||||
response = [self responseWith204];
|
||||
|
||||
return response;
|
||||
}
|
||||
@@ -180,18 +179,17 @@
|
||||
WOResponse *response;
|
||||
|
||||
co = [self clientObject];
|
||||
response = [context response];
|
||||
|
||||
error = [co expunge];
|
||||
if (error)
|
||||
{
|
||||
[response setStatus: 500];
|
||||
response = [self responseWithStatus: 500];
|
||||
[response appendContentString: @"Unable to expunge folder."];
|
||||
}
|
||||
else
|
||||
{
|
||||
[co flushMailCaches];
|
||||
[response setStatus: 204];
|
||||
response = [self responseWith204];
|
||||
}
|
||||
|
||||
return response;
|
||||
@@ -207,7 +205,6 @@
|
||||
NSURL *currentURL;
|
||||
|
||||
co = [self clientObject];
|
||||
response = [context response];
|
||||
|
||||
error = [co addFlagsToAllMessages: @"deleted"];
|
||||
if (!error)
|
||||
@@ -226,11 +223,11 @@
|
||||
}
|
||||
if (error)
|
||||
{
|
||||
[response setStatus: 500];
|
||||
response = [self responseWithStatus: 500];
|
||||
[response appendContentString: @"Unable to empty the trash folder."];
|
||||
}
|
||||
else
|
||||
[response setStatus: 204];
|
||||
response = [self responseWith204];
|
||||
|
||||
return response;
|
||||
}
|
||||
@@ -242,7 +239,6 @@
|
||||
WOResponse *response;
|
||||
SOGoMailFolder *clientObject;
|
||||
|
||||
response = [context response];
|
||||
mailInvitationParam
|
||||
= [[context request] formValueForKey: @"mail-invitation"];
|
||||
if ([mailInvitationParam boolValue])
|
||||
@@ -257,7 +253,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
[response setStatus: 500];
|
||||
response = [self responseWithStatus: 500];
|
||||
[response appendContentString: @"How did you end up here?"];
|
||||
}
|
||||
|
||||
@@ -283,8 +279,7 @@
|
||||
NGImap4Client *client;
|
||||
NSString *responseString;
|
||||
|
||||
response = [context response];
|
||||
[response setStatus: 200];
|
||||
response = [self responseWithStatus: 200];
|
||||
[response setHeader: @"text/plain; charset=UTF-8"
|
||||
forKey: @"content-type"];
|
||||
|
||||
|
||||
@@ -221,10 +221,24 @@ static int attachmentFlagSize = 8096;
|
||||
|
||||
- (NSArray *) sortedUIDs
|
||||
{
|
||||
EOQualifier *fetchQualifier, *notDeleted;
|
||||
if (!sortedUIDs)
|
||||
{
|
||||
notDeleted = [EOQualifier qualifierWithQualifierFormat:
|
||||
@"(not (flags = %@))",
|
||||
@"deleted"];
|
||||
if (qualifier)
|
||||
{
|
||||
fetchQualifier = [[EOAndQualifier alloc] initWithQualifiers:
|
||||
notDeleted, qualifier,
|
||||
nil];
|
||||
[fetchQualifier autorelease];
|
||||
}
|
||||
else
|
||||
fetchQualifier = notDeleted;
|
||||
|
||||
sortedUIDs
|
||||
= [[self clientObject] fetchUIDsMatchingQualifier: qualifier
|
||||
= [[self clientObject] fetchUIDsMatchingQualifier: fetchQualifier
|
||||
sortOrdering: [self imap4SortOrdering]];
|
||||
[sortedUIDs retain];
|
||||
}
|
||||
@@ -407,36 +421,8 @@ static int attachmentFlagSize = 8096;
|
||||
return [self redirectToLocation:url];
|
||||
}
|
||||
|
||||
/* active message */
|
||||
|
||||
- (SOGoMailObject *) lookupActiveMessage
|
||||
{
|
||||
NSString *uid;
|
||||
|
||||
if ((uid = [[context request] formValueForKey: @"uid"]) == nil)
|
||||
return nil;
|
||||
|
||||
return [[self clientObject] lookupName: uid
|
||||
inContext: context
|
||||
acquire: NO];
|
||||
}
|
||||
|
||||
/* actions */
|
||||
|
||||
- (BOOL) isJavaScriptRequest
|
||||
{
|
||||
return [[[context request] formValueForKey:@"jsonly"] boolValue];
|
||||
}
|
||||
|
||||
- (id) javaScriptOK
|
||||
{
|
||||
WOResponse *r;
|
||||
|
||||
r = [context response];
|
||||
[r setStatus:200 /* OK */];
|
||||
return r;
|
||||
}
|
||||
|
||||
- (int) firstMessageOfPageFor: (int) messageNbr
|
||||
{
|
||||
NSArray *messageNbrs;
|
||||
@@ -462,8 +448,7 @@ static int attachmentFlagSize = 8096;
|
||||
|
||||
if ([criteria isEqualToString: @"subject"])
|
||||
qualifier = [EOQualifier qualifierWithQualifierFormat:
|
||||
@"(subject doesContain: %@)",
|
||||
value];
|
||||
@"(subject doesContain: %@)", value];
|
||||
else if ([criteria isEqualToString: @"sender"])
|
||||
qualifier = [EOQualifier qualifierWithQualifierFormat:
|
||||
@"(sender doesContain: %@)", value];
|
||||
@@ -510,39 +495,6 @@ static int attachmentFlagSize = 8096;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) viewAction
|
||||
{
|
||||
return [self defaultAction];
|
||||
}
|
||||
|
||||
- (id) markMessageUnreadAction
|
||||
{
|
||||
NSException *error;
|
||||
|
||||
if ((error = [[self lookupActiveMessage] removeFlags:@"seen"]) != nil)
|
||||
// TODO: improve error handling
|
||||
return error;
|
||||
|
||||
if ([self isJavaScriptRequest])
|
||||
return [self javaScriptOK];
|
||||
|
||||
return [self redirectToLocation:@"view"];
|
||||
}
|
||||
|
||||
- (id) markMessageReadAction
|
||||
{
|
||||
NSException *error;
|
||||
|
||||
if ((error = [[self lookupActiveMessage] addFlags:@"seen"]) != nil)
|
||||
// TODO: improve error handling
|
||||
return error;
|
||||
|
||||
if ([self isJavaScriptRequest])
|
||||
return [self javaScriptOK];
|
||||
|
||||
return [self redirectToLocation:@"view"];
|
||||
}
|
||||
|
||||
- (id) getMailAction
|
||||
{
|
||||
// TODO: we might want to flush the caches?
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#import <Foundation/NSString.h>
|
||||
#import <SoObjects/Mailer/SOGoMailObject.h>
|
||||
|
||||
#import <UI/Common/WODirectAction+SOGo.h>
|
||||
|
||||
#import "UIxMailSourceView.h"
|
||||
|
||||
@implementation UIxMailSourceView
|
||||
@@ -36,8 +38,7 @@
|
||||
|
||||
source = [[self clientObject] contentAsString];
|
||||
|
||||
response = [context response];
|
||||
[response setStatus: 200];
|
||||
response = [self responseWithStatus: 200];
|
||||
[response setHeader: @"text/plain; charset=utf-8"
|
||||
forKey: @"content-type"];
|
||||
[response appendContentString: source];
|
||||
|
||||
+30
-25
@@ -142,37 +142,42 @@ static NSString *mailETag = nil;
|
||||
|
||||
- (id) defaultAction
|
||||
{
|
||||
WOResponse *response;
|
||||
NSString *s;
|
||||
|
||||
/* check etag to see whether we really must rerender */
|
||||
if (mailETag != nil ) {
|
||||
/*
|
||||
Note: There is one thing which *can* change for an existing message,
|
||||
those are the IMAP4 flags (and annotations, which we do not use).
|
||||
Since we don't render the flags, it should be OK, if this changes
|
||||
we must embed the flagging into the etag.
|
||||
*/
|
||||
NSString *s;
|
||||
|
||||
if ((s = [[context request] headerForKey:@"if-none-match"])) {
|
||||
if ([s rangeOfString:mailETag].length > 0) { /* not perfectly correct */
|
||||
/* client already has the proper entity */
|
||||
// [self logWithFormat:@"MATCH: %@ (tag %@)", s, mailETag];
|
||||
|
||||
if (![[self clientObject] doesMailExist]) {
|
||||
return [NSException exceptionWithHTTPStatus:404 /* Not Found */
|
||||
reason:@"message got deleted"];
|
||||
if (mailETag)
|
||||
{
|
||||
/*
|
||||
Note: There is one thing which *can* change for an existing message,
|
||||
those are the IMAP4 flags (and annotations, which we do not use).
|
||||
Since we don't render the flags, it should be OK, if this changes
|
||||
we must embed the flagging into the etag.
|
||||
*/
|
||||
s = [[context request] headerForKey: @"if-none-match"];
|
||||
if (s)
|
||||
{
|
||||
if ([s rangeOfString:mailETag].length > 0) /* not perfectly correct */
|
||||
{
|
||||
/* client already has the proper entity */
|
||||
// [self logWithFormat:@"MATCH: %@ (tag %@)", s, mailETag];
|
||||
|
||||
if (![[self clientObject] doesMailExist]) {
|
||||
return [NSException exceptionWithHTTPStatus:404 /* Not Found */
|
||||
reason:@"message got deleted"];
|
||||
}
|
||||
|
||||
response = [context response];
|
||||
[response setStatus: 304 /* Not Modified */];
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
[[context response] setStatus:304 /* Not Modified */];
|
||||
return [context response];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ([self message] == nil) {
|
||||
// TODO: redirect to proper error
|
||||
if (![self message]) // TODO: redirect to proper error
|
||||
return [NSException exceptionWithHTTPStatus:404 /* Not Found */
|
||||
reason:@"did not find specified message!"];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
+10
-10
@@ -115,16 +115,6 @@
|
||||
protectedBy = "View";
|
||||
pageName = "UIxMailListView";
|
||||
};
|
||||
markMessageUnread = {
|
||||
protectedBy = "View";
|
||||
pageName = "UIxMailListView";
|
||||
actionName = "markMessageUnread";
|
||||
};
|
||||
markMessageRead = {
|
||||
protectedBy = "View";
|
||||
pageName = "UIxMailListView";
|
||||
actionName = "markMessageRead";
|
||||
};
|
||||
getMail = {
|
||||
protectedBy = "View";
|
||||
pageName = "UIxMailListView";
|
||||
@@ -235,6 +225,16 @@
|
||||
actionClass = "UIxMailActions";
|
||||
actionName = "forward";
|
||||
};
|
||||
markMessageUnread = {
|
||||
protectedBy = "View";
|
||||
actionClass = "UIxMailActions";
|
||||
actionName = "markMessageUnread";
|
||||
};
|
||||
markMessageRead = {
|
||||
protectedBy = "View";
|
||||
actionClass = "UIxMailActions";
|
||||
actionName = "markMessageRead";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user