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 #include "IcalResponse.h"
23 #import <Foundation/Foundation.h>
25 @implementation IcalResponse
27 - (void)_initContent {
28 [self appendLine:@"BEGIN:VCALENDAR"];
29 [self appendLine:@"VERSION:2.0"];
30 [self appendLine:@"PRODID:-//skyrix42/scheduler/skyaptd v.1.0//"];
34 if ((self = [super init])) {
35 self->content = [[NSMutableString alloc] initWithCapacity:0xFFFF];
36 self->isFinished = NO;
41 - (id)initWithCapacity:(unsigned)_capacity {
42 if ((self = [super init])) {
43 self->content = [[NSMutableString alloc] initWithCapacity:_capacity];
44 self->isFinished = NO;
51 [self->content release];
56 - (BOOL)appendLine:(NSString *)_line {
57 if (self->isFinished) {
58 NSLog(@"WARNING[%s]: already finished!", __PRETTY_FUNCTION__);
61 // limit length to 75 chars
62 while ([_line length] > 75) {
63 [self appendLine:[_line substringToIndex:75]];
64 _line = [@" " stringByAppendingString:[_line substringFromIndex:75]];
67 [self->content appendString:_line];
68 [self->content appendString:@"\r\n"];
73 - (BOOL)appendLine:(NSString *)_line forAttribute:(NSString *)_attr {
74 _line = [NSString stringWithFormat:@"%@:%@", _attr, _line];
75 return [self appendLine:_line];
80 if (self->isFinished) return;
81 [self appendLine:@"END:VCALENDAR"];
82 self->isFinished = YES;
85 - (NSString *)asString {
87 return [[self->content copy] autorelease];
90 @end /* IcalResponse */