2 Copyright (C) 2000-2005 SKYRIX Software AG
4 This file is part of SOPE.
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
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.
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
22 #import "IcalResponse.h"
24 @implementation IcalResponse
26 - (void)_initContent {
27 [self appendLine:@"BEGIN:VCALENDAR"];
28 [self appendLine:@"VERSION:2.0"];
29 [self appendLine:@"PRODID:-//skyrix42/scheduler/skyaptd v.1.0//"];
33 if ((self = [super init])) {
34 self->content = [[NSMutableString alloc] initWithCapacity:0xFFFF];
35 self->isFinished = NO;
40 - (id)initWithCapacity:(unsigned)_capacity {
41 if ((self = [super init])) {
42 self->content = [[NSMutableString alloc] initWithCapacity:_capacity];
43 self->isFinished = NO;
50 [self->content release];
55 - (BOOL)appendLine:(NSString *)_line {
56 if (self->isFinished) {
57 NSLog(@"WARNING[%s]: already finished!", __PRETTY_FUNCTION__);
60 // limit length to 75 chars
61 while ([_line length] > 75) {
62 [self appendLine:[_line substringToIndex:75]];
63 _line = [@" " stringByAppendingString:[_line substringFromIndex:75]];
66 [self->content appendString:_line];
67 [self->content appendString:@"\r\n"];
72 - (BOOL)appendLine:(NSString *)_line forAttribute:(NSString *)_attr {
73 _line = [NSString stringWithFormat:@"%@:%@", _attr, _line];
74 return [self appendLine:_line];
79 if (self->isFinished) return;
80 [self appendLine:@"END:VCALENDAR"];
81 self->isFinished = YES;
84 - (NSString *)asString {
86 return [[self->content copy] autorelease];
89 @end /* IcalResponse */