From 4775e4188c4f65c9a0db4a65649659afcd6600fc Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 18 Nov 2009 16:44:46 +0000 Subject: [PATCH 1/5] Monotone-Parent: c1d0200c4b60b6258231cb033e48e83ccd97ed4e Monotone-Revision: 0c9fe27ffae5ff44e73d7dfca3b188c2ba1c0873 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2009-11-18T16:44:46 Monotone-Branch: ca.inverse.sogo --- UI/WebServerResources/GNUmakefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/UI/WebServerResources/GNUmakefile b/UI/WebServerResources/GNUmakefile index 9a66c95f3..2d49a6953 100644 --- a/UI/WebServerResources/GNUmakefile +++ b/UI/WebServerResources/GNUmakefile @@ -22,3 +22,8 @@ clean :: distclean :: clean uninstall :: + @if [ -L "$(SOGO_WEBSERVERRESOURCESDIR)" ]; then \ + echo "$(SOGO_WEBSERVERRESOURCESDIR) is a symbolic link (for development?). Uninstallation skipped."; \ + else \ + rm -rf $(SOGO_WEBSERVERRESOURCESDIR); \ + fi From 70947fe36707ceaacefde36c287c3c55a0872a50 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 18 Nov 2009 16:47:49 +0000 Subject: [PATCH 2/5] Monotone-Parent: 0c9fe27ffae5ff44e73d7dfca3b188c2ba1c0873 Monotone-Revision: 3053345e3004d3568a69d34023dc2bdf34c4c3b4 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2009-11-18T16:47:49 Monotone-Branch: ca.inverse.sogo --- UI/Templates/GNUmakefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/UI/Templates/GNUmakefile b/UI/Templates/GNUmakefile index e2d7f2a80..f96e836d9 100644 --- a/UI/Templates/GNUmakefile +++ b/UI/Templates/GNUmakefile @@ -40,3 +40,8 @@ clean :: distclean :: clean uninstall :: + @if [ -L "$(SOGO_TEMPLATESDIR)" ]; then \ + echo "$(SOGO_TEMPLATESDIR) is a symbolic link (for development?). Uninstallation skipped."; \ + else \ + rm -rf $(SOGO_TEMPLATESDIR); \ + fi From bf127ecc18e8a53f1e3d77bb7bae4d33f5419423 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 18 Nov 2009 23:13:44 +0000 Subject: [PATCH 3/5] Monotone-Parent: 3053345e3004d3568a69d34023dc2bdf34c4c3b4 Monotone-Revision: a1ad485763dbb256f42488a0cf3e8c8061604d83 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2009-11-18T23:13:44 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 8 ++++++++ Main/SOGo.m | 50 ++++++++++++++++++++++++++------------------------ 2 files changed, 34 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3a5ea7823..c6e325c4c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2009-11-18 Wolfgang Sourdeau + + * Main/SOGo.m (+initialize): removed the "debugObjectAllocation" global + variable since "debugLeaks" has the same meaning. Instantiate a + "SOGoStartupLogger" object in order to avoid using NSLog when the + parent process is starting, in order to work-around the caching of + the pid in NSLog. + 2009-11-16 Wolfgang Sourdeau * SoObjects/SOGo/SOGoCache.m: "cache", "users" and "localCache" diff --git a/Main/SOGo.m b/Main/SOGo.m index fab8497c0..d15342cec 100644 --- a/Main/SOGo.m +++ b/Main/SOGo.m @@ -60,51 +60,56 @@ #import "SOGo.h" +@interface SOGoStartupLogger : NSObject +@end + +@implementation SOGoStartupLogger +@end + @implementation SOGo static unsigned int vMemSizeLimit = 0; static BOOL doCrashOnSessionCreate = NO; static BOOL hasCheckedTables = NO; static BOOL debugRequests = NO; -static BOOL debugLeaks = NO; static BOOL useRelativeURLs = NO; static BOOL trustProxyAuthentication; #ifdef GNUSTEP_BASE_LIBRARY -static BOOL debugObjectAllocation = NO; +static BOOL debugLeaks = NO; #endif + (void) initialize { - NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + NSUserDefaults *ud; SoClassSecurityInfo *sInfo; NSArray *basicRoles; + SOGoStartupLogger *logger; id tmp; - NSLog(@"starting SOGo (build %@)", SOGoBuildDate); + logger = [SOGoStartupLogger new]; + [logger logWithFormat: @"starting SOGo (build %@)", SOGoBuildDate]; - if ([[ud persistentDomainForName: @"sogod"] count] == 0) - NSLog(@"WARNING: No configuration found. SOGo will not work properly."); - + ud = [NSUserDefaults standardUserDefaults]; + if ([[ud persistentDomainForName: @"sogod"] count] == 0) + [logger warnWithFormat: @"No configuration found." + @" SOGo will not work properly."]; + doCrashOnSessionCreate = [ud boolForKey:@"SOGoCrashOnSessionCreate"]; -#ifdef GNUSTEP_BASE_LIBRARY - debugObjectAllocation = [ud boolForKey: @"SOGoDebugObjectAllocation"]; - if (debugObjectAllocation) - { - NSLog (@"activating stats on object allocation"); - GSDebugAllocationActive (YES); - } -#endif debugRequests = [ud boolForKey: @"SOGoDebugRequests"]; +#ifdef GNUSTEP_BASE_LIBRARY debugLeaks = [ud boolForKey: @"SOGoDebugLeaks"]; + if (debugLeaks) + [logger logWithFormat: @"activating leak debugging"]; +#endif /* vMem size check - default is 384MB */ - + tmp = [ud objectForKey: @"SxVMemLimit"]; vMemSizeLimit = ((tmp != nil) ? [tmp intValue] : 384); if (vMemSizeLimit > 0) - NSLog(@"Note: vmem size check enabled: shutting down app when " - @"vmem > %d MB", vMemSizeLimit); + [logger logWithFormat: @"vmem size check enabled: shutting down app when " + @"vmem > %d MB", vMemSizeLimit]; #if LIB_FOUNDATION_LIBRARY if ([ud boolForKey:@"SOGoEnableDoubleReleaseCheck"]) [NSAutoreleasePool enableDoubleReleaseCheck: YES]; @@ -127,6 +132,7 @@ static BOOL debugObjectAllocation = NO; trustProxyAuthentication = [ud boolForKey: @"SOGoTrustProxyAuthentication"]; useRelativeURLs = [ud boolForKey: @"WOUseRelativeURLs"]; + [logger release]; } - (id) init @@ -337,10 +343,6 @@ static BOOL debugObjectAllocation = NO; { id obj; -#ifdef GNUSTEP_BASE_LIBRARY - if (debugObjectAllocation) - NSLog(@"objects allocated\n%s", GSDebugAllocationList (YES)); -#endif /* put locale info into the context in case it's not there */ [self _setupLocaleInContext:_ctx]; @@ -399,8 +401,6 @@ static BOOL debugObjectAllocation = NO; @"terminating app, vMem size limit (%d MB) has been reached" @" (currently %d MB)", vMemSizeLimit, vmem]; -// if (debugObjectAllocation) -// [self _dumpClassAllocation]; [self terminate]; } } @@ -421,6 +421,7 @@ static BOOL debugObjectAllocation = NO; } cache = [SOGoCache sharedCache]; +#ifdef GNUSTEP_BASE_LIBRARY if (debugLeaks) { if (debugOn) @@ -431,6 +432,7 @@ static BOOL debugObjectAllocation = NO; GSDebugAllocationActive (YES); } } +#endif resp = [super dispatchRequest: _request]; [cache killCache]; From 2dcdcb2e89e1a94330c00436a7457c108a3e6717 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 18 Nov 2009 23:15:34 +0000 Subject: [PATCH 4/5] Monotone-Parent: a1ad485763dbb256f42488a0cf3e8c8061604d83 Monotone-Revision: d656a1a3c9e97c1b1a23a7959821aa3c54780d86 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2009-11-18T23:15:34 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 5 +++++ SoObjects/SOGo/NSDictionary+BSJSONAdditions.h | 2 +- SoObjects/SOGo/NSDictionary+BSJSONAdditions.m | 4 ++-- SoObjects/SOGo/NSScanner+BSJSONAdditions.h | 2 +- SoObjects/SOGo/NSScanner+BSJSONAdditions.m | 2 +- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index c6e325c4c..1d74e93ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2009-11-18 Wolfgang Sourdeau + * SoObjects/SOGo/NSDictionary+BSJSONAdditions.m + (+dictionaryWithJSONString:): this constructor now explicitly + returns an NSMutableDictionary to avoid messing with mutable + copies and useless allocation/deallocation in the callers. + * Main/SOGo.m (+initialize): removed the "debugObjectAllocation" global variable since "debugLeaks" has the same meaning. Instantiate a "SOGoStartupLogger" object in order to avoid using NSLog when the diff --git a/SoObjects/SOGo/NSDictionary+BSJSONAdditions.h b/SoObjects/SOGo/NSDictionary+BSJSONAdditions.h index 5cbfa1b05..1a32190a2 100644 --- a/SoObjects/SOGo/NSDictionary+BSJSONAdditions.h +++ b/SoObjects/SOGo/NSDictionary+BSJSONAdditions.h @@ -28,7 +28,7 @@ extern const int jsonDoNotIndent; @interface NSDictionary (BSJSONAdditions) -+ (NSDictionary *)dictionaryWithJSONString:(NSString *)jsonString; ++ (NSMutableDictionary *)dictionaryWithJSONString:(NSString *)jsonString; - (NSString *)jsonStringValue; @end diff --git a/SoObjects/SOGo/NSDictionary+BSJSONAdditions.m b/SoObjects/SOGo/NSDictionary+BSJSONAdditions.m index 0569376bb..e9c658b86 100644 --- a/SoObjects/SOGo/NSDictionary+BSJSONAdditions.m +++ b/SoObjects/SOGo/NSDictionary+BSJSONAdditions.m @@ -35,10 +35,10 @@ const int jsonDoNotIndent = -1; @implementation NSDictionary (BSJSONAdditions) -+ (NSDictionary *)dictionaryWithJSONString:(NSString *)jsonString ++ (NSMutableDictionary *)dictionaryWithJSONString:(NSString *)jsonString { NSScanner *scanner = [[NSScanner alloc] initWithString:jsonString]; - NSDictionary *dictionary = nil; + NSMutableDictionary *dictionary = nil; [scanner scanJSONObject:&dictionary]; [scanner release]; return dictionary; diff --git a/SoObjects/SOGo/NSScanner+BSJSONAdditions.h b/SoObjects/SOGo/NSScanner+BSJSONAdditions.h index 1505c9228..88059178e 100644 --- a/SoObjects/SOGo/NSScanner+BSJSONAdditions.h +++ b/SoObjects/SOGo/NSScanner+BSJSONAdditions.h @@ -45,7 +45,7 @@ extern NSString *jsonNullString; @interface NSScanner (PrivateBSJSONAdditions) -- (BOOL)scanJSONObject:(NSDictionary **)dictionary; +- (BOOL)scanJSONObject:(NSMutableDictionary **)dictionary; - (BOOL)scanJSONArray:(NSArray **)array; - (BOOL)scanJSONString:(NSString **)string; - (BOOL)scanJSONValue:(id *)value; diff --git a/SoObjects/SOGo/NSScanner+BSJSONAdditions.m b/SoObjects/SOGo/NSScanner+BSJSONAdditions.m index d1af2b006..b23138f30 100644 --- a/SoObjects/SOGo/NSScanner+BSJSONAdditions.m +++ b/SoObjects/SOGo/NSScanner+BSJSONAdditions.m @@ -48,7 +48,7 @@ NSString *jsonNullString = @"null"; @implementation NSScanner (PrivateBSJSONAdditions) -- (BOOL)scanJSONObject:(NSDictionary **)dictionary +- (BOOL)scanJSONObject:(NSMutableDictionary **)dictionary { //[self setCharactersToBeSkipped:nil]; From 7e03b255fe56040bb68e94f960dac93ef4f24bd5 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 18 Nov 2009 23:16:15 +0000 Subject: [PATCH 5/5] Monotone-Parent: d656a1a3c9e97c1b1a23a7959821aa3c54780d86 Monotone-Revision: 8b5b324a1c2f984ac4755fedfc3bf7a66169a6af Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2009-11-18T23:16:15 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 4 ++++ SoObjects/SOGo/NSString+Utilities.h | 2 ++ SoObjects/SOGo/NSString+Utilities.m | 11 +++++++++++ 3 files changed, 17 insertions(+) diff --git a/ChangeLog b/ChangeLog index 1d74e93ed..02be841d1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2009-11-18 Wolfgang Sourdeau + * SoObjects/SOGo/NSString+Utilities.m (-isJSONString): new utility + method that determines whether the current string is a json + document. + * SoObjects/SOGo/NSDictionary+BSJSONAdditions.m (+dictionaryWithJSONString:): this constructor now explicitly returns an NSMutableDictionary to avoid messing with mutable diff --git a/SoObjects/SOGo/NSString+Utilities.h b/SoObjects/SOGo/NSString+Utilities.h index 1b29c1df2..7b5b9d5ff 100644 --- a/SoObjects/SOGo/NSString+Utilities.h +++ b/SoObjects/SOGo/NSString+Utilities.h @@ -65,6 +65,8 @@ // LDIF - (BOOL) _isLDIFSafe; +- (BOOL) isJSONString; + @end #endif /* NSSTRING_URL_H */ diff --git a/SoObjects/SOGo/NSString+Utilities.m b/SoObjects/SOGo/NSString+Utilities.m index 792ea6a0b..2c032cba8 100644 --- a/SoObjects/SOGo/NSString+Utilities.m +++ b/SoObjects/SOGo/NSString+Utilities.m @@ -30,6 +30,7 @@ #import #import "NSArray+Utilities.h" +#import "NSDictionary+BSJSONAdditions.h" #import "NSDictionary+URL.h" #import "NSString+Utilities.h" @@ -422,4 +423,14 @@ static NSMutableCharacterSet *safeLDIFStartChars = nil; return rc; } +- (BOOL) isJSONString +{ + NSDictionary *jsonData; + +#warning this method is a quick and dirty way of detecting the file-format + jsonData = [NSDictionary dictionaryWithJSONString: self]; + + return (jsonData != nil); +} + @end