From: znek Date: Fri, 17 Dec 2004 12:10:21 +0000 (+0000) Subject: formal definitions of participantStatus X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c96af634259607b63cc8af42fb5f6d3802b58a9d;p=sope formal definitions of participantStatus git-svn-id: http://svn.opengroupware.org/SOPE/trunk@450 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- diff --git a/sope-ical/NGiCal/ChangeLog b/sope-ical/NGiCal/ChangeLog index ec3e4cd0..40dfc469 100644 --- a/sope-ical/NGiCal/ChangeLog +++ b/sope-ical/NGiCal/ChangeLog @@ -1,3 +1,9 @@ +2004-12-17 Marcus Mueller + + * iCalPerson.[hm]: formalized participationStatus according to RFC2445. + Provided convenience API to set status without concrete knowledge + of string values involved. (v4.5.38) + 2004-12-16 Marcus Mueller * v4.5.37 diff --git a/sope-ical/NGiCal/Version b/sope-ical/NGiCal/Version index 6329c0fc..177d90a9 100644 --- a/sope-ical/NGiCal/Version +++ b/sope-ical/NGiCal/Version @@ -2,6 +2,6 @@ MAJOR_VERSION=4 MINOR_VERSION=5 -SUBMINOR_VERSION:=37 +SUBMINOR_VERSION:=38 # v4.5.37 requires NGExtensions v4.5.140 diff --git a/sope-ical/NGiCal/iCalPerson.h b/sope-ical/NGiCal/iCalPerson.h index 83c098d9..524082b3 100644 --- a/sope-ical/NGiCal/iCalPerson.h +++ b/sope-ical/NGiCal/iCalPerson.h @@ -25,14 +25,31 @@ #include +typedef enum { + iCalPersonPartStatNeedsAction = 0, /* NEEDS-ACTION (DEFAULT) */ + iCalPersonPartStatAccepted = 1, /* ACCEPTED */ + iCalPersonPartStatDeclined = 2, /* DECLINED */ + /* up to here defined for VJOURNAL */ + iCalPersonPartStatTentative = 3, /* TENTATIVE */ + iCalPersonPartStatDelegated = 4, /* DELEGATED */ + /* up to here defined for VEVENT */ + iCalPersonPartStatCompleted = 5, /* COMPLETED */ + iCalPersonPartStatInProcess = 6, /* IN-PROCESS */ + /* up to there defined for VTODO */ + + /* these are also defined for VJOURNAL, VEVENT and VTODO */ + iCalPersonPartStatExperimental = 7, /* x-name */ + iCalPersonPartStatOther = 8 /* iana-token */ +} iCalPersonPartStat; + @interface iCalPerson : iCalObject { NSString *cn; NSString *email; - NSString *rsvp; /* FALSE */ - NSString *partStat; /* ACCEPTED */ - NSString *role; /* REQ-PARTICIPANT */ - NSString *xuid; /* x22sAAHFf */ + NSString *rsvp; /* i.e. FALSE */ + NSString *partStat; /* i.e. NEEDS-ACTION */ + NSString *role; /* i.e. REQ-PARTICIPANT */ + NSString *xuid; /* i.e. x22sAAHFf */ } /* accessors */ @@ -57,6 +74,9 @@ - (void)setPartStat:(NSString *)_s; - (NSString *)partStat; +- (void)setParticipationStatus:(iCalPersonPartStat)_status; +- (iCalPersonPartStat)participationStatus; + - (BOOL)isEqualToPerson:(iCalPerson *)_other; - (BOOL)hasSameEmailAddress:(iCalPerson *)_other; diff --git a/sope-ical/NGiCal/iCalPerson.m b/sope-ical/NGiCal/iCalPerson.m index f9110eff..72512d67 100644 --- a/sope-ical/NGiCal/iCalPerson.m +++ b/sope-ical/NGiCal/iCalPerson.m @@ -106,6 +106,65 @@ return self->partStat; } +- (void)setParticipationStatus:(iCalPersonPartStat)_status { + NSString *stat; + + switch (_status) { + case iCalPersonPartStatAccepted: + stat = @"ACCEPTED"; + break; + case iCalPersonPartStatDeclined: + stat = @"DECLINED"; + break; + case iCalPersonPartStatTentative: + stat = @"TENTATIVE"; + break; + case iCalPersonPartStatDelegated: + stat = @"DELEGATED"; + break; + case iCalPersonPartStatCompleted: + stat = @"COMPLETED"; + break; + case iCalPersonPartStatInProcess: + stat = @"IN-PROCESS"; + break; + case iCalPersonPartStatExperimental: + case iCalPersonPartStatOther: + [NSException raise:NSInternalInconsistencyException + format:@"Attempt to set meaningless " + @"participationStatus (%d)!", _status]; + break; + default: + stat = @"NEEDS-ACTION"; + break; + } + [self setPartStat:stat]; +} + +- (iCalPersonPartStat)participationStatus { + NSString *stat; + + stat = [[self partStat] uppercaseString]; + if (![stat isNotNull] || [stat isEqualToString:@"NEEDS-ACTION"]) + return iCalPersonPartStatNeedsAction; + else if ([stat isEqualToString:@"ACCEPTED"]) + return iCalPersonPartStatAccepted; + else if ([stat isEqualToString:@"DECLINED"]) + return iCalPersonPartStatDeclined; + else if ([stat isEqualToString:@"TENTATIVE"]) + return iCalPersonPartStatTentative; + else if ([stat isEqualToString:@"DELEGATED"]) + return iCalPersonPartStatDelegated; + else if ([stat isEqualToString:@"COMPLETED"]) + return iCalPersonPartStatCompleted; + else if ([stat isEqualToString:@"IN-PROCESS"]) + return iCalPersonPartStatInProcess; + else if ([stat hasPrefix:@"X-"]) + return iCalPersonPartStatExperimental; + return iCalPersonPartStatOther; +} + + /* comparison */ - (unsigned)hash {