From 60919a0813b022f9990ca45df79217128e71f668 Mon Sep 17 00:00:00 2001 From: helge Date: Tue, 8 Feb 2005 17:04:04 +0000 Subject: [PATCH] fixed for libNGMime v4.5.210 git-svn-id: http://svn.opengroupware.org/SOGo/trunk@533 d1b88da0-ebda-0310-925b-ed51d893ca5b --- SOGo/SoObjects/Mailer/ChangeLog | 9 +++ SOGo/SoObjects/Mailer/SOGoDraftObject.m | 57 ++++++++++++++--- SOGo/SoObjects/Mailer/SOGoMailObject.h | 2 +- SOGo/SoObjects/Mailer/SOGoMailObject.m | 2 +- SOGo/SoObjects/Mailer/Version | 13 ++-- SOGo/UI/Mailer/ChangeLog | 7 +++ SOGo/UI/Mailer/UIxMailEditorAction.m | 81 +++++++++++++++++++++++-- SOGo/UI/Mailer/UIxMailListView.m | 6 +- SOGo/UI/Mailer/UIxMailView.m | 4 -- SOGo/UI/Mailer/UIxMailView.wox | 11 +++- SOGo/UI/Mailer/Version | 4 +- 11 files changed, 164 insertions(+), 32 deletions(-) diff --git a/SOGo/SoObjects/Mailer/ChangeLog b/SOGo/SoObjects/Mailer/ChangeLog index 2cfcfb0c..e5807252 100644 --- a/SOGo/SoObjects/Mailer/ChangeLog +++ b/SOGo/SoObjects/Mailer/ChangeLog @@ -1,3 +1,12 @@ +2005-02-08 Helge Hess + + * v0.9.69 + + * reworked for new NGImap4 v4.5.210 API + + * SOGoMailObject.m: removed fromEnvelopeAddress in favor of + fromEnvelopeAddresses to match the new NGImap4 v4.5.210 API + 2005-02-07 Helge Hess * v0.9.68 diff --git a/SOGo/SoObjects/Mailer/SOGoDraftObject.m b/SOGo/SoObjects/Mailer/SOGoDraftObject.m index 721a48d8..cee6d885 100644 --- a/SOGo/SoObjects/Mailer/SOGoDraftObject.m +++ b/SOGo/SoObjects/Mailer/SOGoDraftObject.m @@ -143,7 +143,13 @@ static BOOL debugOn = NO; /* accessors */ - (NSString *)sender { - return [[self fetchInfo] objectForKey:@"from"]; + id tmp; + + if ((tmp = [[self fetchInfo] objectForKey:@"from"]) == nil) + return nil; + if ([tmp isKindOfClass:[NSArray class]]) + return [tmp count] > 0 ? [tmp objectAtIndex:0] : nil; + return tmp; } /* attachments */ @@ -501,11 +507,25 @@ static BOOL debugOn = NO; } } +- (BOOL)isEmptyValue:(id)_value { + if (![_value isNotNull]) + return YES; + + if ([_value isKindOfClass:[NSArray class]]) + return [_value count] == 0 ? YES : NO; + + if ([_value isKindOfClass:[NSString class]]) + return [_value length] == 0 ? YES : NO; + + return NO; +} + - (NGMutableHashMap *)mimeHeaderMapWithHeaders:(NSDictionary *)_headers { NGMutableHashMap *map; NSDictionary *lInfo; // TODO: this should be some kind of object? NSArray *emails; NSString *s; + id from, replyTo; if ((lInfo = [self fetchInfo]) == nil) return nil; @@ -528,13 +548,24 @@ static BOOL debugOn = NO; /* add senders */ - if ([(s = [lInfo objectForKey:@"from"]) length] > 0) - [map setObject:s forKey:@"from"]; + from = [lInfo objectForKey:@"from"]; + replyTo = [lInfo objectForKey:@"replyTo"]; - if ([(s = [lInfo objectForKey:@"replyTo"]) length] > 0) - [map setObject:s forKey:@"reply-to"]; - else if ([(s = [lInfo objectForKey:@"from"]) length] > 0) - [map setObject:s forKey:@"reply-to"]; + if (![self isEmptyValue:from]) { + if ([from isKindOfClass:[NSArray class]]) + [map setObjects:from forKey:@"from"]; + else + [map setObject:from forKey:@"from"]; + } + + if (![self isEmptyValue:replyTo]) { + if ([from isKindOfClass:[NSArray class]]) + [map setObjects:from forKey:@"reply-to"]; + else + [map setObject:from forKey:@"reply-to"]; + } + else if (![self isEmptyValue:from]) + [map setObjects:[map objectsForKey:@"from"] forKey:@"reply-to"]; /* add subject */ @@ -866,17 +897,25 @@ static BOOL debugOn = NO; - (NGImap4Envelope *)envelope { NSDictionary *lInfo; + id from, replyTo; if (self->envelope != nil) return self->envelope; if ((lInfo = [self fetchInfo]) == nil) return nil; + if ((from = [self sender]) != nil) + from = [NSArray arrayWithObjects:&from count:1]; + + if ((replyTo = [lInfo objectForKey:@"replyTo"]) != nil) { + if (![replyTo isKindOfClass:[NSArray class]]) + replyTo = [NSArray arrayWithObjects:&replyTo count:1]; + } + self->envelope = [[NGImap4Envelope alloc] initWithMessageID:[self nameInContainer] subject:[lInfo objectForKey:@"subject"] - sender:[self sender] - replyTo:[lInfo objectForKey:@"replyTo"] + from:from replyTo:replyTo to:[lInfo objectForKey:@"to"] cc:[lInfo objectForKey:@"cc"] bcc:[lInfo objectForKey:@"bcc"]]; diff --git a/SOGo/SoObjects/Mailer/SOGoMailObject.h b/SOGo/SoObjects/Mailer/SOGoMailObject.h index 148a5a8e..22588182 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailObject.h +++ b/SOGo/SoObjects/Mailer/SOGoMailObject.h @@ -56,7 +56,7 @@ - (NGImap4Envelope *)envelope; - (NSString *)subject; - (NSCalendarDate *)date; -- (NGImap4EnvelopeAddress *)fromEnvelopeAddress; +- (NSArray *)fromEnvelopeAddresses; - (NSArray *)toEnvelopeAddresses; - (NSArray *)ccEnvelopeAddresses; diff --git a/SOGo/SoObjects/Mailer/SOGoMailObject.m b/SOGo/SoObjects/Mailer/SOGoMailObject.m index 008fc8f6..51ee3e7f 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailObject.m +++ b/SOGo/SoObjects/Mailer/SOGoMailObject.m @@ -165,7 +165,7 @@ static BOOL debugBodyStructure = NO; - (NSCalendarDate *)date { return [[self envelope] date]; } -- (NGImap4EnvelopeAddress *)fromEnvelopeAddress { +- (NSArray *)fromEnvelopeAddresses { return [[self envelope] from]; } - (NSArray *)toEnvelopeAddresses { diff --git a/SOGo/SoObjects/Mailer/Version b/SOGo/SoObjects/Mailer/Version index 6ce68cb9..4a26ace7 100644 --- a/SOGo/SoObjects/Mailer/Version +++ b/SOGo/SoObjects/Mailer/Version @@ -1,9 +1,10 @@ # Version file -SUBMINOR_VERSION:=68 +SUBMINOR_VERSION:=69 -# v0.9.55 requires NGExtensions v4.5.136 -# v0.9.44 requires libNGMime v4.3.194 -# v0.9.41 requires libNGMime v4.3.190 -# v0.9.35 requires libSOGoLogic v0.9.24 -# v0.9.34 requires libSOGoLogic v0.9.22 +# v0.9.69 requires libNGMime v4.5.210 +# v0.9.55 requires libNGExtensions v4.5.136 +# v0.9.44 requires libNGMime v4.3.194 +# v0.9.41 requires libNGMime v4.3.190 +# v0.9.35 requires libSOGoLogic v0.9.24 +# v0.9.34 requires libSOGoLogic v0.9.22 diff --git a/SOGo/UI/Mailer/ChangeLog b/SOGo/UI/Mailer/ChangeLog index 52d64f36..8fd5d3d0 100644 --- a/SOGo/UI/Mailer/ChangeLog +++ b/SOGo/UI/Mailer/ChangeLog @@ -1,5 +1,12 @@ 2005-02-08 Helge Hess + * v0.9.94 + + * UIxMailListView.m: properly show "to" address in tableview for + Sent folder + + * UIxMailView.m: fixed for new 'from' API + * v0.9.93 * mailer.js: work on the read-mail marking code, properly change the diff --git a/SOGo/UI/Mailer/UIxMailEditorAction.m b/SOGo/UI/Mailer/UIxMailEditorAction.m index 6a88bdd5..675a673c 100644 --- a/SOGo/UI/Mailer/UIxMailEditorAction.m +++ b/SOGo/UI/Mailer/UIxMailEditorAction.m @@ -175,10 +175,55 @@ return r; } -/* response actions */ +/* reply */ + +- (BOOL)hasReplyPrefix:(NSString *)_subject { + static NSString *replyPrefixes[] = { + @"Re:", // regular + @"RE:", // Outlook v11 (English?) + @"AW:", // German Outlook v11 + @"Re[", // numbered Re, eg "Re[2]:" + nil + }; + unsigned i; + for (i = 0; replyPrefixes[i] != nil; i++) { + if ([_subject hasPrefix:replyPrefixes[i]]) + return YES; + } + return NO; +} + +- (NSString *)replySubject:(NSString *)_subject { + if (![_subject isNotNull] || [_subject length] == 0) + return _subject; + + if ([self hasReplyPrefix:_subject]) { + /* do not do: "Re: Re: Re: My Mail" - a single Re is sufficient ;-) */ + return _subject; + } + + return [@"Re: " stringByAppendingString:_subject]; +} + +- (void)fillInReplyAddresses:(NSMutableDictionary *)_info + replyToAll:(BOOL)_replyToAll + envelope:(NGImap4Envelope *)_envelope +{ + /* + The rules (as checked against Thunderbird): + - if there is a 'reply-to' header, only include that (as TO) + - if we reply to all, all non-from addresses are added as CC + - the from is always the lone TO (except for reply-to) + + TODO: what about sender (RFC 822 3.6.2) + */ + [self logWithFormat:@"env: %@", _envelope]; +} - (id)replyToAll:(BOOL)_replyToAll { + NSMutableDictionary *info; NSException *error; + id result; id tmp; /* ensure mail exists and is filled */ @@ -196,12 +241,36 @@ if ((error = [self _setupNewDraft]) != nil) return error; + /* fill draft info */ + + info = [NSMutableDictionary dictionaryWithCapacity:16]; + + [info setObject:[self replySubject:[[self clientObject] subject]] + forKey:@"subject"]; + [self fillInReplyAddresses:info replyToAll:_replyToAll + envelope:[[self clientObject] envelope]]; + + /* fill content */ + + /* save draft info */ + + [self logWithFormat:@"INFO: %@", info]; + +#if 0 + if ((error = [self->newDraft storeInfo:info]) != nil) + return error; +#endif + #if 0 - [self logWithFormat:@"CORE: %@", [[self clientObject] fetchCoreInfos]]; + // TODO: we might want to pass the original URL to the editor for a final + // redirect back to the message? + result = [self redirectToEditNewDraft]; +#else + result = [NSException exceptionWithHTTPStatus:501 /* Not Implemented */ + reason:@"Sorry, reply is not yet implemented!"]; #endif [self reset]; - return [NSException exceptionWithHTTPStatus:501 /* Not Implemented */ - reason:@"Sorry, reply is not yet implemented!"]; + return result; } - (id)replyAction { @@ -211,6 +280,8 @@ return [self replyToAll:YES]; } +/* forwarding */ + - (NSString *)getAttachmentNameForSubject:(NSString *)_subject { /* SOGoDraftObject disallows some strings - anything else required? */ static NSString *sescape[] = { @@ -262,7 +333,7 @@ return error; /* set subject (do we need to set anything else?) */ - + info = [NSDictionary dictionaryWithObjectsAndKeys: [self forwardSubject:[[self clientObject] subject]], @"subject", diff --git a/SOGo/UI/Mailer/UIxMailListView.m b/SOGo/UI/Mailer/UIxMailListView.m index 917edaf3..63365076 100644 --- a/SOGo/UI/Mailer/UIxMailListView.m +++ b/SOGo/UI/Mailer/UIxMailListView.m @@ -78,8 +78,10 @@ static int attachmentFlagSize = 8096; } - (BOOL)showToAddress { - // TODO: switch for Sent folder - return NO; + NSString *ftype; + + ftype = [[self clientObject] valueForKey:@"outlookFolderClass"]; + return [ftype isEqual:@"IPF.Sent"]; } /* title */ diff --git a/SOGo/UI/Mailer/UIxMailView.m b/SOGo/UI/Mailer/UIxMailView.m index d7ffaedd..9cb519c0 100644 --- a/SOGo/UI/Mailer/UIxMailView.m +++ b/SOGo/UI/Mailer/UIxMailView.m @@ -79,10 +79,6 @@ return [@"mailto:" stringByAppendingString:[_address baseEMail]]; } -- (NSString *)fromLink { - return [self linkToEnvelopeAddress: - [[self clientObject] fromEnvelopeAddress]]; -} - (NSString *)currentAddressLink { return [self linkToEnvelopeAddress:[self currentAddress]]; } diff --git a/SOGo/UI/Mailer/UIxMailView.wox b/SOGo/UI/Mailer/UIxMailView.wox index 381d69b0..be283004 100644 --- a/SOGo/UI/Mailer/UIxMailView.wox +++ b/SOGo/UI/Mailer/UIxMailView.wox @@ -10,6 +10,8 @@ title="panelTitle" const:hideFolderTree="1" > + +