From 001a730b170cfb417b0c92500f7568adcda4d208 Mon Sep 17 00:00:00 2001 From: helge Date: Tue, 12 Jul 2005 10:31:46 +0000 Subject: [PATCH] work on defaults(profile) functionality git-svn-id: http://svn.opengroupware.org/SOGo/trunk@716 d1b88da0-ebda-0310-925b-ed51d893ca5b --- SOGo/Main/SOGoUser.h | 11 ++- SOGo/Main/SOGoUser.m | 11 +++ SOGo/OGoContentStore/ChangeLog | 5 + .../sql/appointment-create.psql | 3 +- .../sql/folderinfo-create.psql | 3 +- SOGo/OGoContentStore/sql/profile-create.psql | 9 ++ SOGo/SoObjects/SOGo/AgenorUserDefaults.h | 41 ++++++++ SOGo/SoObjects/SOGo/AgenorUserDefaults.m | 32 +++++++ SOGo/SoObjects/SOGo/AgenorUserManager.h | 4 +- SOGo/SoObjects/SOGo/AgenorUserManager.m | 7 ++ SOGo/SoObjects/SOGo/ChangeLog | 12 +++ SOGo/SoObjects/SOGo/GNUmakefile | 25 ++--- SOGo/SoObjects/SOGo/GNUmakefile.preamble | 5 +- SOGo/SoObjects/SOGo/Version | 2 +- SOGo/SoObjects/SOGo/agenor_defaults.m | 94 +++++++++++++++++++ 15 files changed, 240 insertions(+), 24 deletions(-) create mode 100644 SOGo/OGoContentStore/sql/profile-create.psql create mode 100644 SOGo/SoObjects/SOGo/AgenorUserDefaults.h create mode 100644 SOGo/SoObjects/SOGo/AgenorUserDefaults.m create mode 100644 SOGo/SoObjects/SOGo/agenor_defaults.m diff --git a/SOGo/Main/SOGoUser.h b/SOGo/Main/SOGoUser.h index 6eb5e55f..e4572479 100644 --- a/SOGo/Main/SOGoUser.h +++ b/SOGo/Main/SOGoUser.h @@ -34,12 +34,13 @@ context.activeUser */ -@class NSString, NSArray, NSURL; +@class NSString, NSArray, NSURL, NSUserDefaults; @interface SOGoUser : SoUser { - NSString *cn; - NSString *email; + NSString *cn; + NSString *email; + NSUserDefaults *userDefaults; } /* properties */ @@ -52,6 +53,10 @@ - (NSArray *)additionalEMailAddresses; - (NSURL *)freeBusyURL; +/* defaults */ + +- (NSUserDefaults *)userDefaults; + @end #endif /* __SOGoUser_H__ */ diff --git a/SOGo/Main/SOGoUser.m b/SOGo/Main/SOGoUser.m index cc131098..0eee0aef 100644 --- a/SOGo/Main/SOGoUser.m +++ b/SOGo/Main/SOGoUser.m @@ -26,6 +26,7 @@ @implementation SOGoUser - (void)dealloc { + [self->userDefaults release]; [self->cn release]; [self->email release]; [super dealloc]; @@ -71,4 +72,14 @@ return [[self userManager] getFreeBusyURLForUID:[self login]]; } +/* defaults */ + +- (NSUserDefaults *)userDefaults { + if (self->userDefaults == nil) { + self->userDefaults = + [[[self userManager] getUserDefaultsForUID:[self login]] retain]; + } + return self->userDefaults; +} + @end /* SOGoUser */ diff --git a/SOGo/OGoContentStore/ChangeLog b/SOGo/OGoContentStore/ChangeLog index 82bacc20..dc8f3308 100644 --- a/SOGo/OGoContentStore/ChangeLog +++ b/SOGo/OGoContentStore/ChangeLog @@ -1,3 +1,8 @@ +2005-07-12 Helge Hess + + * added sql/profile-create.psql to create the user-profile database + table (not strictly related to OCSContentStore) + 2005-07-05 Marcus Mueller * iCalEntityObject+OCS.m: fixed stupid extraction bug (v0.9.29) diff --git a/SOGo/OGoContentStore/sql/appointment-create.psql b/SOGo/OGoContentStore/sql/appointment-create.psql index 7b280be7..45bb70c3 100644 --- a/SOGo/OGoContentStore/sql/appointment-create.psql +++ b/SOGo/OGoContentStore/sql/appointment-create.psql @@ -1,6 +1,5 @@ --- $Id$ -- --- (C) 2004 SKYRIX Software AG +-- (C) 2004-2005 SKYRIX Software AG -- CREATE TABLE %s_quick ( diff --git a/SOGo/OGoContentStore/sql/folderinfo-create.psql b/SOGo/OGoContentStore/sql/folderinfo-create.psql index c8f5833b..d9df55f6 100644 --- a/SOGo/OGoContentStore/sql/folderinfo-create.psql +++ b/SOGo/OGoContentStore/sql/folderinfo-create.psql @@ -1,6 +1,5 @@ --- $Id$ -- --- (C) 2004 SKYRIX Software AG +-- (C) 2004-2005 SKYRIX Software AG -- -- TODO: -- add a unique constraints on path diff --git a/SOGo/OGoContentStore/sql/profile-create.psql b/SOGo/OGoContentStore/sql/profile-create.psql new file mode 100644 index 00000000..3bd9c5e4 --- /dev/null +++ b/SOGo/OGoContentStore/sql/profile-create.psql @@ -0,0 +1,9 @@ +-- +-- (C) 2005 SKYRIX Software AG +-- + +CREATE TABLE SOGo_user_profile ( + uid VARCHAR(255) NOT NULL PRIMARY KEY, + allowinternet SMALLINT DEFAULT 0, + timezonename VARCHAR(255) DEFAULT 'MET' +); diff --git a/SOGo/SoObjects/SOGo/AgenorUserDefaults.h b/SOGo/SoObjects/SOGo/AgenorUserDefaults.h new file mode 100644 index 00000000..cbffb82f --- /dev/null +++ b/SOGo/SoObjects/SOGo/AgenorUserDefaults.h @@ -0,0 +1,41 @@ +/* + Copyright (C) 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. +*/ + +#ifndef __AgenorUserDefaults_H_ +#define __AgenorUserDefaults_H_ + +#import + +/* + AgenorUserDefaults + + An object with the same API like NSUserDefaults which retrieves profile + information for users in the database. +*/ + +@interface AgenorUserDefaults : NSObject +{ + NSString *uid; +} + +@end + +#endif /* __AgenorUserDefaults_H_ */ diff --git a/SOGo/SoObjects/SOGo/AgenorUserDefaults.m b/SOGo/SoObjects/SOGo/AgenorUserDefaults.m new file mode 100644 index 00000000..18f6980b --- /dev/null +++ b/SOGo/SoObjects/SOGo/AgenorUserDefaults.m @@ -0,0 +1,32 @@ +/* + Copyright (C) 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 "AgenorUserDefaults.h" +#include "common.h" + +@implementation AgenorUserDefaults + +- (void)dealloc { + [self->uid release]; + [super dealloc]; +} + +@end /* AgenorUserDefaults */ diff --git a/SOGo/SoObjects/SOGo/AgenorUserManager.h b/SOGo/SoObjects/SOGo/AgenorUserManager.h index 7df36f4d..aa6a3aac 100644 --- a/SOGo/SoObjects/SOGo/AgenorUserManager.h +++ b/SOGo/SoObjects/SOGo/AgenorUserManager.h @@ -30,7 +30,7 @@ TODO: document */ -@class NSString, NSArray, NSURL; +@class NSString, NSArray, NSURL, NSUserDefaults; @class SOGoLRUCache; @interface AgenorUserManager : NSObject @@ -62,6 +62,8 @@ - (NSURL *)getFreeBusyURLForUID:(NSString *)_uid; +- (NSUserDefaults *)getUserDefaultsForUID:(NSString *)_uid; + @end #endif /* __AgenorUserManager_H_ */ diff --git a/SOGo/SoObjects/SOGo/AgenorUserManager.m b/SOGo/SoObjects/SOGo/AgenorUserManager.m index c47f0365..dfafce34 100644 --- a/SOGo/SoObjects/SOGo/AgenorUserManager.m +++ b/SOGo/SoObjects/SOGo/AgenorUserManager.m @@ -780,6 +780,13 @@ static NSArray *fromEMailAttrs = nil; return nil; } +/* defaults */ + +- (NSUserDefaults *)getUserDefaultsForUID:(NSString *)_uid { + [self logWithFormat:@"TODO: implement!"]; + return nil; +} + /* debugging */ - (BOOL)isDebuggingEnabled { diff --git a/SOGo/SoObjects/SOGo/ChangeLog b/SOGo/SoObjects/SOGo/ChangeLog index 905da61d..131e1f43 100644 --- a/SOGo/SoObjects/SOGo/ChangeLog +++ b/SOGo/SoObjects/SOGo/ChangeLog @@ -1,3 +1,15 @@ +2005-07-12 Helge Hess + + * v0.9.43 + + * added agenor_defaults tool to test defaults functionality + + * AgenorUserManager.[hm]: added -getUserDefaultsForUID: method to + retrieve the profile of a user (incomplete) + + * added AgenorUserDefaults class (incomplete) as a wrapper for the + profile data of Agenor users + 2005-07-08 Helge Hess * v0.9.42 diff --git a/SOGo/SoObjects/SOGo/GNUmakefile b/SOGo/SoObjects/SOGo/GNUmakefile index c8659420..0e7bfe73 100644 --- a/SOGo/SoObjects/SOGo/GNUmakefile +++ b/SOGo/SoObjects/SOGo/GNUmakefile @@ -6,7 +6,12 @@ include $(GNUSTEP_MAKEFILES)/common.make -include ./Version LIBRARY_NAME = libSOGo -TOOL_NAME = agenor_email2uid agenor_shares4uid agenor_emails4uid + +TOOL_NAME = \ + agenor_email2uid \ + agenor_shares4uid \ + agenor_emails4uid \ + agenor_defaults libSOGo_SOVERSION=$(MAJOR_VERSION).$(MINOR_VERSION) @@ -44,23 +49,19 @@ libSOGo_OBJC_FILES = \ AgenorUserManager.m \ NSObject+AptComparison.m \ WOContext+Agenor.m \ + AgenorUserDefaults.m \ # tools -agenor_email2uid_OBJC_FILES += \ - agenor_email2uid.m \ - AgenorUserManager.m \ - SOGoLRUCache.m \ - -agenor_shares4uid_OBJC_FILES += \ - agenor_shares4uid.m \ +COMMON_TOOL_FILES = \ AgenorUserManager.m \ + AgenorUserDefaults.m \ SOGoLRUCache.m \ -agenor_emails4uid_OBJC_FILES += \ - agenor_emails4uid.m \ - AgenorUserManager.m \ - SOGoLRUCache.m \ +agenor_email2uid_OBJC_FILES += agenor_email2uid.m $(COMMON_TOOL_FILES) +agenor_shares4uid_OBJC_FILES += agenor_shares4uid.m $(COMMON_TOOL_FILES) +agenor_emails4uid_OBJC_FILES += agenor_emails4uid.m $(COMMON_TOOL_FILES) +agenor_defaults_OBJC_FILES += agenor_defaults.m $(COMMON_TOOL_FILES) -include GNUmakefile.preamble include $(GNUSTEP_MAKEFILES)/library.make diff --git a/SOGo/SoObjects/SOGo/GNUmakefile.preamble b/SOGo/SoObjects/SOGo/GNUmakefile.preamble index 59f2df93..07d977f9 100644 --- a/SOGo/SoObjects/SOGo/GNUmakefile.preamble +++ b/SOGo/SoObjects/SOGo/GNUmakefile.preamble @@ -24,6 +24,5 @@ libSOGo_LIBRARIES_DEPEND_UPON += \ -lXmlRpc -lDOM -lSaxObjC \ -lNGLdap -agenor_email2uid_TOOL_LIBS += -lNGLdap -agenor_shares4uid_TOOL_LIBS += -lNGLdap -agenor_emails4uid_TOOL_LIBS += -lNGLdap +ADDITIONAL_TOOL_LIBS += -lNGLdap + diff --git a/SOGo/SoObjects/SOGo/Version b/SOGo/SoObjects/SOGo/Version index d736dfc4..381f32bc 100644 --- a/SOGo/SoObjects/SOGo/Version +++ b/SOGo/SoObjects/SOGo/Version @@ -1,6 +1,6 @@ # version file -SUBMINOR_VERSION:=42 +SUBMINOR_VERSION:=43 # v0.9.34 requires libGDLContentStore v4.5.26 # v0.9.26 requires libOGoContentStore v0.9.13 diff --git a/SOGo/SoObjects/SOGo/agenor_defaults.m b/SOGo/SoObjects/SOGo/agenor_defaults.m new file mode 100644 index 00000000..0ba83f52 --- /dev/null +++ b/SOGo/SoObjects/SOGo/agenor_defaults.m @@ -0,0 +1,94 @@ +/* + Copyright (C) 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 "AgenorUserManager.h" +#include "common.h" + +static void usage(NSArray *args) { + fprintf(stderr, "usage: %s read|write []\n", + [[args objectAtIndex:0] cString]); +} + +static void doRead(NSUserDefaults *defaults, NSString *key) { + NSLog(@"TODO READ: %@", key); +} + +static void doWrite(NSUserDefaults *defaults, NSString *key, NSString *value) { + NSLog(@"TODO WRITE: %@", key, value); +} + +static void doIt(NSArray *args) { + AgenorUserManager *userManager; + NSUserDefaults *defaults; + NSString *uid, *op, *key, *value; + + /* extract arguments */ + + if ([args count] < 4) { + usage(args); + return; + } + + uid = [args objectAtIndex:1]; + op = [args objectAtIndex:2]; + key = [args objectAtIndex:3]; + value = nil; + + if ([op isEqualToString:@"write"]) { + if ([args count] < 5) { + usage(args); + return; + } + value = [args objectAtIndex:4]; + } + + /* run */ + + userManager = [AgenorUserManager sharedUserManager]; + defaults = [userManager getUserDefaultsForUID:uid]; + + if (![defaults isNotNull]) { + fprintf(stderr, "Error: found no userdefaults for UID: '%s'\n", + [uid cString]); + exit(1); + } + + if ([op isEqualToString:@"read"]) + doRead(defaults, key); + else if ([op isEqualToString:@"write"]) + doWrite(defaults, key, value); + else + usage(args); +} + +int main(int argc, char **argv, char **env) { + NSAutoreleasePool *pool; + + pool = [[NSAutoreleasePool alloc] init]; +#if LIB_FOUNDATION_LIBRARY + [NSProcessInfo initializeWithArguments:argv count:argc environment:env]; +#endif + + doIt([[NSProcessInfo processInfo] argumentsWithoutDefaults]); + + [pool release]; + return 0; +} -- 2.39.5