/* Copyright (C) 2004-2005 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. */ #include @interface SOGoUserHomePage : SoComponent { } - (NSString *)ownPath; - (NSString *)userFolderPath; - (NSString *)relativePathToUserFolderSubPath:(NSString *)_sub; - (NSString *)relativeCalendarPath; - (NSString *)relativeContactsPath; - (NSString *)relativeMailPath; @end #include "common.h" @implementation SOGoUserHomePage /* lookup */ - (id)lookupName:(NSString *)_key inContext:(id)_ctx acquire:(BOOL)_flag { // Note: we do no acquisition id obj; /* first check attributes directly bound to the object */ if ((obj = [super lookupName:_key inContext:_ctx acquire:NO])) return obj; return nil; } /* paths */ - (NSString *)ownPath { NSString *uri; NSRange r; uri = [[[self context] request] uri]; /* first: cut off query parameters */ r = [uri rangeOfString:@"?" options:NSBackwardsSearch]; if (r.length > 0) uri = [uri substringToIndex:r.location]; return uri; } - (NSString *)userFolderPath { WOContext *ctx; NSArray *traversalObjects; NSString *url; ctx = [self context]; traversalObjects = [ctx objectTraversalStack]; url = [[traversalObjects objectAtIndex:1] baseURLInContext:ctx]; return [[NSURL URLWithString:url] path]; } - (NSString *)relativePathToUserFolderSubPath:(NSString *)_sub { NSString *dst, *rel; dst = [[self userFolderPath] stringByAppendingPathComponent:_sub]; rel = [dst urlPathRelativeToPath:[self ownPath]]; return rel; } - (NSString *)relativeCalendarPath { return [self relativePathToUserFolderSubPath:@"Calendar/"]; } - (NSString *)relativeContactsPath { return [self relativePathToUserFolderSubPath:@"Contacts/"]; } - (NSString *)relativeMailPath { return [self relativePathToUserFolderSubPath:@"Mail/"]; } /* actions */ - (id)defaultAction { return [self redirectToLocation:[self relativeCalendarPath]]; } @end /* SOGoUserHomePage */