WOAPP_NAME = sogod
sogod_OBJC_FILES += \
- sogod.m
+ sogod.m \
+ SOGoProductLoader.m \
+ SOGoAuthenticator.m \
sogod_RESOURCE_FILES += \
Version \
--- /dev/null
+/*
+ Copyright (C) 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$
+
+#ifndef __Main_SOGoAuthenticator_H__
+#define __Main_SOGoAuthenticator_H__
+
+#include <NGObjWeb/SoHTTPAuthenticator.h>
+
+@interface SOGoAuthenticator : SoHTTPAuthenticator
+{
+}
+
++ (id)sharedSOGoAuthenticator;
+
+@end
+
+#endif /* __Main_SOGoAuthenticator_H__ */
--- /dev/null
+/*
+ Copyright (C) 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 "SOGoAuthenticator.h"
+#include "common.h"
+
+@implementation SOGoAuthenticator
+
+static SOGoAuthenticator *auth = nil; // THREAD
+
++ (id)sharedSOGoAuthenticator {
+ if (auth == nil)
+ auth = [[self alloc] init];
+ return auth;
+}
+
+- (void)dealloc {
+ [super dealloc];
+}
+
+/* check credentials */
+
+- (BOOL)checkLogin:(NSString *)_login password:(NSString *)_pwd {
+ if ([_login length] == 0)
+ return NO;
+
+ /* we accept any password since it is checked by Apache in front */
+ return YES;
+}
+
+@end /* SOGoAuthenticator */
--- /dev/null
+/*
+ Copyright (C) 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$
+
+#ifndef __Main_SOGoProductLoader_H__
+#define __Main_SOGoProductLoader_H__
+
+#import <Foundation/NSObject.h>
+
+@interface SOGoProductLoader : NSObject
+{
+ NSString *productDirectoryName;
+}
+
++ (id)productLoader;
+
+/* operations */
+
+- (void)loadProducts;
+
+@end
+
+#endif /* __Main_SOGoProductLoader_H__ */
--- /dev/null
+/*
+ Copyright (C) 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 "SOGoProductLoader.h"
+#include "common.h"
+
+@implementation SOGoProductLoader
+
++ (id)productLoader {
+ return [[[self alloc] init] autorelease];
+}
+
+- (id)init {
+ if ((self = [super init])) {
+ self->productDirectoryName = @"SOGo";
+ }
+ return self;
+}
+
+- (void)dealloc {
+ [self->productDirectoryName release];
+ [super dealloc];
+}
+
+/* loading */
+
+- (NSArray *)productSearchPathes {
+ static NSArray *searchPathes = nil;
+ NSMutableArray *ma;
+ NSDictionary *env;
+ id tmp;
+
+ if (searchPathes)
+ return searchPathes;
+
+ env = [[NSProcessInfo processInfo] environment];
+ ma = [NSMutableArray arrayWithCapacity:6];
+
+#if COCOA_Foundation_LIBRARY
+ tmp = NSSearchPathForDirectoriesInDomains(NSAllLibrariesDirectory,
+ NSAllDomainsMask,
+ YES);
+ if ([tmp count] > 0) {
+ NSEnumerator *e;
+
+ e = [tmp objectEnumerator];
+ while ((tmp = [e nextObject])) {
+ tmp = [tmp stringByAppendingPathComponent:self->productDirectoryName];
+ if (![ma containsObject:tmp])
+ [ma addObject:tmp];
+ }
+ }
+#else
+ if ((tmp = [env objectForKey:@"GNUSTEP_PATHPREFIX_LIST"]) == nil)
+ tmp = [env objectForKey:@"GNUSTEP_PATHLIST"];
+
+ tmp = [tmp componentsSeparatedByString:@":"];
+ if ([tmp count] > 0) {
+ NSEnumerator *e;
+
+ e = [tmp objectEnumerator];
+ while ((tmp = [e nextObject])) {
+ tmp = [tmp stringByAppendingPathComponent:@"Library"];
+ tmp = [tmp stringByAppendingPathComponent:self->productDirectoryName];
+ if (![ma containsObject:tmp])
+ [ma addObject:tmp];
+ }
+ }
+ else {
+ NSLog(@"%s: empty library search path !", __PRETTY_FUNCTION__);
+ }
+#endif
+
+ searchPathes = [ma copy];
+
+ if ([searchPathes count] == 0)
+ NSLog(@"%s: no search pathes were found !", __PRETTY_FUNCTION__);
+
+ return searchPathes;
+}
+
+- (void)loadProducts {
+ SoProductRegistry *registry = nil;
+ NSFileManager *fm;
+ NSEnumerator *pathes;
+ NSString *lpath;
+
+ registry = [SoProductRegistry sharedProductRegistry];
+ fm = [NSFileManager defaultManager];
+
+ pathes = [[self productSearchPathes] objectEnumerator];
+ while ((lpath = [pathes nextObject])) {
+ NSEnumerator *productNames;
+ NSString *productName;
+
+ productNames = [[fm directoryContentsAtPath:lpath] objectEnumerator];
+
+ while ((productName = [productNames nextObject])) {
+ NSString *bpath;
+
+ bpath = [lpath stringByAppendingPathComponent:productName];
+ [self logWithFormat:@"register SOGo product: %@",
+ [bpath lastPathComponent]];
+ [registry registerProductAtPath:bpath];
+ }
+ }
+
+ if (![registry loadAllProducts])
+ [self logWithFormat:@"WARNING: could not load all products !"];
+}
+
+@end /* SOGoProductLoader */
@end
+#include "SOGoAuthenticator.h"
+#include "SOGoProductLoader.h"
#include "common.h"
@implementation SOGo
+static unsigned int vMemSizeLimit = 0;
+
++ (void)initialize {
+ NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
+ id tmp;
+
+ /* vMem size check - default is 200MB */
+
+ tmp = [ud objectForKey:@"SxVMemLimit"];
+ vMemSizeLimit = (tmp != nil)
+ ? [tmp intValue]
+ : 200;
+ if (vMemSizeLimit > 0) {
+ NSLog(@"Note: vmem size check enabled: shutting down app when "
+ @"vmem > %d MB", vMemSizeLimit);
+ }
+}
+
- (id)init {
if ((self = [super init])) {
+ [[SOGoProductLoader productLoader] loadProducts];
+
+ /* setup some WebDAV type mappings required for Evolution */
+ [EOQualifier registerValueClass:NSClassFromString(@"dateTime")
+ forTypeName:@"dateTime"];
+ [EOQualifier registerValueClass:NSClassFromString(@"dateTime")
+ forTypeName:@"dateTime.tz"];
+
}
return self;
}
+/* authenticator */
+
+- (id)authenticatorInContext:(WOContext *)_ctx {
+ return [SOGoAuthenticator sharedSOGoAuthenticator];
+}
+
/* name lookup */
- (BOOL)isUserName:(NSString *)_key inContext:(id)_ctx {
abort();
}
+/* runtime maintenance */
+
+- (void)checkIfDaemonHasToBeShutdown {
+ unsigned int limit, vmem;
+
+ if ((limit = vMemSizeLimit) == 0)
+ return;
+
+ vmem = [[NSProcessInfo processInfo] virtualMemorySize]/1048576;
+
+ if (vmem > limit) {
+ [self logWithFormat:
+ @"terminating app, vMem size limit (%d MB) has been reached"
+ @" (currently %d MB)",
+ limit, vmem];
+ [self terminate];
+ }
+}
+
+- (WOResponse *)dispatchRequest:(WORequest *)_request {
+ static NSArray *runLoopModes = nil;
+ WOResponse *resp;
+
+ resp = [super dispatchRequest:_request];
+
+ if ([self isTerminating])
+ return resp;
+
+ if (runLoopModes == nil)
+ runLoopModes = [[NSArray alloc] initWithObjects:NSDefaultRunLoopMode, nil];
+
+ // TODO: a bit complicated? (-perform:afterDelay: doesn't work?)
+ [[NSRunLoop currentRunLoop] performSelector:
+ @selector(checkIfDaemonHasToBeShutdown)
+ target:self argument:nil
+ order:1 modes:runLoopModes];
+ return resp;
+}
+
@end /* SOGo */