From: helge Date: Tue, 9 Nov 2004 19:53:44 +0000 (+0000) Subject: added support for toggling mail flags X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7b07351d35ee7e00b9e15b807e024e16ae57d57a;p=scalable-opengroupware.org added support for toggling mail flags git-svn-id: http://svn.opengroupware.org/SOGo/trunk@451 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/SOGo/SoObjects/Mailer/ChangeLog b/SOGo/SoObjects/Mailer/ChangeLog index 07714959..1554c9e2 100644 --- a/SOGo/SoObjects/Mailer/ChangeLog +++ b/SOGo/SoObjects/Mailer/ChangeLog @@ -1,5 +1,7 @@ 2004-11-09 Helge Hess + * added support for toggling mail flags (v0.9.52) + * moved all tree navigation code to UIxMailTree (v0.9.51) * SOGoMailBaseObject.m, SOGoMailAccounts.m: moved tree code to separate diff --git a/SOGo/SoObjects/Mailer/SOGoMailManager.h b/SOGo/SoObjects/Mailer/SOGoMailManager.h index 4c5acedf..ce9803f9 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailManager.h +++ b/SOGo/SoObjects/Mailer/SOGoMailManager.h @@ -68,6 +68,9 @@ - (NSData *)fetchContentOfBodyPart:(NSString *)_partId atURL:(NSURL *)_url password:(NSString *)_pwd; +- (NSException *)addFlags:(id)_f toURL:(NSURL *)_u password:(NSString *)_p; +- (NSException *)removeFlags:(id)_f toURL:(NSURL *)_u password:(NSString *)_p; + /* managing folders */ - (NSException *)createMailbox:(NSString *)_mailbox atURL:(NSURL *)_url diff --git a/SOGo/SoObjects/Mailer/SOGoMailManager.m b/SOGo/SoObjects/Mailer/SOGoMailManager.m index 0234180a..58b62fb3 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailManager.m +++ b/SOGo/SoObjects/Mailer/SOGoMailManager.m @@ -470,7 +470,6 @@ static NSString *imap4Separator = nil; if (![_url isNotNull]) return nil; - if ((client = [self imap4ClientForURL:_url password:_pwd]) == nil) return nil; @@ -534,6 +533,39 @@ static NSString *imap4Separator = nil; return result; } +- (NSException *)addOrRemove:(BOOL)_flag flags:(id)_f + toURL:(NSURL *)_url password:(NSString *)_p +{ + NGImap4Client *client; + id result; + + if (![_url isNotNull]) return nil; + if (![_f isNotNull]) return nil; + + if ((client = [self imap4ClientForURL:_url password:_p]) == nil) + return nil; + + if (![_f isKindOfClass:[NSArray class]]) + _f = [NSArray arrayWithObjects:&_f count:1]; + + result = [client storeUid:[[[_url path] lastPathComponent] intValue] + add:[NSNumber numberWithBool:_flag] + flags:_f]; + if (![[result valueForKey:@"result"] boolValue]) { + [self logWithFormat:@"DEBUG: fail result %@", result]; + return [NSException exceptionWithHTTPStatus:500 /* server error */ + reason:@"failed to add flag to IMAP4 message"]; + } + /* result contains 'fetch' key with the current flags */ + return nil; +} +- (NSException *)addFlags:(id)_f toURL:(NSURL *)_u password:(NSString *)_p { + return [self addOrRemove:YES flags:_f toURL:_u password:_p]; +} +- (NSException *)removeFlags:(id)_f toURL:(NSURL *)_u password:(NSString *)_p { + return [self addOrRemove:NO flags:_f toURL:_u password:_p]; +} + /* managing folders */ - (BOOL)isPermissionDeniedResult:(id)_result { diff --git a/SOGo/SoObjects/Mailer/SOGoMailObject.h b/SOGo/SoObjects/Mailer/SOGoMailObject.h index d064644f..58f8d759 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailObject.h +++ b/SOGo/SoObjects/Mailer/SOGoMailObject.h @@ -38,7 +38,7 @@ would address the MIME part 1.2.3 of the mail 12345 in the folder INBOX. */ -@class NSString, NSArray, NSCalendarDate; +@class NSData, NSString, NSArray, NSCalendarDate, NSException; @class NGImap4Envelope, NGImap4EnvelopeAddress; @interface SOGoMailObject : SOGoMailBaseObject @@ -64,6 +64,16 @@ - (id)bodyStructure; - (id)lookupInfoForBodyPart:(NSArray *)_path; +/* content */ + +- (NSData *)content; +- (NSString *)contentAsString; + +/* flags */ + +- (NSException *)addFlags:(id)_f; +- (NSException *)removeFlags:(id)_f; + @end #endif /* __Mailer_SOGoMailObject_H__ */ diff --git a/SOGo/SoObjects/Mailer/SOGoMailObject.m b/SOGo/SoObjects/Mailer/SOGoMailObject.m index 34f63caf..a2a8759b 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailObject.m +++ b/SOGo/SoObjects/Mailer/SOGoMailObject.m @@ -200,6 +200,8 @@ static BOOL heavyDebug = NO; return [info isNotNull] ? info : nil; } +/* content */ + - (NSData *)content { NSData *content; id result, fullResult; @@ -259,6 +261,17 @@ static BOOL heavyDebug = NO; return [s autorelease]; } +/* flags */ + +- (NSException *)addFlags:(id)_flags { + return [[self mailManager] addFlags:_flags toURL:[self imap4URL] + password:[self imap4Password]]; +} +- (NSException *)removeFlags:(id)_flags { + return [[self mailManager] removeFlags:_flags toURL:[self imap4URL] + password:[self imap4Password]]; +} + /* name lookup */ - (BOOL)isBodyPartKey:(NSString *)_key inContext:(id)_ctx { diff --git a/SOGo/SoObjects/Mailer/Version b/SOGo/SoObjects/Mailer/Version index 5d92fc81..1841728a 100644 --- a/SOGo/SoObjects/Mailer/Version +++ b/SOGo/SoObjects/Mailer/Version @@ -1,6 +1,6 @@ # Version file -SUBMINOR_VERSION:=51 +SUBMINOR_VERSION:=52 # v0.9.44 requires NGMime v4.3.194 # v0.9.41 requires NGMime v4.3.190 diff --git a/SOGo/UI/Mailer/ChangeLog b/SOGo/UI/Mailer/ChangeLog index 481bdb1e..3e65ac0c 100644 --- a/SOGo/UI/Mailer/ChangeLog +++ b/SOGo/UI/Mailer/ChangeLog @@ -1,5 +1,8 @@ 2004-11-09 Helge Hess + * UIxMailListView.m: added support for toggling read/unread flags + (v0.9.61) + * UIxMailTree.m: added tree navigation code from SoObjects (v0.9.60) * UIxMailTree.m: removed unused code (v0.9.59) diff --git a/SOGo/UI/Mailer/UIxMailListView.m b/SOGo/UI/Mailer/UIxMailListView.m index afc2e659..8c62a189 100644 --- a/SOGo/UI/Mailer/UIxMailListView.m +++ b/SOGo/UI/Mailer/UIxMailListView.m @@ -48,6 +48,7 @@ #include "common.h" #include #include +#include @implementation UIxMailListView @@ -347,6 +348,18 @@ static int attachmentFlagSize = 8096; return script; } +/* active message */ + +- (SOGoMailObject *)lookupActiveMessage { + NSString *uid; + + if ((uid = [[[self context] request] formValueForKey:@"uid"]) == nil) + return nil; + + return [[self clientObject] lookupName:uid inContext:[self context] + acquire:NO]; +} + /* actions */ - (id)defaultAction { @@ -357,11 +370,21 @@ static int attachmentFlagSize = 8096; } - (id)markMessageUnreadAction { - [self logWithFormat:@"TODO: mark message unread!"]; + NSException *error; + + if ((error = [[self lookupActiveMessage] removeFlags:@"seen"]) != nil) + // TODO: improve error handling + return error; + return [self redirectToLocation:@"view"]; } - (id)markMessageReadAction { - [self logWithFormat:@"TODO: mark message read!"]; + NSException *error; + + if ((error = [[self lookupActiveMessage] addFlags:@"seen"]) != nil) + // TODO: improve error handling + return error; + return [self redirectToLocation:@"view"]; } diff --git a/SOGo/UI/Mailer/Version b/SOGo/UI/Mailer/Version index 9603d86c..be4c90df 100644 --- a/SOGo/UI/Mailer/Version +++ b/SOGo/UI/Mailer/Version @@ -1,6 +1,6 @@ # $Id$ -SUBMINOR_VERSION:=60 +SUBMINOR_VERSION:=61 # v0.9.50 requires NGMime v4.3.190 # v0.9.43 requires NGObjWeb v4.3.73 diff --git a/SOGoLogic/SOGoAppointment.m b/SOGoLogic/SOGoAppointment.m index a92f42f8..0f3865d8 100644 --- a/SOGoLogic/SOGoAppointment.m +++ b/SOGoLogic/SOGoAppointment.m @@ -290,7 +290,7 @@ static SaxObjectDecoder *sax = nil; } - (NSArray *)participants { - if (self->participants) + if (self->participants != nil) return self->participants; self->participants = [[self _filteredAttendeesThinkingOfPersons:YES] retain];