/* Copyright (C) 2000-2004 SKYRIX Software AG This file is part of OpenGroupware.org. OGo is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. OGo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with OGo; see the file COPYING. If not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // $Id$ #include "SxRSSRenderer.h" #include "common.h" #include #include #include #include @implementation SxRSSRenderer + (id)renderer { return [[[self alloc] init] autorelease]; } - (NSString *)title { return [self subclassResponsibility:_cmd]; } - (NSString *)info { return [self subclassResponsibility:_cmd]; } - (NSString *)viewURI { return [self subclassResponsibility:_cmd]; } - (NSString *)skyrixLinkForEO:(EOGenericRecord *)_task { NSUserDefaults *ud; NSString *linkPrefix; ud = [NSUserDefaults standardUserDefaults]; if ((linkPrefix = [ud valueForKey:@"SxSkyrixLinkPrefix"]) != nil) { NSString *objectId; objectId = [[[_task valueForKey:@"globalID"] keyValuesArray] objectAtIndex:0]; return [NSString stringWithFormat: @"%@/OpenGroupware.org/wa/LSWViewAction/%@=%@", linkPrefix, [self viewURI], objectId]; } return nil; } - (NSString *)rssHeader { NSMutableString *h; h = [NSMutableString stringWithCapacity:256]; [h appendString:@"\n"]; [h appendString:@"\n\n"]; [h appendString:@"\n\n"]; [h appendString:[self title]]; [h appendString:@"\n"]; [h appendString:[self info]]; [h appendString:@"\nde-de\n"]; return h; } - (NSString *)rssFooter { return @"\n"; } - (NSString *)itemHeader { return @"\n"; } - (NSString *)itemFooter { return @"\n\n"; } - (NSString *)rssStringForFolder:(SxFolder *)_folder inContext:(id)_ctx { return [self subclassResponsibility:_cmd]; } - (WOResponse *)rssResponseForFolder:(SxFolder *)_folder inContext:(id)_ctx { WOResponse *response; NSString *data; response = [WOResponse responseWithRequest:[_ctx request]]; if ((data = [self rssStringForFolder:_folder inContext:_ctx]) != nil) { NSData *contentData; contentData = [NSData dataWithBytes:[data cString] length:[data cStringLength]]; [response setStatus:200 /* OK */]; [response setContent:contentData]; } else { [self logWithFormat:@"ERROR: got no RSS for folder: %@", _folder]; [response setStatus:500 /* server error */]; } return response; } @end /* SxRSSRenderer */