2 Copyright (C) 2000-2003 SKYRIX Software AG
4 This file is part of OGo
6 OGo 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 OGo 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 OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 #include "NGMailAddress.h"
26 @implementation NGMailAddress
32 + (id)mailAddressWithAddress:(NSString *)_address
33 displayName:(NSString *)_owner
34 route:(NSString *)_route
36 return [[[NGMailAddress alloc] initWithAddress:_address
38 route:_route] autorelease];
41 - (id)initWithAddress:(NSString *)_address
42 displayName:(NSString *)_owner
43 route:(NSString *)_route
45 if ((self = [self init])) {
46 NSZone *zone = [self zone];
47 self->address = [_address copyWithZone:zone];
48 self->displayName = [_owner copyWithZone:zone];
49 self->route = [_route copyWithZone:zone];
55 [self->address release];
56 [self->displayName release];
57 [self->route release];
63 - (BOOL)isEqual:(id)_anObject {
64 if ([_anObject isKindOfClass:[NGMailAddress class]]) {
65 NGMailAddress *a = _anObject;
67 return (([self->address isEqualToString:[a address]]) &&
68 ([self->displayName isEqualToString:[a displayName]]) &&
69 ([self->route isEqualToString:[a route]]));
75 return [self->address hash];
80 - (void)encodeWithCoder:(NSCoder *)_encoder {
81 [_encoder encodeObject:address];
82 [_encoder encodeObject:displayName];
83 [_encoder encodeObject:route];
86 - (id)initWithCoder:(NSCoder *)_decoder {
87 id _address, _displayName, _route;
89 _address = [_decoder decodeObject];
90 _displayName = [_decoder decodeObject];
91 _route = [_decoder decodeObject];
92 return [self initWithAddress:_address
93 displayName:_displayName
99 - (id)copyWithZone:(NSZone *)_zone {
100 return [[NGMailAddress allocWithZone:_zone] initWithAddress:self->address
101 displayName:self->displayName
105 return [self copyWithZone:[self zone]];
110 - (void)setAddress:(NSString *)_string {
111 ASSIGN(self->address, _string);
113 - (NSString *)address {
114 return self->address;
117 - (void)setDisplayName:(NSString *)_displayName {
118 ASSIGN(self->displayName, _displayName);
120 - (NSString *)displayName {
121 return self->displayName;
124 - (void)setRoute:(NSString *)_route {
125 ASSIGN(self->route, _route);
127 - (NSString *)route {
133 - (NSString *)description {
134 return [NSString stringWithFormat:@"\"%s\" <%s> | route: %s",
135 [self->displayName cString],
136 [self->address cString],
137 [self->route cString]];
140 @end /* NGMailAddress */