From: helge Date: Tue, 8 Feb 2005 17:04:34 +0000 (+0000) Subject: fixed API of the NGImap4Envelope (from/reply-to are multivalue fields!) X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c2e463ca518e881ba32280dd2c5b2ccc7ee8d5c8;p=sope fixed API of the NGImap4Envelope (from/reply-to are multivalue fields!) git-svn-id: http://svn.opengroupware.org/SOPE/trunk@542 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- diff --git a/sope-mime/ChangeLog b/sope-mime/ChangeLog index a86a3631..e10fe015 100644 --- a/sope-mime/ChangeLog +++ b/sope-mime/ChangeLog @@ -1,3 +1,8 @@ +2005-02-08 Helge Hess + + * NGImap4: change in API: NGImap4Envelope now uses lists for 'from' + and 'reply-to' headers (v4.5.210) + 2005-01-31 Helge Hess * NGImap4: added support for creating envelope objects from body diff --git a/sope-mime/NGImap4/ChangeLog b/sope-mime/NGImap4/ChangeLog index 4f5e08b1..16d4b691 100644 --- a/sope-mime/NGImap4/ChangeLog +++ b/sope-mime/NGImap4/ChangeLog @@ -1,3 +1,11 @@ +2005-02-08 Helge Hess + + * NGImap4ResponseParser.m: properly parse from/reply-to as lists + + * NGImap4Envelope.m: properly use NSArray for 'from' and 'reply-to', + both can be multi valued (only 'sender' is a single mailbox in RFC + 2822, 3.6.2) - Note: might break API! + 2005-01-31 Helge Hess * NGImap4Envelope.m, NGImap4EnvelopeAddress.m: added support for diff --git a/sope-mime/NGImap4/NGImap4Envelope.h b/sope-mime/NGImap4/NGImap4Envelope.h index 484f218f..c5e2dbcd 100644 --- a/sope-mime/NGImap4/NGImap4Envelope.h +++ b/sope-mime/NGImap4/NGImap4Envelope.h @@ -40,16 +40,16 @@ id subject; /* can be either NSData or NSString */ NSString *inReplyTo; NSString *msgId; - NGImap4EnvelopeAddress *from; NGImap4EnvelopeAddress *sender; - NGImap4EnvelopeAddress *replyTo; + NSArray *from; + NSArray *replyTo; NSArray *to; NSArray *cc; NSArray *bcc; } - (id)initWithMessageID:(NSString *)_msgID subject:(NSString *)_subject - sender:(id)_sender replyTo:(id)_replyTo + from:(NSArray *)_sender replyTo:(NSArray *)_replyTo to:(NSArray *)_to cc:(NSArray *)_cc bcc:(NSArray *)_bcc; - (id)initWithBodyStructureInfo:(NSDictionary *)_info; @@ -60,9 +60,9 @@ - (id)subject; - (NSString *)inReplyTo; - (NSString *)messageID; -- (NGImap4EnvelopeAddress *)from; - (NGImap4EnvelopeAddress *)sender; -- (NGImap4EnvelopeAddress *)replyTo; +- (NSArray *)from; +- (NSArray *)replyTo; - (NSArray *)to; - (NSArray *)cc; - (NSArray *)bcc; diff --git a/sope-mime/NGImap4/NGImap4Envelope.m b/sope-mime/NGImap4/NGImap4Envelope.m index d774dfe5..2590d1df 100644 --- a/sope-mime/NGImap4/NGImap4Envelope.m +++ b/sope-mime/NGImap4/NGImap4Envelope.m @@ -76,42 +76,34 @@ static NGMimeRFC822DateHeaderFieldParser *dateParser = nil; } - (id)initWithMessageID:(NSString *)_msgID subject:(NSString *)_subject - sender:(id)_sender replyTo:(id)_replyTo + from:(NSArray *)_from replyTo:(NSArray *)_replyTo to:(NSArray *)_to cc:(NSArray *)_cc bcc:(NSArray *)_bcc { if ((self = [self init])) { self->msgId = [_msgID copy]; self->subject = [_subject copy]; - self->from = [self newEnvelopeAddressForEMail:_sender]; - self->replyTo = [self newEnvelopeAddressForEMail:_replyTo]; - - self->to = [[self envelopeAddressesForEMails:_to] copy]; - self->cc = [[self envelopeAddressesForEMails:_cc] copy]; - self->bcc = [[self envelopeAddressesForEMails:_bcc] copy]; + self->from = [[self envelopeAddressesForEMails:_from] copy]; + self->replyTo = [[self envelopeAddressesForEMails:_replyTo] copy]; + self->to = [[self envelopeAddressesForEMails:_to] copy]; + self->cc = [[self envelopeAddressesForEMails:_cc] copy]; + self->bcc = [[self envelopeAddressesForEMails:_bcc] copy]; } return self; } - (id)initWithBodyStructureInfo:(NSDictionary *)_info { - id lFrom, lReplyTo, lDate; + id lDate; if (![_info isNotNull]) { [self release]; return nil; } - - lFrom = [_info valueForKey:@"from"]; - lReplyTo = [_info valueForKey:@"reply-to"]; - - if ([lFrom isKindOfClass:[NSArray class]]) - lFrom = [lFrom count] > 0 ? [lFrom objectAtIndex:0] : nil; - if ([lReplyTo isKindOfClass:[NSArray class]]) - lReplyTo = [lReplyTo count] > 0 ? [lReplyTo objectAtIndex:0] : nil; self = [self initWithMessageID:[_info valueForKey:@"messageId"] subject:[_info valueForKey:@"subject"] - sender:lFrom replyTo:lReplyTo + from:[_info valueForKey:@"from"] + replyTo:[_info valueForKey:@"reply-to"] to:[_info valueForKey:@"to"] cc:[_info valueForKey:@"cc"] bcc:[_info valueForKey:@"bcc"]]; @@ -159,13 +151,13 @@ static NGMimeRFC822DateHeaderFieldParser *dateParser = nil; - (NSString *)messageID { return self->msgId; } -- (NGImap4EnvelopeAddress *)from { +- (NSArray *)from { return self->from; } - (NGImap4EnvelopeAddress *)sender { return self->sender; } -- (NGImap4EnvelopeAddress *)replyTo { +- (NSArray *)replyTo { return self->replyTo; } - (NSArray *)to { @@ -203,8 +195,9 @@ static NGMimeRFC822DateHeaderFieldParser *dateParser = nil; if (self->msgId) [ms appendFormat:@" msgid='%@'", self->msgId]; if (self->inReplyTo) [ms appendFormat:@" inreplyto='%@'", self->inReplyTo]; - if (self->from) [ms appendFormat:@" from=%@", [self->from email]]; - if (self->sender) [ms appendFormat:@" sender=%@", [self->sender email]]; + if (self->from) [ms appendFormat:@" from=%@", self->from]; + if (self->replyTo) [ms appendFormat:@" reply-to=%@", self->replyTo]; + if (self->sender) [ms appendFormat:@" sender=%@", [self->sender email]]; if (self->to) [ms appendFormat:@" to=%@", self->to]; if (self->cc) [ms appendFormat:@" cc=%@", self->cc]; diff --git a/sope-mime/NGImap4/NGImap4ResponseParser.m b/sope-mime/NGImap4/NGImap4ResponseParser.m index 7fd988d7..561f247d 100644 --- a/sope-mime/NGImap4/NGImap4ResponseParser.m +++ b/sope-mime/NGImap4/NGImap4ResponseParser.m @@ -1179,7 +1179,7 @@ static BOOL _parseThreadResponse(NGImap4ResponseParser *self, /* parse addresses */ if ((tmp = [self _parseEnvelopeAddressStructures]) != nil) { - env->from = [tmp isNotNull] ? [[tmp lastObject] copy] : nil; + env->from = [tmp isNotNull] ? [tmp copy] : nil; [self _consumeOptionalSpace]; } else { @@ -1195,7 +1195,7 @@ static BOOL _parseThreadResponse(NGImap4ResponseParser *self, return nil; } if ((tmp = [self _parseEnvelopeAddressStructures]) != nil) { - env->replyTo = [tmp isNotNull] ? [[tmp lastObject] copy] : nil; + env->replyTo = [tmp isNotNull] ? [tmp copy] : nil; [self _consumeOptionalSpace]; } diff --git a/sope-mime/Version b/sope-mime/Version index 87dde2f4..4d323dc0 100644 --- a/sope-mime/Version +++ b/sope-mime/Version @@ -2,6 +2,6 @@ MAJOR_VERSION:=4 MINOR_VERSION:=5 -SUBMINOR_VERSION:=209 +SUBMINOR_VERSION:=210 # v4.2.149 requires libNGStreams v4.2.34