2 Copyright (C) 2000-2003 SKYRIX Software AG
4 This file is part of OGo
6 OGo 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 OGo 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 OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 #include "IcalResponse.h"
24 #import <Foundation/Foundation.h>
26 @implementation IcalResponse
28 - (void)_initContent {
29 [self appendLine:@"BEGIN:VCALENDAR"];
30 [self appendLine:@"VERSION:2.0"];
31 [self appendLine:@"PRODID:-//skyrix42/scheduler/skyaptd v.1.0//"];
35 if ((self = [super init])) {
36 self->content = [[NSMutableString alloc] initWithCapacity:0xFFFF];
37 self->isFinished = NO;
42 - (id)initWithCapacity:(unsigned)_capacity {
43 if ((self = [super init])) {
44 self->content = [[NSMutableString alloc] initWithCapacity:_capacity];
45 self->isFinished = NO;
52 [self->content release];
57 - (BOOL)appendLine:(NSString *)_line {
58 if (self->isFinished) {
59 NSLog(@"WARNING[%s]: already finished!", __PRETTY_FUNCTION__);
62 // limit length to 75 chars
63 while ([_line length] > 75) {
64 [self appendLine:[_line substringToIndex:75]];
65 _line = [@" " stringByAppendingString:[_line substringFromIndex:75]];
68 [self->content appendString:_line];
69 [self->content appendString:@"\r\n"];
74 - (BOOL)appendLine:(NSString *)_line forAttribute:(NSString *)_attr {
75 _line = [NSString stringWithFormat:@"%@:%@", _attr, _line];
76 return [self appendLine:_line];
81 if (self->isFinished) return;
82 [self appendLine:@"END:VCALENDAR"];
83 self->isFinished = YES;
86 - (NSString *)asString {
88 return [[self->content copy] autorelease];
91 @end /* IcalResponse */