]> err.no Git - sope/blob - sope-ical/NGiCal/iCalPerson.m
import of overhauled version of versitSaxDriver
[sope] / sope-ical / NGiCal / iCalPerson.m
1 /*
2   Copyright (C) 2000-2003 SKYRIX Software AG
3
4   This file is part of OGo
5
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
9   later version.
10
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.
15
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
19   02111-1307, USA.
20 */
21 // $Id$
22
23 #include "iCalPerson.h"
24 #include "common.h"
25
26 @implementation iCalPerson
27
28 - (void)dealloc {
29   [self->rsvp     release];
30   [self->partStat release];
31   [self->role     release];
32   [self->xuid     release];
33   [self->email release];
34   [self->cn    release];
35   [super dealloc];
36 }
37
38 /* accessors */
39
40 - (void)setCn:(NSString *)_s {
41   ASSIGNCOPY(self->cn, _s);
42 }
43 - (NSString *)cn {
44   return self->cn;
45 }
46
47 - (void)setEmail:(NSString *)_s {
48   ASSIGNCOPY(self->email, _s);
49 }
50 - (NSString *)email {
51   return self->email;
52 }
53
54 - (void)setRsvp:(NSString *)_s {
55   ASSIGNCOPY(self->rsvp, _s);
56 }
57 - (NSString *)rsvp {
58   return self->rsvp;
59 }
60
61 - (void)setXuid:(NSString *)_s {
62   ASSIGNCOPY(self->xuid, _s);
63 }
64 - (NSString *)xuid {
65   return self->xuid;
66 }
67
68 - (void)setRole:(NSString *)_s {
69   ASSIGNCOPY(self->role, _s);
70 }
71 - (NSString *)role {
72   return self->role;
73 }
74
75 - (void)setPartStat:(NSString *)_s {
76   ASSIGNCOPY(self->partStat, _s);
77 }
78 - (NSString *)partStat {
79   return self->partStat;
80 }
81
82 /* comparison */
83
84 - (unsigned)hash {
85   if([self email])
86     return [[self email] hash];
87   return [super hash];
88 }
89
90 - (BOOL)isEqual:(id)_other {
91   if(_other == nil)
92     return NO;
93   if([_other class] != self->isa)
94     return NO;
95   if([_other hash] != [self hash])
96     return NO;
97   return [self isEqualToPerson:_other];
98 }
99
100 - (BOOL)isEqualToPerson:(iCalPerson *)_other {
101   if(![self hasSameEmailAddress:_other])
102     return NO;
103   if(!IS_EQUAL([self cn], [_other cn], isEqualToString:))
104     return NO;
105   if(!IS_EQUAL([self rsvp], [_other rsvp], isEqualToString:))
106     return NO;
107   if(!IS_EQUAL([self partStat], [_other partStat], isEqualToString:))
108     return NO;
109   if(!IS_EQUAL([self role], [_other role], isEqualToString:))
110     return NO;
111   if(!IS_EQUAL([self xuid], [_other xuid], isEqualToString:))
112     return NO;
113   return YES;
114 }
115
116 - (BOOL)hasSameEmailAddress:(iCalPerson *)_other {
117   return IS_EQUAL([self email], [_other email], isEqualToString:);
118 }
119
120 /* descriptions */
121
122 - (NSString *)description {
123   NSMutableString *ms;
124
125   ms = [NSMutableString stringWithCapacity:128];
126   [ms appendFormat:@"<0x%08X[%@]:", self, NSStringFromClass([self class])];
127
128   if (self->cn)       [ms appendFormat:@" cn=%@",     self->cn];
129   if (self->email)    [ms appendFormat:@" email=%@",  self->email];
130   if (self->role)     [ms appendFormat:@" role=%@",   self->role];
131   if (self->xuid)     [ms appendFormat:@" uid=%@",    self->xuid];
132   if (self->partStat) [ms appendFormat:@" status=%@", self->partStat];
133   if (self->rsvp)     [ms appendFormat:@" rsvp=%@",   self->rsvp];
134
135   [ms appendString:@">"];
136   return ms;
137 }
138
139 @end /* iCalPerson */