diff --git a/ChangeLog b/ChangeLog index 3a5ea7823..02be841d1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +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 + 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 + 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]; 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]; 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 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 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