+2004-10-28 Helge Hess <helge.hess@skyrix.com>
+
+ * NGImap4Envelope.m: added constructor method:
+ -initWithMessageID:subject:sender:replyTo:to:cc:bcc:
+
2004-10-27 Helge Hess <helge.hess@opengroupware.org>
* NGImap4EnvelopeAddress.m: added -initWithString: method (not properly
@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];