From 2eb62a573e3570e6d749931e6eaf1ae4d654b3fd Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Fri, 9 Oct 2009 21:01:54 +0000 Subject: [PATCH 1/5] See ChangeLog Monotone-Parent: baa7bc0bc74871932c7f4e4d759f25a216d0c939 Monotone-Revision: 25a398b968eb4c84157efcd698facc74c5738e07 Monotone-Author: ludovic@Sophos.ca Monotone-Date: 2009-10-09T21:01:54 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 8 ++ SoObjects/Mailer/SOGoMailAccount.h | 11 +- SoObjects/Mailer/SOGoMailAccount.m | 168 ++++++++++++++++++++++++++--- SoObjects/SOGo/SOGoUserFolder.h | 3 + UI/PreferencesUI/UIxPreferences.m | 17 +++ 5 files changed, 185 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8cce1fce5..b269b0356 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2009-10-08 Ludovic Marcotte + + * Added filters support (Vacation and Forward) which + can be enabled using the SOGoVacationEnabled and + SOGoForwardEnabled defaults. One Sieve right now is + support and we assume the Sieve server is the same + as the IMAP server, running on port 2000. + 2009-10-08 Wolfgang Sourdeau * SoObjects/SOGo/LDAPSource.m (-_searchAttributes): we already diff --git a/SoObjects/Mailer/SOGoMailAccount.h b/SoObjects/Mailer/SOGoMailAccount.h index e8befd19e..f6c87bd2b 100644 --- a/SoObjects/Mailer/SOGoMailAccount.h +++ b/SoObjects/Mailer/SOGoMailAccount.h @@ -1,20 +1,21 @@ /* + Copyright (C) 2009 Inverse inc. Copyright (C) 2004-2005 SKYRIX Software AG - This file is part of OpenGroupware.org. + This file is part of SOGo. - OGo is free software; you can redistribute it and/or modify it under + SOGo is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - OGo is distributed in the hope that it will be useful, but WITHOUT ANY + SOGo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with OGo; see the file COPYING. If not, write to the + License along with SOGo; see the file COPYING. If not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ @@ -52,6 +53,7 @@ - (void) setAccountName: (NSString *) newAccountName; - (BOOL) supportsQuotas; +- (BOOL) updateFilters; /* folder pathes */ @@ -68,7 +70,6 @@ - (NSString *) inboxFolderNameInContext: (id)_ctx; - (NSString *) draftsFolderNameInContext: (id)_ctx; -// - (NSString *) sieveFolderNameInContext: (id)_ctx; - (NSString *) sentFolderNameInContext: (id)_ctx; - (NSString *) trashFolderNameInContext: (id)_ctx; diff --git a/SoObjects/Mailer/SOGoMailAccount.m b/SoObjects/Mailer/SOGoMailAccount.m index 01278aeb2..750edf6dc 100644 --- a/SoObjects/Mailer/SOGoMailAccount.m +++ b/SoObjects/Mailer/SOGoMailAccount.m @@ -15,7 +15,7 @@ License for more details. You should have received a copy of the GNU Lesser General Public - License along with OGo; see the file COPYING. If not, write to the + License along with SOGo; see the file COPYING. If not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ @@ -29,12 +29,14 @@ #import #import #import +#import #import #import #import #import #import #import +#import #import #import @@ -52,11 +54,12 @@ static NSArray *rootFolderNames = nil; static NSString *inboxFolderName = @"INBOX"; static NSString *draftsFolderName = @"Drafts"; -static NSString *sieveFolderName = @"Filters"; static NSString *sentFolderName = nil; static NSString *trashFolderName = nil; -static NSString *sharedFolderName = @""; // TODO: add English default +static NSString *sharedFolderName = @""; // TODO: add English default static NSString *otherUsersFolderName = @""; // TODO: add English default +static NSString *sieveScriptName = @"sogo"; + static BOOL defaultShowSubscribedFoldersOnly = NO; // this is temporary, until we allow users to manage their own accounts static NSString *fallbackIMAP4Server = nil; @@ -91,15 +94,10 @@ static NSString *fallbackIMAP4Server = nil; NSLog(@"Note: using shared-folders name: '%@'", sharedFolderName); NSLog(@"Note: using other-users-folders name: '%@'", otherUsersFolderName); - if ([ud boolForKey: @"SOGoEnableSieveFolder"]) - rootFolderNames = [[NSArray alloc] initWithObjects: - draftsFolderName, - sieveFolderName, - nil]; - else - rootFolderNames = [[NSArray alloc] initWithObjects: - draftsFolderName, - nil]; + + rootFolderNames = [[NSArray alloc] initWithObjects: + draftsFolderName, + nil]; if (!fallbackIMAP4Server) { @@ -206,6 +204,147 @@ static NSString *fallbackIMAP4Server = nil; return [capability containsObject: @"quota"]; } +- (BOOL) updateFilters +{ + NSMutableString *header, *script; + NGInternetSocketAddress *address; + NSDictionary *result, *values; + NSUserDefaults *ud; + NGSieveClient *client; + NSString *v; + BOOL b; + + if (![[NSUserDefaults standardUserDefaults] boolForKey: @"SOGoVacationEnabled"] && + ![[NSUserDefaults standardUserDefaults] boolForKey: @"SOGoForwardEnabled"]) + return YES; + + ud = [[context activeUser] userDefaults]; + b = NO; + + header = [NSMutableString stringWithString: @"require ["]; + script = [NSMutableString string]; + + // Right now, we handle Sieve filters here and only for vacation + // and forwards. Traditional filters support (for fileinto, for + // example) will be added later. + values = [ud objectForKey: @"Vacation"]; + + // We handle vacation messages. + // See http://ietfreport.isoc.org/idref/draft-ietf-sieve-vacation/ + if (values && [[values objectForKey: @"enabled"] boolValue]) + { + NSArray *addresses; + NSString *text; + BOOL ignore; + int days, i; + + days = [[values objectForKey: @"daysBetweenResponse"] intValue]; + addresses = [values objectForKey: @"autoReplyEmailAddresses"]; + ignore = [[values objectForKey: @"ignoreLists"] boolValue]; + text = [values objectForKey: @"autoReplyText"]; + b = YES; + + if (days == 0) + days = 7; + + [header appendString: @"\"vacation\""]; + + // Skip mailing lists + if (ignore) + [script appendString: @"if allof ( not exists [\"list-help\", \"list-unsubscribe\", \"list-subscribe\", \"list-owner\", \"list-post\", \"list-archive\", \"list-id\", \"Mailing-List\"], not header :comparator \"i;ascii-casemap\" :is \"Precedence\" [\"list\", \"bulk\", \"junk\"], not header :comparator \"i;ascii-casemap\" :matches \"To\" \"Multiple recipients of*\" ) {"]; + + [script appendFormat: @"vacation :days %d :addresses [", days]; + + for (i = 0; i < [addresses count]; i++) + { + [script appendFormat: @"\"%@\"", [addresses objectAtIndex: i]]; + + if (i == [addresses count]-1) + [script appendString: @"] "]; + else + [script appendString: @", "]; + } + + [script appendFormat: @"text:\r\n%@\r\n.\r\n;\r\n", text]; + + if (ignore) + [script appendString: @"}\r\n"]; + } + + + // We handle mail forward + values = [ud objectForKey: @"Forward"]; + + if (values && [[values objectForKey: @"enabled"] boolValue]) + { + b = YES; + + v = [values objectForKey: @"forwardAddress"]; + + if (v && [v length] > 0) + [script appendFormat: @"redirect \"%@\";\r\n", v]; + + if ([[values objectForKey: @"keepCopy"] boolValue]) + [script appendString: @"keep;\r\n"]; + } + + if ([header compare: @"require ["] != NSOrderedSame) + { + [header appendString: @"];\r\n"]; + [script insertString: header atIndex: 0]; + } + + // We connect to our Sieve server and upload the script + address = [NGInternetSocketAddress addressWithPort: 2000 + onHost: [[self imap4URL] host]]; + + client = [NGSieveClient clientWithAddress: address]; + + if (!client) { + [self errorWithFormat: @"Sieve connection failed on %@", [address description]]; + return NO; + } + + result = [client login: [[self imap4URL] user] password:[self imap4Password]]; + + if (![[result valueForKey:@"result"] boolValue]) { + [self errorWithFormat: @"Could not login '%@' (%@) on Sieve server: %@: %@", + [[self imap4URL] user], [self imap4Password], client, result]; + [client closeConnection]; + return NO; + } + + // We delete the existing Sieve script + result = [client deleteScript: sieveScriptName]; + + if (![[result valueForKey:@"result"] boolValue]) { + [self logWithFormat:@"WARNING: Could not delete Sieve script - continuing...: %@", result]; + } + + // We put and activate the script only if we actually have a script + // that does something... + if (b) + { + result = [client putScript: sieveScriptName script: script]; + + if (![[result valueForKey:@"result"] boolValue]) { + [self errorWithFormat:@"Could not upload Sieve script: %@", result]; + [client closeConnection]; + return NO; + } + + result = [client setActiveScript: sieveScriptName]; + if (![[result valueForKey:@"result"] boolValue]) { + [self errorWithFormat:@"Could not enable Sieve script: %@", result]; + [client closeConnection]; + return NO; + } + } + + return YES; +} + + /* hierarchy */ - (SOGoMailAccount *) mailAccountFolder @@ -408,11 +547,6 @@ static NSString *fallbackIMAP4Server = nil; return folderName; } -// - (NSString *) sieveFolderNameInContext: (id) _ctx -// { -// return sieveFolderName; -// } - - (NSString *) sentFolderNameInContext: (id)_ctx { NSString *folderName; diff --git a/SoObjects/SOGo/SOGoUserFolder.h b/SoObjects/SOGo/SOGoUserFolder.h index 795a3379b..2de151a56 100644 --- a/SoObjects/SOGo/SOGoUserFolder.h +++ b/SoObjects/SOGo/SOGoUserFolder.h @@ -55,6 +55,9 @@ - (id) freeBusyObject: (NSString *) _key inContext: (WOContext *) _ctx; +- (id) mailAccountsFolder: (NSString *) _key + inContext: (WOContext *) _ctx; + @end #endif /* __SOGo_SOGoUserFolder_H__ */ diff --git a/UI/PreferencesUI/UIxPreferences.m b/UI/PreferencesUI/UIxPreferences.m index 6a143ea11..a492bc168 100644 --- a/UI/PreferencesUI/UIxPreferences.m +++ b/UI/PreferencesUI/UIxPreferences.m @@ -32,7 +32,10 @@ #import #import +#import #import +#import +#import #import "../../Main/SOGo.h" #import "UIxPreferences.h" @@ -901,7 +904,21 @@ static BOOL forwardEnabled = NO; request = [context request]; if ([[request method] isEqualToString: @"POST"]) { + SOGoMailAccount *account; + id mailAccounts; + id folder; + [userDefaults synchronize]; + + mailAccounts = [[[context activeUser] mailAccounts] objectAtIndex: 0]; + folder = [[self clientObject] mailAccountsFolder: @"Mail" + inContext: context]; + account = [folder lookupName: [[mailAccounts objectForKey: @"name"] asCSSIdentifier] + inContext: context + acquire: NO]; + + [account updateFilters]; + if (composeMessageTypeHasChanged) // Due to a limitation of CKEDITOR, we reload the page when the user // changes the composition mode to avoid Javascript errors. From b81ed3b2feca1e5c2c68e98c69c17dff2564a55c Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Fri, 9 Oct 2009 21:54:07 +0000 Subject: [PATCH 2/5] See ChangeLog Monotone-Parent: 25a398b968eb4c84157efcd698facc74c5738e07 Monotone-Revision: a9d5ad1c7b8fa6de9db2b7b205864f5cd9d96b3b Monotone-Author: ludovic@Sophos.ca Monotone-Date: 2009-10-09T21:54:07 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 2 + SoObjects/GNUmakefile | 3 +- SoObjects/Sieve/GNUmakefile | 21 ---- SoObjects/Sieve/GNUmakefile.preamble | 3 - SoObjects/Sieve/Product.m | 32 ------ SoObjects/Sieve/README | 8 -- SoObjects/Sieve/SOGoSieveBaseObject.h | 60 ---------- SoObjects/Sieve/SOGoSieveBaseObject.m | 117 ------------------- SoObjects/Sieve/SOGoSieveScriptObject.h | 50 -------- SoObjects/Sieve/SOGoSieveScriptObject.m | 139 ----------------------- SoObjects/Sieve/SOGoSieveScriptsFolder.h | 50 -------- SoObjects/Sieve/SOGoSieveScriptsFolder.m | 98 ---------------- SoObjects/Sieve/Version | 7 -- SoObjects/Sieve/common.h | 36 ------ SoObjects/Sieve/product.plist | 23 ---- UI/MailerUI/GNUmakefile | 2 - UI/MailerUI/README | 1 - UI/MailerUI/UIxSieveEditor.m | 115 ------------------- UI/MailerUI/product.plist | 77 +------------ UI/Templates/MailerUI/UIxSieveEditor.wox | 33 ------ 20 files changed, 4 insertions(+), 873 deletions(-) delete mode 100644 SoObjects/Sieve/GNUmakefile delete mode 100644 SoObjects/Sieve/GNUmakefile.preamble delete mode 100644 SoObjects/Sieve/Product.m delete mode 100644 SoObjects/Sieve/README delete mode 100644 SoObjects/Sieve/SOGoSieveBaseObject.h delete mode 100644 SoObjects/Sieve/SOGoSieveBaseObject.m delete mode 100644 SoObjects/Sieve/SOGoSieveScriptObject.h delete mode 100644 SoObjects/Sieve/SOGoSieveScriptObject.m delete mode 100644 SoObjects/Sieve/SOGoSieveScriptsFolder.h delete mode 100644 SoObjects/Sieve/SOGoSieveScriptsFolder.m delete mode 100644 SoObjects/Sieve/Version delete mode 100644 SoObjects/Sieve/common.h delete mode 100644 SoObjects/Sieve/product.plist delete mode 100644 UI/MailerUI/UIxSieveEditor.m delete mode 100644 UI/Templates/MailerUI/UIxSieveEditor.wox diff --git a/ChangeLog b/ChangeLog index b269b0356..c8da9df8d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,8 @@ SOGoForwardEnabled defaults. One Sieve right now is support and we assume the Sieve server is the same as the IMAP server, running on port 2000. + * Cleaned up everything related to the old Sieve stuff + which was now useless with our new implementation. 2009-10-08 Wolfgang Sourdeau diff --git a/SoObjects/GNUmakefile b/SoObjects/GNUmakefile index 4fad16f24..8970574dd 100644 --- a/SoObjects/GNUmakefile +++ b/SoObjects/GNUmakefile @@ -7,7 +7,6 @@ SUBPROJECTS = \ SOGo \ Appointments \ Contacts \ - Mailer \ -# Sieve \ + Mailer include $(GNUSTEP_MAKEFILES)/aggregate.make diff --git a/SoObjects/Sieve/GNUmakefile b/SoObjects/Sieve/GNUmakefile deleted file mode 100644 index 9921fefdd..000000000 --- a/SoObjects/Sieve/GNUmakefile +++ /dev/null @@ -1,21 +0,0 @@ -# GNUstep makefile - -include ../common.make - -BUNDLE_NAME = Sieve - -Sieve_PRINCIPAL_CLASS = SOGoSieveProduct - -Sieve_OBJC_FILES += \ - Product.m \ - SOGoSieveBaseObject.m \ - SOGoSieveScriptsFolder.m\ - SOGoSieveScriptObject.m \ - -Sieve_RESOURCE_FILES += \ - Version \ - product.plist \ - --include GNUmakefile.preamble -include $(GNUSTEP_MAKEFILES)/bundle.make --include GNUmakefile.postamble diff --git a/SoObjects/Sieve/GNUmakefile.preamble b/SoObjects/Sieve/GNUmakefile.preamble deleted file mode 100644 index df82baa0b..000000000 --- a/SoObjects/Sieve/GNUmakefile.preamble +++ /dev/null @@ -1,3 +0,0 @@ -# compilation settings - -ADDITIONAL_INCLUDE_DIRS += -I../Mailer diff --git a/SoObjects/Sieve/Product.m b/SoObjects/Sieve/Product.m deleted file mode 100644 index eef605e74..000000000 --- a/SoObjects/Sieve/Product.m +++ /dev/null @@ -1,32 +0,0 @@ -/* - Copyright (C) 2004 SKYRIX Software AG - - This file is part of OpenGroupware.org. - - OGo is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - OGo is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with OGo; see the file COPYING. If not, write to the - Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. -*/ - -#import - -@interface SOGoSieveProduct : NSObject -{ -} - -@end - -@implementation SOGoSieveProduct - -@end /* SOGoSieveProduct */ diff --git a/SoObjects/Sieve/README b/SoObjects/Sieve/README deleted file mode 100644 index 61e347668..000000000 --- a/SoObjects/Sieve/README +++ /dev/null @@ -1,8 +0,0 @@ -# README for Sieve SoObjects - -Class Overview -============== - - -Defaults -======== diff --git a/SoObjects/Sieve/SOGoSieveBaseObject.h b/SoObjects/Sieve/SOGoSieveBaseObject.h deleted file mode 100644 index 40530b4c9..000000000 --- a/SoObjects/Sieve/SOGoSieveBaseObject.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - Copyright (C) 2004-2005 SKYRIX Software AG - - This file is part of OpenGroupware.org. - - OGo is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - OGo is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with OGo; see the file COPYING. If not, write to the - Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. -*/ - -#ifndef __Sieve_SOGoSieveBaseObject_H__ -#define __Sieve_SOGoSieveBaseObject_H__ - -#include - -/* - SOGoSieveBaseObject - - Common base class for Sieve SoObjects. -*/ - -@class NSString, NSArray, NSURL; -@class NGSieveClient; -@class NGImap4ConnectionManager; -@class SOGoMailAccount; - -@interface SOGoSieveBaseObject : SOGoObject -{ - NGSieveClient *sieveClient; -} - -/* hierarchy */ - -- (SOGoMailAccount *)mailAccountFolder; - -/* IMAP4 */ - -- (NGImap4ConnectionManager *)mailManager; -- (NSURL *)imap4URL; -- (NSString *)imap4Password; -- (void)flushMailCaches; - -/* Sieve */ - -- (NGSieveClient *)sieveClient; - -@end - -#endif /* __Sieve_SOGoSieveBaseObject_H__ */ diff --git a/SoObjects/Sieve/SOGoSieveBaseObject.m b/SoObjects/Sieve/SOGoSieveBaseObject.m deleted file mode 100644 index 1392b89e5..000000000 --- a/SoObjects/Sieve/SOGoSieveBaseObject.m +++ /dev/null @@ -1,117 +0,0 @@ -/* - Copyright (C) 2004-2005 SKYRIX Software AG - - This file is part of OpenGroupware.org. - - OGo is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - OGo is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with OGo; see the file COPYING. If not, write to the - Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. -*/ - -#include "SOGoSieveBaseObject.h" -#include -#include -#include "common.h" -#include -#include -#include -#include - -@implementation SOGoSieveBaseObject - -- (void)dealloc { - [self->sieveClient release]; - [super dealloc]; -} - -/* hierarchy */ - -- (SOGoMailAccount *)mailAccountFolder { - if (![[self container] respondsToSelector:_cmd]) { - [self logWithFormat:@"WARNING: weird container of mailfolder: %@", - [self container]]; - return nil; - } - - return [[self container] mailAccountFolder]; -} - -/* IMAP4 */ - -- (NGImap4ConnectionManager *)mailManager { - return [[self mailAccountFolder] mailManager]; -} -- (NSURL *)imap4URL { - return [[self mailAccountFolder] imap4URL]; -} - -- (NSString *)imap4Password { - return [[self mailAccountFolder] imap4Password]; -} - -- (void)flushMailCaches { -} - -/* Sieve */ - -- (NGSieveClient *)sieveClient { - id res; - - if (self->sieveClient != nil) - return self->sieveClient; - - /* check container */ - - res = [self container]; - if ([res respondsToSelector:_cmd]) { - if ((res = [res sieveClient]) != nil) { - self->sieveClient = [res retain]; - return self->sieveClient; - } - } - - /* create client */ - - self->sieveClient = - [[NGSieveClient alloc] initWithHost:[[self imap4URL] host]]; - if (self->sieveClient == nil) - return nil; - - /* login */ - - res = [self->sieveClient - login:[[self imap4URL] user] - password:[self imap4Password]]; - - if (![[res valueForKey:@"result"] boolValue]) { - [self logWithFormat: - @"ERROR: could not login '%@'(%@) into Sieve server: %@: %@", - [[self imap4URL] user], [self imap4Password], - self->sieveClient, res]; - [self->sieveClient release]; self->sieveClient = nil; - return nil; - } - - return self->sieveClient; -} - -/* debugging */ - -- (NSString *)loggingPrefix { - /* improve perf ... */ - return [NSString stringWithFormat:@"<0x%08X[%@]:%@>", - self, NSStringFromClass([self class]), - [self nameInContainer]]; -} -@end /* SOGoSieveBaseObject */ diff --git a/SoObjects/Sieve/SOGoSieveScriptObject.h b/SoObjects/Sieve/SOGoSieveScriptObject.h deleted file mode 100644 index 7063adf8c..000000000 --- a/SoObjects/Sieve/SOGoSieveScriptObject.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - Copyright (C) 2004-2005 SKYRIX Software AG - - This file is part of OpenGroupware.org. - - OGo is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - OGo is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with OGo; see the file COPYING. If not, write to the - Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. -*/ - -#ifndef __Sieve_SOGoSieveScriptObject_H__ -#define __Sieve_SOGoSieveScriptObject_H__ - -#include "SOGoSieveBaseObject.h" - -/* - SOGoSieveScriptObject - - Parent object: SOGoSieveScriptsFolder - Child objects: none - - The SOGoSieveScriptObject represents a single sieve script on a Cyrus folder. -*/ - -@class NSData, NSString, NSException; - -@interface SOGoSieveScriptObject : SOGoSieveBaseObject -{ -} - -/* content */ - -- (NSString *)contentAsString; -- (NSData *)content; -- (NSException *)writeContent:(id)_content; - -@end - -#endif /* __Sieve_SOGoSieveScriptObject_H__ */ diff --git a/SoObjects/Sieve/SOGoSieveScriptObject.m b/SoObjects/Sieve/SOGoSieveScriptObject.m deleted file mode 100644 index 527a13349..000000000 --- a/SoObjects/Sieve/SOGoSieveScriptObject.m +++ /dev/null @@ -1,139 +0,0 @@ -/* - Copyright (C) 2004-2005 SKYRIX Software AG - - This file is part of OpenGroupware.org. - - OGo is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - OGo is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with OGo; see the file COPYING. If not, write to the - Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. -*/ - -#include "SOGoSieveScriptObject.h" -#include "SOGoSieveScriptsFolder.h" -#include "common.h" -#include - -@implementation SOGoSieveScriptObject - -/* script */ - -- (NSString *)fetchScript { - NGSieveClient *client; - - if ((client = [self sieveClient]) == nil) - return nil; - - return [client getScript:[self nameInContainer]]; -} - -/* content */ - -- (NSString *)contentAsString { - return [self fetchScript]; -} -- (NSData *)content { - return [[self contentAsString] dataUsingEncoding:NSUTF8StringEncoding]; -} - -- (NSException *)exceptionForFailedPutResult:(NSDictionary *)_result { - NSString *reason; - - /* Note: valueForKey:@"reason" does not work?! */ - reason = [(NSDictionary *)[_result valueForKey:@"RawResponse"] - objectForKey:@"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!"]; - } - - 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 */ - -- (NSException *)delete { - NSDictionary *res; - NSString *r; - - res = [[self sieveClient] deleteScript:[self nameInContainer]]; - if ([[res valueForKey:@"result"] boolValue]) - return nil; - - // TODO: make it a debug log - [self logWithFormat:@"sieve delete failed: %@", res]; - - r = [@"Sieve delete failed: " stringByAppendingString:[res description]]; - return [NSException exceptionWithHTTPStatus:500 /* Server Error */ - reason:r]; -} - -- (NSException *)activate { - return [[self container] activateScript:[self nameInContainer]]; -} - -/* name lookup */ - -- (id)lookupName:(NSString *)_key inContext:(id)_ctx acquire:(BOOL)_flag { - id obj; - - /* first check attributes directly bound to the object */ - if ((obj = [super lookupName:_key inContext:_ctx acquire:NO])) - return obj; - - /* return 404 to stop acquisition */ - return [NSException exceptionWithHTTPStatus:404 /* Not Found */]; -} - -/* operations */ - -- (id)PUTAction:(id)_context { - NSException *e; - NSString *content; - - content = [[(WOContext *)_context request] contentAsString]; - - if ((e = [self writeContent:content])) - return e; - - return self; -} - -/* message type */ - -- (NSString *)outlookMessageClass { - return @"IPM.Filter"; -} - - -@end /* SOGoSieveScriptObject */ diff --git a/SoObjects/Sieve/SOGoSieveScriptsFolder.h b/SoObjects/Sieve/SOGoSieveScriptsFolder.h deleted file mode 100644 index c711f3629..000000000 --- a/SoObjects/Sieve/SOGoSieveScriptsFolder.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - Copyright (C) 2004 SKYRIX Software AG - - This file is part of OpenGroupware.org. - - OGo is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - OGo is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with OGo; see the file COPYING. If not, write to the - Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. -*/ - -#ifndef __Sieve_SOGoSieveScriptsFolder_H__ -#define __Sieve_SOGoSieveScriptsFolder_H__ - -#include "SOGoSieveBaseObject.h" - -/* - SOGoSieveScriptsFolder - - Parent object: the SOGoMailAccount - Child objects: SOGoSieveScriptObject - - The SOGoSieveScriptsFolder represents a list of sieve scripts on a Cyrus - server. -*/ - -@class NSString, NSException, NSDictionary; - -@interface SOGoSieveScriptsFolder : SOGoSieveBaseObject -{ - NSDictionary *listedScripts; -} - -/* operations */ - -- (NSException *)activateScript:(NSString *)_name; - -@end - -#endif /* __Sieve_SOGoSieveScriptsFolder_H__ */ diff --git a/SoObjects/Sieve/SOGoSieveScriptsFolder.m b/SoObjects/Sieve/SOGoSieveScriptsFolder.m deleted file mode 100644 index 49722fc26..000000000 --- a/SoObjects/Sieve/SOGoSieveScriptsFolder.m +++ /dev/null @@ -1,98 +0,0 @@ -/* - Copyright (C) 2004 SKYRIX Software AG - - This file is part of OpenGroupware.org. - - OGo is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - OGo is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with OGo; see the file COPYING. If not, write to the - Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. -*/ - -#include "SOGoSieveScriptsFolder.h" -#include -#include "common.h" - -@implementation SOGoSieveScriptsFolder - -- (void)dealloc { - [self->listedScripts release]; - [super dealloc]; -} - -/* listing */ - -- (NSDictionary *)fetchScripts { - if (self->listedScripts != nil) - return self->listedScripts; - - self->listedScripts = [[[self sieveClient] listScripts] copy]; - return self->listedScripts; -} - -/* standard methods */ - -- (NSArray *)toOneRelationshipKeys { - return [[self fetchScripts] allKeys]; -} - -/* operations */ - -- (NSException *)activateScript:(NSString *)_name { - NSDictionary *res; - NSString *r; - - res = [[self sieveClient] setActiveScript:_name]; - if ([[res valueForKey:@"result"] boolValue]) - return nil; - - // TODO: make it a debug log - [self logWithFormat:@"sieve activate failed: %@", res]; - - r = [@"Script activation failed: " - stringByAppendingString:[res description]]; - return [NSException exceptionWithHTTPStatus:500 /* Server Error */ - reason:r]; -} - -/* name lookup */ - -- (NSString *)lookupScript:(NSString *)_key inContext:(id)_ctx { - Class clazz; - - clazz = NSClassFromString(@"SOGoSieveScriptObject"); - return [[[clazz alloc] initWithName:_key inContainer:self] autorelease]; -} - -- (id)lookupName:(NSString *)_key inContext:(id)_ctx acquire:(BOOL)_flag { - id obj; - - /* first check attributes directly bound to the object */ - if ((obj = [super lookupName:_key inContext:_ctx acquire:NO])) - return obj; - - /* lookup script */ - if ((obj = [self lookupScript:_key inContext:_ctx])) - return obj; - - /* return 404 to stop acquisition */ - return [NSException exceptionWithHTTPStatus:404 /* Not Found */]; -} - -/* folder type */ - -- (NSString *)outlookFolderClass { - return @"IPF.Filter"; -} - -@end /* SOGoSieveScriptsFolder */ diff --git a/SoObjects/Sieve/Version b/SoObjects/Sieve/Version deleted file mode 100644 index b92acff69..000000000 --- a/SoObjects/Sieve/Version +++ /dev/null @@ -1,7 +0,0 @@ -# Version file - -SUBMINOR_VERSION:=11 - -# v0.9.9 requires libNGMime v4.5.223 -# v0.9.6 requires libNGMime v4.5.207 -# v0.9.1 requires libNGMime v4.3.194 diff --git a/SoObjects/Sieve/common.h b/SoObjects/Sieve/common.h deleted file mode 100644 index 3c76bc134..000000000 --- a/SoObjects/Sieve/common.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - Copyright (C) 2002-2005 SKYRIX Software AG - - This file is part of OpenGroupware.org. - - OGo is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - OGo is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with OGo; see the file COPYING. If not, write to the - Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. -*/ - -#import -#import - -#if NeXT_Foundation_LIBRARY || COCOA_Foundation_LIBRARY -# include -# include -#endif - -#include -#include -#include - -#include - -#warning importing common.h is baaad diff --git a/SoObjects/Sieve/product.plist b/SoObjects/Sieve/product.plist deleted file mode 100644 index 83ed3e0d4..000000000 --- a/SoObjects/Sieve/product.plist +++ /dev/null @@ -1,23 +0,0 @@ -{ - requires = ( MAIN, Mailer ); - - publicResources = ( - ); - - factories = { - }; - - classes = { - SOGoSieveBaseObject = { - superclass = "SOGoObject"; - }; - - SOGoSieveScriptsFolder = { - superclass = "SOGoSieveBaseObject"; - }; - - SOGoSieveScriptObject = { - superclass = "SOGoSieveBaseObject"; - }; - }; -} diff --git a/UI/MailerUI/GNUmakefile b/UI/MailerUI/GNUmakefile index f36632789..808710b95 100644 --- a/UI/MailerUI/GNUmakefile +++ b/UI/MailerUI/GNUmakefile @@ -36,8 +36,6 @@ MailerUI_OBJC_FILES += \ # UIxMailReplyAction.m \ # UIxMailForwardAction.m \ # UIxFilterList.m \ -# \ -# UIxSieveEditor.m MailerUI_RESOURCE_FILES += \ Version \ diff --git a/UI/MailerUI/README b/UI/MailerUI/README index 0bc4b41bd..c3501f9da 100644 --- a/UI/MailerUI/README +++ b/UI/MailerUI/README @@ -40,7 +40,6 @@ Class Hierarchy UIxMailToolbar UIxMailTree UIxMailView - UIxSieveEditor UIxMailSortableTableHeader UIxMailEditorAttach.m UIxMailFilterPanel diff --git a/UI/MailerUI/UIxSieveEditor.m b/UI/MailerUI/UIxSieveEditor.m deleted file mode 100644 index d50fa412b..000000000 --- a/UI/MailerUI/UIxSieveEditor.m +++ /dev/null @@ -1,115 +0,0 @@ -/* - Copyright (C) 2004 SKYRIX Software AG - - This file is part of OpenGroupware.org. - - OGo is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - OGo is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with OGo; see the file COPYING. If not, write to the - Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. -*/ - -#include - -/* - UIxSieveEditor - - An editor component which works on SOGoSieveScriptObject's. -*/ - -@class NSArray, NSString; - -@interface UIxSieveEditor : UIxComponent -{ - NSString *scriptName; - NSString *scriptText; -} - -@end - -#include -#include "common.h" - -@implementation UIxSieveEditor - -- (void)dealloc { - [self->scriptText release]; - [self->scriptName release]; - [super dealloc]; -} - -/* accessors */ - -- (void)setScriptName:(NSString *)_value { - ASSIGNCOPY(self->scriptName, _value); -} -- (NSString *)scriptName { - return self->scriptName ? self->scriptName : @""; -} - -- (void)setScriptText:(NSString *)_value { - ASSIGNCOPY(self->scriptText, _value); -} -- (NSString *)scriptText { - return [self->scriptText isNotNull] ? self->scriptText : @""; -} - -- (NSString *)panelTitle { - return [self labelForKey:@"Edit Mail Filter"]; -} - -/* requests */ - -- (BOOL)shouldTakeValuesFromRequest:(WORequest *)_rq inContext:(WOContext*)_c { - return YES; -} - -/* actions */ - -- (id)defaultAction { - return [self redirectToLocation:@"edit"]; -} - -- (id)editAction { -#if 0 - [self logWithFormat:@"edit action, load content from: %@", - [self clientObject]]; -#endif - - [self setScriptName:[[self clientObject] nameInContainer]]; - [self setScriptText:[[self clientObject] contentAsString]]; - - return self; -} - -- (id)saveAction { - NSException *error; - NSString *text; - - text = [self scriptText]; - if ((error = [[self clientObject] writeContent:text]) != nil) - return error; - - return self; -} - -- (id)deleteAction { - NSException *error; - - if ((error = [[self clientObject] delete]) != nil) - return error; - - return nil; -} - -@end /* UIxSieveEditor */ diff --git a/UI/MailerUI/product.plist b/UI/MailerUI/product.plist index 722f929b0..917654d98 100644 --- a/UI/MailerUI/product.plist +++ b/UI/MailerUI/product.plist @@ -1,5 +1,5 @@ { /* -*-java-*- */ - requires = ( MAIN, MainUI, CommonUI, Mailer, MailPartViewers ); /* , Sieve */ + requires = ( MAIN, MainUI, CommonUI, Mailer, MailPartViewers ); publicResources = ("generic.js", "UIxAppointmentEditor.js", @@ -446,81 +446,6 @@ }; }; }; - - /* Sieve */ - -// SOGoSieveScriptsFolder = { -// slots = { -// toolbar = { -// protectedBy = "View"; -// value = ( -// ( -// { -// link = "getMail"; -// image = "tb-mail-getmail-flat-24x24.png"; -// cssClass = "tbicon_getmail"; label = "Get Mail"; -// }, -// { -// link = "#"; // "compose"; // target = "_blank"; -// onclick = "clickedNewFilter(this); return false"; -// image = "tb-mail-write-flat-24x24.png"; -// cssClass = "tbicon_compose"; label = "New Filter"; -// }, -// ), -// ( -// { link = "#"; -// cssClass = "tbicon_delete"; label = "Delete"; }, -// ), -// ); -// }; -// }; -// methods = { -// view = { -// protectedBy = "View"; -// pageName = "UIxFilterList"; -// }; -// create = { -// protectedBy = "View"; -// pageName = "UIxFilterList"; -// actionName = "create"; -// }; -// }; -// }; - -// SOGoSieveScriptObject = { -// slots = { -// toolbar = { -// protectedBy = "View"; -// value = ( -// ( { link = "#"; -// onclick = "clickedEditorSave(this);return false;"; -// image = "tb-mail-file-flat-24x24.png"; -// cssClass = "tbicon_save"; label = "Save"; }, -// { link = "#"; -// onclick = "clickedEditorDelete(this);return false;"; -// image = "tb-mail-delete-flat-24x24.png"; -// cssClass = "tbicon_delete"; label = "Delete"; }, -// ) -// ); -// }; -// }; -// methods = { -// edit = { -// protectedBy = "View"; -// pageName = "UIxSieveEditor"; -// actionName = "edit"; -// }; -// save = { -// protectedBy = "View"; -// pageName = "UIxSieveEditor"; -// actionName = "save"; -// }; -// delete = { -// protectedBy = "View"; -// pageName = "UIxSieveEditor"; -// actionName = "delete"; -// }; -// } }; } diff --git a/UI/Templates/MailerUI/UIxSieveEditor.wox b/UI/Templates/MailerUI/UIxSieveEditor.wox deleted file mode 100644 index 138ddad1a..000000000 --- a/UI/Templates/MailerUI/UIxSieveEditor.wox +++ /dev/null @@ -1,33 +0,0 @@ - - -
-
- - - - - -
- - : -
-
- - -
-