From: znek Date: Mon, 13 Dec 2004 18:38:35 +0000 (+0000) Subject: convenience methods from SOGo X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4c444bb1650339e64968c76430f41b5bdc6b3619;p=sope convenience methods from SOGo git-svn-id: http://svn.opengroupware.org/SOPE/trunk@436 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- diff --git a/sope-ical/NGiCal/ChangeLog b/sope-ical/NGiCal/ChangeLog index 5be21981..d7e2e54a 100644 --- a/sope-ical/NGiCal/ChangeLog +++ b/sope-ical/NGiCal/ChangeLog @@ -1,3 +1,9 @@ +2004-12-13 Marcus Mueller + + * iCalPerson.[hm]: added -cnWithoutQuotes and -rfc822Email convenience + methods to simplify client code dealing with these properties + (v4.5.36) + 2004-11-07 Marcus Mueller * NGiCal.xcode: provide SOPE_{MAJOR,MINOR}_VERSION to the build diff --git a/sope-ical/NGiCal/Version b/sope-ical/NGiCal/Version index 40f730b0..32c124be 100644 --- a/sope-ical/NGiCal/Version +++ b/sope-ical/NGiCal/Version @@ -2,4 +2,4 @@ MAJOR_VERSION=4 MINOR_VERSION=5 -SUBMINOR_VERSION:=35 +SUBMINOR_VERSION:=36 diff --git a/sope-ical/NGiCal/iCalPerson.h b/sope-ical/NGiCal/iCalPerson.h index 2fb6bf87..83c098d9 100644 --- a/sope-ical/NGiCal/iCalPerson.h +++ b/sope-ical/NGiCal/iCalPerson.h @@ -39,9 +39,11 @@ - (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; diff --git a/sope-ical/NGiCal/iCalPerson.m b/sope-ical/NGiCal/iCalPerson.m index 0b707356..f9110eff 100644 --- a/sope-ical/NGiCal/iCalPerson.m +++ b/sope-ical/NGiCal/iCalPerson.m @@ -43,6 +43,20 @@ - (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); @@ -51,6 +65,19 @@ 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); }