From 6bcb367e53c2613130b9fc5867db3dad4c3c6f72 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 17 Dec 2008 20:19:58 +0000 Subject: [PATCH 01/12] Monotone-Parent: 99f71142b4c9049e7cba05c730fa70b7c121288f Monotone-Revision: e867a018c3076e9e2cf662e96d7cac3352bb8789 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2008-12-17T20:19:58 Monotone-Branch: ca.inverse.sogo --- SoObjects/SOGo/LDAPUserManager.m | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/SoObjects/SOGo/LDAPUserManager.m b/SoObjects/SOGo/LDAPUserManager.m index bf5ff00ba..f0f6f7b56 100644 --- a/SoObjects/SOGo/LDAPUserManager.m +++ b/SoObjects/SOGo/LDAPUserManager.m @@ -40,7 +40,7 @@ static BOOL defaultMailDomainIsConfigured = NO; static BOOL forceImapLoginWithEmail = NO; #if defined(THREADSAFE) -static NSLock *lock; +static NSLock *lock = nil; #endif @implementation LDAPUserManager @@ -134,13 +134,14 @@ static NSLock *lock; udSources = [ud arrayForKey: @"SOGoLDAPSources"]; - if (udSources && [udSources isKindOfClass: [NSArray class]]) { - max = [udSources count]; - for (count = 0; count < max; count++) - [self _registerSource: [udSources objectAtIndex: count]]; - } else { + if (udSources && [udSources isKindOfClass: [NSArray class]]) + { + max = [udSources count]; + for (count = 0; count < max; count++) + [self _registerSource: [udSources objectAtIndex: count]]; + } + else [self errorWithFormat: @"SOGoLDAPSources is not defined or it is not an array. Check your defaults."]; - } } - (id) init From ed9fa6463a9c078d18613fdf6c79963c47d342de Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Fri, 19 Dec 2008 16:13:29 +0000 Subject: [PATCH 02/12] Monotone-Parent: 0e2919955b47e1a2673f50f4effe7af1a813db59 Monotone-Revision: d53f8bb9f0834bbab96c2e6db0136aea6477ee39 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2008-12-19T16:13:29 Monotone-Branch: ca.inverse.sogo --- SOPE/GDLContentStore/GCSChannelManager.m | 30 +++++++++++++----------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/SOPE/GDLContentStore/GCSChannelManager.m b/SOPE/GDLContentStore/GCSChannelManager.m index 17d796bbb..4bf881add 100644 --- a/SOPE/GDLContentStore/GCSChannelManager.m +++ b/SOPE/GDLContentStore/GCSChannelManager.m @@ -46,7 +46,8 @@ */ #if defined(THREADSAFE) -static NSLock *lock; +static NSLock *channelLock; +static NSLock *adaptorLock; #endif @interface GCSChannelHandle : NSObject @@ -89,7 +90,8 @@ static NSTimeInterval ChannelCollectionTimer = 5 * 60; ChannelCollectionTimer = 5*60; #if defined(THREADSAFE) - lock = [NSLock new]; + channelLock = [NSLock new]; + adaptorLock = [NSLock new]; #endif } @@ -104,12 +106,12 @@ static NSTimeInterval ChannelCollectionTimer = 5 * 60; static GCSChannelManager *cm = nil; #if defined(THREADSAFE) - [lock lock]; + [channelLock lock]; #endif if (!cm) cm = [self new]; #if defined(THREADSAFE) - [lock unlock]; + [channelLock unlock]; #endif return cm; @@ -125,7 +127,7 @@ static NSTimeInterval ChannelCollectionTimer = 5 * 60; gcTimer = [[NSTimer scheduledTimerWithTimeInterval: ChannelCollectionTimer - target: self selector: @selector (_garbageCollect: ) + target: self selector: @selector (_garbageCollect:) userInfo: nil repeats: YES] retain]; } @@ -200,7 +202,7 @@ static NSTimeInterval ChannelCollectionTimer = 5 * 60; if ((key = [self databaseKeyForURL: _url])) { #if defined(THREADSAFE) - [lock lock]; + [adaptorLock lock]; #endif adaptor = [urlToAdaptor objectForKey: key]; if (adaptor) @@ -209,7 +211,7 @@ static NSTimeInterval ChannelCollectionTimer = 5 * 60; { [self debugWithFormat: @"creating new adaptor for URL: %@", _url]; - if ([EOAdaptor respondsToSelector: @selector (adaptorForURL: )]) + if ([EOAdaptor respondsToSelector: @selector (adaptorForURL:)]) adaptor = [EOAdaptor adaptorForURL: _url]; else { @@ -234,7 +236,7 @@ static NSTimeInterval ChannelCollectionTimer = 5 * 60; [urlToAdaptor setObject: adaptor forKey: key]; } #if defined(THREADSAFE) - [lock unlock]; + [adaptorLock unlock]; #endif } } @@ -317,7 +319,7 @@ static NSTimeInterval ChannelCollectionTimer = 5 * 60; /* look for cached handles */ #if defined(THREADSAFE) - [lock lock]; + [channelLock lock]; #endif handle = [self findAvailChannelHandleForURL: _url]; if (handle) @@ -364,7 +366,7 @@ static NSTimeInterval ChannelCollectionTimer = 5 * 60; } } #if defined(THREADSAFE) - [lock unlock]; + [channelLock unlock]; #endif return channel; @@ -375,7 +377,7 @@ static NSTimeInterval ChannelCollectionTimer = 5 * 60; GCSChannelHandle *handle; #if defined(THREADSAFE) - [lock lock]; + [channelLock lock]; #endif handle = [self findBusyChannelHandleForChannel: _channel]; if (handle) @@ -411,7 +413,7 @@ static NSTimeInterval ChannelCollectionTimer = 5 * 60; [_channel release]; } #if defined(THREADSAFE) - [lock unlock]; + [channelLock unlock]; #endif } @@ -462,7 +464,7 @@ static NSTimeInterval ChannelCollectionTimer = 5 * 60; GCSChannelHandle *handle; #if defined(THREADSAFE) - [lock lock]; + [channelLock lock]; #endif count = [availableChannels count]; if (count) @@ -499,7 +501,7 @@ static NSTimeInterval ChannelCollectionTimer = 5 * 60; [handlesToRemove release]; } #if defined(THREADSAFE) - [lock unlock]; + [channelLock unlock]; #endif } From 896491a24a397ec0fe89a14455bac5fdab299045 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Fri, 19 Dec 2008 16:18:03 +0000 Subject: [PATCH 03/12] Monotone-Parent: d53f8bb9f0834bbab96c2e6db0136aea6477ee39 Monotone-Revision: f2b7fe7c387ac36654ad3e24e68362b3a0a3f2c8 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2008-12-19T16:18:03 Monotone-Branch: ca.inverse.sogo --- SoObjects/SOGo/LDAPSource.m | 49 +++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/SoObjects/SOGo/LDAPSource.m b/SoObjects/SOGo/LDAPSource.m index 94d8f4c6b..e9fa32e28 100644 --- a/SoObjects/SOGo/LDAPSource.m +++ b/SoObjects/SOGo/LDAPSource.m @@ -22,6 +22,7 @@ #import #import +#import #import #import @@ -41,6 +42,10 @@ static NSString *LDAPContactInfoAttribute = nil; static int timeLimit; static int sizeLimit; +#if defined(THREADSAFE) +static NSLock *lock; +#endif + @implementation LDAPSource + (void) initialize @@ -126,6 +131,10 @@ static int sizeLimit; @"calFBURL", @"proxyAddresses", nil]; [commonSearchFields retain]; + +#if defined(THREADSAFE) + lock = [NSLock new]; +#endif } } @@ -312,6 +321,10 @@ static int sizeLimit; NSString *userDN; NGLdapConnection *bindConnection; +#if defined(THREADSAFE) + [lock lock]; +#endif + didBind = NO; if ([loginToCheck length] > 0) @@ -337,6 +350,10 @@ static int sizeLimit; [bindConnection release]; } +#if defined(THREADSAFE) + [lock unlock]; +#endif + return didBind; } @@ -431,6 +448,10 @@ static int sizeLimit; NGLdapEntry *currentEntry; NSString *value; +#if defined(THREADSAFE) + [lock lock]; +#endif + ids = [NSMutableArray array]; if ([self _initLDAPConnection]) @@ -455,6 +476,10 @@ static int sizeLimit; [ldapConnection autorelease]; +#if defined(THREADSAFE) + [lock unlock]; +#endif + return ids; } @@ -552,6 +577,10 @@ static int sizeLimit; NGLdapEntry *currentEntry; NSEnumerator *entries; +#if defined(THREADSAFE) + [lock lock]; +#endif + contacts = [NSMutableArray array]; if ([match length] > 0) @@ -571,6 +600,10 @@ static int sizeLimit; [ldapConnection release]; } +#if defined(THREADSAFE) + [lock unlock]; +#endif + return contacts; } @@ -579,6 +612,10 @@ static int sizeLimit; NSDictionary *contactEntry; NGLdapEntry *ldapEntry; +#if defined(THREADSAFE) + [lock lock]; +#endif + contactEntry = nil; if ([entryID length] > 0) @@ -597,6 +634,10 @@ static int sizeLimit; [ldapConnection autorelease]; } +#if defined(THREADSAFE) + [lock unlock]; +#endif + return contactEntry; } @@ -607,6 +648,10 @@ static int sizeLimit; NSEnumerator *entries; EOQualifier *qualifier; +#if defined(THREADSAFE) + [lock lock]; +#endif + contactEntry = nil; if ([uid length] > 0) @@ -628,6 +673,10 @@ static int sizeLimit; [ldapConnection release]; } +#if defined(THREADSAFE) + [lock unlock]; +#endif + return contactEntry; } From 30f3441d14ff274a84919d4ff48d3fe1fb5401c9 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Fri, 19 Dec 2008 16:31:03 +0000 Subject: [PATCH 04/12] Monotone-Parent: f2b7fe7c387ac36654ad3e24e68362b3a0a3f2c8 Monotone-Revision: 99c41084c35e71bdf38a8a88897a9ad24b1c0903 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2008-12-19T16:31:03 Monotone-Branch: ca.inverse.sogo --- Main/SOGo.m | 121 +++++++++++++++++- .../Appointments/SOGoAppointmentFolder.m | 6 + .../Appointments/SOGoCalendarComponent.m | 18 +++ SoObjects/SOGo/LDAPUserManager.m | 4 + SoObjects/SOGo/SOGoGCSFolder.m | 11 ++ SoObjects/SOGo/SOGoParentFolder.m | 18 +++ SoObjects/SOGo/SOGoUser.m | 38 ++++-- 7 files changed, 204 insertions(+), 12 deletions(-) diff --git a/Main/SOGo.m b/Main/SOGo.m index 877e389f7..dc9d59796 100644 --- a/Main/SOGo.m +++ b/Main/SOGo.m @@ -19,9 +19,13 @@ 02111-1307, USA. */ +// #import +// #import + #import #import #import +// #import #import #import #import @@ -57,6 +61,102 @@ #import "SOGoProductLoader.h" #import "NSException+Stacktrace.h" +// static NSMutableDictionary *debugCache = nil; + +// static NSMutableArray *debugCache = nil; + +// @interface GSMutableArray : NSArray; +// @end + +// @interface GSMutableArray (sogodebug) +// @end + +// @implementation GSMutableArray (sogodebug) + +// + (id) alloc +// { +// static BOOL avoid = NO; +// id newInst; + +// newInst = [super alloc]; +// if (!avoid) +// { +// avoid = YES; +// if (!debugCache) +// debugCache = [NSMutableArray new]; +// [debugCache addObject: [NSValue valueWithPointer: newInst]]; +// } + +// return newInst; +// } + +// - (id) retain +// { +// NSNumber *nbr; +// id this; +// static BOOL avoid = NO; + +// fprintf (stderr, "retain start (%p)\n", self); + +// if (avoid) +// this = [super retain]; +// else +// { +// avoid = YES; +// if (!debugCache) +// debugCache = [NSMutableArray new]; +// nbr = [debugCache objectForKey: self]; +// nbr = [NSNumber numberWithInt: ([nbr intValue] + 1)]; +// [debugCache setObject: nbr forKey: self]; +// this = [super retain]; +// avoid = NO; +// } + +// fprintf (stderr, "retain stop (%p)\n", self); + +// return this; +// } + +// - (void) release +// { +// NSNumber *nbr; +// int count; +// static BOOL avoid = NO; + +// fprintf (stderr, "release start (%p)\n", self); + +// if (avoid) +// [super release]; +// else +// { +// avoid = YES; + +// nbr = [debugCache objectForKey: self]; +// if (nbr) +// { +// count = [nbr intValue]; +// if (count == 2) +// { +// [debugCache removeObjectForKey: self]; +// fprintf (stderr, "removing object\n"); +// } +// else +// { +// nbr = [NSNumber numberWithInt: (count - 1)]; +// [debugCache setObject: nbr forKey: self]; +// fprintf (stderr, "decrementing counter\n"); +// } +// } +// [super release]; + +// avoid = NO; +// } + +// fprintf (stderr, "release stop (%p)\n", self); +// } + +// @end + @interface SOGo : SoApplication { NSMutableDictionary *localeLUT; @@ -230,6 +330,10 @@ static BOOL debugObjectAllocation = NO; NSUserDefaults *ud; BOOL ok; +#if 0 + return YES; +#endif + ud = [NSUserDefaults standardUserDefaults]; ok = YES; cm = [GCSChannelManager defaultChannelManager]; @@ -342,7 +446,7 @@ static BOOL debugObjectAllocation = NO; #endif /* put locale info into the context in case it's not there */ [self _setupLocaleInContext:_ctx]; - + /* first check attributes directly bound to the application */ obj = [super lookupName:_key inContext:_ctx acquire:_flag]; if (!obj) @@ -357,6 +461,7 @@ static BOOL debugObjectAllocation = NO; if (![_key isEqualToString:@"favicon.ico"]) { +// NSLog (@"lookup user name '%@'", _key); if ([self isUserName: _key inContext: _ctx]) obj = [self lookupUser: _key inContext: _ctx]; } @@ -411,6 +516,8 @@ static BOOL debugObjectAllocation = NO; WOResponse *resp; NSDate *startDate, *endDate; +// NSAutoreleasePool *pool; + if (debugRequests) { [self logWithFormat: @"starting method '%@' on uri '%@'", @@ -418,10 +525,22 @@ static BOOL debugObjectAllocation = NO; startDate = [NSDate date]; } +// GSDebugAllocationActive (YES); +// GSDebugAllocationList (NO); + +// pool = [NSAutoreleasePool new]; + cache = [SOGoCache sharedCache]; resp = [super dispatchRequest: _request]; [SOGoCache killCache]; +// [resp retain]; +// [pool release]; +// [resp autorelease]; + +// NSLog (@"objects:\n%s\n", GSDebugAllocationList (YES)); +// GSDebugAllocationActive (NO); + if (debugRequests) { endDate = [NSDate date]; diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index 34640173b..3433d2835 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -1791,6 +1791,12 @@ static Class sogoAppointmentFolderKlass = Nil; NSString *url; BOOL handledLater; +#if 0 + obj = [SOGoAppointmentObject objectWithName: _key + inContainer: self]; + return obj; +#endif + /* first check attributes directly bound to the application */ handledLater = [self requestNamedIsHandledLater: _key]; if (handledLater) diff --git a/SoObjects/Appointments/SOGoCalendarComponent.m b/SoObjects/Appointments/SOGoCalendarComponent.m index 9c97303d4..a517917f0 100644 --- a/SoObjects/Appointments/SOGoCalendarComponent.m +++ b/SoObjects/Appointments/SOGoCalendarComponent.m @@ -320,6 +320,24 @@ _occurenceHasID (iCalRepeatableEntityObject *occurence, NSString *recID) { NSString *secureContent; +#if 0 + return (@"BEGIN:VCALENDAR\r\n" + @"VERSION:2.0\r\n" + @"PRODID:-//Inverse inc.//SOGo0.9//EN\r\n" + @"BEGIN:VEVENT\r\n" + @"UID:3185-492B0B80-5-BA4E3100\r\n" + @"SUMMARY:test event\r\n" + @"CREATED:20081124T201510Z\r\n" + @"DTSTAMP:20081124T201510Z\r\n" + @"LAST-MODIFIED:20081126T015646Z\r\n" + @"DTSTART:20081127T150000Z\r\n" + @"DTEND:20081127T160000Z\r\n" + @"TRANSP:OPAQUE\r\n" + @"RRULE:INTERVAL=1;FREQ=WEEKLY\r\n" + @"END:VEVENT\r\n" + @"END:VCALENDAR"); +#endif + if ([[context request] isSoWebDAVRequest]) secureContent = [self secureContentAsString]; else diff --git a/SoObjects/SOGo/LDAPUserManager.m b/SoObjects/SOGo/LDAPUserManager.m index f0f6f7b56..fd4886f9a 100644 --- a/SoObjects/SOGo/LDAPUserManager.m +++ b/SoObjects/SOGo/LDAPUserManager.m @@ -317,6 +317,10 @@ static NSLock *lock = nil; NSMutableDictionary *currentUser; NSString *dictPassword; +#if 0 + return YES; +#endif + #if defined(THREADSAFE) [lock lock]; #endif diff --git a/SoObjects/SOGo/SOGoGCSFolder.m b/SoObjects/SOGo/SOGoGCSFolder.m index 21d0176d7..882194988 100644 --- a/SoObjects/SOGo/SOGoGCSFolder.m +++ b/SoObjects/SOGo/SOGoGCSFolder.m @@ -282,6 +282,9 @@ static NSArray *childRecordFields = nil; { static GCSFolderManager *folderManager = nil; +#if 0 + return nil; +#endif if (!folderManager) folderManager = [GCSFolderManager defaultFolderManager]; @@ -290,6 +293,10 @@ static NSArray *childRecordFields = nil; - (GCSFolder *) ocsFolderForPath: (NSString *) _path { +#if 0 + return nil; +#endif + return [[self folderManager] folderAtPath: _path]; } @@ -352,6 +359,10 @@ static NSArray *childRecordFields = nil; GCSFolder *folder; NSString *userLogin; +#if 0 + return nil; +#endif + if (!ocsFolder) { ocsFolder = [self ocsFolderForPath: [self ocsPath]]; diff --git a/SoObjects/SOGo/SOGoParentFolder.m b/SoObjects/SOGo/SOGoParentFolder.m index 78496dc93..42fa919df 100644 --- a/SoObjects/SOGo/SOGoParentFolder.m +++ b/SoObjects/SOGo/SOGoParentFolder.m @@ -202,6 +202,10 @@ static SoSecurityManager *sm = nil; NSURL *folderLocation; NSString *sql, *gcsFolderType; +#if 0 + return; +#endif + cm = [GCSChannelManager defaultChannelManager]; folderLocation = [[GCSFolderManager defaultFolderManager] folderInfoLocation]; @@ -323,6 +327,20 @@ static SoSecurityManager *sm = nil; if (!subFolders) { subFolders = [NSMutableDictionary new]; + +#if 0 + SOGoGCSFolder *folder; + if (!subFolderClass) + subFolderClass = [[self class] subFolderClass]; + + folder = [subFolderClass objectWithName: @"personal" inContainer: self]; + [folder setDisplayName: [self defaultFolderName]]; + [folder + setOCSPath: [NSString stringWithFormat: @"%@/personal", OCSPath]]; + [subFolders setObject: folder forKey: @"personal"]; + return; +#endif + [self appendPersonalSources]; [self appendSystemSources]; login = [[context activeUser] login]; diff --git a/SoObjects/SOGo/SOGoUser.m b/SoObjects/SOGo/SOGoUser.m index dd0c84843..8029c78db 100644 --- a/SoObjects/SOGo/SOGoUser.m +++ b/SoObjects/SOGo/SOGoUser.m @@ -244,17 +244,17 @@ _timeValue (NSString *key) LDAPUserManager *um; NSString *realUID; - if (// acceptAnyUser -// || - [newLogin isEqualToString: @"anonymous"] - || [newLogin isEqualToString: @"freebusy"]) - realUID = newLogin; - else - { - um = [LDAPUserManager sharedUserManager]; - realUID = [[um contactInfosForUserWithUIDorEmail: newLogin] - objectForKey: @"c_uid"]; - } +// if (// acceptAnyUser +// // || +// [newLogin isEqualToString: @"anonymous"] +// || [newLogin isEqualToString: @"freebusy"]) +// realUID = newLogin; +// else +// { + um = [LDAPUserManager sharedUserManager]; + realUID = [[um contactInfosForUserWithUIDorEmail: newLogin] + objectForKey: @"c_uid"]; +// } if ([realUID length]) { @@ -320,12 +320,19 @@ _timeValue (NSString *key) - (void) _fetchAllEmails { +#if 0 + allEmails = [NSArray arrayWithObject: @"wsourdeau@inverse.ca"]; +#else allEmails = [self _fetchFieldForUser: @"emails"]; +#endif [allEmails retain]; } - (void) _fetchCN { +#if 0 + return @"Wolfgang Sourdeau"; +#endif cn = [self _fetchFieldForUser: @"cn"]; [cn retain]; } @@ -517,6 +524,7 @@ _timeValue (NSString *key) - (NSString *) language { + return @"English"; if (!language) { language = [[self userDefaults] stringForKey: @"Language"]; @@ -532,6 +540,10 @@ _timeValue (NSString *key) { NSString *timeZoneName; +#if 0 + return @"UTC"; +#endif + if (!userTimeZone) { timeZoneName = [[self userDefaults] stringForKey: @"TimeZone"]; @@ -958,6 +970,10 @@ _timeValue (NSString *key) { NSString *accessValue; +#if 0 + return YES; +#endif + accessValue = [self _fetchFieldForUser: [NSString stringWithFormat: @"%@Access", module]]; From c42ed774b9b6189128f3b2ede3cc26caa97935e1 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Fri, 19 Dec 2008 16:35:46 +0000 Subject: [PATCH 05/12] Monotone-Parent: 99c41084c35e71bdf38a8a88897a9ad24b1c0903 Monotone-Revision: 4bab2e6c548a557a6d27de35d7470fe01ac28ae0 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2008-12-19T16:35:46 Monotone-Branch: ca.inverse.sogo --- Main/SOGo.m | 1 - 1 file changed, 1 deletion(-) diff --git a/Main/SOGo.m b/Main/SOGo.m index dc9d59796..4cd6dd1d5 100644 --- a/Main/SOGo.m +++ b/Main/SOGo.m @@ -461,7 +461,6 @@ static BOOL debugObjectAllocation = NO; if (![_key isEqualToString:@"favicon.ico"]) { -// NSLog (@"lookup user name '%@'", _key); if ([self isUserName: _key inContext: _ctx]) obj = [self lookupUser: _key inContext: _ctx]; } From 4fd1912644c3e32059b869d5454113c5b42fc09c Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Fri, 19 Dec 2008 16:53:01 +0000 Subject: [PATCH 06/12] Monotone-Parent: 4bab2e6c548a557a6d27de35d7470fe01ac28ae0 Monotone-Revision: a555d41bbb84c4f8d42e4149e1e083b6b7acff44 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2008-12-19T16:53:01 Monotone-Branch: ca.inverse.sogo --- UI/WebServerResources/generic.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/UI/WebServerResources/generic.js b/UI/WebServerResources/generic.js index 721c64be7..ee845fc3b 100644 --- a/UI/WebServerResources/generic.js +++ b/UI/WebServerResources/generic.js @@ -1427,7 +1427,8 @@ function loadPreferences() { } function onLoadHandler(event) { - if (typeof UserLogin != "undefined" && UserLogin != "wrongusernamepassword") + if (typeof UserLogin != "undefined" + && !(UserLogin == "" || UserLogin == "wrongusernamepassword")) loadPreferences(); queryParameters = parseQueryParameters('' + window.location); if (!$(document.body).hasClassName("popup")) { From f4b104f937ec00dab5f949f54d6dacb8120405e2 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Fri, 19 Dec 2008 16:56:36 +0000 Subject: [PATCH 07/12] Monotone-Parent: a555d41bbb84c4f8d42e4149e1e083b6b7acff44 Monotone-Revision: 236f027118f95a11398d4e821b658ea1553b9ffe Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2008-12-19T16:56:36 Monotone-Branch: ca.inverse.sogo --- UI/MainUI/product.plist | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/UI/MainUI/product.plist b/UI/MainUI/product.plist index 194b03cd6..5f1daf9c6 100644 --- a/UI/MainUI/product.plist +++ b/UI/MainUI/product.plist @@ -88,6 +88,11 @@ categories = { SOGo = { // TODO: move decls to class + slots = { + toolbar = { + value = "none"; + }; + }; methods = { view = { protectedBy = ""; From 0184eac492ba143f968b73e88386912add8b254a Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Fri, 19 Dec 2008 17:07:32 +0000 Subject: [PATCH 08/12] Monotone-Parent: 236f027118f95a11398d4e821b658ea1553b9ffe Monotone-Revision: efc5b76b9b6fd3967536ccb3ec40615d6aca7ca5 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2008-12-19T17:07:32 Monotone-Branch: ca.inverse.sogo --- SoObjects/SOGo/SOGoUser.m | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/SoObjects/SOGo/SOGoUser.m b/SoObjects/SOGo/SOGoUser.m index 8029c78db..7450d2ca4 100644 --- a/SoObjects/SOGo/SOGoUser.m +++ b/SoObjects/SOGo/SOGoUser.m @@ -244,17 +244,15 @@ _timeValue (NSString *key) LDAPUserManager *um; NSString *realUID; -// if (// acceptAnyUser -// // || -// [newLogin isEqualToString: @"anonymous"] -// || [newLogin isEqualToString: @"freebusy"]) -// realUID = newLogin; -// else -// { - um = [LDAPUserManager sharedUserManager]; - realUID = [[um contactInfosForUserWithUIDorEmail: newLogin] - objectForKey: @"c_uid"]; -// } + if ([newLogin isEqualToString: @"anonymous"] + || [newLogin isEqualToString: @"freebusy"]) + realUID = newLogin; + else + { + um = [LDAPUserManager sharedUserManager]; + realUID = [[um contactInfosForUserWithUIDorEmail: newLogin] + objectForKey: @"c_uid"]; + } if ([realUID length]) { From 109d1b65f62a5840a54ec195afe6907fcae4afe9 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Fri, 19 Dec 2008 17:07:40 +0000 Subject: [PATCH 09/12] Monotone-Parent: efc5b76b9b6fd3967536ccb3ec40615d6aca7ca5 Monotone-Revision: e0221240c98c353cd78f1dea976887fc91420de9 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2008-12-19T17:07:40 Monotone-Branch: ca.inverse.sogo --- UI/MainUI/product.plist | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/UI/MainUI/product.plist b/UI/MainUI/product.plist index 5f1daf9c6..621cf8eaf 100644 --- a/UI/MainUI/product.plist +++ b/UI/MainUI/product.plist @@ -90,7 +90,8 @@ SOGo = { // TODO: move decls to class slots = { toolbar = { - value = "none"; + value = "none"; // keep this in order to avoid lookups on username + // "toolbar" }; }; methods = { From 1d5aec5e3ae5b1900cb6d9441ab801638250a20c Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Fri, 19 Dec 2008 17:23:31 +0000 Subject: [PATCH 10/12] Monotone-Parent: e0221240c98c353cd78f1dea976887fc91420de9 Monotone-Revision: 0a7b2afa74ab092109cffa4ccc0c67371a5e313a Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2008-12-19T17:23:31 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 7 +++++++ UI/Common/UIxPageFrame.m | 28 ++++++++++++++++++++++++++ UI/Templates/UIxPageFrame.wox | 8 +++++--- UI/WebServerResources/MailerUI.js | 6 +++--- UI/WebServerResources/UIxMailEditor.js | 6 +++--- UI/WebServerResources/generic.js | 16 +++++---------- 6 files changed, 51 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 557baaff5..66b4d1366 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-12-19 Wolfgang Sourdeau + + * UI/Common/UIxPageFrame.m ([UIxPageFrame -userSettings]): new + accessor method to avoid loading the user settings with an + additional json request. + ([UIxPageFrame -userDefaults]): same as above for user defaults. + 2008-12-17 Wolfgang Sourdeau * SoObjects/SOGo/SOGoParentFolder.m ([SOGoParentFolder diff --git a/UI/Common/UIxPageFrame.m b/UI/Common/UIxPageFrame.m index 11dd97d16..8eda4fcda 100644 --- a/UI/Common/UIxPageFrame.m +++ b/UI/Common/UIxPageFrame.m @@ -397,6 +397,34 @@ return language; } +- (NSString *) userSettings +{ + NSUserDefaults *userSettings; + NSString *jsonResult; + + userSettings = [[context activeUser] userSettings]; + if (userSettings) + jsonResult = [userSettings jsonRepresentation]; + else + jsonResult = @"{}"; + + return jsonResult; +} + +- (NSString *) userDefaults +{ + NSUserDefaults *userDefaults; + NSString *jsonResult; + + userDefaults = [[context activeUser] userDefaults]; + if (userDefaults) + jsonResult = [userDefaults jsonRepresentation]; + else + jsonResult = @"{}"; + + return jsonResult; +} + /* browser/os identification */ - (BOOL) isCompatibleBrowser diff --git a/UI/Templates/UIxPageFrame.wox b/UI/Templates/UIxPageFrame.wox index 7625fa6b6..afde244d1 100644 --- a/UI/Templates/UIxPageFrame.wox +++ b/UI/Templates/UIxPageFrame.wox @@ -108,9 +108,11 @@ var UserFolderURL = ''; - var UserLogin = ''; - var UserLanguage = ''; + >var UserFolderURL = ''; + var UserLogin = ''; + var UserLanguage = ''; + var UserSettings = ; + var UserDefaults = ; diff --git a/UI/WebServerResources/MailerUI.js b/UI/WebServerResources/MailerUI.js index 4c48e2b92..d67214dcf 100644 --- a/UI/WebServerResources/MailerUI.js +++ b/UI/WebServerResources/MailerUI.js @@ -583,7 +583,7 @@ function messageListCallback(http) { var div = $('mailboxContent'); var table = $('messageList'); - var columnsOrder = userSettings["SOGoMailListViewColumnsOrder"]; + var columnsOrder = UserSettings["SOGoMailListViewColumnsOrder"]; if ( typeof(columnsOrder) == "undefined" ) { columnsOrder = defaultColumnsOrder; } @@ -1363,7 +1363,7 @@ function configureMessageListBodyEvents(table) { // 4 => Unread // 5 => Date // 6 => Priority - var columnsOrder = userSettings["SOGoMailListViewColumnsOrder"]; + var columnsOrder = UserSettings["SOGoMailListViewColumnsOrder"]; if ( typeof(columnsOrder) == "undefined" ) { columnsOrder = defaultColumnsOrder; } @@ -1474,7 +1474,7 @@ function initMailer(event) { } function initMessageCheckTimer() { - var messageCheck = userDefaults["MessageCheck"]; + var messageCheck = UserDefaults["MessageCheck"]; if (messageCheck && messageCheck != "manually") { var interval; if (messageCheck == "once_per_hour") diff --git a/UI/WebServerResources/UIxMailEditor.js b/UI/WebServerResources/UIxMailEditor.js index 8a4390f0c..a51376f93 100644 --- a/UI/WebServerResources/UIxMailEditor.js +++ b/UI/WebServerResources/UIxMailEditor.js @@ -312,7 +312,7 @@ function onTextIEUpdateCursorPos(event) { function onTextFirstFocus() { var content = this.getValue(); - var replyPlacement = userDefaults["ReplyPlacement"]; + var replyPlacement = UserDefaults["ReplyPlacement"]; if (replyPlacement == "above") { this.insertBefore(document.createTextNode("\r\r"), this.lastChild); @@ -547,7 +547,7 @@ function initMailEditor() { if (sigLimit > -1) MailEditor.signatureLength = (textContent.length - sigLimit); } - if (userDefaults["ReplyPlacement"] != "above") { + if (UserDefaults["ReplyPlacement"] != "above") { textarea.scrollTop = textarea.scrollHeight; } textarea.observe("focus", onTextFirstFocus); @@ -655,7 +655,7 @@ function lineBreakCount(str){ function hasSignature() { try { - return(userDefaults.MailAccounts[0].identities[0].signature.length > 0); + return(UserDefaults.MailAccounts[0].identities[0].signature.length > 0); } catch(e) { return false; } diff --git a/UI/WebServerResources/generic.js b/UI/WebServerResources/generic.js index ee845fc3b..3fc6d568e 100644 --- a/UI/WebServerResources/generic.js +++ b/UI/WebServerResources/generic.js @@ -38,9 +38,6 @@ var lastClickedRow = -1; // logArea = null; var allDocumentElements = null; -var userDefaults = null; -var userSettings = null; - // Ajax requests counts var activeAjaxRequests = 0; var removeFolderRequestCount = 0; @@ -1402,7 +1399,7 @@ function indexColor(number) { return color; } -function loadPreferences() { +function reloadPreferences() { var url = UserFolderURL + "jsonDefaults"; var http = createHTTPClient(); http.open("GET", url, false); @@ -1410,9 +1407,9 @@ function loadPreferences() { if (http.status == 200) { if (http.responseText.length > 0) - userDefaults = http.responseText.evalJSON(true); + UserDefaults = http.responseText.evalJSON(true); else - userDefaults = {}; + UserDefaults = {}; } url = UserFolderURL + "jsonSettings"; @@ -1420,16 +1417,13 @@ function loadPreferences() { http.send(""); if (http.status == 200) { if (http.responseText.length > 0) - userSettings = http.responseText.evalJSON(true); + UserSettings = http.responseText.evalJSON(true); else - userSettings = {}; + UserSettings = {}; } } function onLoadHandler(event) { - if (typeof UserLogin != "undefined" - && !(UserLogin == "" || UserLogin == "wrongusernamepassword")) - loadPreferences(); queryParameters = parseQueryParameters('' + window.location); if (!$(document.body).hasClassName("popup")) { initLogConsole(); From 88df2128c517ffcaf51c7528f15856dee704fc7b Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Fri, 19 Dec 2008 17:27:55 +0000 Subject: [PATCH 11/12] Monotone-Parent: 0a7b2afa74ab092109cffa4ccc0c67371a5e313a Monotone-Revision: ed4c4894c0c554783b39ad526a74404a9cc11e8c Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2008-12-19T17:27:55 Monotone-Branch: ca.inverse.sogo --- SoObjects/SOGo/SOGoUser.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/SoObjects/SOGo/SOGoUser.m b/SoObjects/SOGo/SOGoUser.m index 7450d2ca4..74d28fc76 100644 --- a/SoObjects/SOGo/SOGoUser.m +++ b/SoObjects/SOGo/SOGoUser.m @@ -522,7 +522,10 @@ _timeValue (NSString *key) - (NSString *) language { +#if 0 return @"English"; +#endif + if (!language) { language = [[self userDefaults] stringForKey: @"Language"]; From e7f39264684513535389b721663c9f811fe2774e Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Fri, 19 Dec 2008 17:40:42 +0000 Subject: [PATCH 12/12] Monotone-Parent: ed4c4894c0c554783b39ad526a74404a9cc11e8c Monotone-Revision: bac00846545ecbaa355017083f8a425f751077c7 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2008-12-19T17:40:42 Monotone-Branch: ca.inverse.sogo --- Main/SOGo.m | 120 +----------------- .../Appointments/SOGoAppointmentFolder.m | 6 - .../Appointments/SOGoCalendarComponent.m | 18 --- SoObjects/SOGo/LDAPUserManager.m | 4 - SoObjects/SOGo/SOGoGCSFolder.m | 11 -- SoObjects/SOGo/SOGoParentFolder.m | 18 --- SoObjects/SOGo/SOGoUser.m | 19 --- 7 files changed, 1 insertion(+), 195 deletions(-) diff --git a/Main/SOGo.m b/Main/SOGo.m index 4cd6dd1d5..877e389f7 100644 --- a/Main/SOGo.m +++ b/Main/SOGo.m @@ -19,13 +19,9 @@ 02111-1307, USA. */ -// #import -// #import - #import #import #import -// #import #import #import #import @@ -61,102 +57,6 @@ #import "SOGoProductLoader.h" #import "NSException+Stacktrace.h" -// static NSMutableDictionary *debugCache = nil; - -// static NSMutableArray *debugCache = nil; - -// @interface GSMutableArray : NSArray; -// @end - -// @interface GSMutableArray (sogodebug) -// @end - -// @implementation GSMutableArray (sogodebug) - -// + (id) alloc -// { -// static BOOL avoid = NO; -// id newInst; - -// newInst = [super alloc]; -// if (!avoid) -// { -// avoid = YES; -// if (!debugCache) -// debugCache = [NSMutableArray new]; -// [debugCache addObject: [NSValue valueWithPointer: newInst]]; -// } - -// return newInst; -// } - -// - (id) retain -// { -// NSNumber *nbr; -// id this; -// static BOOL avoid = NO; - -// fprintf (stderr, "retain start (%p)\n", self); - -// if (avoid) -// this = [super retain]; -// else -// { -// avoid = YES; -// if (!debugCache) -// debugCache = [NSMutableArray new]; -// nbr = [debugCache objectForKey: self]; -// nbr = [NSNumber numberWithInt: ([nbr intValue] + 1)]; -// [debugCache setObject: nbr forKey: self]; -// this = [super retain]; -// avoid = NO; -// } - -// fprintf (stderr, "retain stop (%p)\n", self); - -// return this; -// } - -// - (void) release -// { -// NSNumber *nbr; -// int count; -// static BOOL avoid = NO; - -// fprintf (stderr, "release start (%p)\n", self); - -// if (avoid) -// [super release]; -// else -// { -// avoid = YES; - -// nbr = [debugCache objectForKey: self]; -// if (nbr) -// { -// count = [nbr intValue]; -// if (count == 2) -// { -// [debugCache removeObjectForKey: self]; -// fprintf (stderr, "removing object\n"); -// } -// else -// { -// nbr = [NSNumber numberWithInt: (count - 1)]; -// [debugCache setObject: nbr forKey: self]; -// fprintf (stderr, "decrementing counter\n"); -// } -// } -// [super release]; - -// avoid = NO; -// } - -// fprintf (stderr, "release stop (%p)\n", self); -// } - -// @end - @interface SOGo : SoApplication { NSMutableDictionary *localeLUT; @@ -330,10 +230,6 @@ static BOOL debugObjectAllocation = NO; NSUserDefaults *ud; BOOL ok; -#if 0 - return YES; -#endif - ud = [NSUserDefaults standardUserDefaults]; ok = YES; cm = [GCSChannelManager defaultChannelManager]; @@ -446,7 +342,7 @@ static BOOL debugObjectAllocation = NO; #endif /* put locale info into the context in case it's not there */ [self _setupLocaleInContext:_ctx]; - + /* first check attributes directly bound to the application */ obj = [super lookupName:_key inContext:_ctx acquire:_flag]; if (!obj) @@ -515,8 +411,6 @@ static BOOL debugObjectAllocation = NO; WOResponse *resp; NSDate *startDate, *endDate; -// NSAutoreleasePool *pool; - if (debugRequests) { [self logWithFormat: @"starting method '%@' on uri '%@'", @@ -524,22 +418,10 @@ static BOOL debugObjectAllocation = NO; startDate = [NSDate date]; } -// GSDebugAllocationActive (YES); -// GSDebugAllocationList (NO); - -// pool = [NSAutoreleasePool new]; - cache = [SOGoCache sharedCache]; resp = [super dispatchRequest: _request]; [SOGoCache killCache]; -// [resp retain]; -// [pool release]; -// [resp autorelease]; - -// NSLog (@"objects:\n%s\n", GSDebugAllocationList (YES)); -// GSDebugAllocationActive (NO); - if (debugRequests) { endDate = [NSDate date]; diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index 3433d2835..34640173b 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -1791,12 +1791,6 @@ static Class sogoAppointmentFolderKlass = Nil; NSString *url; BOOL handledLater; -#if 0 - obj = [SOGoAppointmentObject objectWithName: _key - inContainer: self]; - return obj; -#endif - /* first check attributes directly bound to the application */ handledLater = [self requestNamedIsHandledLater: _key]; if (handledLater) diff --git a/SoObjects/Appointments/SOGoCalendarComponent.m b/SoObjects/Appointments/SOGoCalendarComponent.m index a517917f0..9c97303d4 100644 --- a/SoObjects/Appointments/SOGoCalendarComponent.m +++ b/SoObjects/Appointments/SOGoCalendarComponent.m @@ -320,24 +320,6 @@ _occurenceHasID (iCalRepeatableEntityObject *occurence, NSString *recID) { NSString *secureContent; -#if 0 - return (@"BEGIN:VCALENDAR\r\n" - @"VERSION:2.0\r\n" - @"PRODID:-//Inverse inc.//SOGo0.9//EN\r\n" - @"BEGIN:VEVENT\r\n" - @"UID:3185-492B0B80-5-BA4E3100\r\n" - @"SUMMARY:test event\r\n" - @"CREATED:20081124T201510Z\r\n" - @"DTSTAMP:20081124T201510Z\r\n" - @"LAST-MODIFIED:20081126T015646Z\r\n" - @"DTSTART:20081127T150000Z\r\n" - @"DTEND:20081127T160000Z\r\n" - @"TRANSP:OPAQUE\r\n" - @"RRULE:INTERVAL=1;FREQ=WEEKLY\r\n" - @"END:VEVENT\r\n" - @"END:VCALENDAR"); -#endif - if ([[context request] isSoWebDAVRequest]) secureContent = [self secureContentAsString]; else diff --git a/SoObjects/SOGo/LDAPUserManager.m b/SoObjects/SOGo/LDAPUserManager.m index fd4886f9a..f0f6f7b56 100644 --- a/SoObjects/SOGo/LDAPUserManager.m +++ b/SoObjects/SOGo/LDAPUserManager.m @@ -317,10 +317,6 @@ static NSLock *lock = nil; NSMutableDictionary *currentUser; NSString *dictPassword; -#if 0 - return YES; -#endif - #if defined(THREADSAFE) [lock lock]; #endif diff --git a/SoObjects/SOGo/SOGoGCSFolder.m b/SoObjects/SOGo/SOGoGCSFolder.m index 882194988..21d0176d7 100644 --- a/SoObjects/SOGo/SOGoGCSFolder.m +++ b/SoObjects/SOGo/SOGoGCSFolder.m @@ -282,9 +282,6 @@ static NSArray *childRecordFields = nil; { static GCSFolderManager *folderManager = nil; -#if 0 - return nil; -#endif if (!folderManager) folderManager = [GCSFolderManager defaultFolderManager]; @@ -293,10 +290,6 @@ static NSArray *childRecordFields = nil; - (GCSFolder *) ocsFolderForPath: (NSString *) _path { -#if 0 - return nil; -#endif - return [[self folderManager] folderAtPath: _path]; } @@ -359,10 +352,6 @@ static NSArray *childRecordFields = nil; GCSFolder *folder; NSString *userLogin; -#if 0 - return nil; -#endif - if (!ocsFolder) { ocsFolder = [self ocsFolderForPath: [self ocsPath]]; diff --git a/SoObjects/SOGo/SOGoParentFolder.m b/SoObjects/SOGo/SOGoParentFolder.m index 42fa919df..78496dc93 100644 --- a/SoObjects/SOGo/SOGoParentFolder.m +++ b/SoObjects/SOGo/SOGoParentFolder.m @@ -202,10 +202,6 @@ static SoSecurityManager *sm = nil; NSURL *folderLocation; NSString *sql, *gcsFolderType; -#if 0 - return; -#endif - cm = [GCSChannelManager defaultChannelManager]; folderLocation = [[GCSFolderManager defaultFolderManager] folderInfoLocation]; @@ -327,20 +323,6 @@ static SoSecurityManager *sm = nil; if (!subFolders) { subFolders = [NSMutableDictionary new]; - -#if 0 - SOGoGCSFolder *folder; - if (!subFolderClass) - subFolderClass = [[self class] subFolderClass]; - - folder = [subFolderClass objectWithName: @"personal" inContainer: self]; - [folder setDisplayName: [self defaultFolderName]]; - [folder - setOCSPath: [NSString stringWithFormat: @"%@/personal", OCSPath]]; - [subFolders setObject: folder forKey: @"personal"]; - return; -#endif - [self appendPersonalSources]; [self appendSystemSources]; login = [[context activeUser] login]; diff --git a/SoObjects/SOGo/SOGoUser.m b/SoObjects/SOGo/SOGoUser.m index 74d28fc76..c9c6a1322 100644 --- a/SoObjects/SOGo/SOGoUser.m +++ b/SoObjects/SOGo/SOGoUser.m @@ -318,19 +318,12 @@ _timeValue (NSString *key) - (void) _fetchAllEmails { -#if 0 - allEmails = [NSArray arrayWithObject: @"wsourdeau@inverse.ca"]; -#else allEmails = [self _fetchFieldForUser: @"emails"]; -#endif [allEmails retain]; } - (void) _fetchCN { -#if 0 - return @"Wolfgang Sourdeau"; -#endif cn = [self _fetchFieldForUser: @"cn"]; [cn retain]; } @@ -522,10 +515,6 @@ _timeValue (NSString *key) - (NSString *) language { -#if 0 - return @"English"; -#endif - if (!language) { language = [[self userDefaults] stringForKey: @"Language"]; @@ -541,10 +530,6 @@ _timeValue (NSString *key) { NSString *timeZoneName; -#if 0 - return @"UTC"; -#endif - if (!userTimeZone) { timeZoneName = [[self userDefaults] stringForKey: @"TimeZone"]; @@ -971,10 +956,6 @@ _timeValue (NSString *key) { NSString *accessValue; -#if 0 - return YES; -#endif - accessValue = [self _fetchFieldForUser: [NSString stringWithFormat: @"%@Access", module]];