From b061047eb9b5c3e68bf81b0ec476e6e6023152c5 Mon Sep 17 00:00:00 2001 From: helge Date: Wed, 29 Sep 2004 23:24:45 +0000 Subject: [PATCH] fixed libFoundation vs Cocoa issue git-svn-id: http://svn.opengroupware.org/SOGo/trunk@335 d1b88da0-ebda-0310-925b-ed51d893ca5b --- SOGo/SoObjects/Mailer/ChangeLog | 8 +++++ SOGo/SoObjects/Mailer/SOGoMailBaseObject.m | 22 ++++++++++++-- SOGo/SoObjects/Mailer/SOGoMailManager.m | 35 ++++++++++++++++++---- SOGo/SoObjects/Mailer/common.h | 1 + 4 files changed, 58 insertions(+), 8 deletions(-) diff --git a/SOGo/SoObjects/Mailer/ChangeLog b/SOGo/SoObjects/Mailer/ChangeLog index 158de732..1c64918b 100644 --- a/SOGo/SoObjects/Mailer/ChangeLog +++ b/SOGo/SoObjects/Mailer/ChangeLog @@ -1,3 +1,11 @@ +2004-09-30 Helge Hess + + * v0.9.16 + + * SOGoMailBaseObject.m: improved debug logging + + * SOGoMailManager.m: fixed an Apple/libFoundation incompatibility + 2004-09-29 Helge Hess * SOGoMailManager.m: minor improvement to error logging (v0.9.15) diff --git a/SOGo/SoObjects/Mailer/SOGoMailBaseObject.m b/SOGo/SoObjects/Mailer/SOGoMailBaseObject.m index 53bffb93..26f02e11 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailBaseObject.m +++ b/SOGo/SoObjects/Mailer/SOGoMailBaseObject.m @@ -28,6 +28,9 @@ @implementation SOGoMailBaseObject +static BOOL debugOn = YES; +static BOOL debugTree = NO; + - (id)initWithImap4URL:(NSURL *)_url inContainer:(id)_container { NSString *n; @@ -219,9 +222,22 @@ } - (id)treeNavigationNodes { - return [[self container] treeNavigationBlockWithActiveChildBlock: - [self treeNavigationBlockForActiveNode] - depth:1]; + id block; + + block = [self treeNavigationBlockForActiveNode]; + if (debugTree) [self logWithFormat:@"own block: %@", block]; + block = [[self container] treeNavigationBlockWithActiveChildBlock:block + depth:1]; + if (debugTree) [self logWithFormat:@" root block: %@", block]; + return block; } +/* debugging */ + +- (NSString *)loggingPrefix { + /* improve perf ... */ + return [NSString stringWithFormat:@"<0x%08X[%@]:%@>", + self, NSStringFromClass([self class]), + [self nameInContainer]]; +} @end /* SOGoMailBaseObject */ diff --git a/SOGo/SoObjects/Mailer/SOGoMailManager.m b/SOGo/SoObjects/Mailer/SOGoMailManager.m index be260354..8973495d 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailManager.m +++ b/SOGo/SoObjects/Mailer/SOGoMailManager.m @@ -56,7 +56,12 @@ static NSTimeInterval PoolScanInterval = 5 * 60; NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; debugOn = [ud boolForKey:@"SOGoEnableIMAP4Debug"]; + debugCache = [ud boolForKey:@"SOGoEnableIMAP4CacheDebug"]; poolingOff = [ud boolForKey:@"SOGoDisableIMAP4Pooling"]; + + if (debugOn) NSLog(@"Note: SOGoEnableIMAP4Debug is enabled!"); + if (poolingOff) NSLog(@"WARNING: IMAP4 connection pooling is disabled!"); + } + (id)defaultMailManager { @@ -143,8 +148,14 @@ static NSTimeInterval PoolScanInterval = 5 * 60; result = [client login:[_url user] password:_pwd]; if (![[result valueForKey:@"result"] boolValue]) { - [self logWithFormat:@"ERROR: IMAP4 login failed! (%@,pwd=%s,%@)", - [_url absoluteString], [_pwd length] > 0 ? "yes" : "no", client]; + [self logWithFormat: + @"ERROR: IMAP4 login failed " + @"(host=%@,user=%@,pwd=%s,url=%@/%@/%@): " + @"%@", + [_url host], [_url user], [_pwd length] > 0 ? "yes" : "no", + [_url absoluteString], [_url baseURL], + NSStringFromClass([[_url baseURL] class]), + client]; return nil; } @@ -226,15 +237,24 @@ static NSTimeInterval PoolScanInterval = 5 * 60; /* Note: the result is normalized, that is, it contains / as the separator */ folderName = [_url path]; +#if __APPLE__ + /* normalized results already have the / in front on libFoundation?! */ if ([folderName hasPrefix:@"/"]) folderName = [folderName substringFromIndex:1]; +#endif result = [_result valueForKey:@"list"]; /* Cyrus already tells us whether we need to check for children */ flags = [result objectForKey:folderName]; - if ([flags containsObject:@"hasnochildren"]) + if ([flags containsObject:@"hasnochildren"]) { +#if 0 + [self debugWithFormat:@"folder %@ has no children.", folderName]; +#endif return nil; + } + + [self debugWithFormat:@"all keys %@: %@", folderName, [result allKeys]]; names = [self _getDirectChildren:[result allKeys] folderName:folderName]; #if 0 @@ -249,6 +269,9 @@ static NSTimeInterval PoolScanInterval = 5 * 60; SOGoMailConnectionEntry *entry; NGImap4Client *client; NSDictionary *result; + + if (debugOn) + [self debugWithFormat:@"subfolders for URL: %@ ...",[_url absoluteString]]; /* check cache */ @@ -293,8 +316,10 @@ static NSTimeInterval PoolScanInterval = 5 * 60; entry = [self entryForURL:_url]; [entry cacheHierarchyResults:result]; - if (debugCache) - [self logWithFormat:@"cached results in entry %@: %@", entry, result]; + if (debugCache) { + [self logWithFormat:@"cached results in entry %@: 0x%08X(%d)", + entry, result, [result count]]; + } } /* extract list */ diff --git a/SOGo/SoObjects/Mailer/common.h b/SOGo/SoObjects/Mailer/common.h index a03b8b0d..42bb4ab6 100644 --- a/SOGo/SoObjects/Mailer/common.h +++ b/SOGo/SoObjects/Mailer/common.h @@ -21,6 +21,7 @@ // $Id$ #import +#import #if NeXT_Foundation_LIBRARY || COCOA_Foundation_LIBRARY # include -- 2.39.5