From e8cf31b23ad5e679d2b91b93923923ccc7ac5a3e Mon Sep 17 00:00:00 2001 From: helge Date: Sun, 30 Jan 2005 20:24:10 +0000 Subject: [PATCH] implemented basic Sieve script upload git-svn-id: http://svn.opengroupware.org/SOGo/trunk@509 d1b88da0-ebda-0310-925b-ed51d893ca5b --- SOGo/SoObjects/Sieve/ChangeLog | 2 ++ SOGo/SoObjects/Sieve/SOGoSieveScriptObject.m | 32 +++++++++++++++++--- SOGo/SoObjects/Sieve/Version | 3 +- SOGo/UI/Mailer/ChangeLog | 7 +++++ SOGo/UI/Mailer/UIxMailEditor.m | 5 +++ SOGo/UI/Mailer/UIxMailToSelection.wox | 7 +++-- SOGo/UI/Mailer/UIxSieveEditor.m | 8 ++++- SOGo/UI/Mailer/Version | 3 +- SOGo/UI/Mailer/mailer.js | 2 ++ SOGo/UI/Mailer/product.plist | 4 +-- 10 files changed, 62 insertions(+), 11 deletions(-) diff --git a/SOGo/SoObjects/Sieve/ChangeLog b/SOGo/SoObjects/Sieve/ChangeLog index 2706045f..0684990f 100644 --- a/SOGo/SoObjects/Sieve/ChangeLog +++ b/SOGo/SoObjects/Sieve/ChangeLog @@ -1,5 +1,7 @@ 2005-01-30 Helge Hess + * SOGoSieveScriptObject.m: implemented Sieve script upload (v0.9.6) + * some work on script upload (v0.9.5) 2004-12-03 Helge Hess diff --git a/SOGo/SoObjects/Sieve/SOGoSieveScriptObject.m b/SOGo/SoObjects/Sieve/SOGoSieveScriptObject.m index 37ad358b..eebc5df9 100644 --- a/SOGo/SoObjects/Sieve/SOGoSieveScriptObject.m +++ b/SOGo/SoObjects/Sieve/SOGoSieveScriptObject.m @@ -46,14 +46,38 @@ return [[self contentAsString] dataUsingEncoding:NSUTF8StringEncoding]; } +- (NSException *)exceptionForFailedPutResult:(NSDictionary *)_result { + NSString *reason; + + /* Note: valueForKey:@"reason" does not work?! */ + reason = [[_result valueForKey:@"RawResponse"] objectForKey:@"reason"]; + [self logWithFormat:@"REASON: %@", reason]; + if (![reason isNotNull]) + reason = @"Failed to upload Sieve script."; + + return [NSException exceptionWithHTTPStatus:500 /* Server Error */ + reason:reason]; +} + - (NSException *)writeContent:(id)_content { + NGSieveClient *client; + NSDictionary *result; + if (_content == nil) { return [NSException exceptionWithHTTPStatus:400 /* Bad Request */ reason:@"Missing content to write!"]; } - return [NSException exceptionWithHTTPStatus:501 /* Not Implemented */ - reason:@"Does not implement script upload yet!"]; + if ((client = [self sieveClient]) == nil) { + return [NSException exceptionWithHTTPStatus:500 /* Server Error */ + reason:@"Failed to create NGSieveClient object"]; + } + + result = [client putScript:[self nameInContainer] script:_content]; + if (![[result valueForKey:@"result"] boolValue]) + return [self exceptionForFailedPutResult:result]; + + return nil; /* everything is great */ } /* operations */ @@ -95,9 +119,9 @@ - (id)PUTAction:(id)_context { NSException *e; - NSData *content; + NSString *content; - content = [[_context request] content]; + content = [[_context request] contentAsString]; if ((e = [self writeContent:content])) return e; diff --git a/SOGo/SoObjects/Sieve/Version b/SOGo/SoObjects/Sieve/Version index 298ef851..29dc4630 100644 --- a/SOGo/SoObjects/Sieve/Version +++ b/SOGo/SoObjects/Sieve/Version @@ -1,5 +1,6 @@ # Version file -SUBMINOR_VERSION:=5 +SUBMINOR_VERSION:=6 +# v0.9.6 requires libNGMime v4.5.207 # v0.9.1 requires libNGMime v4.3.194 diff --git a/SOGo/UI/Mailer/ChangeLog b/SOGo/UI/Mailer/ChangeLog index 5559e5ef..04b698ec 100644 --- a/SOGo/UI/Mailer/ChangeLog +++ b/SOGo/UI/Mailer/ChangeLog @@ -1,4 +1,11 @@ 2005-01-30 Helge Hess + + * v0.9.81 + + * UIxSieveEditor.m: call proper save method in Sieve SoObject + + * UIxMailEditor.m: added 'SOGoMailEditorKeepTmpFile' default to debug + MIME generation * v0.9.80 diff --git a/SOGo/UI/Mailer/UIxMailEditor.m b/SOGo/UI/Mailer/UIxMailEditor.m index 627052d2..b79884a9 100644 --- a/SOGo/UI/Mailer/UIxMailEditor.m +++ b/SOGo/UI/Mailer/UIxMailEditor.m @@ -59,11 +59,14 @@ static BOOL keepMailTmpFile = NO; static NSArray *infoKeys = nil; + (void)initialize { + NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + infoKeys = [[NSArray alloc] initWithObjects: @"subject", @"text", @"to", @"cc", @"bcc", @"from", @"replyTo", nil]; + keepMailTmpFile = [ud boolForKey:@"SOGoMailEditorKeepTmpFile"]; if (keepMailTmpFile) NSLog(@"WARNING: keeping mail files."); } @@ -242,6 +245,8 @@ static NSArray *infoKeys = nil; NSException *error; NSString *mailPath; + // TODO: need to validate whether we have a To etc + /* first, save form data */ if (![self _saveFormInfo]) diff --git a/SOGo/UI/Mailer/UIxMailToSelection.wox b/SOGo/UI/Mailer/UIxMailToSelection.wox index a74d881e..92d2bd34 100644 --- a/SOGo/UI/Mailer/UIxMailToSelection.wox +++ b/SOGo/UI/Mailer/UIxMailToSelection.wox @@ -10,7 +10,7 @@ - + @@ -39,12 +39,15 @@
+ - + +
diff --git a/SOGo/UI/Mailer/UIxSieveEditor.m b/SOGo/UI/Mailer/UIxSieveEditor.m index 1046401d..a9dd7021 100644 --- a/SOGo/UI/Mailer/UIxSieveEditor.m +++ b/SOGo/UI/Mailer/UIxSieveEditor.m @@ -91,7 +91,13 @@ } - (id)saveAction { - [self logWithFormat:@"TODO: should save script!"]; + NSException *error; + NSString *text; + + text = [self scriptText]; + if ((error = [[self clientObject] writeContent:text]) != nil) + return error; + return self; } diff --git a/SOGo/UI/Mailer/Version b/SOGo/UI/Mailer/Version index cbd97192..e846368e 100644 --- a/SOGo/UI/Mailer/Version +++ b/SOGo/UI/Mailer/Version @@ -1,7 +1,8 @@ # version file -SUBMINOR_VERSION:=80 +SUBMINOR_VERSION:=81 +# v0.9.81 requires SoObjects/Sieve v0.9.5 # v0.9.80 requires SoObjects/Mailer v0.9.59 # v0.9.78 requires SoObjects/Mailer v0.9.58 # v0.9.77 requires SoObjects/Mailer v0.9.57 diff --git a/SOGo/UI/Mailer/mailer.js b/SOGo/UI/Mailer/mailer.js index 8b6d9e50..2927ffc2 100644 --- a/SOGo/UI/Mailer/mailer.js +++ b/SOGo/UI/Mailer/mailer.js @@ -64,6 +64,8 @@ function validateEditorInput(sender) { function clickedEditorSend(sender) { if (!validateEditorInput(sender)) return false; + + // TODO: validate whether we have a recipient! (#1220) document.pageform.action="send"; document.pageform.submit(); diff --git a/SOGo/UI/Mailer/product.plist b/SOGo/UI/Mailer/product.plist index c35e679d..c9508f41 100644 --- a/SOGo/UI/Mailer/product.plist +++ b/SOGo/UI/Mailer/product.plist @@ -167,7 +167,7 @@ { link = "compose"; target = "_blank"; cssClass = "tbicon_compose"; label = "Write"; }, ), -/* TODO: enable when implemented +//* TODO: enable when implemented ( // second group { link = "reply"; cssClass = "tbicon_reply"; label = "Reply"; }, @@ -176,7 +176,7 @@ { link = "forward"; cssClass = "tbicon_forward"; label = "Forward"; }, ), -*/ +//*/ ( // third group { link = "delete"; cssClass = "tbicon_delete"; label = "Delete"; }, -- 2.39.5