From e0939370288fb5aa18695ffe9e0d24ea1243d9a3 Mon Sep 17 00:00:00 2001 From: helge Date: Thu, 28 Oct 2004 15:07:35 +0000 Subject: [PATCH] NGImap4Envelope constructor git-svn-id: http://svn.opengroupware.org/SOPE/trunk@324 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- sope-mime/ChangeLog | 4 +++ sope-mime/NGImap4/ChangeLog | 5 +++ sope-mime/NGImap4/NGImap4Envelope.h | 4 +++ sope-mime/NGImap4/NGImap4Envelope.m | 53 +++++++++++++++++++++++++++++ sope-mime/Version | 2 +- 5 files changed, 67 insertions(+), 1 deletion(-) diff --git a/sope-mime/ChangeLog b/sope-mime/ChangeLog index 0bf3cfb0..89d2eb4a 100644 --- a/sope-mime/ChangeLog +++ b/sope-mime/ChangeLog @@ -1,3 +1,7 @@ +2004-10-28 Helge Hess + + * NGImap4: added a constructor to NGImap4Envelope (v4.3.194) + 2004-10-27 Helge Hess * NGImap4: enhanced NGImap4EnvelopeAddress (v4.3.193) diff --git a/sope-mime/NGImap4/ChangeLog b/sope-mime/NGImap4/ChangeLog index bdf16d5a..283277ae 100644 --- a/sope-mime/NGImap4/ChangeLog +++ b/sope-mime/NGImap4/ChangeLog @@ -1,3 +1,8 @@ +2004-10-28 Helge Hess + + * NGImap4Envelope.m: added constructor method: + -initWithMessageID:subject:sender:replyTo:to:cc:bcc: + 2004-10-27 Helge Hess * NGImap4EnvelopeAddress.m: added -initWithString: method (not properly diff --git a/sope-mime/NGImap4/NGImap4Envelope.h b/sope-mime/NGImap4/NGImap4Envelope.h index 8a0e5ea2..4777db83 100644 --- a/sope-mime/NGImap4/NGImap4Envelope.h +++ b/sope-mime/NGImap4/NGImap4Envelope.h @@ -48,6 +48,10 @@ NSArray *bcc; } +- (id)initWithMessageID:(NSString *)_msgID subject:(NSString *)_subject + sender:(id)_sender replyTo:(id)_replyTo + to:(NSArray *)_to cc:(NSArray *)_cc bcc:(NSArray *)_bcc; + /* accessors */ - (NSCalendarDate *)date; diff --git a/sope-mime/NGImap4/NGImap4Envelope.m b/sope-mime/NGImap4/NGImap4Envelope.m index cbeb1690..8b24928e 100644 --- a/sope-mime/NGImap4/NGImap4Envelope.m +++ b/sope-mime/NGImap4/NGImap4Envelope.m @@ -25,6 +25,59 @@ @implementation NGImap4Envelope +- (id)newEnvelopeAddressForEMail:(id)_email { + if (![_email isNotNull]) + return nil; + + if ([_email isKindOfClass:[NGImap4EnvelopeAddress class]]) + return [_email copy]; + + _email = [_email stringValue]; + if ([_email length] == 0) + return nil; + return [[NGImap4EnvelopeAddress alloc] initWithString:_email]; +} +- (NSArray *)envelopeAddressesForEMails:(NSArray *)_emails { + NSMutableArray *ma; + unsigned i, count; + + if (_emails == nil) + return nil; + if ((count = [_emails count]) == 0) + return [NSArray array]; + + ma = [NSMutableArray arrayWithCapacity:count]; + for (i = 0; i < count; i++) { + NGImap4EnvelopeAddress *envaddr; + + envaddr = [self newEnvelopeAddressForEMail:[_emails objectAtIndex:i]]; + if (![envaddr isNotNull]) + continue; + + [ma addObject:envaddr]; + [envaddr release]; + } + return ma; +} + +- (id)initWithMessageID:(NSString *)_msgID subject:(NSString *)_subject + sender:(id)_sender replyTo:(id)_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]; + } + return self; +} + - (void)dealloc { [self->date release]; [self->subject release]; diff --git a/sope-mime/Version b/sope-mime/Version index 4be618fe..a1f50532 100644 --- a/sope-mime/Version +++ b/sope-mime/Version @@ -2,6 +2,6 @@ MAJOR_VERSION:=4 MINOR_VERSION:=3 -SUBMINOR_VERSION:=193 +SUBMINOR_VERSION:=194 # v4.2.149 requires libNGStreams v4.2.34 -- 2.39.5