2 Copyright (C) 2000-2005 SKYRIX Software AG
4 This file is part of SOPE.
6 SOPE is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with SOPE; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #include "NGMailAddressList.h"
25 @implementation NGMailAddressList
31 + (id)mailAddressListWithAddresses:(NSSet *)_addresses
32 groupName:(NSString *)_groupName {
33 return [[[NGMailAddressList alloc] initWithAddresses:_addresses
34 groupName:_groupName] autorelease];
38 if ((self = [super init])) {
39 self->addresses = [[NSMutableSet alloc] init];
44 - (id)initWithAddresses:(NSSet *)_addresses groupName:(NSString *)_groupName {
45 if ((self = [self init])) {
47 [self->addresses unionSet:_addresses];
48 self->groupName = [_groupName copy];;
54 [self->addresses release];
55 [self->groupName release];
59 - (void)addAddress:(NGMailAddress *)_address {
60 [self->addresses addObject:_address];
65 - (BOOL)isEqual:(id)_anObject {
66 if ([_anObject isKindOfClass:[NGMailAddressList class]]) {
70 if (![self->groupName isEqualToString:[_anObject groupName]])
74 initWithObjectsFromEnumerator:
75 [(NGMailAddressList *)_anObject addresses]];
76 result = [self->addresses isEqualToSet:set];
77 [set release]; set = nil;
85 - (void)encodeWithCoder:(NSCoder *)_encoder {
86 [_encoder encodeObject:self->addresses];
87 [_encoder encodeObject:self->groupName];
90 - (id)initWithCoder:(NSCoder *)_decoder {
91 id _addresses, _groupName;
93 _addresses = [_decoder decodeObject];
94 _groupName = [_decoder decodeObject];
96 return [self initWithAddresses:_addresses groupName:_groupName];
101 - (id)copyWithZone:(NSZone *)_zone {
102 return [[NGMailAddressList allocWithZone:_zone]
103 initWithAddresses:self->addresses
104 groupName:self->groupName];
109 - (NSEnumerator *)addresses {
110 return [self->addresses objectEnumerator];
113 - (void)setGroupName:(NSString *)_name {
114 ASSIGN(self->groupName, _name);
116 - (NSString *)groupName {
117 return self->groupName;
122 - (NSString *)description {
123 return [NSString stringWithFormat:@"GroupName: %s \n %@\n",
124 [self->groupName cString],
128 @end /* NGMailAddressList */