// $Id$ #include @interface SOGoUserHomePage : SoComponent { } - (NSString *)ownPath; - (NSString *)userFolderPath; - (NSString *)relativePathToUserFolderSubPath:(NSString *)_sub; - (NSString *)relativeCalendarPath; - (NSString *)relativeContactsPath; - (NSString *)relativeMailPath; @end #include "common.h" @implementation SOGoUserHomePage - (id)initWithContext:(id)_ctx { if ((self = [super initWithContext:_ctx])) { } return self; } - (void)dealloc { [super dealloc]; } /* 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 */