From 84ee55053369b7e128d9e75f7f687cd6120d2caf Mon Sep 17 00:00:00 2001 From: helge Date: Sun, 28 Nov 2004 18:51:41 +0000 Subject: [PATCH] more work on Sieve git-svn-id: http://svn.opengroupware.org/SOGo/trunk@457 d1b88da0-ebda-0310-925b-ed51d893ca5b --- SOGo/SoObjects/Sieve/ChangeLog | 4 ++ SOGo/SoObjects/Sieve/SOGoSieveBaseObject.h | 7 ++- SOGo/SoObjects/Sieve/SOGoSieveBaseObject.m | 49 +++++++++++++++++++ SOGo/SoObjects/Sieve/SOGoSieveScriptsFolder.h | 3 ++ SOGo/SoObjects/Sieve/SOGoSieveScriptsFolder.m | 22 +++++++++ SOGo/SoObjects/Sieve/Version | 2 +- SOGo/UI/Mailer/ChangeLog | 5 ++ SOGo/UI/Mailer/UIxFilterList.m | 5 +- 8 files changed, 93 insertions(+), 4 deletions(-) diff --git a/SOGo/SoObjects/Sieve/ChangeLog b/SOGo/SoObjects/Sieve/ChangeLog index 8b164704..cb375fee 100644 --- a/SOGo/SoObjects/Sieve/ChangeLog +++ b/SOGo/SoObjects/Sieve/ChangeLog @@ -1,3 +1,7 @@ +2004-11-28 Helge Hess + + * added list capability, does not work with 'dotted' logins? (v0.9.2) + 2004-11-27 Helge Hess * started Sieve product diff --git a/SOGo/SoObjects/Sieve/SOGoSieveBaseObject.h b/SOGo/SoObjects/Sieve/SOGoSieveBaseObject.h index 97761d83..71fbdcf9 100644 --- a/SOGo/SoObjects/Sieve/SOGoSieveBaseObject.h +++ b/SOGo/SoObjects/Sieve/SOGoSieveBaseObject.h @@ -31,12 +31,13 @@ */ @class NSString, NSArray, NSURL; -@class NGImap4Client; +@class NGImap4Client, NGSieveClient; @class SOGoMailManager; @class SOGoMailAccount; @interface SOGoSieveBaseObject : SOGoObject { + NGSieveClient *sieveClient; } /* hierarchy */ @@ -51,6 +52,10 @@ - (NGImap4Client *)imap4Client; - (void)flushMailCaches; +/* Sieve */ + +- (NGSieveClient *)sieveClient; + @end #endif /* __Sieve_SOGoSieveBaseObject_H__ */ diff --git a/SOGo/SoObjects/Sieve/SOGoSieveBaseObject.m b/SOGo/SoObjects/Sieve/SOGoSieveBaseObject.m index 80b97ac6..091ff77a 100644 --- a/SOGo/SoObjects/Sieve/SOGoSieveBaseObject.m +++ b/SOGo/SoObjects/Sieve/SOGoSieveBaseObject.m @@ -23,12 +23,18 @@ #include #include #include "common.h" +#include #include #include #include @implementation SOGoSieveBaseObject +- (void)dealloc { + [self->sieveClient release]; + [super dealloc]; +} + /* hierarchy */ - (SOGoMailAccount *)mailAccountFolder { @@ -61,6 +67,49 @@ - (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 { diff --git a/SOGo/SoObjects/Sieve/SOGoSieveScriptsFolder.h b/SOGo/SoObjects/Sieve/SOGoSieveScriptsFolder.h index 008ec217..acaf78fe 100644 --- a/SOGo/SoObjects/Sieve/SOGoSieveScriptsFolder.h +++ b/SOGo/SoObjects/Sieve/SOGoSieveScriptsFolder.h @@ -34,8 +34,11 @@ server. */ +@class NSDictionary; + @interface SOGoSieveScriptsFolder : SOGoSieveBaseObject { + NSDictionary *listedScripts; } diff --git a/SOGo/SoObjects/Sieve/SOGoSieveScriptsFolder.m b/SOGo/SoObjects/Sieve/SOGoSieveScriptsFolder.m index 1165641e..c8287516 100644 --- a/SOGo/SoObjects/Sieve/SOGoSieveScriptsFolder.m +++ b/SOGo/SoObjects/Sieve/SOGoSieveScriptsFolder.m @@ -20,8 +20,30 @@ */ #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]; +} + @end /* SOGoSieveScriptsFolder */ diff --git a/SOGo/SoObjects/Sieve/Version b/SOGo/SoObjects/Sieve/Version index e2e93a0f..4ba9ab79 100644 --- a/SOGo/SoObjects/Sieve/Version +++ b/SOGo/SoObjects/Sieve/Version @@ -1,5 +1,5 @@ # Version file -SUBMINOR_VERSION:=1 +SUBMINOR_VERSION:=2 # v0.9.1 requires libNGMime v4.3.194 diff --git a/SOGo/UI/Mailer/ChangeLog b/SOGo/UI/Mailer/ChangeLog index 8a14bd97..1794ae5b 100644 --- a/SOGo/UI/Mailer/ChangeLog +++ b/SOGo/UI/Mailer/ChangeLog @@ -1,3 +1,8 @@ +2004-11-28 Helge Hess + + * UIxFilterList.m: use toOneRelationshipKeys to retrieve the filters + being displayed (v0.9.66) + 2004-11-27 Helge Hess * v0.9.65 diff --git a/SOGo/UI/Mailer/UIxFilterList.m b/SOGo/UI/Mailer/UIxFilterList.m index ffea50ab..958777b8 100644 --- a/SOGo/UI/Mailer/UIxFilterList.m +++ b/SOGo/UI/Mailer/UIxFilterList.m @@ -74,9 +74,10 @@ - (id)defaultAction { // TODO: remove log [self logWithFormat:@"default action ..."]; - + [self logWithFormat:@"should fetch scripts in: %@", [self clientObject]]; - + self->filters = [[[self clientObject] toOneRelationshipKeys] copy]; + return self; } -- 2.39.5