+2004-12-13 Marcus Mueller <znek@mulle-kybernetik.com>
+
+ * iCalPerson.[hm]: added -cnWithoutQuotes and -rfc822Email convenience
+ methods to simplify client code dealing with these properties
+ (v4.5.36)
+
2004-11-07 Marcus Mueller <znek@mulle-kybernetik.com>
* NGiCal.xcode: provide SOPE_{MAJOR,MINOR}_VERSION to the build
- (void)setCn:(NSString *)_s;
- (NSString *)cn;
+- (NSString *)cnWithoutQuotes;
- (void)setEmail:(NSString *)_s;
- (NSString *)email;
+- (NSString *)rfc822Email; /* email without 'mailto:' prefix */
- (void)setRsvp:(NSString *)_s;
- (NSString *)rsvp;
- (NSString *)cn {
return self->cn;
}
+- (NSString *)cnWithoutQuotes {
+ /* remove quotes around a CN */
+ NSString *_cn;
+
+ _cn = [self cn];
+ if ([_cn length] <= 2)
+ return _cn;
+ if ([_cn characterAtIndex:0] != '"')
+ return _cn;
+ if (![_cn hasSuffix:@"\""])
+ return _cn;
+
+ return [_cn substringWithRange:NSMakeRange(1, [_cn length] - 2)];
+}
- (void)setEmail:(NSString *)_s {
ASSIGNCOPY(self->email, _s);
return self->email;
}
+- (NSString *)rfc822Email {
+ NSString *_email;
+ unsigned idx;
+
+ _email = [self email];
+ idx = NSMaxRange([_email rangeOfString:@":"]);
+
+ if ((idx > 0) && ([_email length] > idx))
+ return [_email substringFromIndex:idx];
+
+ return _email;
+}
+
- (void)setRsvp:(NSString *)_s {
ASSIGNCOPY(self->rsvp, _s);
}