]> err.no Git - sope/blob - sope-ical/NGiCal/iCalFreeBusy.m
742e4ad5f15c33c7cbf42bc89b6981b6c95398f0
[sope] / sope-ical / NGiCal / iCalFreeBusy.m
1 /*
2   Copyright (C) 2000-2005 SKYRIX Software AG
3
4   This file is part of SOPE.
5
6   SOPE 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   SOPE 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 SOPE; 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
22 #include "iCalFreeBusy.h"
23 #include "iCalPerson.h"
24 #include "common.h"
25
26 @implementation iCalFreeBusy
27
28 + (int)version {
29   return [super version] + 0 /* v0 */;
30 }
31 + (void)initialize {
32   NSAssert2([super version] == 0,
33             @"invalid superclass (%@) version %i !",
34             NSStringFromClass([self superclass]), [super version]);
35 }
36
37 - (void)dealloc {
38   [self->entries   release];
39   [self->organizer release];
40   [self->startDate release];
41   [self->endDate   release];
42   [self->url       release];
43   [super dealloc];
44 }
45
46 /* NSCopying */
47
48 - (id)copyWithZone:(NSZone *)_zone {
49   iCalFreeBusy *new;
50   
51   new = [super copyWithZone:_zone];
52   
53   ASSIGNCOPY(new->entries,   self->entries);
54   ASSIGNCOPY(new->organizer, self->organizer);
55   ASSIGNCOPY(new->startDate, self->startDate);
56   ASSIGNCOPY(new->endDate,   self->endDate);
57   ASSIGNCOPY(new->url,       self->url);
58   
59   return new;
60 }
61
62 /* accessors */
63
64 - (void)setUrl:(NSString *)_url {
65   ASSIGN(self->url, _url);
66 }
67 - (NSString *)url {
68   return self->url;
69 }
70
71 - (void)setStartDate:(NSCalendarDate *)_date {
72   ASSIGN(self->startDate, _date);
73 }
74 - (NSCalendarDate *)startDate {
75   return self->startDate;
76 }
77
78 - (void)setEndDate:(NSCalendarDate *)_date {
79   ASSIGN(self->endDate, _date);
80 }
81 - (NSCalendarDate *)endDate {
82   return self->endDate;
83 }
84
85 - (void)setOrganizer:(iCalPerson *)_organizer {
86   ASSIGN(self->organizer, _organizer);
87 }
88 - (iCalPerson *)organizer {
89   return self->organizer;
90 }
91
92 - (void)addToEntries:(id)_obj {
93   if (_obj == nil) return;
94   if (self->entries == nil)
95     self->entries = [[NSMutableArray alloc] initWithCapacity:1];
96   [self->entries addObject:_obj];
97 }
98
99 /* ical typing */
100
101 - (NSString *)entityName {
102   return @"vfreebusy";
103 }
104
105 /* descriptions */
106
107 - (NSString *)description {
108   NSMutableString *ms;
109
110   ms = [NSMutableString stringWithCapacity:128];
111   [ms appendFormat:@"<0x%08X[%@]:", self, NSStringFromClass([self class])];
112
113   if (self->startDate) [ms appendFormat:@" from=%@", self->startDate];
114   if (self->endDate)   [ms appendFormat:@" to=%@", self->endDate];
115   
116   if (self->organizer)
117     [ms appendFormat:@" organizer=%@", self->organizer];
118   
119   if ([self->entries count] > 0)
120     [ms appendFormat:@" %@", self->entries];
121   
122   [ms appendString:@">"];
123   return ms;
124 }
125
126 @end /* iCalFreeBusy */